use of lucee.transformer.bytecode.statement.Switch in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method switchStatement.
/**
* Liest ein switch Statment ein
* @return switch Statement
* @throws TemplateException
*/
private final Switch switchStatement(ExprData data) throws TemplateException {
if (!data.srcCode.forwardIfCurrent("switch", '('))
return null;
Position line = data.srcCode.getPosition();
comments(data);
Expression expr = super.expression(data);
comments(data);
// end )
if (!data.srcCode.forwardIfCurrent(')'))
throw new TemplateException(data.srcCode, "switch statement must end with a [)]");
comments(data);
if (!data.srcCode.forwardIfCurrent('{'))
throw new TemplateException(data.srcCode, "switch statement must have a starting [{]");
Switch swit = new Switch(expr, line, null);
// cases
// Node child=null;
comments(data);
while (caseStatement(data, swit)) {
comments(data);
}
// default
if (defaultStatement(data, swit)) {
comments(data);
}
while (caseStatement(data, swit)) {
comments(data);
}
// }
if (!data.srcCode.forwardIfCurrent('}'))
throw new TemplateException(data.srcCode, "invalid construct in switch statement");
swit.setEnd(data.srcCode.getPosition());
return swit;
}
Aggregations