From 88139fe99c281c21e7090644ac2867b36e1e5a3e Mon Sep 17 00:00:00 2001 From: Ulf Norell Date: Fri, 26 Apr 2019 13:35:35 +0200 Subject: [PATCH] Get rid of unit in AST --- src/aeso_ast_infer_types.erl | 2 -- src/aeso_parser.erl | 4 +--- src/aeso_pretty.erl | 1 - src/aeso_syntax.erl | 1 - 4 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 324def0..f157eb7 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -938,8 +938,6 @@ infer_expr(Env, Id = {Tag, As, _}) when Tag == id; Tag == qid -> infer_expr(Env, Id = {Tag, As, _}) when Tag == con; Tag == qcon -> {QName, Type} = lookup_name(Env, As, Id, [freshen]), {typed, As, QName, Type}; -infer_expr(Env, {unit, As}) -> - infer_expr(Env, {tuple, As, []}); infer_expr(Env, {tuple, As, Cpts}) -> NewCpts = [infer_expr(Env, C) || C <- Cpts], CptTypes = [T || {typed, _, _, T} <- NewCpts], diff --git a/src/aeso_parser.erl b/src/aeso_parser.erl index c174a6b..ba9e8b9 100644 --- a/src/aeso_parser.erl +++ b/src/aeso_parser.erl @@ -441,7 +441,7 @@ build_if(Ann, Cond, Then, [{elif, Ann1, Cond1, Then1} | Elses]) -> build_if(Ann, Cond, Then, [{else, _Ann, Else}]) -> {'if', Ann, Cond, Then, Else}; build_if(Ann, Cond, Then, []) -> - {'if', Ann, Cond, Then, {unit, [{origin, system}]}}. + {'if', Ann, Cond, Then, {tuple, [{origin, system}], []}}. else_branches([Elif = {elif, _, _, _} | Stmts], Acc) -> else_branches(Stmts, [Elif | Acc]); @@ -457,7 +457,6 @@ fun_t(Domains, Type) -> lists:foldr(fun({Dom, Ann}, T) -> {fun_t, Ann, [], Dom, T} end, Type, Domains). -tuple_e(Ann, []) -> {unit, Ann}; tuple_e(_Ann, [Expr]) -> Expr; %% Not a tuple tuple_e(Ann, Exprs) -> {tuple, Ann, Exprs}. @@ -478,7 +477,6 @@ parse_pattern({record, Ann, Fs}) -> {record, Ann, lists:map(fun parse_field_pattern/1, Fs)}; parse_pattern(E = {con, _, _}) -> E; parse_pattern(E = {id, _, _}) -> E; -parse_pattern(E = {unit, _}) -> E; parse_pattern(E = {int, _, _}) -> E; parse_pattern(E = {bool, _, _}) -> E; parse_pattern(E = {bytes, _, _}) -> E; diff --git a/src/aeso_pretty.erl b/src/aeso_pretty.erl index 8a09fbc..3177e60 100644 --- a/src/aeso_pretty.erl +++ b/src/aeso_pretty.erl @@ -332,7 +332,6 @@ expr_p(_, {Type, _, Bin}) Type == oracle_pubkey; Type == oracle_query_id -> text(binary_to_list(aeser_api_encoder:encode(Type, Bin))); -expr_p(_, {unit, _}) -> text("()"); expr_p(_, {string, _, S}) -> term(binary_to_list(S)); expr_p(_, {char, _, C}) -> case C of diff --git a/src/aeso_syntax.erl b/src/aeso_syntax.erl index 25f0963..63f192d 100644 --- a/src/aeso_syntax.erl +++ b/src/aeso_syntax.erl @@ -75,7 +75,6 @@ | {contract_pubkey, binary()} | {oracle_pubkey, binary()} | {oracle_query_id, binary()} - | {unit, ann()} | {string, ann(), binary()} | {char, ann(), integer()}.