[antlr-interest] rule names collision with reserved words in target language
Magnus Danielson
magnus at rubidium.dyndns.org
Sat Oct 11 14:36:46 PDT 2008
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.
Cheers,
Magnus
More information about the antlr-interest
mailing list