Skip to content

Commit

Permalink
[ErlyORM#7] Assign the location of the macro to the tokens that repla…
Browse files Browse the repository at this point in the history
…ce it.
  • Loading branch information
jfacorro committed Nov 11, 2014
1 parent 95e7bc6 commit f30c9da
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/aleppo.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down

0 comments on commit f30c9da

Please sign in to comment.