Search in sources :

Example 16 with ParserString

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;
    }
}
Also used : ParserString(lucee.commons.lang.ParserString)

Example 17 with ParserString

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");
}
Also used : Attribute(lucee.transformer.bytecode.statement.tag.Attribute) Expression(lucee.transformer.expression.Expression) LitBoolean(lucee.transformer.expression.literal.LitBoolean) ParserString(lucee.commons.lang.ParserString)

Example 18 with ParserString

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;
}
Also used : PageException(lucee.runtime.exp.PageException) StringList(lucee.commons.lang.StringList) ParserString(lucee.commons.lang.ParserString)

Example 19 with ParserString

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;
}
Also used : StringList(lucee.commons.lang.StringList) ParserString(lucee.commons.lang.ParserString)

Example 20 with ParserString

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;
}
Also used : StringList(lucee.commons.lang.StringList) ParserString(lucee.commons.lang.ParserString)

Aggregations

ParserString (lucee.commons.lang.ParserString)23 StringList (lucee.commons.lang.StringList)10 ValueString (lucee.runtime.sql.exp.value.ValueString)7 PageException (lucee.runtime.exp.PageException)5 RefBoolean (lucee.commons.lang.types.RefBoolean)3 RefBooleanImpl (lucee.commons.lang.types.RefBooleanImpl)3 ColumnExpression (lucee.runtime.sql.exp.ColumnExpression)3 Expression (lucee.runtime.sql.exp.Expression)2 ValueNumber (lucee.runtime.sql.exp.value.ValueNumber)2 DateFormat (lucee.runtime.format.DateFormat)1 TimeFormat (lucee.runtime.format.TimeFormat)1 Ref (lucee.runtime.interpreter.ref.Ref)1 Column (lucee.runtime.sql.exp.Column)1 OperationN (lucee.runtime.sql.exp.op.OperationN)1 Collection (lucee.runtime.type.Collection)1 Struct (lucee.runtime.type.Struct)1 StructImpl (lucee.runtime.type.StructImpl)1 DateTime (lucee.runtime.type.dt.DateTime)1 VariableReference (lucee.runtime.type.ref.VariableReference)1 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)1