mirror of
https://github.com/danog/PHP-Parser.git
synced 2025-01-22 05:41:23 +01:00
Implement UVS
This commit is contained in:
parent
74c57eef0e
commit
d18dcc0c7f
293
grammar/php7.y
293
grammar/php7.y
@ -1,5 +1,5 @@
|
||||
%pure_parser
|
||||
%expect 6
|
||||
%expect 2
|
||||
|
||||
%left T_INCLUDE T_INCLUDE_ONCE T_EVAL T_REQUIRE T_REQUIRE_ONCE
|
||||
%left ','
|
||||
@ -215,7 +215,7 @@ constant_declaration_list:
|
||||
;
|
||||
|
||||
constant_declaration:
|
||||
T_STRING '=' static_scalar { $$ = Node\Const_[$1, $3]; }
|
||||
T_STRING '=' expr { $$ = Node\Const_[$1, $3]; }
|
||||
;
|
||||
|
||||
class_const_list:
|
||||
@ -224,7 +224,7 @@ class_const_list:
|
||||
;
|
||||
|
||||
class_const:
|
||||
identifier '=' static_scalar { $$ = Node\Const_[$1, $3]; }
|
||||
identifier '=' expr { $$ = Node\Const_[$1, $3]; }
|
||||
;
|
||||
|
||||
inner_statement_list:
|
||||
@ -251,12 +251,9 @@ statement:
|
||||
| T_FOR '(' for_expr ';' for_expr ';' for_expr ')' for_statement
|
||||
{ $$ = Stmt\For_[['init' => $3, 'cond' => $5, 'loop' => $7, 'stmts' => $9]]; }
|
||||
| T_SWITCH parentheses_expr switch_case_list { $$ = Stmt\Switch_[$2, $3]; }
|
||||
| T_BREAK ';' { $$ = Stmt\Break_[null]; }
|
||||
| T_BREAK expr ';' { $$ = Stmt\Break_[$2]; }
|
||||
| T_CONTINUE ';' { $$ = Stmt\Continue_[null]; }
|
||||
| T_CONTINUE expr ';' { $$ = Stmt\Continue_[$2]; }
|
||||
| T_RETURN ';' { $$ = Stmt\Return_[null]; }
|
||||
| T_RETURN expr ';' { $$ = Stmt\Return_[$2]; }
|
||||
| T_BREAK optional_expr ';' { $$ = Stmt\Break_[$2]; }
|
||||
| T_CONTINUE optional_expr ';' { $$ = Stmt\Continue_[$2]; }
|
||||
| T_RETURN optional_expr ';' { $$ = Stmt\Return_[$2]; }
|
||||
| yield_expr ';' { $$ = $1; }
|
||||
| T_GLOBAL global_var_list ';' { $$ = Stmt\Global_[$2]; }
|
||||
| T_STATIC static_var_list ';' { $$ = Stmt\Static_[$2]; }
|
||||
@ -369,7 +366,7 @@ declare_list:
|
||||
;
|
||||
|
||||
declare_list_element:
|
||||
T_STRING '=' static_scalar { $$ = Stmt\DeclareDeclare[$1, $3]; }
|
||||
T_STRING '=' expr { $$ = Stmt\DeclareDeclare[$1, $3]; }
|
||||
;
|
||||
|
||||
switch_case_list:
|
||||
@ -446,7 +443,7 @@ non_empty_parameter_list:
|
||||
parameter:
|
||||
optional_param_type optional_ref optional_ellipsis T_VARIABLE
|
||||
{ $$ = Node\Param[parseVar($4), null, $1, $2, $3]; }
|
||||
| optional_param_type optional_ref optional_ellipsis T_VARIABLE '=' static_scalar
|
||||
| optional_param_type optional_ref optional_ellipsis T_VARIABLE '=' expr
|
||||
{ $$ = Node\Param[parseVar($4), $6, $1, $2, $3]; }
|
||||
;
|
||||
|
||||
@ -501,7 +498,7 @@ static_var_list:
|
||||
|
||||
static_var:
|
||||
T_VARIABLE { $$ = Stmt\StaticVar[parseVar($1), null]; }
|
||||
| T_VARIABLE '=' static_scalar { $$ = Stmt\StaticVar[parseVar($1), $3]; }
|
||||
| T_VARIABLE '=' expr { $$ = Stmt\StaticVar[parseVar($1), $3]; }
|
||||
;
|
||||
|
||||
class_statement_list:
|
||||
@ -584,7 +581,7 @@ property_declaration_list:
|
||||
|
||||
property_declaration:
|
||||
T_VARIABLE { $$ = Stmt\PropertyProperty[parseVar($1), null]; }
|
||||
| T_VARIABLE '=' static_scalar { $$ = Stmt\PropertyProperty[parseVar($1), $3]; }
|
||||
| T_VARIABLE '=' expr { $$ = Stmt\PropertyProperty[parseVar($1), $3]; }
|
||||
;
|
||||
|
||||
expr_list:
|
||||
@ -653,8 +650,6 @@ expr:
|
||||
| expr T_IS_GREATER_OR_EQUAL expr { $$ = Expr\BinaryOp\GreaterOrEqual[$1, $3]; }
|
||||
| expr T_INSTANCEOF class_name_reference { $$ = Expr\Instanceof_[$1, $3]; }
|
||||
| parentheses_expr { $$ = $1; }
|
||||
/* we need a separate '(' new_expr ')' rule to avoid problems caused by a s/r conflict */
|
||||
| '(' new_expr ')' { $$ = $2; }
|
||||
| expr '?' expr ':' expr { $$ = Expr\Ternary[$1, $3, $5]; }
|
||||
| expr '?' ':' expr { $$ = Expr\Ternary[$1, null, $4]; }
|
||||
| expr T_COALESCE expr { $$ = Expr\BinaryOp\Coalesce[$1, $3]; }
|
||||
@ -675,8 +670,6 @@ expr:
|
||||
| T_EXIT exit_expr { $$ = Expr\Exit_ [$2]; }
|
||||
| '@' expr { $$ = Expr\ErrorSuppress[$2]; }
|
||||
| scalar { $$ = $1; }
|
||||
| array_expr { $$ = $1; }
|
||||
| scalar_dereference { $$ = $1; }
|
||||
| '`' backticks_expr '`' { $$ = Expr\ShellExec[$2]; }
|
||||
| T_PRINT expr { $$ = Expr\Print_[$2]; }
|
||||
| T_YIELD { $$ = Expr\Yield_[null, null]; }
|
||||
@ -699,20 +692,6 @@ yield_expr:
|
||||
| T_YIELD expr T_DOUBLE_ARROW expr { $$ = Expr\Yield_[$4, $2]; }
|
||||
;
|
||||
|
||||
array_expr:
|
||||
T_ARRAY '(' array_pair_list ')' { $$ = Expr\Array_[$3]; }
|
||||
| '[' array_pair_list ']' { $$ = Expr\Array_[$2]; }
|
||||
;
|
||||
|
||||
scalar_dereference:
|
||||
array_expr '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| T_CONSTANT_ENCAPSED_STRING '[' dim_offset ']'
|
||||
{ $$ = Expr\ArrayDimFetch[Scalar\String_[Scalar\String_::parse($1)], $3]; }
|
||||
| constant '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| scalar_dereference '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
/* alternative array syntax missing intentionally */
|
||||
;
|
||||
|
||||
anonymous_class:
|
||||
T_CLASS ctor_arguments extends_from implements_list '{' class_statement_list '}'
|
||||
{ $$ = array(Stmt\Class_[null, ['type' => 0, 'extends' => $3, 'implements' => $4, 'stmts' => $6]], $2); }
|
||||
@ -739,29 +718,9 @@ lexical_var:
|
||||
|
||||
function_call:
|
||||
name argument_list { $$ = Expr\FuncCall[$1, $2]; }
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier argument_list
|
||||
| callable_expr argument_list { $$ = Expr\FuncCall[$1, $2]; }
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM member_name argument_list
|
||||
{ $$ = Expr\StaticCall[$1, $3, $4]; }
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '{' expr '}' argument_list
|
||||
{ $$ = Expr\StaticCall[$1, $4, $6]; }
|
||||
| static_property argument_list {
|
||||
if ($1 instanceof Node\Expr\StaticPropertyFetch) {
|
||||
$$ = Expr\StaticCall[$1->class, Expr\Variable[$1->name], $2];
|
||||
} elseif ($1 instanceof Node\Expr\ArrayDimFetch) {
|
||||
$tmp = $1;
|
||||
while ($tmp->var instanceof Node\Expr\ArrayDimFetch) {
|
||||
$tmp = $tmp->var;
|
||||
}
|
||||
|
||||
$$ = Expr\StaticCall[$tmp->var->class, $1, $2];
|
||||
$tmp->var = Expr\Variable[$tmp->var->name];
|
||||
} else {
|
||||
throw new \Exception;
|
||||
}
|
||||
}
|
||||
| variable_without_objects argument_list
|
||||
{ $$ = Expr\FuncCall[$1, $2]; }
|
||||
| function_call '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
/* alternative array syntax missing intentionally */
|
||||
;
|
||||
|
||||
class_name:
|
||||
@ -777,26 +736,12 @@ name:
|
||||
|
||||
class_name_reference:
|
||||
class_name { $$ = $1; }
|
||||
| dynamic_class_name_reference { $$ = $1; }
|
||||
;
|
||||
|
||||
dynamic_class_name_reference:
|
||||
object_access_for_dcnr { $$ = $1; }
|
||||
| base_variable { $$ = $1; }
|
||||
| new_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]; }
|
||||
| object_access_for_dcnr T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr\PropertyFetch[$1, $3]; }
|
||||
| object_access_for_dcnr '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| object_access_for_dcnr '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| dereferencable { $$ = $1; }
|
||||
;
|
||||
|
||||
exit_expr:
|
||||
@ -816,10 +761,21 @@ ctor_arguments:
|
||||
| argument_list { $$ = $1; }
|
||||
;
|
||||
|
||||
common_scalar:
|
||||
constant:
|
||||
name { $$ = Expr\ConstFetch[$1]; }
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier
|
||||
{ $$ = Expr\ClassConstFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
dereferencable_scalar:
|
||||
T_ARRAY '(' array_pair_list ')' { $$ = Expr\Array_[$3]; }
|
||||
| '[' array_pair_list ']' { $$ = Expr\Array_[$2]; }
|
||||
| T_CONSTANT_ENCAPSED_STRING { $$ = Scalar\String_[Scalar\String_::parse($1)]; }
|
||||
;
|
||||
|
||||
scalar:
|
||||
T_LNUMBER { $$ = Scalar\LNumber[Scalar\LNumber::parse($1)]; }
|
||||
| T_DNUMBER { $$ = Scalar\DNumber[Scalar\DNumber::parse($1)]; }
|
||||
| T_CONSTANT_ENCAPSED_STRING { $$ = Scalar\String_[Scalar\String_::parse($1)]; }
|
||||
| T_LINE { $$ = Scalar\MagicConst\Line[]; }
|
||||
| T_FILE { $$ = Scalar\MagicConst\File[]; }
|
||||
| T_DIR { $$ = Scalar\MagicConst\Dir[]; }
|
||||
@ -828,161 +784,86 @@ common_scalar:
|
||||
| T_METHOD_C { $$ = Scalar\MagicConst\Method[]; }
|
||||
| T_FUNC_C { $$ = Scalar\MagicConst\Function_[]; }
|
||||
| T_NS_C { $$ = Scalar\MagicConst\Namespace_[]; }
|
||||
| dereferencable_scalar { $$ = $1; }
|
||||
| constant { $$ = $1; }
|
||||
| T_START_HEREDOC T_ENCAPSED_AND_WHITESPACE T_END_HEREDOC
|
||||
{ $$ = Scalar\String_[Scalar\String_::parseDocString($1, $2)]; }
|
||||
| T_START_HEREDOC T_END_HEREDOC
|
||||
{ $$ = Scalar\String_['']; }
|
||||
;
|
||||
|
||||
static_scalar:
|
||||
common_scalar { $$ = $1; }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM identifier { $$ = Expr\ClassConstFetch[$1, $3]; }
|
||||
| name { $$ = Expr\ConstFetch[$1]; }
|
||||
| T_ARRAY '(' static_array_pair_list ')' { $$ = Expr\Array_[$3]; }
|
||||
| '[' static_array_pair_list ']' { $$ = Expr\Array_[$2]; }
|
||||
| static_operation { $$ = $1; }
|
||||
;
|
||||
|
||||
static_operation:
|
||||
static_scalar T_BOOLEAN_OR static_scalar { $$ = Expr\BinaryOp\BooleanOr [$1, $3]; }
|
||||
| static_scalar T_BOOLEAN_AND static_scalar { $$ = Expr\BinaryOp\BooleanAnd[$1, $3]; }
|
||||
| static_scalar T_LOGICAL_OR static_scalar { $$ = Expr\BinaryOp\LogicalOr [$1, $3]; }
|
||||
| static_scalar T_LOGICAL_AND static_scalar { $$ = Expr\BinaryOp\LogicalAnd[$1, $3]; }
|
||||
| static_scalar T_LOGICAL_XOR static_scalar { $$ = Expr\BinaryOp\LogicalXor[$1, $3]; }
|
||||
| static_scalar '|' static_scalar { $$ = Expr\BinaryOp\BitwiseOr [$1, $3]; }
|
||||
| static_scalar '&' static_scalar { $$ = Expr\BinaryOp\BitwiseAnd[$1, $3]; }
|
||||
| static_scalar '^' static_scalar { $$ = Expr\BinaryOp\BitwiseXor[$1, $3]; }
|
||||
| static_scalar '.' static_scalar { $$ = Expr\BinaryOp\Concat [$1, $3]; }
|
||||
| static_scalar '+' static_scalar { $$ = Expr\BinaryOp\Plus [$1, $3]; }
|
||||
| static_scalar '-' static_scalar { $$ = Expr\BinaryOp\Minus [$1, $3]; }
|
||||
| static_scalar '*' static_scalar { $$ = Expr\BinaryOp\Mul [$1, $3]; }
|
||||
| static_scalar '/' static_scalar { $$ = Expr\BinaryOp\Div [$1, $3]; }
|
||||
| static_scalar '%' static_scalar { $$ = Expr\BinaryOp\Mod [$1, $3]; }
|
||||
| static_scalar T_SL static_scalar { $$ = Expr\BinaryOp\ShiftLeft [$1, $3]; }
|
||||
| static_scalar T_SR static_scalar { $$ = Expr\BinaryOp\ShiftRight[$1, $3]; }
|
||||
| static_scalar T_POW static_scalar { $$ = Expr\BinaryOp\Pow [$1, $3]; }
|
||||
| '+' static_scalar %prec T_INC { $$ = Expr\UnaryPlus [$2]; }
|
||||
| '-' static_scalar %prec T_INC { $$ = Expr\UnaryMinus[$2]; }
|
||||
| '!' static_scalar { $$ = Expr\BooleanNot[$2]; }
|
||||
| '~' static_scalar { $$ = Expr\BitwiseNot[$2]; }
|
||||
| static_scalar T_IS_IDENTICAL static_scalar { $$ = Expr\BinaryOp\Identical [$1, $3]; }
|
||||
| static_scalar T_IS_NOT_IDENTICAL static_scalar { $$ = Expr\BinaryOp\NotIdentical [$1, $3]; }
|
||||
| static_scalar T_IS_EQUAL static_scalar { $$ = Expr\BinaryOp\Equal [$1, $3]; }
|
||||
| static_scalar T_IS_NOT_EQUAL static_scalar { $$ = Expr\BinaryOp\NotEqual [$1, $3]; }
|
||||
| static_scalar '<' static_scalar { $$ = Expr\BinaryOp\Smaller [$1, $3]; }
|
||||
| static_scalar T_IS_SMALLER_OR_EQUAL static_scalar { $$ = Expr\BinaryOp\SmallerOrEqual[$1, $3]; }
|
||||
| static_scalar '>' static_scalar { $$ = Expr\BinaryOp\Greater [$1, $3]; }
|
||||
| static_scalar T_IS_GREATER_OR_EQUAL static_scalar { $$ = Expr\BinaryOp\GreaterOrEqual[$1, $3]; }
|
||||
| static_scalar '?' static_scalar ':' static_scalar { $$ = Expr\Ternary[$1, $3, $5]; }
|
||||
| static_scalar '?' ':' static_scalar { $$ = Expr\Ternary[$1, null, $4]; }
|
||||
| static_scalar '[' static_scalar ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| '(' static_scalar ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
constant:
|
||||
name { $$ = Expr\ConstFetch[$1]; }
|
||||
| class_name_or_var T_PAAMAYIM_NEKUDOTAYIM identifier
|
||||
{ $$ = Expr\ClassConstFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
scalar:
|
||||
common_scalar { $$ = $1; }
|
||||
| constant { $$ = $1; }
|
||||
| '"' encaps_list '"'
|
||||
{ parseEncapsed($2, '"'); $$ = Scalar\Encapsed[$2]; }
|
||||
| T_START_HEREDOC encaps_list T_END_HEREDOC
|
||||
{ parseEncapsedDoc($2); $$ = Scalar\Encapsed[$2]; }
|
||||
;
|
||||
|
||||
static_array_pair_list:
|
||||
/* empty */ { $$ = array(); }
|
||||
| non_empty_static_array_pair_list optional_comma { $$ = $1; }
|
||||
;
|
||||
|
||||
optional_comma:
|
||||
/* empty */
|
||||
| ','
|
||||
;
|
||||
|
||||
non_empty_static_array_pair_list:
|
||||
non_empty_static_array_pair_list ',' static_array_pair { push($1, $3); }
|
||||
| static_array_pair { init($1); }
|
||||
;
|
||||
|
||||
static_array_pair:
|
||||
static_scalar T_DOUBLE_ARROW static_scalar { $$ = Expr\ArrayItem[$3, $1, false]; }
|
||||
| static_scalar { $$ = Expr\ArrayItem[$1, null, false]; }
|
||||
;
|
||||
|
||||
variable:
|
||||
object_access { $$ = $1; }
|
||||
| base_variable { $$ = $1; }
|
||||
| function_call { $$ = $1; }
|
||||
| new_expr_array_deref { $$ = $1; }
|
||||
;
|
||||
|
||||
new_expr_array_deref:
|
||||
'(' new_expr ')' '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$2, $5]; }
|
||||
| new_expr_array_deref '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
/* alternative array syntax missing intentionally */
|
||||
;
|
||||
|
||||
object_access:
|
||||
variable_or_new_expr T_OBJECT_OPERATOR object_property
|
||||
{ $$ = Expr\PropertyFetch[$1, $3]; }
|
||||
| variable_or_new_expr T_OBJECT_OPERATOR object_property argument_list
|
||||
{ $$ = Expr\MethodCall[$1, $3, $4]; }
|
||||
| object_access argument_list { $$ = Expr\FuncCall[$1, $2]; }
|
||||
| object_access '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| object_access '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
variable_or_new_expr:
|
||||
variable { $$ = $1; }
|
||||
| '(' new_expr ')' { $$ = $2; }
|
||||
;
|
||||
|
||||
variable_without_objects:
|
||||
reference_variable { $$ = $1; }
|
||||
| '$' variable_without_objects { $$ = Expr\Variable[$2]; }
|
||||
;
|
||||
|
||||
base_variable:
|
||||
variable_without_objects { $$ = $1; }
|
||||
| static_property { $$ = $1; }
|
||||
;
|
||||
|
||||
static_property:
|
||||
class_name_or_var T_PAAMAYIM_NEKUDOTAYIM '$' reference_variable
|
||||
{ $$ = Expr\StaticPropertyFetch[$1, $4]; }
|
||||
| static_property_with_arrays { $$ = $1; }
|
||||
;
|
||||
|
||||
static_property_with_arrays:
|
||||
class_name_or_var T_PAAMAYIM_NEKUDOTAYIM T_VARIABLE
|
||||
{ $$ = Expr\StaticPropertyFetch[$1, parseVar($3)]; }
|
||||
| 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]; }
|
||||
;
|
||||
|
||||
reference_variable:
|
||||
reference_variable '[' dim_offset ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| reference_variable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| T_VARIABLE { $$ = Expr\Variable[parseVar($1)]; }
|
||||
| '$' '{' expr '}' { $$ = Expr\Variable[$3]; }
|
||||
;
|
||||
|
||||
dim_offset:
|
||||
optional_expr:
|
||||
/* empty */ { $$ = null; }
|
||||
| expr { $$ = $1; }
|
||||
;
|
||||
|
||||
object_property:
|
||||
dereferencable:
|
||||
variable { $$ = $1; }
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
| dereferencable_scalar { $$ = $1; }
|
||||
;
|
||||
|
||||
callable_expr:
|
||||
callable_variable { $$ = $1; }
|
||||
| '(' expr ')' { $$ = $2; }
|
||||
| dereferencable_scalar { $$ = $1; }
|
||||
;
|
||||
|
||||
callable_variable:
|
||||
simple_variable { $$ = Expr\Variable[$1]; }
|
||||
| dereferencable '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| constant '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| dereferencable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| function_call { $$ = $1; }
|
||||
| dereferencable T_OBJECT_OPERATOR property_name argument_list
|
||||
{ $$ = Expr\MethodCall[$1, $3, $4]; }
|
||||
;
|
||||
|
||||
variable:
|
||||
callable_variable { $$ = $1; }
|
||||
| static_member { $$ = $1; }
|
||||
| dereferencable T_OBJECT_OPERATOR property_name { $$ = Expr\PropertyFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
simple_variable:
|
||||
T_VARIABLE { $$ = parseVar($1); }
|
||||
| '$' '{' expr '}' { $$ = $3; }
|
||||
| '$' simple_variable { $$ = Expr\Variable[$2]; }
|
||||
;
|
||||
|
||||
static_member:
|
||||
class_name_or_var T_PAAMAYIM_NEKUDOTAYIM simple_variable
|
||||
{ $$ = Expr\StaticPropertyFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
new_variable:
|
||||
simple_variable { $$ = Expr\Variable[$1]; }
|
||||
| new_variable '[' optional_expr ']' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| new_variable '{' expr '}' { $$ = Expr\ArrayDimFetch[$1, $3]; }
|
||||
| new_variable T_OBJECT_OPERATOR property_name { $$ = Expr\PropertyFetch[$1, $3]; }
|
||||
| class_name T_PAAMAYIM_NEKUDOTAYIM simple_variable { $$ = Expr\StaticPropertyFetch[$1, $3]; }
|
||||
| new_variable T_PAAMAYIM_NEKUDOTAYIM simple_variable { $$ = Expr\StaticPropertyFetch[$1, $3]; }
|
||||
;
|
||||
|
||||
member_name:
|
||||
identifier { $$ = $1; }
|
||||
| '{' expr '}' { $$ = $2; }
|
||||
| simple_variable { $$ = Expr\Variable[$1]; }
|
||||
;
|
||||
|
||||
property_name:
|
||||
T_STRING { $$ = $1; }
|
||||
| '{' expr '}' { $$ = $2; }
|
||||
| variable_without_objects { $$ = $1; }
|
||||
| '{' expr '}' { $$ = $2; }
|
||||
| simple_variable { $$ = Expr\Variable[$1]; }
|
||||
;
|
||||
|
||||
list_expr:
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -22,11 +22,30 @@ class ParserTest extends CodeTestAbstract
|
||||
'throwOnError' => false,
|
||||
));
|
||||
|
||||
$output5 = $this->getParseOutput($parser5, $code);
|
||||
$output7 = $this->getParseOutput($parser7, $code);
|
||||
$expected = $this->canonicalize($expected);
|
||||
$mode = null;
|
||||
|
||||
$this->assertSame($this->canonicalize($expected), $output5, $name);
|
||||
$this->assertSame($this->canonicalize($expected), $output7, $name);
|
||||
$firstNewLine = strpos($expected, "\n");
|
||||
if (false !== $firstNewLine) {
|
||||
$firstLine = substr($expected, 0, $firstNewLine);
|
||||
if (substr($firstLine, 0, 2) === '!!') {
|
||||
$mode = substr($firstLine, 2);
|
||||
$expected = substr($expected, $firstNewLine + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode === 'php5') {
|
||||
$output5 = $this->getParseOutput($parser5, $code);
|
||||
$this->assertSame($this->canonicalize($expected), $output5, $name);
|
||||
} else if ($mode === 'php7') {
|
||||
$output7 = $this->getParseOutput($parser7, $code);
|
||||
$this->assertSame($this->canonicalize($expected), $output7, $name);
|
||||
} else {
|
||||
$output5 = $this->getParseOutput($parser5, $code);
|
||||
$this->assertSame($this->canonicalize($expected), $output5, $name);
|
||||
$output7 = $this->getParseOutput($parser7, $code);
|
||||
$this->assertSame($this->canonicalize($expected), $output7, $name);
|
||||
}
|
||||
}
|
||||
|
||||
private function getParseOutput(ParserInterface $parser, $code) {
|
||||
|
@ -17,6 +17,7 @@ $a->$b['c']();
|
||||
$a->b()['c'];
|
||||
$a->b(){'c'}; // invalid PHP: drop Support?
|
||||
-----
|
||||
!!php5
|
||||
array(
|
||||
0: Expr_PropertyFetch(
|
||||
var: Expr_Variable(
|
||||
@ -115,4 +116,4 @@ array(
|
||||
value: c
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -18,6 +18,7 @@ $a::b();
|
||||
${'a'}::b();
|
||||
$a['b']::c();
|
||||
-----
|
||||
!!php5
|
||||
array(
|
||||
0: Expr_StaticCall(
|
||||
class: Name(
|
||||
@ -148,4 +149,4 @@ array(
|
||||
args: array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
@ -9,6 +9,7 @@ $$a;
|
||||
$$$a;
|
||||
$$a['b'];
|
||||
-----
|
||||
!!php5
|
||||
array(
|
||||
0: Expr_Variable(
|
||||
name: a
|
||||
@ -51,4 +52,4 @@ array(
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user