Parses a token and returns a node.

@param Twig_Token $token A Twig_Token instance

@return AnnotationsNode A Twig_NodeInterface instance
969693
public function parse(Twig_Token $token)
    {
        $stream = $this->parser->getStream();

        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        $body = $this->parser->subparse(array($this, 'decideEndAnnotations'));
        $stream->expect('endannotations');
        $stream->expect(Twig_Token::BLOCK_END_TYPE);

        return new AnnotationsNode(array('body' => $body));
    }
903214
protected function parseStartOption(\Twig_Token $token, \Twig_TokenStream $stream)
    {
        $this->testToken('start', $token, $stream);

        return $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::NUMBER_TYPE);
    }
378523
public function parse(Twig_Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();
        $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        $body = $this->parser->subparse([$this, 'decidePutEnd'], true);

        $endType = null;
        if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
            $endType = $token->getValue();
        }

        $stream->expect(Twig_Token::BLOCK_END_TYPE);

        return new PutNode($body, $name, $endType, $lineno, $this->getTag());
    }
1169169
public function parse(Twig_Token $token)
    {
        $stream = $this->parser->getStream();
        $id = $page_id = null;

        if($stream->getCurrent()->getType() != Twig_Token::BLOCK_END_TYPE){
            $id = $this->parser->getExpressionParser()->parseExpression();
        }

        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        return new PageVariableTwigNodeImpl($token->getLine(), $this->getTag(), $id);
    }
980511
public function getByActionToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('action_token', '=', $token)->first());
	}
835396
public function parse(array $tokens)
    {
        $symbolNodes = $this->detectSymbols($tokens);

        $nodes = $this->createTreeByBrackets($symbolNodes);

        $nodes = $this->transformTreeByFunctions($nodes);

        $this->checkGrammar($nodes);

        // Wrap the nodes in an array node.
        $rootNode = new ContainerNode($nodes);

        return $rootNode;
    }
1091714
public function parse(Token $token): CellNode
    {
        $stream = $this->parser->getStream();

        $variable = null;
        if ($stream->test(Token::NAME_TYPE)) {
            $variable = $stream->expect(Token::NAME_TYPE)->getValue();
        }
        $assign = false;
        if ($stream->test(Token::OPERATOR_TYPE)) {
            $stream->expect(Token::OPERATOR_TYPE, '=');
            $assign = true;
        }

        $name = $this->parser->getExpressionParser()->parseExpression();
        $data = null;
        if (!$stream->test(Token::BLOCK_END_TYPE)) {
            $data = $this->parser->getExpressionParser()->parseExpression();
        }
        $options = null;
        if (!$stream->test(Token::BLOCK_END_TYPE)) {
            $options = $this->parser->getExpressionParser()->parseExpression();
        }

        $stream->expect(Token::BLOCK_END_TYPE);

        return new CellNode($assign, $variable, $name, $data, $options, $token->getLine(), $this->getTag());
    }
625955
public function parse(Twig_Token $token)
    {
        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);

        return new Twig_Node_Flush($token->getLine(), $this->getTag());
    }
1235677
public function parse(\Twig_Token $token) {

        $lineno = $token->getLine();

        $nodes['criteria'] = $this->parser->getExpressionParser()->parseExpression();
        $this->parser->getStream()->expect('as');
        $targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);

        $nodes['body'] = $this->parser->subparse(array($this, 'endOfTag'), true);
        $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);

        $elementsTarget = $targets->getNode(0);
        $nodes['elementsTarget'] = new \Twig_Node_Expression_AssignName($elementsTarget->getAttribute('name'), $elementsTarget->getLine());

        return new PageNode($nodes, array(), $lineno, $this->getTag());

    }
828314
public function parse(Twig_Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();

        $name = null;
        if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
            $name = $token->getValue();
        }

        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        return new FrameworkNode($name, $lineno, $this->getTag());
    }
