Search in sources :

Example 1 with FilterLexer

use of com.google.security.zynamics.binnavi.parsers.filter.FilterLexer in project binnavi by google.

the class CFilterRuleParser method parse.

/**
   * Parses a filter string.
   * 
   * @param filterString The filter string to parse.
   * 
   * @return The root node of the parsed AST.
   * 
   * @throws RecognitionException Thrown if parsing the filter string failed.
   */
public static IAbstractNode parse(final String filterString) throws RecognitionException {
    final CharStream charStream = new ANTLRStringStream(filterString);
    final FilterLexer lexer = new FilterLexer(charStream);
    final CommonTokenStream tokens = new CommonTokenStream();
    tokens.setTokenSource(lexer);
    final FilterParser parser = new FilterParser(tokens);
    parser.setTreeAdaptor(adaptor);
    final FilterParser.prog_return parserResult = parser.prog();
    final CommonTree ast = (CommonTree) parserResult.getTree();
    return convert(ast);
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) CommonTokenStream(org.antlr.runtime.CommonTokenStream) CommonTree(org.antlr.runtime.tree.CommonTree) FilterParser(com.google.security.zynamics.binnavi.parsers.filter.FilterParser) CharStream(org.antlr.runtime.CharStream) FilterLexer(com.google.security.zynamics.binnavi.parsers.filter.FilterLexer)

Aggregations

FilterLexer (com.google.security.zynamics.binnavi.parsers.filter.FilterLexer)1 FilterParser (com.google.security.zynamics.binnavi.parsers.filter.FilterParser)1 ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)1 CharStream (org.antlr.runtime.CharStream)1 CommonTokenStream (org.antlr.runtime.CommonTokenStream)1 CommonTree (org.antlr.runtime.tree.CommonTree)1