diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-09 21:36:39 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-10-09 21:36:39 -0400 |
commit | 7c7a8b30ea73cc5b402dab217ad6c0a72f601072 (patch) | |
tree | a61a975df32f0deaa316bb4782edaff45736e2aa | |
parent | dcf9840baea42559d1754fde498a8537e86c20a3 (diff) | |
download | roux-7c7a8b30ea73cc5b402dab217ad6c0a72f601072.tar.gz |
start implementing basic function calls
-rw-r--r-- | minic/minic.y | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/minic/minic.y b/minic/minic.y index 1e4ba8a..fbe4f89 100644 --- a/minic/minic.y +++ b/minic/minic.y @@ -286,6 +286,10 @@ expr(Node *n) sr.ctyp = IDIR(INT); break; + case 'C': + die("call not implemented"); + break; + case '@': s0 = expr(n->l); if (KIND(s0.ctyp) != PTR) @@ -508,7 +512,7 @@ mkstmt(int t, void *p1, void *p2, void *p3) %type <u> type %type <s> stmt stmts -%type <n> expr pref post +%type <n> expr pref post arg0 arg1 %% @@ -584,10 +588,18 @@ pref: post post: NUM | STR | IDENT - | '(' expr ')' { $$ = $2; } - | post '[' expr ']' { $$ = mkidx($1, $3); } - | post PP { $$ = mknode('P', $1, 0); } - | post MM { $$ = mknode('M', $1, 0); } + | '(' expr ')' { $$ = $2; } + | IDENT '(' arg0 ')' { $$ = mknode('C', $1, $3); } + | post '[' expr ']' { $$ = mkidx($1, $3); } + | post PP { $$ = mknode('P', $1, 0); } + | post MM { $$ = mknode('M', $1, 0); } + ; + +arg0: arg1 + | { $$ = 0; } + ; +arg1: expr { $$ = mknode(0, $1, 0); } + | arg1 ',' expr { $$ = mknode(0, $1, $3); } ; %% |