⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fmparser.java

📁 freemaker安装软件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
      break;
    case DOUBLE_STAR:
      t = jj_consume_token(DOUBLE_STAR);
      break;
    case FALSE:
    case TRUE:
    case LESS_THAN:
    case LESS_THAN_EQUALS:
    case ESCAPED_GT:
    case ESCAPED_GTE:
    case IN:
    case AS:
    case USING:
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case LESS_THAN:
        t = jj_consume_token(LESS_THAN);
        break;
      case LESS_THAN_EQUALS:
        t = jj_consume_token(LESS_THAN_EQUALS);
        break;
      case ESCAPED_GT:
        t = jj_consume_token(ESCAPED_GT);
        break;
      case ESCAPED_GTE:
        t = jj_consume_token(ESCAPED_GTE);
        break;
      case FALSE:
        t = jj_consume_token(FALSE);
        break;
      case TRUE:
        t = jj_consume_token(TRUE);
        break;
      case IN:
        t = jj_consume_token(IN);
        break;
      case AS:
        t = jj_consume_token(AS);
        break;
      case USING:
        t = jj_consume_token(USING);
        break;
      default:
        jj_la1[11] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
            if (!Character.isLetter(t.image.charAt(0))) {
                String msg = getErrorStart(t)
                            + "\n" + t.image + " is not a valid identifier.";
                {if (true) throw new ParseException(msg, t.beginLine, t.beginColumn);}
            }
      break;
    default:
      jj_la1[12] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
         notListLiteral(exp, "hash");
         notStringLiteral(exp, "hash");
         notBooleanLiteral(exp, "hash");
         Dot dot = new Dot(exp, t.image);
         dot.setLocation(template, exp, t);
         {if (true) return dot;}
    throw new Error("Missing return statement in function");
  }

/**
 * production for when the key is specified
 * in brackets.
 */
  final public Expression DynamicKey(Expression exp) throws ParseException {
   Expression arg;
   Token t;
    jj_consume_token(OPEN_BRACKET);
    arg = Expression();
    t = jj_consume_token(CLOSE_BRACKET);
       notBooleanLiteral(exp, "list or hash");
       notNumberLiteral(exp, "list or hash");
       DynamicKeyName dkn = new DynamicKeyName(exp, arg);
       dkn.setLocation(template, exp, t);
       {if (true) return dkn;}
    throw new Error("Missing return statement in function");
  }

