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 =
|
||||
SomeApp of (c_Some * arguments) reg
|
||||
| NoneExpr of none_expr
|
||||
| ConstrApp of (constr * arguments) reg
|
||||
| ConstrApp of (constr * arguments option) reg
|
||||
|
||||
and record_expr = field_assign reg injection reg
|
||||
|
||||
|
@ -581,7 +581,7 @@ and nil = kwd_nil
|
||||
and constr_expr =
|
||||
SomeApp of (c_Some * arguments) reg
|
||||
| NoneExpr of none_expr
|
||||
| ConstrApp of (constr * arguments) reg
|
||||
| ConstrApp of (constr * arguments option) reg
|
||||
|
||||
and record_expr = field_assign reg injection reg
|
||||
|
||||
|
@ -956,7 +956,10 @@ core_expr:
|
||||
| projection { EProj $1 }
|
||||
| Constr arguments {
|
||||
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 {
|
||||
let region = cover $1 $2.region in
|
||||
|
@ -648,7 +648,9 @@ and print_fun_call {value; _} =
|
||||
and print_constr_app {value; _} =
|
||||
let constr, arguments = value in
|
||||
print_constr constr;
|
||||
print_tuple_inj arguments
|
||||
match arguments with
|
||||
None -> ()
|
||||
| Some args -> print_tuple_inj args
|
||||
|
||||
and print_some_app {value; _} =
|
||||
let c_Some, arguments = value in
|
||||
|
@ -416,7 +416,10 @@ let rec simpl_expression (t:Raw.expr) : expr result =
|
||||
| EProj p -> simpl_projection p
|
||||
| EConstr (ConstrApp c) -> (
|
||||
let ((c, args) , loc) = r_split c in
|
||||
let (args , args_loc) = r_split args in
|
||||
match args with
|
||||
None -> simpl_tuple_expression []
|
||||
| Some args ->
|
||||
let args, args_loc = r_split args in
|
||||
let%bind arg =
|
||||
simpl_tuple_expression ~loc:args_loc
|
||||
@@ npseq_to_list args.inside in
|
||||
|
Loading…
Reference in New Issue
Block a user