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

Breadcrumb

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

function Scanner::scanString

String scanning method

Parameters

bool $handleEscape True to handle escaping:

Return value

Token|null

1 call to Scanner::scanString()
Scanner::getToken in vendor/mck89/peast/lib/Peast/Syntax/Scanner.php
Returns the current token

File

vendor/mck89/peast/lib/Peast/Syntax/Scanner.php, line 1345

Class

Scanner
Base class for scanners.

Namespace

Peast\Syntax

Code

protected function scanString($handleEscape = true) {
    $char = $this->charAt();
    if ($char === "'" || $char === '"') {
        $this->index++;
        $this->column++;
        
        //Add the quote to the LSM and then remove it after consuming
        $this->stringsStopsLSM
            ->add($char);
        $buffer = $this->consumeUntil($this->stringsStopsLSM, $handleEscape);
        $this->stringsStopsLSM
            ->remove($char);
        if ($buffer === null || $buffer[1] !== $char) {
            $this->error("Unterminated string");
        }
        return new Token(Token::TYPE_STRING_LITERAL, $char . $buffer[0]);
    }
    return null;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal