Extend compiler to allow bytes()/bytes as type
This commit is contained in:
parent
32a98112d3
commit
fda58ec430
@ -4287,7 +4287,7 @@ pp({tuple_t, _, []}) ->
|
|||||||
"unit";
|
"unit";
|
||||||
pp({tuple_t, _, Cpts}) ->
|
pp({tuple_t, _, Cpts}) ->
|
||||||
["(", string:join(lists:map(fun pp/1, Cpts), " * "), ")"];
|
["(", string:join(lists:map(fun pp/1, Cpts), " * "), ")"];
|
||||||
pp({bytes_t, _, any}) -> "bytes(_)";
|
pp({bytes_t, _, any}) -> "bytes()";
|
||||||
pp({bytes_t, _, Len}) ->
|
pp({bytes_t, _, Len}) ->
|
||||||
["bytes(", integer_to_list(Len), ")"];
|
["bytes(", integer_to_list(Len), ")"];
|
||||||
pp({app_t, _, T, []}) ->
|
pp({app_t, _, T, []}) ->
|
||||||
|
@ -264,10 +264,11 @@ type300() ->
|
|||||||
type400() ->
|
type400() ->
|
||||||
choice(
|
choice(
|
||||||
[?RULE(typeAtom(), optional(type_args()),
|
[?RULE(typeAtom(), optional(type_args()),
|
||||||
|
any_bytes(
|
||||||
case _2 of
|
case _2 of
|
||||||
none -> _1;
|
none -> _1;
|
||||||
{ok, Args} -> {app_t, get_ann(_1), _1, Args}
|
{ok, Args} -> {app_t, get_ann(_1), _1, Args}
|
||||||
end),
|
end)),
|
||||||
?RULE(id("bytes"), parens(token(int)),
|
?RULE(id("bytes"), parens(token(int)),
|
||||||
{bytes_t, get_ann(_1), element(3, _2)})
|
{bytes_t, get_ann(_1), element(3, _2)})
|
||||||
]).
|
]).
|
||||||
@ -792,3 +793,7 @@ auto_imports(L) when is_list(L) ->
|
|||||||
auto_imports(T) when is_tuple(T) ->
|
auto_imports(T) when is_tuple(T) ->
|
||||||
auto_imports(tuple_to_list(T));
|
auto_imports(tuple_to_list(T));
|
||||||
auto_imports(_) -> [].
|
auto_imports(_) -> [].
|
||||||
|
|
||||||
|
any_bytes({id, Ann, "bytes"}) -> {bytes_t, Ann, any};
|
||||||
|
any_bytes({app_t, _, {id, Ann, "bytes"}, []}) -> {bytes_t, Ann, any};
|
||||||
|
any_bytes(Type) -> Type.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user