use of org.mvel2.ast.DoUntilNode in project mvel by mvel.
the class AbstractParser method createBlockToken.
/**
* Generate a code block token.
*
* @param condStart the start offset for the condition
* @param condEnd the end offset for the condition
* @param blockStart the start offset for the block
* @param blockEnd the end offset for the block
* @param type the type of block
* @return and ast node
*/
private ASTNode createBlockToken(final int condStart, final int condEnd, final int blockStart, final int blockEnd, int type) {
lastWasIdentifier = false;
cursor++;
if (isStatementNotManuallyTerminated()) {
splitAccumulator.add(new EndOfStatement(pCtx));
}
int condOffset = condEnd - condStart;
int blockOffset = blockEnd - blockStart;
if (blockOffset < 0)
blockOffset = 0;
switch(type) {
case ASTNode.BLOCK_IF:
return new IfNode(expr, condStart, condOffset, blockStart, blockOffset, fields, pCtx);
case ASTNode.BLOCK_FOR:
for (int i = condStart; i < condEnd; i++) {
if (expr[i] == ';')
return new ForNode(expr, condStart, condOffset, blockStart, blockOffset, fields, pCtx);
else if (expr[i] == ':')
break;
}
case ASTNode.BLOCK_FOREACH:
return new ForEachNode(expr, condStart, condOffset, blockStart, blockOffset, fields, pCtx);
case ASTNode.BLOCK_WHILE:
return new WhileNode(expr, condStart, condOffset, blockStart, blockOffset, fields, pCtx);
case ASTNode.BLOCK_UNTIL:
return new UntilNode(expr, condStart, condOffset, blockStart, blockOffset, fields, pCtx);
case ASTNode.BLOCK_DO:
return new DoNode(expr, condStart, condOffset, blockStart, blockOffset, fields, pCtx);
case ASTNode.BLOCK_DO_UNTIL:
return new DoUntilNode(expr, condStart, condOffset, blockStart, blockOffset, pCtx);
default:
return new WithNode(expr, condStart, condOffset, blockStart, blockOffset, fields, pCtx);
}
}
Aggregations