[antlr-interest] #defines in C target

Jim Idle jimi at temporal-wave.com
Tue Dec 14 09:35:24 PST 2010


I had wanted to do that but a limitation in the code generation templates
(which I no longer remember) meant that I could not. You need to suffix your
token names with _ as that is least intrusive. You need only do that for the
tokens that clash and you will find it isn't as much work as you think using
visual studio. You will not notice. The other way I do it is to prefix with
K such as KNULL KTRUE and so on.

Jim



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Justin Murray
> Sent: Tuesday, December 14, 2010 7:48 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] #defines in C target
> 
> Hello,
> 
> 
> 
> I am building a parser for a C target, and am running into issues with
> the generated #defines from the lexer tokens. Essentially, the lexer
> names that were chosen in some cases conflict with other #defines in
> the code (either from our own code, or from standard libraries like
> Windows.h). While I realize that I could just rename the lexer rules to
> remove the conflict, this makes the grammar file less readable, and at
> this point is a considerable amount of work (our language has hundreds
> of keywords). Is it possible to tell the lexer generator to
> prefix/postfix all of these defines to make them more unique, while
> preserving the nice, readable grammar definition file?
> 
> 
> 
> Thank you,
> 
> 
> 
> Justin Murray
> Software Engineer
> jmurray at aerotech.com
> 
> Aerotech, Inc.
> 101 Zeta Drive
> Pittsburgh, PA 15238
> 412-963-7470
> 
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address



More information about the antlr-interest mailing list