private Reduction conditional;
private Reduction thenStatements;
private Reduction elseStatements;
public IfThenElse(GOLDParser parser) {
Reduction reduction = parser.getCurrentReduction();
if (reduction != null) {
if (reduction.size() == 5) {
// if x then y end
conditional = reduction.get(1).asReduction();
thenStatements = reduction.get(3).asReduction();
} else if (reduction.size() == 7) {
// if x then y else z end
conditional = reduction.get(1).asReduction();
thenStatements = reduction.get(3).asReduction();
elseStatements = reduction.get(5).asReduction();
} else {
if (reduction.size() < 5) {
// if x then y form
parser.raiseParserException(Simple2.formatMessage("error.param_count", "5", String.valueOf(reduction.size())));
}
// if x then y else z end form
parser.raiseParserException(Simple2.formatMessage("error.param_count", "7", String.valueOf(reduction.size())));
}
} else {
parser.raiseParserException(Simple2.formatMessage("error.no_reduction"));
}
}