diff options
author | Anthony Ramine <[email protected]> | 2014-02-01 04:20:00 +0100 |
---|---|---|
committer | Anthony Ramine <[email protected]> | 2014-02-01 04:20:00 +0100 |
commit | 81824d20efb18b08d53aa5bb7e1c764074f473e7 (patch) | |
tree | c4db0a3a653b3a3d09cf6dc9c3bbd1719a63df8a /lib/syntax_tools/src | |
parent | 53a9a250470c29334a07dddafb6b1adcde39596b (diff) | |
download | otp-81824d20efb18b08d53aa5bb7e1c764074f473e7.tar.gz otp-81824d20efb18b08d53aa5bb7e1c764074f473e7.tar.bz2 otp-81824d20efb18b08d53aa5bb7e1c764074f473e7.zip |
Support maps in erl_prettypr
Diffstat (limited to 'lib/syntax_tools/src')
-rw-r--r-- | lib/syntax_tools/src/erl_prettypr.erl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/syntax_tools/src/erl_prettypr.erl b/lib/syntax_tools/src/erl_prettypr.erl index 1ffcf31134..4d6e88f58b 100644 --- a/lib/syntax_tools/src/erl_prettypr.erl +++ b/lib/syntax_tools/src/erl_prettypr.erl @@ -892,6 +892,32 @@ lay_2(Node, Ctxt) -> beside(floating(text(".")), D2)), maybe_parentheses(D3, Prec, Ctxt); + map_expr -> + {PrecL, Prec, _} = inop_prec('#'), + Ctxt1 = reset_prec(Ctxt), + D1 = par(seq(erl_syntax:map_expr_fields(Node), + floating(text(",")), Ctxt1, fun lay/2)), + D2 = beside(text("#{"), beside(D1, floating(text("}")))), + D3 = case erl_syntax:map_expr_argument(Node) of + none -> + D2; + A -> + beside(lay(A, set_prec(Ctxt, PrecL)), D2) + end, + maybe_parentheses(D3, Prec, Ctxt); + + map_field_assoc -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:map_field_assoc_name(Node), Ctxt1), + D2 = lay(erl_syntax:map_field_assoc_value(Node), Ctxt1), + par([D1, floating(text("=>")), D2], Ctxt1#ctxt.break_indent); + + map_field_exact -> + Ctxt1 = reset_prec(Ctxt), + D1 = lay(erl_syntax:map_field_exact_name(Node), Ctxt1), + D2 = lay(erl_syntax:map_field_exact_value(Node), Ctxt1), + par([D1, floating(text(":=")), D2], Ctxt1#ctxt.break_indent); + rule -> %% Comments on the name will be repeated; cf. %% `function'. |