aboutsummaryrefslogtreecommitdiff
path: root/src/parser.c
diff options
context:
space:
mode:
authorMustafa Quraish <[email protected]>2022-02-05 01:38:34 -0500
committerMustafa Quraish <[email protected]>2022-02-05 08:56:15 -0500
commit81a0df76cbcd46799134e688dabb8dc870da5351 (patch)
treec272607d270b3ae8f1ba95cb6f6b28c9d0bc6075 /src/parser.c
parentMiscellaneous stdlib additions (diff)
downloadcup-81a0df76cbcd46799134e688dabb8dc870da5351.tar.xz
cup-81a0df76cbcd46799134e688dabb8dc870da5351.zip
Add support for some more binary ops: |, &, ^
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/parser.c b/src/parser.c
index 99926d0..9f66060 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -651,8 +651,17 @@ Node *parse_relational(Lexer *lexer) { BINOP_PARSER(parse_additive, is_relationa
bool is_equality_token(TokenType type) { return type == TOKEN_EQ || type == TOKEN_NEQ; }
Node *parse_equality(Lexer *lexer) { BINOP_PARSER(parse_relational, is_equality_token); }
+bool is_and_token(TokenType type) { return type == TOKEN_AMPERSAND; }
+Node *parse_and(Lexer *lexer) { BINOP_PARSER(parse_equality, is_and_token); }
+
+bool is_exclusive_or_token(TokenType type) { return type == TOKEN_CARET; }
+Node *parse_exclusive_or(Lexer *lexer) { BINOP_PARSER(parse_and, is_exclusive_or_token); }
+
+bool is_inclusive_or_token(TokenType type) { return type == TOKEN_BAR; }
+Node *parse_inclusive_or(Lexer *lexer) { BINOP_PARSER(parse_exclusive_or, is_inclusive_or_token); }
+
bool is_logical_and_token(TokenType type) { return type == TOKEN_AND; }
-Node *parse_logical_and(Lexer *lexer) { BINOP_PARSER(parse_equality, is_logical_and_token); }
+Node *parse_logical_and(Lexer *lexer) { BINOP_PARSER(parse_inclusive_or, is_logical_and_token); }
bool is_logical_or_token(TokenType type) { return type == TOKEN_OR; }
Node *parse_logical_or(Lexer *lexer) { BINOP_PARSER(parse_logical_and, is_logical_or_token); }