use of org.drools.compiler.lang.ParserHelper in project drools by kiegroup.
the class DrlExprParser method parse.
/**
* Parse an expression from text
*/
public ConstraintConnectiveDescr parse(final String text) {
ConstraintConnectiveDescr constraint = null;
try {
DRLLexer lexer = DRLFactory.getDRLLexer(new ANTLRStringStream(text), languageLevel);
CommonTokenStream input = new CommonTokenStream(lexer);
RecognizerSharedState state = new RecognizerSharedState();
helper = new ParserHelper(input, state, languageLevel);
DRLExpressions parser = DRLFactory.getDRLExpressions(input, state, helper, languageLevel);
parser.setBuildDescr(true);
// setting initial value just in case
parser.setLeftMostExpr(null);
BaseDescr expr = parser.conditionalOrExpression();
if (expr != null && !parser.hasErrors()) {
constraint = ConstraintConnectiveDescr.newAnd();
constraint.addOrMerge(expr);
}
} catch (RecognitionException e) {
helper.reportError(e);
}
return constraint;
}
Aggregations