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

Breadcrumb

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

function Scanner::consumeNumbers

Consumes the maximum number of digits

Parameters

string $type Digits type (decimal, hexadecimal, etc...):

int $max Maximum number of digits to match:

Return value

string|null

3 calls to Scanner::consumeNumbers()
Scanner::consumeExponentPart in vendor/mck89/peast/lib/Peast/Syntax/Scanner.php
Consumes the exponent part of a number
Scanner::consumeUnicodeEscapeSequence in vendor/mck89/peast/lib/Peast/Syntax/Scanner.php
Consumes an unicode escape sequence
Scanner::scanNumber in vendor/mck89/peast/lib/Peast/Syntax/Scanner.php
Number scanning method

File

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

Class

Scanner
Base class for scanners.

Namespace

Peast\Syntax

Code

protected function consumeNumbers($type = "", $max = null) {
    $buffer = "";
    $char = $this->charAt();
    $count = 0;
    $extra = $this->features->numericLiteralSeparator ? "_" : "";
    while (in_array($char, $this->{$type . "numbers"}) || $count && $char === $extra) {
        $buffer .= $char;
        $this->index++;
        $this->column++;
        $count++;
        if ($count === $max) {
            break;
        }
        $char = $this->charAt();
    }
    if ($count && substr($buffer, -1) === "_") {
        $this->error("Numeric separators are not allowed at the end of a number");
    }
    return $count ? $buffer : null;
}

API Navigation

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