use of lucee.commons.lang.ParserString in project Lucee by lucee.
the class DocCommentTransformer method transform.
public DocComment transform(Factory f, String str) {
try {
DocComment dc = new DocComment();
str = str.trim();
if (str.startsWith("/**"))
str = str.substring(3);
if (str.endsWith("*/"))
str = str.substring(0, str.length() - 2);
ParserString ps = new ParserString(str);
transform(f, dc, ps);
// TODO do different -> make sure internal structure is valid
dc.getHint();
return dc;
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
return null;
}
}
use of lucee.commons.lang.ParserString in project Lucee by lucee.
the class DocCommentTransformer method param.
private Attribute param(Factory factory, ParserString ps) {
String name = paramName(ps);
if (name == null)
return new Attribute(true, "@", factory.TRUE(), "boolean");
// white space
while (ps.isValidIndex() && ps.isCurrentWhiteSpace()) {
if (ps.getCurrent() == '\n')
return new Attribute(true, name, factory.TRUE(), "boolean");
ps.next();
}
Expression value = paramValue(factory, ps);
return new Attribute(true, name, value, value instanceof LitBoolean ? "boolean" : "string");
}
use of lucee.commons.lang.ParserString in project Lucee by lucee.
the class VariableInterpreter method isDefined.
/**
* check if a variable is defined in Page Context
* @param pc PageContext to check
* @param var variable String
* @return exists or not
*/
public static boolean isDefined(PageContext pc, String var) {
StringList list = parse(pc, new ParserString(var), false);
if (list == null)
return false;
try {
int scope = scopeString2Int(pc.ignoreScopes(), list.next());
Object coll = NULL;
if (scope == Scope.SCOPE_UNDEFINED) {
coll = pc.undefinedScope().get(list.current(), null);
if (coll == null)
return false;
} else {
coll = VariableInterpreter.scope(pc, scope, list.hasNext());
// coll=pc.scope(scope);
}
while (list.hasNext()) {
coll = pc.getVariableUtil().getCollection(pc, coll, list.next(), null);
if (coll == null)
return false;
}
} catch (PageException e) {
return false;
}
return true;
}
use of lucee.commons.lang.ParserString in project Lucee by lucee.
the class VariableInterpreter method getVariable.
/**
* get a variable from page context
* @param pc Page Context
* @param var variable string to get value to
* @return the value
* @throws PageException
*/
public static Object getVariable(PageContext pc, String var) throws PageException {
StringList list = parse(pc, new ParserString(var), false);
if (list == null)
throw new InterpreterException("invalid variable declaration [" + var + "]");
int scope = scopeString2Int(pc.ignoreScopes(), list.next());
Object coll = null;
if (scope == Scope.SCOPE_UNDEFINED) {
coll = pc.undefinedScope().get(list.current());
} else {
coll = VariableInterpreter.scope(pc, scope, list.hasNext());
}
while (list.hasNext()) {
coll = pc.getVariableUtil().get(pc, coll, list.next());
}
return coll;
}
use of lucee.commons.lang.ParserString in project Lucee by lucee.
the class VariableInterpreter method getVariableAsCollection.
public static Object getVariableAsCollection(PageContext pc, String var) throws PageException {
StringList list = parse(pc, new ParserString(var), false);
if (list == null)
throw new InterpreterException("invalid variable declaration [" + var + "]");
int scope = scopeString2Int(pc.ignoreScopes(), list.next());
Object coll = null;
if (scope == Scope.SCOPE_UNDEFINED) {
coll = pc.undefinedScope().getCollection(list.current());
} else {
coll = VariableInterpreter.scope(pc, scope, list.hasNext());
}
while (list.hasNext()) {
coll = pc.getVariableUtil().getCollection(pc, coll, list.next());
}
return coll;
}
Aggregations