public function parse(\Twig_Token $token) { $lineno = $token->getLine(); $extras = ''; $type = $this->parser->getStream()->expect(\Twig_Token::NAME_TYPE)->getValue(); if (!in_array($type, array(self::TYPE_JS, self::TYPE_CSS))) { throw new \Twig_SyntaxError("Register type must be 'css' or 'js'.", $lineno, $token->getFilename()); } $file = $this->parser->getStream()->expect(\Twig_Token::STRING_TYPE)->getValue(); if ($type == self::TYPE_CSS) { if ($this->parser->getStream()->test(\Twig_Token::STRING_TYPE)) { $extras = $this->parser->getStream()->expect(\Twig_Token::STRING_TYPE)->getValue(); } else { $extras = 'all'; } } if ($this->parser->getStream()->test(\Twig_Token::NUMBER_TYPE)) { $priority = $this->parser->getStream()->expect(\Twig_Token::NUMBER_TYPE)->getValue(); } else { $priority = 0; } $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE); return new RegisterNode($type, $file, $extras, $priority, $lineno, $this->getTag()); }