* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\ExpressionLanguage; /** * Represents a token stream. * * @author Fabien Potencier */ class TokenStream { public $current; private $tokens; private $position = 0; private $expression; /** * @param array $tokens An array of tokens * @param string $expression */ public function __construct(array $tokens, $expression = '') { $this->tokens = $tokens; $this->current = $tokens[0]; $this->expression = $expression; } /** * Returns a string representation of the token stream. * * @return string */ public function __toString() { return implode("\n", $this->tokens); } /** * Sets the pointer to the next token and returns the old one. */ public function next() { ++$this->position; if (!isset($this->tokens[$this->position])) { throw new SyntaxError('Unexpected end of expression', $this->current->cursor, $this->expression); } $this->current = $this->tokens[$this->position]; } /** * Tests a token. * * @param array|int $type The type to test * @param string|null $value The token value * @param string|null $message The syntax error message */ public function expect($type, $value = null, $message = null) { $token = $this->current; if (!$token->test($type, $value)) { throw new SyntaxError(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', $message ? $message.'. ' : '', $token->type, $token->value, $type, $value ? sprintf(' with value "%s"', $value) : ''), $token->cursor, $this->expression); } $this->next(); } /** * Checks if end of stream was reached. * * @return bool */ public function isEOF() { return Token::EOF_TYPE === $this->current->type; } /** * @internal * * @return string */ public function getExpression() { return $this->expression; } } __halt_compiler();----SIGNATURE:----np58oE9ZEypnh/s2bh0FcvuJxlVLVehHqi3Y/f+sIAoe9+TolznXo1IgHq/FsFwhzWXTLTOjEqn7kEw+rkQBWK7Ksj+UX6mFpzrPdkV40ESk40tZKSlkNj7tlzftvhR84B0WWXgZ1UHvJ1B7i8EBNrlts2cSSJElbonk6Ic2Zlqw4GmWVvFfE1Dsj41Cp/uqkNkxnboebb1pOb7W7/dMSAIMKIpEkntE3MHV7FCChGDkGp0QtKbPb1C76IyayLmjpJ3v5qPtMvPQ+/RRz/069ftI9fxwajPPEteAyHqfiYy/UGpNqR/QW3kd1DisUSMBVR8cVRiKwqnEF9HbObUqqXsOtI5Y6LTn8ebv7dWUdjNGWI1nP/TZu47I2opN0VAgIQ2OTeiZBYSlu+keFFjn8q4IHR64qSkFBuE3dQTt6y7/ERL3WDQANQ5R1BKC+NzorHbgD7xBK1HoH9r8YKSrwwuENxMuEmXDttMi6cMgvMFYCt81xGLjs1xxiZid5j6zLj1HTNCpObMaM7xSpi5EV8y3inTwDy9WYrMbrz5hHVhV7oSaPF26HaH4optkhBi1EELCre+p4odOU4jqXpvVMpAhZcPA+dKzycT3voCIQtIDfGFE4CKj6WgIJehuIf2deNPRElG7iNISa08BCpx44ds4vv7uXRL81UNCZej8Cug=----ATTACHMENT:----MTQyOTA1Njc0MjI1MTE2MCAzNzA2OTYyNDUxNzc4MzY3IDQ2OTQ4ODQ1MTYwOTIyMDg=