From f56eeb0b2bc5d210c891f3681c4d7a5f751d8133 Mon Sep 17 00:00:00 2001 From: Gaith Hallak Date: Sat, 11 Jun 2022 21:52:23 +0400 Subject: [PATCH] Use id() for constraints instead of keywords --- priv/stdlib/String.aes | 4 ++-- src/aeso_parser.erl | 3 +-- src/aeso_scan.erl | 2 +- src/aeso_syntax.erl | 5 ++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/priv/stdlib/String.aes b/priv/stdlib/String.aes index 33f813b..99d5c0e 100644 --- a/priv/stdlib/String.aes +++ b/priv/stdlib/String.aes @@ -98,10 +98,10 @@ namespace String = private function to_int_([], _, x, _) = Some(x) - to_int_(i :: is, value, x, b) = + to_int_(i :: ints, value, x, b) = switch(value(i)) None => None - Some(n) => to_int_(is, value, x * b + n, b) + Some(i) => to_int_(ints, value, x * b + i, b) private function ch_to_int_10(ch) = let c = Char.to_int(ch) diff --git a/src/aeso_parser.erl b/src/aeso_parser.erl index b0f0bce..c32d944 100644 --- a/src/aeso_parser.erl +++ b/src/aeso_parser.erl @@ -135,8 +135,7 @@ fun_block(Mods, Kind, Decls) -> {block, get_ann(Kind), [ add_modifiers(Mods, Kind, Decl) || Decl <- Decls ]}. typevar_constraint() -> - ?RULE(tvar(), keyword(is), choice([tok(eq), tok(ord)]), - {constraint, element(2, _1), element(3, _1), element(1, _3)}). + ?RULE(tvar(), keyword(is), id(), {constraint, get_ann(_1), _1, _3}). typevars_constraints() -> ?RULE(comma_sep1(typevar_constraint()), tok(';'), _1). diff --git a/src/aeso_scan.erl b/src/aeso_scan.erl index 11900b1..c7de2eb 100644 --- a/src/aeso_scan.erl +++ b/src/aeso_scan.erl @@ -45,7 +45,7 @@ lexer() -> Keywords = ["contract", "include", "let", "switch", "type", "record", "datatype", "if", "elif", "else", "function", "stateful", "payable", "true", "false", "mod", "public", "entrypoint", "private", "indexed", "namespace", - "interface", "main", "using", "as", "for", "hiding", "is", "eq", "ord" + "interface", "main", "using", "as", "for", "hiding", "is" ], KW = string:join(Keywords, "|"), diff --git a/src/aeso_syntax.erl b/src/aeso_syntax.erl index 6461dac..c92f0f6 100644 --- a/src/aeso_syntax.erl +++ b/src/aeso_syntax.erl @@ -79,15 +79,14 @@ -type constructor_t() :: {constr_t, ann(), con(), [type()]}. --type tvar_constraint() :: eq | ord. --type constraint() :: {constraint, ann(), name(), tvar_constraint()}. +-type tvar_constraint() :: {constraint, ann(), tvar(), id()}. -type type() :: {fun_t, ann(), [named_arg_t()], [type()], type()} | {app_t, ann(), type(), [type()]} | {tuple_t, ann(), [type()]} | {args_t, ann(), [type()]} %% old tuple syntax, old for error messages | {bytes_t, ann(), integer() | any} - | {constrained_t, ann(), [constraint()], type()} + | {constrained_t, ann(), [tvar_constraint()], type()} | id() | qid() | con() | qcon() %% contracts | tvar().