diff options
author | kdx <kikoodx@paranoici.org> | 2023-06-15 03:04:15 +0200 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-06-15 03:04:15 +0200 |
commit | 3f00f1d38eb87f02f5e147b1f4b65d55424a1357 (patch) | |
tree | e8986637b2415e3eb2b9b5febd0f30ef840d2c67 /src | |
parent | 69aa1b02d3064813da5d19b13ffef231501d58ca (diff) | |
download | golem-3f00f1d38eb87f02f5e147b1f4b65d55424a1357.tar.gz |
rewrite malloc example
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -92,7 +92,7 @@ is_punct(const char *p) return 2; if (strchr("-+", p[0]) != NULL && p[0] == p[1]) return 2; - if (p[0] == '|' && p[1] == '>') + if (strchr("|=", p[0]) != NULL && p[1] == '>') return 2; return (strchr("+-/*()<>,;{}[]=&^|", p[0]) != NULL); @@ -679,7 +679,7 @@ stmt(Token **rest, Token *tok) return loop_stmt(rest, tok); if (equal(tok, "break")) return break_stmt(rest, tok); - if (equal(tok, "return")) + if (equal(tok, "=>") || equal(tok, "return")) return return_stmt(rest, tok); if (equal(tok, "[")) { int opn = 1; @@ -742,7 +742,10 @@ expr_stmt(Token **rest, Token *tok) static Node * return_stmt(Token **rest, Token *tok) { - tok = skip(tok, "return"); + if (tok->type == TOK_PUNCT) + tok = skip(tok, "=>"); + else + tok = skip(tok, "return"); Node *node; if (equal(tok, ";")) node = new_unary(NOD_RETURN_STMT, new_num(0)); |