I've been performing a series of abominations on the Erlang
scanner/parser/compiler pipeline and found myself in need of a
preprocessor that's not epp. My problem with epp is that the API is
very file oriented (you have to call "open" before you can do any
preprocessing) and insists on doing parsing too. I just want to pass
in a list of erl_scan-compatible tokens and have the macros expanded
and directives executed and receive back a list of preprocessed tokens
without any substantial parsing done.
So here's a rough cut of Aleppo, an ALternative Erlang Pre-ProcessOr:
It's very alpha but implements basic versions of -define, -undef,
-ifdef, -ifndef, -include, and -include_lib and the associated macro
expansion. You can't use Aleppo on its own, it's meant to be the
missing link between erl_scan and erl_parse for people who like to
mess with those things :-)
Aleppo is implemented with Yecc. Bonus feature: preprocessor
directives can appear inside function forms with no problem.