summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-04 15:18:23 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-10-04 15:18:27 -0400
commit6b3cbe2e83b2a3278d83945a529552533b39be88 (patch)
treeee8cc1f70b16f7b304af9b974d4aabba1b146c41
parent4beee73fd38818a287c00087d3d1e3cf2a3ccfa5 (diff)
downloadroux-6b3cbe2e83b2a3278d83945a529552533b39be88.tar.gz
parse functions in minic
-rw-r--r--minic/minic.y6
1 files changed, 4 insertions, 2 deletions
diff --git a/minic/minic.y b/minic/minic.y
index c97a4ca..bb9b1d7 100644
--- 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++);
 };