Пример #1
0
  /**
   * Wird aufgerufen um aus dem bergebenen CFMLString einen Ausdruck auszulesen und diese zu
   * interpretieren. <br>
   * Beispiel eines bergebenen String:<br>
   * <code>session.firstName</code> oder <code>trim(left('test'&var1,3))</code> <br>
   * EBNF:<br>
   * <code>spaces impOp;</code>
   *
   * @param pc
   * @param cfml
   * @return
   * @throws PageException
   */
  public Object interpret(PageContext pc, ParserString cfml) throws PageException {
    this.cfml = cfml;
    this.pc = pc;
    if (pc != null) fld = ((ConfigImpl) pc.getConfig()).getCombinedFLDs();

    if (JSON_ARRAY == null) JSON_ARRAY = fld.getFunction("_jsonArray");
    if (JSON_STRUCT == null) JSON_STRUCT = fld.getFunction("_jsonStruct");

    cfml.removeSpace();
    Ref ref = assignOp();
    cfml.removeSpace();

    if (cfml.isAfterLast()) {
      return ref.getValue();
    }
    throw new ExpressionException("Syntax Error, invalid Expression [" + cfml.toString() + "]");
  }
Пример #2
0
  private Ref subDynamic(Ref ref) throws PageException {
    String name = null;

    // Loop over nested Variables
    while (cfml.isValidIndex()) {
      // .
      if (cfml.forwardIfCurrent('.')) {
        // Extract next Var String
        cfml.removeSpace();
        name = identifier(true);
        if (name == null) throw new ExpressionException("Invalid identifier");
        cfml.removeSpace();
        ref = new Variable(pc, ref, name);
      }
      // []
      else if (cfml.forwardIfCurrent('[')) {
        cfml.removeSpace();
        ref = new Variable(pc, ref, assignOp());
        cfml.removeSpace();
        if (!cfml.forwardIfCurrent(']'))
          throw new ExpressionException("Invalid Syntax Closing []] not found");
      }
      // finish
      else {
        break;
      }

      cfml.removeSpace();

      if (cfml.isCurrent('(')) {
        if (!(ref instanceof Set))
          throw new ExpressionException(
              "invalid syntax " + ref.getTypeName() + " can't called as function");
        Set set = (Set) ref;
        ref = new UDFCall(pc, set.getParent(), set.getKey(), functionArg(name, false, null, ')'));
      }
    }
    if (ref instanceof railo.runtime.interpreter.ref.var.Scope) {
      railo.runtime.interpreter.ref.var.Scope s = (railo.runtime.interpreter.ref.var.Scope) ref;
      if (s.getScope() == Scope.SCOPE_ARGUMENTS
          || s.getScope() == Scope.SCOPE_LOCAL
          || s.getScope() == ScopeSupport.SCOPE_VAR) {
        ref = new Bind(s);
      }
    }
    return ref;
  }
Пример #3
0
 @Override
 public Object getValue(PageContext pc) throws PageException {
   return new Double(
       Caster.toDoubleValue(left.getValue(pc)) % Caster.toDoubleValue(right.getValue(pc)));
 }