Packages
abi
0.1.13
1.3.0
1.2.0
1.1.0
1.0.0-bravo6
1.0.0-bravo4
1.0.0-bravo3
1.0.0-bravo2
1.0.0-bravo1
1.0.0-alpha9
1.0.0-alpha8
1.0.0-alpha7
1.0.0-alpha6
1.0.0-alpha5
1.0.0-alpha4
1.0.0-alpha3
1.0.0-alpha2
1.0.0-alpha1
0.1.21
0.1.21-alpha2
0.1.21-alpha1
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Ethereum's ABI Interface
Current section
Files
Jump to
Current section
Files
src/ethereum_abi_parser.yrl
Terminals '(' ')' '[' ']' ',' '->' typename letters digits 'expecting selector' 'expecting type'.
Nonterminals dispatch selector nontrivial_selector comma_delimited_types type_with_subscripts array_subscripts tuple array_subscript identifier identifier_parts identifier_part type typespec.
Rootsymbol dispatch.
dispatch -> 'expecting type' type_with_subscripts : {type, '$2'}.
dispatch -> 'expecting selector' selector : {selector, '$2'}.
dispatch -> tuple : {selector, #{function => nil, types => ['$1'], returns => nil}}.
dispatch -> nontrivial_selector : {selector, '$1'}.
selector -> typespec : #{function => nil, types => '$1', returns => nil}.
selector -> nontrivial_selector : '$1'.
nontrivial_selector -> typespec '->' type : #{function => nil, types => '$1', returns => '$3'}.
nontrivial_selector -> identifier typespec : #{function => '$1', types => '$2', returns => nil}.
nontrivial_selector -> identifier typespec '->' type : #{function => '$1', types => '$2', returns => '$4'}.
typespec -> '(' ')' : [].
typespec -> '(' comma_delimited_types ')' : '$2'.
tuple -> '(' ')' : {tuple, []}.
tuple -> '(' comma_delimited_types ')' : {tuple, '$2'}.
comma_delimited_types -> type_with_subscripts : ['$1'].
comma_delimited_types -> type_with_subscripts ',' comma_delimited_types : ['$1' | '$3'].
identifier -> identifier_parts : iolist_to_binary('$1').
identifier_parts -> identifier_part : ['$1'].
identifier_parts -> identifier_part identifier_parts : ['$1' | '$2'].
identifier_part -> typename : v('$1').
identifier_part -> letters : v('$1').
identifier_part -> digits : v('$1').
type_with_subscripts -> type : '$1'.
type_with_subscripts -> type array_subscripts : with_subscripts('$1', '$2').
array_subscripts -> array_subscript : ['$1'].
array_subscripts -> array_subscript array_subscripts : ['$1' | '$2'].
array_subscript -> '[' ']' : variable.
array_subscript -> '[' digits ']' : list_to_integer(v('$2')).
type -> typename :
plain_type(list_to_atom(v('$1'))).
type -> typename digits :
juxt_type(list_to_atom(v('$1')), list_to_integer(v('$2'))).
type -> typename digits letters digits :
double_juxt_type(list_to_atom(v('$1')), v('$3'), list_to_integer(v('$2')), list_to_integer(v('$4'))).
type -> tuple : '$1'.
Erlang code.
v({_Token, _Line, Value}) -> Value.
plain_type(address) -> address;
plain_type(bool) -> bool;
plain_type(function) -> function;
plain_type(string) -> string;
plain_type(bytes) -> bytes;
plain_type(int) -> juxt_type(int, 256);
plain_type(uint) -> juxt_type(uint, 256);
plain_type(fixed) -> double_juxt_type(fixed, 'x', 128, 19);
plain_type(ufixed) -> double_juxt_type(ufixed, 'x', 128, 19).
with_subscripts(Type, []) -> Type;
with_subscripts(Type, [H | T]) -> with_subscripts(with_subscript(Type, H), T).
with_subscript(Type, variable) -> {array, Type};
with_subscript(Type, N) when is_integer(N), N >= 0 -> {array, Type, N}.
juxt_type(int, M) when M > 0, M =< 256, (M rem 8) =:= 0 -> {int, M};
juxt_type(uint, M) when M > 0, M =< 256, (M rem 8) =:= 0 -> {uint, M};
juxt_type(bytes, M) when M > 0, M =< 32 -> {bytes, M}.
double_juxt_type(fixed, 'x', M, N) when M >= 0, M =< 256, (M rem 8) =:= 0, N > 0, N =< 80 -> {fixed, M, N};
double_juxt_type(ufixed, 'x', M, N) when M >= 0, M =< 256, (M rem 8) =:= 0, N > 0, N =< 80 -> {ufixed, M, N}.