trait_use node

This commit is contained in:
vadim 2017-12-09 12:27:01 +02:00
parent d33afa9b38
commit ef11d0ab38
3 changed files with 136 additions and 92 deletions

44
node/stmt/trait_use.go Normal file
View File

@ -0,0 +1,44 @@
package stmt
import (
"fmt"
"io"
"github.com/z7zmey/php-parser/node"
"github.com/z7zmey/php-parser/token"
)
type TraitUse struct {
node.SimpleNode
token token.Token
traits []node.Node
adaptations []node.Node
}
//TODO: traits myst be []node.Node
func NewTraitUse(token token.Token, traits []node.Node, adaptations []node.Node) node.Node {
return TraitUse{
node.SimpleNode{Name: "TraitUse", Attributes: make(map[string]string)},
token,
traits,
adaptations,
}
}
func (n TraitUse) Print(out io.Writer, indent string) {
fmt.Fprintf(out, "\n%v%v [%d %d] %q", indent, n.Name, n.token.StartLine, n.token.EndLine, n.token.Value)
if n.traits != nil {
fmt.Fprintf(out, "\n%vtraits:", indent+" ")
for _, nn := range n.traits {
nn.Print(out, indent+" ")
}
}
if n.adaptations != nil {
fmt.Fprintf(out, "\n%vadaptations:", indent+" ")
for _, nn := range n.adaptations {
nn.Print(out, indent+" ")
}
}
}

View File

