Returns the mark option value from the mark token

@param \Twig_Token $token The token to parse
@param \Twig_TokenStream $stream The token stream being traversed
@return string
325958
protected function parseMarkOption(\Twig_Token $token, \Twig_TokenStream $stream)
    {
        $this->testToken('mark', $token, $stream);

        $markValue = $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::NUMBER_TYPE);

        while ($stream->test(\Twig_Token::OPERATOR_TYPE)
            || $stream->test(\Twig_Token::PUNCTUATION_TYPE)
            || $stream->test(\Twig_Token::NUMBER_TYPE)
        ) {
            $markValue .= $stream->getCurrent()->getValue();
            $stream->next();
        }

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

        $crud = $this->parser->getExpressionParser()->parseExpression();
        $resources = array();
        do {
            $resources[] = $this->parser->getExpressionParser()->parseExpression();
        } while (!$stream->test(\Twig_Token::BLOCK_END_TYPE));

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

        return new CrudThemeNode($crud, new \Twig_Node($resources), $lineno, $this->getTag());
    }
343872
public function parse(\Twig_Token $token)
    {
        list($type, $options, $variables, $skip, $loop) = $this->parseArguments();

        $stream = $this->parser->getStream();
        $lineno = $stream->getCurrent()->getLine();

        $superblock = new Superblock($type, $options, $loop, $lineno, $this->getTag());
        $name = $superblock->getAttribute('name');
        $reference = new SuperblockReference($name, $variables, $loop, $lineno, $this->getTag());
        $reference->setAttribute('parent_name', $name);

        $this->parser->setBlock($name, $superblock);
        $this->parser->pushLocalScope();
        $this->parser->pushBlockStack($name);

        if ($skip) {
            $this->parser->popBlockStack();
            $this->parser->popLocalScope();

            return $reference;
        }

        // body content
        $sBlocks = new \Twig_Node([], [], $lineno);
        $body = $this->parser->subparse([$this, 'decideBlockEnd'], true);
        $previousTwigNode = null;

        if (0 === \count($body) || null !== $body->getNodeTag()) {
            $body = new \Twig_Node([$body], [], $lineno);
        }

        if (null === $body->getNodeTag()) {
            /* @var \Twig_Node $node */
            foreach ($body->getIterator() as $node) {
                if (!$node instanceof \Twig_Node) {
                    continue;
                }

                if ($node instanceof SuperblockReference) {
                    $this->pushClosureNode($sBlocks, $variables, $name, $previousTwigNode);
                    $previousTwigNode = null;

                    $node->setAttribute('is_root', false);
                    $node->setAttribute('parent_name', $name);
                    $sBlocks->setNode(\count($sBlocks), $node);
                } elseif ($node instanceof \Twig_Node_Set) {
                    $this->pushClosureNode($sBlocks, $variables, $name, $previousTwigNode);
                    $previousTwigNode = null;

                    $sBlocks->setNode(\count($sBlocks), $node);
                } elseif (!$node instanceof \Twig_Node_Text || ($node instanceof \Twig_Node_Text && '' !== trim($node->getAttribute('data')))) {
                    if (null === $previousTwigNode) {
                        $previousTwigNode = new SuperblockClosure(new \Twig_Node([], [], $lineno), $node->getTemplateLine());
                    }

                    $previousTwigNode->getNode('body')->setNode(\count($previousTwigNode->getNode('body')), $node);
                }
            }
        }

        $this->pushClosureNode($sBlocks, $variables, $name, $previousTwigNode);

        $superblock->setNode('sblocks', $sBlocks);

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

        $this->parser->popBlockStack();
        $this->parser->popLocalScope();

        return $reference;
    }
