use of lucee.runtime.interpreter.ref.literal.LStringBuffer in project Lucee by lucee.
the class CFMLExpressionInterpreter method string.
/**
* Transfomiert einen lierale Zeichenkette.
* <br />
* EBNF:<br />
* <code>("'" {"##"|"''"|"#" impOp "#"| ?-"#"-"'" } "'") |
* (""" {"##"|""""|"#" impOp "#"| ?-"#"-""" } """);</code>
* @return CFXD Element
* @throws PageException
*/
protected Ref string() throws PageException {
// Init Parameter
char quoter = cfml.getCurrentLower();
LStringBuffer str = new LStringBuffer();
Ref value = null;
while (cfml.hasNext()) {
cfml.next();
// check sharp
if (!limited && cfml.isCurrent('#')) {
if (cfml.isNext('#')) {
cfml.next();
str.append('#');
} else {
cfml.next();
cfml.removeSpace();
if (!str.isEmpty() || value != null)
str.append(assignOp());
else
value = assignOp();
cfml.removeSpace();
if (!cfml.isCurrent('#'))
throw new InterpreterException("Invalid Syntax Closing [#] not found");
}
} else if (cfml.isCurrent(quoter)) {
if (cfml.isNext(quoter)) {
cfml.next();
str.append(quoter);
} else {
break;
}
} else // all other character
{
str.append(cfml.getCurrent());
}
}
if (!cfml.forwardIfCurrent(quoter))
throw new InterpreterException("Invalid String Literal Syntax Closing [" + quoter + "] not found");
cfml.removeSpace();
mode = STATIC;
if (value != null) {
if (str.isEmpty())
return value;
return new Concat(value, str, limited);
}
return str;
}
use of lucee.runtime.interpreter.ref.literal.LStringBuffer in project Lucee by lucee.
the class JSONExpressionInterpreter method string.
@Override
protected Ref string() throws PageException {
// Init Parameter
char quoter = cfml.getCurrentLower();
LStringBuffer str = new LStringBuffer();
while (cfml.hasNext()) {
cfml.next();
// check sharp
if (cfml.isCurrent('\\')) {
if (cfml.isNext(quoter)) {
cfml.next();
str.append(quoter);
} else if (cfml.isNext('\\')) {
cfml.next();
str.append('\\');
} else if (cfml.isNext('"')) {
cfml.next();
str.append('"');
} else if (cfml.isNext('\'')) {
cfml.next();
str.append('\'');
} else if (cfml.isNext('t')) {
cfml.next();
str.append('\t');
} else if (cfml.isNext('n')) {
cfml.next();
str.append('\n');
} else if (cfml.isNext('b')) {
cfml.next();
str.append('\b');
} else if (cfml.isNext('f')) {
cfml.next();
str.append('\f');
} else if (cfml.isNext('r')) {
cfml.next();
str.append('\r');
} else if (cfml.isNext('u')) {
cfml.next();
StringBuilder sb = new StringBuilder();
int i = 0;
for (; i < 4 && cfml.hasNext(); i++) {
cfml.next();
sb.append(cfml.getCurrent());
}
if (i < 4) {
str.append("\\u");
str.append(sb.toString());
} else {
int asc = NumberUtil.hexToInt(sb.toString(), -1);
if (asc != -1)
str.append((char) asc);
else {
str.append("\\u");
str.append(sb.toString());
}
}
} else if (cfml.isNext('/')) {
cfml.next();
str.append('/');
} else {
str.append('\\');
}
} else if (cfml.isCurrent(quoter)) {
break;
} else // all other character
{
str.append(cfml.getCurrent());
}
}
if (!cfml.forwardIfCurrent(quoter))
throw new InterpreterException("Invalid String Literal Syntax Closing [" + quoter + "] not found");
cfml.removeSpace();
mode = STATIC;
/*Ref value=null;
if(value!=null) {
if(str.isEmpty()) return value;
return new Concat(pc,value,str);
}*/
return str;
}
Aggregations