Fix grammar - allow empty set of record fields
[tiger.ml.git] / compiler / src / lib / tiger / tiger_parser.mly
index 1bb9388..42470a4 100644 (file)
@@ -1,5 +1,6 @@
 %{
   module Ast = Tiger_absyn
+  module Err = Tiger_error
   module Sym = Tiger_symbol
 
   let pos () =
 
 %%
 
-program: exp EOF { $1 };
+program:
+  | exp EOF { $1 }
+  | error {Err.raise (Err.Invalid_syntax (pos ()))}
+  ;
 
 exp:
   | NIL
@@ -308,6 +312,7 @@ exps:
   ;
 
 rec_fields_bind:
+  |                                 {                                   [] }
   | ID EQ exp                       { (Sym.of_string $1, $3, pos ()) :: [] }
   | ID EQ exp COMMA rec_fields_bind { (Sym.of_string $1, $3, pos ()) :: $5 }
   ;
This page took 0.029442 seconds and 4 git commands to generate.