Remove stand-alone ty grammar rule
authorSiraaj Khandkar <siraaj@khandkar.net>
Mon, 28 May 2018 18:05:34 +0000 (14:05 -0400)
committerSiraaj Khandkar <siraaj@khandkar.net>
Mon, 28 May 2018 18:05:34 +0000 (14:05 -0400)
tiger/src/lib/tiger/tiger_parser.mly

index 7ab644a..2cd530d 100644 (file)
@@ -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:
This page took 0.021953 seconds and 4 git commands to generate.