[antlr-interest] Lexer and Parser class packaging
Cameron Taggart
cameron.taggart at gmail.com
Sun Jun 17 17:47:12 PDT 2007
I didn't see this in the FAQ yet.
http://www.antlr.org/wiki/display/ANTLR3/ANTLR+v3+FAQ
As a newbie, I just ran into it. :(
On 2/5/07, Terence Parr <parrt at cs.usfca.edu> wrote:
>
> On Feb 5, 2007, at 8:40 AM, Martin Probst wrote:
>
> > Hi,
> >
> >> You need to use @header::lexer and @header::parser. Otherwise the
> >> header element will only appear in one of them (can't remember
> >> which it is now by default ;-).
> >
> > Why is that actually so? Apparently 95% of all beginners with ANTLR
> > 3 run into this problem, maybe you should simply adjust to the
> > users and make @header {} be inherited by both parser and lexer?
>
> Well, this has come up a number of times. I suppose that
>
> @header {package foo;}
>
> Could split across both lexer and parser, but then @members {int i;}
> should parallel this and send the member declaration to both parser
> and lexer, which I can't agree with.
>
> I don't like special cases; either we insist that the lack of a scope
> means both or it means parser. Having one with some both and one
> assume parser is not correct.
>
> You can see my conundrum here. clearly if we don't change this it
> will have to be the first entry in the FAQ ;)
>
> Ter
More information about the antlr-interest
mailing list