1 | <?php |
||
8 | class Token |
||
9 | { |
||
10 | const EOF_TYPE = 1; |
||
11 | const BANG_TYPE = 2; |
||
12 | const DOLLAR_TYPE = 3; |
||
13 | const PAREN_L_TYPE = 4; |
||
14 | const PAREN_R_TYPE = 5; |
||
15 | const SPREAD_TYPE = 6; |
||
16 | const COLON_TYPE = 7; |
||
17 | const EQUALS_TYPE = 8; |
||
18 | const AT_TYPE = 9; |
||
19 | const BRACKET_L_TYPE = 10; |
||
20 | const BRACKET_R_TYPE = 11; |
||
21 | const BRACE_L_TYPE = 12; |
||
22 | const PIPE_TYPE = 13; |
||
23 | const BRACE_R_TYPE = 14; |
||
24 | const NAME_TYPE = 15; |
||
25 | const VARIABLE_TYPE = 16; |
||
26 | const INT_TYPE = 17; |
||
27 | const FLOAT_TYPE = 18; |
||
28 | const STRING_TYPE = 19; |
||
29 | |||
30 | /** |
||
31 | * The token type. |
||
32 | * |
||
33 | * @var int |
||
34 | */ |
||
35 | protected $type; |
||
36 | |||
37 | /** |
||
38 | * The start position. |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $start; |
||
43 | |||
44 | /** |
||
45 | * The end position. |
||
46 | * |
||
47 | * @var int |
||
48 | */ |
||
49 | protected $end; |
||
50 | |||
51 | /** |
||
52 | * The token value. |
||
53 | * |
||
54 | * @var string|null |
||
55 | */ |
||
56 | protected $value; |
||
57 | |||
58 | /** |
||
59 | * Constructor. |
||
60 | * |
||
61 | * @param int $type |
||
62 | * The token type. |
||
63 | * @param int $start |
||
64 | * The start position. |
||
65 | * @param int $end |
||
66 | * The end position. |
||
67 | * @param null|string $value |
||
68 | * The token value. |
||
69 | */ |
||
70 | 426 | public function __construct($type, $start, $end, $value = NULL) |
|
77 | |||
78 | /** |
||
79 | * Gets the token type. |
||
80 | * |
||
81 | * @return int |
||
82 | * The token type |
||
83 | */ |
||
84 | 309 | public function getType() |
|
88 | |||
89 | /** |
||
90 | * Gets the start position. |
||
91 | * |
||
92 | * @return int |
||
93 | * The start position. |
||
94 | */ |
||
95 | 309 | public function getStart() |
|
99 | |||
100 | /** |
||
101 | * Gets the end position. |
||
102 | * |
||
103 | * @return int |
||
104 | * The end position. |
||
105 | */ |
||
106 | 309 | public function getEnd() |
|
110 | |||
111 | /** |
||
112 | * Gets the token value. |
||
113 | * |
||
114 | * @return string|null |
||
115 | * The token value |
||
116 | */ |
||
117 | 309 | public function getValue() |
|
121 | |||
122 | /** |
||
123 | * Gets the token value. |
||
124 | * |
||
125 | * @return string|null |
||
126 | * The token value |
||
127 | */ |
||
128 | public function getDescription() |
||
132 | |||
133 | /** |
||
134 | * Returns a string representation of the token. |
||
135 | * |
||
136 | * @return string |
||
137 | * A string representation of the token |
||
138 | */ |
||
139 | public function __toString() |
||
144 | |||
145 | /** |
||
146 | * Returns the constant representation (internal) of a given type. |
||
147 | * |
||
148 | * @param int $type |
||
149 | * The type as an integer |
||
150 | * |
||
151 | * @return string |
||
152 | * The string representation |
||
153 | */ |
||
154 | public static function typeToString($type) |
||
199 | } |
||
200 |