aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2013-10-01 22:29:29 +0200
committerBjörn-Egil Dahlberg <[email protected]>2014-01-28 15:56:27 +0100
commitb15b2098627f702958771c3497949c62623a415d (patch)
tree45eed8edb6bbbd2a42f7744e2f07557b1b5db6d8
parent226e1e5898058aa3459c4d562df13132c9bc0899 (diff)
downloadotp-b15b2098627f702958771c3497949c62623a415d.tar.gz
otp-b15b2098627f702958771c3497949c62623a415d.tar.bz2
otp-b15b2098627f702958771c3497949c62623a415d.zip
Extend erl_parse with two Op Map syntax
Example how to construct: #{ K1 => V1, K2 => V2 } How to update: M#{ K1 => V1, K2 := V2 } How to match: #{ K1 := V1, K2 := V2 } = M
-rw-r--r--lib/stdlib/src/erl_parse.yrl14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl
index 5a846266c5..35c33c7796 100644
--- a/lib/stdlib/src/erl_parse.yrl
+++ b/lib/stdlib/src/erl_parse.yrl
@@ -34,7 +34,7 @@ binary_comprehension
tuple
%struct
record_expr record_tuple record_field record_fields
-map_expr map_tuple map_field map_fields map_key
+map_expr map_tuple map_field map_field_assoc map_field_exact map_fields map_key
if_expr if_clause if_clauses case_expr cr_clause cr_clauses receive_expr
fun_expr fun_clause fun_clauses atom_or_var integer_or_var
try_expr try_catch try_clause try_clauses
@@ -60,7 +60,7 @@ char integer float atom string var
'*' '/' 'div' 'rem' 'band' 'and'
'+' '-' 'bor' 'bxor' 'bsl' 'bsr' 'or' 'xor'
'++' '--'
-'==' '/=' '=<' '<' '>=' '>' '=:=' '=/=' '<=' '=>'
+'==' '/=' '=<' '<' '>=' '>' '=:=' '=/=' '<=' '=>' ':='
'<<' '>>'
'!' '=' '::' '..' '...'
'spec' 'callback' % helper
@@ -344,8 +344,14 @@ map_tuple -> '{' map_fields '}' : '$2'.
map_fields -> map_field : ['$1'].
map_fields -> map_field ',' map_fields : ['$1' | '$3'].
-map_field -> map_key '=>' expr :
- {map_field,?line('$1'),'$1','$3'}.
+map_field -> map_field_assoc : '$1'.
+map_field -> map_field_exact : '$1'.
+
+map_field_assoc -> map_key '=>' expr :
+ {map_field_assoc,?line('$1'),'$1','$3'}.
+
+map_field_exact -> map_key ':=' expr :
+ {map_field_exact,?line('$1'),'$1','$3'}.
map_key -> expr : '$1'.