commit 6b3cbe2e83b2a3278d83945a529552533b39be88
parent 4beee73fd38818a287c00087d3d1e3cf2a3ccfa5
Author: Quentin Carbonneaux <quentin.carbonneaux@yale.edu>
Date: Sun, 4 Oct 2015 15:18:23 -0400
parse functions in minic
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/minic/minic.y b/minic/minic.y
@@ -466,17 +466,19 @@ mkstmt(int t, void *p1, void *p2, void *p3)
%%
-prog: init '{' dcls stmts '}'
+prog: prot '{' dcls stmts '}'
{
stmt($4);
fprintf(of, "\tret\n");
+ fprintf(of, "}\n\n");
};
-init:
+prot: IDENT '(' ')'
{
varclr();
lbl = 0;
tmp = 0;
+ fprintf(of, "function %s() {\n", $1->u.v);
fprintf(of, "@l%d\n", lbl++);
};