use of lucee.transformer.bytecode.Body in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method elseStatement.
/**
* Liest ein else Statement ein.
* <br />
* EBNF:<br />
* <code>block;</code>
* @return else Statement
* @throws TemplateException
*/
private final boolean elseStatement(ExprData data, Condition cont) throws TemplateException {
if (!data.srcCode.forwardIfCurrent("else", '{') && !data.srcCode.forwardIfCurrent("else ") && !data.srcCode.forwardIfCurrent("else", '/'))
return false;
// start (
data.srcCode.previous();
// ex block
Body body = new BodyBase(data.factory);
Pair p = cont.setElse(body, data.srcCode.getPosition(), null);
statement(data, body, CTX_ELSE);
p.end = data.srcCode.getPosition();
return true;
}
use of lucee.transformer.bytecode.Body in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method doStatement.
/**
* Liest ein do Statement ein.
* <br />
* EBNF:<br />
* <code>block spaces "while" spaces "(" spaces condition spaces ")";</code>
* @return do Statement
* @throws TemplateException
*/
private final DoWhile doStatement(ExprData data) throws TemplateException {
int pos = data.srcCode.getPos();
// id
String id = variableDec(data, false);
if (id == null) {
data.srcCode.setPos(pos);
return null;
}
if (id.equalsIgnoreCase("do")) {
id = null;
if (!data.srcCode.isCurrent('{') && !data.srcCode.isCurrent(' ') && !data.srcCode.isCurrent('/')) {
data.srcCode.setPos(pos);
return null;
}
} else {
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent(':')) {
data.srcCode.setPos(pos);
return null;
}
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent("do", '{') && !data.srcCode.forwardIfCurrent("do ") && !data.srcCode.forwardIfCurrent("do", '/')) {
data.srcCode.setPos(pos);
return null;
}
data.srcCode.previous();
}
// if(!data.srcCode.forwardIfCurrent("do",'{') && !data.srcCode.forwardIfCurrent("do ") && !data.srcCode.forwardIfCurrent("do",'/'))
// return null;
Position line = data.srcCode.getPosition();
Body body = new BodyBase(data.factory);
// data.srcCode.previous();
statement(data, body, CTX_DO_WHILE);
comments(data);
if (!data.srcCode.forwardIfCurrent("while", '('))
throw new TemplateException(data.srcCode, "do statement must have a while at the end");
DoWhile doWhile = new DoWhile(condition(data), body, line, data.srcCode.getPosition(), id);
if (!data.srcCode.forwardIfCurrent(')'))
throw new TemplateException(data.srcCode, "do statement must end with a [)]");
return doWhile;
}
use of lucee.transformer.bytecode.Body in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method whileStatement.
/**
* Liest ein while Statement ein.
* <br />
* EBNF:<br />
* <code>spaces condition spaces ")" spaces block;</code>
* @return while Statement
* @throws TemplateException
*/
private final While whileStatement(ExprData data) throws TemplateException {
int pos = data.srcCode.getPos();
// id
String id = variableDec(data, false);
if (id == null) {
data.srcCode.setPos(pos);
return null;
}
if (id.equalsIgnoreCase("while")) {
id = null;
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent('(')) {
data.srcCode.setPos(pos);
return null;
}
} else {
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent(':')) {
data.srcCode.setPos(pos);
return null;
}
data.srcCode.removeSpace();
if (!data.srcCode.forwardIfCurrent("while", '(')) {
data.srcCode.setPos(pos);
return null;
}
}
Position line = data.srcCode.getPosition();
Body body = new BodyBase(data.factory);
While whil = new While(condition(data), body, line, null, id);
if (!data.srcCode.forwardIfCurrent(')'))
throw new TemplateException(data.srcCode, "while statement must end with a [)]");
statement(data, body, CTX_WHILE);
whil.setEnd(data.srcCode.getPosition());
return whil;
}
use of lucee.transformer.bytecode.Body in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method defaultStatement.
/**
* Liest ein default Statement ein
* @return default Statement
* @throws TemplateException
*/
private final boolean defaultStatement(ExprData data, Switch swit) throws TemplateException {
if (!data.srcCode.forwardIfCurrent("default", ':'))
return false;
// int line=data.srcCode.getLine();
Body body = new BodyBase(data.factory);
swit.setDefaultCase(body);
switchBlock(data, body);
return true;
}
use of lucee.transformer.bytecode.Body in project Lucee by lucee.
the class AbstrCFMLScriptTransformer method finallyStatement.
private final boolean finallyStatement(ExprData data, TryCatchFinally tcf) throws TemplateException {
if (!data.srcCode.forwardIfCurrent("finally", '{') && !data.srcCode.forwardIfCurrent("finally ") && !data.srcCode.forwardIfCurrent("finally", '/'))
return false;
// start (
data.srcCode.previous();
// ex block
Body body = new BodyBase(data.factory);
tcf.setFinally(body, data.srcCode.getPosition());
statement(data, body, CTX_FINALLY);
return true;
}
Aggregations