Permalink
Browse files

Create a new "column" option in compile

If set, compile will call epp with a full location {1, 1} instead of 1,
thus making it keep the column numbers in the parsed AST.
  • Loading branch information...
1 parent 26ad68f commit f6dc9c00459cba32e06d5eb7a0b9f2c6785a4e4d @nox nox committed Jun 2, 2012
Showing with 13 additions and 1 deletion.
  1. +5 −0 lib/compiler/doc/src/compile.xml
  2. +8 −1 lib/compiler/src/compile.erl
@@ -108,6 +108,11 @@
See the <em>Efficiency Guide</em> for further information.</p>
</item>
+ <tag><c>column</c></tag>
+ <item>
+ <p>The compiler will keep the column numbers while parsing.</p>
+ </item>
+
<tag><c>compressed</c></tag>
<item>
<p>The compiler will compress the generated object code,
@@ -769,7 +769,8 @@ parse_module(St) ->
Opts = St#compile.options,
Cwd = ".",
IncludePath = [Cwd, St#compile.dir|inc_paths(Opts)],
- R = epp:parse_file(St#compile.ifile, IncludePath, pre_defs(Opts)),
+ AtPos = initial_position(Opts),
+ R = epp:parse_file(St#compile.ifile, AtPos, IncludePath, pre_defs(Opts)),
case R of
{ok,Forms} ->
{ok,St#compile{code=Forms}};
@@ -1475,6 +1476,12 @@ objfile(Base, St) ->
tmpfile(Ofile) ->
reverse([$#|tl(reverse(Ofile))]).
+initial_position(Opts) ->
+ case lists:member(column, Opts) of
+ true -> {1, 1};
+ false -> 1
+ end.
+
%% pre_defs(Options)
%% inc_paths(Options)
%% Extract the predefined macros and include paths from the option list.

0 comments on commit f6dc9c0

Please sign in to comment.