Parse statements for alternative if syntax.
@return Node
422089
private function innerIfInnerStatementList() {
    static $terminators = [T_ELSEIF, T_ELSE, T_ENDIF];
    $node = new StatementBlockNode();
    while ($this->currentType !== NULL && !in_array($this->currentType, $terminators)) {
      $this->matchHidden($node);
      $node->addChild($this->innerStatement());
    }
    return $node;
  }
31621
public function parse()
    {
        if (isset($this->raw->data)) {
            $this->setData($this->raw->data);
        }

        if (isset($this->raw->included)) {
            $this->setIncluded($this->raw->included);
        }

        if (isset($this->raw->links)) {
            $this->setLinks($this->raw->links);
        }

        if (isset($this->raw->meta)) {
            $this->setMeta($this->raw->meta);
        }

        if (isset($this->raw->errors)) {
            $this->setErrors($this->raw->errors);
        }

        return $this;
    }
837139
public function parse()
    {
        $counter = 0;
        $continue = true;
        while ($continue) {
            $continue = $this->readNextChunk();

            ++$counter;
            if (!isset($this->rootNode)) {
                // Find root node
                if (isset($this->customRootNode)) {
                    $customRootNodePos = strpos($this->chunk, "<{$this->customRootNode}");
                    if (false !== $customRootNodePos) {
                        // Found custom root node
                        // Support attributes
                        $closer = strpos(substr($this->chunk, $customRootNodePos), '>');
                        $readFromChunkPos = $customRootNodePos + $closer + 1;

                        // Custom child node?
                        if (isset($this->customChildNode)) {
                            // Find it in the chunk
                            $customChildNodePos = strpos(substr($this->chunk, $readFromChunkPos), "<{$this->customChildNode}");
                            if (false !== $customChildNodePos) {
                                // Found it!
                                $readFromChunkPos = $readFromChunkPos + $customChildNodePos;
                            } else {
                                // Didn't find it - read a larger chunk and do everything again
                                continue;
                            }
                        }

                        $this->rootNode = $this->customRootNode;
                        $this->readFromChunkPos = $readFromChunkPos;
                    } else {
                        // Clear chunk to save memory, it doesn't contain the root anyway
                        $this->readFromChunkPos = 0;
                        $this->chunk = '';
                        continue;
                    }
                } else {
                    // XML1.0 standard allows almost all Unicode characters even Chinese and Cyrillic.
                    // see: http://en.wikipedia.org/wiki/XML#International_use
                    preg_match('/<([^>\?]+)>/', $this->chunk, $matches);
                    if (isset($matches[1])) {
                        // Found root node
                        $this->rootNode = $matches[1];
                        $this->readFromChunkPos = strpos($this->chunk, $matches[0]) + strlen($matches[0]);
                    } else {
                        // Clear chunk to save memory, it doesn't contain the root anyway
                        $this->readFromChunkPos = 0;
                        $this->chunk = '';
                        continue;
                    }
                }
            }

            while (true) {
                $fromChunkPos = substr($this->chunk, $this->readFromChunkPos);

                // Find element
                // XML1.0 standard allows almost all Unicode characters even Chinese and Cyrillic.
                // see: http://en.wikipedia.org/wiki/XML#International_use
                preg_match('/<([^>]+)>/', $fromChunkPos, $matches);
                if (isset($matches[1])) {
                    // Found element
                    $element = $matches[1];

                    // Is there an end to this element tag?
                    $spacePos = strpos($element, ' ');
                    $crPos = strpos($element, "\r");
                    $lfPos = strpos($element, "\n");
                    $tabPos = strpos($element, "\t");

                    // find min. (exclude false, as it would convert to int 0)
                    $aPositionsIn = array($spacePos, $crPos, $lfPos, $tabPos);
                    $aPositions = array();
                    foreach ($aPositionsIn as $iPos) {
                        if (false !== $iPos) {
                            $aPositions[] = $iPos;
                        }
                    }

                    $minPos = $aPositions === array() ? false : min($aPositions);

                    if (false !== $minPos && 0 != $minPos) {
                        $sElementName = substr($element, 0, $minPos);
                        $endTag = '</'.$sElementName.'>';
                    } else {
                        $sElementName = $element;
                        $endTag = "</$sElementName>";
                    }

                    $endTagPos = false;

                    // try selfclosing first!
                    // NOTE: selfclosing is inside the element
                    $lastCharPos = strlen($element) - 1;
                    if ('/' == substr($element, $lastCharPos)) {
                        $endTag = '/>';
                        $endTagPos = $lastCharPos;

                        $iPos = strpos($fromChunkPos, '<');
                        if (false !== $iPos) {
                            // correct difference between $element and $fromChunkPos
                            // "+1" is for the missing '<' in $element
                            $endTagPos += $iPos + 1;
                        }
                    }

                    if (false === $endTagPos) {
                        $endTagPos = strpos($fromChunkPos, $endTag);
                    }

                    if (false !== $endTagPos) {
                        // Found end tag
                        $endTagEndPos = $endTagPos + strlen($endTag);
                        $elementWithChildren = trim(substr($fromChunkPos, 0, $endTagEndPos));

                        $continueParsing = $this->processNode($elementWithChildren, $sElementName, $this->nodeIndex++);
                        $this->chunk = substr($this->chunk, strpos($this->chunk, $endTag) + strlen($endTag));
                        $this->readFromChunkPos = 0;

                        if (isset($continueParsing) && false === $continueParsing) {
                            $this->chunkCompleted();
                            break 2;
                        }
                    } else {
                        break;
                    }
                } else {
                    break;
                }
            }
            $this->chunkCompleted();
        }

        return isset($this->rootNode);
        fclose($this->handle);
    }
