[antlr-interest] Testing a grammar with output=template setting through gUnit

Vinicius Durelli vinicius.durelli at gmail.com
Wed Aug 15 17:54:12 PDT 2012


Hi all,

I am trying to test the CMinus grammar (from Terence's book) just to get
the hang of using gUnit.
However, I am getting the following error message:

$ java -cp ./antlr-3.4-complete.jar:. org.antlr.gunit.Interp CMinus.gunit
-----------------------------------------------------------------------
executing testsuite for grammar:CMinus with 1 tests
-----------------------------------------------------------------------
1 failures found:
test1 (variable, line4) -
expected: int x; /* x variable declaration*/
actual: java.lang.ClassCastException: org.antlr.runtime.CommonTokenStream
cannot be cast to org.antlr.runtime.TokenRewriteStream


Here is my gunit file:

gunit CMinus;

variable:
<<
int x;
>> -> "int x; /* x variable declaration*/"

Am I missing something? How do I state that my grammar is set to output a
template?

(I am running antlr 3.4)

Best,
Vinicius


More information about the antlr-interest mailing list