use of org.drools.compiler.lang.descr.ConditionalElementDescr in project drools by kiegroup.
the class DRL5Parser method lhsExpression.
/**
* lhsExpression := lhsOr*
*
* @param lhs
* @throws RecognitionException
*/
private void lhsExpression(CEDescrBuilder<?, AndDescr> lhs) throws RecognitionException {
helper.start(lhs, CEDescrBuilder.class, null);
if (state.backtracking == 0) {
helper.emit(Location.LOCATION_LHS_BEGIN_OF_CONDITION);
}
try {
while (input.LA(1) != DRL5Lexer.EOF && !helper.validateIdentifierKey(DroolsSoftKeywords.THEN) && !helper.validateIdentifierKey(DroolsSoftKeywords.END)) {
if (state.backtracking == 0) {
helper.emit(Location.LOCATION_LHS_BEGIN_OF_CONDITION);
}
lhsOr(lhs, true);
if (lhs.getDescr() != null && lhs.getDescr() instanceof ConditionalElementDescr) {
ConditionalElementDescr root = (ConditionalElementDescr) lhs.getDescr();
BaseDescr[] descrs = root.getDescrs().toArray(new BaseDescr[root.getDescrs().size()]);
root.getDescrs().clear();
for (int i = 0; i < descrs.length; i++) {
root.addOrMerge(descrs[i]);
}
}
if (state.failed)
return;
}
} finally {
helper.end(CEDescrBuilder.class, lhs);
}
}
use of org.drools.compiler.lang.descr.ConditionalElementDescr in project drools by kiegroup.
the class CEDescrBuilderImpl method not.
/**
* {@inheritDoc}
*/
public CEDescrBuilder<CEDescrBuilder<P, T>, NotDescr> not() {
CEDescrBuilder<CEDescrBuilder<P, T>, NotDescr> not = new CEDescrBuilderImpl<CEDescrBuilder<P, T>, NotDescr>(this, new NotDescr());
((ConditionalElementDescr) descr).addDescr(not.getDescr());
return not;
}
use of org.drools.compiler.lang.descr.ConditionalElementDescr in project drools by kiegroup.
the class CEDescrBuilderImpl method and.
/**
* {@inheritDoc}
*/
public CEDescrBuilder<CEDescrBuilder<P, T>, AndDescr> and() {
AndDescr andDescr = new AndDescr();
((ConditionalElementDescr) descr).addDescr(andDescr);
return new CEDescrBuilderImpl<CEDescrBuilder<P, T>, AndDescr>(this, andDescr);
}
use of org.drools.compiler.lang.descr.ConditionalElementDescr in project drools by kiegroup.
the class CEDescrBuilderImpl method exists.
/**
* {@inheritDoc}
*/
public CEDescrBuilder<CEDescrBuilder<P, T>, ExistsDescr> exists() {
CEDescrBuilder<CEDescrBuilder<P, T>, ExistsDescr> exists = new CEDescrBuilderImpl<CEDescrBuilder<P, T>, ExistsDescr>(this, new ExistsDescr());
((ConditionalElementDescr) descr).addDescr(exists.getDescr());
return exists;
}
use of org.drools.compiler.lang.descr.ConditionalElementDescr in project drools by kiegroup.
the class RuleModelDRLPersistenceImpl method parseBaseDescr.
private IPattern parseBaseDescr(final RuleModel m, final BaseDescr descr, final boolean isJavaDialect, final Map<String, String> boundParams, final PackageDataModelOracle dmo) {
if (descr instanceof PatternDescr) {
return parsePatternDescr(m, (PatternDescr) descr, isJavaDialect, boundParams, dmo);
} else if (descr instanceof AndDescr) {
AndDescr andDescr = (AndDescr) descr;
return parseBaseDescr(m, andDescr.getDescrs().get(0), isJavaDialect, boundParams, dmo);
} else if (descr instanceof EvalDescr) {
FreeFormLine freeFormLine = new FreeFormLine();
freeFormLine.setText("eval( " + ((EvalDescr) descr).getContent() + " )");
return freeFormLine;
} else if (descr instanceof ConditionalElementDescr) {
return parseExistentialElementDescr(m, (ConditionalElementDescr) descr, isJavaDialect, boundParams, dmo);
}
return null;
}
Aggregations