Ejemplo n.º 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() + "]");
  }
Ejemplo n.º 2
0
  /**
   * Hier werden die verschiedenen M￶glichen 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 ((ref = sharp()) != null) {
      mode = DYNAMIC;
      return ref;
    }
    // JSON
    if ((ref = json(JSON_ARRAY, '[', ']')) != null) {
      mode = DYNAMIC;
      return ref;
    }
    if ((ref = json(JSON_STRUCT, '{', '}')) != null) {
      mode = DYNAMIC;
      return ref;
    }

    if (cfml.isAfterLast() && cfml.toString().trim().length() == 0) return new LString("");

    // else Error
    throw new ExpressionException(
        "Syntax Error, Invalid Construct",
        "at position " + cfml.getPos() + " in [" + cfml.toString() + "]");
  }