[antlr-interest] Can a rule reference be labled as well?

YiQing Yang yiqing at objectivity.com
Mon Jun 11 18:15:18 PDT 2007


Hi All,

 

I have a simple question regarding labling an elment in a parser rule. The
Reference Manual says  that we can label any atomic or a rule reference with
an identifier. But I can only lable a token, not a reference rule. 

 

For example,

 

addition_operator_exp

  :  atom_expression (p:PLUS|m:MINUS) atom_expression              => OK

    ;

 

addition_operator_exp

  :  atom_expression  opt:(PLUS|MINUS) atom_expression              => error
C2065: 'opt' : undeclared identifier    

 

addition_operator_exp

  :  atom_expression  opt:operator_symbol atom_expression        => error
C2065: 'opt' : undeclared identifier

    ;

operator_symbol: PLUS|MINUS

 

 

I am using antlr2.7.7 to generate C++ paser.

 

Am I missing anything here. Thanks for your help.

 

Yiqing

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070611/71638e63/attachment-0001.html 


More information about the antlr-interest mailing list