Skip to content

Commit 0b26cc9

Browse files
committed
Fix: resolve compilation errors in scanner.c and add missing tokens to scanner.h
1 parent 6bd1545 commit 0b26cc9

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

include/scanner.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ typedef enum {
157157
TOKEN_DECRYPT,
158158
TOKEN_VERIFY,
159159
TOKEN_IDENTITY,
160+
TOKEN_DO,
161+
TOKEN_MATCH,
162+
TOKEN_MUTABLE,
163+
TOKEN_PACKAGE,
164+
TOKEN_VAR,
160165

161166
TOKEN_ERROR,
162167
TOKEN_EOF

src/compiler/lexer/scanner.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,15 @@ static PxTokenType identifierType(Scanner *scanner) {
480480
if (scanner->current - scanner->start > 1) {
481481
switch (scanner->start[1]) {
482482
case 'a': return checkKeyword(scanner, 2, 6, "nitize", TOKEN_SANITIZE); // sanitize
483-
case 'u':
483+
case 't':
484+
if (scanner->current - scanner->start > 2) {
485+
switch (scanner->start[2]) {
486+
case 'a': return checkKeyword(scanner, 3, 3, "tic", TOKEN_STATIC);
487+
case 'r': return checkKeyword(scanner, 3, 3, "uct", TOKEN_STRUCT);
488+
}
489+
}
490+
break;
491+
case 'u':
484492
if (scanner->current - scanner->start > 2) {
485493
if (scanner->start[2] == 'p') {
486494
// super... superpose or super
@@ -489,18 +497,7 @@ static PxTokenType identifierType(Scanner *scanner) {
489497
return checkKeyword(scanner, 2, 3, "per", TOKEN_SUPER);
490498
}
491499
}
492-
break;
493-
if (scanner->current - scanner->start > 2) {
494-
switch (scanner->start[2]) {
495-
case 'a':
496-
return checkKeyword(scanner, 3, 3, "tic", TOKEN_STATIC);
497-
case 'r':
498-
return checkKeyword(scanner, 3, 3, "uct", TOKEN_STRUCT);
499-
}
500-
}
501-
break;
502-
case 'u':
503-
return checkKeyword(scanner, 2, 3, "per", TOKEN_SUPER);
500+
return checkKeyword(scanner, 2, 3, "per", TOKEN_SUPER);
504501
case 'w':
505502
return checkKeyword(scanner, 2, 4, "itch", TOKEN_SWITCH);
506503
}

0 commit comments

Comments
 (0)