1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2025-01-20 20:57:48 +01:00

[5.4] Add support for short array syntax

This commit is contained in:
nikic 2011-10-21 11:07:06 +02:00
parent 1eb1118ee1
commit ab982567d7
3 changed files with 625 additions and 618 deletions

View File

@ -517,6 +517,7 @@ expr:
| '@' expr { $$ = Expr_ErrorSuppress[$2]; }
| scalar { $$ = $1; }
| T_ARRAY '(' array_pair_list ')' { $$ = Expr_Array[$3]; }
| '[' array_pair_list ']' { $$ = Expr_Array[$2]; }
| '`' backticks_expr '`' { $$ = Expr_ShellExec[$2]; }
| T_PRINT expr { $$ = Expr_Print[$2]; }
| T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
@ -630,6 +631,7 @@ static_scalar: /* compile-time evaluated scalars */
| '+' 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]; }
;

File diff suppressed because it is too large Load Diff

View File

@ -236,6 +236,7 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"expr : '@' expr",
"expr : scalar",
"expr : T_ARRAY '(' array_pair_list ')'",
"expr : '[' array_pair_list ']'",
"expr : '`' backticks_expr '`'",
"expr : T_PRINT expr",
"expr : T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'",
@ -287,6 +288,7 @@ class PHPParser_Parser_Debug extends PHPParser_Parser
"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_constant",