[antlr-interest] automatically generated syntatic predicates become semantic predicates (fragments) plus arguments generate parser which doesn't compile

Doucette, Charles cdoucette at vaultus.com
Tue Sep 16 07:07:45 PDT 2008


> That seems suspicious. Are you sure that no alternative is
> disabled? Do you use backtracking for convenience? There is a
> tutorial which describes the removal of global backtracking
> on the wiki.

I don't know what it means for "no alternative to be disabled."

Here are my grammar options:


> >
> > Here's the one that is giving me trouble:
> ...
> > When I look at this rule in ANTLRworks, it says that the production
> > for commonObjectBodyElement corresponds to the semantic predicate
> > {synpred20_vscript}?.
> >
> > That generated code looks like this:
> ...
> > This obviously doesn't compile since it refers to an argument of a
> > parent rule (which is not part of the current context).
> >
> > Is this an ANTLR bug or a user bug?
> >
> > In any case, how can I refactor my grammar to avoid this situation
> > (and generate a parser which will compile)?
> >
> It's a user bug. Arguments and predicates don't mix. Use
> scopes instead like this.
>
> rule a
> scope {
> int i;
> }
>    : (pred)=> y {$a::i = 3;}
>    ;
>
> Johannes
>


More information about the antlr-interest mailing list