@ -600,13 +600,13 @@ var yyAct = [...]int{
807, 197, 199, 198, 332, 607, 795, 610, 608, 308, 807, 197, 199, 198, 332, 607, 795, 610, 608, 308,
766, 718, 669, 279, 280, 642, 817, 633, 628, 785, 766, 718, 669, 279, 280, 642, 817, 633, 628, 785,
229, 564, 812, 824, 810, 825, 554, 118, 231, 409, 229, 564, 812, 824, 810, 825, 554, 118, 231, 409,
1, 831, 651, 144, 659, 544, 255, 256, 748, 803, 1, 831, 804, 848, 659, 544, 255, 256, 651, 803,
842, 141, 321, 830, 148, 813, 578, 846, 833, 800, 842, 144, 748, 830, 141, 813, 578, 846, 833, 321,
855, 666, 841, 687, 688, 689, 686, 685, 684, 829, 855, 148, 841, 687, 688, 689, 686, 685, 684, 800,
864, 854, 167, 168, 161, 162, 160, 163, 165, 166, 864, 854, 167, 168, 161, 162, 160, 163, 165, 166,
863, 178, 250, 37, 872, 681, 873, 679, 868, 678, 863, 178, 666, 829, 872, 250, 873, 37, 868, 681,
877, 221, 223, 164, 861, 835, 879, 848, 42, 912, 877, 679, 678, 164, 861, 221, 879, 223, 835, 42,
804, 529, 855, 570, 782, 878, 41, 365, 882, 15, 912, 529, 855, 570, 782, 878, 41, 365, 882, 15,
14, 519, 606, 854, 888, 889, 266, 48, 890, 87, 14, 519, 606, 854, 888, 889, 266, 48, 890, 87,
88, 89, 90, 91, 47, 107, 49, 82, 73, 74, 88, 89, 90, 91, 47, 107, 49, 82, 73, 74,
80, 75, 71, 247, 896, 893, 61, 264, 897, 60, 80, 75, 71, 247, 896, 893, 61, 264, 897, 60,
@ -1368,11 +1368,11 @@ var yyPgo = [...]int{
111, 98, 197, 886, 883, 882, 8, 880, 81, 43, 111, 98, 197, 886, 883, 882, 8, 880, 81, 43,
877, 55, 47, 876, 875, 874, 867, 866, 97, 862, 877, 55, 47, 876, 875, 874, 867, 866, 97, 862,
861, 103, 549, 1, 860, 859, 857, 7, 19, 38, 861, 103, 549, 1, 860, 859, 857, 7, 19, 38,
856, 853, 83, 851, 10, 4, 850, 849, 86, 848, 856, 853, 83, 851, 10, 4, 850, 86, 849, 18,
847, 18, 845, 842, 841, 44, 42, 32, 41, 2, 848, 847, 845, 44, 42, 32, 41, 2, 16, 842,
16, 839, 837, 835, 5, 775, 833, 670, 832, 28, 841, 839, 5, 775, 837, 670, 835, 28, 833, 832,
819, 811, 809, 90, 804, 31, 802, 801, 25, 29, 819, 90, 811, 31, 809, 804, 25, 29, 802, 801,
798, 793, 792, 24, 790, 37, 12, 798, 24, 793, 792, 790, 37, 12,
} }
var yyR1 = [...]int{ var yyR1 = [...]int{
@ -1384,27 +1384,27 @@ var yyR1 = [...]int{
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6,
6, 6, 6, 6, 6, 6, 7, 7, 71, 71, 6, 6, 6, 6, 6, 6, 7, 7, 71, 71,
109, 109, 9, 9, 9, 8, 8, 8, 8, 8, 107, 107, 9, 9, 9, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8, 8, 105, 8, 8, 8, 8, 8, 8, 8, 8, 8, 103,
105, 16, 16, 18, 18, 125, 125, 119, 119, 118, 103, 16, 16, 18, 18, 125, 125, 117, 117, 116,
118, 72, 72, 17, 17, 20, 20, 19, 19, 113, 116, 72, 72, 17, 17, 20, 20, 19, 19, 111,
113, 73, 73, 22, 22, 22, 22, 22, 22, 10, 111, 73, 73, 22, 22, 22, 22, 22, 22, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
10, 10, 10, 111, 111, 110, 110, 30, 30, 76, 10, 10, 10, 109, 109, 108, 108, 30, 30, 76,
76, 31, 11, 1, 1, 2, 2, 12, 12, 106, 76, 31, 11, 1, 1, 2, 2, 12, 12, 104,
106, 4, 4, 13, 14, 33, 33, 15, 15, 79, 104, 4, 4, 13, 14, 33, 33, 15, 15, 79,
79, 27, 27, 27, 27, 26, 26, 28, 28, 29, 79, 27, 27, 27, 27, 26, 26, 28, 28, 29,
29, 122, 122, 122, 122, 123, 123, 123, 126, 126, 29, 120, 120, 120, 120, 121, 121, 121, 126, 126,
25, 25, 80, 80, 74, 74, 89, 89, 75, 75, 25, 25, 80, 80, 74, 74, 88, 88, 75, 75,
77, 77, 81, 81, 34, 34, 35, 35, 100, 100, 77, 77, 81, 81, 34, 34, 35, 35, 98, 98,
98, 98, 98, 99, 99, 82, 82, 83, 83, 36, 96, 96, 96, 97, 97, 82, 82, 83, 83, 36,
36, 117, 117, 38, 121, 121, 39, 39, 78, 78, 36, 115, 115, 38, 119, 119, 39, 39, 78, 78,
40, 40, 40, 40, 85, 85, 86, 86, 86, 90, 40, 40, 40, 40, 85, 85, 123, 123, 123, 122,
90, 41, 41, 42, 43, 43, 43, 43, 45, 45, 122, 41, 41, 42, 43, 43, 43, 43, 45, 45,
44, 87, 87, 101, 101, 102, 102, 103, 103, 104, 44, 86, 86, 99, 99, 100, 100, 101, 101, 102,
104, 104, 104, 104, 104, 120, 120, 46, 46, 112, 102, 102, 102, 102, 102, 118, 118, 46, 46, 110,
112, 84, 21, 114, 114, 47, 115, 115, 116, 116, 110, 84, 21, 112, 112, 47, 113, 113, 114, 114,
49, 48, 48, 37, 37, 37, 37, 37, 37, 37, 49, 48, 48, 37, 37, 37, 37, 37, 37, 37,
37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
@ -1413,18 +1413,18 @@ var yyR1 = [...]int{
37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
37, 37, 37, 37, 37, 37, 37, 37, 37, 3, 37, 37, 37, 37, 37, 37, 37, 37, 37, 3,
3, 91, 91, 92, 92, 56, 56, 57, 57, 57, 3, 89, 89, 90, 90, 56, 56, 57, 57, 57,
57, 50, 50, 51, 51, 54, 54, 108, 108, 108, 57, 50, 50, 51, 51, 54, 54, 106, 106, 106,
88, 88, 61, 61, 61, 55, 55, 55, 55, 55, 87, 87, 61, 61, 61, 55, 55, 55, 55, 55,
55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55,
55, 62, 62, 62, 23, 23, 24, 24, 60, 63, 55, 62, 62, 62, 23, 23, 24, 24, 60, 63,
63, 63, 64, 64, 64, 65, 65, 65, 65, 65, 63, 63, 64, 64, 64, 65, 65, 65, 65, 65,
65, 32, 32, 32, 52, 52, 52, 66, 66, 67, 65, 32, 32, 32, 52, 52, 52, 66, 66, 67,
67, 67, 67, 67, 67, 58, 58, 58, 59, 59, 67, 67, 67, 67, 67, 58, 58, 58, 59, 59,
59, 95, 96, 96, 94, 94, 93, 93, 93, 93, 59, 93, 94, 94, 92, 92, 91, 91, 91, 91,
93, 93, 107, 107, 107, 107, 68, 68, 68, 68, 91, 91, 105, 105, 105, 105, 68, 68, 68, 68,
68, 68, 68, 69, 69, 69, 69, 53, 53, 53, 68, 68, 68, 69, 69, 69, 69, 53, 53, 53,
53, 53, 53, 53, 70, 70, 97, 53, 53, 53, 53, 70, 70, 95,
} }
var yyR2 = [...]int{ var yyR2 = [...]int{
@ -1483,18 +1483,18 @@ var yyChk = [...]int{
-1000, -124, -71, -8, -10, -11, -12, -13, -14, 127, -1000, -124, -71, -8, -10, -11, -12, -13, -14, 127,
154, 120, 114, 161, -74, -75, 97, 96, 99, 106, 154, 120, 114, 161, -74, -75, 97, 96, 99, 106,
110, 111, 115, 122, 76, 95, 90, -23, 124, 101, 110, 111, 115, 122, 76, 95, 90, -23, 124, 101,
103, 163, 116, 119, 112, 86, 113, -106, 128, 129, 103, 163, 116, 119, 112, 86, 113, -104, 128, 129,
130, -80, -89, -32, -37, -4, 83, -65, -66, -63, 130, -80, -88, -32, -37, -4, 83, -65, -66, -63,
134, 69, 71, 58, 59, 49, 50, 55, 57, 164, 134, 69, 71, 58, 59, 49, 50, 55, 57, 164,
-48, -53, 60, 61, 62, 63, 64, 65, 66, 82, -48, -53, 60, 61, 62, 63, 64, 65, 66, 82,
67, -55, 160, 13, 14, 16, 77, 78, -52, -62, 67, -55, 160, 13, 14, 16, 77, 78, -52, -62,
-57, -50, -60, -61, 70, 125, 126, 4, 5, 6, -57, -50, -60, -61, 70, 125, 126, 4, 5, 6,
7, 8, 84, 85, 141, 142, 156, 138, 139, 140, 7, 8, 84, 85, 141, 142, 156, 138, 139, 140,
155, 137, 149, 159, 88, 167, -9, -64, 135, 94, 155, 137, 149, 159, 88, 167, -9, -64, 135, 94,
-109, 157, 164, 157, -109, 161, 86, -18, -105, -72, -107, 157, 164, 157, -107, 161, 86, -18, -103, -72,
-109, 157, 113, 114, -19, -20, -113, -21, 86, -73, -107, 157, 113, 114, -19, -20, -111, -21, 86, -73,
164, -10, 113, 154, 164, 164, -24, -23, 76, -24, 164, -10, 113, 154, 164, 164, -24, -23, 76, -24,
-24, -117, -38, -52, -121, 113, -39, 88, -114, -47, -24, -115, -38, -52, -119, 113, -39, 88, -112, -47,
-23, 163, 33, 34, 10, 12, 11, 35, 37, 36, -23, 163, 33, 34, 10, 12, 11, 35, 37, 36,
51, 49, 50, 52, 68, 53, 54, 47, 48, 40, 51, 49, 50, 52, 68, 53, 54, 47, 48, 40,
41, 38, 39, 43, 44, 45, 46, 42, 56, 30, 41, 38, 39, 43, 44, 45, 46, 42, 56, 30,
@ -1502,26 +1502,26 @@ var yyChk = [...]int{
128, -4, 86, 86, 86, 73, 74, 73, 75, 74, 128, -4, 86, 86, 86, 73, 74, 73, 75, 74,
17, 18, 19, 20, 29, 21, 22, 23, 24, 25, 17, 18, 19, 20, 29, 21, 22, 23, 24, 25,
26, 27, 28, 58, 59, 164, 69, 161, 133, 164, 26, 27, 28, 58, 59, 164, 69, 161, 133, 164,
-95, -94, -96, -93, -23, 37, 134, -23, -32, -62, -93, -92, -94, -91, -23, 37, 134, -23, -32, -62,
164, -61, 76, 69, -32, -23, -23, -23, -23, -23, 164, -61, 76, 69, -32, -23, -23, -23, -23, -23,
-23, -23, -23, -23, -23, -23, -23, -54, 164, -23, -23, -23, -23, -23, -23, -23, -23, -54, 164, -23,
-108, 93, -107, -68, 88, 151, 152, -23, -23, -23, -106, 93, -105, -68, 88, 151, 152, -23, -23, -23,
69, 153, 153, -51, -49, -50, -67, 128, -9, -52, 69, 153, 153, -51, -49, -50, -67, 128, -9, -52,
164, 164, -23, -23, 164, -23, -23, 93, 150, -107, 164, 164, -23, -23, 164, -23, -23, 93, 150, -105,
-107, 93, 161, -52, -82, 164, -82, 164, 157, -109, -105, 93, 161, -52, -82, 164, -82, 164, 157, -107,
165, -109, 163, 161, -71, 163, -16, -72, -109, 157, 165, -107, 163, 161, -71, 163, -16, -72, -107, 157,
163, 9, 157, 105, -109, -20, 163, 9, 17, -22, 163, 9, 157, 105, -107, -20, 163, 9, 17, -22,
162, -10, -11, -12, -13, -14, 127, -23, 97, -3, 162, -10, -11, -12, -13, -14, 127, -23, 97, -3,
-115, -116, -23, -23, 163, 163, 163, 163, 9, 163, -113, -114, -23, -23, 163, 163, 163, 163, 9, 163,
9, -3, 17, 163, 9, -23, -23, -23, -23, -23, 9, -3, 17, 163, 9, -23, -23, -23, -23, -23,
-23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23,
-23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23,
-23, -51, -23, 31, -23, -76, -31, -32, -23, -113, -23, -51, -23, 31, -23, -76, -31, -32, -23, -111,
-73, 163, 163, 86, 164, 86, -33, 131, 161, -15, -73, 163, 163, 86, 164, 86, -33, 131, 161, -15,
131, 164, -10, 164, 163, 31, -23, 37, -23, -23, 131, 164, -10, 164, 163, 31, -23, 37, -23, -23,
-23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23,
-23, -24, -23, -59, 86, 161, -52, -95, 166, 9, -23, -24, -23, -59, 86, 161, -52, -93, 166, 9,
15, -32, 164, -23, -95, 165, -24, 160, -68, -68, 15, -32, 164, -23, -93, 165, -24, 160, -68, -68,
93, 69, 133, -23, 87, -32, 15, -24, -58, -7, 93, 69, 133, -23, 87, -32, 15, -24, -58, -7,
-52, 161, 86, -6, -5, 76, 77, 78, 79, 80, -52, 161, 86, -6, -5, 76, 77, 78, 79, 80,
81, 4, 5, 6, 7, 8, 10, 11, 12, 56, 81, 4, 5, 6, 7, 8, 10, 11, 12, 56,
@ -1531,47 +1531,47 @@ var yyChk = [...]int{
112, 113, 114, 115, 13, 14, 134, 106, 107, 108, 112, 113, 114, 115, 13, 14, 134, 106, 107, 108,
109, 110, 135, 136, 131, 132, 154, 129, 130, 128, 109, 110, 135, 136, 131, 132, 154, 129, 130, 128,
137, 138, 140, 139, 141, 142, 156, 155, -58, -7, 137, 138, 140, 139, 141, 142, 156, 155, -58, -7,
-52, -88, -82, 153, 69, 161, 133, 153, -88, -70, -52, -87, -82, 153, 69, 161, 133, 153, -87, -70,
-97, -23, -23, -23, 150, 150, 159, -23, 165, -83, -95, -23, -23, -23, 150, 150, 159, -23, 165, -83,
-36, -23, 158, -95, 86, 163, -71, 162, 163, 163, -36, -23, 158, -93, 86, 163, -71, 162, 163, 163,
157, -109, -19, 157, -109, 161, 86, 157, -21, -23, 157, -107, -19, 157, -107, 161, 86, 157, -21, -23,
164, 165, 164, 163, 9, 165, -38, -39, 164, -23, 164, 165, 164, 163, 9, 165, -38, -39, 164, -23,
-47, 31, -23, -125, 9, 105, 165, 162, 164, -77, -47, 31, -23, -125, 9, 105, 165, 162, 164, -77,
-81, -34, -35, -100, -98, 30, 135, 136, -9, -33, -81, -34, -35, -98, -96, 30, 135, 136, -9, -33,
-79, 132, -9, -78, 161, -85, -9, -23, -23, -73, -79, 132, -9, -78, 161, -85, -9, -23, -23, -73,
-23, 165, 166, 162, -82, -23, 165, 17, -96, -23, -23, 165, 166, 162, -82, -23, 165, 17, -94, -23,
37, 134, -95, 165, 166, 165, -69, 86, 89, 50, 37, 134, -93, 165, 166, 165, -69, 86, 89, 50,
88, 86, 162, 162, 69, 162, -23, 166, -82, -23, 88, 86, 162, 162, 69, 162, -23, 166, -82, -23,
-82, -52, -24, -23, -59, -52, -33, -125, 9, 165, -82, -52, -24, -23, -59, -52, -33, -125, 9, 165,
165, 162, -125, 9, -23, 165, 162, 161, 157, -119, 165, 162, -125, 9, -23, 165, 162, 161, 157, -117,
-17, -20, -105, 161, 165, -25, -10, 31, -23, -115, -17, -20, -103, 161, 165, -25, -10, 31, -23, -113,
-23, -122, 161, 31, -77, -23, 165, -31, -27, -32, -23, -120, 161, 31, -77, -23, 165, -31, -27, -32,
37, 134, 69, -29, -10, 31, -111, -77, 165, 9, 37, 134, 69, -29, -10, 31, -109, -77, 165, 9,
-1, 37, -98, -79, 161, -85, 162, -40, -101, -102, -1, 37, -96, -79, 161, -85, 162, -40, -99, -100,
120, -103, 123, -104, 81, 80, 79, 76, 77, 78, 120, -101, 123, -102, 81, 80, 79, 76, 77, 78,
-78, 9, 165, 165, 75, -10, 31, 162, 17, -23, -78, 9, 165, 165, 75, -10, 31, 162, 17, -23,
-32, 164, 165, 166, 89, -23, 162, 166, 162, -79, -32, 164, 165, 166, 89, -23, 162, 166, 162, -79,
165, -97, 165, -36, -118, -20, 161, -125, 9, -20, 165, -95, 165, -36, -116, -20, 161, -125, 9, -20,
-119, 163, -73, 165, 163, -123, 163, -123, 163, 165, -117, 163, -73, 165, 163, -121, 163, -121, 163, 165,
163, 165, 15, -32, 164, -95, -73, -30, 117, 118, 163, 165, 15, -32, 164, -93, -73, -30, 117, 118,
165, -91, 120, -34, -2, 158, 161, -78, -120, -46, 165, -89, 120, -34, -2, 158, 161, -78, -118, -46,
88, 114, 113, -85, -104, 162, -9, -10, 31, 163, 88, 114, 113, -85, -102, 162, -9, -10, 31, 163,
-73, -23, -95, 166, 161, -125, 9, -118, 162, -17, -73, -23, -93, 166, 161, -125, 9, -116, 162, -17,
-125, 98, 163, -115, 162, 108, 109, -123, 107, -123, -125, 98, 163, -113, 162, 108, 109, -121, 107, -121,
-91, -28, -10, 31, -27, -95, 166, 104, 164, 161, -89, -28, -10, 31, -27, -93, 166, 104, 164, 161,
-99, 31, -99, 164, 88, -78, 162, 163, 9, 17, -97, 31, -97, 164, 88, -78, 162, 163, 9, 17,
-112, -84, -7, -3, -86, 163, 161, -73, 165, 162, -110, -84, -7, -3, -123, 163, 161, -73, 165, 162,
-78, 162, -20, -125, 162, 163, 165, -23, -126, 31, -78, 162, -20, -125, 162, 163, 165, -23, -126, 31,
163, 162, 163, 107, -99, -73, 165, 165, 163, -110, 163, 162, 163, 107, -97, -73, 165, 165, 163, -108,
-9, -73, 161, -100, 161, -92, -56, 88, 37, 17, -9, -73, 161, -98, 161, -90, -56, 88, 37, 17,
162, -46, -23, 163, 9, 17, -7, 162, -90, -41, 162, -46, -23, 163, 9, 17, -7, 162, -122, -41,
-42, -43, -44, -45, -9, -7, 154, 86, 162, 162, -42, -43, -44, -45, -9, -7, 154, 86, 162, 162,
-26, -10, 31, -126, -73, 163, 161, 102, -28, 88, -26, -10, 31, -126, -73, 163, 161, 102, -28, 88,
35, 162, -73, -73, 165, 9, 88, -23, -84, -23, 35, 162, -73, -73, 165, 9, 88, -23, -84, -23,
164, 162, -41, 163, 163, 121, 105, 153, -73, -73, 164, 162, -41, 163, 163, 121, 105, 153, -73, -73,
-73, 163, 165, -9, 162, 162, -56, -77, -85, 86, -73, 163, 165, -9, 162, 162, -56, -77, -85, 86,
-5, -104, -7, 100, 162, 161, 165, -7, 163, -73, -5, -102, -7, 100, 162, 161, 165, -7, 163, -73,
-99, 162, -87, 163, 161, -73, 162, -97, 162, -86, 163, 161, -73, 162,
} }
var yyDef = [...]int{ var yyDef = [...]int{
@ -3488,7 +3488,7 @@ yydefault:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line parser/parser.y:674 //line parser/parser.y:674
{ {
yyVAL.node = node.NewSimpleNode("Use").Append(yyDollar[2].node).Append(yyDollar[3].node) yyVAL.node = stmt.NewTraitUse(yyDollar[1].token, yyDollar[2].node.(node.SimpleNode).Children, yyDollar[3].list)
} }
case 243: case 243:
yyDollar = yyS[yypt-9 : yypt+1] yyDollar = yyS[yypt-9 : yypt+1]
@ -3512,31 +3512,31 @@ yydefault:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line parser/parser.y:687 //line parser/parser.y:687
{ {
yyVAL.node = node.NewSimpleNode("") yyVAL.list = nil
} }
case 247: case 247:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
//line parser/parser.y:688 //line parser/parser.y:688
{ {
yyVAL.node = node.NewSimpleNode("") yyVAL.list = nil
} }
case 248: case 248:
yyDollar = yyS[yypt-3 : yypt+1] yyDollar = yyS[yypt-3 : yypt+1]
//line parser/parser.y:689 //line parser/parser.y:689
{ {
yyVAL.node = yyDollar[2].node yyVAL.list = yyDollar[2].list
} }
case 249: case 249:
yyDollar = yyS[yypt-1 : yypt+1] yyDollar = yyS[yypt-1 : yypt+1]
//line parser/parser.y:693 //line parser/parser.y:693
{ {
yyVAL.node = node.NewSimpleNode("TraitAdaptionList").Append(yyDollar[1].node) yyVAL.list = []node.Node{yyDollar[1].node}
} }
case 250: case 250:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]
//line parser/parser.y:694 //line parser/parser.y:694
{ {
yyVAL.node = yyDollar[1].node.Append(yyDollar[2].node) yyVAL.list = append(yyDollar[1].list, yyDollar[2].node)
} }
case 251: case 251:
yyDollar = yyS[yypt-2 : yypt+1] yyDollar = yyS[yypt-2 : yypt+1]

View File

@ -204,8 +204,8 @@ func Parse(src io.Reader, fName string) node.Node {
%type <node> unset_variables parameter_list class_statement_list %type <node> unset_variables parameter_list class_statement_list
%type <node> implements_list if_stmt_without_else %type <node> implements_list if_stmt_without_else
%type <node> non_empty_parameter_list argument_list non_empty_argument_list %type <node> non_empty_parameter_list argument_list non_empty_argument_list
%type <node> class_const_decl name_list trait_adaptations method_body %type <node> class_const_decl name_list method_body
%type <node> ctor_arguments alt_if_stmt_without_else trait_adaptation_list lexical_vars %type <node> ctor_arguments alt_if_stmt_without_else lexical_vars
%type <node> lexical_var_list %type <node> lexical_var_list
%type <node> array_pair non_empty_array_pair_list array_pair_list possible_array_pair %type <node> array_pair non_empty_array_pair_list array_pair_list possible_array_pair
%type <node> isset_variable type return_type type_expr %type <node> isset_variable type return_type type_expr
@ -218,7 +218,7 @@ func Parse(src io.Reader, fName string) node.Node {
%type <list> encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list %type <list> encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list
%type <list> const_list echo_expr_list for_exprs non_empty_for_exprs global_var_list %type <list> const_list echo_expr_list for_exprs non_empty_for_exprs global_var_list
%type <list> unprefixed_use_declarations inline_use_declarations property_list static_var_list %type <list> unprefixed_use_declarations inline_use_declarations property_list static_var_list
%type <list> switch_case_list case_list %type <list> switch_case_list case_list trait_adaptation_list trait_adaptations
%% %%
@ -671,7 +671,7 @@ class_statement_list:
class_statement: class_statement:
variable_modifiers property_list ';' { $$ = stmt.NewPropertyList($1, $2) } variable_modifiers property_list ';' { $$ = stmt.NewPropertyList($1, $2) }
| method_modifiers T_CONST class_const_list ';' { $$ = stmt.NewClassConst($2, $1.(node.SimpleNode).Children, $3); } | method_modifiers T_CONST class_const_list ';' { $$ = stmt.NewClassConst($2, $1.(node.SimpleNode).Children, $3); }
| T_USE name_list trait_adaptations { $$ = node.NewSimpleNode("Use").Append($2).Append($3); } | T_USE name_list trait_adaptations { $$ = stmt.NewTraitUse($1, $2.(node.SimpleNode).Children, $3) }
| method_modifiers T_FUNCTION returns_ref identifier '(' parameter_list ')' return_type method_body | method_modifiers T_FUNCTION returns_ref identifier '(' parameter_list ')' return_type method_body
{ {
$$ = stmt.NewClassMethod($4, $1.(node.SimpleNode).Children, $3 == "true", $6.(node.SimpleNode).Children, $8, $9.(node.SimpleNode).Children) $$ = stmt.NewClassMethod($4, $1.(node.SimpleNode).Children, $3 == "true", $6.(node.SimpleNode).Children, $8, $9.(node.SimpleNode).Children)
@ -684,14 +684,14 @@ name_list:
; ;
trait_adaptations: trait_adaptations:
';' { $$ = node.NewSimpleNode(""); } ';' { $$ = nil }
| '{' '}' { $$ = node.NewSimpleNode(""); } | '{' '}' { $$ = nil }
| '{' trait_adaptation_list '}' { $$ = $2; } | '{' trait_adaptation_list '}' { $$ = $2; }
; ;
trait_adaptation_list: trait_adaptation_list:
trait_adaptation { $$ = node.NewSimpleNode("TraitAdaptionList").Append($1) } trait_adaptation { $$ = []node.Node{$1} }
| trait_adaptation_list trait_adaptation { $$ = $1.Append($2) } | trait_adaptation_list trait_adaptation { $$ = append($1, $2) }
; ;
trait_adaptation: trait_adaptation: