aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools/src/merl_transform.erl
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2015-07-02 13:28:46 +0200
committerHans Bolinder <[email protected]>2015-09-15 14:15:49 +0200
commitd16c327bd35493a3687f7e07e2b332d2d18c5bc8 (patch)
treed6907817794d330611df1ef5a1969fe97ca8116f /lib/syntax_tools/src/merl_transform.erl
parent5ba36a3857eb2673d28fd33ec4655da41ee78d3d (diff)
downloadotp-d16c327bd35493a3687f7e07e2b332d2d18c5bc8.tar.gz
otp-d16c327bd35493a3687f7e07e2b332d2d18c5bc8.tar.bz2
otp-d16c327bd35493a3687f7e07e2b332d2d18c5bc8.zip
syntax_tools: Use the erl_anno module a bit more
Diffstat (limited to 'lib/syntax_tools/src/merl_transform.erl')
-rw-r--r--lib/syntax_tools/src/merl_transform.erl16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/syntax_tools/src/merl_transform.erl b/lib/syntax_tools/src/merl_transform.erl
index 66b06c8137..fe58b6a122 100644
--- a/lib/syntax_tools/src/merl_transform.erl
+++ b/lib/syntax_tools/src/merl_transform.erl
@@ -68,8 +68,7 @@ case_guard([{expr,_}, {text,Text}]) ->
erl_syntax:is_literal(Text).
case_body([{expr,Expr}, {text,_Text}], T) ->
- pre_expand_case(Expr, erl_syntax:case_expr_clauses(T),
- erl_syntax:get_pos(T)).
+ pre_expand_case(Expr, erl_syntax:case_expr_clauses(T), get_location(T)).
post(T) ->
merl:switch(
@@ -79,7 +78,7 @@ post(T) ->
lists:all(fun erl_syntax:is_literal/1, [F|As])
end,
fun ([{args, As}, {function, F}]) ->
- Line = erl_syntax:get_pos(F),
+ Line = get_location(F),
[F1|As1] = lists:map(fun erl_syntax:concrete/1, [F|As]),
eval_call(Line, F1, As1, T)
end},
@@ -118,7 +117,7 @@ expand_qquote(_As, T, _StartPos) ->
expand_template(F, [Pattern | Args], T) ->
case erl_syntax:is_literal(Pattern) of
true ->
- Line = erl_syntax:get_pos(Pattern),
+ Line = get_location(Pattern),
As = [erl_syntax:concrete(Pattern)],
merl:qquote(Line, "merl:_@function(_@pattern, _@args)",
[{function, F},
@@ -260,3 +259,12 @@ is_erlang_var([C|_]) when C >= $A, C =< $Z ; C >= $À, C =< $Þ, C /= $× ->
true;
is_erlang_var(_) ->
false.
+
+get_location(T) ->
+ Pos = erl_syntax:get_pos(T),
+ case erl_anno:is_anno(Pos) of
+ true ->
+ erl_anno:location(Pos);
+ false ->
+ Pos
+ end.