mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-26 20:14:46 +01:00
Fix parsing issue with array accesses on object accesses ($x->y[z])
This commit is contained in:
parent
bd88e4f555
commit
ae3603d126
29120
grammar/y.output
29120
grammar/y.output
File diff suppressed because it is too large
Load Diff
@ -571,11 +571,19 @@ class_name_reference:
|
||||
;
|
||||
|
||||
dynamic_class_name_reference:
|
||||
dynamic_class_name_reference T_OBJECT_OPERATOR object_property
|
||||
{ $$ = new Node_Expr_PropertyFetch(array('var' => $1, 'name' => $3)); }
|
||||
object_access_for_dcnr { $$ = $1; }
|
||||
| base_variable { $$ = $1; }
|
||||
;
|
||||
|
||||
object_access_for_dcnr:
|
||||
| base_variable T_OBJECT_OPERATOR object_property
|
||||
{ $$ = new Node_Expr_PropertyFetch(array('var' => $1, 'name' => $3)); }
|
||||
| object_access_for_dcnr T_OBJECT_OPERATOR object_property
|
||||
{ $$ = new Node_Expr_PropertyFetch(array('var' => $1, 'name' => $3)); }
|
||||
| object_access_for_dcnr '[' dim_offset ']' { $$ = new Node_Expr_ArrayDimFetch(array('var' => $1, 'dim' => $3)); }
|
||||
| object_access_for_dcnr '{' expr '}' { $$ = new Node_Expr_ArrayDimFetch(array('var' => $1, 'dim' => $3)); }
|
||||
;
|
||||
|
||||
exit_expr:
|
||||
/* empty */ { $$ = null; }
|
||||
| '(' ')' { $$ = null; }
|
||||
@ -651,14 +659,34 @@ expr:
|
||||
;
|
||||
|
||||
variable:
|
||||
variable T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_MethodCall(array('var' => $1, 'name' => $3, 'args' => $5)); }
|
||||
| variable T_OBJECT_OPERATOR object_property
|
||||
{ $$ = new Node_Expr_PropertyFetch(array('var' => $1, 'name' => $3)); }
|
||||
object_access { $$ = $1; }
|
||||
| base_variable { $$ = $1; }
|
||||
| function_call { $$ = $1; }
|
||||
;
|
||||
|
||||
object_access:
|
||||
base_variable T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_MethodCall(array('var' => $1, 'name' => $3, 'args' => $5)); }
|
||||
| function_call T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_MethodCall(array('var' => $1, 'name' => $3, 'args' => $5)); }
|
||||
| object_access T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_MethodCall(array('var' => $1, 'name' => $3, 'args' => $5)); }
|
||||
| object_access_arrayable { $$ = $1; }
|
||||
| object_access_arrayable '(' function_call_argument_list ')'
|
||||
{ $$ = new Node_Expr_FuncCall(array('func' => $1, 'args' => $3)); }
|
||||
;
|
||||
|
||||
object_access_arrayable:
|
||||
base_variable T_OBJECT_OPERATOR object_property
|
||||
{ $$ = new Node_Expr_PropertyFetch(array('var' => $1, 'name' => $3)); }
|
||||
| function_call T_OBJECT_OPERATOR object_property
|
||||
{ $$ = new Node_Expr_PropertyFetch(array('var' => $1, 'name' => $3)); }
|
||||
| object_access T_OBJECT_OPERATOR object_property
|
||||
{ $$ = new Node_Expr_PropertyFetch(array('var' => $1, 'name' => $3)); }
|
||||
| object_access_arrayable '[' dim_offset ']' { $$ = new Node_Expr_ArrayDimFetch(array('var' => $1, 'dim' => $3)); }
|
||||
| object_access_arrayable '{' expr '}' { $$ = new Node_Expr_ArrayDimFetch(array('var' => $1, 'dim' => $3)); }
|
||||
;
|
||||
|
||||
variable_without_objects:
|
||||
reference_variable { $$ = $1; }
|
||||
| '$' reference_variable { $$ = new Node_Variable(array('name' => $2)); }
|
||||
@ -695,15 +723,9 @@ dim_offset:
|
||||
;
|
||||
|
||||
object_property:
|
||||
object_dim_list { $$ = $1; }
|
||||
| variable_without_objects { $$ = $1; }
|
||||
;
|
||||
|
||||
object_dim_list:
|
||||
object_dim_list '[' dim_offset ']' { $$ = new Node_Expr_ArrayDimFetch(array('var' => $1, 'dim' => $3)); }
|
||||
| object_dim_list '{' expr '}' { $$ = new Node_Expr_ArrayDimFetch(array('var' => $1, 'dim' => $3)); }
|
||||
| T_STRING { $$ = $1; }
|
||||
T_STRING { $$ = $1; }
|
||||
| '{' expr '}' { $$ = $2; }
|
||||
| variable_without_objects { $$ = $1; }
|
||||
;
|
||||
|
||||
assignment_list:
|
||||
|
@ -571,11 +571,19 @@ class_name_reference:
|
||||
;
|
||||
|
||||
dynamic_class_name_reference:
|
||||
dynamic_class_name_reference T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
object_access_for_dcnr { $$ = $1; }
|
||||
| base_variable { $$ = $1; }
|
||||
;
|
||||
|
||||
object_access_for_dcnr:
|
||||
| base_variable T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| object_access_for_dcnr T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| object_access_for_dcnr '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| object_access_for_dcnr '{' expr '}' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
;
|
||||
|
||||
exit_expr:
|
||||
/* empty */ { $$ = null; }
|
||||
| '(' ')' { $$ = null; }
|
||||
@ -651,14 +659,34 @@ expr:
|
||||
;
|
||||
|
||||
variable:
|
||||
variable T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_MethodCall[var: $1, name: $3, args: $5]; }
|
||||
| variable T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
object_access { $$ = $1; }
|
||||
| base_variable { $$ = $1; }
|
||||
| function_call { $$ = $1; }
|
||||
;
|
||||
|
||||
object_access:
|
||||
base_variable T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_MethodCall[var: $1, name: $3, args: $5]; }
|
||||
| function_call T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_MethodCall[var: $1, name: $3, args: $5]; }
|
||||
| object_access T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_MethodCall[var: $1, name: $3, args: $5]; }
|
||||
| object_access_arrayable { $$ = $1; }
|
||||
| object_access_arrayable '(' function_call_argument_list ')'
|
||||
{ $$ = Expr_FuncCall[func: $1, args: $3]; }
|
||||
;
|
||||
|
||||
object_access_arrayable:
|
||||
base_variable T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| function_call T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| object_access T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr_PropertyFetch[var: $1, name: $3]; }
|
||||
| object_access_arrayable '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| object_access_arrayable '{' expr '}' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
;
|
||||
|
||||
variable_without_objects:
|
||||
reference_variable { $$ = $1; }
|
||||
| '$' reference_variable { $$ = Variable[name: $2]; }
|
||||
@ -695,15 +723,9 @@ dim_offset:
|
||||
;
|
||||
|
||||
object_property:
|
||||
object_dim_list { $$ = $1; }
|
||||
| variable_without_objects { $$ = $1; }
|
||||
;
|
||||
|
||||
object_dim_list:
|
||||
object_dim_list '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| object_dim_list '{' expr '}' { $$ = Expr_ArrayDimFetch[var: $1, dim: $3]; }
|
||||
| T_STRING { $$ = $1; }
|
||||
T_STRING { $$ = $1; }
|
||||
| '{' expr '}' { $$ = $2; }
|
||||
| variable_without_objects { $$ = $1; }
|
||||
;
|
||||
|
||||
assignment_list:
|
||||
|
1367
lib/Parser.php
1367
lib/Parser.php
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user