[antlr-interest] BUG (JAVA): Generics not permitted in Antlr rule parameter lists
Austin Hastings
Austin_Hastings at Yahoo.com
Sun Nov 11 12:44:57 PST 2007
Note that this doesn't purport to work - I just jammed some text in to
reproduce the behavior.
testSuite[List<GunitTest> tests]
: rule1=ID ('walks' rule2=ID)? ':'
{
String method1 = $rule1.text;
if (isLexerMethod(method1) && method1.charAt(0) != 'm')
{
method1 = 'm' + method1;
}
String method2 = (rule2 != null) ? $rule2.text : null;
}
(tc=testCase[method1, method2, $tests]
{
if ($tc.test != null)
{
$tests.add($tc.test);
}
}
)+
';'
;
testCase[String m1, String m2, List<GunitTest> tests] returns [GunitTest
test]
: input '->' outputExpr
{
$test = newTestCase(m1, m2, $input.test_input, $outputExpr.expect);
}
;
compile:
[antlr3] ANTLR Parser Generator Version 3.0.1 (August 13, 2007)
1989-2007
[antlr3] warning(200):
/home/austin/gunit/sources/org/antlr/gunit/TestSuite.g:433:16: Decision
can match input such as "'(' QUOTED_LITERAL ')'" using multiple
alternatives: 1, 2
[antlr3] As a result, alternative(s) 2 were disabled for that input
[javac] Compiling 2 source files to /home/austin/gunit/classes
[javac] /home/austin/gunit/sources/org/antlr/gunit/TestSuiteLexer.java
[javac] /home/austin/gunit/sources/org/antlr/gunit/TestSuiteParser.java
[javac]
/home/austin/gunit/sources/org/antlr/gunit/TestSuiteParser.java:710:
illegal start of expression
[javac] tc=testCase(method1, method2, ,
tests);
[javac] ^
[javac] 1 error
=Austin
Gavin Lambert wrote:
> At 17:13 11/11/2007, Austin Hastings wrote:
> >In the Java target, the dreaded string-template failure occurs if a
> >rule has a parameter with generic type:
> >
> >testCase[String m1, String m2, List<TestCase> tests]
> >
> >produces a call like
> >
> >testCase(m1, m2, , tests);
> >
> >and a build failure, etc.
>
> I tried replicating this in 3.0.1, but couldn't -- calls,
> declarations, and return values involving generic types all seemed to
> generate the correct code.
>
> Can you post a more specific repro example? Or are you using an
> earlier version?
>
>
>
More information about the antlr-interest
mailing list