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

📄 fmparser.java

📁 freemaker安装软件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
   TemplateElement block, recoveryBlock;
    start = jj_consume_token(ATTEMPT);
    block = OptionalBlock();
    recoveryBlock = Recover();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case END_RECOVER:
      end = jj_consume_token(END_RECOVER);
      break;
    case END_ATTEMPT:
      end = jj_consume_token(END_ATTEMPT);
      break;
    default:
      jj_la1[22] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
      AttemptBlock result = new AttemptBlock(block, recoveryBlock);
      result.setLocation(template, start, end);
      {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public RecoveryBlock Recover() throws ParseException {
   Token start;
   TemplateElement block;
    start = jj_consume_token(RECOVER);
    block = OptionalBlock();
      RecoveryBlock result = new RecoveryBlock(block);
      result.setLocation(template, start, block);
      {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public IteratorBlock List() throws ParseException {
    Expression exp;
    Token index, start, end;
    TemplateElement block;
    start = jj_consume_token(LIST);
                 ++loopNesting;
    exp = Expression();
    jj_consume_token(AS);
    index = jj_consume_token(ID);
    jj_consume_token(DIRECTIVE_END);
    block = OptionalBlock();
    end = jj_consume_token(END_LIST);
     --loopNesting;
     IteratorBlock result = new IteratorBlock(exp,
                                              index.image,
                                              block,
                                              false);
     result.setLocation(template, start, end);
     {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public IteratorBlock ForEach() throws ParseException {
     Expression exp;
     Token index, start, end;
     TemplateElement block;
    start = jj_consume_token(FOREACH);
                    ++loopNesting;
    index = jj_consume_token(ID);
    jj_consume_token(IN);
    exp = Expression();
    jj_consume_token(DIRECTIVE_END);
    block = OptionalBlock();
    end = jj_consume_token(END_FOREACH);
     --loopNesting;
     IteratorBlock result = new IteratorBlock(exp,
                                              index.image,
                                              block,
                                              true);
     result.setLocation(template, start, end);
     {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public VisitNode Visit() throws ParseException {
   Token start, end;
   Expression targetNode, namespaces=null;
    start = jj_consume_token(VISIT);
    targetNode = Expression();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case USING:
      jj_consume_token(USING);
      namespaces = Expression();
      break;
    default:
      jj_la1[23] = jj_gen;
      ;
    }
    end = LooseDirectiveEnd();
       VisitNode result = new VisitNode(targetNode, namespaces);
       result.setLocation(template, start, end);
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public RecurseNode Recurse() throws ParseException {
   Token start, end = null;
   Expression node=null, namespaces=null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SIMPLE_RECURSE:
      start = jj_consume_token(SIMPLE_RECURSE);
      break;
    case RECURSE:
      start = jj_consume_token(RECURSE);
      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:
        node = Expression();
        break;
      default:
        jj_la1[24] = jj_gen;
        ;
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case USING:
        jj_consume_token(USING);
        namespaces = Expression();
        break;
      default:
        jj_la1[25] = jj_gen;
        ;
      }
      end = LooseDirectiveEnd();
      break;
    default:
      jj_la1[26] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
       if (end == null) end = start;
       RecurseNode result = new RecurseNode(node, namespaces);
       result.setLocation(template, start, end);
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public FallbackInstruction FallBack() throws ParseException {
   Token tok;
    tok = jj_consume_token(FALLBACK);
      if (!inMacro) {
          {if (true) throw new ParseException(getErrorStart(tok)
                                   + "\nCannot fall back "
                                   + " outside a macro.",
                                   tok.beginLine, tok.beginColumn);}

      }
      FallbackInstruction result = new FallbackInstruction();
      result.setLocation(template, tok, tok);
      {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

/**
 * Production used to break out of a loop or a switch block.
 */
  final public BreakInstruction Break() throws ParseException {
   Token start;
    start = jj_consume_token(BREAK);
       if (loopNesting < 1 && switchNesting <1)
       {
          String msg = getErrorStart(start) + "\n"
                       + start.image
                       + " occurred outside a loop or a switch block.";
          {if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
       }
       BreakInstruction result = new BreakInstruction();
       result.setLocation(template, start, start);
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

/**
 * Production used to jump out of a macro.
 * The stop instruction terminates the rendering of the template.
 */
  final public ReturnInstruction Return() throws ParseException {
   Token start, end=null;
   Expression exp = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SIMPLE_RETURN:
      start = jj_consume_token(SIMPLE_RETURN);
                            end = start;
      break;
    case RETURN:
      start = jj_consume_token(RETURN);
      exp = Expression();
      end = LooseDirectiveEnd();
      break;
    default:
      jj_la1[27] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
      if (inMacro) {
         if (exp != null) {
            String msg = getErrorStart(start)
                         + "\nA macro cannot return a value";
            {if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
         }
      }
      else if (inFunction) {
         if (exp == null) {
            String msg = getErrorStart(start)
                         + "\nA function must return a value";
            {if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
         }
      }
      else {
         if (exp == null) {
            String msg = getErrorStart(start)
                         + "\nA return instruction can only occur inside a macro of function";
            {if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
         }
      }
      ReturnInstruction result = new ReturnInstruction(exp);
      result.setLocation(template, start, end);
      {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public StopInstruction Stop() throws ParseException {
   Token start = null;
   Expression exp = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case HALT:
      start = jj_consume_token(HALT);
      break;
    case STOP:
      start = jj_consume_token(STOP);
      exp = Expression();
      LooseDirectiveEnd();
      break;
    default:
      jj_la1[28] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
       StopInstruction result = new StopInstruction(exp);
       result.setLocation(template, start, start);
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public TemplateElement Nested() throws ParseException {
  Token t, end;
  ArrayList bodyParameters;
  BodyInstruction result = null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case SIMPLE_NESTED:
      t = jj_consume_token(SIMPLE_NESTED);
            result = new BodyInstruction(null);
            result.setLocation(template, t, t);
      break;
    case NESTED:
      t = jj_consume_token(NESTED);
      bodyParameters = PositionalArgs();
      end = LooseDirectiveEnd();
             result = new BodyInstruction(bodyParameters);
             result.setLocation(template, t, end);
      break;
    default:
      jj_la1[29] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
       if (!inMacro) {
          {if (true) throw new ParseException(getErrorStart(t)
                                   + "\nCannot use a "
                                   + t.image
                                   + " instruction outside a macro.",
                                   t.beginLine, t.beginColumn);}
       }
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public TemplateElement Flush() throws ParseException {
  Token t;
    t = jj_consume_token(FLUSH);
       FlushInstruction result = new FlushInstruction();
       result.setLocation(template, t, t);
       {if (true) return result;}
    throw new Error("Missing return statement in function");
  }

  final public TemplateElement Trim() throws ParseException {
  Token t;
  TrimInstruction result=null;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case TRIM:
      t = jj_consume_token(TRIM);
               result = new TrimInstruction(true, true);
      break;
    case LTRIM:
      t = jj_consume_token(LTRIM);
                result = new TrimInstruction(true, false);
      break;
    case RTRIM:
      t = jj_consume_token(RTRIM);
                result = new TrimInstruction(false, true);
      break;
    case NOTRIM:
      t = jj_consume_token(NOTRIM);
                 result = new TrimInstruction(false, false);
      break;
    default:
      jj_la1[30] = 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 TemplateElement Assign() throws ParseException {
   Token start, end;
   int scope;
   Token id=null;
   Expression nameExp, exp, nsExp=null;
   String varName;
   ArrayList assignments = new ArrayList();
   Assignment ass;
   TemplateElement block;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case ASSIGN:
      start = jj_consume_token(ASSIGN);
                      scope = Assignment.NAMESPACE;
      break;
    case GLOBALASSIGN:
      start = jj_consume_token(GLOBALASSIGN);
                           scope = Assignment.GLOBAL;
      break;
    case LOCALASSIGN:
      start = jj_consume_token(LOCALASSIGN);
                           scope = Assignment.LOCAL;
          scope = Assignment.LOCAL;
          if (!inMacro && !inFunction) {
             String msg = getErrorStart(start)
                          + "\nLocal variable assigned outside a macro.";
             {if (true) throw new ParseException(msg, start.beginLine, start.beginColumn);}
          }
      break;
    default:
      jj_la1[31] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    nameExp = IdentifierOrStringLiteral();
       varName = (nameExp instanceof StringLiteral) ? ((StringLiteral) nameExp).getAsString() : nameExp.toString();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case EQUALS:
      jj_consume_token(EQUALS);
      exp = Expression();
          ass = new Assignment(varName, exp, scope);
          ass.setLocation(template, nameExp, exp);
          assignments.add(ass);
      label_9:
      while (true) {
        if (jj_2_11(2147483647)) {
          ;
        } else {
          break label_9;
        }
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case COMMA:
          jj_consume_token(COMMA);
          break;
        default:
          jj_la1[32] = jj_gen;
          ;
        }
        nameExp = IdentifierOrStringLiteral();
               varName = (nameExp instanceof StringLiteral) ? ((StringLiteral) nameExp).getAsString() : nameExp.toString();
        jj_consume_token(EQUALS);
        exp = Expression();
               ass = new Assignment(varName, exp, scope);
               ass.setLocation(template, nameExp, exp);
               assignments.add(ass);
      }
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case IN:
        id = jj_consume_token(IN);
        nsExp = Expression();
                              if (scope != Assignment.NAMESPACE) {if (true) throw new ParseException(getErrorStart(id) + "\nCannot assign to namespace here.", id.beginLine, id.beginColumn);}

⌨️ 快捷键说明

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