use of com.google.security.zynamics.binnavi.parsers.BreakpointCondition.ConditionParser in project binnavi by google.
the class BreakpointConditionParser method parse.
/**
* Parses a breakpoint condition string.
*
* @param conditionString The condition string to parse.
*
* @return The parsed breakpoint condition tree.
*
* @throws RecognitionException Thrown if the condition string could not be parsed.
* @throws MaybeNullException Thrown if an empty condition string is passed to the function.
*/
public static ConditionNode parse(final String conditionString) throws RecognitionException, MaybeNullException {
if (conditionString.trim().isEmpty()) {
throw new MaybeNullException();
}
final CharStream charStream = new ANTLRStringStream(conditionString);
final ConditionLexer lexer = new ConditionLexer(charStream);
final CommonTokenStream tokens = new CommonTokenStream();
tokens.setTokenSource(lexer);
final ConditionParser parser = new ConditionParser(tokens);
parser.setTreeAdaptor(adaptor);
try {
final ConditionParser.prog_return parserResult = parser.prog();
final CommonTree ast = (CommonTree) parserResult.getTree();
if (parser.input.index() < parser.input.size()) {
throw new RecognitionException();
}
return convert(ast);
} catch (final IllegalArgumentException e) {
throw new RecognitionException();
}
}
Aggregations