[erlang-questions] Parse Transform with Macros

Evan Miller emmiller@REDACTED
Sun Mar 6 18:27:40 CET 2011


Hi Tristan,

Aleppo will apply preprocessor macros on tokens returned by erl_scan:

https://github.com/evanmiller/aleppo

I think it will fit your needs. Aleppo also lets you use -ifdef and
the like inside of functions since it uses a proper grammar for the
macro syntax.

On Sun, Mar 6, 2011 at 9:41 AM, Tristan Sloughter
<tristan.sloughter@REDACTED> wrote:
> I'd like to construct a parse transform that has a macro in the inserted
> code. I've had no problem using erl_scan:tokens and erl_parse:parse_form to
> construct the AST as long as no macros exist.
>
> Since macros are expanded before getting to this point it fails if in the
> string scanned has something like ?MODULE. I looked at epp_dodger and
> elsewhere but I can't seem to find something I could use to send in a string
> like:
>
> "init() -> ?MODULE."
>
> And have tokens I could use to then generate the AST.
>
> Is this possible?
>
> Thanks,
> Tristan
>



-- 
Evan Miller
http://www.evanmiller.org/


More information about the erlang-questions mailing list