php5 syntax
This commit is contained in:
parent
b1c1bb6dc6
commit
fbe20bbbb6
4090
php5/php5.go
4090
php5/php5.go
File diff suppressed because it is too large
Load Diff
540
php5/php5.y
540
php5/php5.y
@ -3,7 +3,7 @@ package php5
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
// "fmt"
|
// "fmt"
|
||||||
// "strings"
|
"strings"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/z7zmey/php-parser/token"
|
"github.com/z7zmey/php-parser/token"
|
||||||
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/z7zmey/php-parser/node/stmt"
|
"github.com/z7zmey/php-parser/node/stmt"
|
||||||
"github.com/z7zmey/php-parser/node/expr"
|
"github.com/z7zmey/php-parser/node/expr"
|
||||||
"github.com/z7zmey/php-parser/node/expr/assign_op"
|
"github.com/z7zmey/php-parser/node/expr/assign_op"
|
||||||
// "github.com/z7zmey/php-parser/node/expr/binary_op"
|
"github.com/z7zmey/php-parser/node/expr/binary_op"
|
||||||
// "github.com/z7zmey/php-parser/node/expr/cast"
|
"github.com/z7zmey/php-parser/node/expr/cast"
|
||||||
)
|
)
|
||||||
|
|
||||||
%}
|
%}
|
||||||
@ -217,7 +217,7 @@ import (
|
|||||||
%type <list> non_empty_additional_catches parameter_list non_empty_parameter_list class_statement_list implements_list
|
%type <list> non_empty_additional_catches parameter_list non_empty_parameter_list class_statement_list implements_list
|
||||||
%type <list> class_statement_list variable_modifiers method_modifiers class_variable_declaration interface_extends_list
|
%type <list> class_statement_list variable_modifiers method_modifiers class_variable_declaration interface_extends_list
|
||||||
%type <list> interface_list non_empty_function_call_parameter_list trait_list trait_adaptation_list non_empty_trait_adaptation_list
|
%type <list> interface_list non_empty_function_call_parameter_list trait_list trait_adaptation_list non_empty_trait_adaptation_list
|
||||||
%type <list> trait_reference_list non_empty_member_modifiers
|
%type <list> trait_reference_list non_empty_member_modifiers backticks_expr
|
||||||
|
|
||||||
%type <list> chaining_dereference chaining_instance_call chaining_method_or_property instance_call variable_property
|
%type <list> chaining_dereference chaining_instance_call chaining_method_or_property instance_call variable_property
|
||||||
%type <list> method_or_not array_method_dereference object_property object_dim_list dynamic_class_name_variable_property
|
%type <list> method_or_not array_method_dereference object_property object_dim_list dynamic_class_name_variable_property
|
||||||
@ -1825,57 +1825,317 @@ expr_without_variable:
|
|||||||
comments.AddComments(list, $1.Comments())
|
comments.AddComments(list, $1.Comments())
|
||||||
comments.AddComments($$, $1.Comments())
|
comments.AddComments($$, $1.Comments())
|
||||||
}
|
}
|
||||||
| variable '=' expr { }
|
| variable '=' expr
|
||||||
| variable '=' '&' variable { }
|
{
|
||||||
| variable '=' '&' T_NEW class_name_reference { } ctor_arguments { }
|
$$ = assign_op.NewAssign($1, $3)
|
||||||
| T_CLONE expr { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
| variable T_PLUS_EQUAL expr { }
|
comments.AddComments($$, comments[$1])
|
||||||
| variable T_MINUS_EQUAL expr { }
|
}
|
||||||
| variable T_MUL_EQUAL expr { }
|
| variable '=' '&' variable
|
||||||
| variable T_POW_EQUAL expr { }
|
{
|
||||||
| variable T_DIV_EQUAL expr { }
|
$$ = assign_op.NewAssignRef($1, $4)
|
||||||
| variable T_CONCAT_EQUAL expr { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $4))
|
||||||
| variable T_MOD_EQUAL expr { }
|
comments.AddComments($$, comments[$1])
|
||||||
| variable T_AND_EQUAL expr { }
|
}
|
||||||
| variable T_OR_EQUAL expr { }
|
| variable '=' '&' T_NEW class_name_reference ctor_arguments
|
||||||
| variable T_XOR_EQUAL expr { }
|
{
|
||||||
| variable T_SL_EQUAL expr { }
|
_new := expr.NewNew($5, nil)
|
||||||
| variable T_SR_EQUAL expr { }
|
positions.AddPosition(_new, positionBuilder.NewTokenNodePosition($4, $5))
|
||||||
| rw_variable T_INC { }
|
|
||||||
| T_INC rw_variable { }
|
if $6 != nil {
|
||||||
| rw_variable T_DEC { }
|
_new := expr.NewNew($5, $6.nodes)
|
||||||
| T_DEC rw_variable { }
|
positions.AddPosition(_new, positionBuilder.NewTokensPosition($4, $6.endToken))
|
||||||
| expr T_BOOLEAN_OR { } expr { }
|
}
|
||||||
| expr T_BOOLEAN_AND { } expr { }
|
comments.AddComments(_new, comments[$1])
|
||||||
| expr T_LOGICAL_OR { } expr { }
|
|
||||||
| expr T_LOGICAL_AND { } expr { }
|
$$ = assign_op.NewAssignRef($1, _new)
|
||||||
| expr T_LOGICAL_XOR expr { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, _new))
|
||||||
| expr '|' expr { }
|
comments.AddComments($$, comments[$1])
|
||||||
| expr '&' expr { }
|
}
|
||||||
| expr '^' expr { }
|
| T_CLONE expr
|
||||||
| expr '.' expr { }
|
{
|
||||||
| expr '+' expr { }
|
$$ = expr.NewClone($2)
|
||||||
| expr '-' expr { }
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
| expr '*' expr { }
|
comments.AddComments($$, $1.Comments())
|
||||||
| expr T_POW expr { }
|
}
|
||||||
| expr '/' expr { }
|
| variable T_PLUS_EQUAL expr
|
||||||
| expr '%' expr { }
|
{
|
||||||
| expr T_SL expr { }
|
$$ = assign_op.NewPlus($1, $3)
|
||||||
| expr T_SR expr { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
| '+' expr %prec T_INC { }
|
comments.AddComments($$, comments[$1])
|
||||||
| '-' expr %prec T_INC { }
|
}
|
||||||
| '!' expr { }
|
| variable T_MINUS_EQUAL expr
|
||||||
| '~' expr { }
|
{
|
||||||
| expr T_IS_IDENTICAL expr { }
|
$$ = assign_op.NewMinus($1, $3)
|
||||||
| expr T_IS_NOT_IDENTICAL expr { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
| expr T_IS_EQUAL expr { }
|
comments.AddComments($$, comments[$1])
|
||||||
| expr T_IS_NOT_EQUAL expr { }
|
}
|
||||||
| expr '<' expr { }
|
| variable T_MUL_EQUAL expr
|
||||||
| expr T_IS_SMALLER_OR_EQUAL expr { }
|
{
|
||||||
| expr '>' expr { }
|
$$ = assign_op.NewMul($1, $3)
|
||||||
| expr T_IS_GREATER_OR_EQUAL expr { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
| expr T_INSTANCEOF class_name_reference { }
|
comments.AddComments($$, comments[$1])
|
||||||
| parenthesis_expr { }
|
}
|
||||||
|
| variable T_POW_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewPow($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_DIV_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewDiv($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_CONCAT_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewConcat($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_MOD_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewMod($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_AND_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewBitwiseAnd($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_OR_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewBitwiseOr($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_XOR_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewBitwiseXor($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_SL_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewShiftLeft($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| variable T_SR_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = assign_op.NewShiftRight($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| rw_variable T_INC
|
||||||
|
{
|
||||||
|
$$ = expr.NewPostInc($1)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodeTokenPosition($1, $2))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| T_INC rw_variable
|
||||||
|
{
|
||||||
|
$$ = expr.NewPreInc($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| rw_variable T_DEC
|
||||||
|
{
|
||||||
|
$$ = expr.NewPostDec($1)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodeTokenPosition($1, $2))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| T_DEC rw_variable
|
||||||
|
{
|
||||||
|
$$ = expr.NewPreDec($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| expr T_BOOLEAN_OR expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewBooleanOr($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_BOOLEAN_AND expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewBooleanAnd($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_LOGICAL_OR expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewLogicalOr($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_LOGICAL_AND expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewLogicalAnd($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_LOGICAL_XOR expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewLogicalXor($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '|' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewBitwiseOr($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '&' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewBitwiseAnd($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '^' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewBitwiseXor($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '.' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewConcat($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '+' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewPlus($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '-' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewMinus($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '*' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewMul($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_POW expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewPow($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '/' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewDiv($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '%' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewMod($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_SL expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewShiftLeft($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_SR expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewShiftRight($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| '+' expr %prec T_INC
|
||||||
|
{
|
||||||
|
$$ = expr.NewUnaryPlus($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| '-' expr %prec T_INC
|
||||||
|
{
|
||||||
|
$$ = expr.NewUnaryMinus($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| '!' expr
|
||||||
|
{
|
||||||
|
$$ = expr.NewBooleanNot($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| '~' expr
|
||||||
|
{
|
||||||
|
$$ = expr.NewBitwiseNot($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| expr T_IS_IDENTICAL expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewIdentical($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_IS_NOT_IDENTICAL expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewNotIdentical($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_IS_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewEqual($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_IS_NOT_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewNotEqual($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '<' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewSmaller($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_IS_SMALLER_OR_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewSmallerOrEqual($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr '>' expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewGreater($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_IS_GREATER_OR_EQUAL expr
|
||||||
|
{
|
||||||
|
$$ = binary_op.NewGreaterOrEqual($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| expr T_INSTANCEOF class_name_reference
|
||||||
|
{
|
||||||
|
$$ = expr.NewInstanceOf($1, $3)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $3))
|
||||||
|
comments.AddComments($$, comments[$1])
|
||||||
|
}
|
||||||
|
| parenthesis_expr
|
||||||
|
{ $$ = $1 }
|
||||||
| new_expr
|
| new_expr
|
||||||
{ $$ = $1 }
|
{ $$ = $1 }
|
||||||
| '(' new_expr ')' instance_call
|
| '(' new_expr ')' instance_call
|
||||||
@ -1904,40 +2164,139 @@ expr_without_variable:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
| expr '?' { }
|
| expr '?' expr ':' expr
|
||||||
expr ':' { }
|
{
|
||||||
expr { }
|
$$ = expr.NewTernary($1, $3, $5)
|
||||||
| expr '?' ':' { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $5))
|
||||||
expr { }
|
comments.AddComments($$, comments[$1])
|
||||||
| internal_functions_in_yacc { }
|
}
|
||||||
| T_INT_CAST expr { }
|
| expr '?' ':' expr
|
||||||
| T_DOUBLE_CAST expr { }
|
{
|
||||||
| T_STRING_CAST expr { }
|
$$ = expr.NewTernary($1, nil, $4)
|
||||||
| T_ARRAY_CAST expr { }
|
positions.AddPosition($$, positionBuilder.NewNodesPosition($1, $4))
|
||||||
| T_OBJECT_CAST expr { }
|
comments.AddComments($$, comments[$1])
|
||||||
| T_BOOL_CAST expr { }
|
}
|
||||||
| T_UNSET_CAST expr { }
|
| internal_functions_in_yacc
|
||||||
| T_EXIT exit_expr { }
|
{ $$ = $1 }
|
||||||
| '@' { } expr { }
|
| T_INT_CAST expr
|
||||||
| scalar { $$ = $1 }
|
{
|
||||||
| combined_scalar_offset { }
|
$$ = cast.NewCastInt($2)
|
||||||
| combined_scalar { }
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
| '`' backticks_expr '`' { }
|
comments.AddComments($$, $1.Comments())
|
||||||
| T_PRINT expr { }
|
}
|
||||||
| T_YIELD { }
|
| T_DOUBLE_CAST expr
|
||||||
| function is_reference { }
|
{
|
||||||
'(' parameter_list ')' lexical_vars
|
$$ = cast.NewCastDouble($2)
|
||||||
'{' inner_statement_list '}' { }
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
| T_STATIC function is_reference { }
|
comments.AddComments($$, $1.Comments())
|
||||||
'(' parameter_list ')' lexical_vars
|
}
|
||||||
'{' inner_statement_list '}' { }
|
| T_STRING_CAST expr
|
||||||
|
{
|
||||||
|
$$ = cast.NewCastString($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_ARRAY_CAST expr
|
||||||
|
{
|
||||||
|
$$ = cast.NewCastArray($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_OBJECT_CAST expr
|
||||||
|
{
|
||||||
|
$$ = cast.NewCastObject($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_BOOL_CAST expr
|
||||||
|
{
|
||||||
|
$$ = cast.NewCastBool($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_UNSET_CAST expr
|
||||||
|
{
|
||||||
|
$$ = cast.NewCastUnset($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_EXIT exit_expr
|
||||||
|
{
|
||||||
|
$$ = expr.NewExit($2, strings.EqualFold($1.Value, "die"))
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| '@' expr
|
||||||
|
{
|
||||||
|
$$ = expr.NewErrorSuppress($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| scalar
|
||||||
|
{ $$ = $1 }
|
||||||
|
| combined_scalar_offset
|
||||||
|
{ $$ = $1 }
|
||||||
|
| combined_scalar
|
||||||
|
{ $$ = $1 }
|
||||||
|
| '`' backticks_expr '`'
|
||||||
|
{
|
||||||
|
$$ = expr.NewShellExec($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokensPosition($1, $3))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_PRINT expr
|
||||||
|
{
|
||||||
|
$$ = expr.NewPrint($2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_YIELD
|
||||||
|
{
|
||||||
|
$$ = expr.NewYield(nil, nil)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenPosition($1))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||||
|
{
|
||||||
|
$$ = expr.NewClosure($4, $6, nil, $8, false, $2.value, "")
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokensPosition($1, $9))
|
||||||
|
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_STATIC function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||||
|
{
|
||||||
|
$$ = expr.NewClosure($5, $7, nil, $9, true, $3.value, "")
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokensPosition($1, $10))
|
||||||
|
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
yield_expr:
|
yield_expr:
|
||||||
T_YIELD expr_without_variable { }
|
T_YIELD expr_without_variable
|
||||||
| T_YIELD variable { }
|
{
|
||||||
| T_YIELD expr T_DOUBLE_ARROW expr_without_variable { }
|
$$ = expr.NewYield(nil, $2)
|
||||||
| T_YIELD expr T_DOUBLE_ARROW variable { }
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_YIELD variable
|
||||||
|
{
|
||||||
|
$$ = expr.NewYield(nil, $2)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $2))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_YIELD expr T_DOUBLE_ARROW expr_without_variable
|
||||||
|
{
|
||||||
|
$$ = expr.NewYield($2, $4)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $4))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
|
| T_YIELD expr T_DOUBLE_ARROW variable
|
||||||
|
{
|
||||||
|
$$ = expr.NewYield($2, $4)
|
||||||
|
positions.AddPosition($$, positionBuilder.NewTokenNodePosition($1, $4))
|
||||||
|
comments.AddComments($$, $1.Comments())
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
combined_scalar_offset:
|
combined_scalar_offset:
|
||||||
@ -2260,9 +2619,12 @@ exit_expr:
|
|||||||
;
|
;
|
||||||
|
|
||||||
backticks_expr:
|
backticks_expr:
|
||||||
/* empty */ { }
|
/* empty */
|
||||||
| T_ENCAPSED_AND_WHITESPACE { }
|
{ $$ = []node.Node{} }
|
||||||
| encaps_list { }
|
| T_ENCAPSED_AND_WHITESPACE
|
||||||
|
{ $$ = []node.Node{scalar.NewEncapsedStringPart($1.Value)} }
|
||||||
|
| encaps_list
|
||||||
|
{ $$ = $1; }
|
||||||
;
|
;
|
||||||
|
|
||||||
ctor_arguments:
|
ctor_arguments:
|
||||||
|
Loading…
Reference in New Issue
Block a user