[antlr-interest] gUnit: Test of a parser rule always fail
Simon Marchi
simon.marchi at polymtl.ca
Fri May 20 15:33:08 PDT 2011
Hello !
I a trying to automatize the testing of my grammar using gUnit, but I
ran into the following problem: when I try to test a parser rule, the
input string is never recognized. The lexer rules can be tested
without problem. I made a simple example to illustrate:
Grammar file Cool.g:
grammar Cool;
options {language = Java;}
@lexer::header {package a.b.c;}
@header {package a.b.c;}
// Parser rule
fullName: FIRSTNAME LASTNAME;
// Lexer tokens
FIRSTNAME: 'SIMON';
LASTNAME: 'MARCHI';
gUnit file Cool.gunit:
gunit Cool;
@header {package a.b.c;}
// The test case
fullName:
"SIMON MARCHI" OK
Normally, the test case should pass, since the input is part of the
grammar. I use the ANTLR plugin inside Eclipse, and pasting the input
("SIMON MARCHI") in the interactive interpreter tells me that it is
accepted by the rule fullName. However, the test fails. If I change
from OK to FAIL, then the test passes (obviously).
Is there anything I am doing wrong here ?
Thank you,
Simon
More information about the antlr-interest
mailing list