|
@@ -53,6 +53,12 @@
|
|
|
|
|
|
|
|
%%
|
|
%%
|
|
|
|
|
|
|
|
|
|
+(* Right-recursive list (less efficient then left-recursive list(x), only use
|
|
|
|
|
+ * when followed by left-recursive list to resolve conflicts) *)
|
|
|
|
|
+rlist(x):
|
|
|
|
|
+ | { [] }
|
|
|
|
|
+ | rlist(x) x { $1 @ [$2] }
|
|
|
|
|
+
|
|
|
basic_type:
|
|
basic_type:
|
|
|
| FLOAT { Float }
|
|
| FLOAT { Float }
|
|
|
| INT { Int }
|
|
| INT { Int }
|
|
@@ -116,7 +122,7 @@ param:
|
|
|
Param (ArrayDims (ctype, make_dims dimloc dims), name, loc) }
|
|
Param (ArrayDims (ctype, make_dims dimloc dims), name, loc) }
|
|
|
|
|
|
|
|
fun_body:
|
|
fun_body:
|
|
|
- | var_dec* local_fun_dec* statement* loption(return_statement)
|
|
|
|
|
|
|
+ | rlist(var_dec); local_fun_dec*; statement*; loption(return_statement)
|
|
|
{ VarDecs $1 :: (LocalFuns $2) :: $3 @ $4 }
|
|
{ VarDecs $1 :: (LocalFuns $2) :: $3 @ $4 }
|
|
|
|
|
|
|
|
return_statement:
|
|
return_statement:
|
|
@@ -126,7 +132,7 @@ return_statement:
|
|
|
|
|
|
|
|
(* function: use location of function name *)
|
|
(* function: use location of function name *)
|
|
|
local_fun_dec:
|
|
local_fun_dec:
|
|
|
- hdr=fun_header; LBRACE; body=fun_body; RBRACE
|
|
|
|
|
|
|
+ | hdr=fun_header; LBRACE; body=fun_body; RBRACE
|
|
|
{ let (t, n, p, nameloc) = hdr in
|
|
{ let (t, n, p, nameloc) = hdr in
|
|
|
FunDef (false, t, n, p, Block body, nameloc) }
|
|
FunDef (false, t, n, p, Block body, nameloc) }
|
|
|
|
|
|