X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=tiger%2Fsrc%2Flib%2Ftiger%2Ftiger_parser.mly;h=2cd530db084d75f4ebd43aa69de44653bef67a0a;hb=0e2c715d15688b48aba534d8ab9c3a2aec918752;hp=27e051d3d1adebfd5333af2e4537a3a4ce181f9c;hpb=b9397ef56c9d24d6a974e93dc4a0eb51872ce90c;p=tiger.ml.git diff --git a/tiger/src/lib/tiger/tiger_parser.mly b/tiger/src/lib/tiger/tiger_parser.mly index 27e051d..2cd530d 100644 --- a/tiger/src/lib/tiger/tiger_parser.mly +++ b/tiger/src/lib/tiger/tiger_parser.mly @@ -151,15 +151,15 @@ exp: { "break[]" } - | LPAREN seq RPAREN + | LPAREN exps RPAREN { - sprintf "seq[%s]" $2 + sprintf "exps[%s]" $2 } - | LET decs IN seq END + | LET decs IN exps END { let decs = $2 in - let seq = $4 in - sprintf "let[decs[%s], in[seq[%s]]]" decs seq + let exps = $4 in + sprintf "let[decs[%s], in[exps[%s]]]" decs exps } | LPAREN RPAREN { @@ -167,12 +167,12 @@ exp: "unit[]" } -seq: +exps: | exp { sprintf "%s" $1 } - | exp SEMICOLON seq + | exp SEMICOLON exps { sprintf "%s; %s" $1 $3 } @@ -233,32 +233,28 @@ vardec: } tydec: - | TYPE ID EQ ty + | TYPE ID EQ ID { - let type_id = $2 in - let ty = $4 in - sprintf "tydec[%s, %s]" type_id ty - } - -ty: - | ID - { - let type_id = $1 in - sprintf "type[type_id[%S]]" type_id + let type_id_new = $2 in + let type_id_orig = $4 in + sprintf "tydec_alias[from[%s], to[%s]]" type_id_new type_id_orig } - | LBRACE RBRACE + | TYPE ID EQ LBRACE RBRACE { - "record[]" + let type_id = $2 in + sprintf "tydec_empty_record[%s]" type_id } - | LBRACE tyfields RBRACE + | TYPE ID EQ LBRACE tyfields RBRACE { - let tyfields = $2 in - sprintf "record[%s]" tyfields + let type_id = $2 in + let tyfields = $5 in + sprintf "tydec_record[%s, fields[%s]]" type_id tyfields } - | ARRAY OF ID + | TYPE ID EQ ARRAY OF ID { - let type_id = $3 in - sprintf "array_of_type[%s]" type_id + let type_id = $2 in + let element_type_id = $6 in + sprintf "tydec_array[%s, elements_of_type[%s]]" type_id element_type_id } tyfields: