use of org.beetl.core.statement.VarRefAssignExpress in project beetl2.0 by javamonkey.
the class AntlrProgramBuilder method parseExpress.
protected Expression parseExpress(ExpressionContext ctx) {
if (ctx == null)
return null;
if (ctx instanceof LiteralExpContext) {
return parseLiteralExpress(((LiteralExpContext) ctx).literal());
} else if (ctx instanceof VarRefExpContext) {
return this.parseVarRefExpression(((VarRefExpContext) ctx).varRef());
} else if (ctx instanceof CompareExpContext) {
CompareExpression compare = parseCompareExpression((CompareExpContext) ctx);
if (gt.conf.isStrict) {
throw new MVCStrictException(compare.token);
}
return compare;
} else if (ctx instanceof TernaryExpContext) {
return this.parseTernaryExpression((TernaryExpContext) ctx);
} else if (ctx instanceof MuldivmodExpContext) {
ArthExpression arth = this.parseMuldivmodExpression((MuldivmodExpContext) ctx);
if (gt.conf.isStrict) {
throw new MVCStrictException(arth.token);
}
return arth;
} else if (ctx instanceof AddminExpContext) {
return this.parsePlusMins((AddminExpContext) ctx);
} else if (ctx instanceof ParExpContext) {
ParExpContext par = (ParExpContext) ctx;
return this.parseExpress(par.expression());
} else if (ctx instanceof FunctionCallExpContext) {
FunctionCallExpContext fceCtx = (FunctionCallExpContext) ctx;
FunctionExpression fun = parseFunExp(fceCtx.functionCall());
if (gt.conf.isStrict) {
throw new MVCStrictException(fun.token);
}
return fun;
} else if (ctx instanceof JsonExpContext) {
JsonContext jc = ((JsonExpContext) ctx).json();
return this.parseJson(jc);
} else if (ctx instanceof NativeCallExpContext) {
NativeCallContext ncc = ((NativeCallExpContext) ctx).nativeCall();
NativeCallExpression nativeCall = this.parseNativeCallExpression(ncc);
if (!gt.conf.nativeCall || gt.conf.isStrict) {
throw new NativeNotAllowedException(nativeCall.token);
}
return nativeCall;
} else if (ctx instanceof AndExpContext) {
AndExpContext andCtx = (AndExpContext) ctx;
return this.parseAndExpression(andCtx);
} else if (ctx instanceof OrExpContext) {
OrExpContext orExp = (OrExpContext) ctx;
return this.parseOrExpression(orExp);
} else if (ctx instanceof NotExpContext) {
NotExpContext notCtx = (NotExpContext) ctx;
return this.parseNotExpression(notCtx);
} else if (ctx instanceof NegExpContext) {
NegExpContext negCtx = (NegExpContext) ctx;
return this.parseNegExpression(negCtx);
} else if (ctx instanceof IncDecOneContext) {
IncDecOneContext oneCtx = (IncDecOneContext) ctx;
IncDecExpression exp = this.parseIncDecOneContext(oneCtx);
if (gt.conf.isStrict) {
throw new NativeNotAllowedException(exp.token);
}
return exp;
} else if (ctx instanceof OneIncDecContext) {
OneIncDecContext oneCtx = (OneIncDecContext) ctx;
IncDecExpression exp = this.parseOneIncDecContext(oneCtx);
if (gt.conf.isStrict) {
throw new NativeNotAllowedException(exp.token);
}
return exp;
} else if (ctx instanceof AssignGeneralInExpContext) {
AssignGeneralInExpContext agc = (AssignGeneralInExpContext) ctx;
VarRefAssignExpress vas = this.parseAssingInExp(agc);
return vas;
} else {
throw new UnsupportedOperationException();
}
}
use of org.beetl.core.statement.VarRefAssignExpress in project beetl2.0 by javamonkey.
the class AntlrProgramBuilder method parseAssingInExp.
/**
* 赋值变量
* @param agc
* @return
*/
protected VarRefAssignExpress parseAssingInExp(AssignGeneralInExpContext agc) {
VarRefAssignExpress vas = null;
ExpressionContext expCtx = agc.generalAssignExp().expression();
Expression exp = parseExpress(expCtx);
VarRefContext varRefCtx = agc.generalAssignExp().varRef();
VarRef ref = this.parseVarRefInLeftExpression(varRefCtx);
vas = new VarRefAssignExpress(exp, ref);
if (ref.attributes.length == 0) {
// 变量定义:
Token token = varRefCtx.Identifier().getSymbol();
if (pbCtx.hasDefined(token.getText()) != null) {
registerVar(vas);
return vas;
} else {
BeetlException ex = new BeetlException(BeetlException.VAR_NOT_DEFINED);
ex.pushToken(this.getBTToken(token));
throw ex;
}
}
return vas;
}
Aggregations