Make type_expr_simple less complicated.
This commit is contained in:
parent
f5aebffd0b
commit
09875cf1da
@ -388,30 +388,14 @@ type_expr_simple_args:
|
||||
par(nsepseq(type_expr_simple, ",")) { $1 }
|
||||
|
||||
type_expr_simple:
|
||||
core_expr_2 type_expr_simple_args? {
|
||||
type_name type_expr_simple_args? {
|
||||
let args = $2 in
|
||||
let constr =
|
||||
match $1 with
|
||||
EVar i -> i
|
||||
| EProj {value={struct_name; field_path; _}; region} ->
|
||||
let app a = function
|
||||
FieldName v -> a ^ "." ^ v.value
|
||||
| Component {value = c, _; _} -> a ^ "." ^ c in
|
||||
let value =
|
||||
Utils.nsepseq_foldl app struct_name.value field_path
|
||||
in {region; value}
|
||||
| EArith Mutez r | EArith Int r | EArith Nat r ->
|
||||
{r with value = fst r.value}
|
||||
| EString String s -> s
|
||||
| ELogic BoolExpr (True t) -> {region=t; value="true"}
|
||||
| ELogic BoolExpr (False f) -> {region=f; value="false"}
|
||||
| _ -> failwith "Not supported" (* TODO: raise a proper exception *)
|
||||
in match args with
|
||||
Some {value; _} ->
|
||||
let region = cover (expr_to_region $1) value.rpar in
|
||||
let value = constr, {region; value}
|
||||
in TApp {region; value}
|
||||
| None -> TVar constr
|
||||
match args with
|
||||
Some {value; _} ->
|
||||
let region = cover $1.region value.rpar in
|
||||
let value = $1, {region; value}
|
||||
in TApp {region; value}
|
||||
| None -> TVar $1
|
||||
}
|
||||
| "(" nsepseq(type_expr_simple, ",") ")" {
|
||||
TProd {region = cover $1 $3; value=$2}
|
||||
|
Loading…
Reference in New Issue
Block a user