[antlr-interest] Antlr 3 doesn't like '%' operator in actions?

Bernardo Elayda belayda at gmail.com
Thu Jun 21 10:18:24 PDT 2007


Hi,

I needed to create some actions and functions that you the Java modulus
operator.  I expected Antlr 3 to ignore it but I'm getting an error when I
compile my grammar that says:

invalid StringTemplate % shorthand syntax '%'

Why isn't Antlr just passing over the code in the action?  In  general,  I
found that whenever '%' was used in code in an action or in the @members
section, I get the above error.  Am I missing something here?

A simple example is below.

regards,
Bernardo


-------------------------------

grammar Mytest;

options{
output=AST;
}


prog : lhs=MYINT (MYCOMMA MYINT)*
     {
            Integer temp = new Integer($lhs.text);
            int i = temp.intValue();
            int j = i % 16;
     }
     ;

MYINT : ('0'..'9')+
      ;

MYCOMMA : ','
        ;

WS : ('\r'|'\n'|' '|'\t')+ {$channel=HIDDEN;}
   ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070621/a70f51b6/attachment.html 


More information about the antlr-interest mailing list