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_pp.erl | |
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_pp.erl')
-rw-r--r-- | lib/compiler/src/core_pp.erl | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/lib/compiler/src/core_pp.erl b/lib/compiler/src/core_pp.erl index 01922c3fdf..662ef6c83f 100644 --- a/lib/compiler/src/core_pp.erl +++ b/lib/compiler/src/core_pp.erl @@ -183,15 +183,9 @@ format_1(#c_map{arg=Var,es=Es}, Ctxt) -> "}~" ]; format_1(#c_map_pair{op=#c_literal{val=assoc},key=K,val=V}, Ctxt) -> - ["::<", - format_map_pair(K, V, Ctxt), - ">" - ]; + format_map_pair("=>", K, V, Ctxt); format_1(#c_map_pair{op=#c_literal{val=exact},key=K,val=V}, Ctxt) -> - ["~<", - format_map_pair(K, V, Ctxt), - ">" - ]; + format_map_pair(":=", K, V, Ctxt); format_1(#c_cons{hd=H,tl=T}, Ctxt) -> Txt = ["["|format(H, add_indent(Ctxt, 1))], [Txt|format_list_tail(T, add_indent(Ctxt, width(Txt, Ctxt)))]; @@ -448,11 +442,11 @@ format_list_tail(#c_cons{anno=[],hd=H,tl=T}, Ctxt) -> format_list_tail(Tail, Ctxt) -> ["|",format(Tail, add_indent(Ctxt, 1)),"]"]. -format_map_pair(K, V, Ctxt0) -> +format_map_pair(Op, K, V, Ctxt0) -> Ctxt1 = add_indent(Ctxt0, 1), Txt = format(K, set_class(Ctxt1, expr)), Ctxt2 = add_indent(Ctxt0, width(Txt, Ctxt1)), - [Txt,",",format(V, Ctxt2)]. + [Txt,Op,format(V, Ctxt2)]. indent(Ctxt) -> indent(Ctxt#ctxt.indent, Ctxt). |