[antlr-interest] Failing parser rule test in GUnit

Martin Kempf martin.kempf at gmail.com
Wed May 2 07:31:59 PDT 2012


Hi there

I'am using GUnit together with maven to test my grammar. The setup was 
pretty easy due to good information from: 
http://www.antlr.org/wiki/display/ANTLR3/gUnit+-+Maven+Integration

But I am sticking now with the test on parser rules. I have the 
following grammar.

---- grammar.g------------
grammar TParser;

options {
   language = Java;
   output   = AST;
}

@header {
package antlr.test;
}

@lexer::header {
package antlr.test;
}

builtInType
   :
   LITERAL_int
   ;


PATTERN_TYPE
   :
   'IPattern'
   ;

LITERAL_int
   :
   'int'
   ;

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

and the follwoing test file:


------ test.gunit --------------
gunit TParser;

@header{package antlr.test;}

//test parser rules
builtInType:
"int" OK

// test lexical rules
PATTERN_TYPE:
"IPattern" OK

LITERAL_int:
"int" OK

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

the tests for the lexer work as expected, but the parser rule test does 
not pass although I think they should. The output of maven starting with 
the command: "mvn test" is as follows:

Failed tests:   testBuiltInType1(TestTParser): testing rule builtInType 
expected:<OK> but was:<FAIL, >

Why does this parser rule test fail?

The version I use are:
Antlr: 3.4
antlr-runtime: 3.4
gunit: 3.4
jUnit: 3.8.1

It would be nice to receive some hints on this behaviour. A similar 
situation, that a parsing rule test did not succeed, I found here: 
http://antlr.1301665.n2.nabble.com/gUnit-help-needed-td6391239.html but 
without a solution.
The situation I am faceing might be similar?

thanks,
Martin


More information about the antlr-interest mailing list