From 7c7a8b30ea73cc5b402dab217ad6c0a72f601072 Mon Sep 17 00:00:00 2001 From: Quentin Carbonneaux Date: Fri, 9 Oct 2015 21:36:39 -0400 Subject: start implementing basic function calls --- minic/minic.y | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'minic/minic.y') 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 type %type stmt stmts -%type expr pref post +%type 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); } ; %% -- cgit 1.4.1