use of com.google.security.zynamics.binnavi.parsers.gotomem.MemoryExpressionLexer in project binnavi by google.
the class DebuggerMemoryExpressionParser method parse.
/**
* Parses a single memory expression string.
*
* @param memoryExpression The memory expression string to parse.
*
* @return The parsed memory expression tree.
*
* @throws RecognitionException Thrown if parsing failed.
*/
public static MemoryExpressionElement parse(final String memoryExpression) throws RecognitionException {
final CharStream charStream = new ANTLRStringStream(memoryExpression);
final MemoryExpressionLexer lexer = new MemoryExpressionLexer(charStream);
final CommonTokenStream tokens = new CommonTokenStream();
tokens.setTokenSource(lexer);
final MemoryExpressionParser parser = new MemoryExpressionParser(tokens) {
@Override
public void recover(final IntStream input, final RecognitionException exception) {
// Nothing to do
}
@Override
public Object recoverFromMismatchedToken(final IntStream input, final int ttype, final org.antlr.runtime.BitSet follow) throws RecognitionException {
throw new MismatchedTokenException(ttype, input);
}
@Override
public void reportError(final RecognitionException exception) {
// Nothing to do
}
};
parser.setTreeAdaptor(adaptor);
final MemoryExpressionParser.prog_return parserResult = parser.prog();
final CommonTree ast = (CommonTree) parserResult.getTree();
return convert(ast);
}
Aggregations