[antlr-interest] predicate question

Terence Parr parrt at cs.usfca.edu
Mon May 5 19:27:19 PDT 2008


On May 5, 2008, at 7:17 PM, Gerald Rosenberg wrote:

> Is the question whether
>
> a : {p1}? {action();} {p2}? A | A ;
>
> should perform differently from
>
> a : {p1}? {action(); return true;}? {p2}? A | A ;
>
> From a high level the-grammar-as-a-language point of view, seems  
> like those two rules should match equivalently.

p1 / p2 are evaluated out of order of normal flow, which is the  
issue.  Predicates can be hoisted into parsing decision, which  
different than the matching. the matching works...prediction won't :)

Ter


More information about the antlr-interest mailing list