633760
private function parseItem()
    {
        $subparser = new StringValue($this->parser, ($this->level + 1));
        $subparser->parse();

        $key = $subparser->getValue();

        $this->debug('key: ' . var_export($key, true));

        if ($this->tokenIs(T_DOUBLE_ARROW)) {
            // We MUST have an key when double arrow is encountered.
            if ($key === null) {
                $this->bailUnexpectedToken();
            }

            $this->pushStack($key);
            $this->parseValue();
            $this->popStack();
        } elseif ($this->tokenIs(',') || $this->tokenIs(')') || $this->tokenIs(']')) {
            // String item without key.
            $this->debug('String item without key.');
            $this->pushStack($this->counter++);
            $this->parser->setValue($this->parser->getStack(), $key);
            $this->popStack();
        }

        if ($this->tokenIs(',')) {
            $this->getNextToken();
            return true;
        }
        if ($this->tokenIs(')') || $this->tokenIs(']')) {
            $this->debug('closing bracket.');
            $this->getNextToken();

            return false;
        }

        return true;
    }
874630
protected function parse()
	{
		if (($s = $this->copy_until_char('<'))==='')
		{
			return $this->read_tag();
		}

		// text
		$node = new Node($this);
		++$this->cursor;
		$node->_[self::HDOM_INFO_TEXT] = $s;
		$this->link_nodes($node, false);
		return true;
	}
536276
public function matchIfValueReturnValue(If_ $ifNode): ?Expr
    {
        if (count($ifNode->stmts) !== 1) {
            return null;
        }

        $insideIfNode = $ifNode->stmts[0];
        if (! $insideIfNode instanceof Return_) {
            return null;
        }

        /** @var Return_ $returnNode */
        $returnNode = $insideIfNode;

        if (! $ifNode->cond instanceof Identical) {
            return null;
        }

        if ($this->betterStandardPrinter->areNodesEqual($ifNode->cond->left, $returnNode->expr)) {
            return $ifNode->cond->right;
        }

        if ($this->betterStandardPrinter->areNodesEqual($ifNode->cond->right, $returnNode->expr)) {
            return $ifNode->cond->left;
        }

        return null;
    }
1222493
private function namespaceBlock() {
    $node = new StatementBlockNode();
    $this->matchHidden($node);
    while ($this->currentType !== NULL) {
      if ($this->currentType === T_NAMESPACE && !$this->isLookAhead(T_NS_SEPARATOR)) {
        break;
      }
      $node->addChild($this->topStatement());
      $this->matchHidden($node);
    }
    $this->matchHidden($node);
    return $node;
  }
