feat: run existing ArrayList with imported C allocator
This commit is contained in:
@@ -42,6 +42,8 @@ keywords strmap.StaticStringMap(TokenKind) :: strmap.init([
|
||||
{ "or", .or },
|
||||
{ "mut", .mut },
|
||||
{ "struct", .struct },
|
||||
{ "c_struct", .c_struct },
|
||||
{ "opaque", .opaque },
|
||||
{ "enum", .enum },
|
||||
{ "union", .union },
|
||||
{ "distinct", .distinct },
|
||||
@@ -169,8 +171,9 @@ scan proc(
|
||||
|
||||
if (char == '.' and cursor + 1 < program.len and program[cursor + 1] == '.') {
|
||||
inclusive :: cursor + 2 < program.len and program[cursor + 2] == '='
|
||||
width :: if (inclusive) 3 else 2
|
||||
range_kind :: if (inclusive) .range_inclusive else .range
|
||||
variadic :: cursor + 2 < program.len and program[cursor + 2] == '.'
|
||||
width :: if (inclusive or variadic) 3 else 2
|
||||
range_kind :: if (inclusive) .range_inclusive else if (variadic) .ellipsis else .range
|
||||
try add_token(state, Token{
|
||||
span = make_span(source, cursor, cursor + width),
|
||||
kind = range_kind,
|
||||
|
||||
@@ -150,10 +150,10 @@ scans_ranges_without_consuming_float_dots test {
|
||||
state := init(mem.c_allocator)
|
||||
defer deinit(&state)
|
||||
try scan(&state, "0..10 0..=10 1.5..2.5 |@item, _| ... 1.", &pool, &diagnostic_store)
|
||||
expected [19]TokenKind :: [
|
||||
expected [18]TokenKind :: [
|
||||
.int, .range, .int, .int, .range_inclusive, .int,
|
||||
.float, .range, .float, .pipe, .at, .ident, .comma, .ident, .pipe,
|
||||
.range, .dot, .invalid, .eof,
|
||||
.ellipsis, .invalid, .eof,
|
||||
]
|
||||
try testing.expect_equal(expected.len, state.tokens.items.len)
|
||||
for (expected) |kind, index| try testing.expect_equal(kind, state.tokens.items[index].kind)
|
||||
|
||||
@@ -28,7 +28,9 @@ TokenKind :: enum {
|
||||
defer, errdefer
|
||||
true, false
|
||||
and, or
|
||||
struct, enum, union
|
||||
struct, c_struct
|
||||
opaque
|
||||
enum, union
|
||||
distinct, alias
|
||||
import, test
|
||||
mut
|
||||
@@ -53,7 +55,7 @@ TokenKind :: enum {
|
||||
plus, minus
|
||||
star, slash
|
||||
|
||||
range, range_inclusive
|
||||
range, range_inclusive, ellipsis
|
||||
at, ampersand, caret, dollar
|
||||
question, semicolon
|
||||
pipe
|
||||
|
||||
Reference in New Issue
Block a user