diff options
author | Björn Gustavsson <[email protected]> | 2015-01-30 15:43:41 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-01-30 15:51:52 +0100 |
commit | f667931e2905797ffab63e224e56eaf07f77178a (patch) | |
tree | e202cad143ed4ecb5b2f0b2bad14292ea172890f /lib/compiler/src/core_parse.yrl | |
parent | e4a8ab7530d340249c09ca7f27b0120f55b8354a (diff) | |
download | otp-f667931e2905797ffab63e224e56eaf07f77178a.tar.gz otp-f667931e2905797ffab63e224e56eaf07f77178a.tar.bz2 otp-f667931e2905797ffab63e224e56eaf07f77178a.zip |
Make the syntax for map pairs readable
Use the same syntax for map pairs in Core Erlang code as in the
Erlang Code. This Erlang code:
M#{x:=42,y=>1}
will look like this in Core Erlang:
~{'x':=42,'y'=>1|M}~
Diffstat (limited to 'lib/compiler/src/core_parse.yrl')
-rw-r--r-- | lib/compiler/src/core_parse.yrl | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/compiler/src/core_parse.yrl b/lib/compiler/src/core_parse.yrl index 849f801a11..8bdb6bc37d 100644 --- a/lib/compiler/src/core_parse.yrl +++ b/lib/compiler/src/core_parse.yrl @@ -58,7 +58,8 @@ Terminals %% Separators -'(' ')' '{' '}' '[' ']' '|' ',' '->' '=' '/' '<' '>' ':' '-|' '#' '~' '::' +'(' ')' '{' '}' '[' ']' '|' ',' '->' '=' '/' '<' '>' ':' '-|' '#' +'~' '=>' ':=' %% Keywords (atoms are assumed to always be single-quoted). @@ -189,8 +190,9 @@ map_pattern -> '~' '{' map_pair_patterns '}' '~' : map_pair_patterns -> map_pair_pattern : ['$1']. map_pair_patterns -> map_pair_pattern ',' map_pair_patterns : ['$1' | '$3']. -map_pair_pattern -> '~' '<' anno_expression ',' anno_pattern '>' : - #c_map_pair{op=#c_literal{val=exact},key='$3',val='$5'}. +map_pair_pattern -> anno_expression ':=' anno_pattern : + #c_map_pair{op=#c_literal{val=exact}, + key='$1',val='$3'}. cons_pattern -> '[' anno_pattern tail_pattern : c_cons('$2', '$3'). @@ -295,10 +297,10 @@ map_pairs -> map_pair ',' map_pairs : ['$1' | '$3']. map_pair -> map_pair_assoc : '$1'. map_pair -> map_pair_exact : '$1'. -map_pair_assoc -> '::' '<' anno_expression ',' anno_expression'>' : - #c_map_pair{op=#c_literal{val=assoc},key='$3',val='$5'}. -map_pair_exact -> '~' '<' anno_expression ',' anno_expression'>' : - #c_map_pair{op=#c_literal{val=exact},key='$3',val='$5'}. +map_pair_assoc -> anno_expression '=>' anno_expression : + #c_map_pair{op=#c_literal{val=assoc},key='$1',val='$3'}. +map_pair_exact -> anno_expression ':=' anno_expression : + #c_map_pair{op=#c_literal{val=exact},key='$1',val='$3'}. cons -> '[' anno_expression tail : c_cons('$2', '$3'). |