[antlr-interest] C++ compliance of antlr generated code

Maurizio de Pascale mdepascale at dii.unisi.it
Sun Dec 31 05:59:22 PST 2006


Hi Kay, Sohail,
thank you for your responses.

I know that strictly speaking this is a non-issue, since in the worst 
case these "unhappy" vars could at most hide some strange 
implementation-defined symbols in the global namespace (which however 
could cause problems in some weird user defined actions).
However, code lives also of conventions, and to the brainlexer of most 
C++ programmers any symbol starting with '_' is a compiler/os specific 
hack, whatever namespace it is supposed to be into.
So I was not saying that this is a bug, or that it will break some code 
in the future, but since I suppose that the C++ target for ANTLR3 is 
already being rewritten, I still suggest that it could be worth to do a 
bit of find-and-replace to handle this.

I've read the old post you pointed to, and I agree this is not a 
bug/issue, but the real (still to be answered) question is:
Is there a good reason to keep in ANTLR3 C++ generated code variables 
starting with '_' ?
Why is _ttype better than ttype, tokenType, token_type, or whatever one 
can choose?

thank you,
Maurizio de Pascale
mdepascale at dii.unisi.it

P.S. is ANTLR3 C++ target complete?




Kay Roepke wrote:
>
> On 29. Dec 2006, at 17:34 , sohail at taggedtype.net wrote:
>
>> Quoting Maurizio de Pascale <mdepascale at dii.unisi.it>:
>>
>>> the C++ code generated by ANTLR (latest 2.7.X) uses lots of variables
>>> starting with '_', which is however forbidden by the standard since
>>> symbols starting with an underscore are reserved to the implementation.
>>> I suggest taking care of this for the ANTLR 3 C++ target.
>>
>> From what I recall, symbols starting with _ are reserved in the 
>> global namespace.
>
> Hi!
>
> We had a discussion about this over on antlr-dev a while ago. Please 
> see my reply at
> <http://antlr.org/pipermail/antlr-dev/2006-November/000729.html> 
> for the gist
> of it.
>
> Ric has agreed that it doesn't appear to be a problem, just as Sohail 
> said.
> I don't think this will need to be changed.
>
> cheers,
>
> -k
> --Kay Röpke
> http://classdump.org/
>
>
>
>
>


More information about the antlr-interest mailing list