From: Siraaj Khandkar Date: Mon, 28 May 2018 17:52:36 +0000 (-0400) Subject: Remove stand-alone unit grammar rule X-Git-Url: https://git.xandkar.net/?a=commitdiff_plain;h=b9397ef56c9d24d6a974e93dc4a0eb51872ce90c;p=tiger.ml.git Remove stand-alone unit grammar rule --- diff --git a/tiger/src/lib/tiger/tiger_parser.mly b/tiger/src/lib/tiger/tiger_parser.mly index 4497ce3..27e051d 100644 --- a/tiger/src/lib/tiger/tiger_parser.mly +++ b/tiger/src/lib/tiger/tiger_parser.mly @@ -109,7 +109,7 @@ exp: { sprintf "string[%S]" $1 } - | ID unit + | ID LPAREN RPAREN { let id = $1 in sprintf "fun_call[%s, []]" id @@ -161,9 +161,10 @@ exp: let seq = $4 in sprintf "let[decs[%s], in[seq[%s]]]" decs seq } - | unit + | LPAREN RPAREN { - $1 + (* Perhaps "void"? *) + "unit[]" } seq: @@ -192,18 +193,18 @@ dec: | fundec {$1} fundec: - | FUNCTION ID unit EQ exp + | FUNCTION ID LPAREN RPAREN EQ exp { let id = $2 in - let exp = $5 in - sprintf "fundec[%s, exp[%s]]" id exp + let exp = $6 in + sprintf "fundec[%s, arguments[], exp[%s]]" id exp } | FUNCTION ID LPAREN tyfields RPAREN EQ exp { let id = $2 in let tyfields = $4 in let exp = $7 in - sprintf "fundec[%s, tyfields[%s], exp[%s]]" id tyfields exp + sprintf "fundec[%s, arguments[%s], exp[%s]]" id tyfields exp } | FUNCTION ID LPAREN tyfields RPAREN COLON ID EQ exp { @@ -279,13 +280,6 @@ tyfield: sprintf "tyfield[%s, %s]" id type_id } -/* Perhaps "void"? */ -unit: - | LPAREN RPAREN - { - "unit[]" - } - rec_field_assignments: | ID EQ exp {