8 Feb 19:42
Macro preprocessor
Jonathan Lee <jonjlee <at> gmail.com>
2012-02-08 18:42:37 GMT
2012-02-08 18:42:37 GMT
Hello everyone, I am very new to SableCC, so please bear with me. I would like to implement an Erlang parser, and I've written the main grammar. However, Erlang supports preprocessing. For example, macros can be defined and applied as: -define(MACRO, "abc"). f() -> ?MACRO. I am trying to understand how to create a preprocessor that integrates with SableCC. I've looked at the Java 1.5 unicode preprocessor, but that is much simpler than what I need -- it simply replaces escaped tokens as they occur. I've thought of writing a preprocessor grammar, parsing the text once, modifying the AST, outputting back to a string, and finally reparsing with the main grammar. But my gut feel is that that's a poor approach, especially with the need to output an intermediate string. Is there a standard way of doing this, or an example of this anywhere? Is there a simple way to chain a preprocessor and parser together in SableCC? Thanks for your help! Jonathan
RSS Feed