src/Language/Lexer.php
private function readBlockString($line, $col, Token $prev)
    {
        $start = $this->position;

        // Skip leading quotes and read first string char:
        [$char, $code, $bytes] = $this->moveStringCursor(3, 3)->readChar();

        $chunk = '';
        $value = '';

        while ($code !== null) {
            // Closing Triple-Quote (""")
            if ($code === 34) {
                // Move 2 quotes
                [, $nextCode]     = $this->moveStringCursor(1, 1)->readChar();
                [, $nextNextCode] = $this->moveStringCursor(1, 1)->readChar();

                if ($nextCode === 34 && $nextNextCode === 34) {
                    $value .= $chunk;

                    $this->moveStringCursor(1, 1);

                    return new Token(
                        Token::BLOCK_STRING,
                        $start,
                        $this->position,
                        $line,
                        $col,
                        $prev,
                        BlockString::value($value)
                    );
                }

                // move cursor back to before the first quote
                $this->moveStringCursor(-2, -2);
            }

            $this->assertValidBlockStringCharacterCode($code, $this->position);
            $this->moveStringCursor(1, $bytes);

            [, $nextCode]         = $this->readChar();
            [, $nextNextCode]     = $this->moveStringCursor(1, 1)->readChar();
            [, $nextNextNextCode] = $this->moveStringCursor(1, 1)->readChar();

            // Escape Triple-Quote (\""")
            if ($code === 92 &&
                $nextCode === 34 &&
                $nextNextCode === 34 &&
                $nextNextNextCode === 34
            ) {
                $this->moveStringCursor(1, 1);
                $value .= $chunk . '"""';
                $chunk  = '';
            } else {
                $this->moveStringCursor(-2, -2);
                $chunk .= $char;
            }

            [$char, $code, $bytes] = $this->readChar();
        }

        throw new SyntaxError(
            $this->source,
            $this->position,
            'Unterminated string.'
        );
    }
private function readBlockString($line, $col, Token $prev)
    {
        $start = $this->position;

        // Skip leading quotes and read first string char:
        [$char, $code, $bytes] = $this->moveStringCursor(3, 3)->readChar();

        $chunk = '';
        $value = '';

        while ($code !== null) {
            // Closing Triple-Quote (""")
            if ($code === 34) {
                // Move 2 quotes
                [, $nextCode]     = $this->moveStringCursor(1, 1)->readChar();
                [, $nextNextCode] = $this->moveStringCursor(1, 1)->readChar();

                if ($nextCode === 34 && $nextNextCode === 34) {
                    $value .= $chunk;

                    $this->moveStringCursor(1, 1);

                    return new Token(
                        Token::BLOCK_STRING,
                        $start,
                        $this->position,
                        $line,
                        $col,
                        $prev,
                        BlockString::value($value)
                    );
                }

                // move cursor back to before the first quote
                $this->moveStringCursor(-2, -2);
            }

            $this->assertValidBlockStringCharacterCode($code, $this->position);
            $this->moveStringCursor(1, $bytes);

            [, $nextCode]         = $this->readChar();
            [, $nextNextCode]     = $this->moveStringCursor(1, 1)->readChar();
            [, $nextNextNextCode] = $this->moveStringCursor(1, 1)->readChar();

            // Escape Triple-Quote (\""")
            if ($code === 92 &&
                $nextCode === 34 &&
                $nextNextCode === 34 &&
                $nextNextNextCode === 34
            ) {
                $this->moveStringCursor(1, 1);
                $value .= $chunk . '"""';
                $chunk  = '';
            } else {
                $this->moveStringCursor(-2, -2);
                $chunk .= $char;
            }

            [$char, $code, $bytes] = $this->readChar();
        }

        throw new SyntaxError(
            $this->source,
            $this->position,
            'Unterminated string.'
        );
    }
private function readBlockString ( $ line , $ col , Token $ prev ) { $ start = $ this -> position ; // Skip leading quotes and read first string char: [ $ char , $ code , $ bytes ] = $ this -> moveStringCursor ( 3 , 3 ) -> readChar ( ) ; $ chunk = '' ; $ value = '' ; while ( $ code !== null ) { // Closing Triple-Quote (""") if ( $ code === 34 ) { // Move 2 quotes [ , $ nextCode ] = $ this -> moveStringCursor ( 1 , 1 ) -> readChar ( ) ; [ , $ nextNextCode ] = $ this -> moveStringCursor ( 1 , 1 ) -> readChar ( ) ; if ( $ nextCode === 34 && $ nextNextCode === 34 ) { $ value .= $ chunk ; $ this -> moveStringCursor ( 1 , 1 ) ; return new Token ( Token :: BLOCK_STRING , $ start , $ this -> position , $ line , $ col , $ prev , BlockString :: value ( $ value ) ) ; } // move cursor back to before the first quote $ this -> moveStringCursor ( - 2 , - 2 ) ; } $ this -> assertValidBlockStringCharacterCode ( $ code , $ this -> position ) ; $ this -> moveStringCursor ( 1 , $ bytes ) ; [ , $ nextCode ] = $ this -> readChar ( ) ; [ , $ nextNextCode ] = $ this -> moveStringCursor ( 1 , 1 ) -> readChar ( ) ; [ , $ nextNextNextCode ] = $ this -> moveStringCursor ( 1 , 1 ) -> readChar ( ) ; // Escape Triple-Quote (\""") if ( $ code === 92 && $ nextCode === 34 && $ nextNextCode === 34 && $ nextNextNextCode === 34 ) { $ this -> moveStringCursor ( 1 , 1 ) ; $ value .= $ chunk . '"""' ; $ chunk = '' ; } else { $ this -> moveStringCursor ( - 2 , - 2 ) ; $ chunk .= $ char ; } [ $ char , $ code , $ bytes ] = $ this -> readChar ( ) ; } throw new SyntaxError ( $ this -> source , $ this -> position , 'Unterminated string.' ) ; }
Reads a block string token from the source file.

"""("?"?(\\"""|\\(?!=""")|[^"\\]))*"""
Reads a block string token from the source file .