From 09875cf1da7fb2444e24ba3681c2451af3cd96f3 Mon Sep 17 00:00:00 2001 From: Sander Spies Date: Mon, 16 Dec 2019 14:54:12 +0100 Subject: [PATCH] Make type_expr_simple less complicated. --- src/passes/1-parser/reasonligo/Parser.mly | 30 ++++++----------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/passes/1-parser/reasonligo/Parser.mly b/src/passes/1-parser/reasonligo/Parser.mly index c91cd352e..61edd2349 100644 --- a/src/passes/1-parser/reasonligo/Parser.mly +++ b/src/passes/1-parser/reasonligo/Parser.mly @@ -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}