/** * {@inheritdoc} * * @throws MalformedFunctionException */ public function lex(string $value) : array { if (false === $this->functionTokenizer->isTokenized($value)) { $value = $this->functionTokenizer->tokenize($value); } return $this->decoratedLexer->lex($value); }
/** * Parses '<<', '@@'... * * {@inheritdoc} */ public function parse(Token $token) : string { $value = $token->getValue(); if ('' === $value) { throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token); } return $this->tokenizer->detokenize(substr($value, 1)); }
/** * @dataProvider provideValues */ public function testTokenizeValues($value, $expected) { try { $actual = $this->tokenizer->tokenize($value); if (null === $expected) { $this->fail('Expected exception to be thrown.'); } $this->assertEquals($expected, $actual); } catch (MalformedFunctionException $exception) { if (null !== $expected) { throw $exception; } } }
/** * 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))); }