[antlr-interest] Rule Arguments and Automatically Generated Syntactic Predicates

Randall R Schulz rschulz at sonic.net
Tue Jul 24 08:07:57 PDT 2007


Hi,

I have a rule (the accept state for this particular tree grammar) with 
an argument:

clifUnit [ String unitName ]
returns [ CLPhrase cf ]
@init {
  fAcceptor.startUnit(unitName);
}
  : ( text[unitName]
      {
        $cf = $text.t;
        fAcceptor.acceptText($text.t);
      }

    | ...


This grammar is generated with backtrack and memoize both enabled. When 
I generate a Java tree parser from this grammar, this method is 
generated:

  // $ANTLR start synpred1
  public final void synpred1_fragment() throws RecognitionException {
    // CLIFBuilder.g:647:6: ( text[unitName] )
    // CLIFBuilder.g:647:6: text[unitName]
    {
      pushFollow(FOLLOW_text_in_synpred1108);
      text(unitName);
      _fsp--;
      if (failed) return ;

    }
  }
  // $ANTLR end synpred1


The problem is, the unitName argument is not propagated to the formal or 
actual parameters of this method.


Is this a bug or a known limitation?


Randall Schulz


More information about the antlr-interest mailing list