SmoothFriction.nl

posts - 39, comments - 20, trackbacks - 0

antlr

antlr
Unit testing ANTLR generated code

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...

posted @ Tuesday, August 25, 2009 1:34 PM | Feedback (0) | Filed Under [ antlr testing ]