From f30c9daeaa83888abdb2622f249066c886cc0a62 Mon Sep 17 00:00:00 2001 From: Juan Facorro Date: Tue, 11 Nov 2014 12:31:53 -0300 Subject: [PATCH] [#7] Assign the location of the macro to the tokens that replace it. --- src/aleppo.erl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/aleppo.erl b/src/aleppo.erl index d06f427..a2be70c 100644 --- a/src/aleppo.erl +++ b/src/aleppo.erl @@ -142,12 +142,19 @@ process_tree([Node|Rest], TokenAcc, Context) -> {'macro', {var, Attrs, 'LINE'}} -> {Line, _} = location(Attrs), process_tree(Rest, [{integer, Attrs, Line}|TokenAcc], Context); - {'macro', {_Type, _Loc, MacroName}} -> + {'macro', {_Type, Attrs, MacroName}} -> InsertTokens = dict:fetch(MacroName, Context#ale_context.macro_dict), {_, RevProcessedTokens} = process_tree(InsertTokens, [], Context), - process_tree(Rest, RevProcessedTokens ++ TokenAcc, Context); + + LocFun = fun + ({T, _, V}) -> {T, Attrs, V}; + (Token) -> Token + end, + RevProcessedTokens1 = lists:map(LocFun, RevProcessedTokens), + + process_tree(Rest, RevProcessedTokens1 ++ TokenAcc, Context); {'macro', {_Type, Loc, MacroName}, MacroArgs} -> InsertTokens = case dict:find({MacroName, length(MacroArgs)},