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

Breadcrumb

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

function ExpressionParser::getPrimary

3 calls to ExpressionParser::getPrimary()
ExpressionParser::parseArguments in vendor/twig/twig/src/ExpressionParser.php
Parses arguments.
ExpressionParser::parseExpression in vendor/twig/twig/src/ExpressionParser.php
ExpressionParser::parseTestExpression in vendor/twig/twig/src/ExpressionParser.php

File

vendor/twig/twig/src/ExpressionParser.php, line 235

Class

ExpressionParser
Parses expressions.

Namespace

Twig

Code

private function getPrimary() : AbstractExpression {
    $token = $this->parser
        ->getCurrentToken();
    if ($this->isUnary($token)) {
        $operator = $this->unaryOperators[$token->getValue()];
        $this->parser
            ->getStream()
            ->next();
        $expr = $this->parseExpression($operator['precedence']);
        $class = $operator['class'];
        $expr = new $class($expr, $token->getLine());
        $expr->setAttribute('operator', 'unary_' . $token->getValue());
        if ($this->deprecationCheck) {
            $this->triggerPrecedenceDeprecations($expr);
        }
        return $this->parsePostfixExpression($expr);
    }
    elseif ($token->test(Token::PUNCTUATION_TYPE, '(')) {
        $this->parser
            ->getStream()
            ->next();
        $previous = $this->setDeprecationCheck(false);
        try {
            $expr = $this->parseExpression()
                ->setExplicitParentheses();
        } finally {
            $this->setDeprecationCheck($previous);
        }
        $this->parser
            ->getStream()
            ->expect(Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
        return $this->parsePostfixExpression($expr);
    }
    return $this->parsePrimaryExpression();
}

API Navigation

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