[antlr-interest] antlr-interest Digest, Vol 50, Issue 24

Bill Cox bill at qswtools.com
Fri Jan 23 12:29:48 PST 2009


Re: preprocessing an ANTLR grammar

I've been able to use the GNU C preprocessor for a Pascal compiler in the past.
As you imply, the difficulty is in turning OFF all the C-specific stuff:
You can use -D and -U to set/unset variables
You should use:
-nostdinc         suppress looking for std libs
-P                    inhibit c-specific line-number tracking lines from output
-C                    do not discard comments
I haven't done this in a long while.  Here's the reference:
http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Preprocessor-Options.html#Preprocessor-Options

>>>>> I need to generate C and Java from an ANTLR grammar containing
>>>>> actions. Is there a preprocessor approach I can use rather than
>>>>> maintaining two versions of the grammar?


More information about the antlr-interest mailing list