AST child = tree.getFirstChild();
String ruleBlockName = child.getText();
Gpr.debug(debug, "Parsing: " + ruleBlockName);
// Use 'default' methods
RuleConnectionMethod and = new RuleConnectionMethodAndMin(), or = new RuleConnectionMethodOrMax();
// Explore each sibling in this level
for( child = child.getNextSibling(); child != null; child = child.getNextSibling() ) {
String leaveName = child.getText();
Gpr.debug(debug, "Parsing: " + leaveName);
if( leaveName.equalsIgnoreCase("AND") ) {
//---
// Which 'AND' method to use? (Note: We alse set 'OR' method accordingly to fullfill DeMorgan's law
//---
if( rulesAdded ) throw new RuntimeException("AND / OR methods must be defined prior to RULE definition");
String type = child.getFirstChild().getText();
if( type.equalsIgnoreCase("MIN") ) {
and = new RuleConnectionMethodAndMin();
or = new RuleConnectionMethodOrMax();
} else if( type.equalsIgnoreCase("PROD") ) {
and = new RuleConnectionMethodAndProduct();
or = new RuleConnectionMethodOrProbOr();
} else if( type.equalsIgnoreCase("BDIF") ) {
and = new RuleConnectionMethodAndBoundedDif();
or = new RuleConnectionMethodOrBoundedSum();
} else throw new RuntimeException("Unknown (or unimplemented) 'AND' method: " + type);
} else if( leaveName.equalsIgnoreCase("OR") ) {
//---
// Which 'AND' method to use? (Note: We alse set 'OR' method accordingly to fullfill DeMorgan's law
//---
if( rulesAdded ) throw new RuntimeException("AND / OR methods must be defined prior to RULE definition");
String type = tree.getFirstChild().getText();
if( type.equalsIgnoreCase("MAX") ) {
or = new RuleConnectionMethodOrMax();
and = new RuleConnectionMethodAndMin();
} else if( type.equalsIgnoreCase("ASUM") ) {
or = new RuleConnectionMethodOrProbOr();
and = new RuleConnectionMethodAndProduct();
} else if( type.equalsIgnoreCase("BSUM") ) {