diff options
Diffstat (limited to 'boot/lex.c')
| -rw-r--r-- | boot/lex.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/boot/lex.c b/boot/lex.c index 37eabcd..30f4071 100644 --- a/boot/lex.c +++ b/boot/lex.c @@ -122,6 +122,10 @@ enum Token_Kind TOKEN_STAR, TOKEN_SLASH, + TOKEN_PLUS_PLUS, + TOKEN_MINUS_MINUS, + TOKEN_STAR_STAR, + TOKEN_AND, TOKEN_OR, TOKEN_EQUAL, @@ -239,6 +243,13 @@ token_kind_to_string(enum Token_Kind kind) case TOKEN_SLASH: return "SLASH"; + case TOKEN_PLUS_PLUS: + return "PLUS_PLUS"; + case TOKEN_MINUS_MINUS: + return "MINUS_MINUS"; + case TOKEN_STAR_STAR: + return "STAR_STAR"; + case TOKEN_AND: return "AND"; case TOKEN_OR: @@ -582,20 +593,28 @@ lexer_symbol_token(struct Lexer* l, struct Lexer_Char current) if (a.got_match) RET{ TOKEN_ASSIGN_CARET, 2 }; RET{ TOKEN_CARET, 1 }; } - // todo: increment, decrement, power case '+': { a = lexer_match_char(l, '='); if (a.got_match) RET{ TOKEN_ASSIGN_PLUS, 2 }; + + a = lexer_match_char(l, '+'); + if (a.got_match) RET{ TOKEN_PLUS_PLUS, 2 }; RET{ TOKEN_PLUS, 1 }; } case '-': { a = lexer_match_char(l, '='); if (a.got_match) RET{ TOKEN_ASSIGN_MINUS, 2 }; + + a = lexer_match_char(l, '-'); + if (a.got_match) RET{ TOKEN_MINUS_MINUS, 2 }; RET{ TOKEN_MINUS, 1 }; } case '*': { a = lexer_match_char(l, '='); if (a.got_match) RET{ TOKEN_ASSIGN_STAR, 2 }; + + a = lexer_match_char(l, '*'); + if (a.got_match) RET{ TOKEN_STAR_STAR, 2 }; RET{ TOKEN_STAR, 1 }; } case '/': { |
