Refactoring of the parser specification.
The rules [set_injection] and [list_injection] have been unified in a new parametric rule [injection(Kind)]. The rules [unqualified(OP)] and [extended_expr] were refactored too.
This commit is contained in:
parent
45a26826ca
commit
b200239d82
34
AST.ml
34
AST.ml
@ -370,7 +370,7 @@ and set_patch = {
|
|||||||
kwd_patch : kwd_patch;
|
kwd_patch : kwd_patch;
|
||||||
path : path;
|
path : path;
|
||||||
kwd_with : kwd_with;
|
kwd_with : kwd_with;
|
||||||
set_inj : set_injection reg
|
set_inj : injection reg
|
||||||
}
|
}
|
||||||
|
|
||||||
and map_patch = {
|
and map_patch = {
|
||||||
@ -515,10 +515,10 @@ and expr =
|
|||||||
| EPar of expr par reg
|
| EPar of expr par reg
|
||||||
|
|
||||||
and set_expr =
|
and set_expr =
|
||||||
SetInj of set_injection reg
|
SetInj of injection reg
|
||||||
| SetMem of set_membership reg
|
| SetMem of set_membership reg
|
||||||
|
|
||||||
and set_injection = {
|
and injection = {
|
||||||
opening : opening;
|
opening : opening;
|
||||||
elements : (expr, semi) sepseq;
|
elements : (expr, semi) sepseq;
|
||||||
terminator : semi option;
|
terminator : semi option;
|
||||||
@ -591,16 +591,9 @@ and string_expr =
|
|||||||
|
|
||||||
and list_expr =
|
and list_expr =
|
||||||
Cons of cons bin_op reg
|
Cons of cons bin_op reg
|
||||||
| List of list_injection reg
|
| List of injection reg
|
||||||
| Nil of nil par reg
|
| Nil of nil par reg
|
||||||
|
|
||||||
and list_injection = {
|
|
||||||
opening : opening;
|
|
||||||
elements : (expr, semi) sepseq;
|
|
||||||
terminator : semi option;
|
|
||||||
closing : closing
|
|
||||||
}
|
|
||||||
|
|
||||||
and nil = {
|
and nil = {
|
||||||
nil : kwd_nil;
|
nil : kwd_nil;
|
||||||
colon : colon;
|
colon : colon;
|
||||||
@ -1237,7 +1230,7 @@ and print_map_expr = function
|
|||||||
| MapInj inj -> print_map_injection inj
|
| MapInj inj -> print_map_injection inj
|
||||||
|
|
||||||
and print_set_expr = function
|
and print_set_expr = function
|
||||||
SetInj inj -> print_set_injection inj
|
SetInj inj -> print_injection "set" inj
|
||||||
| SetMem mem -> print_set_membership mem
|
| SetMem mem -> print_set_membership mem
|
||||||
|
|
||||||
and print_set_membership {value; _} =
|
and print_set_membership {value; _} =
|
||||||
@ -1308,7 +1301,7 @@ and print_string_expr = function
|
|||||||
and print_list_expr = function
|
and print_list_expr = function
|
||||||
Cons {value = {arg1; op; arg2}; _} ->
|
Cons {value = {arg1; op; arg2}; _} ->
|
||||||
print_expr arg1; print_token op "#"; print_expr arg2
|
print_expr arg1; print_token op "#"; print_expr arg2
|
||||||
| List e -> print_list_injection e
|
| List e -> print_injection "list" e
|
||||||
| Nil e -> print_nil e
|
| Nil e -> print_nil e
|
||||||
|
|
||||||
and print_constr_expr = function
|
and print_constr_expr = function
|
||||||
@ -1357,7 +1350,7 @@ and print_set_patch node =
|
|||||||
print_token kwd_patch "patch";
|
print_token kwd_patch "patch";
|
||||||
print_path path;
|
print_path path;
|
||||||
print_token kwd_with "with";
|
print_token kwd_with "with";
|
||||||
print_set_injection set_inj
|
print_injection "set" set_inj
|
||||||
|
|
||||||
and print_map_patch node =
|
and print_map_patch node =
|
||||||
let {kwd_patch; path; kwd_with; map_inj} = node in
|
let {kwd_patch; path; kwd_with; map_inj} = node in
|
||||||
@ -1389,9 +1382,9 @@ and print_map_injection {value; _} =
|
|||||||
print_terminator terminator;
|
print_terminator terminator;
|
||||||
print_closing closing
|
print_closing closing
|
||||||
|
|
||||||
and print_set_injection {value; _} =
|
and print_injection kwd {value; _} =
|
||||||
let {opening; elements; terminator; closing} : set_injection = value in
|
let {opening; elements; terminator; closing} : injection = value in
|
||||||
print_opening "set" opening;
|
print_opening kwd opening;
|
||||||
print_sepseq ";" print_expr elements;
|
print_sepseq ";" print_expr elements;
|
||||||
print_terminator terminator;
|
print_terminator terminator;
|
||||||
print_closing closing
|
print_closing closing
|
||||||
@ -1421,13 +1414,6 @@ and print_tuple_inj {value; _} =
|
|||||||
print_nsepseq "," print_expr inside;
|
print_nsepseq "," print_expr inside;
|
||||||
print_token rpar ")"
|
print_token rpar ")"
|
||||||
|
|
||||||
and print_list_injection {value; _} =
|
|
||||||
let {opening; elements; terminator; closing} : list_injection = value in
|
|
||||||
print_opening "list" opening;
|
|
||||||
print_sepseq ";" print_expr elements;
|
|
||||||
print_terminator terminator;
|
|
||||||
print_closing closing
|
|
||||||
|
|
||||||
and print_nil {value; _} =
|
and print_nil {value; _} =
|
||||||
let {lpar; inside; rpar} = value in
|
let {lpar; inside; rpar} = value in
|
||||||
let {nil; colon; list_type} = inside in
|
let {nil; colon; list_type} = inside in
|
||||||
|
15
AST.mli
15
AST.mli
@ -354,7 +354,7 @@ and set_patch = {
|
|||||||
kwd_patch : kwd_patch;
|
kwd_patch : kwd_patch;
|
||||||
path : path;
|
path : path;
|
||||||
kwd_with : kwd_with;
|
kwd_with : kwd_with;
|
||||||
set_inj : set_injection reg
|
set_inj : injection reg
|
||||||
}
|
}
|
||||||
|
|
||||||
and map_patch = {
|
and map_patch = {
|
||||||
@ -499,10 +499,10 @@ and expr =
|
|||||||
| EPar of expr par reg
|
| EPar of expr par reg
|
||||||
|
|
||||||
and set_expr =
|
and set_expr =
|
||||||
SetInj of set_injection reg
|
SetInj of injection reg
|
||||||
| SetMem of set_membership reg
|
| SetMem of set_membership reg
|
||||||
|
|
||||||
and set_injection = {
|
and injection = {
|
||||||
opening : opening;
|
opening : opening;
|
||||||
elements : (expr, semi) sepseq;
|
elements : (expr, semi) sepseq;
|
||||||
terminator : semi option;
|
terminator : semi option;
|
||||||
@ -575,16 +575,9 @@ and string_expr =
|
|||||||
|
|
||||||
and list_expr =
|
and list_expr =
|
||||||
Cons of cons bin_op reg
|
Cons of cons bin_op reg
|
||||||
| List of list_injection reg
|
| List of injection reg
|
||||||
| Nil of nil par reg
|
| Nil of nil par reg
|
||||||
|
|
||||||
and list_injection = {
|
|
||||||
opening : opening;
|
|
||||||
elements : (expr, semi) sepseq;
|
|
||||||
terminator : semi option;
|
|
||||||
closing : closing
|
|
||||||
}
|
|
||||||
|
|
||||||
and nil = {
|
and nil = {
|
||||||
nil : kwd_nil;
|
nil : kwd_nil;
|
||||||
colon : colon;
|
colon : colon;
|
||||||
|
227
Parser.mly
227
Parser.mly
@ -154,8 +154,7 @@ type_expr:
|
|||||||
cartesian:
|
cartesian:
|
||||||
nsepseq(core_type,TIMES) {
|
nsepseq(core_type,TIMES) {
|
||||||
let region = nsepseq_to_region type_expr_to_region $1
|
let region = nsepseq_to_region type_expr_to_region $1
|
||||||
in {region; value=$1}
|
in {region; value=$1}}
|
||||||
}
|
|
||||||
|
|
||||||
core_type:
|
core_type:
|
||||||
type_name {
|
type_name {
|
||||||
@ -185,8 +184,7 @@ core_type:
|
|||||||
in TApp {region=total; value = type_constr, tuple}
|
in TApp {region=total; value = type_constr, tuple}
|
||||||
}
|
}
|
||||||
| par(type_expr) {
|
| par(type_expr) {
|
||||||
TPar $1
|
TPar $1}
|
||||||
}
|
|
||||||
|
|
||||||
type_tuple:
|
type_tuple:
|
||||||
par(nsepseq(type_expr,COMMA)) { $1 }
|
par(nsepseq(type_expr,COMMA)) { $1 }
|
||||||
@ -194,15 +192,13 @@ type_tuple:
|
|||||||
sum_type:
|
sum_type:
|
||||||
nsepseq(variant,VBAR) {
|
nsepseq(variant,VBAR) {
|
||||||
let region = nsepseq_to_region (fun x -> x.region) $1
|
let region = nsepseq_to_region (fun x -> x.region) $1
|
||||||
in {region; value = $1}
|
in {region; value = $1}}
|
||||||
}
|
|
||||||
|
|
||||||
variant:
|
variant:
|
||||||
Constr Of cartesian {
|
Constr Of cartesian {
|
||||||
let region = cover $1.region $3.region
|
let region = cover $1.region $3.region
|
||||||
and value = {constr = $1; kwd_of = $2; product = $3}
|
and value = {constr = $1; kwd_of = $2; product = $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
record_type:
|
record_type:
|
||||||
Record series(field_decl,End) {
|
Record series(field_decl,End) {
|
||||||
@ -213,16 +209,14 @@ record_type:
|
|||||||
field_decls = first, others;
|
field_decls = first, others;
|
||||||
terminator;
|
terminator;
|
||||||
closing}
|
closing}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
field_decl:
|
field_decl:
|
||||||
field_name COLON type_expr {
|
field_name COLON type_expr {
|
||||||
let stop = type_expr_to_region $3 in
|
let stop = type_expr_to_region $3 in
|
||||||
let region = cover $1.region stop
|
let region = cover $1.region stop
|
||||||
and value = {field_name = $1; colon = $2; field_type = $3}
|
and value = {field_name = $1; colon = $2; field_type = $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
(* Function and procedure declarations *)
|
(* Function and procedure declarations *)
|
||||||
|
|
||||||
@ -240,8 +234,8 @@ fun_decl:
|
|||||||
match $11 with
|
match $11 with
|
||||||
Some region -> region
|
Some region -> region
|
||||||
| None -> expr_to_region $10 in
|
| None -> expr_to_region $10 in
|
||||||
let region = cover $1 stop in
|
let region = cover $1 stop
|
||||||
let value = {
|
and value = {
|
||||||
kwd_function = $1;
|
kwd_function = $1;
|
||||||
name = $2;
|
name = $2;
|
||||||
param = $3;
|
param = $3;
|
||||||
@ -253,8 +247,7 @@ fun_decl:
|
|||||||
kwd_with = $9;
|
kwd_with = $9;
|
||||||
return = $10;
|
return = $10;
|
||||||
terminator = $11}
|
terminator = $11}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
entry_decl:
|
entry_decl:
|
||||||
Entrypoint fun_name entry_params COLON type_expr Is
|
Entrypoint fun_name entry_params COLON type_expr Is
|
||||||
@ -265,8 +258,8 @@ entry_decl:
|
|||||||
match $11 with
|
match $11 with
|
||||||
Some region -> region
|
Some region -> region
|
||||||
| None -> expr_to_region $10 in
|
| None -> expr_to_region $10 in
|
||||||
let region = cover $1 stop in
|
let region = cover $1 stop
|
||||||
let value = {
|
and value = {
|
||||||
kwd_entrypoint = $1;
|
kwd_entrypoint = $1;
|
||||||
name = $2;
|
name = $2;
|
||||||
param = $3;
|
param = $3;
|
||||||
@ -278,8 +271,7 @@ entry_decl:
|
|||||||
kwd_with = $9;
|
kwd_with = $9;
|
||||||
return = $10;
|
return = $10;
|
||||||
terminator = $11}
|
terminator = $11}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
entry_params:
|
entry_params:
|
||||||
par(nsepseq(entry_param_decl,SEMI)) { $1 }
|
par(nsepseq(entry_param_decl,SEMI)) { $1 }
|
||||||
@ -293,8 +285,8 @@ proc_decl:
|
|||||||
match $7 with
|
match $7 with
|
||||||
Some region -> region
|
Some region -> region
|
||||||
| None -> $6.region in
|
| None -> $6.region in
|
||||||
let region = cover $1 stop in
|
let region = cover $1 stop
|
||||||
let value = {
|
and value = {
|
||||||
kwd_procedure = $1;
|
kwd_procedure = $1;
|
||||||
name = $2;
|
name = $2;
|
||||||
param = $3;
|
param = $3;
|
||||||
@ -302,8 +294,7 @@ proc_decl:
|
|||||||
local_decls = $5;
|
local_decls = $5;
|
||||||
block = $6;
|
block = $6;
|
||||||
terminator = $7}
|
terminator = $7}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
par(nsepseq(param_decl,SEMI)) { $1 }
|
par(nsepseq(param_decl,SEMI)) { $1 }
|
||||||
@ -327,8 +318,7 @@ param_decl:
|
|||||||
var = $2;
|
var = $2;
|
||||||
colon = $3;
|
colon = $3;
|
||||||
param_type = $4}
|
param_type = $4}
|
||||||
in ParamConst {region; value}
|
in ParamConst {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
entry_param_decl:
|
entry_param_decl:
|
||||||
param_decl {
|
param_decl {
|
||||||
@ -344,14 +334,12 @@ entry_param_decl:
|
|||||||
var = $2;
|
var = $2;
|
||||||
colon = $3;
|
colon = $3;
|
||||||
storage_type = $4}
|
storage_type = $4}
|
||||||
in EntryStore {region; value}
|
in EntryStore {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
param_type:
|
param_type:
|
||||||
nsepseq(core_param_type,TIMES) {
|
nsepseq(core_param_type,TIMES) {
|
||||||
let region = nsepseq_to_region type_expr_to_region $1
|
let region = nsepseq_to_region type_expr_to_region $1
|
||||||
in TProd {region; value=$1}
|
in TProd {region; value=$1}}
|
||||||
}
|
|
||||||
|
|
||||||
core_param_type:
|
core_param_type:
|
||||||
type_name {
|
type_name {
|
||||||
@ -359,8 +347,7 @@ core_param_type:
|
|||||||
}
|
}
|
||||||
| type_name type_tuple {
|
| type_name type_tuple {
|
||||||
let region = cover $1.region $2.region
|
let region = cover $1.region $2.region
|
||||||
in TApp {region; value = $1,$2}
|
in TApp {region; value = $1,$2}}
|
||||||
}
|
|
||||||
|
|
||||||
block:
|
block:
|
||||||
Begin series(instruction,End) {
|
Begin series(instruction,End) {
|
||||||
@ -391,15 +378,11 @@ local_decl:
|
|||||||
|
|
||||||
unqualified_decl(OP):
|
unqualified_decl(OP):
|
||||||
var COLON type_expr OP extended_expr option(SEMI) {
|
var COLON type_expr OP extended_expr option(SEMI) {
|
||||||
let stop = match $6 with
|
let init, region =
|
||||||
Some region -> region
|
match $5 with
|
||||||
| None -> $5.region in
|
`Expr e -> e, expr_to_region e
|
||||||
let init =
|
|
||||||
match $5.value with
|
|
||||||
`Expr e -> e
|
|
||||||
| `EList kwd_nil ->
|
| `EList kwd_nil ->
|
||||||
let region = $5.region
|
let value = {
|
||||||
and value = {
|
|
||||||
nil = kwd_nil;
|
nil = kwd_nil;
|
||||||
colon = Region.ghost;
|
colon = Region.ghost;
|
||||||
list_type = $3} in
|
list_type = $3} in
|
||||||
@ -407,7 +390,7 @@ unqualified_decl(OP):
|
|||||||
lpar = Region.ghost;
|
lpar = Region.ghost;
|
||||||
inside = value;
|
inside = value;
|
||||||
rpar = Region.ghost} in
|
rpar = Region.ghost} in
|
||||||
EList (Nil {region; value})
|
EList (Nil {region=kwd_nil; value}), kwd_nil
|
||||||
| `ENone region ->
|
| `ENone region ->
|
||||||
let value = {
|
let value = {
|
||||||
lpar = Region.ghost;
|
lpar = Region.ghost;
|
||||||
@ -416,16 +399,18 @@ unqualified_decl(OP):
|
|||||||
colon = Region.ghost;
|
colon = Region.ghost;
|
||||||
opt_type = $3};
|
opt_type = $3};
|
||||||
rpar = Region.ghost}
|
rpar = Region.ghost}
|
||||||
in EConstr (NoneExpr {region; value})
|
in EConstr (NoneExpr {region; value}), region in
|
||||||
in $1, $2, $3, $4, init, $6, stop
|
let stop = match $6 with
|
||||||
}
|
Some region -> region
|
||||||
|
| None -> region
|
||||||
|
in $1, $2, $3, $4, init, $6, stop}
|
||||||
|
|
||||||
const_decl:
|
const_decl:
|
||||||
Const unqualified_decl(EQUAL) {
|
Const unqualified_decl(EQUAL) {
|
||||||
let name, colon, const_type, equal,
|
let name, colon, const_type, equal,
|
||||||
init, terminator, stop = $2 in
|
init, terminator, stop = $2 in
|
||||||
let region = cover $1 stop in
|
let region = cover $1 stop
|
||||||
let value = {
|
and value = {
|
||||||
kwd_const = $1;
|
kwd_const = $1;
|
||||||
name;
|
name;
|
||||||
colon;
|
colon;
|
||||||
@ -433,15 +418,14 @@ const_decl:
|
|||||||
equal;
|
equal;
|
||||||
init;
|
init;
|
||||||
terminator}
|
terminator}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
var_decl:
|
var_decl:
|
||||||
Var unqualified_decl(ASS) {
|
Var unqualified_decl(ASS) {
|
||||||
let name, colon, var_type, assign,
|
let name, colon, var_type, assign,
|
||||||
init, terminator, stop = $2 in
|
init, terminator, stop = $2 in
|
||||||
let region = cover $1 stop in
|
let region = cover $1 stop
|
||||||
let value = {
|
and value = {
|
||||||
kwd_var = $1;
|
kwd_var = $1;
|
||||||
name;
|
name;
|
||||||
colon;
|
colon;
|
||||||
@ -449,13 +433,12 @@ var_decl:
|
|||||||
assign;
|
assign;
|
||||||
init;
|
init;
|
||||||
terminator}
|
terminator}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
extended_expr:
|
extended_expr:
|
||||||
expr { {region = expr_to_region $1; value = `Expr $1} }
|
expr { `Expr $1 }
|
||||||
| Nil { {region = $1; value = `EList $1} }
|
| Nil { `EList $1 }
|
||||||
| C_None { {region = $1; value = `ENone $1} }
|
| C_None { `ENone $1 }
|
||||||
|
|
||||||
instruction:
|
instruction:
|
||||||
single_instr { Single $1 }
|
single_instr { Single $1 }
|
||||||
@ -484,8 +467,7 @@ set_remove:
|
|||||||
kwd_from = $3;
|
kwd_from = $3;
|
||||||
kwd_set = $4;
|
kwd_set = $4;
|
||||||
set = $5}
|
set = $5}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
map_remove:
|
map_remove:
|
||||||
Remove expr From Map path {
|
Remove expr From Map path {
|
||||||
@ -496,19 +478,17 @@ map_remove:
|
|||||||
kwd_from = $3;
|
kwd_from = $3;
|
||||||
kwd_map = $4;
|
kwd_map = $4;
|
||||||
map = $5}
|
map = $5}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
set_patch:
|
set_patch:
|
||||||
Patch path With set_injection {
|
Patch path With injection(Set) {
|
||||||
let region = cover $1 $4.region in
|
let region = cover $1 $4.region in
|
||||||
let value = {
|
let value = {
|
||||||
kwd_patch = $1;
|
kwd_patch = $1;
|
||||||
path = $2;
|
path = $2;
|
||||||
kwd_with = $3;
|
kwd_with = $3;
|
||||||
set_inj = $4}
|
set_inj = $4}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
map_patch:
|
map_patch:
|
||||||
Patch path With map_injection {
|
Patch path With map_injection {
|
||||||
@ -518,50 +498,46 @@ map_patch:
|
|||||||
path = $2;
|
path = $2;
|
||||||
kwd_with = $3;
|
kwd_with = $3;
|
||||||
map_inj = $4}
|
map_inj = $4}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
(* Note: [list_injection] and [set_injection] could be merged. *)
|
injection(Kind):
|
||||||
|
Kind series(expr,End) {
|
||||||
set_injection:
|
|
||||||
Set series(expr,End) {
|
|
||||||
let first, (others, terminator, closing) = $2 in
|
let first, (others, terminator, closing) = $2 in
|
||||||
let region = cover $1 closing
|
let region = cover $1 closing
|
||||||
and value : set_injection = {
|
and value = {
|
||||||
opening = Kwd $1;
|
opening = Kwd $1;
|
||||||
elements = Some (first, others);
|
elements = Some (first, others);
|
||||||
terminator;
|
terminator;
|
||||||
closing = End closing}
|
closing = End closing}
|
||||||
in {region; value}
|
in {region; value}
|
||||||
}
|
}
|
||||||
| Set End {
|
| Kind End {
|
||||||
let region = cover $1 $2
|
let region = cover $1 $2
|
||||||
and value : set_injection = {
|
and value = {
|
||||||
opening = Kwd $1;
|
opening = Kwd $1;
|
||||||
elements = None;
|
elements = None;
|
||||||
terminator = None;
|
terminator = None;
|
||||||
closing = End $2}
|
closing = End $2}
|
||||||
in {region; value}
|
in {region; value}
|
||||||
}
|
}
|
||||||
| Set LBRACKET series(expr,RBRACKET) {
|
| Kind LBRACKET series(expr,RBRACKET) {
|
||||||
let first, (others, terminator, closing) = $3 in
|
let first, (others, terminator, closing) = $3 in
|
||||||
let region = cover $1 closing
|
let region = cover $1 closing
|
||||||
and value : set_injection = {
|
and value = {
|
||||||
opening = KwdBracket ($1,$2);
|
opening = KwdBracket ($1,$2);
|
||||||
elements = Some (first, others);
|
elements = Some (first, others);
|
||||||
terminator;
|
terminator;
|
||||||
closing = RBracket closing}
|
closing = RBracket closing}
|
||||||
in {region; value}
|
in {region; value}
|
||||||
}
|
}
|
||||||
| Set LBRACKET RBRACKET {
|
| Kind LBRACKET RBRACKET {
|
||||||
let region = cover $1 $3
|
let region = cover $1 $3
|
||||||
and value : set_injection = {
|
and value = {
|
||||||
opening = KwdBracket ($1,$2);
|
opening = KwdBracket ($1,$2);
|
||||||
elements = None;
|
elements = None;
|
||||||
terminator = None;
|
terminator = None;
|
||||||
closing = RBracket $3}
|
closing = RBracket $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
map_injection:
|
map_injection:
|
||||||
Map series(binding,End) {
|
Map series(binding,End) {
|
||||||
@ -600,8 +576,7 @@ map_injection:
|
|||||||
bindings = None;
|
bindings = None;
|
||||||
terminator = None;
|
terminator = None;
|
||||||
closing = RBracket $3}
|
closing = RBracket $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
binding:
|
binding:
|
||||||
expr ARROW expr {
|
expr ARROW expr {
|
||||||
@ -612,8 +587,7 @@ binding:
|
|||||||
source = $1;
|
source = $1;
|
||||||
arrow = $2;
|
arrow = $2;
|
||||||
image = $3}
|
image = $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
record_patch:
|
record_patch:
|
||||||
Patch path With record_injection {
|
Patch path With record_injection {
|
||||||
@ -623,8 +597,7 @@ record_patch:
|
|||||||
path = $2;
|
path = $2;
|
||||||
kwd_with = $3;
|
kwd_with = $3;
|
||||||
record_inj = $4}
|
record_inj = $4}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
fail_instr:
|
fail_instr:
|
||||||
Fail expr {
|
Fail expr {
|
||||||
@ -646,8 +619,7 @@ conditional:
|
|||||||
terminator = $5;
|
terminator = $5;
|
||||||
kwd_else = $6;
|
kwd_else = $6;
|
||||||
ifnot = $7}
|
ifnot = $7}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
if_clause:
|
if_clause:
|
||||||
instruction {
|
instruction {
|
||||||
@ -660,8 +632,7 @@ if_clause:
|
|||||||
lbrace = $1;
|
lbrace = $1;
|
||||||
inside = (first, others), terminator;
|
inside = (first, others), terminator;
|
||||||
rbrace = closing} in
|
rbrace = closing} in
|
||||||
ClauseBlock {value; region}
|
ClauseBlock {value; region}}
|
||||||
}
|
|
||||||
|
|
||||||
case_instr:
|
case_instr:
|
||||||
Case expr Of option(VBAR) cases End {
|
Case expr Of option(VBAR) cases End {
|
||||||
@ -673,29 +644,25 @@ case_instr:
|
|||||||
lead_vbar = $4;
|
lead_vbar = $4;
|
||||||
cases = $5;
|
cases = $5;
|
||||||
kwd_end = $6}
|
kwd_end = $6}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
cases:
|
cases:
|
||||||
nsepseq(case,VBAR) {
|
nsepseq(case,VBAR) {
|
||||||
let region = nsepseq_to_region (fun x -> x.region) $1
|
let region = nsepseq_to_region (fun x -> x.region) $1
|
||||||
in {region; value = $1}
|
in {region; value = $1}}
|
||||||
}
|
|
||||||
|
|
||||||
case:
|
case:
|
||||||
pattern ARROW instruction {
|
pattern ARROW instruction {
|
||||||
let region = cover (pattern_to_region $1) (instr_to_region $3)
|
let region = cover (pattern_to_region $1) (instr_to_region $3)
|
||||||
and value = {pattern = $1; arrow = $2; instr = $3}
|
and value = {pattern = $1; arrow = $2; instr = $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
assignment:
|
assignment:
|
||||||
lhs ASS rhs {
|
lhs ASS rhs {
|
||||||
let stop = rhs_to_region $3 in
|
let stop = rhs_to_region $3 in
|
||||||
let region = cover (lhs_to_region $1) stop
|
let region = cover (lhs_to_region $1) stop
|
||||||
and value = {lhs = $1; assign = $2; rhs = $3}
|
and value = {lhs = $1; assign = $2; rhs = $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
rhs:
|
rhs:
|
||||||
expr { Expr $1 }
|
expr { Expr $1 }
|
||||||
@ -716,8 +683,7 @@ while_loop:
|
|||||||
kwd_while = $1;
|
kwd_while = $1;
|
||||||
cond = $2;
|
cond = $2;
|
||||||
block = $3}
|
block = $3}
|
||||||
in While {region; value}
|
in While {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
for_loop:
|
for_loop:
|
||||||
For var_assign Down? To expr option(step_clause) block {
|
For var_assign Down? To expr option(step_clause) block {
|
||||||
@ -741,15 +707,13 @@ for_loop:
|
|||||||
kwd_in = $4;
|
kwd_in = $4;
|
||||||
expr = $5;
|
expr = $5;
|
||||||
block = $6}
|
block = $6}
|
||||||
in For (ForCollect {region; value})
|
in For (ForCollect {region; value})}
|
||||||
}
|
|
||||||
|
|
||||||
var_assign:
|
var_assign:
|
||||||
var ASS expr {
|
var ASS expr {
|
||||||
let region = cover $1.region (expr_to_region $3)
|
let region = cover $1.region (expr_to_region $3)
|
||||||
and value = {name = $1; assign = $2; expr = $3}
|
and value = {name = $1; assign = $2; expr = $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
step_clause:
|
step_clause:
|
||||||
Step expr { $1,$2 }
|
Step expr { $1,$2 }
|
||||||
@ -938,11 +902,10 @@ core_expr:
|
|||||||
}
|
}
|
||||||
| C_Some arguments {
|
| C_Some arguments {
|
||||||
let region = cover $1 $2.region in
|
let region = cover $1 $2.region in
|
||||||
EConstr (SomeApp {region; value = $1,$2})
|
EConstr (SomeApp {region; value = $1,$2})}
|
||||||
}
|
|
||||||
|
|
||||||
set_expr:
|
set_expr:
|
||||||
set_injection { SetInj $1 }
|
injection(Set) { SetInj $1 }
|
||||||
|
|
||||||
map_expr:
|
map_expr:
|
||||||
map_lookup { MapLookUp $1 }
|
map_lookup { MapLookUp $1 }
|
||||||
@ -993,19 +956,15 @@ field_assignment:
|
|||||||
field_name = $1;
|
field_name = $1;
|
||||||
equal = $2;
|
equal = $2;
|
||||||
field_expr = $3}
|
field_expr = $3}
|
||||||
in {region; value}
|
in {region; value}}
|
||||||
}
|
|
||||||
|
|
||||||
fun_call:
|
fun_call:
|
||||||
fun_name arguments {
|
fun_name arguments {
|
||||||
let region = cover $1.region $2.region
|
let region = cover $1.region $2.region
|
||||||
in {region; value = $1,$2}
|
in {region; value = $1,$2}}
|
||||||
}
|
|
||||||
|
|
||||||
tuple_expr:
|
tuple_expr:
|
||||||
tuple_inj {
|
tuple_inj { TupleInj $1 }
|
||||||
TupleInj $1
|
|
||||||
}
|
|
||||||
|
|
||||||
tuple_inj:
|
tuple_inj:
|
||||||
par(nsepseq(expr,COMMA)) { $1 }
|
par(nsepseq(expr,COMMA)) { $1 }
|
||||||
@ -1014,50 +973,9 @@ arguments:
|
|||||||
tuple_inj { $1 }
|
tuple_inj { $1 }
|
||||||
|
|
||||||
list_expr:
|
list_expr:
|
||||||
list_injection { List $1 }
|
injection(List) { List $1 }
|
||||||
| nil { Nil $1 }
|
| nil { Nil $1 }
|
||||||
|
|
||||||
(* Note: [list_injection] and [set_injection] could be merged. *)
|
|
||||||
|
|
||||||
list_injection:
|
|
||||||
List series(expr,End) {
|
|
||||||
let first, (others, terminator, closing) = $2 in
|
|
||||||
let region = cover $1 closing
|
|
||||||
and value : list_injection = {
|
|
||||||
opening = Kwd $1;
|
|
||||||
elements = Some (first, others);
|
|
||||||
terminator;
|
|
||||||
closing = End closing}
|
|
||||||
in {region; value}
|
|
||||||
}
|
|
||||||
| List End {
|
|
||||||
let region = cover $1 $2
|
|
||||||
and value : list_injection = {
|
|
||||||
opening = Kwd $1;
|
|
||||||
elements = None;
|
|
||||||
terminator = None;
|
|
||||||
closing = End $2}
|
|
||||||
in {region; value}
|
|
||||||
}
|
|
||||||
| List LBRACKET series(expr,RBRACKET) {
|
|
||||||
let first, (others, terminator, closing) = $3 in
|
|
||||||
let region = cover $1 closing
|
|
||||||
and value : list_injection = {
|
|
||||||
opening = KwdBracket ($1,$2);
|
|
||||||
elements = Some (first, others);
|
|
||||||
terminator;
|
|
||||||
closing = RBracket closing}
|
|
||||||
in {region; value}
|
|
||||||
}
|
|
||||||
| List LBRACKET RBRACKET {
|
|
||||||
let region = cover $1 $3
|
|
||||||
and value : list_injection = {
|
|
||||||
opening = KwdBracket ($1,$2);
|
|
||||||
elements = None;
|
|
||||||
terminator = None;
|
|
||||||
closing = RBracket $3}
|
|
||||||
in {region; value}}
|
|
||||||
|
|
||||||
nil:
|
nil:
|
||||||
par(typed_empty_list) { $1 }
|
par(typed_empty_list) { $1 }
|
||||||
|
|
||||||
@ -1081,8 +999,7 @@ typed_none_expr:
|
|||||||
pattern:
|
pattern:
|
||||||
nsepseq(core_pattern,CONS) {
|
nsepseq(core_pattern,CONS) {
|
||||||
let region = nsepseq_to_region pattern_to_region $1
|
let region = nsepseq_to_region pattern_to_region $1
|
||||||
in PCons {region; value=$1}
|
in PCons {region; value=$1}}
|
||||||
}
|
|
||||||
|
|
||||||
core_pattern:
|
core_pattern:
|
||||||
var { PVar $1 }
|
var { PVar $1 }
|
||||||
|
Loading…
Reference in New Issue
Block a user