use empty *expr.ArrayItem to represent missed a list and array items.
This commit is contained in:
15
php5/php5.go
15
php5/php5.go
@@ -347,6 +347,7 @@ const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
//line php5/php5.y:6795
|
||||
|
||||
type simpleIndirectReference struct {
|
||||
all []*expr.Variable
|
||||
last *expr.Variable
|
||||
@@ -8741,15 +8742,15 @@ yydefault:
|
||||
//line php5/php5.y:6190
|
||||
{
|
||||
if len(yyDollar[1].list) == 0 {
|
||||
yyDollar[1].list = []node.Node{nil}
|
||||
yyDollar[1].list = []node.Node{expr.NewArrayItem(nil, nil)}
|
||||
}
|
||||
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
// save comments
|
||||
if lastNode(yyDollar[1].list) != nil {
|
||||
lastNode(yyDollar[1].list).AddComments(yyDollar[2].token.Comments, comment.CommaToken)
|
||||
}
|
||||
// if lastNode($1) != nil {
|
||||
lastNode(yyDollar[1].list).AddComments(yyDollar[2].token.Comments, comment.CommaToken)
|
||||
// }
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@@ -8757,7 +8758,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6205
|
||||
{
|
||||
if yyDollar[1].node == nil {
|
||||
if yyDollar[1].node.(*expr.ArrayItem).Key == nil && yyDollar[1].node.(*expr.ArrayItem).Val == nil {
|
||||
yyVAL.list = []node.Node{}
|
||||
} else {
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
@@ -8798,7 +8799,7 @@ yydefault:
|
||||
yyDollar = yyS[yypt-0 : yypt+1]
|
||||
//line php5/php5.y:6244
|
||||
{
|
||||
yyVAL.node = nil
|
||||
yyVAL.node = expr.NewArrayItem(nil, nil)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@@ -8817,7 +8818,7 @@ yydefault:
|
||||
yyVAL.list = yyDollar[1].list
|
||||
|
||||
if yyDollar[2].token != nil {
|
||||
yyVAL.list = append(yyDollar[1].list, nil)
|
||||
yyVAL.list = append(yyDollar[1].list, expr.NewArrayItem(nil, nil))
|
||||
}
|
||||
|
||||
// save comments
|
||||
|
||||
12
php5/php5.y
12
php5/php5.y
@@ -6189,21 +6189,19 @@ assignment_list:
|
||||
assignment_list ',' assignment_list_element
|
||||
{
|
||||
if len($1) == 0 {
|
||||
$1 = []node.Node{nil}
|
||||
$1 = []node.Node{expr.NewArrayItem(nil, nil)}
|
||||
}
|
||||
|
||||
$$ = append($1, $3)
|
||||
|
||||
// save comments
|
||||
if lastNode($1) != nil {
|
||||
lastNode($1).AddComments($2.Comments, comment.CommaToken)
|
||||
}
|
||||
lastNode($1).AddComments($2.Comments, comment.CommaToken)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
| assignment_list_element
|
||||
{
|
||||
if $1 == nil {
|
||||
if $1.(*expr.ArrayItem).Key == nil && $1.(*expr.ArrayItem).Val == nil {
|
||||
$$ = []node.Node{}
|
||||
} else {
|
||||
$$ = []node.Node{$1}
|
||||
@@ -6242,7 +6240,7 @@ assignment_list_element:
|
||||
}
|
||||
| /* empty */
|
||||
{
|
||||
$$ = nil
|
||||
$$ = expr.NewArrayItem(nil, nil)
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
@@ -6261,7 +6259,7 @@ array_pair_list:
|
||||
$$ = $1
|
||||
|
||||
if $2 != nil {
|
||||
$$ = append($1, nil)
|
||||
$$ = append($1, expr.NewArrayItem(nil, nil))
|
||||
}
|
||||
|
||||
// save comments
|
||||
|
||||
@@ -8216,7 +8216,7 @@ func TestPhp5(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
&expr.ArrayItem{},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -11019,7 +11019,7 @@ func TestPhp5(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
nil,
|
||||
&expr.ArrayItem{},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user