#44: fix crash on an empty list item
This commit is contained in:
parent
26117164d8
commit
10c63a30ae
@ -141,3 +141,35 @@ func TestListList(t *testing.T) {
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestListEmptyItem(t *testing.T) {
|
||||
src := `<? list(, $a) = $b;`
|
||||
|
||||
expected := &node.Root{
|
||||
Stmts: []node.Node{
|
||||
&stmt.Expression{
|
||||
Expr: &assign.Assign{
|
||||
Variable: &expr.List{
|
||||
Items: []node.Node{
|
||||
nil,
|
||||
&expr.ArrayItem{
|
||||
Val: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
Expression: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php7parser.Parse()
|
||||
actual := php7parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
|
||||
php5parser := php5.NewParser(bytes.NewBufferString(src), "test.php")
|
||||
php5parser.Parse()
|
||||
actual = php5parser.GetRootNode()
|
||||
assertEqual(t, expected, actual)
|
||||
}
|
||||
|
@ -108,6 +108,9 @@ func (l *Parser) GetPositions() parser.Positions {
|
||||
// helpers
|
||||
|
||||
func lastNode(nn []node.Node) node.Node {
|
||||
if len(nn) == 0 {
|
||||
return nil
|
||||
}
|
||||
return nn[len(nn)-1]
|
||||
}
|
||||
|
||||
|
99
php5/php5.go
99
php5/php5.go
@ -346,7 +346,8 @@ const yyEofCode = 1
|
||||
const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
//line php5/php5.y:6782
|
||||
//line php5/php5.y:6788
|
||||
|
||||
type simpleIndirectReference struct {
|
||||
all []*expr.Variable
|
||||
last *expr.Variable
|
||||
@ -8737,16 +8738,22 @@ yydefault:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6187
|
||||
{
|
||||
if len(yyDollar[1].list) == 0 {
|
||||
yyDollar[1].list = []node.Node{nil}
|
||||
}
|
||||
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken)
|
||||
if lastNode(yyDollar[1].list) != nil {
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken)
|
||||
}
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
case 477:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6196
|
||||
//line php5/php5.y:6202
|
||||
{
|
||||
if yyDollar[1].node == nil {
|
||||
yyVAL.list = []node.Node{}
|
||||
@ -8758,7 +8765,7 @@ yydefault:
|
||||
}
|
||||
case 478:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6210
|
||||
//line php5/php5.y:6216
|
||||
{
|
||||
yyVAL.node = expr.NewArrayItem(nil, yyDollar[1].node)
|
||||
|
||||
@ -8769,7 +8776,7 @@ yydefault:
|
||||
}
|
||||
case 479:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6219
|
||||
//line php5/php5.y:6225
|
||||
{
|
||||
item := expr.NewList(yyDollar[3].list)
|
||||
yyVAL.node = expr.NewArrayItem(nil, item)
|
||||
@ -8787,7 +8794,7 @@ yydefault:
|
||||
}
|
||||
case 480:
|
||||
yyDollar = yyS[yypt-0 : yypt+1]
|
||||
//line php5/php5.y:6235
|
||||
//line php5/php5.y:6241
|
||||
{
|
||||
yyVAL.node = nil
|
||||
|
||||
@ -8795,7 +8802,7 @@ yydefault:
|
||||
}
|
||||
case 481:
|
||||
yyDollar = yyS[yypt-0 : yypt+1]
|
||||
//line php5/php5.y:6245
|
||||
//line php5/php5.y:6251
|
||||
{
|
||||
yyVAL.list = []node.Node{}
|
||||
|
||||
@ -8803,7 +8810,7 @@ yydefault:
|
||||
}
|
||||
case 482:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6251
|
||||
//line php5/php5.y:6257
|
||||
{
|
||||
yyVAL.list = yyDollar[1].list
|
||||
|
||||
@ -8816,7 +8823,7 @@ yydefault:
|
||||
}
|
||||
case 483:
|
||||
yyDollar = yyS[yypt-5 : yypt+1]
|
||||
//line php5/php5.y:6265
|
||||
//line php5/php5.y:6271
|
||||
{
|
||||
arrayItem := expr.NewArrayItem(yyDollar[3].node, yyDollar[5].node)
|
||||
yyVAL.list = append(yyDollar[1].list, arrayItem)
|
||||
@ -8832,7 +8839,7 @@ yydefault:
|
||||
}
|
||||
case 484:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6279
|
||||
//line php5/php5.y:6285
|
||||
{
|
||||
arrayItem := expr.NewArrayItem(nil, yyDollar[3].node)
|
||||
yyVAL.list = append(yyDollar[1].list, arrayItem)
|
||||
@ -8847,7 +8854,7 @@ yydefault:
|
||||
}
|
||||
case 485:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6292
|
||||
//line php5/php5.y:6298
|
||||
{
|
||||
arrayItem := expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node)
|
||||
yyVAL.list = []node.Node{arrayItem}
|
||||
@ -8862,7 +8869,7 @@ yydefault:
|
||||
}
|
||||
case 486:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6305
|
||||
//line php5/php5.y:6311
|
||||
{
|
||||
arrayItem := expr.NewArrayItem(nil, yyDollar[1].node)
|
||||
yyVAL.list = []node.Node{arrayItem}
|
||||
@ -8874,7 +8881,7 @@ yydefault:
|
||||
}
|
||||
case 487:
|
||||
yyDollar = yyS[yypt-6 : yypt+1]
|
||||
//line php5/php5.y:6315
|
||||
//line php5/php5.y:6321
|
||||
{
|
||||
reference := expr.NewReference(yyDollar[6].node)
|
||||
arrayItem := expr.NewArrayItem(yyDollar[3].node, reference)
|
||||
@ -8893,7 +8900,7 @@ yydefault:
|
||||
}
|
||||
case 488:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6332
|
||||
//line php5/php5.y:6338
|
||||
{
|
||||
reference := expr.NewReference(yyDollar[4].node)
|
||||
arrayItem := expr.NewArrayItem(nil, reference)
|
||||
@ -8911,7 +8918,7 @@ yydefault:
|
||||
}
|
||||
case 489:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6348
|
||||
//line php5/php5.y:6354
|
||||
{
|
||||
reference := expr.NewReference(yyDollar[4].node)
|
||||
arrayItem := expr.NewArrayItem(yyDollar[1].node, reference)
|
||||
@ -8929,7 +8936,7 @@ yydefault:
|
||||
}
|
||||
case 490:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6364
|
||||
//line php5/php5.y:6370
|
||||
{
|
||||
reference := expr.NewReference(yyDollar[2].node)
|
||||
arrayItem := expr.NewArrayItem(nil, reference)
|
||||
@ -8946,7 +8953,7 @@ yydefault:
|
||||
}
|
||||
case 491:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6382
|
||||
//line php5/php5.y:6388
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[2].node)
|
||||
|
||||
@ -8954,7 +8961,7 @@ yydefault:
|
||||
}
|
||||
case 492:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6388
|
||||
//line php5/php5.y:6394
|
||||
{
|
||||
encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value)
|
||||
yyVAL.list = append(yyDollar[1].list, encapsed)
|
||||
@ -8969,7 +8976,7 @@ yydefault:
|
||||
}
|
||||
case 493:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6401
|
||||
//line php5/php5.y:6407
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -8977,7 +8984,7 @@ yydefault:
|
||||
}
|
||||
case 494:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6407
|
||||
//line php5/php5.y:6413
|
||||
{
|
||||
encapsed := scalar.NewEncapsedStringPart(yyDollar[1].token.Value)
|
||||
yyVAL.list = []node.Node{encapsed, yyDollar[2].node}
|
||||
@ -8992,7 +8999,7 @@ yydefault:
|
||||
}
|
||||
case 495:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6423
|
||||
//line php5/php5.y:6429
|
||||
{
|
||||
name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(name)
|
||||
@ -9008,7 +9015,7 @@ yydefault:
|
||||
}
|
||||
case 496:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6437
|
||||
//line php5/php5.y:6443
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
variable := expr.NewVariable(identifier)
|
||||
@ -9028,7 +9035,7 @@ yydefault:
|
||||
}
|
||||
case 497:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6455
|
||||
//line php5/php5.y:6461
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
variable := expr.NewVariable(identifier)
|
||||
@ -9050,7 +9057,7 @@ yydefault:
|
||||
}
|
||||
case 498:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6475
|
||||
//line php5/php5.y:6481
|
||||
{
|
||||
yyVAL.node = expr.NewVariable(yyDollar[2].node)
|
||||
|
||||
@ -9065,7 +9072,7 @@ yydefault:
|
||||
}
|
||||
case 499:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6488
|
||||
//line php5/php5.y:6494
|
||||
{
|
||||
name := node.NewIdentifier(yyDollar[2].token.Value)
|
||||
yyVAL.node = expr.NewVariable(name)
|
||||
@ -9083,7 +9090,7 @@ yydefault:
|
||||
}
|
||||
case 500:
|
||||
yyDollar = yyS[yypt-6 : yypt+1]
|
||||
//line php5/php5.y:6504
|
||||
//line php5/php5.y:6510
|
||||
{
|
||||
identifier := node.NewIdentifier(yyDollar[2].token.Value)
|
||||
variable := expr.NewVariable(identifier)
|
||||
@ -9105,7 +9112,7 @@ yydefault:
|
||||
}
|
||||
case 501:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6524
|
||||
//line php5/php5.y:6530
|
||||
{
|
||||
yyVAL.node = yyDollar[2].node
|
||||
|
||||
@ -9113,7 +9120,7 @@ yydefault:
|
||||
}
|
||||
case 502:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6533
|
||||
//line php5/php5.y:6539
|
||||
{
|
||||
yyVAL.node = scalar.NewString(yyDollar[1].token.Value)
|
||||
|
||||
@ -9127,7 +9134,7 @@ yydefault:
|
||||
}
|
||||
case 503:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6545
|
||||
//line php5/php5.y:6551
|
||||
{
|
||||
// TODO: add option to handle 64 bit integer
|
||||
if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil {
|
||||
@ -9146,7 +9153,7 @@ yydefault:
|
||||
}
|
||||
case 504:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6562
|
||||
//line php5/php5.y:6568
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(identifier)
|
||||
@ -9162,7 +9169,7 @@ yydefault:
|
||||
}
|
||||
case 505:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6579
|
||||
//line php5/php5.y:6585
|
||||
{
|
||||
yyVAL.node = expr.NewIsset(yyDollar[3].list)
|
||||
|
||||
@ -9178,7 +9185,7 @@ yydefault:
|
||||
}
|
||||
case 506:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6593
|
||||
//line php5/php5.y:6599
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -9194,7 +9201,7 @@ yydefault:
|
||||
}
|
||||
case 507:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6607
|
||||
//line php5/php5.y:6613
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -9210,7 +9217,7 @@ yydefault:
|
||||
}
|
||||
case 508:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6621
|
||||
//line php5/php5.y:6627
|
||||
{
|
||||
yyVAL.node = expr.NewInclude(yyDollar[2].node)
|
||||
|
||||
@ -9224,7 +9231,7 @@ yydefault:
|
||||
}
|
||||
case 509:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6633
|
||||
//line php5/php5.y:6639
|
||||
{
|
||||
yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node)
|
||||
|
||||
@ -9238,7 +9245,7 @@ yydefault:
|
||||
}
|
||||
case 510:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php5/php5.y:6645
|
||||
//line php5/php5.y:6651
|
||||
{
|
||||
yyVAL.node = expr.NewEval(yyDollar[3].node)
|
||||
|
||||
@ -9254,7 +9261,7 @@ yydefault:
|
||||
}
|
||||
case 511:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6659
|
||||
//line php5/php5.y:6665
|
||||
{
|
||||
yyVAL.node = expr.NewRequire(yyDollar[2].node)
|
||||
|
||||
@ -9268,7 +9275,7 @@ yydefault:
|
||||
}
|
||||
case 512:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php5/php5.y:6671
|
||||
//line php5/php5.y:6677
|
||||
{
|
||||
yyVAL.node = expr.NewRequireOnce(yyDollar[2].node)
|
||||
|
||||
@ -9282,7 +9289,7 @@ yydefault:
|
||||
}
|
||||
case 513:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6686
|
||||
//line php5/php5.y:6692
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -9290,7 +9297,7 @@ yydefault:
|
||||
}
|
||||
case 514:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6692
|
||||
//line php5/php5.y:6698
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
@ -9301,7 +9308,7 @@ yydefault:
|
||||
}
|
||||
case 515:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6704
|
||||
//line php5/php5.y:6710
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
@ -9309,7 +9316,7 @@ yydefault:
|
||||
}
|
||||
case 516:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php5/php5.y:6710
|
||||
//line php5/php5.y:6716
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
@ -9317,7 +9324,7 @@ yydefault:
|
||||
}
|
||||
case 517:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6719
|
||||
//line php5/php5.y:6725
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9333,7 +9340,7 @@ yydefault:
|
||||
}
|
||||
case 518:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6733
|
||||
//line php5/php5.y:6739
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9349,7 +9356,7 @@ yydefault:
|
||||
}
|
||||
case 519:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6750
|
||||
//line php5/php5.y:6756
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
@ -9365,7 +9372,7 @@ yydefault:
|
||||
}
|
||||
case 520:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php5/php5.y:6767
|
||||
//line php5/php5.y:6773
|
||||
{
|
||||
target := node.NewIdentifier(yyDollar[3].token.Value)
|
||||
yyVAL.node = expr.NewClassConstFetch(yyDollar[1].node, target)
|
||||
|
@ -6185,10 +6185,16 @@ simple_indirect_reference:
|
||||
assignment_list:
|
||||
assignment_list ',' assignment_list_element
|
||||
{
|
||||
if len($1) == 0 {
|
||||
$1 = []node.Node{nil}
|
||||
}
|
||||
|
||||
$$ = append($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken)
|
||||
if lastNode($1) != nil {
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken)
|
||||
}
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
|
@ -97,6 +97,9 @@ func (l *Parser) GetPositions() parser.Positions {
|
||||
// helpers
|
||||
|
||||
func lastNode(nn []node.Node) node.Node {
|
||||
if len(nn) == 0 {
|
||||
return nil
|
||||
}
|
||||
return nn[len(nn)-1]
|
||||
}
|
||||
|
||||
|
70
php7/php7.go
70
php7/php7.go
@ -346,7 +346,7 @@ const yyEofCode = 1
|
||||
const yyErrCode = 2
|
||||
const yyInitialStackSize = 16
|
||||
|
||||
//line php7/php7.y:5344
|
||||
//line php7/php7.y:5346
|
||||
|
||||
//line yacctab:1
|
||||
var yyExca = [...]int{
|
||||
@ -7548,13 +7548,15 @@ yydefault:
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken)
|
||||
if lastNode(yyDollar[1].list) != nil {
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode(yyDollar[1].list), yyDollar[2].token, comment.CommaToken)
|
||||
}
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
case 458:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:4898
|
||||
//line php7/php7.y:4900
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -7562,7 +7564,7 @@ yydefault:
|
||||
}
|
||||
case 459:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:4907
|
||||
//line php7/php7.y:4909
|
||||
{
|
||||
yyVAL.node = expr.NewArrayItem(yyDollar[1].node, yyDollar[3].node)
|
||||
|
||||
@ -7576,7 +7578,7 @@ yydefault:
|
||||
}
|
||||
case 460:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:4919
|
||||
//line php7/php7.y:4921
|
||||
{
|
||||
yyVAL.node = expr.NewArrayItem(nil, yyDollar[1].node)
|
||||
|
||||
@ -7587,7 +7589,7 @@ yydefault:
|
||||
}
|
||||
case 461:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:4928
|
||||
//line php7/php7.y:4930
|
||||
{
|
||||
reference := expr.NewReference(yyDollar[4].node)
|
||||
yyVAL.node = expr.NewArrayItem(yyDollar[1].node, reference)
|
||||
@ -7603,7 +7605,7 @@ yydefault:
|
||||
}
|
||||
case 462:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:4942
|
||||
//line php7/php7.y:4944
|
||||
{
|
||||
reference := expr.NewReference(yyDollar[2].node)
|
||||
yyVAL.node = expr.NewArrayItem(nil, reference)
|
||||
@ -7618,7 +7620,7 @@ yydefault:
|
||||
}
|
||||
case 463:
|
||||
yyDollar = yyS[yypt-6 : yypt+1]
|
||||
//line php7/php7.y:4955
|
||||
//line php7/php7.y:4957
|
||||
{
|
||||
// TODO: Cannot use list() as standalone expression
|
||||
list := expr.NewList(yyDollar[5].list)
|
||||
@ -7638,7 +7640,7 @@ yydefault:
|
||||
}
|
||||
case 464:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:4973
|
||||
//line php7/php7.y:4975
|
||||
{
|
||||
// TODO: Cannot use list() as standalone expression
|
||||
list := expr.NewList(yyDollar[3].list)
|
||||
@ -7657,7 +7659,7 @@ yydefault:
|
||||
}
|
||||
case 465:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:4993
|
||||
//line php7/php7.y:4995
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[2].node)
|
||||
|
||||
@ -7665,7 +7667,7 @@ yydefault:
|
||||
}
|
||||
case 466:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:4999
|
||||
//line php7/php7.y:5001
|
||||
{
|
||||
encapsed := scalar.NewEncapsedStringPart(yyDollar[2].token.Value)
|
||||
yyVAL.list = append(yyDollar[1].list, encapsed)
|
||||
@ -7680,7 +7682,7 @@ yydefault:
|
||||
}
|
||||
case 467:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5012
|
||||
//line php7/php7.y:5014
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -7688,7 +7690,7 @@ yydefault:
|
||||
}
|
||||
case 468:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5018
|
||||
//line php7/php7.y:5020
|
||||
{
|
||||
encapsed := scalar.NewEncapsedStringPart(yyDollar[1].token.Value)
|
||||
yyVAL.list = []node.Node{encapsed, yyDollar[2].node}
|
||||
@ -7703,7 +7705,7 @@ yydefault:
|
||||
}
|
||||
case 469:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5034
|
||||
//line php7/php7.y:5036
|
||||
{
|
||||
name := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(name)
|
||||
@ -7719,7 +7721,7 @@ yydefault:
|
||||
}
|
||||
case 470:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:5048
|
||||
//line php7/php7.y:5050
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
variable := expr.NewVariable(identifier)
|
||||
@ -7739,7 +7741,7 @@ yydefault:
|
||||
}
|
||||
case 471:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5066
|
||||
//line php7/php7.y:5068
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
variable := expr.NewVariable(identifier)
|
||||
@ -7761,7 +7763,7 @@ yydefault:
|
||||
}
|
||||
case 472:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5086
|
||||
//line php7/php7.y:5088
|
||||
{
|
||||
yyVAL.node = expr.NewVariable(yyDollar[2].node)
|
||||
|
||||
@ -7776,7 +7778,7 @@ yydefault:
|
||||
}
|
||||
case 473:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5099
|
||||
//line php7/php7.y:5101
|
||||
{
|
||||
name := node.NewIdentifier(yyDollar[2].token.Value)
|
||||
yyVAL.node = expr.NewVariable(name)
|
||||
@ -7794,7 +7796,7 @@ yydefault:
|
||||
}
|
||||
case 474:
|
||||
yyDollar = yyS[yypt-6 : yypt+1]
|
||||
//line php7/php7.y:5115
|
||||
//line php7/php7.y:5117
|
||||
{
|
||||
identifier := node.NewIdentifier(yyDollar[2].token.Value)
|
||||
variable := expr.NewVariable(identifier)
|
||||
@ -7816,7 +7818,7 @@ yydefault:
|
||||
}
|
||||
case 475:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5135
|
||||
//line php7/php7.y:5137
|
||||
{
|
||||
yyVAL.node = yyDollar[2].node
|
||||
|
||||
@ -7824,7 +7826,7 @@ yydefault:
|
||||
}
|
||||
case 476:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5144
|
||||
//line php7/php7.y:5146
|
||||
{
|
||||
yyVAL.node = scalar.NewString(yyDollar[1].token.Value)
|
||||
|
||||
@ -7838,7 +7840,7 @@ yydefault:
|
||||
}
|
||||
case 477:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5156
|
||||
//line php7/php7.y:5158
|
||||
{
|
||||
// TODO: add option to handle 64 bit integer
|
||||
if _, err := strconv.Atoi(yyDollar[1].token.Value); err == nil {
|
||||
@ -7857,7 +7859,7 @@ yydefault:
|
||||
}
|
||||
case 478:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5173
|
||||
//line php7/php7.y:5175
|
||||
{
|
||||
var lnumber *scalar.Lnumber
|
||||
// TODO: add option to handle 64 bit integer
|
||||
@ -7890,7 +7892,7 @@ yydefault:
|
||||
}
|
||||
case 479:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5204
|
||||
//line php7/php7.y:5206
|
||||
{
|
||||
identifier := node.NewIdentifier(strings.TrimLeftFunc(yyDollar[1].token.Value, isDollar))
|
||||
yyVAL.node = expr.NewVariable(identifier)
|
||||
@ -7906,7 +7908,7 @@ yydefault:
|
||||
}
|
||||
case 480:
|
||||
yyDollar = yyS[yypt-5 : yypt+1]
|
||||
//line php7/php7.y:5221
|
||||
//line php7/php7.y:5223
|
||||
{
|
||||
yyVAL.node = expr.NewIsset(yyDollar[3].list)
|
||||
|
||||
@ -7925,7 +7927,7 @@ yydefault:
|
||||
}
|
||||
case 481:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:5238
|
||||
//line php7/php7.y:5240
|
||||
{
|
||||
yyVAL.node = expr.NewEmpty(yyDollar[3].node)
|
||||
|
||||
@ -7941,7 +7943,7 @@ yydefault:
|
||||
}
|
||||
case 482:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5252
|
||||
//line php7/php7.y:5254
|
||||
{
|
||||
yyVAL.node = expr.NewInclude(yyDollar[2].node)
|
||||
|
||||
@ -7955,7 +7957,7 @@ yydefault:
|
||||
}
|
||||
case 483:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5264
|
||||
//line php7/php7.y:5266
|
||||
{
|
||||
yyVAL.node = expr.NewIncludeOnce(yyDollar[2].node)
|
||||
|
||||
@ -7969,7 +7971,7 @@ yydefault:
|
||||
}
|
||||
case 484:
|
||||
yyDollar = yyS[yypt-4 : yypt+1]
|
||||
//line php7/php7.y:5276
|
||||
//line php7/php7.y:5278
|
||||
{
|
||||
yyVAL.node = expr.NewEval(yyDollar[3].node)
|
||||
|
||||
@ -7985,7 +7987,7 @@ yydefault:
|
||||
}
|
||||
case 485:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5290
|
||||
//line php7/php7.y:5292
|
||||
{
|
||||
yyVAL.node = expr.NewRequire(yyDollar[2].node)
|
||||
|
||||
@ -7999,7 +8001,7 @@ yydefault:
|
||||
}
|
||||
case 486:
|
||||
yyDollar = yyS[yypt-2 : yypt+1]
|
||||
//line php7/php7.y:5302
|
||||
//line php7/php7.y:5304
|
||||
{
|
||||
yyVAL.node = expr.NewRequireOnce(yyDollar[2].node)
|
||||
|
||||
@ -8013,7 +8015,7 @@ yydefault:
|
||||
}
|
||||
case 487:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5317
|
||||
//line php7/php7.y:5319
|
||||
{
|
||||
yyVAL.list = []node.Node{yyDollar[1].node}
|
||||
|
||||
@ -8021,7 +8023,7 @@ yydefault:
|
||||
}
|
||||
case 488:
|
||||
yyDollar = yyS[yypt-3 : yypt+1]
|
||||
//line php7/php7.y:5323
|
||||
//line php7/php7.y:5325
|
||||
{
|
||||
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
|
||||
|
||||
@ -8032,7 +8034,7 @@ yydefault:
|
||||
}
|
||||
case 489:
|
||||
yyDollar = yyS[yypt-1 : yypt+1]
|
||||
//line php7/php7.y:5335
|
||||
//line php7/php7.y:5337
|
||||
{
|
||||
yyVAL.node = yyDollar[1].node
|
||||
|
||||
|
@ -4890,7 +4890,9 @@ non_empty_array_pair_list:
|
||||
$$ = append($1, $3)
|
||||
|
||||
// save comments
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken)
|
||||
if lastNode($1) != nil {
|
||||
yylex.(*Parser).comments.AddFromToken(lastNode($1), $2, comment.CommaToken)
|
||||
}
|
||||
|
||||
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user