Enabled user-defined constant constructors in expressions.
This commit is contained in:
parent
23da509c11
commit
582e95f9a8
@ -597,7 +597,7 @@ and nil = kwd_nil
|
|||||||
and constr_expr =
|
and constr_expr =
|
||||||
SomeApp of (c_Some * arguments) reg
|
SomeApp of (c_Some * arguments) reg
|
||||||
| NoneExpr of none_expr
|
| NoneExpr of none_expr
|
||||||
| ConstrApp of (constr * arguments) reg
|
| ConstrApp of (constr * arguments option) reg
|
||||||
|
|
||||||
and record_expr = field_assign reg injection reg
|
and record_expr = field_assign reg injection reg
|
||||||
|
|
||||||
|
@ -581,7 +581,7 @@ and nil = kwd_nil
|
|||||||
and constr_expr =
|
and constr_expr =
|
||||||
SomeApp of (c_Some * arguments) reg
|
SomeApp of (c_Some * arguments) reg
|
||||||
| NoneExpr of none_expr
|
| NoneExpr of none_expr
|
||||||
| ConstrApp of (constr * arguments) reg
|
| ConstrApp of (constr * arguments option) reg
|
||||||
|
|
||||||
and record_expr = field_assign reg injection reg
|
and record_expr = field_assign reg injection reg
|
||||||
|
|
||||||
|
@ -956,7 +956,10 @@ core_expr:
|
|||||||
| projection { EProj $1 }
|
| projection { EProj $1 }
|
||||||
| Constr arguments {
|
| Constr arguments {
|
||||||
let region = cover $1.region $2.region in
|
let region = cover $1.region $2.region in
|
||||||
EConstr (ConstrApp {region; value = $1,$2})
|
EConstr (ConstrApp {region; value = $1, Some $2})
|
||||||
|
}
|
||||||
|
| Constr {
|
||||||
|
EConstr (ConstrApp {region=$1.region; value = $1,None})
|
||||||
}
|
}
|
||||||
| C_Some arguments {
|
| C_Some arguments {
|
||||||
let region = cover $1 $2.region in
|
let region = cover $1 $2.region in
|
||||||
|
@ -648,7 +648,9 @@ and print_fun_call {value; _} =
|
|||||||
and print_constr_app {value; _} =
|
and print_constr_app {value; _} =
|
||||||
let constr, arguments = value in
|
let constr, arguments = value in
|
||||||
print_constr constr;
|
print_constr constr;
|
||||||
print_tuple_inj arguments
|
match arguments with
|
||||||
|
None -> ()
|
||||||
|
| Some args -> print_tuple_inj args
|
||||||
|
|
||||||
and print_some_app {value; _} =
|
and print_some_app {value; _} =
|
||||||
let c_Some, arguments = value in
|
let c_Some, arguments = value in
|
||||||
|
@ -416,11 +416,14 @@ let rec simpl_expression (t:Raw.expr) : expr result =
|
|||||||
| EProj p -> simpl_projection p
|
| EProj p -> simpl_projection p
|
||||||
| EConstr (ConstrApp c) -> (
|
| EConstr (ConstrApp c) -> (
|
||||||
let ((c, args) , loc) = r_split c in
|
let ((c, args) , loc) = r_split c in
|
||||||
let (args , args_loc) = r_split args in
|
match args with
|
||||||
let%bind arg =
|
None -> simpl_tuple_expression []
|
||||||
simpl_tuple_expression ~loc:args_loc
|
| Some args ->
|
||||||
@@ npseq_to_list args.inside in
|
let args, args_loc = r_split args in
|
||||||
return @@ e_constructor ~loc c.value arg
|
let%bind arg =
|
||||||
|
simpl_tuple_expression ~loc:args_loc
|
||||||
|
@@ npseq_to_list args.inside in
|
||||||
|
return @@ e_constructor ~loc c.value arg
|
||||||
)
|
)
|
||||||
| EConstr (SomeApp a) ->
|
| EConstr (SomeApp a) ->
|
||||||
let ((_, args) , loc) = r_split a in
|
let ((_, args) , loc) = r_split a in
|
||||||
|
Loading…
Reference in New Issue
Block a user