133629
public function parse(TokenStream $stream)
    {
        if ($stream->match(Token::OPERATOR, array('!', '-'))) {
            $value = $stream->current()->value;
            $stream->next();
            $ret = new Op\Unary($value, $this->parse($stream));
        } elseif ($stream->match(Token::KEYWORD, array('true', 'false'))) {
            $ret = new Node\Expr\Literal($stream->current()->value === 'true');
            $stream->next();
        } elseif ($stream->match(Token::KEYWORD, 'null')) {
            $ret = new Node\Expr\Literal(null);
            $stream->next();
        } elseif ($stream->match(Token::IDENTIFIER)) {
            $name = $stream->current()->value;
            $stream->next();

            $ret = new Node\Expr\Variable($name);
        } elseif ($stream->match(Token::STRING)) {
            $ret = new Node\Expr\Str($stream->current()->value);
            $stream->next();
        } elseif ($stream->match(Token::NUMBER)) {
            $value = $stream->current()->value;
            if (strpos('.', $value) !== false) {
                $ret = new Node\Expr\Number((float)$value);
            } else {
                $ret = new Node\Expr\Number((int)$value);
            }
            $stream->next();
        } elseif ($stream->match(Token::OPERATOR, '(')) {
            $stream->next();
            $ret = new Node\Expr\Parens($this->parse($stream));
            $stream->expect(Token::OPERATOR, ')');
        } elseif ($stream->match(Token::OPERATOR, '[')) {
            $stream->next();
            $ret = new Node\Expr\ListNode();
            if (!$stream->match(Token::OPERATOR, ']')) {
                $ret->append($this->parse($stream));
                while ($stream->match(',')) {
                    $stream->next();
                    $ret->append($this->parse($stream));
                }
            }
            $stream->expect(Token::OPERATOR, ']');
        } else {
            $this->err($stream);
            return null;
        }

        if ($stream->valid()) {
            while ($stream->valid() && $stream->match(Token::OPERATOR, array('(', '.', '['))) {
                $type = $stream->current();

                $stream->next();
                if ($type->value === '(') {
                    $ret = new Node\Expr\Call($ret);
                    if (!$stream->match(Token::OPERATOR, ')')) {
                        do {
                            $arg = $this->parse($stream);
                            $ret->append($arg);

                            if ($stream->match(',')) {
                                $stream->next();
                            } else {
                                break;
                            }
                        } while (true);
                    }
                    $stream->expect(Token::OPERATOR, ')');
                } else {
                    $ret = new Node\Expr\Subscript($ret);

                    if ($type->value === '.') {
                        $token = $stream->expect(Token::IDENTIFIER);
                        $ret->append(new Node\Expr\Str($token->value));
                    } else {
                        $ret->append($this->parse($stream));
                    }

                    switch ($type->value) {
                        case '[':
                            $stream->expect(Token::OPERATOR, ']');
                            break;
                    }
                }
            }
        }

        if ($stream->valid()) {
            if ($stream->match(Token::OPERATOR, self::$INFIX_BINARY) || $stream->match(Token::KEYWORD, 'in')) {
                $value = $stream->current()->value;
                $stream->next();
                $ret = new Op\Binary($value, $ret, $this->parse($stream));
            } elseif ($stream->match(Token::OPERATOR, '?')) {
                $stream->next();
                if ($stream->match(Token::OPERATOR, ':')) {
                    $then = null;
                } else {
                    $then = $this->parse($stream);
                }

                if ($stream->valid() && $stream->match(Token::OPERATOR, ':')) {
                    $stream->next();
                    $else = $this->parse($stream);
                } else {
                    $else = null;
                }
                $ret = new Op\Ternary('?', $ret, $then, $else);
            }
        }

        // little syntactic sugar for function calls without parentheses:
        $allowInlineCallTokens = array(Token::IDENTIFIER, Token::STRING, Token::NUMBER);
        if ($stream->valid() && ($stream->match($allowInlineCallTokens))) {
            $ret = new Node\Expr\Call($ret);
            $ret->append($this->parse($stream));
        }

        return $ret;
    }
1184819
private function parseFunction(Stream $stream)
    {
        if ($stream->current()->equals(Token::TYPE_KEYWORD, 'export')) {
            $stream->expects(Token::TYPE_KEYWORD, 'export');

            $isExported = true;
        } else {
            $isExported = false;
        }

        $stream->expects(Token::TYPE_KEYWORD, 'function');

        $functionName = $this->parseIdentifier($stream);

        if ($isExported) {
            $nodes = [new BlueprintExportNode($functionName)];
        } else {
            $nodes = [];
        }

        $stream->expects(Token::TYPE_SYMBOL, '(');

        if (!$stream->current()->equals(Token::TYPE_SYMBOL, ')')) {
            $arguments = $this->parseArgumentList($stream);
        } else {
            $arguments = [];
        }

        $stream->expects(Token::TYPE_SYMBOL, ')');

        $returnExpr = $this->parseReturnExpr($stream);

        $body = new BodyNode($this->templateParser->parse($stream));
        $stream->expects(Token::TYPE_EOF); // Should mark the end of the template.

        $stream->expects(Token::TYPE_SYMBOL, ';');

        array_unshift($nodes, new SetFunctionNode($functionName, $arguments, $returnExpr, $body));

        return $nodes;
    }
609976
protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node)
    {
        if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
            throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition', $node->getLine(), $stream->getFilename());
        }

        foreach ($node as $n) {
            if (!$n) {
                continue;
            }

            $this->checkLoopUsageCondition($stream, $n);
        }
    }
