[refactoring] update ast structure of "InstanceOf" and "Isset" nodes

This commit is contained in:
Vadym Slizov 2020-12-01 12:16:46 +02:00
parent 9b122de8bf
commit b5ef30eb36
No known key found for this signature in database
GPG Key ID: AEA2A9388EF42A4A
5 changed files with 754 additions and 737 deletions

189
internal/php5/php5.go generated
View File

@ -343,7 +343,7 @@ const yyEofCode = 1
const yyErrCode = 2
const yyInitialStackSize = 16
// line internal/php5/php5.y:6524
// line internal/php5/php5.y:6527
type simpleIndirectReference struct {
all []*ast.ExprVariable
@ -700,10 +700,10 @@ var yyAct = [...]int{
836, 566, 1006, 39, 572, 1012, 531, 1005, 725, 1013,
341, 698, 531, 531, 993, 572, 1016, 518, 716, 538,
422, 39, 658, 664, 665, 672, 673, 674, 675, 678,
679, 460, 318, 259, 446, 231, 31, 231, 256, 654,
531, 314, 296, 656, 655, 39, 260, 261, 449, 127,
403, 39, 575, 657, 659, 660, 676, 677, 666, 903,
147, 151, 155, 401, 335, 945, 165, 685, 478, 995,
679, 318, 314, 259, 446, 231, 31, 231, 256, 654,
531, 127, 296, 656, 655, 39, 260, 261, 449, 403,
575, 39, 903, 657, 659, 660, 676, 677, 666, 401,
147, 151, 155, 460, 335, 945, 165, 685, 478, 995,
1009, 929, 483, 343, 198, 290, 394, 389, 939, 206,
896, 164, 157, 161, 528, 231, 608, 997, 531, 970,
223, 969, 968, 967, 235, 236, 237, 238, 260, 261,
@ -1614,8 +1614,8 @@ var yyPgo = [...]int{
48, 5, 1093, 1092, 1091, 1089, 1087, 6, 1086, 1017,
1084, 1083, 1082, 18, 1042, 1081, 1080, 1078, 1077, 1076,
1075, 41, 1073, 1072, 4, 1071, 1070, 1069, 17, 1067,
12, 1065, 1064, 7, 21, 1063, 25, 1059, 1052, 1050,
14, 39, 0, 1049, 1041, 1032, 391, 619, 1031, 1019,
12, 1065, 1064, 1063, 7, 21, 1059, 25, 1052, 1050,
1049, 14, 39, 0, 1041, 1032, 1031, 391, 619, 1019,
1011, 1010, 30, 52, 1008, 1007, 1002, 3, 1001, 15,
1000, 999, 996, 993, 992, 984, 983, 972, 23, 969,
19, 9, 968, 37, 965, 964, 963, 962, 182, 13,
@ -1623,24 +1623,24 @@ var yyPgo = [...]int{
}
var yyR1 = [...]int{
0, 151, 111, 111, 112, 112, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 113, 113,
6, 6, 6, 6, 114, 114, 7, 7, 7, 7,
115, 115, 8, 8, 8, 8, 55, 55, 116, 116,
0, 151, 112, 112, 113, 113, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 114, 114,
6, 6, 6, 6, 115, 115, 7, 7, 7, 7,
116, 116, 8, 8, 8, 8, 55, 55, 117, 117,
26, 26, 26, 26, 26, 27, 27, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
28, 28, 28, 28, 28, 124, 124, 60, 60, 125,
125, 126, 126, 61, 88, 88, 58, 53, 54, 149,
149, 150, 150, 62, 63, 63, 66, 66, 66, 66,
105, 105, 2, 109, 109, 108, 108, 106, 106, 104,
104, 103, 103, 103, 101, 101, 100, 100, 59, 59,
106, 106, 2, 110, 110, 109, 109, 107, 107, 105,
105, 104, 104, 104, 101, 101, 100, 100, 59, 59,
89, 89, 92, 92, 92, 92, 123, 123, 123, 4,
4, 102, 102, 119, 119, 120, 120, 56, 56, 57,
57, 127, 127, 128, 128, 65, 65, 64, 64, 64,
64, 84, 84, 84, 93, 93, 70, 70, 70, 70,
82, 82, 29, 29, 29, 81, 81, 81, 81, 129,
129, 67, 67, 67, 67, 69, 107, 107, 87, 87,
129, 67, 67, 67, 67, 69, 108, 108, 87, 87,
132, 132, 133, 133, 71, 71, 72, 97, 97, 75,
75, 74, 73, 73, 76, 76, 96, 96, 130, 130,
131, 131, 134, 134, 77, 77, 77, 77, 77, 77,
@ -1654,7 +1654,7 @@ var yyR1 = [...]int{
17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
17, 17, 17, 17, 17, 17, 52, 52, 52, 52,
49, 49, 49, 49, 48, 48, 1, 110, 110, 95,
49, 49, 49, 49, 48, 48, 1, 111, 111, 95,
95, 95, 95, 25, 25, 25, 25, 25, 25, 25,
25, 13, 13, 13, 13, 47, 47, 47, 45, 45,
43, 43, 146, 146, 145, 51, 51, 51, 135, 135,
@ -1672,9 +1672,9 @@ var yyR1 = [...]int{
12, 12, 12, 11, 11, 15, 15, 143, 143, 144,
144, 144, 41, 41, 148, 148, 94, 94, 40, 40,
40, 91, 91, 90, 90, 90, 90, 90, 90, 90,
90, 117, 117, 117, 117, 35, 35, 35, 35, 35,
90, 118, 118, 118, 118, 35, 35, 35, 35, 35,
35, 35, 36, 36, 36, 39, 39, 39, 39, 39,
39, 39, 39, 118, 118, 38, 38, 32, 32, 33,
39, 39, 39, 103, 103, 38, 38, 32, 32, 33,
34,
}
@ -1735,7 +1735,7 @@ var yyR2 = [...]int{
}
var yyChk = [...]int{
-1000, -151, -111, -5, 2, -27, -53, -54, 52, 80,
-1000, -151, -112, -5, 2, -27, -53, -54, 52, 80,
45, -55, -28, 10, -62, -63, 39, 144, 7, 21,
20, 23, 30, 34, 35, 40, -52, 47, 99, 19,
14, -16, 49, 25, 27, 146, 41, 44, 36, -1,
@ -1745,10 +1745,10 @@ var yyChk = [...]int{
113, 114, 6, 158, -31, -49, -48, 143, 97, -22,
92, 50, 51, 4, 5, 85, 86, 87, 11, -37,
-34, -9, 142, 75, 63, 18, 61, 150, -23, -24,
-25, -32, -112, 83, -13, 8, 9, 67, 68, 82,
-25, -32, -113, 83, -13, 8, 9, 67, 68, 82,
64, 65, 66, 81, -12, -148, -46, -14, -42, -11,
159, 12, 148, -112, 144, 83, 10, -113, 37, 39,
-6, -112, 83, 146, 160, 147, 10, -116, -50, 148,
159, 12, 148, -113, 144, 83, 10, -114, 37, 39,
-6, -113, 83, 146, 160, 147, 10, -117, -50, 148,
-50, -27, -1, 80, 148, -50, 146, -16, 98, 99,
146, -16, 146, -17, -21, -16, 146, -82, -29, 12,
159, -81, -1, 12, -85, -16, 146, 131, 132, 88,
@ -1757,87 +1757,87 @@ var yyChk = [...]int{
168, 141, 91, 152, 148, 148, 148, 144, -16, 10,
-149, 153, 10, 10, -17, -21, -16, 53, 53, 162,
118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
128, 129, 148, -16, 105, 106, -20, -21, -112, 80,
128, 129, 148, -16, 105, 106, -20, -21, -113, 80,
83, -13, -14, 99, -20, -16, -16, -16, -16, -44,
-16, -52, -16, -16, -16, -16, -16, -16, -16, -51,
148, -50, -16, 150, 150, -135, 17, -117, -35, 12,
77, 78, -16, 58, -45, -13, -43, -112, 80, 83,
148, -50, -16, 150, 150, -135, 17, -118, -35, 12,
77, 78, -16, 58, -45, -13, -43, -113, 80, 83,
-23, -12, -148, -14, 148, 148, -16, -16, 148, -16,
-16, 150, -117, 17, 17, 76, -117, 150, 148, -91,
-90, -16, 153, 150, 150, 83, -84, 148, -112, 79,
-16, 150, -118, 17, 17, 76, -118, 150, 148, -91,
-90, -16, 153, 150, 150, 83, -84, 148, -113, 79,
150, 144, -12, 159, 79, -84, 144, 149, 146, 144,
-111, -112, 146, 160, -114, -7, -112, 83, -115, -8,
-112, 83, 29, -112, 10, 162, -26, 145, 2, -27,
-112, -113, 146, 160, -115, -7, -113, 83, -116, -8,
-113, 83, 29, -113, 10, 162, -26, 145, 2, -27,
-53, -54, 52, -27, 147, -102, -27, 147, 21, -149,
-122, -121, -16, -92, 144, 147, 146, 146, 146, 146,
146, 160, -18, 144, -21, 146, 160, -149, 162, 146,
160, -16, -16, -16, -16, -16, -16, -16, -16, -16,
-16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
-16, -16, -16, -16, -16, -16, -45, -16, 147, -88,
-58, -21, -21, -17, -89, 10, -116, 146, 146, 10,
148, -105, 56, -109, 56, 59, -16, 153, -16, -16,
-58, -21, -21, -17, -89, 10, -117, 146, 146, 10,
148, -106, 56, -110, 56, 59, -16, 153, -16, -16,
-16, -16, -16, -16, -16, -16, -16, -16, -16, -16,
-94, -40, -21, 60, 83, -112, 79, 79, 149, 149,
-94, -40, -21, 60, 83, -113, 79, 79, 149, 149,
149, 149, -15, -16, -15, 143, -35, -35, 17, 150,
58, -16, 11, -21, -143, -144, -42, -41, -12, -148,
10, 144, -83, -84, 79, 83, -112, 58, -12, 79,
-118, -38, -21, -17, -21, -16, -16, -15, 142, 76,
10, 144, -83, -84, 79, 83, -113, 58, -12, 79,
-103, -38, -21, -17, -21, -16, -16, -15, 142, 76,
76, -15, -91, 151, -3, 160, 59, -19, -21, -15,
-15, 10, 149, -93, -52, -70, -17, -21, 153, 84,
-84, -41, -42, 10, 53, -15, -16, -41, -42, 10,
-16, 146, -111, 145, -84, -6, 146, 160, 29, -112,
146, 160, 29, -112, 10, 29, 162, -30, -79, -9,
-33, -112, 80, 83, 61, 150, -10, 63, -80, 18,
75, -13, 156, 157, 155, 154, 148, 148, -119, -116,
-116, -50, 146, 160, -123, 146, -123, 146, -29, -16,
-16, 146, -112, 145, -84, -6, 146, 160, 29, -113,
146, 160, 29, -113, 10, 29, 162, -30, -79, -9,
-33, -113, 80, 83, 61, 150, -10, 63, -80, 18,
75, -13, 156, 157, 155, 154, 148, 148, -119, -117,
-117, -50, 146, 160, -123, 146, -123, 146, -29, -16,
12, 148, -30, -16, 147, -16, 149, 160, 29, 29,
149, 160, 162, 145, 148, -127, -128, -65, -64, 61,
62, -47, -112, 80, 83, -108, 57, -47, 144, -106,
-47, -17, -21, -21, 92, 149, 160, 148, -112, -139,
62, -47, -113, 80, 83, -109, 57, -47, 144, -107,
-47, -17, -21, -21, 92, 149, 160, 148, -113, -139,
-137, -136, -138, 150, -140, 58, 151, 151, -36, 10,
13, 12, 10, 145, 145, 150, 145, -141, -78, -142,
-84, 150, 144, -12, -16, -42, -112, -143, -42, 149,
-84, 150, 144, -12, -16, -42, -113, -143, -42, 149,
160, 149, 149, 149, 151, 151, 149, -16, 153, -16,
153, 151, 151, 149, 160, 149, -19, -16, -84, -84,
151, 145, -84, -84, 145, 145, -7, 10, 29, -8,
10, 29, 10, -30, 150, 155, 154, 164, 133, 165,
166, 161, 153, 163, 134, 135, 169, 89, 90, 88,
132, 131, 136, 137, 138, 139, 167, 168, 140, 141,
152, 83, -112, 148, -98, -99, -79, 17, 79, -79,
152, 83, -113, 148, -98, -99, -79, 17, 79, -79,
-79, -79, -79, -79, 149, -56, 94, 95, -120, 22,
146, -122, -16, 145, 32, 33, -123, 31, -123, 145,
162, -127, -16, 146, -58, -103, -21, 153, 60, -103,
162, -127, -16, 146, -58, -104, -21, 153, 60, -104,
-59, -27, 147, 10, -30, -124, 42, -127, 149, 160,
-149, 83, -112, 144, -106, -129, 160, -45, 162, -40,
-149, 83, -113, 144, -107, -129, 160, -45, 162, -40,
-94, 150, -138, -140, -15, -143, 151, -16, -147, 150,
150, -15, -16, 145, -146, -38, 59, -19, -19, -70,
10, 10, -79, -79, -79, -79, -79, -79, -79, -79,
-79, -79, -79, -79, -79, -79, -79, -79, -79, -79,
-79, -79, -79, -79, -79, -79, -79, -79, 147, -79,
-112, -98, 151, -3, 160, 59, 10, 53, 149, 146,
-113, -98, 151, -3, 160, 59, 10, 53, 149, 146,
-50, -27, -57, 94, 95, 146, 146, -16, -4, 147,
146, 145, 146, 31, -30, 149, -104, 59, -21, 148,
-104, -116, 162, -60, 43, 148, 149, -110, 45, -65,
-150, 84, -112, -129, 145, -67, -130, -68, -69, -131,
146, 145, 146, 31, -30, 149, -105, 59, -21, 148,
-105, -117, 162, -60, 43, 148, 149, -111, 45, -65,
-150, 84, -113, -129, 145, -67, -130, -68, -69, -131,
-134, 48, 39, 45, -77, 104, 103, 102, 99, 100,
101, -47, -83, -16, 149, -15, 151, -141, 151, -140,
-15, -15, 151, 145, -145, 58, -16, 153, 151, -79,
147, 149, -79, -79, -27, 96, -50, 147, -122, -4,
-116, 146, -110, 149, -103, -94, 149, 28, -30, 144,
-117, 146, -111, 149, -104, -94, 149, 28, -30, 144,
-47, 144, 144, 148, 12, 145, -86, 12, 146, 160,
-1, -77, 10, -107, -47, 151, 145, 151, 151, -143,
-19, -79, 59, 146, 147, -116, 149, -116, 144, -100,
-27, 147, 149, -100, 146, -116, 12, -116, -116, -95,
-1, -77, 10, -108, -47, 151, 145, 151, 151, -143,
-19, -79, 59, 146, 147, -117, 149, -117, 144, -100,
-27, 147, 149, -100, 146, -117, 12, -117, -117, -95,
12, 153, 162, 146, 160, 162, 10, -149, 162, -87,
160, 146, 144, -79, -116, -101, -27, 147, -116, -116,
160, 146, 144, -79, -117, -101, -27, 147, -117, -117,
145, 149, 145, 145, 149, 160, 12, -16, 12, -30,
162, 10, -30, -47, -132, -133, -71, -72, -73, -74,
-75, -47, 10, -116, 145, 26, 144, 12, 153, 162,
-75, -47, 10, -117, 145, 26, 144, 12, 153, 162,
-30, 148, 145, -71, 146, 146, 46, 29, 79, 24,
146, -116, 12, -30, -127, -97, -47, -76, -77, 10,
146, -117, 12, -30, -127, -97, -47, -76, -77, 10,
146, 145, 149, 160, 10, -125, -126, -61, 42, -96,
146, 144, -47, -61, 148, -116, -47, 145, 12, 149,
144, -116, 145,
146, 144, -47, -61, 148, -117, -47, 145, 12, 149,
144, -117, 145,
}
var yyDef = [...]int{
@ -6051,14 +6051,14 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:3719
{
yyVAL.node = &ast.ExprInstanceOf{ast.Node{}, yyDollar[1].node, yyDollar[3].node}
// save position
yyVAL.node.GetNode().Position = position.NewNodesPosition(yyDollar[1].node, yyDollar[3].node)
// save comments
yylex.(*Parser).MoveFreeFloating(yyDollar[1].node, yyVAL.node)
yylex.(*Parser).setFreeFloating(yyVAL.node, token.Expr, yyDollar[2].token.SkippedTokens)
yyVAL.node = &ast.ExprInstanceOf{
Node: ast.Node{
Position: position.NewNodesPosition(yyDollar[1].node, yyDollar[3].node),
},
Expr: yyDollar[1].node,
InstanceOfTkn: yyDollar[2].token,
Class: yyDollar[3].node,
}
}
case 283:
yyDollar = yyS[yypt-1 : yypt+1]
@ -8927,19 +8927,20 @@ yydefault:
yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php5/php5.y:6333
{
yyVAL.node = &ast.ExprIsset{ast.Node{}, yyDollar[3].list}
// save position
yyVAL.node.GetNode().Position = position.NewTokensPosition(yyDollar[1].token, yyDollar[4].token)
// save comments
yylex.(*Parser).setFreeFloating(yyVAL.node, token.Start, yyDollar[1].token.SkippedTokens)
yylex.(*Parser).setFreeFloating(yyVAL.node, token.Isset, yyDollar[2].token.SkippedTokens)
yylex.(*Parser).setFreeFloating(yyVAL.node, token.VarList, yyDollar[4].token.SkippedTokens)
yyVAL.node = &ast.ExprIsset{
Node: ast.Node{
Position: position.NewTokensPosition(yyDollar[1].token, yyDollar[4].token),
},
IssetTkn: yyDollar[1].token,
OpenParenthesisTkn: yyDollar[2].token,
Vars: yyDollar[3].node.(*ast.ParserSeparatedList).Items,
SeparatorTkns: yyDollar[3].node.(*ast.ParserSeparatedList).SeparatorTkns,
CloseParenthesisTkn: yyDollar[4].token,
}
}
case 506:
yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php5/php5.y:6345
// line internal/php5/php5.y:6346
{
yyVAL.node = &ast.ExprEmpty{
Node: ast.Node{
@ -8953,7 +8954,7 @@ yydefault:
}
case 507:
yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php5/php5.y:6357
// line internal/php5/php5.y:6358
{
yyVAL.node = &ast.ExprEmpty{
Node: ast.Node{
@ -8967,7 +8968,7 @@ yydefault:
}
case 508:
yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php5/php5.y:6369
// line internal/php5/php5.y:6370
{
yyVAL.node = &ast.ExprInclude{
Node: ast.Node{
@ -8979,7 +8980,7 @@ yydefault:
}
case 509:
yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php5/php5.y:6379
// line internal/php5/php5.y:6380
{
yyVAL.node = &ast.ExprIncludeOnce{
Node: ast.Node{
@ -8991,7 +8992,7 @@ yydefault:
}
case 510:
yyDollar = yyS[yypt-4 : yypt+1]
// line internal/php5/php5.y:6389
// line internal/php5/php5.y:6390
{
yyVAL.node = &ast.ExprEval{
Node: ast.Node{
@ -9005,7 +9006,7 @@ yydefault:
}
case 511:
yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php5/php5.y:6401
// line internal/php5/php5.y:6402
{
yyVAL.node = &ast.ExprRequire{ast.Node{}, yyDollar[2].node}
@ -9017,7 +9018,7 @@ yydefault:
}
case 512:
yyDollar = yyS[yypt-2 : yypt+1]
// line internal/php5/php5.y:6411
// line internal/php5/php5.y:6412
{
yyVAL.node = &ast.ExprRequireOnce{ast.Node{}, yyDollar[2].node}
@ -9029,34 +9030,36 @@ yydefault:
}
case 513:
yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php5/php5.y:6424
// line internal/php5/php5.y:6425
{
yyVAL.list = []ast.Vertex{yyDollar[1].node}
yyVAL.node = &ast.ParserSeparatedList{
Items: []ast.Vertex{yyDollar[1].node},
}
}
case 514:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:6428
// line internal/php5/php5.y:6431
{
yyVAL.list = append(yyDollar[1].list, yyDollar[3].node)
yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns = append(yyDollar[1].node.(*ast.ParserSeparatedList).SeparatorTkns, yyDollar[2].token)
yyDollar[1].node.(*ast.ParserSeparatedList).Items = append(yyDollar[1].node.(*ast.ParserSeparatedList).Items, yyDollar[3].node)
// save comments
yylex.(*Parser).setFreeFloating(lastNode(yyDollar[1].list), token.End, yyDollar[2].token.SkippedTokens)
yyVAL.node = yyDollar[1].node
}
case 515:
yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php5/php5.y:6438
// line internal/php5/php5.y:6441
{
yyVAL.node = yyDollar[1].node
}
case 516:
yyDollar = yyS[yypt-1 : yypt+1]
// line internal/php5/php5.y:6442
// line internal/php5/php5.y:6445
{
yyVAL.node = yyDollar[1].node
}
case 517:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:6449
// line internal/php5/php5.y:6452
{
yyVAL.node = &ast.ExprClassConstFetch{
Node: ast.Node{
@ -9075,7 +9078,7 @@ yydefault:
}
case 518:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:6466
// line internal/php5/php5.y:6469
{
yyVAL.node = &ast.ExprClassConstFetch{
Node: ast.Node{
@ -9094,7 +9097,7 @@ yydefault:
}
case 519:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:6486
// line internal/php5/php5.y:6489
{
yyVAL.node = &ast.ExprClassConstFetch{
Node: ast.Node{
@ -9113,7 +9116,7 @@ yydefault:
}
case 520:
yyDollar = yyS[yypt-3 : yypt+1]
// line internal/php5/php5.y:6506
// line internal/php5/php5.y:6509
{
yyVAL.node = &ast.ExprClassConstFetch{
Node: ast.Node{

View File

@ -240,7 +240,7 @@ import (
%type <node> trait_adaptations unset_variables declare_list non_empty_array_pair_list array_pair_list
%type <node> switch_case_list non_empty_function_call_parameter_list assignment_list lexical_var_list
%type <node> method_body trait_reference_list static_array_pair_list non_empty_static_array_pair_list
%type <node> foreach_statement for_statement while_statement
%type <node> foreach_statement for_statement while_statement isset_variables
%type <node> foreach_variable foreach_optional_arg
%type <node> extends_from interface_list trait_list
%type <node> implements_list
@ -248,7 +248,7 @@ import (
%type <ClosureUse> lexical_vars
%type <list> top_statement_list namespace_name use_declarations use_function_declarations use_const_declarations
%type <list> inner_statement_list encaps_list isset_variables
%type <list> inner_statement_list encaps_list
%type <list> elseif_list new_elseif_list non_empty_for_expr
%type <list> for_expr case_list catch_statement additional_catches
%type <list> non_empty_additional_catches parameter_list non_empty_parameter_list class_statement_list
@ -3717,14 +3717,14 @@ expr_without_variable:
}
| expr T_INSTANCEOF class_name_reference
{
$$ = &ast.ExprInstanceOf{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprInstanceOf{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Expr: $1,
InstanceOfTkn: $2,
Class: $3,
}
}
| parenthesis_expr
{
@ -6331,15 +6331,16 @@ encaps_var_offset:
internal_functions_in_yacc:
T_ISSET '(' isset_variables ')'
{
$$ = &ast.ExprIsset{ast.Node{}, $3}
// save position
$$.GetNode().Position = position.NewTokensPosition($1, $4)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloating($$, token.Isset, $2.SkippedTokens)
yylex.(*Parser).setFreeFloating($$, token.VarList, $4.SkippedTokens)
$$ = &ast.ExprIsset{
Node: ast.Node{
Position: position.NewTokensPosition($1, $4),
},
IssetTkn: $1,
OpenParenthesisTkn: $2,
Vars: $3.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
CloseParenthesisTkn: $4,
}
}
| T_EMPTY '(' variable ')'
{
@ -6422,14 +6423,16 @@ internal_functions_in_yacc:
isset_variables:
isset_variable
{
$$ = []ast.Vertex{$1}
$$ = &ast.ParserSeparatedList{
Items: []ast.Vertex{$1},
}
}
| isset_variables ',' isset_variable
{
$$ = append($1, $3)
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, $3)
// save comments
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
$$ = $1
}
;

1189
internal/php7/php7.go generated

File diff suppressed because it is too large Load Diff

View File

@ -247,7 +247,7 @@ import (
%type <node> callable_expr callable_variable static_member new_variable
%type <node> encaps_var encaps_var_offset echo_expr_list catch_name_list name_list
%type <node> if_stmt const_list non_empty_argument_list property_list
%type <node> alt_if_stmt lexical_var_list
%type <node> alt_if_stmt lexical_var_list isset_variables
%type <node> if_stmt_without_else
%type <node> class_const_decl
%type <node> alt_if_stmt_without_else
@ -275,7 +275,7 @@ import (
%type <list> for_exprs non_empty_for_exprs
%type <list> unprefixed_use_declarations inline_use_declarations
%type <list> case_list trait_adaptation_list
%type <list> use_declarations isset_variables
%type <list> use_declarations
%type <list> top_statement_list
%type <list> inner_statement_list parameter_list non_empty_parameter_list class_statement_list
%type <list> method_modifiers variable_modifiers
@ -3386,14 +3386,14 @@ expr_without_variable:
}
| expr T_INSTANCEOF class_name_reference
{
$$ = &ast.ExprInstanceOf{ast.Node{}, $1, $3}
// save position
$$.GetNode().Position = position.NewNodesPosition($1, $3)
// save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloating($$, token.Expr, $2.SkippedTokens)
$$ = &ast.ExprInstanceOf{
Node: ast.Node{
Position: position.NewNodesPosition($1, $3),
},
Expr: $1,
InstanceOfTkn: $2,
Class: $3,
}
}
| '(' expr ')'
{
@ -4886,18 +4886,19 @@ encaps_var_offset:
internal_functions_in_yacc:
T_ISSET '(' isset_variables possible_comma ')'
{
$$ = &ast.ExprIsset{ast.Node{}, $3}
if $4 != nil {
$3.(*ast.ParserSeparatedList).SeparatorTkns = append($3.(*ast.ParserSeparatedList).SeparatorTkns, $4)
}
// save position
$$.GetNode().Position = position.NewTokensPosition($1, $5)
// save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
yylex.(*Parser).setFreeFloating($$, token.Isset, $2.SkippedTokens)
if $4 == nil {
yylex.(*Parser).setFreeFloating($$, token.VarList, $5.SkippedTokens)
} else {
yylex.(*Parser).setFreeFloating($$, token.VarList, append($4.SkippedTokens, $5.SkippedTokens...))
$$ = &ast.ExprIsset{
Node: ast.Node{
Position: position.NewTokensPosition($1, $5),
},
IssetTkn: $1,
OpenParenthesisTkn: $2,
Vars: $3.(*ast.ParserSeparatedList).Items,
SeparatorTkns: $3.(*ast.ParserSeparatedList).SeparatorTkns,
CloseParenthesisTkn: $5,
}
}
| T_EMPTY '(' expr ')'
@ -4969,14 +4970,16 @@ internal_functions_in_yacc:
isset_variables:
isset_variable
{
$$ = []ast.Vertex{$1}
$$ = &ast.ParserSeparatedList{
Items: []ast.Vertex{$1},
}
}
| isset_variables ',' isset_variable
{
$$ = append($1, $3)
$1.(*ast.ParserSeparatedList).SeparatorTkns = append($1.(*ast.ParserSeparatedList).SeparatorTkns, $2)
$1.(*ast.ParserSeparatedList).Items = append($1.(*ast.ParserSeparatedList).Items, $3)
// save comments
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
$$ = $1
}
;

View File

@ -1175,8 +1175,9 @@ func (n *ExprIncludeOnce) Accept(v NodeVisitor) {
// ExprInstanceOf node
type ExprInstanceOf struct {
Node
Expr Vertex
Class Vertex
Expr Vertex
InstanceOfTkn *token.Token
Class Vertex
}
func (n *ExprInstanceOf) Accept(v NodeVisitor) {
@ -1186,7 +1187,11 @@ func (n *ExprInstanceOf) Accept(v NodeVisitor) {
// ExprIsset node
type ExprIsset struct {
Node
Vars []Vertex
IssetTkn *token.Token
OpenParenthesisTkn *token.Token
Vars []Vertex
SeparatorTkns []*token.Token
CloseParenthesisTkn *token.Token
}
func (n *ExprIsset) Accept(v NodeVisitor) {