/** * Handle cases like '<f()> <g()>' by trying to break down the token. * * {@inheritdoc} * * @throws LexException * @TODO: handle redundant ListValue tokens * * @return FunctionCallValue|ListValue */ public function parse(Token $token) { parent::parse($token); $split = preg_split(self::REGEX, $token->getValue(), 2, PREG_SPLIT_DELIM_CAPTURE + PREG_SPLIT_NO_EMPTY); $splitSize = count($split); if (1 === $splitSize) { return $this->functionTokenParser->parse($token); } if (3 !== count($split) && 4 !== count($split)) { throw ExpressionLanguageExceptionFactory::createForCouldNotLexValue($token->getValue()); } $values = [$this->parser->parse($split[0] . $split[1])]; if (3 === $splitSize) { $values[] = $this->parser->parse('<' . $split[2]); } if (4 === $splitSize) { $values[] = $this->parser->parse($split[2]); $values[] = $this->parser->parse('<' . $split[3]); } return $this->mergeValues($values); }
/** * @inheritdoc */ public function parse(Token $token) { return $this->decoratedParser->parse($token); }
/** * Parses expressions such as '<(something)>'. * * {@inheritdoc} * * @throws ParseException */ public function parse(Token $token) { $value = $this->tokenizer->detokenize($token->getValue()); $realValue = preg_replace('/^<\\((.*)\\)>$/', '<identity($1)>', $value); return $this->decoratedTokenParser->parse(new Token($realValue, new TokenType(TokenType::FUNCTION_TYPE))); }