1235476
protected function parseClassDefinition(TokenStream $stream)
    {
        $token = $stream->expect(Lexer::TOKEN_NODE);
        $this->nodes[] = new Node(self::NODE_CLASS, $token->getValue());
        if ($this->skip($stream)->is(Lexer::TOKEN_EXTD)) {
            $stream->next();
            $token = $stream->skipType(Lexer::TOKEN_WTSP)->expect(Lexer::TOKEN_NODE);
            $this->nodes[] = new Node(self::NODE_EXTENDS, $token->getValue());
        }
        if ($this->skip($stream)->is(Lexer::TOKEN_IMPL)) {
            $stream->next();
            while (!$stream->is(Lexer::TOKEN_EOL)) {
                if ($stream->is(Lexer::TOKEN_NODE)) {
                    $this->nodes[] = new Node(self::NODE_IMPLEMENTS, $stream->current()->getValue());
                }
                $stream->next();
            }
        }
        $this->parseComment($stream, self::NODE_CLASS_COMMENT);
        $this->status = self::STAT_CLASS_DEFINED;
    }
1341400
public function lexAll(\Jstewmc\Stream\Stream $stream) 
	{
		$tokens = [];
		
		// while tokens exist
		while (false !== ($token = $this->lexOne($stream))) {
			// append le token
			$tokens[] = $token;
		}
		
		return $tokens;
	}
438840
protected function getValueOfToken(array $token)
    {
        switch ($token[Lexer::TYPE]) {
            case Lexer::T_QUOTED_STRING:
                return substr($token[Lexer::VALUE], 1, -1);

            case Lexer::T_NUMBER:
                return (float)$token[Lexer::VALUE];

            case Lexer::T_TRUE:
                return true;

            case Lexer::T_FALSE:
                return false;

            case Lexer::T_NULL:
                return null;
        }

        return null;
    }
1059855
public function supportsExpr(Stream $stream)
    {
        $token = $stream->current();

        return !$token->is(Token::TYPE_KEYWORD) && ($token->is(Token::TYPE_STRING) || $token->is(Token::TYPE_NUMBER) || $token->is(Token::TYPE_CONSTANT) || $token->is(Token::TYPE_IDENTIFIER) || $token->equals(Token::TYPE_SYMBOL, '{') || $token->equals(Token::TYPE_SYMBOL, '['));
    }
554334
protected function addKeyValues(\Twig_TokenStream $stream, \Twig_Node_Expression_Array $values)
    {
        if (!$stream->test(\Twig_Token::NAME_TYPE)
            && !$stream->test(\Twig_Token::STRING_TYPE)) {
            throw new \Twig_Error_Syntax(sprintf('The attribute name "%s" must be an STRING or CONSTANT', $stream->getCurrent()->getValue()), $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
        }

        $attr = $stream->getCurrent();
        $attr = new \Twig_Node_Expression_Constant($attr->getValue(), $attr->getLine());
        $stream->next();

        if (!$stream->test(\Twig_Token::OPERATOR_TYPE, '=')) {
            throw new \Twig_Error_Syntax("The attribute must be followed by '=' operator", $stream->getCurrent()->getLine(), $stream->getSourceContext()->getName());
        }

        $stream->next();
        $values->addElement($this->parser->getExpressionParser()->parseExpression(), $attr);
    }
1209200
protected function parseLinenosOption(\Twig_Token $token, \Twig_TokenStream $stream)
    {
        $this->testToken('linenos', $token, $stream);

        return $this->getNextExpectedBoolValueFromStream($stream, 'linenos');
    }
870907
public function parse(Twig_Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();
        $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();

        $arguments = $this->parser->getExpressionParser()->parseArguments(true, true);

        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        $this->parser->pushLocalScope();
        $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
        if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
            $value = $token->getValue();

            if ($value != $name) {
                throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $stream->getCurrent()->getLine(), $stream->getFilename());
            }
        }
        $this->parser->popLocalScope();
        $stream->expect(Twig_Token::BLOCK_END_TYPE);

        $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
    }
1201576
public function parse(Token $token)
    {
        $lineno = $token->getLine();

        [$object, $layout, $context] = $this->parseArguments($token);

        return new TwigNodeRender($object, $layout, $context, $lineno, $this->getTag());
    }
1041257
public function parse(Twig_Token $token)
    {
        $line = $token->getLine();

        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);

        $body = $this->parser->subparse(function(Twig_Token $token)
        {
            return $token->test('endmarkdown');
        }, true);

        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);

        return new Node($body, $line, $this->getTag());
    }
1067152
public function parse(Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();

        list ($file, $group, $priority, $attributes) = $this->parseArguments($token);

        $content = null;
        if (!$file) {
            $content = $this->parser->subparse([$this, 'decideBlockEnd'], true);
            $stream->expect(Token::BLOCK_END_TYPE);
        }

        return new TwigNodeStyle($content, $file, $group, $priority, $attributes, $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());
    }