Parse if control structure.
@return IfNode
547131
private function _if() {
    $node = new IfNode();
    $this->mustMatch(T_IF, $node);
    $this->condition($node, 'condition');
    if ($this->tryMatch(':', $node, 'openColon', FALSE, TRUE)) {
      $node->addChild($this->innerIfInnerStatementList(), 'then');
      while ($this->currentType === T_ELSEIF) {
        $this->matchHidden($node);
        $elseIf = new ElseIfNode();
        $this->mustMatch(T_ELSEIF, $elseIf);
        $this->condition($elseIf, 'condition');
        $this->mustMatch(':', $elseIf, 'openColon', FALSE, TRUE);
        $elseIf->addChild($this->innerIfInnerStatementList(), 'then');
        $node->addChild($elseIf);
      }
      if ($this->tryMatch(T_ELSE, $node, 'elseKeyword')) {
        $this->mustMatch(':', $node, 'elseColon', FALSE, TRUE);
        $node->addChild($this->innerStatementListNode(T_ENDIF), 'else');
      }
      $this->mustMatch(T_ENDIF, $node, 'endKeyword');
      $this->endStatement($node);
      return $node;
    }
    else {
      $this->matchHidden($node);
      $node->addChild($this->statement(), 'then');
      while ($this->currentType === T_ELSEIF) {
        $this->matchHidden($node);
        $elseIf = new ElseIfNode();
        $this->mustMatch(T_ELSEIF, $elseIf);
        $this->condition($elseIf, 'condition');
        $this->matchHidden($elseIf);
        $elseIf->addChild($this->statement(), 'then');
        $node->addChild($elseIf);
      }
      if ($this->tryMatch(T_ELSE, $node, 'elseKeyword', FALSE, TRUE)) {
        $node->addChild($this->statement(), 'else');
      }
      return $node;
    }
  }
11274
protected function parseTitle() {
    if (is_object($this->file)) {
      if (isset($this->file->title)) {
        return $this->file->title;
      }
    }

    if (is_array($this->file)) {
      if (isset($this->file['title'])) {
        return $this->file['title'];
      }
    }

    return '';
  }
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;
	}
411779
protected 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 the previous tag was not a block element, we simulate a paragraph tag
                    if ($this->parser->isBlockElement && $this->parser->isNextToInlineContext && !in_array($this->parent(), $this->allowMixedChildren)) {
                        $this->setLineBreaks(2);
                    }
                    if ($this->parser->isStartTag) {
                        $this->flushLinebreaks();
                    }
                    if ($this->skipConversion) {
                        $this->isMarkdownable(); // update notConverted
                        $this->handleTagToText();
                        break;
                    }

                    // block elements
                    if (!$this->parser->keepWhitespace && $this->parser->isBlockElement) {
                        $this->fixBlockElementSpacing();
                    }

                    // inline elements
                    if (!$this->parser->keepWhitespace && $this->parser->isInlineContext) {
                        $this->fixInlineElementSpacing();
                    }

                    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->linkPosition == self::LINK_AFTER_PARAGRAPH && $this->parser->isBlockElement && !$this->parser->isStartTag && empty($this->parser->openTags)) {
                            $this->flushFootnotes();
                        }
                        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->flushFootnotes();
        $this->stack = [];
    }
127379
public function isStrictMode()
    {
        // declare statement for the strict_types can be only top-level node
        $topLevelNode = reset($this->topLevelNodes);
        if (!$topLevelNode instanceof Node\Stmt\Declare_) {
            return false;
        }

        $declareStatement = reset($topLevelNode->declares);
        $isStrictTypeKey  = $declareStatement->key->toString() === 'strict_types';
        $isScalarValue    = $declareStatement->value instanceof Node\Scalar\LNumber;
        $isStrictMode     = $isStrictTypeKey && $isScalarValue && $declareStatement->value->value === 1;

        return $isStrictMode;
    }
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;
    }
433681
protected function evaluateNodeContext()
    {
        $eelContext = new Context($this->nodeContext);
        return $this->eelCompilingEvaluator->evaluate($this->getParsedMatcher(), $eelContext);
    }
