From 910b70f6b68dac1f0b573b7013d86cb0ec0c8775 Mon Sep 17 00:00:00 2001 From: Mariano Guerra Date: Wed, 25 Mar 2015 11:15:34 -0300 Subject: [PATCH] add colon back to match for consistency --- examples/all.fn | 2 +- src/efene.erl | 3 +-- src/fn_parser.yrl | 4 ++-- src/fn_pp.erl | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/all.fn b/examples/all.fn index d803ba1..661b5b9 100644 --- a/examples/all.fn +++ b/examples/all.fn @@ -216,7 +216,7 @@ fn types @public end case match_expr: Error = (throw, badarg) - match Error + match Error: case throw, T1: T1 case error, E1: E1 case exit, X1: X1 diff --git a/src/efene.erl b/src/efene.erl index d6dc0a6..9e44d32 100644 --- a/src/efene.erl +++ b/src/efene.erl @@ -190,14 +190,13 @@ clean_tokens([{arrow, _, _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accu clean_tokens([{arrowend, _, _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); clean_tokens([{larrow, _, _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); clean_tokens([{larrowend, _, _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); -% remove newline after try, catch, after, receive, begin, match +% remove newline after try, catch, after, receive, begin clean_tokens([{'try', _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); clean_tokens([{'catch', _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); clean_tokens([{'after', _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); clean_tokens([{'receive', _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); clean_tokens([{'begin', _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); clean_tokens([{'fn', _}=H, {nl, _, _}|T], Accum) -> clean_tokens([H|T], Accum); -clean_tokens([{'match', _}=H1, H2, {nl, _, _}|T], Accum) -> clean_tokens([H1, H2|T], Accum); clean_tokens([{'fn', _}=H1, {var, _, _}=H2, {nl, _, _}|T], Accum) -> clean_tokens([H1, H2|T], Accum); clean_tokens([{'fn', _}=H1, {atom, _, _}=H2, {nl, _, _}|T], Accum) -> clean_tokens([H1, H2|T], Accum); diff --git a/src/fn_parser.yrl b/src/fn_parser.yrl index 81afe2c..02b27d0 100644 --- a/src/fn_parser.yrl +++ b/src/fn_parser.yrl @@ -76,8 +76,8 @@ e_cases -> e_case_cond : ['$1']. e_cases -> e_case_cond e_case_else : ['$1', '$2']. e_cases -> e_case_cond e_cases : ['$1'|'$2']. -e_switch -> match literal e_case end: - {expr, line('$1'), switch, {'$2', '$3'}}. +e_switch -> match literal colon e_case end: + {expr, line('$1'), switch, {'$2', '$4'}}. e_receive -> receive e_case end: {expr, line('$1'), 'receive', {'$2', noafter}}. diff --git a/src/fn_pp.erl b/src/fn_pp.erl index 960a26d..13f4fd2 100644 --- a/src/fn_pp.erl +++ b/src/fn_pp.erl @@ -127,7 +127,7 @@ print(?E(_L, 'receive', {?E(_CLine, 'case', Clauses), After}), Str, Nl, Indent) ind(Indent)]); print(?E(_L, switch, {Value, ?E(_CaseLine, 'case', Clauses)}), Str, Nl, Indent) -> - fmt(Str, "match ~s~n~s~send", true, Indent, [print_single(Value), + fmt(Str, "match ~s:~n~s~send", true, Indent, [print_single(Value), print_clauses(Clauses, Nl, Indent + 1), ind(Indent)]);