private function parseTokens(TokenStream $tokens, AstNode $ast): void
    {
        $parsingPath = $ast->type === AstNodeTypes::PATH;
        $currNode = $ast;

        while (($token = $tokens->getCurrent()) !== null) {
            switch ($token->type) {
                case TokenTypes::T_TEXT:
                    $this->parseText($tokens, $currNode);
                    break;
                case TokenTypes::T_NUMBER:
                    // Since we handle a number inside of variables elsewhere, we'll just treat this as text
                    $this->parseText($tokens, $currNode);
                    break;
                case TokenTypes::T_VARIABLE:
                    $this->parseVariable($tokens, $currNode);
                    break;
                case TokenTypes::T_PUNCTUATION:
                    $this->parsePunctuation($tokens, $currNode, $parsingPath);
                    break;
                case TokenTypes::T_QUOTED_STRING:
                    // Since we handle a quoted string inside of variables elsewhere, we'll just treat this as text
                    $this->parseText($tokens, $currNode);
                    break;
            }
        }
    }
private function parseTokens(TokenStream $tokens, AstNode $ast): void
    {
        $parsingPath = $ast->type === AstNodeTypes::PATH;
        $currNode = $ast;

        while (($token = $tokens->getCurrent()) !== null) {
            switch ($token->type) {
                case TokenTypes::T_TEXT:
                    $this->parseText($tokens, $currNode);
                    break;
                case TokenTypes::T_NUMBER:
                    // Since we handle a number inside of variables elsewhere, we'll just treat this as text
                    $this->parseText($tokens, $currNode);
                    break;
                case TokenTypes::T_VARIABLE:
                    $this->parseVariable($tokens, $currNode);
                    break;
                case TokenTypes::T_PUNCTUATION:
                    $this->parsePunctuation($tokens, $currNode, $parsingPath);
                    break;
                case TokenTypes::T_QUOTED_STRING:
                    // Since we handle a quoted string inside of variables elsewhere, we'll just treat this as text
                    $this->parseText($tokens, $currNode);
                    break;
            }
        }
    }
private function parseTokens ( TokenStream $ tokens , AstNode $ ast ) : void { $ parsingPath = $ ast -> type === AstNodeTypes :: PATH ; $ currNode = $ ast ; while ( ( $ token = $ tokens -> getCurrent ( ) ) !== null ) { switch ( $ token -> type ) { case TokenTypes :: T_TEXT : $ this -> parseText ( $ tokens , $ currNode ) ; break ; case TokenTypes :: T_NUMBER : // Since we handle a number inside of variables elsewhere, we'll just treat this as text $ this -> parseText ( $ tokens , $ currNode ) ; break ; case TokenTypes :: T_VARIABLE : $ this -> parseVariable ( $ tokens , $ currNode ) ; break ; case TokenTypes :: T_PUNCTUATION : $ this -> parsePunctuation ( $ tokens , $ currNode , $ parsingPath ) ; break ; case TokenTypes :: T_QUOTED_STRING : // Since we handle a quoted string inside of variables elsewhere, we'll just treat this as text $ this -> parseText ( $ tokens , $ currNode ) ; break ; } } }
Parses a stream of tokens and adds it to an abstract syntax tree

@param TokenStream $tokens The tokens to parse
@param AstNode $ast The abstract syntax tree to add to
Parses a stream of tokens and adds it to an abstract syntax tree