aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--main.c5
-rw-r--r--tests/004.sh7
2 files changed, 12 insertions, 0 deletions
diff --git a/main.c b/main.c
index b177901..e346738 100644
--- a/main.c
+++ b/main.c
@@ -285,6 +285,11 @@ AST* parse_primitive_expr(PARSER* p) {
buf[t->len] = 0;
e->int_value = atoi(buf);
return e;
+ } else if (t->kind == TK_PAREN_L) {
+ next_token(p);
+ AST* e = parse_expr(p);
+ expect(p, TK_PAREN_R);
+ return e;
} else {
fatal_error("parse_expr");
}
diff --git a/tests/004.sh b/tests/004.sh
new file mode 100644
index 0000000..b5ceb16
--- /dev/null
+++ b/tests/004.sh
@@ -0,0 +1,7 @@
+set -e
+
+bash ../../test_exit_code.sh 197 <<'EOF'
+int main() {
+ return (((3+5)/2) + (5*(9-6)) * (5+6*7)) % 256;
+}
+EOF