aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-02-12 14:30:21 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-02-12 14:30:21 +0100
commitce1e2d3e865c42b01c8088ee07470a6f25be55cb (patch)
tree6ed33b1a5084c22142de16a3a345d2f204fd61e7 /lib/stdlib/src
parentf6d12d4b4ebce206c637ecadfaa3ec46e52b0383 (diff)
parent57939ce49accf39bc153f0d6e1ab2ca5e1bee534 (diff)
downloadotp-ce1e2d3e865c42b01c8088ee07470a6f25be55cb.tar.gz
otp-ce1e2d3e865c42b01c8088ee07470a6f25be55cb.tar.bz2
otp-ce1e2d3e865c42b01c8088ee07470a6f25be55cb.zip
Merge branch 'nox/maps-erl_prettypr'
* nox/maps-erl_prettypr: stdlib: Add tests for Maps in erl_prettypr Support maps in erl_prettypr
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/erl_pp.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/stdlib/src/erl_pp.erl b/lib/stdlib/src/erl_pp.erl
index 8a1d8e0440..9dbe89da91 100644
--- a/lib/stdlib/src/erl_pp.erl
+++ b/lib/stdlib/src/erl_pp.erl
@@ -479,6 +479,15 @@ lexpr({record_field, _, Rec, F}, Prec, Opts) ->
{L,P,R} = inop_prec('.'),
El = [lexpr(Rec, L, Opts),$.,lexpr(F, R, Opts)],
maybe_paren(P, Prec, El);
+lexpr({map, _, Fs}, Prec, Opts) ->
+ {P,_R} = preop_prec('#'),
+ El = {first,leaf("#"),map_fields(Fs, Opts)},
+ maybe_paren(P, Prec, El);
+lexpr({map, _, Map, Fs}, Prec, Opts) ->
+ {L,P,_R} = inop_prec('#'),
+ Rl = lexpr(Map, L, Opts),
+ El = {first,[Rl,leaf("#")],map_fields(Fs, Opts)},
+ maybe_paren(P, Prec, El);
lexpr({block,_,Es}, _, Opts) ->
{list,[{step,'begin',body(Es, Opts)},'end']};
lexpr({'if',_,Cs}, _, Opts) ->
@@ -671,6 +680,16 @@ record_field({typed_record_field,Field,Type}, Opts) ->
record_field({record_field,_,F}, Opts) ->
lexpr(F, 0, Opts).
+map_fields(Fs, Opts) ->
+ tuple(Fs, fun map_field/2, Opts).
+
+map_field({map_field_assoc,_,K,V}, Opts) ->
+ Pl = lexpr(K, 0, Opts),
+ {list,[{step,[Pl,leaf(" =>")],lexpr(V, 0, Opts)}]};
+map_field({map_field_exact,_,K,V}, Opts) ->
+ Pl = lexpr(K, 0, Opts),
+ {list,[{step,[Pl,leaf(" :=")],lexpr(V, 0, Opts)}]}.
+
list({cons,_,H,T}, Es, Opts) ->
list(T, [H|Es], Opts);
list({nil,_}, Es, Opts) ->