I am trying to test some subrules in my parser to check options. The rule I'm checking is an expression rule
expression: expression PLUS expression
In the generated analysis, the method signature:
public final ExpressionContext expression(int _p) throws RecognitionException {
I find it difficult to understand what value to pass as an argument to _p.
When I check the calls to the expression method in the parser, I see that 0 is passed. However, when I try to call parser.expression (0) directly, I get a null pointer exception.
What is the recommended way to call this accessory to enable unit testing?
As a link, here is the code for installing unit test, which I am trying to write:
private Expression parseExpression( String expressionString ) { DataProcessorLexer lexer = new DataProcessorLexer( new ANTLRInputStream( expressionString ) ); DataProcessorParser parser = new DataProcessorParser( new CommonTokenStream( lexer ) ); parser.removeErrorListeners(); parser.addErrorListener( new DiagnosticErrorListener() );
source share