src/main/java/org/mvel2/compiler/AbstractParser.java
private ASTNode captureCodeBlock(int type) {
    boolean cond = true;

    ASTNode first = null;
    ASTNode tk = null;

    switch (type) {
      case ASTNode.BLOCK_IF: {
        do {
          if (tk != null) {
            captureToNextTokenJunction();
            skipWhitespace();
            cond = expr[cursor] != '{' && expr[cursor] == 'i' && expr[++cursor] == 'f'
                && expr[cursor = incNextNonBlank()] == '(';
          }

          if (((IfNode) (tk = _captureBlock(tk, expr, cond, type))).getElseBlock() != null) {
            cursor++;
            return first;
          }

          if (first == null) first = tk;

          if (cursor != end && expr[cursor] != ';') {
            cursor++;
          }
        }
        while (ifThenElseBlockContinues());

        return first;
      }

      case ASTNode.BLOCK_DO:
        skipWhitespace();
        return _captureBlock(null, expr, false, type);

      default: // either BLOCK_WITH or BLOCK_FOREACH
        captureToNextTokenJunction();
        skipWhitespace();
        return _captureBlock(null, expr, true, type);
    }
  }
/**
   * Capture a code block by type.
   *
   * @param type the block type
   * @return an ast node
   */
Capture a code block by type.
@param type the block type
@return an ast node
Capture a code block by type . @param type the block type @return an ast node
private ASTNode captureCodeBlock(int type) {
    boolean cond = true;
    ASTNode first = null;
    ASTNode tk = null;
    switch (type) {
      case ASTNode.BLOCK_IF: {
        do {
          if (tk != null) {
            captureToNextTokenJunction();
            skipWhitespace();
            cond = expr[cursor] != '{' && expr[cursor] == 'i' && expr[++cursor] == 'f'
                && expr[cursor = incNextNonBlank()] == '(';
          }
          if (((IfNode) (tk = _captureBlock(tk, expr, cond, type))).getElseBlock() != null) {
            cursor++;
            return first;
          }
          if (first == null) first = tk;
          if (cursor != end && expr[cursor] != ';') {
            cursor++;
          }
        }
        while (ifThenElseBlockContinues());
        return first;
      }
      case ASTNode.BLOCK_DO:
        skipWhitespace();
        return _captureBlock(null, expr, false, type);
      default: 
        captureToNextTokenJunction();
        skipWhitespace();
        return _captureBlock(null, expr, true, type);
    }
  }
private ASTNode captureCodeBlock ( int type ) { boolean cond = true ; ASTNode first = null ; ASTNode tk = null ; switch ( type ) { case ASTNode . BLOCK_IF : { do { if ( tk != null ) { captureToNextTokenJunction ( ) ; skipWhitespace ( ) ; cond = expr [ cursor ] != '{' && expr [ cursor ] == 'i' && expr [ ++ cursor ] == 'f' && expr [ cursor = incNextNonBlank ( ) ] == '(' ; } if ( ( ( IfNode ) ( tk = _captureBlock ( tk , expr , cond , type ) ) ) . getElseBlock ( ) != null ) { cursor ++ ; return first ; } if ( first == null ) first = tk ; if ( cursor != end && expr [ cursor ] != ';' ) { cursor ++ ; } } while ( ifThenElseBlockContinues ( ) ) ; return first ; } case ASTNode . BLOCK_DO : skipWhitespace ( ) ; return _captureBlock ( null , expr , false , type ) ; default : captureToNextTokenJunction ( ) ; skipWhitespace ( ) ; return _captureBlock ( null , expr , true , type ) ; } }
Capture a code block by type.
Capture a code block by type .
// either BLOCK_WITH or BLOCK_FOREACH