private function lexDirectiveName()
    {
        $name = '';
        $newLinesAfterName = 0;

        // Loop while there's still a directive name or until we encounter the first space after the name
        do {
            $currentChar = $this->getCurrentChar();

            // Handle new line characters between directive delimiters
            if ($currentChar === "\n") {
                if (trim($name) === '') {
                    $this->line++;
                } else {
                    $newLinesAfterName++;
                }
            }

            $name .= $currentChar;
            $this->cursor++;
        } while (
            preg_match("/^[a-zA-Z0-9_\s]$/", $this->getCurrentChar()) === 1 &&
            ($this->getCurrentChar() !== ' ' || trim($name) === '')
        );

        $name = trim($name);

        if ($name === '') {
            throw new RuntimeException(
                sprintf(
                    'Expected %s on line %d, none found',
                    TokenTypes::T_DIRECTIVE_NAME,
                    $this->line
                )
            );
        }

        $this->tokens[] = new Token(TokenTypes::T_DIRECTIVE_NAME, $name, $this->line);
        $this->line += $newLinesAfterName;
    }
private function lexDirectiveName()
    {
        $name = '';
        $newLinesAfterName = 0;

        // Loop while there's still a directive name or until we encounter the first space after the name
        do {
            $currentChar = $this->getCurrentChar();

            // Handle new line characters between directive delimiters
            if ($currentChar === "\n") {
                if (trim($name) === '') {
                    $this->line++;
                } else {
                    $newLinesAfterName++;
                }
            }

            $name .= $currentChar;
            $this->cursor++;
        } while (
            preg_match("/^[a-zA-Z0-9_\s]$/", $this->getCurrentChar()) === 1 &&
            ($this->getCurrentChar() !== ' ' || trim($name) === '')
        );

        $name = trim($name);

        if ($name === '') {
            throw new RuntimeException(
                sprintf(
                    'Expected %s on line %d, none found',
                    TokenTypes::T_DIRECTIVE_NAME,
                    $this->line
                )
            );
        }

        $this->tokens[] = new Token(TokenTypes::T_DIRECTIVE_NAME, $name, $this->line);
        $this->line += $newLinesAfterName;
    }
private function lexDirectiveName ( ) { $ name = '' ; $ newLinesAfterName = 0 ; // Loop while there's still a directive name or until we encounter the first space after the name do { $ currentChar = $ this -> getCurrentChar ( ) ; // Handle new line characters between directive delimiters if ( $ currentChar === "\n" ) { if ( trim ( $ name ) === '' ) { $ this -> line ++ ; } else { $ newLinesAfterName ++ ; } } $ name .= $ currentChar ; $ this -> cursor ++ ; } while ( preg_match ( "/^[a-zA-Z0-9_\s]$/" , $ this -> getCurrentChar ( ) ) === 1 && ( $ this -> getCurrentChar ( ) !== ' ' || trim ( $ name ) === '' ) ) ; $ name = trim ( $ name ) ; if ( $ name === '' ) { throw new RuntimeException ( sprintf ( 'Expected %s on line %d, none found' , TokenTypes :: T_DIRECTIVE_NAME , $ this -> line ) ) ; } $ this -> tokens [ ] = new Token ( TokenTypes :: T_DIRECTIVE_NAME , $ name , $ this -> line ) ; $ this -> line += $ newLinesAfterName ; }
Lexes a directive name

@throws RuntimeException Thrown if the directive did not have a name
Lexes a directive name