[antlr-interest] DMQL Grammar - ANTLR Eats Characters

Terence Parr parrt at cs.usfca.edu
Fri Mar 20 17:05:49 PDT 2009


lexer grammar T;

options {backtrack=true;}

A :  '(' A ')'
    | '(' A* ')'
   ;

Gives same output ;)

Ter
On Mar 20, 2009, at 5:04 PM, Gavin Lambert wrote:

> At 08:58 21/03/2009, Terence Parr wrote:
> >Well, come to think of it, I have not tried it a while but:
> >
> >A : ('(' A ')')=> '(' A ')'
> >    | '(' A* ')'
> >   ;
> >
> >should work.  Yep, seems to:
> >
> >             if ( (LA2_0=='(') ) {
> >                 int LA2_1 = input.LA(2);
> >
> >                 if ( (synpred1_T()) ) {
> >                     alt2=1;
> >                 }
> >                 else if ( (true) ) {
> >                     alt2=2;
> >                 }
>
> I suspect we're arguing from different usages of the word  
> "backtracking" :)
>
> I was referring to *automatic* backtracking (a la "backtrack=true"  
> option).  I know that explicit predicates work ok.
>



More information about the antlr-interest mailing list