Skip to content

Commit

Permalink
Merge pull request ErlyORM#8 from inaka/jfacorro.7.fix.token.location
Browse files Browse the repository at this point in the history
[ErlyORM#7] Assign the location of the macro to the tokens that replace it.
  • Loading branch information
Brujo Benavides committed Nov 11, 2014
2 parents 95e7bc6 + f30c9da commit cc75a94
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 cc75a94

Please sign in to comment.