[antlr-interest] [V3] '%' in java code obtains unexpected
StringTemplate error
John B. Brodie
jbb at acm.org
Fri Aug 11 19:31:32 PDT 2006
Sorry if this is a duplicated report, I did not see anything that I
thought was similar on the wiki...
This grammar:
grammar T;
@members {
private void hello() { System.out.format("hello%n"); }
}
junk : FOO { System.out.format("junk says:%n"); hello(); } ;
FOO : 'foo' ;
gets this output from the tool:
ANTLR Parser Generator Early Access Version 3.0b3 (July 21, 2006) 1989-2006
t.g:2:10: invalid StringTemplate % shorthand syntax: '%n")'
t.g:5:12: invalid StringTemplate % shorthand syntax: '%n")'
Workaround: Replacing each occurrence of '%' above with '\%' fixes the
problem. No messages from the tool and javac 1.5 compiles/runs no
problem.
Thanks!
-jbb
More information about the antlr-interest
mailing list