diff options
| author | iamcheeseman <[email protected]> | 2026-04-17 20:06:02 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-04-17 20:06:02 -0400 |
| commit | a4677cf4301f378c6338f2f29408f83f91053516 (patch) | |
| tree | c4b5c69383d8317d0d91fc68be929af8555d95fa /uscript | |
| parent | bdc4806f5ddc90aea8840225fd8993e305b7ad10 (diff) | |
microscript: change ! to not
Diffstat (limited to 'uscript')
| -rw-r--r-- | uscript/lex.c | 7 | ||||
| -rw-r--r-- | uscript/lex.h | 1 | ||||
| -rw-r--r-- | uscript/parser.c | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/uscript/lex.c b/uscript/lex.c index c8218fa..b940cd4 100644 --- a/uscript/lex.c +++ b/uscript/lex.c @@ -312,10 +312,9 @@ struct token symbol_token(struct lexer *lex, char c) match_char(lex, '=') ? TOKEN_EQL : c ); case '!': - return create_token( - lex, - match_char(lex, '=') ? TOKEN_NEQL : c - ); + if (match_char(lex, '=')) + return create_token(lex, TOKEN_NEQL); + break; } // TODO: log unknown character diff --git a/uscript/lex.h b/uscript/lex.h index 2d5035e..58ea353 100644 --- a/uscript/lex.h +++ b/uscript/lex.h @@ -30,6 +30,7 @@ _(MULT_EQL) \ _(NEQL) \ _(NEXT) \ + _(NOT) \ _(NUM) \ _(OR) \ _(PLUS_EQL) \ diff --git a/uscript/parser.c b/uscript/parser.c index 7909f98..dc721d5 100644 --- a/uscript/parser.c +++ b/uscript/parser.c @@ -516,7 +516,7 @@ void parse_unary(struct parser *p) switch (op.kind) { case '-': parser_add_byte(p, BC_NEG); break; - case '!': parser_add_byte(p, BC_NOT); break; + case TOKEN_NOT: parser_add_byte(p, BC_NOT); break; } } @@ -601,7 +601,6 @@ struct expr expressions[] = { ['<'] = {NULL, parse_binary, PREC_COMP}, ['>'] = {NULL, parse_binary, PREC_COMP}, ['='] = {NULL, NULL, PREC_NONE}, - ['!'] = {parse_unary, NULL, PREC_NONE}, [TOKEN_AND] = {NULL, parse_and, PREC_AND}, [TOKEN_BREAK] = {NULL, NULL, PREC_NONE}, [TOKEN_DIV_EQL] = {NULL, NULL, PREC_NONE}, @@ -627,6 +626,7 @@ struct expr expressions[] = { [TOKEN_MULT_EQL] = {NULL, NULL, PREC_NONE}, [TOKEN_NEQL] = {NULL, parse_binary, PREC_EQL}, [TOKEN_NEXT] = {NULL, NULL, PREC_NONE}, + [TOKEN_NOT] = {parse_unary, NULL, PREC_NONE}, [TOKEN_NUM] = {parse_number, NULL, PREC_NONE}, [TOKEN_OR] = {NULL, parse_or, PREC_OR}, [TOKEN_PLUS_EQL] = {NULL, NULL, PREC_NONE}, |
