private function lexDelimitedExpressionStatement(
        string $openTokenType,
        string $openDelimiter,
        string $closeTokenType,
        string $closeDelimiter,
        bool $closeDelimiterOptional
    ) {
        $this->flushExpressionBuffer();
        $this->tokens[] = new Token($openTokenType, $openDelimiter, $this->line);
        $this->lexDelimitedExpression($closeDelimiter);

        if (!$this->matches($closeDelimiter) && !$closeDelimiterOptional) {
            throw new RuntimeException(
                sprintf(
                    'Expected %s, found %s on line %d',
                    $closeDelimiter,
                    $this->getStream($this->cursor, strlen($closeDelimiter)),
                    $this->line
                )
            );
        }

        $this->tokens[] = new Token($closeTokenType, $closeDelimiter, $this->line);
    }
private function lexDelimitedExpressionStatement(
        string $openTokenType,
        string $openDelimiter,
        string $closeTokenType,
        string $closeDelimiter,
        bool $closeDelimiterOptional
    ) {
        $this->flushExpressionBuffer();
        $this->tokens[] = new Token($openTokenType, $openDelimiter, $this->line);
        $this->lexDelimitedExpression($closeDelimiter);

        if (!$this->matches($closeDelimiter) && !$closeDelimiterOptional) {
            throw new RuntimeException(
                sprintf(
                    'Expected %s, found %s on line %d',
                    $closeDelimiter,
                    $this->getStream($this->cursor, strlen($closeDelimiter)),
                    $this->line
                )
            );
        }

        $this->tokens[] = new Token($closeTokenType, $closeDelimiter, $this->line);
    }
private function lexDelimitedExpressionStatement ( string $ openTokenType , string $ openDelimiter , string $ closeTokenType , string $ closeDelimiter , bool $ closeDelimiterOptional ) { $ this -> flushExpressionBuffer ( ) ; $ this -> tokens [ ] = new Token ( $ openTokenType , $ openDelimiter , $ this -> line ) ; $ this -> lexDelimitedExpression ( $ closeDelimiter ) ; if ( ! $ this -> matches ( $ closeDelimiter ) && ! $ closeDelimiterOptional ) { throw new RuntimeException ( sprintf ( 'Expected %s, found %s on line %d' , $ closeDelimiter , $ this -> getStream ( $ this -> cursor , strlen ( $ closeDelimiter ) ) , $ this -> line ) ) ; } $ this -> tokens [ ] = new Token ( $ closeTokenType , $ closeDelimiter , $ this -> line ) ; }
Lexes a statement that is comprised of a delimited statement

@param string $openTokenType The open token type
@param string $openDelimiter The open delimiter
@param string $closeTokenType The close token type
@param string $closeDelimiter The close delimiter
@param bool $closeDelimiterOptional Whether or not the close delimiter is optional
@throws RuntimeException Thrown if the expression was not delimited correctly
Lexes a statement that is comprised of a delimited statement