1359349
private function parseAddition (){

		$return = $m = $this->parseMultiplication();
		if( $return ){
			while( true ){

				$isSpaced = $this->isWhitespace( -1 );

				$op = $this->MatchReg('/\\G[-+]\s+/');
				if( $op ){
					$op = $op[0];
				}else{
					if( !$isSpaced ){
						$op = $this->match(array('#+','#-'));
					}
					if( !$op ){
						break;
					}
				}

				$a = $this->parseMultiplication();
				if( !$a ){
					break;
				}

				$m->parensInOp = true;
				$a->parensInOp = true;
				$return = $this->NewObj3('Less_Tree_Operation',array($op, array($return, $a), $isSpaced));
			}
		}

		return $return;
	}
1240576
public function parse()
    {
        if (preg_match_all($this->pattern, $this->originalString, $matches, PREG_SET_ORDER)) {
            $this->parsed = [];
            foreach ($matches as $match) {
                $code = explode(';', static::$colorMaps[$match['color']]);
                $parsed = [];
                if ($match['prefix']) {
                    $parsed = array_merge($parsed, $this->parseLine($match['prefix']));
                }
                $parsed = array_merge($parsed, $this->parseLine($match['str'], $code[1]));
                if ($match['suffix']) {
                    $parsed = array_merge($parsed, $this->parseLine($match['suffix']));
                }
                /*
                $this->parsed = array_merge(
                    $this->parsed,
                    // $this->parseLine($match['prefix']),
                    $this->parseLine($match['str'], $code[1])
                    // $this->parseLine($match['suffix'])
                );
                */
               $this->parsed = array_merge($this->parsed, $parsed);
            }
        } else {
            $this->parsed = $this->parseLine($this->originalString, null);
        }

        return $this;
    }
1076139
protected function processLogicalAndNode()
    {
        if (null !== $this->scope->getCurrentLeftNode()
            && null !== $this->scope->getNode()
            && null !== $this->scope->getCurrentOperator()
        ) {
            $node = new BooleanNode($this->scope->getCurrentLeftNode(), $this->scope->getNode(), $this->scope->getCurrentOperator());
            $this->scope
                ->setNode($node)
                ->deleteCurrentLeftNode()
                ->deleteCurrentOperator();
        }

        return $this;
    }
205955
public function parse()
    {
        $nodes = [];
        foreach (array_slice($this->body, self::POS_NODES_START) as $node) {
            $nodes[] = [
                self::NODE_ID => $node[self::POS_NODE_ID],
                self::NODE_HOST => $node[self::POS_NODE_HOST],
                self::NODE_PORT => $node[self::POS_NODE_PORT],
                self::NODE_PRIORITY => $node[self::POS_NODE_PRIORITY]
            ];
        }

        return [
            self::NODE_VERSION => $this->body[self::POS_VERSION],
            self::NODE_ID => $this->body[self::POS_ID],
            self::NODES => $nodes
        ];
    }
1193722
public function conditionalExpression()
    {
        $conditionalTerms = array();
        $conditionalTerms[] = $this->conditionalTerm();

        while ($this->lexer->isNextToken(Lexer::T_OR)) {
            $this->match(Lexer::T_OR);

            $conditionalTerms[] = $this->conditionalTerm();
        }

        // Phase 1 AST optimization: Prevent AST\ConditionalExpression
        // if only one AST\ConditionalTerm is defined
        if (count($conditionalTerms) == 1) {
            return $conditionalTerms[0];
        }

        return new ConditionalExpressionNode($conditionalTerms);
    }