347269
public function getByToken($token)
    {
        if (null === $this->profiler) {
            throw new \RuntimeException('Invalid profiler instance.');
        }

        $profile = $this->profiler->loadProfile($token);

        // In case no results were found
        if (!$profile instanceof Profile) {
            return array(array(), 0);
        }

        try {
            /** @var TranslationDataCollector $collector */
            $collector = $profile->getCollector('translation');
            $messages = $collector->getMessages();

            $transUnits = array();
            foreach ($messages as $message) {
                $transUnit = $this->storage->getTransUnitByKeyAndDomain($message['id'], $message['domain']);

                if ($transUnit instanceof TransUnit) {
                    $transUnits[] = $transUnit;
                } elseif (true === $this->createMissing) {
                    $transUnits[] = $transUnit = $this->transUnitManager->create($message['id'], $message['domain'], true);
                }

                // Also store the translation if profiler state was defined
                if (!$transUnit->hasTranslation($message['locale']) && $message['state'] === DataCollectorTranslator::MESSAGE_DEFINED) {
                    $file = $this->fileManager->getFor(sprintf('%s.%s.%s', $message['domain'], $message['locale'], $this->defaultFileFormat));

                    $this->transUnitManager->addTranslation($transUnit, $message['locale'], $message['translation'], $file, true);
                }
            }

            return array($transUnits, count($transUnits));

        } catch (\InvalidArgumentException $e) {

            // Translation collector is a 2.7 feature
            return array(array(), 0);
        }
    }
435971
private function parsePHPToken($token)
    {
        list($type, $expr) = $token;

        if ($type == T_INLINE_HTML) {
            $expr = $this->compileStatements($expr);
            $expr = $this->compileComments($expr);
            $expr = $this->compileRawEchos($expr);
            $expr = $this->compileRegularEchos($expr);
        }

        return $expr;
    }
1345097
public function parse(Twig_Token $token)
    {
        $options = array();
        $stream = $this->parser->getStream();
        $start = $stream->getCurrent();
        $arguments = array();
        do {
            $value = $this->parser->getExpressionParser()->parseExpression();
            if ($stream->test('as')) {
                $stream->expect('as');
                $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
            } else {
                $name = null;
            }
            $arguments[] = array('name' => $name, 'value' => $value);

            $end = !$stream->test(Twig_Token::PUNCTUATION_TYPE, ',');
            if (!$end) {
                $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',');
            }
        } while (!$end);

        while ($stream->test($this->options)) {
            $options[] = $stream->expect($this->options)->getValue();
        }

        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        $body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        return new WithNode($arguments, $body, $options, $start->getLine(), $start->getValue());
    }
187722
public function parse(Token $token): ElementNode
    {
        $stream = $this->parser->getStream();
        $name = $this->parser->getExpressionParser()->parseExpression();

        $data = null;
        if (!$stream->test(Token::BLOCK_END_TYPE)) {
            $data = $this->parser->getExpressionParser()->parseExpression();
        }

        $options = null;
        if (!$stream->test(Token::BLOCK_END_TYPE)) {
            $options = $this->parser->getExpressionParser()->parseExpression();
        }

        $stream->expect(Token::BLOCK_END_TYPE);

        return new ElementNode($name, $data, $options, $token->getLine(), $this->getTag());
    }
162883
public function parse(Twig_Token $token)
    {
        $stream = $this->parser->getStream();

        $info = array();
        $first = $this->parser->getExpressionParser()->parseExpression();

        if ($stream->test(Twig_Token::BLOCK_END_TYPE)) {
            $info['expr']= $first;
        } else {
            $info['name']= $first;
            $info['expr']= $this->parser->getExpressionParser()->parseExpression();
            if (!$stream->test(Twig_Token::BLOCK_END_TYPE)) {
                $info['prio']= $this->parser->getExpressionParser()->parseExpression();
            }
        }

        $node = new AnnotateNode($info);
        $stream->expect(\Twig_Token::BLOCK_END_TYPE);

        return $node;
    }
1155457
public function parse(Twig_Token $token)
    {
        $parser = $this->parser;
        $stream = $parser->getStream();
        $subunitExpression = $parser->getExpressionParser()->parseExpression();
        $stream->expect(Twig_Token::BLOCK_END_TYPE);

        return new RenderNode($subunitExpression, $token->getLine(), $this->getTag());
    }
894687
public function parse(Token $token): ParameterValue
    {
        $value = $token->getValue();
        try {
            $paramKey = substr($value, 2, strlen($value) - 4);

            return new ParameterValue($paramKey);
        } catch (\TypeError $error) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token, 0, $error);
        }
    }