use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method _plus.
private Ref _plus(Ref ref) throws PageException {
// +=
if (cfml.isCurrent('=')) {
cfml.next();
cfml.removeSpace();
Ref right = assignOp();
Ref res = preciseMath ? new BigPlus(ref, right, limited) : new Plus(ref, right, limited);
ref = new Assign(ref, res, limited);
} else {
cfml.removeSpace();
ref = preciseMath ? new BigPlus(ref, modOp(), limited) : new Plus(ref, modOp(), limited);
}
return ref;
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method checker.
/**
* Hier werden die verschiedenen Moeglichen Werte erkannt
* und jenachdem wird mit der passenden Methode weitergefahren
* <br />
* EBNF:<br />
* <code>string | number | dynamic | sharp;</code>
* @return CFXD Element
* @throws PageException
*/
private Ref checker() throws PageException {
Ref ref = null;
// String
if (cfml.isCurrentQuoter()) {
// mode=STATIC; is at the end of the string function because must set after execution
return string();
}
// Number
if (cfml.isCurrentDigit() || cfml.isCurrent('.')) {
// mode=STATIC; is at the end of the string function because must set after execution
return number();
}
// Dynamic
if ((ref = dynamic()) != null) {
mode = DYNAMIC;
return ref;
}
// Sharp
if (!limited && (ref = sharp()) != null) {
mode = DYNAMIC;
return ref;
}
// JSON
if ((ref = json(isJson ? JSON_ARRAY : LITERAL_ARRAY, '[', ']')) != null) {
mode = DYNAMIC;
return ref;
}
if ((ref = json(isJson ? JSON_STRUCT : LITERAL_STRUCT, '{', '}')) != null) {
mode = DYNAMIC;
return ref;
}
if (cfml.isAfterLast() && cfml.toString().trim().length() == 0)
return new LString("");
// else Error
String str = cfml.toString();
int pos = cfml.getPos();
if (str.length() > 100) {
// Failure is in the beginning
if (pos <= 10) {
str = str.substring(0, 20) + " ...";
} else // Failure is in the end
if ((str.length() - pos) <= 10) {
str = "... " + str.substring(str.length() - 20, str.length());
} else {
str = "... " + str.substring(pos - 10, pos + 10) + " ...";
}
}
throw new InterpreterException("Syntax Error, Invalid Construct", "at position " + (pos + 1) + " in [" + str + "]");
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method interpret.
public Object interpret(PageContext pc, String str, boolean preciseMath) throws PageException {
this.cfml = new ParserString(str);
this.preciseMath = preciseMath;
init(pc);
if (LITERAL_ARRAY == null)
LITERAL_ARRAY = fld.getFunction("_literalArray");
if (LITERAL_STRUCT == null)
LITERAL_STRUCT = fld.getFunction("_literalStruct");
if (JSON_ARRAY == null)
JSON_ARRAY = fld.getFunction("_jsonArray");
if (JSON_STRUCT == null)
JSON_STRUCT = fld.getFunction("_jsonStruct");
if (LITERAL_ORDERED_STRUCT == null)
LITERAL_ORDERED_STRUCT = fld.getFunction("_literalOrderedStruct");
cfml.removeSpace();
Ref ref = assignOp();
cfml.removeSpace();
if (cfml.isAfterLast()) {
// data.put(str+":"+preciseMath,ref);
return ref.getValue(pc);
}
throw new InterpreterException("Syntax Error, invalid Expression [" + cfml.toString() + "]");
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method orOp.
/**
* Transfomiert eine Or (or) Operation. Im Gegensatz zu CFMX ,
* werden "||" Zeichen auch als Or Operatoren anerkannt.
* <br />
* EBNF:<br />
* <code>andOp {("or" | "||") spaces andOp}; (* "||" Existiert in CFMX nicht *)</code>
* @return CFXD Element
* @throws PageException
*/
private Ref orOp() throws PageException {
Ref ref = andOp();
while (cfml.isValidIndex() && (cfml.forwardIfCurrent("||") || cfml.forwardIfCurrent("or"))) {
cfml.removeSpace();
ref = new Or(ref, andOp(), limited);
}
return ref;
}
use of lucee.runtime.interpreter.ref.Ref in project Lucee by lucee.
the class CFMLExpressionInterpreter method dynamic.
/**
* Liest den folgenden idetifier ein und prueft ob dieser ein boolscher Wert ist.
* Im Gegensatz zu CFMX wird auch "yes" und "no" als bolscher <wert akzeptiert,
* was bei CFMX nur beim Umwandeln einer Zeichenkette zu einem boolschen Wert der Fall ist.<br />
* Wenn es sich um keinen bolschen Wert handelt wird der folgende Wert eingelesen mit seiner ganzen Hirarchie.
* <br />
* EBNF:<br />
* <code>"true" | "false" | "yes" | "no" | startElement
* {("." identifier | "[" structElement "]" )[function] };</code>
* @return CFXD Element
* @throws PageException
*/
private Ref dynamic() throws PageException {
// get First Element of the Variable
int pos = cfml.getPos();
String name = identifier(false);
if (name == null) {
if (!cfml.forwardIfCurrent('('))
return null;
cfml.removeSpace();
Ref ref = assignOp();
if (!cfml.forwardIfCurrent(')'))
throw new InterpreterException("Invalid Syntax Closing [)] not found");
cfml.removeSpace();
return limited ? ref : subDynamic(ref);
}
cfml.removeSpace();
// Boolean constant
if (name.equalsIgnoreCase("TRUE")) {
cfml.removeSpace();
return LBoolean.TRUE;
} else if (name.equalsIgnoreCase("FALSE")) {
cfml.removeSpace();
return LBoolean.FALSE;
} else if (!isJson && name.equalsIgnoreCase("YES")) {
cfml.removeSpace();
return LBoolean.TRUE;
} else if (!isJson && name.equalsIgnoreCase("NO")) {
cfml.removeSpace();
return LBoolean.FALSE;
} else if (allowNullConstant && name.equalsIgnoreCase("NULL")) {
cfml.removeSpace();
return new LString(null);
} else if (!limited && name.equalsIgnoreCase("NEW")) {
Ref res = newOp();
if (res != null)
return res;
}
return limited ? startElement(name) : subDynamic(startElement(name));
}
Aggregations