Slightly clean up scalar/static_sclar/common_sclar

name rule is now in common_scalar as it is shared. T_STRING_VARNAME is in encaps_var now.
This commit is contained in:
nikic 2011-10-21 12:22:41 +02:00
parent ef9d0283e9
commit 73cc546140
3 changed files with 401 additions and 407 deletions

View File

@ -627,23 +627,21 @@ common_scalar:
{ $$ = Scalar_String[Scalar_String::parseEscapeSequences($2, null)]; }
| T_START_HEREDOC T_END_HEREDOC
{ $$ = Scalar_String['']; }
| name { $$ = Expr_ConstFetch[$1]; }
;
static_scalar: /* compile-time evaluated scalars */
common_scalar { $$ = $1; }
| name { $$ = Expr_ConstFetch[$1]; }
| class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { $$ = Expr_ClassConstFetch[$1, $3]; }
| '+' static_scalar { $$ = Expr_UnaryPlus[$2]; }
| '-' static_scalar { $$ = Expr_UnaryMinus[$2]; }
| T_ARRAY '(' static_array_pair_list ')' { $$ = Expr_Array[$3]; }
| '[' static_array_pair_list ']' { $$ = Expr_Array[$2]; }
| class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING { $$ = Expr_ClassConstFetch[$1, $3]; }
;
scalar:
T_STRING_VARNAME { $$ = Scalar_String[$1]; }
common_scalar { $$ = $1; }
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING { $$ = Expr_ClassConstFetch[$1, $3]; }
| name { $$ = Expr_ConstFetch[$1]; }
| common_scalar { $$ = $1; }
| '"' encaps_list '"'
{ parseEncapsed($2, '"'); $$ = Scalar_Encapsed[$2]; }
| T_START_HEREDOC encaps_list T_END_HEREDOC
@ -768,6 +766,7 @@ encaps_var:
| T_VARIABLE '[' encaps_var_offset ']' { $$ = Expr_ArrayDimFetch[Expr_Variable[parseVar($1)], $3]; }
| T_VARIABLE T_OBJECT_OPERATOR T_STRING { $$ = Expr_PropertyFetch[Expr_Variable[parseVar($1)], $3]; }
| T_DOLLAR_OPEN_CURLY_BRACES expr '}' { $$ = Expr_Variable[$2]; }
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}' { $$ = Expr_Variable[$2]; }
| T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'
{ $$ = Expr_ArrayDimFetch[Expr_Variable[$2], $4]; }
| T_CURLY_OPEN variable '}' { $$ = $2; }

File diff suppressed because it is too large Load Diff

View File

@ -285,17 +285,15 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"common_scalar : T_NS_C",
"common_scalar : T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC",
"common_scalar : T_START_HEREDOC T_END_HEREDOC",
"common_scalar : name",
"static_scalar : common_scalar",
"static_scalar : name",
"static_scalar : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING",
"static_scalar : '+' static_scalar",
"static_scalar : '-' static_scalar",
"static_scalar : T_ARRAY '(' static_array_pair_list ')'",
"static_scalar : '[' static_array_pair_list ']'",
"static_scalar : class_name T_PAAMAYIM_NEKUDOTAYIM T_STRING",
"scalar : T_STRING_VARNAME",
"scalar : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING",
"scalar : name",
"scalar : common_scalar",
"scalar : class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_STRING",
"scalar : '\"' encaps_list '\"'",
"scalar : T_START_HEREDOC encaps_list T_END_HEREDOC",
"static_array_pair_list : /* empty */",
@ -354,6 +352,7 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"encaps_var : T_VARIABLE '[' encaps_var_offset ']'",
"encaps_var : T_VARIABLE T_OBJECT_OPERATOR T_STRING",
"encaps_var : T_DOLLAR_OPEN_CURLY_BRACES expr '}'",
"encaps_var : T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '}'",
"encaps_var : T_DOLLAR_OPEN_CURLY_BRACES T_STRING_VARNAME '[' expr ']' '}'",
"encaps_var : T_CURLY_OPEN variable '}'",
"encaps_var_offset : T_STRING",