1320602
function nextNode() {
    if (empty($this->html)) {
      # we are done with parsing the html string
      return false;
    }
    static $skipWhitespace = true;
    if ($this->isStartTag && !$this->isEmptyTag) {
      array_push($this->openTags, $this->tagName);
      if (in_array($this->tagName, $this->preformattedTags)) {
        # dont truncate whitespaces for <code> or <pre> contents
        $this->keepWhitespace++;
      }
    }

    if ($this->html[0] == '<') {
      $token = substr($this->html, 0, 9);
      if (substr($token, 0, 2) == '<?') {
        # xml prolog or other pi's
        /** TODO **/
        #trigger_error('this might need some work', E_USER_NOTICE);
        $pos = strpos($this->html, '>');
        $this->setNode('pi', $pos + 1);
        return true;
      }
      if (substr($token, 0, 4) == '<!--') {
        # comment
        $pos = strpos($this->html, '-->');
        if ($pos === false) {
          # could not find a closing -->, use next gt instead
          # this is firefox' behaviour
          $pos = strpos($this->html, '>') + 1;
        } else {
          $pos += 3;
        }
        $this->setNode('comment', $pos);

        $skipWhitespace = true;
        return true;
      }
      if ($token == '<!DOCTYPE') {
        # doctype
        $this->setNode('doctype', strpos($this->html, '>')+1);

        $skipWhitespace = true;
        return true;
      }
      if ($token == '<![CDATA[') {
        # cdata, use text node

        # remove leading <![CDATA[
        $this->html = substr($this->html, 9);

        $this->setNode('text', strpos($this->html, ']]>')+3);

        # remove trailing ]]> and trim
        $this->node = substr($this->node, 0, -3);
        $this->handleWhitespaces();

        $skipWhitespace = true;
        return true;
      }
      if ($this->parseTag()) {
        # seems to be a tag
        # handle whitespaces
        if ($this->isBlockElement) {
          $skipWhitespace = true;
        } else {
          $skipWhitespace = false;
        }
        return true;
      }
    }
    if ($this->keepWhitespace) {
      $skipWhitespace = false;
    }
    # when we get here it seems to be a text node
    $pos = strpos($this->html, '<');
    if ($pos === false) {
      $pos = strlen($this->html);
    }
    $this->setNode('text', $pos);
    $this->handleWhitespaces();
    if ($skipWhitespace && $this->node == ' ') {
      return $this->nextNode();
    }
    $skipWhitespace = false;
    return true;
  }
934762
protected function isControlStructure()
	{
		return in_array(
			$this->tokens[$this->i][0],
			[T_ELSE, T_ELSEIF, T_FOR, T_FOREACH, T_IF, T_WHILE],
			true
		);
	}
