commit ed2af9df22b86d96d8299c08c9074871d1582867
parent 8fed9dbb623791cdd6345ba520ceb3c752a4e399
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Sat, 27 Nov 2021 23:06:31 -0600
paranthetical grouping for expressions
Diffstat:
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/main.c b/main.c
@@ -226,6 +226,13 @@ parseexpr(struct token **tok)
{
struct expr expr = { 0 };
switch ((*tok)->type) {
+ case TOK_LPAREN:
+ *tok = (*tok)->next;
+ size_t ret = parseexpr(tok);
+ expect(*tok, TOK_RPAREN);
+ *tok = (*tok)->next;
+ return ret;
+ break;
case TOK_NAME:
// a function call
if ((*tok)->next && (*tok)->next->type == TOK_LPAREN) {
diff --git a/prog.nc b/prog.nc
@@ -3,6 +3,6 @@ stdout = 0
exit = 60
len1 = 11
len2 = 6
-syscall(write, - 2 1, "hello world", + 1 + 2 + 3 + 4 1)
+syscall(write, stdout, "hello world", (+ 1 (+ 5 5)))
syscall(write, stdout, " world", len2)
syscall(exit, 0)