Use id() for constraints instead of keywords
This commit is contained in:
parent
3f177d363f
commit
f56eeb0b2b
@ -98,10 +98,10 @@ namespace String =
|
|||||||
|
|
||||||
private function
|
private function
|
||||||
to_int_([], _, x, _) = Some(x)
|
to_int_([], _, x, _) = Some(x)
|
||||||
to_int_(i :: is, value, x, b) =
|
to_int_(i :: ints, value, x, b) =
|
||||||
switch(value(i))
|
switch(value(i))
|
||||||
None => None
|
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) =
|
private function ch_to_int_10(ch) =
|
||||||
let c = Char.to_int(ch)
|
let c = Char.to_int(ch)
|
||||||
|
@ -135,8 +135,7 @@ fun_block(Mods, Kind, Decls) ->
|
|||||||
{block, get_ann(Kind), [ add_modifiers(Mods, Kind, Decl) || Decl <- Decls ]}.
|
{block, get_ann(Kind), [ add_modifiers(Mods, Kind, Decl) || Decl <- Decls ]}.
|
||||||
|
|
||||||
typevar_constraint() ->
|
typevar_constraint() ->
|
||||||
?RULE(tvar(), keyword(is), choice([tok(eq), tok(ord)]),
|
?RULE(tvar(), keyword(is), id(), {constraint, get_ann(_1), _1, _3}).
|
||||||
{constraint, element(2, _1), element(3, _1), element(1, _3)}).
|
|
||||||
|
|
||||||
typevars_constraints() ->
|
typevars_constraints() ->
|
||||||
?RULE(comma_sep1(typevar_constraint()), tok(';'), _1).
|
?RULE(comma_sep1(typevar_constraint()), tok(';'), _1).
|
||||||
|
@ -45,7 +45,7 @@ lexer() ->
|
|||||||
|
|
||||||
Keywords = ["contract", "include", "let", "switch", "type", "record", "datatype", "if", "elif", "else", "function",
|
Keywords = ["contract", "include", "let", "switch", "type", "record", "datatype", "if", "elif", "else", "function",
|
||||||
"stateful", "payable", "true", "false", "mod", "public", "entrypoint", "private", "indexed", "namespace",
|
"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, "|"),
|
KW = string:join(Keywords, "|"),
|
||||||
|
|
||||||
|
@ -79,15 +79,14 @@
|
|||||||
|
|
||||||
-type constructor_t() :: {constr_t, ann(), con(), [type()]}.
|
-type constructor_t() :: {constr_t, ann(), con(), [type()]}.
|
||||||
|
|
||||||
-type tvar_constraint() :: eq | ord.
|
-type tvar_constraint() :: {constraint, ann(), tvar(), id()}.
|
||||||
-type constraint() :: {constraint, ann(), name(), tvar_constraint()}.
|
|
||||||
|
|
||||||
-type type() :: {fun_t, ann(), [named_arg_t()], [type()], type()}
|
-type type() :: {fun_t, ann(), [named_arg_t()], [type()], type()}
|
||||||
| {app_t, ann(), type(), [type()]}
|
| {app_t, ann(), type(), [type()]}
|
||||||
| {tuple_t, ann(), [type()]}
|
| {tuple_t, ann(), [type()]}
|
||||||
| {args_t, ann(), [type()]} %% old tuple syntax, old for error messages
|
| {args_t, ann(), [type()]} %% old tuple syntax, old for error messages
|
||||||
| {bytes_t, ann(), integer() | any}
|
| {bytes_t, ann(), integer() | any}
|
||||||
| {constrained_t, ann(), [constraint()], type()}
|
| {constrained_t, ann(), [tvar_constraint()], type()}
|
||||||
| id() | qid()
|
| id() | qid()
|
||||||
| con() | qcon() %% contracts
|
| con() | qcon() %% contracts
|
||||||
| tvar().
|
| tvar().
|
||||||
|
Loading…
x
Reference in New Issue
Block a user