/**
 * production for an arglist part of a method invocation.
 */
  final public MethodCall MethodArgs(Expression exp) throws ParseException {
     ArrayList args = new ArrayList();
     Token end;
    jj_consume_token(OPEN_PAREN);
    args = PositionalArgs();
    end = jj_consume_token(CLOSE_PAREN);
        args.trimToSize();
        MethodCall result = new MethodCall(exp, args);
        result.setLocation(template, exp, end);
        {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public StringLiteral StringLiteral(boolean interpolate) throws ParseException {
  Token t;
  boolean raw = false;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case STRING_LITERAL:
      t = jj_consume_token(STRING_LITERAL);
      break;
    case RAW_STRING:
      t = jj_consume_token(RAW_STRING);
                     raw = true;
      break;
    default:
      jj_la1[13] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
       String s = t.image;
       // Get rid of the quotes.
       s = s.substring(1, s.length() -1);
       if (raw) {
           s=s.substring(1);
       }
       else try {
          s = StringUtil.FTLStringLiteralDec(s);
       } catch (ParseException pe) {
          pe.lineNumber = t.beginLine;
          pe.columnNumber = t.beginColumn;
          {if (true) throw pe;}
       }
       StringLiteral result = new StringLiteral(s);
       result.setLocation(template, t, t);
       if (interpolate && !raw) {
           result.checkInterpolation();
       }
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public Expression BooleanLiteral() throws ParseException {
   Token t;
   Expression result;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case FALSE:
      t = jj_consume_token(FALSE);
                  result = new BooleanLiteral(false);
      break;
    case TRUE:
      t = jj_consume_token(TRUE);
                 result = new BooleanLiteral(true);
      break;
    default:
      jj_la1[14] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
       result.setLocation(template, t, t);
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public HashLiteral HashLiteral() throws ParseException {
   Token begin, end;
   Expression key, value;
   ArrayList keys = new ArrayList();
   ArrayList values = new ArrayList();
    begin = jj_consume_token(OPEN_BRACE);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case STRING_LITERAL:
    case RAW_STRING:
    case FALSE:
    case TRUE:
    case INTEGER:
    case DECIMAL:
    case DOT:
    case PLUS:
    case MINUS:
    case EXCLAM:
    case OPEN_BRACKET:
    case OPEN_PAREN:
    case OPEN_BRACE:
    case ID:
      key = Expression();
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case COMMA:
        jj_consume_token(COMMA);
        break;
      case COLON:
        jj_consume_token(COLON);
        break;
      default:
        jj_la1[15] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      value = Expression();
          stringLiteralOnly(key);
          keys.add(key);
          values.add(value);
      label_7:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case COMMA:
          ;
          break;
        default:
          jj_la1[16] = jj_gen;
          break label_7;
        }
        jj_consume_token(COMMA);
        key = Expression();
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case COMMA:
          jj_consume_token(COMMA);
          break;
        case COLON:
          jj_consume_token(COLON);
          break;
        default:
          jj_la1[17] = jj_gen;
          jj_consume_token(-1);
          throw new ParseException();
        }
        value = Expression();
               stringLiteralOnly(key);
               keys.add(key);
               values.add(value);
      }
      break;
    default:
      jj_la1[18] = jj_gen;
      ;
    }
    end = jj_consume_token(CLOSE_BRACE);
      HashLiteral result = new HashLiteral(keys, values);
      result.setLocation(template, begin, end);
      {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

/**
 * A production representing the ${...}
 * that outputs a variable.
 */
  final public DollarVariable StringOutput() throws ParseException {
   Expression exp;
   Token begin, end;
    begin = jj_consume_token(OUTPUT_ESCAPE);
    exp = Expression();
      notHashLiteral(exp, "scalar");
      notListLiteral(exp, "scalar");
      notBooleanLiteral(exp, "scalar");
    end = jj_consume_token(CLOSE_BRACE);
      DollarVariable result = new DollarVariable(exp, escapedExpression(exp));
      result.setLocation(template, begin, end);
      {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public NumericalOutput NumericalOutput() throws ParseException {
   Expression exp;
   Token fmt = null, begin, end;
    begin = jj_consume_token(NUMERICAL_ESCAPE);
    exp = Expression();
                     numberLiteralOnly(exp);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SEMICOLON:
      jj_consume_token(SEMICOLON);
      fmt = jj_consume_token(ID);
      break;
    default:
      jj_la1[19] = jj_gen;
      ;
    }
    end = jj_consume_token(CLOSE_BRACE);
      NumericalOutput result;
      if (fmt != null) {
         int minFrac = -1;  // -1 indicates that the value has not been set
         int maxFrac = -1;

         StringTokenizer st = new StringTokenizer(fmt.image, "mM", true);
         char type = '-';
         while (st.hasMoreTokens()) {
             String token = st.nextToken();
             try {
                if (type != '-') {
                    switch (type) {
                    case 'm':
                       if (minFrac != -1) {if (true) throw new ParseException("invalid formatting string", fmt.beginLine, fmt.beginColumn);}
                       minFrac = Integer.parseInt(token);
                       break;
                    case 'M':
                       if (maxFrac != -1) {if (true) throw new ParseException("invalid formatting string", fmt.beginLine, fmt.beginColumn);}
                       maxFrac = Integer.parseInt(token);
                       break;
                    default:
                       {if (true) throw new ParseException();}
                    }
                    type = '-';
                } else if (token.equals("m")) {
                   type = 'm';
                } else if (token.equals("M")) {
                   type = 'M';
                } else {
                   {if (true) throw new ParseException();}
                }
             }
             catch (ParseException e) {
                String msg = getErrorStart(fmt)
                      + "\nInvalid format specifier "
                      + fmt.image;
                {if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
             }
             catch (NumberFormatException e) {
                String msg = getErrorStart(fmt)
                      + "\nInvalid number in the format specifier "
                      + fmt.image;
                {if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
             }
         }

         if (maxFrac == -1) {
            if (minFrac == -1) {
               String msg = getErrorStart(fmt)
                     + "\nInvalid format specification, at least one of m and M must be specified!";
               {if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
            }
            maxFrac = minFrac;
         } else if (minFrac == -1) {
            minFrac = 0;
         }
         if (minFrac > maxFrac) {
            String msg = getErrorStart(fmt)
                  + "\nInvalid format specification, min cannot be greater than max!";
            {if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
         }
         if (minFrac > 50 || maxFrac > 50) {// sanity check
               String msg = getErrorStart(fmt)
               + "\nCannot specify more than 50 fraction digits";
             {if (true) throw new ParseException(msg, fmt.beginLine, fmt.beginColumn);}
         }
         result = new NumericalOutput(exp, minFrac, maxFrac);
      } else {  // if format != null
         result = new NumericalOutput(exp);
      }
      result.setLocation(template, begin, end);
      {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public TemplateElement If() throws ParseException {
    Token start, end, t;
    Expression condition;
    TemplateElement block;
    IfBlock ifBlock;
    ConditionalBlock cblock;
    start = jj_consume_token(IF);
    condition = Expression();
    jj_consume_token(DIRECTIVE_END);
    block = OptionalBlock();
      cblock = new ConditionalBlock(condition, block, true);
      cblock.setLocation(template, start, block);
      ifBlock = new IfBlock(cblock);
    label_8:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case ELSE_IF:
        ;
        break;
      default:
        jj_la1[20] = jj_gen;
        break label_8;
      }
      t = jj_consume_token(ELSE_IF);
      condition = Expression();
      LooseDirectiveEnd();
      block = OptionalBlock();
          cblock = new ConditionalBlock(condition, block, false);
          cblock.setLocation(template, t, block);
          ifBlock.addBlock(cblock);
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ELSE:
      t = jj_consume_token(ELSE);
      block = OptionalBlock();
            cblock = new ConditionalBlock(null, block, false);
            cblock.setLocation(template, t, block);
            ifBlock.addBlock(cblock);
      break;
    default:
      jj_la1[21] = jj_gen;
      ;
    }
    end = jj_consume_token(END_IF);
       ifBlock.setLocation(template, start, end);
       {if (true) return ifBlock;}
    throw new Error("Missing return statement in function");
  }

  final public AttemptBlock Attempt() throws ParseException {
   Token start, end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -