|
@@ -54,13 +54,13 @@
|
|
|
%%
|
|
%%
|
|
|
|
|
|
|
|
(* Left-recursive list (use List.rev to obtain original list) *)
|
|
(* Left-recursive list (use List.rev to obtain original list) *)
|
|
|
-lreclist(x):
|
|
|
|
|
- | { [] }
|
|
|
|
|
- | lreclist(x) x { $2 :: $1 }
|
|
|
|
|
|
|
+llist(x):
|
|
|
|
|
+ | { [] }
|
|
|
|
|
+ | llist(x) x { $2 :: $1 }
|
|
|
|
|
|
|
|
(* Shorthand for comma-separated list *)
|
|
(* Shorthand for comma-separated list *)
|
|
|
%inline clist(x):
|
|
%inline clist(x):
|
|
|
- lst=separated_list(COMMA, x)
|
|
|
|
|
|
|
+ | lst=separated_list(COMMA, x)
|
|
|
{ lst }
|
|
{ lst }
|
|
|
|
|
|
|
|
basic_type:
|
|
basic_type:
|
|
@@ -69,7 +69,7 @@ basic_type:
|
|
|
| BOOL { Bool }
|
|
| BOOL { Bool }
|
|
|
|
|
|
|
|
program:
|
|
program:
|
|
|
- decl* EOF
|
|
|
|
|
|
|
+ | decl* EOF
|
|
|
{ Program ($1, loc $startpos $endpos) }
|
|
{ Program ($1, loc $startpos $endpos) }
|
|
|
|
|
|
|
|
decl:
|
|
decl:
|
|
@@ -127,7 +127,7 @@ dimlist:
|
|
|
{ Dim (name, loc $startpos(name) $endpos(name)) :: head }
|
|
{ Dim (name, loc $startpos(name) $endpos(name)) :: head }
|
|
|
|
|
|
|
|
fun_body:
|
|
fun_body:
|
|
|
- | lreclist(var_dec) local_fun_dec* statement* loption(return_statement)
|
|
|
|
|
|
|
+ | llist(var_dec) local_fun_dec* statement* loption(return_statement)
|
|
|
{ VarDecs (List.rev $1) :: (LocalFuns $2) :: $3 @ $4 }
|
|
{ VarDecs (List.rev $1) :: (LocalFuns $2) :: $3 @ $4 }
|
|
|
|
|
|
|
|
return_statement:
|
|
return_statement:
|