diff options
author | Himbeer <himbeer@disroot.org> | 2024-10-01 11:49:49 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-10-01 13:51:46 +0200 |
commit | e8c3ca08b84e2a462ed461009a5b63cb65e9288f (patch) | |
tree | b69d3c554582c4c58ced05966a275606403b3cc6 | |
parent | 659e0cc1099cd119bcd372928feed340b1d80cb7 (diff) |
Fix unary postfix expressions being expected in absence of operator
This allows the expression parser to return false for non-expressions
instead of terminating the entire parsing procedure with an error,
fixing calls to functions with no parameters not being allowed.
-rw-r--r-- | src/parse.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/parse.c b/src/parse.c index d491e4f..4b938bb 100644 --- a/src/parse.c +++ b/src/parse.c @@ -274,7 +274,12 @@ parse_unarypre_e(struct lexer *lexer, struct unarypre_e *out) out->op = UPR_NONE; } - if (!parse_unarypost_e(lexer, &out->post)) { + bool post_ok = parse_unarypost_e(lexer, &out->post); + if (!post_ok) { + if (out->op == UPR_NONE) { + return false; + } + error(lex_loc(lexer), "syntax error: expected unary postfix expression"); } |