Package org.lilystudio.smarty4j

Examples of org.lilystudio.smarty4j.ParseException


      } else if (direction.equals("down")) {
        type = 1;
      } else if (direction.equals("keep")) {
        type = 2;
      } else {
        throw new ParseException("direction必须是: up, down, keep");
      }
    }
  }
View Full Code Here


          // 处理数值常量
          int end = start + 1;
          while (end < len) {
            char d = line.charAt(end);
            if (Character.isJavaIdentifierStart(d)) {
              throw new ParseException("数值常量格式错误");
            } else if (!Character.isDigit(d)) {
              break;
            }
            end++;
          }

          int index = words.size() - 1;
          if (index > 3 && words.get(index) == Operation.C_SUB
              && words.get(index - 1) == Operation.C_SET) {
            // 识别负数
            words
                .add(new Integer(-Integer.parseInt(line.substring(start, end))));
          } else {
            words.add(new Integer(line.substring(start, end)));
          }
          start = end;
          continue;
        } else if (Character.isLetter(c)) {
          // 识别变量名
          int end = start + 1;
          while (end < len) {
            if (!Character.isJavaIdentifierPart(line.charAt(end))) {
              break;
            }
            end++;
          }

          String name = line.substring(start, end);
          if (!fields.containsKey(name)) {
            throw new ParseException("变量[" + name + "]不存在");
          }
          words.add(fields.get(name));
          start = end;
          continue;
        }
      }
      throw new ParseException("语法错误");
    }
    return words.toArray();
  }
View Full Code Here

  @Override
  public void syntax(Template template, Object[] words, int wordSize)
      throws ParseException {
    Object var = words[3];
    if ((wordSize > 4) || !(var instanceof VariableExpression)) {
      throw new ParseException("参数错误");
    }
    exp = (IExpression) var;
  }
View Full Code Here

    } else if (value.equals("hex")) {
      type = 4;
    } else if (value.equals("hexentity")) {
      type = 5;
    } else {
      throw new ParseException("不支持的参数");
    }
  }
View Full Code Here

   */
  int process(IExpression[] expressions, int expressionSize, int mode)
      throws ParseException {
    int index = expressionSize - param;
    if (index < 0) {
      throw new ParseException("运算符参数不足");
    }
    IExpression exp = expressions[index];
    switch (type) {
    case -1:
      if (exp instanceof ConstInteger) {
View Full Code Here

  @Override
  public void addStatement(IStatement statement) throws ParseException {
    if (statement instanceof $sectionelse) {
      if (elseBlock != null) {
        throw new ParseException("不能重复定义sectionelse");
      } else {
        elseBlock = new BlockStatement();
        elseBlock.setParent(this.getParent());
      }
    } else if (elseBlock != null) {
View Full Code Here

        if (floor > 0) {
          return;
        }
      }
    }
    throw new ParseException("参数错误");
  }
View Full Code Here

  @Override
  public void addStatement(IStatement statement) throws ParseException {
    if (statement instanceof $elseif) {
      if (elseBlock != null) {
        throw new ParseException("在else语句后不能再包含其它elseif或else语句");
      }
      addBranch((($elseif) statement).getCheckExpression());
    } else if (statement instanceof $else) {
      if (elseBlock != null) {
        throw new ParseException("在else语句后不能再包含其它elseif或else语句");
      }
      elseBlock = new BlockStatement();
      elseBlock.setParent(this);
      now = elseBlock;
    } else {
View Full Code Here

  @Override
  public void init(Template parent, boolean ransack, List<IExpression> values)
      throws ParseException {
    super.init(parent, ransack, values);
    if ((getParameter(0) == null) || (getParameter(1) == null)) {
      throw new ParseException("regex_replace参数错误");
    }
    rule = Pattern.compile(getParameter(0).toString());
  }
View Full Code Here

  public void syntax(Template template, Object[] words, int wordSize)
      throws ParseException {
    super.syntax(template, words, wordSize);

    if ((getParameter(2) == null) && (getParameter(3) == null)) {
      throw new ParseException("'to'和'assign'必须定义一个");
    }
  }
View Full Code Here

TOP

Related Classes of org.lilystudio.smarty4j.ParseException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.