[antlr-interest] gUnit doesn't work with rewrite rules

深町英太郎 (E. Fukamachi) e.arrows at gmail.com
Thu Jul 29 20:27:13 PDT 2010


Hi.
I'm trying to develop a simple translator with ANTLR.
I thought "rewrite option" better for me, but gUnit raised
ClassCastException with it.

The following codes have the problem. I'm using ANTLR v3.2 and Java
1.6.0 on Mac OS 10.6.

Do you have any advice?

Thanks.

== T.g ==
{{{
grammar T;
options {output=template; rewrite=true;}

type: 'int' -> template() "Integer";
}}}

== T.gunit ==
{{{
gunit T;

type:
"int" -> "Integer"
}}}

Then, I executed following shell commands.

$ java org.antlr.Tool T.g
$ javac T{Lexer,Parser}.java
$ java org.antlr.gunit.Interp T.gunit

And, I got the following outputs.

{{{
-----------------------------------------------------------------------
executing testsuite for grammar:T with 1 tests
-----------------------------------------------------------------------
1 failures found:
test1 (type, line4) -
expected: Integer
actual: java.lang.ClassCastException:
org.antlr.runtime.CommonTokenStream cannot be cast to
org.antlr.runtime.TokenRewriteStream


Tests run: 1, Failures: 1
}}}

--
Eitarow Fukamachi


More information about the antlr-interest mailing list