Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Lexer.php

function Lexer::lexString

1 call to Lexer::lexString()
Lexer::tokenize in vendor/twig/twig/src/Lexer.php

File

vendor/twig/twig/src/Lexer.php, line 488

Class

Lexer
@author Fabien Potencier <fabien@symfony.com>

Namespace

Twig

Code

private function lexString() : void {
    if (preg_match($this->regexes['interpolation_start'], $this->code, $match, 0, $this->cursor)) {
        $this->brackets[] = [
            $this->options['interpolation'][0],
            $this->lineno,
        ];
        $this->pushToken(Token::INTERPOLATION_START_TYPE);
        $this->moveCursor($match[0]);
        $this->pushState(self::STATE_INTERPOLATION);
    }
    elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, 0, $this->cursor) && '' !== $match[0]) {
        $this->pushToken(Token::STRING_TYPE, $this->stripcslashes($match[0], '"'));
        $this->moveCursor($match[0]);
    }
    elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, 0, $this->cursor)) {
        [
            $expect,
            $lineno,
        ] = array_pop($this->brackets);
        if ('"' != $this->code[$this->cursor]) {
            throw new SyntaxError(\sprintf('Unclosed "%s".', $expect), $lineno, $this->source);
        }
        $this->popState();
        ++$this->cursor;
    }
    else {
        // unlexable
        throw new SyntaxError(\sprintf('Unexpected character "%s".', $this->code[$this->cursor]), $this->lineno, $this->source);
    }
}
RSS feed
Powered by Drupal