Merge branch 'rinderknecht-dev' into 'dev'

Enabled user-defined constant constructors in expressions.

See merge request ligolang/ligo!29
This commit is contained in:
Georges Dupéron 2019-06-11 23:42:21 +00:00
commit d6fc9c79f3
5 changed files with 17 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -416,11 +416,14 @@ 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
let%bind arg =
simpl_tuple_expression ~loc:args_loc
@@ npseq_to_list args.inside in
return @@ e_constructor ~loc c.value arg
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
return @@ e_constructor ~loc c.value arg
)
| EConstr (SomeApp a) ->
let ((_, args) , loc) = r_split a in