use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method _mod.
private Ref _mod(Ref ref) throws PageException {
// %=
if (cfml.forwardIfCurrent('=')) {
cfml.removeSpace();
Ref right = assignOp();
Ref res = preciseMath ? new BigMod(ref, right, limited) : new Mod(ref, right, limited);
ref = new Assign(ref, res, limited);
} else {
cfml.removeSpace();
ref = preciseMath ? new BigMod(ref, divMultiOp(), limited) : new Mod(ref, divMultiOp(), limited);
}
return ref;
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method impOp.
/**
* Transfomiert eine Implication (imp) Operation.
* <br />
* EBNF:<br />
* <code>eqvOp {"imp" spaces eqvOp};</code>
* @return CFXD Element
* @throws PageException
*/
private Ref impOp() throws PageException {
Ref ref = eqvOp();
while (cfml.forwardIfCurrentAndNoWordAfter("imp")) {
cfml.removeSpace();
ref = new Imp(ref, eqvOp(), limited);
}
return ref;
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method functionArg.
/**
* Liest die Argumente eines Funktonsaufruf ein und prueft ob die Funktion
* innerhalb der FLD (Function Library Descriptor) definiert ist.
* Falls sie existiert wird die Funktion gegen diese geprueft und ein build-in-function CFXD Element generiert,
* ansonsten ein normales funcion-call Element.
* <br />
* EBNF:<br />
* <code>[impOp{"," impOp}];</code>
* @param name Identifier der Funktion als Zeichenkette
* @param checkLibrary Soll geprueft werden ob die Funktion innerhalb der Library existiert.
* @param flf FLD Function definition .
* @return CFXD Element
* @throws PageException
*/
private Ref[] functionArg(String name, boolean checkLibrary, FunctionLibFunction flf, char end) throws PageException {
// get Function Library
checkLibrary = checkLibrary && flf != null;
// Function Attributes
List<Ref> arr = new ArrayList<Ref>();
List<FunctionLibFunctionArg> arrFuncLibAtt = null;
int libLen = 0;
if (checkLibrary) {
arrFuncLibAtt = flf.getArg();
libLen = arrFuncLibAtt.size();
}
int count = 0;
Ref ref;
do {
cfml.next();
cfml.removeSpace();
// finish
if (cfml.isCurrent(end))
break;
// too many Attributes
boolean isDynamic = false;
int max = -1;
if (checkLibrary) {
isDynamic = isDynamic(flf);
max = flf.getArgMax();
// Dynamic
if (isDynamic) {
if (max != -1 && max <= count)
throw new InterpreterException("too many Attributes in function [" + name + "]");
} else // Fix
{
if (libLen <= count)
throw new InterpreterException("too many Attributes in function [" + name + "]");
}
}
if (checkLibrary && !isDynamic) {
// current attribues from library
FunctionLibFunctionArg funcLibAtt = (FunctionLibFunctionArg) arrFuncLibAtt.get(count);
short type = CFTypes.toShort(funcLibAtt.getTypeAsString(), false, CFTypes.TYPE_UNKNOW);
if (type == CFTypes.TYPE_VARIABLE_STRING) {
arr.add(functionArgDeclarationVarString());
} else {
ref = functionArgDeclaration();
arr.add(new Casting(funcLibAtt.getTypeAsString(), type, ref));
}
} else {
arr.add(functionArgDeclaration());
}
cfml.removeSpace();
count++;
} while (cfml.isCurrent(','));
// end with ) ??
if (!cfml.forwardIfCurrent(end)) {
if (name.startsWith("_json"))
throw new InterpreterException("Invalid Syntax Closing [" + end + "] not found");
throw new InterpreterException("Invalid Syntax Closing [" + end + "] for function [" + name + "] not found");
}
// check min attributes
if (checkLibrary && flf.getArgMin() > count)
throw new InterpreterException("to less Attributes in function [" + name + "]");
cfml.removeSpace();
return (Ref[]) arr.toArray(new Ref[arr.size()]);
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method xorOp.
/**
* Transfomiert eine Xor (xor) Operation.
* <br />
* EBNF:<br />
* <code>orOp {"xor" spaces orOp};</code>
* @return CFXD Element
* @throws PageException
*/
private Ref xorOp() throws PageException {
Ref ref = orOp();
while (cfml.forwardIfCurrent("xor")) {
cfml.removeSpace();
ref = new Xor(ref, orOp(), limited);
}
return ref;
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method decsionOp.
/**
* <font f>Transfomiert eine Vergleichs Operation.
* <br />
* EBNF:<br />
* <code>concatOp {("neq"|"eq"|"gte"|"gt"|"lte"|"lt"|"ct"|
* "contains"|"nct"|"does not contain") spaces concatOp};
* (* "ct"=conatains und "nct"=does not contain; Existiert in CFMX nicht *)</code>
* @return CFXD Element
* @throws PageException
*/
private Ref decsionOp() throws PageException {
Ref ref = concatOp();
boolean hasChanged = false;
// ct, contains
if (cfml.isValidIndex()) {
do {
hasChanged = false;
if (cfml.isCurrent('c')) {
if (cfml.forwardIfCurrent("ct")) {
cfml.removeSpace();
ref = new CT(ref, concatOp(), limited);
hasChanged = true;
} else if (cfml.forwardIfCurrent("contains")) {
cfml.removeSpace();
ref = new CT(ref, concatOp(), limited);
hasChanged = true;
}
} else // does not contain
if (cfml.forwardIfCurrent("does", "not", "contain")) {
cfml.removeSpace();
ref = new NCT(ref, concatOp(), limited);
hasChanged = true;
} else // equal, eq
if (cfml.isCurrent("eq") && !cfml.isCurrent("eqv")) {
cfml.setPos(cfml.getPos() + 2);
cfml.forwardIfCurrent("ual");
cfml.removeSpace();
ref = new EQ(ref, concatOp(), limited);
hasChanged = true;
} else // ==
if (cfml.forwardIfCurrent("==")) {
if (cfml.forwardIfCurrent('=')) {
cfml.removeSpace();
ref = new EEQ(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new EQ(ref, concatOp(), limited);
}
hasChanged = true;
} else // !=
if (cfml.forwardIfCurrent("!=")) {
if (cfml.forwardIfCurrent('=')) {
cfml.removeSpace();
ref = new NEEQ(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new NEQ(ref, concatOp(), limited);
}
hasChanged = true;
} else // <=/</<>
if (cfml.forwardIfCurrent('<')) {
if (cfml.forwardIfCurrent('=')) {
cfml.removeSpace();
ref = new LTE(ref, concatOp(), limited);
} else if (cfml.forwardIfCurrent('>')) {
cfml.removeSpace();
ref = new NEQ(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new LT(ref, concatOp(), limited);
}
hasChanged = true;
} else // >/>=
if (cfml.forwardIfCurrent('>')) {
if (cfml.forwardIfCurrent('=')) {
cfml.removeSpace();
ref = new GTE(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new GT(ref, concatOp(), limited);
}
hasChanged = true;
} else // gt, gte, greater than or equal to, greater than
if (cfml.isCurrent('g')) {
if (cfml.forwardIfCurrent("gt")) {
if (cfml.forwardIfCurrent('e')) {
cfml.removeSpace();
ref = new GTE(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new GT(ref, concatOp(), limited);
}
hasChanged = true;
} else if (cfml.forwardIfCurrent("greater", "than")) {
if (cfml.forwardIfCurrent("or", "equal", "to", true)) {
cfml.removeSpace();
ref = new GTE(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new GT(ref, concatOp(), limited);
}
hasChanged = true;
} else if (cfml.forwardIfCurrent("ge")) {
cfml.removeSpace();
ref = new GTE(ref, concatOp(), limited);
hasChanged = true;
}
} else // is, is not
if (cfml.forwardIfCurrent("is")) {
if (cfml.forwardIfCurrent("not", true)) {
cfml.removeSpace();
ref = new NEQ(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new EQ(ref, concatOp(), limited);
}
hasChanged = true;
} else // lt, lte, less than, less than or equal to
if (cfml.isCurrent('l')) {
if (cfml.forwardIfCurrent("lt")) {
if (cfml.forwardIfCurrent('e')) {
cfml.removeSpace();
ref = new LTE(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new LT(ref, concatOp(), limited);
}
hasChanged = true;
} else if (cfml.forwardIfCurrent("less", "than")) {
if (cfml.forwardIfCurrent("or", "equal", "to", true)) {
cfml.removeSpace();
ref = new LTE(ref, concatOp(), limited);
} else {
cfml.removeSpace();
ref = new LT(ref, concatOp(), limited);
}
hasChanged = true;
} else if (cfml.forwardIfCurrent("le")) {
cfml.removeSpace();
ref = new LTE(ref, concatOp(), limited);
hasChanged = true;
}
} else // neq, not equal, nct
if (cfml.isCurrent('n')) {
// Not Equal
if (cfml.forwardIfCurrent("neq")) {
cfml.removeSpace();
ref = new NEQ(ref, concatOp(), limited);
hasChanged = true;
} else // Not Equal (Alias)
if (cfml.forwardIfCurrent("not", "equal")) {
cfml.removeSpace();
ref = new NEQ(ref, concatOp(), limited);
hasChanged = true;
} else // nct
if (cfml.forwardIfCurrent("nct")) {
cfml.removeSpace();
ref = new NCT(ref, concatOp(), limited);
hasChanged = true;
}
}
} while (hasChanged);
}
return ref;
}
Aggregations