Search in sources :

Example 11 with Ref

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;
}
Also used : Ref(lucee.runtime.interpreter.ref.Ref) BigMod(lucee.runtime.interpreter.ref.op.BigMod) Mod(lucee.runtime.interpreter.ref.op.Mod) BigMod(lucee.runtime.interpreter.ref.op.BigMod) Assign(lucee.runtime.interpreter.ref.var.Assign) DynAssign(lucee.runtime.interpreter.ref.var.DynAssign)

Example 12 with 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;
}
Also used : Ref(lucee.runtime.interpreter.ref.Ref) Imp(lucee.runtime.interpreter.ref.op.Imp)

Example 13 with 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()]);
}
Also used : Casting(lucee.runtime.interpreter.ref.cast.Casting) Ref(lucee.runtime.interpreter.ref.Ref) ArrayList(java.util.ArrayList) FunctionLibFunctionArg(lucee.transformer.library.function.FunctionLibFunctionArg)

Example 14 with Ref

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;
}
Also used : Ref(lucee.runtime.interpreter.ref.Ref) Xor(lucee.runtime.interpreter.ref.op.Xor)

Example 15 with 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;
}
Also used : EEQ(lucee.runtime.interpreter.ref.op.EEQ) NEEQ(lucee.runtime.interpreter.ref.op.NEEQ) CT(lucee.runtime.interpreter.ref.op.CT) NCT(lucee.runtime.interpreter.ref.op.NCT) Ref(lucee.runtime.interpreter.ref.Ref) NEEQ(lucee.runtime.interpreter.ref.op.NEEQ) LT(lucee.runtime.interpreter.ref.op.LT) GTE(lucee.runtime.interpreter.ref.op.GTE) NEQ(lucee.runtime.interpreter.ref.op.NEQ) EEQ(lucee.runtime.interpreter.ref.op.EEQ) NEEQ(lucee.runtime.interpreter.ref.op.NEEQ) NEQ(lucee.runtime.interpreter.ref.op.NEQ) EQ(lucee.runtime.interpreter.ref.op.EQ) LTE(lucee.runtime.interpreter.ref.op.LTE) GT(lucee.runtime.interpreter.ref.op.GT) NCT(lucee.runtime.interpreter.ref.op.NCT)

Aggregations

Ref (lucee.runtime.interpreter.ref.Ref)34 Assign (lucee.runtime.interpreter.ref.var.Assign)9 DynAssign (lucee.runtime.interpreter.ref.var.DynAssign)9 ArrayList (java.util.ArrayList)6 Casting (lucee.runtime.interpreter.ref.cast.Casting)6 BIFCall (lucee.runtime.interpreter.ref.func.BIFCall)6 LString (lucee.runtime.interpreter.ref.literal.LString)6 FunctionLibFunctionArg (lucee.transformer.library.function.FunctionLibFunctionArg)5 ParserString (lucee.commons.lang.ParserString)4 FunctionLibFunction (lucee.transformer.library.function.FunctionLibFunction)4 ExpressionException (lucee.runtime.exp.ExpressionException)3 LFunctionValue (lucee.runtime.interpreter.ref.literal.LFunctionValue)3 BigPlus (lucee.runtime.interpreter.ref.op.BigPlus)3 Plus (lucee.runtime.interpreter.ref.op.Plus)3 BigIntDiv (lucee.runtime.interpreter.ref.op.BigIntDiv)2 BigMinus (lucee.runtime.interpreter.ref.op.BigMinus)2 Concat (lucee.runtime.interpreter.ref.op.Concat)2 IntDiv (lucee.runtime.interpreter.ref.op.IntDiv)2 Minus (lucee.runtime.interpreter.ref.op.Minus)2 Key (lucee.runtime.type.Collection.Key)2