ANTLR generates code, which you have to assume works as it should. However, the output is a variable factor, determined only by your grammar files. Considering that the rest of the application, or at least the part which loads the AST into your object model, depends on a specific output from your parser, it’s smart to test your parser output. Consider the following grammar: grammar expression;
options {
output=AST;
ASTLabelType=CommonTree;
}
expression : additiveExpression*;
additiveExpression : value ('+' value)* -> ^('+' value+);
value : NUMERIC;
NUMERIC : '0'..'9'+;
This grammar accepts input in the form of x+y, where x is an integer value. Thanks to the rewrite rule...