Package httl.ast

Examples of httl.ast.BlockDirective


      // 弹栈
      if (directiveClass == EndDirective.class
          || directiveClass == ElseDirective.class) {
        if (directiveStack.isEmpty())
          throw new ParseException("Miss #end directive.", directive.getOffset());
        BlockDirective blockDirective = ((BlockDirectiveEntry) directiveStack.pop()).popDirective();
        if (blockDirective == rootDirective)
          throw new ParseException("Miss #end directive.", directive.getOffset());
        EndDirective endDirective;
        if (directiveClass == ElseDirective.class) {
          endDirective = new EndDirective(directive.getOffset());
        } else {
          endDirective = (EndDirective) directive;
        }
        blockDirective.setEnd(endDirective);
      }
      // 设置树
      if (directiveClass != EndDirective.class) { // 排除EndDirective
        if (directiveStack.isEmpty())
          throw new ParseException("Miss #end directive.", directive.getOffset());
        ((BlockDirectiveEntry) directiveStack.peek()).appendInnerDirective(directive);
      }
      // 压栈
      if (directive instanceof BlockDirective)
        directiveStack.push(new BlockDirectiveEntry((BlockDirective) directive));
    }
    BlockDirective root = (BlockDirective) ((BlockDirectiveEntry) directiveStack.pop()).popDirective();
    if (! directiveStack.isEmpty()) { // 后验条件
      throw new ParseException("Miss #end directive." + root.getClass().getSimpleName(), root.getOffset());
    }
    return root;
  }
View Full Code Here

TOP

Related Classes of httl.ast.BlockDirective

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.