Add parser tokens, guru meditation on why the AST types don't work
This commit is contained in:
parent
8997155a57
commit
35a59a0867
@ -49,6 +49,7 @@ type kwd_contains = Region.t
|
|||||||
type kwd_down = Region.t
|
type kwd_down = Region.t
|
||||||
type kwd_else = Region.t
|
type kwd_else = Region.t
|
||||||
type kwd_end = Region.t
|
type kwd_end = Region.t
|
||||||
|
type kwd_expr = Region.t
|
||||||
type kwd_for = Region.t
|
type kwd_for = Region.t
|
||||||
type kwd_from = Region.t
|
type kwd_from = Region.t
|
||||||
type kwd_function = Region.t
|
type kwd_function = Region.t
|
||||||
@ -210,19 +211,29 @@ and type_tuple = (type_expr, comma) nsepseq par reg
|
|||||||
|
|
||||||
(* Function and procedure declarations *)
|
(* Function and procedure declarations *)
|
||||||
|
|
||||||
and fun_decl = {
|
and fun_decl =
|
||||||
kwd_function : kwd_function;
|
BlockFun of {
|
||||||
name : variable;
|
kwd_function : kwd_function;
|
||||||
param : parameters;
|
name : variable;
|
||||||
colon : colon;
|
param : parameters;
|
||||||
ret_type : type_expr;
|
colon : colon;
|
||||||
kwd_is : kwd_is;
|
ret_type : type_expr;
|
||||||
local_decls : local_decl list;
|
kwd_is : kwd_is;
|
||||||
block : block reg;
|
local_decls : local_decl list;
|
||||||
kwd_with : kwd_with;
|
block : block reg;
|
||||||
return : expr;
|
kwd_with : kwd_with;
|
||||||
terminator : semi option
|
return : expr;
|
||||||
}
|
terminator : semi option }
|
||||||
|
| BlocklessFun of
|
||||||
|
{ kwd_function : kwd_function;
|
||||||
|
name : variable;
|
||||||
|
param : parameters;
|
||||||
|
colon : colon;
|
||||||
|
ret_type : type_expr;
|
||||||
|
kwd_is : kwd_is;
|
||||||
|
kwd_expr : kwd_expr;
|
||||||
|
return : expr;
|
||||||
|
terminator : semi option }
|
||||||
|
|
||||||
and parameters = (param_decl, semi) nsepseq par reg
|
and parameters = (param_decl, semi) nsepseq par reg
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ type kwd_contains = Region.t
|
|||||||
type kwd_down = Region.t
|
type kwd_down = Region.t
|
||||||
type kwd_else = Region.t
|
type kwd_else = Region.t
|
||||||
type kwd_end = Region.t
|
type kwd_end = Region.t
|
||||||
|
type kwd_expr = Region.t
|
||||||
type kwd_for = Region.t
|
type kwd_for = Region.t
|
||||||
type kwd_from = Region.t
|
type kwd_from = Region.t
|
||||||
type kwd_function = Region.t
|
type kwd_function = Region.t
|
||||||
@ -201,19 +202,29 @@ and type_tuple = (type_expr, comma) nsepseq par reg
|
|||||||
|
|
||||||
(* Function declarations *)
|
(* Function declarations *)
|
||||||
|
|
||||||
and fun_decl = {
|
and fun_decl =
|
||||||
kwd_function : kwd_function;
|
BlockFun of {
|
||||||
name : variable;
|
kwd_function : kwd_function;
|
||||||
param : parameters;
|
name : variable;
|
||||||
colon : colon;
|
param : parameters;
|
||||||
ret_type : type_expr;
|
colon : colon;
|
||||||
kwd_is : kwd_is;
|
ret_type : type_expr;
|
||||||
local_decls : local_decl list;
|
kwd_is : kwd_is;
|
||||||
block : block reg;
|
local_decls : local_decl list;
|
||||||
kwd_with : kwd_with;
|
block : block reg;
|
||||||
return : expr;
|
kwd_with : kwd_with;
|
||||||
terminator : semi option
|
return : expr;
|
||||||
}
|
terminator : semi option }
|
||||||
|
| BlocklessFun of
|
||||||
|
{ kwd_function : kwd_function;
|
||||||
|
name : variable;
|
||||||
|
param : parameters;
|
||||||
|
colon : colon;
|
||||||
|
ret_type : type_expr;
|
||||||
|
kwd_is : kwd_is;
|
||||||
|
kwd_expr : kwd_expr;
|
||||||
|
return : expr;
|
||||||
|
terminator : semi option }
|
||||||
|
|
||||||
and parameters = (param_decl, semi) nsepseq par reg
|
and parameters = (param_decl, semi) nsepseq par reg
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
%token <Region.t> Contains (* "contains" *)
|
%token <Region.t> Contains (* "contains" *)
|
||||||
%token <Region.t> Else (* "else" *)
|
%token <Region.t> Else (* "else" *)
|
||||||
%token <Region.t> End (* "end" *)
|
%token <Region.t> End (* "end" *)
|
||||||
|
%token <Region.t> Expr (* "expr" *)
|
||||||
%token <Region.t> For (* "for" *)
|
%token <Region.t> For (* "for" *)
|
||||||
%token <Region.t> Function (* "function" *)
|
%token <Region.t> Function (* "function" *)
|
||||||
%token <Region.t> From (* "from" *)
|
%token <Region.t> From (* "from" *)
|
||||||
|
@ -263,7 +263,7 @@ fun_decl:
|
|||||||
kwd_with = $9;
|
kwd_with = $9;
|
||||||
return = $10;
|
return = $10;
|
||||||
terminator = $11}
|
terminator = $11}
|
||||||
in {region; value}}
|
in BlockFun {region; value}}
|
||||||
| Function fun_name parameters COLON type_expr Is
|
| Function fun_name parameters COLON type_expr Is
|
||||||
Expr expr option(SEMI) {
|
Expr expr option(SEMI) {
|
||||||
let stop =
|
let stop =
|
||||||
@ -279,10 +279,10 @@ fun_decl:
|
|||||||
ret_type = $5;
|
ret_type = $5;
|
||||||
kwd_is = $6;
|
kwd_is = $6;
|
||||||
kwd_expr = $7;
|
kwd_expr = $7;
|
||||||
expr = $8;
|
return = $8;
|
||||||
terminator = $9;
|
terminator = $9;
|
||||||
}
|
}
|
||||||
in {region; value}}
|
in BlocklessFun {region; value}}
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
par(nsepseq(param_decl,SEMI)) { $1 }
|
par(nsepseq(param_decl,SEMI)) { $1 }
|
||||||
|
Loading…
Reference in New Issue
Block a user