Mercurial > hg > isophonics-drupal-site
comparison vendor/nikic/php-parser/grammar/php5.y @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
14 | /* empty */ { init(); } | 14 | /* empty */ { init(); } |
15 ; | 15 ; |
16 | 16 |
17 top_statement_list: | 17 top_statement_list: |
18 top_statement_list_ex | 18 top_statement_list_ex |
19 { makeNop($nop, $this->lookaheadStartAttributes); | 19 { makeNop($nop, $this->lookaheadStartAttributes, $this->endAttributes); |
20 if ($nop !== null) { $1[] = $nop; } $$ = $1; } | 20 if ($nop !== null) { $1[] = $nop; } $$ = $1; } |
21 ; | 21 ; |
22 | 22 |
23 reserved_non_modifiers: | 23 reserved_non_modifiers: |
24 T_INCLUDE | T_INCLUDE_ONCE | T_EVAL | T_REQUIRE | T_REQUIRE_ONCE | T_LOGICAL_OR | T_LOGICAL_XOR | T_LOGICAL_AND | 24 T_INCLUDE | T_INCLUDE_ONCE | T_EVAL | T_REQUIRE | T_REQUIRE_ONCE | T_LOGICAL_OR | T_LOGICAL_XOR | T_LOGICAL_AND |
33 semi_reserved: | 33 semi_reserved: |
34 reserved_non_modifiers | 34 reserved_non_modifiers |
35 | T_STATIC | T_ABSTRACT | T_FINAL | T_PRIVATE | T_PROTECTED | T_PUBLIC | 35 | T_STATIC | T_ABSTRACT | T_FINAL | T_PRIVATE | T_PROTECTED | T_PUBLIC |
36 ; | 36 ; |
37 | 37 |
38 identifier_ex: | |
39 T_STRING { $$ = Node\Identifier[$1]; } | |
40 | semi_reserved { $$ = Node\Identifier[$1]; } | |
41 ; | |
42 | |
38 identifier: | 43 identifier: |
39 T_STRING { $$ = $1; } | 44 T_STRING { $$ = Node\Identifier[$1]; } |
40 | semi_reserved { $$ = $1; } | 45 ; |
46 | |
47 reserved_non_modifiers_identifier: | |
48 reserved_non_modifiers { $$ = Node\Identifier[$1]; } | |
41 ; | 49 ; |
42 | 50 |
43 namespace_name_parts: | 51 namespace_name_parts: |
44 T_STRING { init($1); } | 52 T_STRING { init($1); } |
45 | namespace_name_parts T_NS_SEPARATOR T_STRING { push($1, $3); } | 53 | namespace_name_parts T_NS_SEPARATOR T_STRING { push($1, $3); } |
46 ; | 54 ; |
47 | 55 |
48 namespace_name: | 56 namespace_name: |
49 namespace_name_parts { $$ = Name[$1]; } | 57 namespace_name_parts { $$ = Name[$1]; } |
58 ; | |
59 | |
60 plain_variable: | |
61 T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } | |
50 ; | 62 ; |
51 | 63 |
52 top_statement: | 64 top_statement: |
53 statement { $$ = $1; } | 65 statement { $$ = $1; } |
54 | function_declaration_statement { $$ = $1; } | 66 | function_declaration_statement { $$ = $1; } |
107 ; | 119 ; |
108 | 120 |
109 unprefixed_use_declaration: | 121 unprefixed_use_declaration: |
110 namespace_name | 122 namespace_name |
111 { $$ = Stmt\UseUse[$1, null, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #1); } | 123 { $$ = Stmt\UseUse[$1, null, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #1); } |
112 | namespace_name T_AS T_STRING | 124 | namespace_name T_AS identifier |
113 { $$ = Stmt\UseUse[$1, $3, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #3); } | 125 { $$ = Stmt\UseUse[$1, $3, Stmt\Use_::TYPE_UNKNOWN]; $this->checkUseUse($$, #3); } |
114 ; | 126 ; |
115 | 127 |
116 use_declaration: | 128 use_declaration: |
117 unprefixed_use_declaration { $$ = $1; } | 129 unprefixed_use_declaration { $$ = $1; } |
127 constant_declaration_list ',' constant_declaration { push($1, $3); } | 139 constant_declaration_list ',' constant_declaration { push($1, $3); } |
128 | constant_declaration { init($1); } | 140 | constant_declaration { init($1); } |
129 ; | 141 ; |
130 | 142 |
131 constant_declaration: | 143 constant_declaration: |
132 T_STRING '=' static_scalar { $$ = Node\Const_[$1, $3]; } | 144 identifier '=' static_scalar { $$ = Node\Const_[$1, $3]; } |
133 ; | 145 ; |
134 | 146 |
135 class_const_list: | 147 class_const_list: |
136 class_const_list ',' class_const { push($1, $3); } | 148 class_const_list ',' class_const { push($1, $3); } |
137 | class_const { init($1); } | 149 | class_const { init($1); } |
138 ; | 150 ; |
139 | 151 |
140 class_const: | 152 class_const: |
141 identifier '=' static_scalar { $$ = Node\Const_[$1, $3]; } | 153 identifier_ex '=' static_scalar { $$ = Node\Const_[$1, $3]; } |
142 ; | 154 ; |
143 | 155 |
144 inner_statement_list_ex: | 156 inner_statement_list_ex: |
145 inner_statement_list_ex inner_statement { pushNormalizing($1, $2); } | 157 inner_statement_list_ex inner_statement { pushNormalizing($1, $2); } |
146 | /* empty */ { init(); } | 158 | /* empty */ { init(); } |
147 ; | 159 ; |
148 | 160 |
149 inner_statement_list: | 161 inner_statement_list: |
150 inner_statement_list_ex | 162 inner_statement_list_ex |
151 { makeNop($nop, $this->lookaheadStartAttributes); | 163 { makeNop($nop, $this->lookaheadStartAttributes, $this->endAttributes); |
152 if ($nop !== null) { $1[] = $nop; } $$ = $1; } | 164 if ($nop !== null) { $1[] = $nop; } $$ = $1; } |
153 ; | 165 ; |
154 | 166 |
155 inner_statement: | 167 inner_statement: |
156 statement { $$ = $1; } | 168 statement { $$ = $1; } |
164 '{' inner_statement_list '}' | 176 '{' inner_statement_list '}' |
165 { | 177 { |
166 if ($2) { | 178 if ($2) { |
167 $$ = $2; prependLeadingComments($$); | 179 $$ = $2; prependLeadingComments($$); |
168 } else { | 180 } else { |
169 makeNop($$, $this->startAttributeStack[#1]); | 181 makeNop($$, $this->startAttributeStack[#1], $this->endAttributes); |
170 if (null === $$) { $$ = array(); } | 182 if (null === $$) { $$ = array(); } |
171 } | 183 } |
172 } | 184 } |
173 | T_IF parentheses_expr statement elseif_list else_single | 185 | T_IF parentheses_expr statement elseif_list else_single |
174 { $$ = Stmt\If_[$2, ['stmts' => toArray($3), 'elseifs' => $4, 'else' => $5]]; } | 186 { $$ = Stmt\If_[$2, ['stmts' => toArray($3), 'elseifs' => $4, 'else' => $5]]; } |
183 | T_BREAK expr ';' { $$ = Stmt\Break_[$2]; } | 195 | T_BREAK expr ';' { $$ = Stmt\Break_[$2]; } |
184 | T_CONTINUE ';' { $$ = Stmt\Continue_[null]; } | 196 | T_CONTINUE ';' { $$ = Stmt\Continue_[null]; } |
185 | T_CONTINUE expr ';' { $$ = Stmt\Continue_[$2]; } | 197 | T_CONTINUE expr ';' { $$ = Stmt\Continue_[$2]; } |
186 | T_RETURN ';' { $$ = Stmt\Return_[null]; } | 198 | T_RETURN ';' { $$ = Stmt\Return_[null]; } |
187 | T_RETURN expr ';' { $$ = Stmt\Return_[$2]; } | 199 | T_RETURN expr ';' { $$ = Stmt\Return_[$2]; } |
188 | yield_expr ';' { $$ = $1; } | |
189 | T_GLOBAL global_var_list ';' { $$ = Stmt\Global_[$2]; } | 200 | T_GLOBAL global_var_list ';' { $$ = Stmt\Global_[$2]; } |
190 | T_STATIC static_var_list ';' { $$ = Stmt\Static_[$2]; } | 201 | T_STATIC static_var_list ';' { $$ = Stmt\Static_[$2]; } |
191 | T_ECHO expr_list ';' { $$ = Stmt\Echo_[$2]; } | 202 | T_ECHO expr_list ';' { $$ = Stmt\Echo_[$2]; } |
192 | T_INLINE_HTML { $$ = Stmt\InlineHTML[$1]; } | 203 | T_INLINE_HTML { $$ = Stmt\InlineHTML[$1]; } |
193 | expr ';' { $$ = $1; } | 204 | yield_expr ';' { $$ = Stmt\Expression[$1]; } |
205 | expr ';' { $$ = Stmt\Expression[$1]; } | |
194 | T_UNSET '(' variables_list ')' ';' { $$ = Stmt\Unset_[$3]; } | 206 | T_UNSET '(' variables_list ')' ';' { $$ = Stmt\Unset_[$3]; } |
195 | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement | 207 | T_FOREACH '(' expr T_AS foreach_variable ')' foreach_statement |
196 { $$ = Stmt\Foreach_[$3, $5[0], ['keyVar' => null, 'byRef' => $5[1], 'stmts' => $7]]; } | 208 { $$ = Stmt\Foreach_[$3, $5[0], ['keyVar' => null, 'byRef' => $5[1], 'stmts' => $7]]; } |
197 | T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement | 209 | T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW foreach_variable ')' foreach_statement |
198 { $$ = Stmt\Foreach_[$3, $7[0], ['keyVar' => $5, 'byRef' => $7[1], 'stmts' => $9]]; } | 210 { $$ = Stmt\Foreach_[$3, $7[0], ['keyVar' => $5, 'byRef' => $7[1], 'stmts' => $9]]; } |
199 | T_DECLARE '(' declare_list ')' declare_statement { $$ = Stmt\Declare_[$3, $5]; } | 211 | T_DECLARE '(' declare_list ')' declare_statement { $$ = Stmt\Declare_[$3, $5]; } |
200 | T_TRY '{' inner_statement_list '}' catches optional_finally | 212 | T_TRY '{' inner_statement_list '}' catches optional_finally |
201 { $$ = Stmt\TryCatch[$3, $5, $6]; $this->checkTryCatch($$); } | 213 { $$ = Stmt\TryCatch[$3, $5, $6]; $this->checkTryCatch($$); } |
202 | T_THROW expr ';' { $$ = Stmt\Throw_[$2]; } | 214 | T_THROW expr ';' { $$ = Stmt\Throw_[$2]; } |
203 | T_GOTO T_STRING ';' { $$ = Stmt\Goto_[$2]; } | 215 | T_GOTO identifier ';' { $$ = Stmt\Goto_[$2]; } |
204 | T_STRING ':' { $$ = Stmt\Label[$1]; } | 216 | identifier ':' { $$ = Stmt\Label[$1]; } |
205 | expr error { $$ = $1; } | 217 | expr error { $$ = Stmt\Expression[$1]; } |
206 | error { $$ = array(); /* means: no statement */ } | 218 | error { $$ = array(); /* means: no statement */ } |
207 ; | 219 ; |
208 | 220 |
209 statement: | 221 statement: |
210 non_empty_statement { $$ = $1; } | 222 non_empty_statement { $$ = $1; } |
211 | ';' | 223 | ';' |
212 { makeNop($$, $this->startAttributeStack[#1]); | 224 { makeNop($$, $this->startAttributeStack[#1], $this->endAttributes); |
213 if ($$ === null) $$ = array(); /* means: no statement */ } | 225 if ($$ === null) $$ = array(); /* means: no statement */ } |
214 ; | 226 ; |
215 | 227 |
216 catches: | 228 catches: |
217 /* empty */ { init(); } | 229 /* empty */ { init(); } |
218 | catches catch { push($1, $2); } | 230 | catches catch { push($1, $2); } |
219 ; | 231 ; |
220 | 232 |
221 catch: | 233 catch: |
222 T_CATCH '(' name T_VARIABLE ')' '{' inner_statement_list '}' | 234 T_CATCH '(' name plain_variable ')' '{' inner_statement_list '}' |
223 { $$ = Stmt\Catch_[array($3), parseVar($4), $7]; } | 235 { $$ = Stmt\Catch_[array($3), $4, $7]; } |
224 ; | 236 ; |
225 | 237 |
226 optional_finally: | 238 optional_finally: |
227 /* empty */ { $$ = null; } | 239 /* empty */ { $$ = null; } |
228 | T_FINALLY '{' inner_statement_list '}' { $$ = Stmt\Finally_[$3]; } | 240 | T_FINALLY '{' inner_statement_list '}' { $$ = Stmt\Finally_[$3]; } |
242 /* empty */ { $$ = false; } | 254 /* empty */ { $$ = false; } |
243 | T_ELLIPSIS { $$ = true; } | 255 | T_ELLIPSIS { $$ = true; } |
244 ; | 256 ; |
245 | 257 |
246 function_declaration_statement: | 258 function_declaration_statement: |
247 T_FUNCTION optional_ref T_STRING '(' parameter_list ')' optional_return_type '{' inner_statement_list '}' | 259 T_FUNCTION optional_ref identifier '(' parameter_list ')' optional_return_type '{' inner_statement_list '}' |
248 { $$ = Stmt\Function_[$3, ['byRef' => $2, 'params' => $5, 'returnType' => $7, 'stmts' => $9]]; } | 260 { $$ = Stmt\Function_[$3, ['byRef' => $2, 'params' => $5, 'returnType' => $7, 'stmts' => $9]]; } |
249 ; | 261 ; |
250 | 262 |
251 class_declaration_statement: | 263 class_declaration_statement: |
252 class_entry_type T_STRING extends_from implements_list '{' class_statement_list '}' | 264 class_entry_type identifier extends_from implements_list '{' class_statement_list '}' |
253 { $$ = Stmt\Class_[$2, ['type' => $1, 'extends' => $3, 'implements' => $4, 'stmts' => $6]]; | 265 { $$ = Stmt\Class_[$2, ['type' => $1, 'extends' => $3, 'implements' => $4, 'stmts' => $6]]; |
254 $this->checkClass($$, #2); } | 266 $this->checkClass($$, #2); } |
255 | T_INTERFACE T_STRING interface_extends_list '{' class_statement_list '}' | 267 | T_INTERFACE identifier interface_extends_list '{' class_statement_list '}' |
256 { $$ = Stmt\Interface_[$2, ['extends' => $3, 'stmts' => $5]]; | 268 { $$ = Stmt\Interface_[$2, ['extends' => $3, 'stmts' => $5]]; |
257 $this->checkInterface($$, #2); } | 269 $this->checkInterface($$, #2); } |
258 | T_TRAIT T_STRING '{' class_statement_list '}' | 270 | T_TRAIT identifier '{' class_statement_list '}' |
259 { $$ = Stmt\Trait_[$2, ['stmts' => $4]]; } | 271 { $$ = Stmt\Trait_[$2, ['stmts' => $4]]; } |
260 ; | 272 ; |
261 | 273 |
262 class_entry_type: | 274 class_entry_type: |
263 T_CLASS { $$ = 0; } | 275 T_CLASS { $$ = 0; } |
305 declare_list_element { init($1); } | 317 declare_list_element { init($1); } |
306 | declare_list ',' declare_list_element { push($1, $3); } | 318 | declare_list ',' declare_list_element { push($1, $3); } |
307 ; | 319 ; |
308 | 320 |
309 declare_list_element: | 321 declare_list_element: |
310 T_STRING '=' static_scalar { $$ = Stmt\DeclareDeclare[$1, $3]; } | 322 identifier '=' static_scalar { $$ = Stmt\DeclareDeclare[$1, $3]; } |
311 ; | 323 ; |
312 | 324 |
313 switch_case_list: | 325 switch_case_list: |
314 '{' case_list '}' { $$ = $2; } | 326 '{' case_list '}' { $$ = $2; } |
315 | '{' ';' case_list '}' { $$ = $3; } | 327 | '{' ';' case_list '}' { $$ = $3; } |
321 /* empty */ { init(); } | 333 /* empty */ { init(); } |
322 | case_list case { push($1, $2); } | 334 | case_list case { push($1, $2); } |
323 ; | 335 ; |
324 | 336 |
325 case: | 337 case: |
326 T_CASE expr case_separator inner_statement_list { $$ = Stmt\Case_[$2, $4]; } | 338 T_CASE expr case_separator inner_statement_list_ex { $$ = Stmt\Case_[$2, $4]; } |
327 | T_DEFAULT case_separator inner_statement_list { $$ = Stmt\Case_[null, $3]; } | 339 | T_DEFAULT case_separator inner_statement_list_ex { $$ = Stmt\Case_[null, $3]; } |
328 ; | 340 ; |
329 | 341 |
330 case_separator: | 342 case_separator: |
331 ':' | 343 ':' |
332 | ';' | 344 | ';' |
380 parameter { init($1); } | 392 parameter { init($1); } |
381 | non_empty_parameter_list ',' parameter { push($1, $3); } | 393 | non_empty_parameter_list ',' parameter { push($1, $3); } |
382 ; | 394 ; |
383 | 395 |
384 parameter: | 396 parameter: |
385 optional_param_type optional_ref optional_ellipsis T_VARIABLE | 397 optional_param_type optional_ref optional_ellipsis plain_variable |
386 { $$ = Node\Param[parseVar($4), null, $1, $2, $3]; $this->checkParam($$); } | 398 { $$ = Node\Param[$4, null, $1, $2, $3]; $this->checkParam($$); } |
387 | optional_param_type optional_ref optional_ellipsis T_VARIABLE '=' static_scalar | 399 | optional_param_type optional_ref optional_ellipsis plain_variable '=' static_scalar |
388 { $$ = Node\Param[parseVar($4), $6, $1, $2, $3]; $this->checkParam($$); } | 400 { $$ = Node\Param[$4, $6, $1, $2, $3]; $this->checkParam($$); } |
389 ; | 401 ; |
390 | 402 |
391 type: | 403 type: |
392 name { $$ = $1; } | 404 name { $$ = $1; } |
393 | T_ARRAY { $$ = 'array'; } | 405 | T_ARRAY { $$ = Node\Identifier['array']; } |
394 | T_CALLABLE { $$ = 'callable'; } | 406 | T_CALLABLE { $$ = Node\Identifier['callable']; } |
395 ; | 407 ; |
396 | 408 |
397 optional_param_type: | 409 optional_param_type: |
398 /* empty */ { $$ = null; } | 410 /* empty */ { $$ = null; } |
399 | type { $$ = $1; } | 411 | type { $$ = $1; } |
425 global_var_list ',' global_var { push($1, $3); } | 437 global_var_list ',' global_var { push($1, $3); } |
426 | global_var { init($1); } | 438 | global_var { init($1); } |
427 ; | 439 ; |
428 | 440 |
429 global_var: | 441 global_var: |
430 T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } | 442 plain_variable { $$ = $1; } |
431 | '$' variable { $$ = Expr\Variable[$2]; } | 443 | '$' variable { $$ = Expr\Variable[$2]; } |
432 | '$' '{' expr '}' { $$ = Expr\Variable[$3]; } | 444 | '$' '{' expr '}' { $$ = Expr\Variable[$3]; } |
433 ; | 445 ; |
434 | 446 |
435 static_var_list: | 447 static_var_list: |
436 static_var_list ',' static_var { push($1, $3); } | 448 static_var_list ',' static_var { push($1, $3); } |
437 | static_var { init($1); } | 449 | static_var { init($1); } |
438 ; | 450 ; |
439 | 451 |
440 static_var: | 452 static_var: |
441 T_VARIABLE { $$ = Stmt\StaticVar[parseVar($1), null]; } | 453 plain_variable { $$ = Stmt\StaticVar[$1, null]; } |
442 | T_VARIABLE '=' static_scalar { $$ = Stmt\StaticVar[parseVar($1), $3]; } | 454 | plain_variable '=' static_scalar { $$ = Stmt\StaticVar[$1, $3]; } |
443 ; | 455 ; |
444 | 456 |
445 class_statement_list: | 457 class_statement_list: |
446 class_statement_list class_statement { push($1, $2); } | 458 class_statement_list class_statement { push($1, $2); } |
447 | /* empty */ { init(); } | 459 | /* empty */ { init(); } |
449 | 461 |
450 class_statement: | 462 class_statement: |
451 variable_modifiers property_declaration_list ';' | 463 variable_modifiers property_declaration_list ';' |
452 { $$ = Stmt\Property[$1, $2]; $this->checkProperty($$, #1); } | 464 { $$ = Stmt\Property[$1, $2]; $this->checkProperty($$, #1); } |
453 | T_CONST class_const_list ';' { $$ = Stmt\ClassConst[$2, 0]; } | 465 | T_CONST class_const_list ';' { $$ = Stmt\ClassConst[$2, 0]; } |
454 | method_modifiers T_FUNCTION optional_ref identifier '(' parameter_list ')' optional_return_type method_body | 466 | method_modifiers T_FUNCTION optional_ref identifier_ex '(' parameter_list ')' optional_return_type method_body |
455 { $$ = Stmt\ClassMethod[$4, ['type' => $1, 'byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9]]; | 467 { $$ = Stmt\ClassMethod[$4, ['type' => $1, 'byRef' => $3, 'params' => $6, 'returnType' => $8, 'stmts' => $9]]; |
456 $this->checkClassMethod($$, #1); } | 468 $this->checkClassMethod($$, #1); } |
457 | T_USE class_name_list trait_adaptations { $$ = Stmt\TraitUse[$2, $3]; } | 469 | T_USE class_name_list trait_adaptations { $$ = Stmt\TraitUse[$2, $3]; } |
458 ; | 470 ; |
459 | 471 |
468 ; | 480 ; |
469 | 481 |
470 trait_adaptation: | 482 trait_adaptation: |
471 trait_method_reference_fully_qualified T_INSTEADOF class_name_list ';' | 483 trait_method_reference_fully_qualified T_INSTEADOF class_name_list ';' |
472 { $$ = Stmt\TraitUseAdaptation\Precedence[$1[0], $1[1], $3]; } | 484 { $$ = Stmt\TraitUseAdaptation\Precedence[$1[0], $1[1], $3]; } |
473 | trait_method_reference T_AS member_modifier identifier ';' | 485 | trait_method_reference T_AS member_modifier identifier_ex ';' |
474 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, $4]; } | 486 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, $4]; } |
475 | trait_method_reference T_AS member_modifier ';' | 487 | trait_method_reference T_AS member_modifier ';' |
476 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, null]; } | 488 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], $3, null]; } |
477 | trait_method_reference T_AS T_STRING ';' | 489 | trait_method_reference T_AS identifier ';' |
478 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } | 490 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } |
479 | trait_method_reference T_AS reserved_non_modifiers ';' | 491 | trait_method_reference T_AS reserved_non_modifiers_identifier ';' |
480 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } | 492 { $$ = Stmt\TraitUseAdaptation\Alias[$1[0], $1[1], null, $3]; } |
481 ; | 493 ; |
482 | 494 |
483 trait_method_reference_fully_qualified: | 495 trait_method_reference_fully_qualified: |
484 name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = array($1, $3); } | 496 name T_PAAMAYIM_NEKUDOTAYIM identifier_ex { $$ = array($1, $3); } |
485 ; | 497 ; |
486 trait_method_reference: | 498 trait_method_reference: |
487 trait_method_reference_fully_qualified { $$ = $1; } | 499 trait_method_reference_fully_qualified { $$ = $1; } |
488 | identifier { $$ = array(null, $1); } | 500 | identifier_ex { $$ = array(null, $1); } |
489 ; | 501 ; |
490 | 502 |
491 method_body: | 503 method_body: |
492 ';' /* abstract method */ { $$ = null; } | 504 ';' /* abstract method */ { $$ = null; } |
493 | '{' inner_statement_list '}' { $$ = $2; } | 505 | '{' inner_statement_list '}' { $$ = $2; } |
520 property_declaration_list: | 532 property_declaration_list: |
521 property_declaration { init($1); } | 533 property_declaration { init($1); } |
522 | property_declaration_list ',' property_declaration { push($1, $3); } | 534 | property_declaration_list ',' property_declaration { push($1, $3); } |
523 ; | 535 ; |
524 | 536 |
537 property_decl_name: | |
538 T_VARIABLE { $$ = Node\VarLikeIdentifier[parseVar($1)]; } | |
539 ; | |
540 | |
525 property_declaration: | 541 property_declaration: |
526 T_VARIABLE { $$ = Stmt\PropertyProperty[parseVar($1), null]; } | 542 property_decl_name { $$ = Stmt\PropertyProperty[$1, null]; } |
527 | T_VARIABLE '=' static_scalar { $$ = Stmt\PropertyProperty[parseVar($1), $3]; } | 543 | property_decl_name '=' static_scalar { $$ = Stmt\PropertyProperty[$1, $3]; } |
528 ; | 544 ; |
529 | 545 |
530 expr_list: | 546 expr_list: |
531 expr_list ',' expr { push($1, $3); } | 547 expr_list ',' expr { push($1, $3); } |
532 | expr { init($1); } | 548 | expr { init($1); } |
663 | 679 |
664 anonymous_class: | 680 anonymous_class: |
665 T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}' | 681 T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}' |
666 { $$ = array(Stmt\Class_[null, ['type' => 0, 'extends' => $3, 'implements' => $4, 'stmts' => $6]], $2); | 682 { $$ = array(Stmt\Class_[null, ['type' => 0, 'extends' => $3, 'implements' => $4, 'stmts' => $6]], $2); |
667 $this->checkClass($$[0], -1); } | 683 $this->checkClass($$[0], -1); } |
684 ; | |
668 | 685 |
669 new_expr: | 686 new_expr: |
670 T_NEW class_name_reference ctor_arguments { $$ = Expr\New_[$2, $3]; } | 687 T_NEW class_name_reference ctor_arguments { $$ = Expr\New_[$2, $3]; } |
671 | T_NEW anonymous_class | 688 | T_NEW anonymous_class |
672 { list($class, $ctorArgs) = $2; $$ = Expr\New_[$class, $ctorArgs]; } | 689 { list($class, $ctorArgs) = $2; $$ = Expr\New_[$class, $ctorArgs]; } |
681 lexical_var { init($1); } | 698 lexical_var { init($1); } |
682 | lexical_var_list ',' lexical_var { push($1, $3); } | 699 | lexical_var_list ',' lexical_var { push($1, $3); } |
683 ; | 700 ; |
684 | 701 |
685 lexical_var: | 702 lexical_var: |
686 optional_ref T_VARIABLE { $$ = Expr\ClosureUse[parseVar($2), $1]; } | 703 optional_ref plain_variable { $$ = Expr\ClosureUse[$2, $1]; } |
687 ; | 704 ; |
688 | 705 |
689 function_call: | 706 function_call: |
690 name argument_list { $$ = Expr\FuncCall[$1, $2]; } | 707 name argument_list { $$ = Expr\FuncCall[$1, $2]; } |
691 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier argument_list | 708 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier_ex argument_list |
692 { $$ = Expr\StaticCall[$1, $3, $4]; } | 709 { $$ = Expr\StaticCall[$1, $3, $4]; } |
693 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' argument_list | 710 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' argument_list |
694 { $$ = Expr\StaticCall[$1, $4, $6]; } | 711 { $$ = Expr\StaticCall[$1, $4, $6]; } |
695 | static_property argument_list { | 712 | static_property argument_list |
696 if ($1 instanceof Node\Expr\StaticPropertyFetch) { | 713 { $$ = $this->fixupPhp5StaticPropCall($1, $2, attributes()); } |
697 $$ = Expr\StaticCall[$1->class, Expr\Variable[$1->name], $2]; | |
698 } elseif ($1 instanceof Node\Expr\ArrayDimFetch) { | |
699 $tmp = $1; | |
700 while ($tmp->var instanceof Node\Expr\ArrayDimFetch) { | |
701 $tmp = $tmp->var; | |
702 } | |
703 | |
704 $$ = Expr\StaticCall[$tmp->var->class, $1, $2]; | |
705 $tmp->var = Expr\Variable[$tmp->var->name]; | |
706 } else { | |
707 throw new \Exception; | |
708 } | |
709 } | |
710 | variable_without_objects argument_list | 714 | variable_without_objects argument_list |
711 { $$ = Expr\FuncCall[$1, $2]; } | 715 { $$ = Expr\FuncCall[$1, $2]; } |
712 | function_call '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | 716 | function_call '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } |
713 /* alternative array syntax missing intentionally */ | 717 /* alternative array syntax missing intentionally */ |
714 ; | 718 ; |
788 $$ = new Scalar\String_('', $attrs); } | 792 $$ = new Scalar\String_('', $attrs); } |
789 ; | 793 ; |
790 | 794 |
791 static_scalar: | 795 static_scalar: |
792 common_scalar { $$ = $1; } | 796 common_scalar { $$ = $1; } |
793 | class_name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = Expr\ClassConstFetch[$1, $3]; } | 797 | class_name T_PAAMAYIM_NEKUDOTAYIM identifier_ex { $$ = Expr\ClassConstFetch[$1, $3]; } |
794 | name { $$ = Expr\ConstFetch[$1]; } | 798 | name { $$ = Expr\ConstFetch[$1]; } |
795 | T_ARRAY '(' static_array_pair_list ')' { $$ = Expr\Array_[$3]; } | 799 | T_ARRAY '(' static_array_pair_list ')' { $$ = Expr\Array_[$3]; } |
796 | '[' static_array_pair_list ']' { $$ = Expr\Array_[$2]; } | 800 | '[' static_array_pair_list ']' { $$ = Expr\Array_[$2]; } |
797 | static_operation { $$ = $1; } | 801 | static_operation { $$ = $1; } |
798 ; | 802 ; |
833 | '(' static_scalar ')' { $$ = $2; } | 837 | '(' static_scalar ')' { $$ = $2; } |
834 ; | 838 ; |
835 | 839 |
836 constant: | 840 constant: |
837 name { $$ = Expr\ConstFetch[$1]; } | 841 name { $$ = Expr\ConstFetch[$1]; } |
838 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier | 842 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier_ex |
839 { $$ = Expr\ClassConstFetch[$1, $3]; } | 843 { $$ = Expr\ClassConstFetch[$1, $3]; } |
840 ; | 844 ; |
841 | 845 |
842 scalar: | 846 scalar: |
843 common_scalar { $$ = $1; } | 847 common_scalar { $$ = $1; } |
912 class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable | 916 class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable |
913 { $$ = Expr\StaticPropertyFetch[$1, $4]; } | 917 { $$ = Expr\StaticPropertyFetch[$1, $4]; } |
914 | static_property_with_arrays { $$ = $1; } | 918 | static_property_with_arrays { $$ = $1; } |
915 ; | 919 ; |
916 | 920 |
921 static_property_simple_name: | |
922 T_VARIABLE | |
923 { $var = parseVar($1); $$ = \is_string($var) ? Node\VarLikeIdentifier[$var] : $var; } | |
924 ; | |
925 | |
917 static_property_with_arrays: | 926 static_property_with_arrays: |
918 class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE | 927 class_name_or_var T_PAAMAYIM_NEKUDOTAYIM static_property_simple_name |
919 { $$ = Expr\StaticPropertyFetch[$1, parseVar($3)]; } | 928 { $$ = Expr\StaticPropertyFetch[$1, $3]; } |
920 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}' | 929 | class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}' |
921 { $$ = Expr\StaticPropertyFetch[$1, $5]; } | 930 { $$ = Expr\StaticPropertyFetch[$1, $5]; } |
922 | static_property_with_arrays '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | 931 | static_property_with_arrays '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } |
923 | static_property_with_arrays '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } | 932 | static_property_with_arrays '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } |
924 ; | 933 ; |
925 | 934 |
926 reference_variable: | 935 reference_variable: |
927 reference_variable '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | 936 reference_variable '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } |
928 | reference_variable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } | 937 | reference_variable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; } |
929 | T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } | 938 | plain_variable { $$ = $1; } |
930 | '$' '{' expr '}' { $$ = Expr\Variable[$3]; } | 939 | '$' '{' expr '}' { $$ = Expr\Variable[$3]; } |
931 ; | 940 ; |
932 | 941 |
933 dim_offset: | 942 dim_offset: |
934 /* empty */ { $$ = null; } | 943 /* empty */ { $$ = null; } |
935 | expr { $$ = $1; } | 944 | expr { $$ = $1; } |
936 ; | 945 ; |
937 | 946 |
938 object_property: | 947 object_property: |
939 T_STRING { $$ = $1; } | 948 identifier { $$ = $1; } |
940 | '{' expr '}' { $$ = $2; } | 949 | '{' expr '}' { $$ = $2; } |
941 | variable_without_objects { $$ = $1; } | 950 | variable_without_objects { $$ = $1; } |
942 | error { $$ = Expr\Error[]; $this->errorState = 2; } | 951 | error { $$ = Expr\Error[]; $this->errorState = 2; } |
943 ; | 952 ; |
944 | 953 |
983 | 992 |
984 encaps_string_part: | 993 encaps_string_part: |
985 T_ENCAPSED_AND_WHITESPACE { $$ = Scalar\EncapsedStringPart[$1]; } | 994 T_ENCAPSED_AND_WHITESPACE { $$ = Scalar\EncapsedStringPart[$1]; } |
986 ; | 995 ; |
987 | 996 |
988 encaps_base_var: | 997 encaps_str_varname: |
989 T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } | 998 T_STRING_VARNAME { $$ = Expr\Variable[$1]; } |
990 ; | 999 ; |
991 | 1000 |
992 encaps_var: | 1001 encaps_var: |
993 encaps_base_var { $$ = $1; } | 1002 plain_variable { $$ = $1; } |
994 | encaps_base_var '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } | 1003 | plain_variable '[' encaps_var_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; } |
995 | encaps_base_var T_OBJECT_OPERATOR T_STRING { $$ = Expr\PropertyFetch[$1, $3]; } | 1004 | plain_variable T_OBJECT_OPERATOR identifier { $$ = Expr\PropertyFetch[$1, $3]; } |
996 | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Expr\Variable[$2]; } | 1005 | T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Expr\Variable[$2]; } |
997 | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Expr\Variable[$2]; } | 1006 | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Expr\Variable[$2]; } |
998 | T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}' | 1007 | T_DOLLAR_OPEN_CURLY_BRACES encaps_str_varname '[' expr ']' '}' |
999 { $$ = Expr\ArrayDimFetch[Expr\Variable[$2], $4]; } | 1008 { $$ = Expr\ArrayDimFetch[$2, $4]; } |
1000 | T_CURLY_OPEN variable '}' { $$ = $2; } | 1009 | T_CURLY_OPEN variable '}' { $$ = $2; } |
1001 ; | 1010 ; |
1002 | 1011 |
1003 encaps_var_offset: | 1012 encaps_var_offset: |
1004 T_STRING { $$ = Scalar\String_[$1]; } | 1013 T_STRING { $$ = Scalar\String_[$1]; } |
1005 | T_NUM_STRING { $$ = $this->parseNumString($1, attributes()); } | 1014 | T_NUM_STRING { $$ = $this->parseNumString($1, attributes()); } |
1006 | T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; } | 1015 | plain_variable { $$ = $1; } |
1007 ; | 1016 ; |
1008 | 1017 |
1009 %% | 1018 %% |