[erlang-questions] The preprocessor

Vlad Dumitrescu <>
Fri Oct 16 19:46:25 CEST 2015


Hi!

This is related to the new EEP 44, but different. That discusson made clear
something that has been bothering me for a while, but I couldn't put my
finger on it.

The preprocessor runs in two different stages: one that handles -include
and macros, and one that handles conditional compilation. Because of the
restrictions that macros can't be multi-form and that conditional markers
have to be well-formed inside one file, the latter stage is basically a
parser, albeit a simpler one than erl_parse. Instead of building a complete
tree, it throws away the parts that aren't used. In the current
implementation, these stages are intertwined, as the lexing and parsing are
done in lock-step.

I wonder: would it be worth to separate these stages completely? The first
stage is the one that few people like and many complain about. The latter
is useful.

In conclusion, what if the preprocessor is split in two and the second pass
can be configured to return the whole tree, with the chunks guarded by
conditional expressions? I think all tools that handle raw source code
would benefit from having access to the actual processor instead of writing
their own. The two smaller tools will probably be easier to maintain, too.

best regards,
Vlad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151016/251ab841/attachment.html>


More information about the erlang-questions mailing list