[antlr-interest] uh oh...trouble in meaning of (..)=> pred!!!

Loring Craymer lgcraymer at yahoo.com
Wed Mar 14 16:27:33 PDT 2007


Ter--

As a first step, predicates should not specify more
tokens that the alternative being selected.  That
would rule out the example grammar.

As to the ordering problem:  the original expectation
was that LL* "did not need no stinking syntactic
predicates" and that automatic and silent elimination
was a good thing since synpreds were a no-op.  Given
that synpreds are sometimes needed in v3, I think that
it makes more sense to always generate code for them
but to issue an "extraneous synpred" warning so that
the grammar developer can remove them.  [You could
also add some machinery (a flag in the predicate
object or some such) to turn off warnings for
automatically generated synpreds (backtracking =
true).]

--Loring

--- Terence Parr <parrt at cs.usfca.edu> wrote:

> Hi.  Harmut submitted a bug report, which I have
> converted to a parser:
> 
> grammar T;
> 
> x : (a d) => a
>    | (b d) => b
>    | ('a'|'b')+
>    ;
> 
> a       :       'a' 'a' ;
> b       :       'a' 'a' 'b' ;
> digit   :       '0'|'1' ;
> 
> Basically, in the book and in my intentions,
> predicates order the  
> alts.  The problem is that ANTLR's analysis doesn't
> consider  
> syntactic predicates if it can figure out what to do
> w/o them.   
> That's an optimization.  The problem is that you are
> often specifying  
> the lookahead in the predicate that must be
> evaluated.  Crap.  ANTLR  
> is not forcing those predicates in there.
> 
> For semantic predicates, we have {...}? and {...}?=>
> where the latter  
> forces backtracking.  Perhaps (...)=> should always
> force  
> backtracking.  BUT, for backtracking=true, I add a
> predicate to every  
> alt!  I guess for that backtracking mode, those
> predicates should be  
> analogous to {...}? and manually specified (...)=>
> should operate  
> like {..}?
> 
> I have exactly 4 days to resolve this issue before
> the book goes to  
> copy editing.  Anybody wanna help me think about
> this?
> 
> Ter
> 



 
____________________________________________________________________________________
Now that's room service!  Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097


More information about the antlr-interest mailing list