| 30 | |
| 31 | public class ParserTestingUtils { |
| 32 | public static CommonTokenStream tokenize(String query) throws IOException, ParsingFailureException { |
| 33 | CharStream input = new QueryParserStringStream( query, null ); |
| 34 | QueryLexer lexer = new QueryLexer( input ); |
| 35 | CommonTokenStream tokens = new CommonTokenStream( lexer ); |
| 36 | if( 0 < lexer.getNumberOfSyntaxErrors() ) |
| 37 | throw new ParsingFailureException( QueryLexer.class ); |
| 38 | return tokens; |
| 39 | } |
| 40 | |
| 41 | public static Tree parse(String query) throws IOException, RecognitionException, ParsingFailureException { |
| 42 | CommonTokenStream tokens = tokenize( query ); |