summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-06-12 18:43:11 +0200
committerkdx <kikoodx@paranoici.org>2023-06-12 18:43:11 +0200
commit77c272bf67beb30997021947ff8d7fc5cef7b637 (patch)
tree7a49bd0801cecfce164a3d056d1ea930493c6f47 /src
parentc26a76a39a93656b547886acbc96147fe779cffc (diff)
downloadgolem-77c272bf67beb30997021947ff8d7fc5cef7b637.tar.gz
return w/o argument
Diffstat (limited to 'src')
-rw-r--r--src/main.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 9951685..6337b1d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -107,6 +107,14 @@ tokenize(char *p)
continue;
}
+ if (*p == '#') {
+ char *q = p + 1;
+ while (*p != '\n' && *p != '\0') {
+ p += 1;
+ }
+ printf("%.*s\n", (int)(p - q), q);
+ }
+
if (isspace(*p)) {
p++;
continue;
@@ -677,7 +685,11 @@ static Node *
return_stmt(Token **rest, Token *tok)
{
tok = skip(tok, "return");
- Node *const node = new_unary(NOD_RETURN_STMT, expr(&tok, tok));
+ Node *node;
+ if (equal(tok, ";"))
+ node = new_unary(NOD_RETURN_STMT, new_num(0));
+ else
+ node = new_unary(NOD_RETURN_STMT, expr(&tok, tok));
*rest = skip(tok, ";");
return node;
}