You are here

protected function Twig_Lexer::lexString in Translation template extractor 6.3

Same name and namespace in other branches
  1. 7.3 vendor/Twig/Lexer.php \Twig_Lexer::lexString()
  2. 7.2 vendor/Twig/Lexer.php \Twig_Lexer::lexString()
1 call to Twig_Lexer::lexString()
Twig_Lexer::tokenize in vendor/Twig/Lexer.php
Tokenizes a source code.

File

vendor/Twig/Lexer.php, line 313

Class

Twig_Lexer
Lexes a template string.

Code

protected function lexString() {
  if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
    $this->brackets[] = array(
      $this->options['interpolation'][0],
      $this->lineno,
    );
    $this
      ->pushToken(Twig_Token::INTERPOLATION_START_TYPE);
    $this
      ->moveCursor($match[0]);
    $this
      ->pushState(self::STATE_INTERPOLATION);
  }
  elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
    $this
      ->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
    $this
      ->moveCursor($match[0]);
  }
  elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
    list($expect, $lineno) = array_pop($this->brackets);
    if ($this->code[$this->cursor] != '"') {
      throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
    }
    $this
      ->popState();
    ++$this->cursor;
  }
}