Exemplo n.º 1
0
 private ASTNode parseCondition(IfContext context) throws IfStatementError {
   if (context.isEOF()) {
     throw new IfStatementError(
         Messages.TclIfProcessor_missingCondition, context.start(), context.end());
   }
   ASTNode node = context.get();
   if (node instanceof TclBlockExpression) {
     TclBlockExpression bl = (TclBlockExpression) node;
     List parseBlock = bl.parseBlockSimple(false);
     ASTListNode list = new ASTListNode(bl.sourceStart() + 1, bl.sourceEnd() - 1);
     for (int j = 0; j < parseBlock.size(); j++) {
       Object st = parseBlock.get(j);
       if (st instanceof TclStatement) {
         List expressions = ((TclStatement) st).getExpressions();
         for (int k = 0; k < expressions.size(); k++) {
           ASTNode expr = (ASTNode) expressions.get(k);
           list.addNode(expr);
         }
       }
     }
     return list;
   } else if (node instanceof SimpleReference) {
     return node;
   } else if (node instanceof TclAdvancedExecuteExpression) {
     TclAdvancedExecuteExpression ex = (TclAdvancedExecuteExpression) node;
     List childs = ex.getChilds();
     return new ASTListNode(node.sourceStart(), node.sourceEnd(), childs);
   } else if (node instanceof TclExecuteExpression) {
     return node;
   } else if (node instanceof Block) {
     return node;
   }
   throw new IfStatementError(Messages.TclIfProcessor_incorrectCondition, node);
 }
Exemplo n.º 2
0
 private void parseBlock(ITclParser parser, Block el, TclBlockExpression block) {
   String blockContent = block.getBlock();
   blockContent = blockContent.substring(1, blockContent.length() - 1);
   parser.parse(blockContent, block.sourceStart() + 1 - parser.getStartPos(), el);
 }