add else if, else, and comments

This commit is contained in:
2025-06-03 13:57:49 +01:00
parent 18993a5d7e
commit 604839d324
8 changed files with 122 additions and 44 deletions

View File

@@ -47,6 +47,7 @@ int yywrap(void *) {
"if" { return TOKEN_IF; }
"else if" { return TOKEN_ELSE_IF; }
"else" { return TOKEN_ELSE; }
"while" { return TOKEN_WHILE; }
"forever" { return TOKEN_FOREVER; }
@@ -102,6 +103,8 @@ int yywrap(void *) {
COLUMN_NO += yyleng;
}
#[^\n]* {}
. {
GET_STATE
fprintf(stderr, "%s:%u:%u error: unexpected character '%s'\n", state->path, yylineno, COLUMN_NO+1, yytext);

View File

@@ -39,6 +39,7 @@ typedef enum {
// Keywords
TOKEN_IF,
TOKEN_ELSE_IF,
TOKEN_ELSE,
TOKEN_WHILE,
TOKEN_FOREVER,