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

Breadcrumb

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

function Parser::parseNumericLiteral

Parses a numeric literal

Return value

Node\NumericLiteral|Node\BigIntLiteral|null

2 calls to Parser::parseNumericLiteral()
Parser::parseLiteral in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a literal
Parser::parsePropertyName in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a property name. The returned value is an array where there first element is the property name and the second element is a boolean indicating if it's a computed property

File

vendor/mck89/peast/lib/Peast/Syntax/Parser.php, line 3854

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseNumericLiteral() {
    $token = $this->scanner
        ->getToken();
    if ($token && $token->type === Token::TYPE_NUMERIC_LITERAL) {
        $val = $token->value;
        $this->checkInvalidEscapeSequences($val, true);
        $this->scanner
            ->consumeToken();
        $node = $this->createNode("NumericLiteral", $token);
        $node->setRaw($val);
        return $this->completeNode($node);
    }
    elseif ($token && $token->type === Token::TYPE_BIGINT_LITERAL) {
        $val = $token->value;
        $this->checkInvalidEscapeSequences($val, true);
        $this->scanner
            ->consumeToken();
        $node = $this->createNode("BigIntLiteral", $token);
        $node->setRaw($val);
        return $this->completeNode($node);
    }
    return null;
}

API Navigation

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