G unit tests giving NullPointerException

90 views Asked by At

I am using G Unit for the first time for testing Antlr3 grammar but while running the tests, I am getting NullPointerException.

Exception occurs only when there is a method call in the action part of the grammar rule.

Example:

identifier
: name=ID 
{
obj.identStmt($name.text, this.currentLine, this.currentPos);
}
;

ID: ('a'..'z'|'A'..'Z')+;

While debugging, I get NullPointerException at:

obj.identStmt($name.text, this.currentLine, this.currentPos);

I want to know if it is possible to write G unit test case for such a scenario and if yes then how and what I am doing wrong.

Thanks in advance.

1

There are 1 answers

0
AudioBubble On

If i were u , i would use

        ID : Identifier (Identifier)+;
        Identifier : ('a'..'z'|'A'..'Z');

Just a thought , Your grammar stating that Id ca