403378
protected function _parse()
    {
        $origCss = '';
        $length = 0;
        foreach (@file($this->_absoluteCssPath) as $line) {
            $origCss .= $line;
            $length += strlen($line);
            $this->_lines[] = $length;
        }
        $css = $origCss;
        $peek = 0;
        $block = null;

        // Consume all CSS data (blockwise)
        while ($peek < $length) {

            // Consume whitespace
            if (preg_match("%^(\s+)%isSu", $css, $whitespace)) {
                $block .= $whitespace[0];
                $peek += strlen($whitespace[0]);

                // Consume Block comment
            } else {
                if (!strncmp('/*', $css, 2)) {
                    $commentEnd = strpos($css, '*/', 2);

                    // If no comment end is found: Error
                    if ($commentEnd === false) {
                        throw new \Tollwerk\Squeezr\Exception(sprintf(\Tollwerk\Squeezr\Exception::UNBALANCED_BLOCK_COMMENT_STR,
                            $this->_peekToLine($peek)), \Tollwerk\Squeezr\Exception::UNBALANCED_BLOCK_COMMENT);
                    }

                    $commentLength = $commentEnd + 2;
                    $block .= substr($css, 0, $commentLength);
                    $peek += $commentLength;

                    // Consume @-rule
                } elseif (!strncmp('@', $css, 1)) {

                    // Determine the rule identifier
                    if (!preg_match("%^\@([\w\-]+)%", $css, $atRule)) {
                        throw new \Tollwerk\Squeezr\Exception(sprintf(\Tollwerk\Squeezr\Exception::INVALID_AT_RULE_IDENTIFIER_STR,
                            $this->_peekToLine($peek)), \Tollwerk\Squeezr\Exception::INVALID_AT_RULE_IDENTIFIER);
                    }

                    // Consume @-rule by identifier
                    switch ($atRule[1]) {

                        // @media rule
                        case 'media':
                            $declarationBlockStart = 0;
                            $declarationBlock = $this->_consumeDeclarationBlock($css, $peek, strlen($atRule[1]) + 1,
                                $declarationBlockStart);
                            $peek += strlen($declarationBlock);
                            $breakpoints = $this->_breakpoints(substr($css, 6, $declarationBlockStart - 6));

                            // If the @media query is squeezable
                            if (is_array($breakpoints)) {

                                // If there's already block data to be registered
                                if (strlen($block)) {
                                    $this->_registerBlock($block);
                                }

                                $this->_registerBlock($declarationBlock, $breakpoints);

                                // Else: Not a squeezable @media query, register as regular block
                            } else {
                                $block .= $declarationBlock;
                            }

                            break;

                        // @import rule: May contain media query, should be implemented
                        case 'import':

                            // Find the next line break or semicolon
                            if (preg_match("%[\r\n\;]%", $css, $delimiter, PREG_OFFSET_CAPTURE, strlen($atRule[1]))) {
                                $declarationBlock = substr($css, 0, $delimiter[0][1] + 1);

                                // Else: this must be the end of the data
                            } else {
                                $declarationBlock = $css;
                            }

                            $peek += strlen($declarationBlock);

                            // Examine the import rule
                            $import = trim(substr($declarationBlock, 7), ' ;');
                            foreach (self::$_importPatterns as $start => $pattern) {
                                if (!strncmp($start, $import, strlen($start)) && preg_match($pattern, $import,
                                        $importMediaQuery)
                                ) {
                                    $breakpoints = $this->_breakpoints($importMediaQuery[4]);

                                    // If the @import rule has a squeezable media query part
                                    if (is_array($breakpoints)) {

                                        // If there's already block data to be registered
                                        if (strlen($block)) {
                                            $this->_registerBlock($block);
                                        }

                                        $this->_registerBlock($declarationBlock, $breakpoints);
                                        break 2;
                                    }
                                }
                            }

                            $block .= $declarationBlock;
                            break;

                        // Single line @-rules (except @import)
                        case 'charset';
                        case 'namespace':

                            // Find the next line break or semicolon
                            if (preg_match("%[\r\n\;]%", $css, $delimiter, PREG_OFFSET_CAPTURE, strlen($atRule[1]))) {
                                $block .=
                                $declarationBlock = substr($css, 0, $delimiter[0][1] + 1);
                                $peek += strlen($declarationBlock);

                                // Else: this must be the end of the data
                            } else {
                                $block .= $css;
                                $peek += strlen($css);
                            }

                            break;

                        // Block @-rules (e.g. *-keyframes)
                        case 'page':
                        case 'font-face':
                        default:
                            $block .=
                            $declarationBlock = $this->_consumeDeclarationBlock($css, $peek, strlen($atRule[1]) + 1);
                            $peek += strlen($declarationBlock);
                            break;
                    }

                    // Consume declaration blocks
                } else {
                    $block .=
                    $declarationBlock = $this->_consumeDeclarationBlock($css, $peek);
                    $peek += strlen($declarationBlock);
                }
            }

            $css = substr($origCss, $peek);
        }

        // Register the last block (if any)
        if (strlen($block)) {
            $this->_registerBlock($block);
        }
    }
