123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace Symfony\Component\ExpressionLanguage;
- class Token
- {
- public $value;
- public $type;
- public $cursor;
- const EOF_TYPE = 'end of expression';
- const NAME_TYPE = 'name';
- const NUMBER_TYPE = 'number';
- const STRING_TYPE = 'string';
- const OPERATOR_TYPE = 'operator';
- const PUNCTUATION_TYPE = 'punctuation';
-
- public function __construct($type, $value, $cursor)
- {
- $this->type = $type;
- $this->value = $value;
- $this->cursor = $cursor;
- }
-
- public function __toString()
- {
- return sprintf('%3d %-11s %s', $this->cursor, strtoupper($this->type), $this->value);
- }
-
- public function test($type, $value = null)
- {
- return $this->type === $type && (null === $value || $this->value == $value);
- }
- }
|