use of org.beetl.core.parser.BeetlParser.G_defaultStatmentContext in project beetl2.0 by javamonkey.
the class AntlrProgramBuilder method parseSelect.
protected SelectStatement parseSelect(SelectStContext selectCtx) {
// this.pbCtx.enterBlock();
// this.pbCtx.current.canStopContinueBreakFlag = true;
G_switchStatmentContext ctx = selectCtx.g_switchStatment();
ExpressionContext exp = ctx.expression();
Expression base = exp != null ? this.parseExpress(exp) : null;
List<G_caseStatmentContext> caseCtxList = ctx.g_caseStatment();
List<Expression> condtionList = new LinkedList<Expression>();
List<BlockStatement> blockList = new LinkedList<BlockStatement>();
for (G_caseStatmentContext caseCtx : caseCtxList) {
List<ExpressionContext> expCtxList = caseCtx.expression();
List<StatementContext> statCtxList = caseCtx.statement();
BlockStatement block = this.parseBlock(statCtxList, caseCtx);
for (ExpressionContext expCtx : expCtxList) {
Expression condition = this.parseExpress(expCtx);
// select case 的条件是||的关系,只要任何一个条件满足,都可以执行block
condtionList.add(condition);
blockList.add(block);
}
}
BlockStatement defaultStatement = null;
G_defaultStatmentContext defaultCtx = ctx.g_defaultStatment();
if (defaultCtx != null) {
List<StatementContext> defaultCtxList = ctx.g_defaultStatment().statement();
defaultStatement = this.parseBlock(defaultCtxList, ctx);
}
SelectStatement select = new SelectStatement(base, condtionList.toArray(new Expression[0]), blockList.toArray(new BlockStatement[0]), defaultStatement, this.getBTToken(selectCtx.Select().getSymbol()));
return select;
}
Aggregations