package org.uva.sea.ql.parser.test; import org.antlr.runtime.ANTLRStringStream; import org.antlr.runtime.CommonTokenStream; import org.antlr.runtime.RecognitionException; import org.uva.sea.ql.ast.expr.Expr; import org.uva.sea.ql.parser.antlr.QLLexer; import org.uva.sea.ql.parser.antlr.QLParser; public class ExprParser implements IParser<Expr> { @Override public Expr parse(String src) throws ParseError { ANTLRStringStream stream = new ANTLRStringStream(src); CommonTokenStream tokens = new CommonTokenStream(); tokens.setTokenSource(new QLLexer(stream)); QLParser parser = new QLParser(tokens); try { return parser.orExpr(); } catch (RecognitionException e) { throw new ParseError(e.getMessage()); } } }