[antlr-interest] Q: move from v2 to v3 parser grammar. Rewrite tree rule

Jim Idle jimi at temporal-wave.com
Tue Mar 22 16:54:28 PDT 2011


You can do it the same way in v3, but when you generate the code, ANTLR
will make up token names and you won't be able to write a good error
display routine/handler because you won't know the tokens. You will just
have T23 or something like that, and then you can't do anything
interesting. So, you don't HAVE to, but it is neater when you come to do
certain things.

Jim

> -----Original Message-----
> From: Ruslan Zasukhin [mailto:ruslan_zasukhin at valentina-db.com]
> Sent: Tuesday, March 22, 2011 2:43 PM
> To: Jim Idle; Michail Kropivka
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Q: move from v2 to v3 parser grammar.
> Rewrite tree rule
>
> On 3/22/11 11:27 PM, "Jim Idle" <jimi at temporal-wave.com> wrote:
>
> >>> However, using lower case literals in your parser directly is not a
> >>> good idea.  Use real tokens so that you error messages are better
> >>
> >> Simple example, please?
> >
> > Instead of:
> >
> > rule : 'join' somerule;
> >
> > Use:
> >
> > rule : JOIN somerule;
> >
> > // Lexer rule to match:
> > //
> > JOIN : 'join';
>
>
> Clear.
>
> But this is exactly what was NOT needed in ANTLR v2.
> And ANTLR was proud that we can write tokens directly in grammar.
>
> Collecting all this tokens into Lexer is additional manual work. No?
> Similar to  Lexer :)
>
>
> So for me not clear why this is better now for v3?
>
>
>
>
> ==============
> > And for case insensitivity I specify the token specs all in UPPPER
> > rather than lower and then override the input stream as per:
> >
> > http://www.antlr.org/wiki/pages/viewpage.action?pageId=1782
> >
> > Although someone has added instructions for generating the slowest
> > case insensitive lexers in the world with individual letter rules.
> Use
> > the input stream override method in general.
>
> Yes, we have see this page ...
>
> > Support for case insenstive matching is built in to the C target
> input
> > streams. To use it, you must make a method call before using the
> input
> > stream as in the example below and specify all your keyword/lexer
> > tokens in UPPER CASE only
>
>     JOIN above  is that  UPPER CASE  example?
>
> I ask because   'join'  above still is in low case ...
>
>
>
> --
> Best regards,
>
> Ruslan Zasukhin
> VP Engineering and New Technology
> Paradigma Software, Inc
>
> Valentina - Joining Worlds of Information http://www.paradigmasoft.com
>
> [I feel the need: the need for speed]
>


More information about the antlr-interest mailing list