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

Breadcrumb

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

function Parser::parseLiteral

Same name in this branch
  1. 11.1.x vendor/mck89/peast/lib/Peast/Selector/Parser.php \Peast\Selector\Parser::parseLiteral()

Parses a literal

Return value

Node\Literal|null

1 call to Parser::parseLiteral()
Parser::parsePrimaryExpression in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a primary expression

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseLiteral() {
    if ($token = $this->scanner
        ->getToken()) {
        if ($token->type === Token::TYPE_NULL_LITERAL) {
            $this->scanner
                ->consumeToken();
            $node = $this->createNode("NullLiteral", $token);
            return $this->completeNode($node);
        }
        elseif ($token->type === Token::TYPE_BOOLEAN_LITERAL) {
            $this->scanner
                ->consumeToken();
            $node = $this->createNode("BooleanLiteral", $token);
            $node->setRaw($token->value);
            return $this->completeNode($node);
        }
        elseif ($literal = $this->parseStringLiteral()) {
            return $literal;
        }
        elseif ($literal = $this->parseNumericLiteral()) {
            return $literal;
        }
    }
    return null;
}

API Navigation

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