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

Breadcrumb

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

function Parser::parseLiteralNumber

Parses a literal number

Return value

int|float|null

1 call to Parser::parseLiteralNumber()
Parser::parseLiteral in vendor/mck89/peast/lib/Peast/Selector/Parser.php
Parses a literal value

File

vendor/mck89/peast/lib/Peast/Selector/Parser.php, line 409

Class

Parser
Selector parser class

Namespace

Peast\Selector

Code

protected function parseLiteralNumber() {
    if ($this->getChar() === "0" && ($val = $this->consumeRegex("0[xX][a-fA-F]+|0[bB][01]+|0[oO][0-7]+"))) {
        $form = strtolower($val[1]);
        $val = substr($val, 2);
        if ($form === "x") {
            return hexdec($val);
        }
        elseif ($form === "o") {
            return octdec($val);
        }
        return bindec($val);
    }
    $reg = "-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?|-?\\.\\d+(?:[eE][+-]?\\d+)?";
    if (!($val = $this->consumeRegex($reg))) {
        return null;
    }
    return (double) $val;
}

API Navigation

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