363201
public function parseLabel()
    {
        $token = '';

        /**
         * Value to be returned.
         *
         * @var Token
         */
        $ret = null;

        /**
         * The value of `$this->last` where `$token` ends in `$this->str`.
         *
         * @var int
         */
        $iEnd = $this->last;
        for ($j = 1; $j < Context::LABEL_MAX_LENGTH && $this->last < $this->len; ++$j, ++$this->last) {
            if ($this->str[$this->last] === ':' && $j > 1) {
                // End of label
                $token .= $this->str[$this->last];
                $ret = new Token($token, Token::TYPE_LABEL);
                $iEnd = $this->last;
                break;
            } elseif (Context::isWhitespace($this->str[$this->last]) && $j > 1) {
                // Whitespace between label and :
                // The size of the keyword didn't increase.
                --$j;
            } elseif (Context::isSeparator($this->str[$this->last])) {
                // Any other separator
                break;
            }
            $token .= $this->str[$this->last];
        }

        $this->last = $iEnd;

        return $ret;
    }
660936
protected function parseAll()
    {
        if (!empty($this->parameter)) {
            return $this->parameter;
        }

        $this->parseParameter();
        $this->parseSource();
        $this->parseFilter();
    }
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;
	}
81557
protected function parseHtml()
    {
        $parser = new Parser($this->htmlStringOrFile);
        $document = $parser->setTableClass($this->tableClass)
            ->setRowClass($this->rowClass)
            ->setCellClass($this->cellClass)
            ->parse();

        $this->document = $document;

        return $document;
    }
982782
private If parseIf(Node node) {
        return new If(
                nodeAttribute(node, TAG_VAR_ATTR_NAME, Variable.DEFAULT_NAME),
                parseTemplateElements(node)
        );
    }
977807
public function parse() {
		/** @noinspection PhpParamsInspection */
		return $this -> execute(Util::cache(
			$this -> file,
			$this -> raw,
			'viper',
			function($data): NodeCollection {
				$tokens = $this -> tokenize($data);
				return $this -> formLogicalTree($tokens);
			}
		), $this -> data);
	}
1009845
public function getConfigNode()
    {
        $node = $this->getChordNode();
        $node
        ->prototype('array')
            ->children()
                ->booleanNode('inline')
                    ->defaultTrue()
                ->end()
                ->enumNode('brand')
                    ->values(array('image', 'text', 'none'))
                    ->defaultValue('text')
                ->end()
                ->arrayNode('parts')
                    ->prototype('array')
                    ->beforeNormalization()
                        ->ifTrue(function ($v) {
                            return 'links' === $v['type'] && isset($v['part']);
                        })
                        ->thenInvalid('Invalid "part" key when type is "links"')
                    ->end()
                    ->beforeNormalization()
                        ->ifTrue(function ($v) {
                            return 'embedded' === $v['type'] && isset($v['parts']);
                        })
                        ->thenInvalid('Invalid "parts" key when type is "embedded"')
                    ->end()
                        ->children()
                            ->enumNode('type')
                                ->values(array('links', 'embedded'))
                            ->end()
                            ->enumNode('position')
                                ->values(array('right', 'left'))
                                ->defaultValue('right')
                            ->end()
                            ->scalarNode('part')->end()
                            ->arrayNode('parts')
                                ->prototype('array')
                                    ->beforeNormalization()
                                        ->ifTrue(function ($v) {
                                            return 'link' === $v['type'] && isset($v['parts']);
                                        })
                                        ->thenInvalid('Invalid "parts" key when type is "link"')
                                    ->end()
                                    ->beforeNormalization()
                                        ->ifTrue(function ($v) {
                                            return 'dropdown' === $v['type'] && isset($v['part']);
                                        })
                                        ->thenInvalid('Invalid "part" key when type is "dropdown"')
                                    ->end()
                                    ->children()
                                        ->enumNode('type')
                                            ->values(array('link', 'dropdown'))
                                        ->end()
                                        ->scalarNode('part')->end()
                                        ->arrayNode('parts')
                                            ->prototype('array')
                                                ->children()
                                                    ->scalarNode('part')->end()
                                                ->end()
                                            ->end()
                                        ->end()
                                    ->end()
                                ->end()
                            ->end()
                        ->end()
                    ->end()
                ->end()
            ->end()
        ->end();

        return $node;
    }