41665
function parse() {
    $this->output = '';
    # drop tags
    $this->parser->html = preg_replace('#<('.implode('|', $this->drop).')[^>]*>.*</\\1>#sU', '', $this->parser->html);
    while ($this->parser->nextNode()) {
      switch ($this->parser->nodeType) {
        case 'doctype':
          break;
        case 'pi':
        case 'comment':
          if ($this->keepHTML) {
            $this->flushLinebreaks();
            $this->out($this->parser->node);
            $this->setLineBreaks(2);
          }
          # else drop
          break;
        case 'text':
          $this->handleText();
          break;
        case 'tag':
          if (in_array($this->parser->tagName, $this->ignore)) {
            break;
          }
          if ($this->parser->isStartTag) {
            $this->flushLinebreaks();
          }
          if ($this->skipConversion) {
            $this->isMarkdownable(); # update notConverted
            $this->handleTagToText();
            continue;
          }
          if (!$this->parser->keepWhitespace && $this->parser->isBlockElement && $this->parser->isStartTag) {
            $this->parser->html = ltrim($this->parser->html);
          }
          if ($this->isMarkdownable()) {
            if ($this->parser->isBlockElement && $this->parser->isStartTag && !$this->lastWasBlockTag && !empty($this->output)) {
              if (!empty($this->buffer)) {
                $str =& $this->buffer[count($this->buffer) -1];
              } else {
                $str =& $this->output;
              }
              if (substr($str, -strlen($this->indent)-1) != "\n".$this->indent) {
                $str .= "\n".$this->indent;
              }
            }
            $func = 'handleTag_'.$this->parser->tagName;
            $this->$func();
            if ($this->linksAfterEachParagraph && $this->parser->isBlockElement && !$this->parser->isStartTag && empty($this->parser->openTags)) {
              $this->flushStacked();
            }
            if (!$this->parser->isStartTag) {
              $this->lastClosedTag = $this->parser->tagName;
            }
          } else {
            $this->handleTagToText();
            $this->lastClosedTag = '';
          }
          break;
        default:
          trigger_error('invalid node type', E_USER_ERROR);
          break;
      }
      $this->lastWasBlockTag = $this->parser->nodeType == 'tag' && $this->parser->isStartTag && $this->parser->isBlockElement;
    }
    if (!empty($this->buffer)) {
      trigger_error('buffer was not flushed, this is a bug. please report!', E_USER_WARNING);
      while (!empty($this->buffer)) {
        $this->out($this->unbuffer());
      }
    }
    ### cleanup
    $this->output = rtrim(str_replace('&amp;', '&', str_replace('&lt;', '<', str_replace('&gt;', '>', $this->output))));
    # end parsing, flush stacked tags
    $this->flushStacked();
    $this->stack = array();
  }
665090
public function parse(){
		if($this->hasCircularReferences($this))
			throw new RuntimeException('Circular reference found in the query tree, cannot parse the query.');

		$this->connection->connect();

		$parser = $this->connection->getParser();
		$instance = new $parser($this);
		return $instance->parse();
	}
520429
private function topStatement() {
    switch ($this->currentType) {
      case T_USE:
        return $this->useBlock();
      case T_CONST:
        return $this->_const();
      case T_ABSTRACT:
      case T_FINAL:
      case T_CLASS:
        return $this->classDeclaration();
      case T_INTERFACE:
        return $this->interfaceDeclaration();
      case T_TRAIT:
        return $this->traitDeclaration();
      case T_HALT_COMPILER:
        $node = new HaltCompilerNode();
        $this->mustMatch(T_HALT_COMPILER, $node, 'name');
        $this->mustMatch('(', $node, 'openParen');
        $this->mustMatch(')', $node, 'closeParen');
        $this->endStatement($node);
        $this->tryMatch(T_INLINE_HTML, $node);
        return $node;
      default:
        if ($this->currentType === T_FUNCTION && $this->isLookAhead(T_STRING, '&')) {
          return $this->functionDeclaration();
        }
        elseif ($this->currentType === T_NAMESPACE && !$this->isLookAhead(T_NS_SEPARATOR)) {
          return $this->_namespace();
        }
        return $this->statement();
    }
  }
1158453
public function filterLanguage()
    {
        $this->lexer->moveNext();

        $node = $this->filterNode();

        // Check for end of string
        if ($this->lexer->lookahead !== null) {
            $this->syntaxError('end of string');
        }

        return $node;
    }
1143579
private function optionalTypeHint() {
    static $array_callable_types = [T_ARRAY, T_CALLABLE];
    $node = NULL;
    if ($node = $this->tryMatchToken($array_callable_types)) {
      return $node;
    }
    elseif (in_array($this->currentType, self::$namespacePathTypes)) {
      return $this->name();
    }
    return NULL;
  }