[antlr-interest] rule names collision with reserved words in target language

Johannes Luber jaluber at gmx.de
Sat Oct 11 14:54:50 PDT 2008


Magnus Danielson schrieb:
> Hi!
> 
> As I was working on a project I had a bug that took some time to figure 
> out. It crashed and burned as I compiled it. The trouble was that I hade 
> a rule named const in my grammar, and producting a routine called const 
> in the produced C code. Now, const is a reserved word so GCC spewed 
> severly upon it.
> 
> If I had used prefixing it would have solved itself. Renaming it solved 
> it, but you would rather want either a warning/error occur up in the 
> ANTLR front or a backend renaming to occur to avoid it, if needed (i.e. 
> if reserved for the target language and no prefixing is used).
> 
> I think this problem can occur with other languages than C, so it could 
> be worth considering. Oh, I was using 3.0.1 if you where asking.

This problem is known, but until name mangling is implemented not much
can be done. ANTLR is largely language agnostic and doesn't know if a
rule has the same name as a reserved word. Maybe putting a warning on
the wiki to that effect.

Johannes
> 
> Cheers,
> Magnus
> 
> 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