Flow\Parser::parseMacroExpression PHP Method

parseMacroExpression() protected method

protected parseMacroExpression ( $token )
    protected function parseMacroExpression($token)
    {
        static $constants = array('true', 'false', 'null');
        static $operators = array('and', 'xor', 'or', 'not', 'in');
        $module = null;
        $name = $this->parseName()->getValue();
        if ($this->stream->consume(Token::OPERATOR, '.')) {
            $module = $name;
            $name = $this->parseName()->getValue();
        }
        $args = array();
        if ($this->stream->consume(Token::OPERATOR, '(')) {
            while (!$this->stream->test(Token::OPERATOR, ')')) {
                if (!empty($args)) {
                    $this->stream->expect(Token::OPERATOR, ',');
                    if ($this->stream->test(Token::OPERATOR, ')')) {
                        break;
                    }
                }
                if (($this->stream->test(Token::NAME) || $this->stream->test(Token::CONSTANT, $constants) || $this->stream->test(Token::OPERATOR, $operators)) && $this->stream->look()->test(Token::OPERATOR, '=')) {
                    $key = $this->parseName()->getValue();
                    $this->stream->expect(Token::OPERATOR, '=');
                    $val = $this->parseExpression();
                    $args[$key] = $val;
                } else {
                    $args[] = $this->parseExpression();
                }
            }
            $this->stream->expect(Token::OPERATOR, ')');
        }
        return new Expression\MacroExpression($module, $name, $args, $token->getLine());
    }