Add class_name_or_var nonterminal (to simplify)

class_name_or_var nonterminal is class_name | reference_variable
This commit is contained in:
nikic 2011-10-21 11:50:03 +02:00
parent 08ea0e3d56
commit ef9d0283e9
3 changed files with 579 additions and 612 deletions

View File

@ -539,9 +539,7 @@ lexical_var_list:
function_call:
name '(' function_call_argument_list ')' { $$ = Expr_FuncCall[$1, $3]; }
| class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
{ $$ = Expr_StaticCall[$1, $3, $5]; }
| reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'
{ $$ = Expr_StaticCall[$1, $3, $5]; }
| static_property '(' function_call_argument_list ')' {
if ($1 instanceof PHPParser_Node_Expr_StaticPropertyFetch) {
@ -583,6 +581,11 @@ dynamic_class_name_reference:
| base_variable { $$ = $1; }
;
class_name_or_var:
class_name { $$ = $1; }
| reference_variable { $$ = $1; }
;
object_access_for_dcnr:
| base_variable T_OBJECT_OPERATOR object_property
{ $$ = Expr_PropertyFetch[$1, $3]; }
@ -638,7 +641,7 @@ static_scalar: /* compile-time evaluated scalars */
scalar:
T_STRING_VARNAME { $$ = Scalar_String[$1]; }
| class_constant { $$ = $1; }
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING { $$ = Expr_ClassConstFetch[$1, $3]; }
| name { $$ = Expr_ConstFetch[$1]; }
| common_scalar { $$ = $1; }
| '"' encaps_list '"'
@ -693,21 +696,15 @@ base_variable:
;
static_property:
class_name T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable
{ $$ = Expr_StaticPropertyFetch[$1, $4]; }
| reference_variable T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable
class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable
{ $$ = Expr_StaticPropertyFetch[$1, $4]; }
| static_property_with_arrays { $$ = $1; }
;
static_property_with_arrays:
class_name T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE
class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE
{ $$ = Expr_StaticPropertyFetch[$1, parseVar($3)]; }
| reference_variable T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE
{ $$ = Expr_StaticPropertyFetch[$1, parseVar($3)]; }
| class_name T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'
{ $$ = Expr_StaticPropertyFetch[$1, $5]; }
| reference_variable T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'
{ $$ = Expr_StaticPropertyFetch[$1, $5]; }
| static_property_with_arrays '[' dim_offset ']' { $$ = Expr_ArrayDimFetch[$1, $3]; }
| static_property_with_arrays '{' expr '}' { $$ = Expr_ArrayDimFetch[$1, $3]; }
@ -782,9 +779,4 @@ encaps_var_offset:
| T_VARIABLE { $$ = Expr_Variable[parseVar($1)]; }
;
class_constant:
class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { $$ = Expr_ClassConstFetch[$1, $3]; }
| reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING { $$ = Expr_ClassConstFetch[$1, $3]; }
;
%%

File diff suppressed because it is too large Load Diff

View File

@ -246,8 +246,7 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"lexical_var_list : lexical_var_list ',' optional_ref T_VARIABLE",
"lexical_var_list : optional_ref T_VARIABLE",
"function_call : name '(' function_call_argument_list ')'",
"function_call : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'",
"function_call : reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'",
"function_call : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING '(' function_call_argument_list ')'",
"function_call : static_property '(' function_call_argument_list ')'",
"function_call : variable_without_objects '(' function_call_argument_list ')'",
"class_name : T_STATIC",
@ -259,6 +258,8 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"class_name_reference : dynamic_class_name_reference",
"dynamic_class_name_reference : object_access_for_dcnr",
"dynamic_class_name_reference : base_variable",
"class_name_or_var : class_name",
"class_name_or_var : reference_variable",
"object_access_for_dcnr : /* empty */",
"object_access_for_dcnr : base_variable T_OBJECT_OPERATOR object_property",
"object_access_for_dcnr : object_access_for_dcnr T_OBJECT_OPERATOR object_property",
@ -292,7 +293,7 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"static_scalar : '[' static_array_pair_list ']'",
"static_scalar : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING",
"scalar : T_STRING_VARNAME",
"scalar : class_constant",
"scalar : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING",
"scalar : name",
"scalar : common_scalar",
"scalar : '\"' encaps_list '\"'",
@ -317,13 +318,10 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"variable_without_objects : '$' variable_without_objects",
"base_variable : variable_without_objects",
"base_variable : static_property",
"static_property : class_name T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable",
"static_property : reference_variable T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable",
"static_property : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable",
"static_property : static_property_with_arrays",
"static_property_with_arrays : class_name T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE",
"static_property_with_arrays : reference_variable T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE",
"static_property_with_arrays : class_name T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'",
"static_property_with_arrays : reference_variable T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'",
"static_property_with_arrays : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE",
"static_property_with_arrays : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' '{' expr '}'",
"static_property_with_arrays : static_property_with_arrays '[' dim_offset ']'",
"static_property_with_arrays : static_property_with_arrays '{' expr '}'",
"reference_variable : reference_variable '[' dim_offset ']'",
@ -360,9 +358,7 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"encaps_var : T_CURLY_OPEN variable '}'",
"encaps_var_offset : T_STRING",
"encaps_var_offset : T_NUM_STRING",
"encaps_var_offset : T_VARIABLE",
"class_constant : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING",
"class_constant : reference_variable T_PAAMAYIM_NEKUDOTAYIM T_STRING"
"encaps_var_offset : T_VARIABLE"
);
protected function yyprintln($msg) {