Between work, .Less and other things, I’ve been working a bit on a tool I would personally use. How many times did you just need a big set of test data for an application? How many times did you resort to simply dumping randomly generated data into your tables? Well, I’ve did that a few times, and one of the biggest annoyances is that the generated data is usually not really ‘real’, if you know what I mean. Say I have an application which has keeps customer records. I’d have a name, address, maybe some dates, something numeric and...
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...