blob: 802cf470568cde7069a3c3e8af0d25daf0b49498 [file] [log] [blame]
Dusan Klinecccaa0d92014-11-09 03:21:31 +01001__author__ = "Dusan (Ph4r05) Klinec"
2__copyright__ = "Copyright (C) 2014 Dusan (ph4r05) Klinec"
3__license__ = "Apache License, Version 2.0"
4__version__ = "1.0"
5
Dusan Klinece26bb022014-11-09 12:21:37 +01006class Visitor(object):
7
8 def __init__(self, verbose=False):
9 self.verbose = verbose
10
11 def __getattr__(self, name):
12 if not name.startswith('visit_'):
Dusan Klinecc9b031a2014-11-10 13:21:08 +010013 raise AttributeError('name must start with visit_ but was {}'.format(name))
Dusan Klinece26bb022014-11-09 12:21:37 +010014
15 def f(element):
16 if self.verbose:
17 msg = 'unimplemented call to {}; ignoring ({})'
18 print(msg.format(name, element))
19 return True
20 return f
21
22 # visitor.visit_PackageStatement(self)
23 # visitor.visit_ImportStatement(self)
24 # visitor.visit_OptionStatement(self)
25 # visitor.visit_FieldDirective(self)
26 # visitor.visit_FieldType(self)
27 # visitor.visit_FieldDefinition(self)
28 # visitor.visit_EnumFieldDefinition(self)
29 # visitor.visit_EnumDefinition(self)
30 # visitor.visit_MessageDefinition(self)
31 # visitor.visit_MessageExtension(self)
32 # visitor.visit_MethodDefinition(self)
33 # visitor.visit_ServiceDefinition(self)
34 # visitor.visit_ExtensionsDirective(self)
35 # visitor.visit_Literal(self)
36 # visitor.visit_Name(self)
Dusan Klinecc9b031a2014-11-10 13:21:08 +010037 # visitor.visit_Proto(self)
Dusan Klineca9f6d362014-11-10 21:07:08 +010038 # visitor.visit_LU(self)
39
40class Base(object):
41 parent = None
Dusan Klinec00eb5da2014-11-10 21:24:15 +010042 lexspan = None
43 linespan = None
Dusan Klineca9f6d362014-11-10 21:07:08 +010044
45 def v(self, obj, visitor):
46 if obj == None:
47 return
Dusan Klinec1064fb32014-11-10 21:48:50 +010048 elif hasattr(obj, "accept"):
49 obj.accept(visitor)
50 elif isinstance(obj, list):
51 for s in obj:
52 self.v(s, visitor)
53 pass
54 pass
55
56 @staticmethod
57 def p(obj, parent):
58 if isinstance(obj, list):
59 for s in obj:
60 Base.p(s, parent)
61
62 if hasattr(obj, "parent"):
63 obj.parent = parent
Dusan Klinece26bb022014-11-09 12:21:37 +010064
Dusan Klinecaa9ff472014-11-10 18:02:03 +010065# Lexical unit - contains lexspan and linespan for later analysis.
Dusan Klineca9f6d362014-11-10 21:07:08 +010066class LU(Base):
Dusan Klinecaa9ff472014-11-10 18:02:03 +010067 def __init__(self, p, idx):
68 self.p = p
69 self.idx = idx
70 self.pval = p[idx]
71 self.lexspan = p.lexspan(idx)
72 self.linespan = p.linespan(idx)
73
74 # If string is in the value (raw value) and start and stop lexspan is the same, add real span
75 # obtained by string length.
76 if isinstance(self.pval, str) \
77 and self.lexspan != None \
78 and self.lexspan[0] == self.lexspan[1] \
79 and self.lexspan[0] != 0:
80 self.lexspan = tuple([self.lexspan[0], self.lexspan[0] + len(self.pval)])
81 super(LU, self).__init__()
82
83 @staticmethod
84 def i(p, idx):
85 if isinstance(p[idx], LU): return p[idx]
86 if isinstance(p[idx], str): return LU(p, idx)
87 return p[idx]
88
89 def describe(self):
90 return "LU(%s,%s)" % (self.pval, self.lexspan)
91
92 def __str__(self):
93 return self.pval
94
95 def __repr__(self):
96 return self.describe()
97
98 def accept(self, visitor):
Dusan Klineca9f6d362014-11-10 21:07:08 +010099 self.v(self.pval, visitor)
Dusan Klinecaa9ff472014-11-10 18:02:03 +0100100
101 def __iter__(self):
102 for x in self.pval:
103 yield x
104
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100105# Base node
Dusan Klineca9f6d362014-11-10 21:07:08 +0100106class SourceElement(Base):
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100107 '''
Dusan Klinece26bb022014-11-09 12:21:37 +0100108 A SourceElement is the base class for all elements that occur in a Protocol Buffers
109 file parsed by plyproto.
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100110 '''
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100111 def __init__(self, linespan=[], lexspan=[], p=None):
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100112 super(SourceElement, self).__init__()
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100113 self._fields = [] # ['linespan', 'lexspan']
114 self.linespan = linespan
115 self.lexspan = lexspan
116 self.p = p
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100117
118 def __repr__(self):
119 equals = ("{0}={1!r}".format(k, getattr(self, k))
120 for k in self._fields)
121 args = ", ".join(equals)
122 return "{0}({1})".format(self.__class__.__name__, args)
123
124 def __eq__(self, other):
125 try:
126 return self.__dict__ == other.__dict__
127 except AttributeError:
128 return False
129
130 def __ne__(self, other):
131 return not self == other
132
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100133 def setLexData(self, linespan, lexspan):
134 self.linespan = linespan
135 self.lexspan = lexspan
136
137 def setLexObj(self, p):
138 self.p = p
139
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100140 def accept(self, visitor):
141 pass
142
Dusan Klinece26bb022014-11-09 12:21:37 +0100143class PackageStatement(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100144 def __init__(self, name, linespan=None, lexspan=None, p=None):
145 super(PackageStatement, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
146 self._fields += ['name']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100147 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100148 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100149
150 def accept(self, visitor):
Dusan Klinece26bb022014-11-09 12:21:37 +0100151 visitor.visit_PackageStatement(self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100152
153class ImportStatement(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100154 def __init__(self, name, linespan=None, lexspan=None, p=None):
155 super(ImportStatement, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
156 self._fields += ['name']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100157 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100158 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100159
160 def accept(self, visitor):
161 visitor.visit_ImportStatement(self)
162
Dusan Klinece26bb022014-11-09 12:21:37 +0100163class OptionStatement(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100164 def __init__(self, name, value, linespan=None, lexspan=None, p=None):
165 super(OptionStatement, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
166 self._fields += ['name', 'value']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100167 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100168 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100169 self.value = value
Dusan Klinec1064fb32014-11-10 21:48:50 +0100170 Base.p(self.value, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100171
172 def accept(self, visitor):
Dusan Klinece26bb022014-11-09 12:21:37 +0100173 visitor.visit_OptionStatement(self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100174
Dusan Klinece26bb022014-11-09 12:21:37 +0100175class FieldDirective(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100176 def __init__(self, name, value, linespan=None, lexspan=None, p=None):
177 super(FieldDirective, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
178 self._fields += ['name', 'value']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100179 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100180 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100181 self.value = value
Dusan Klinec1064fb32014-11-10 21:48:50 +0100182 Base.p(self.value, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100183
184 def accept(self, visitor):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100185 if visitor.visit_FieldDirective(self):
186 self.v(self.name, visitor)
187 self.v(self.value, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100188
Dusan Klinece26bb022014-11-09 12:21:37 +0100189class FieldType(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100190 def __init__(self, name, linespan=None, lexspan=None, p=None):
191 super(FieldType, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
192 self._fields += ['name']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100193 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100194 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100195
196 def accept(self, visitor):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100197 if visitor.visit_FieldType(self):
198 self.v(self.name, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100199
Dusan Klinece26bb022014-11-09 12:21:37 +0100200class FieldDefinition(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100201 def __init__(self, field_modifier, ftype, name, fieldId, fieldDirective, linespan=None, lexspan=None, p=None):
202 super(FieldDefinition, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
203 self._fields += ['field_modifier', 'ftype', 'name', 'fieldId', 'fieldDirective']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100204 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100205 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100206 self.field_modifier = field_modifier
Dusan Klinec1064fb32014-11-10 21:48:50 +0100207 Base.p(self.field_modifier, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100208 self.ftype = ftype
Dusan Klinec1064fb32014-11-10 21:48:50 +0100209 Base.p(self.ftype, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100210 self.fieldId = fieldId
Dusan Klinec1064fb32014-11-10 21:48:50 +0100211 Base.p(self.fieldId, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100212 self.fieldDirective = fieldDirective
Dusan Klinec1064fb32014-11-10 21:48:50 +0100213 Base.p(self.fieldDirective, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100214
215 def accept(self, visitor):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100216 if visitor.visit_FieldDefinition(self):
217 self.v(self.name, visitor)
218 self.v(self.field_modifier, visitor)
219 self.v(self.ftype, visitor)
220 self.v(self.fieldId, visitor)
Dusan Klinec1064fb32014-11-10 21:48:50 +0100221 self.v(self.fieldDirective, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100222
Dusan Klinece26bb022014-11-09 12:21:37 +0100223class EnumFieldDefinition(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100224 def __init__(self, name, fieldId, linespan=None, lexspan=None, p=None):
225 super(EnumFieldDefinition, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
226 self._fields += ['name', 'fieldId']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100227 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100228 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100229 self.fieldId = fieldId
Dusan Klinec1064fb32014-11-10 21:48:50 +0100230 Base.p(self.fieldId, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100231
232 def accept(self, visitor):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100233 if visitor.visit_EnumFieldDefinition(self):
234 self.v(self.name, visitor)
235 self.v(self.fieldId, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100236
Dusan Klinece26bb022014-11-09 12:21:37 +0100237class EnumDefinition(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100238 def __init__(self, name, body, linespan=None, lexspan=None, p=None):
239 super(EnumDefinition, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
240 self._fields += ['name', 'body']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100241 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100242 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100243 self.body = body
Dusan Klinec1064fb32014-11-10 21:48:50 +0100244 Base.p(self.body, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100245
246 def accept(self, visitor):
Dusan Klinece26bb022014-11-09 12:21:37 +0100247 if visitor.visit_EnumDefinition(self):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100248 self.v(self.name, visitor)
Dusan Klinec1064fb32014-11-10 21:48:50 +0100249 self.v(self.body, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100250
Dusan Klinece26bb022014-11-09 12:21:37 +0100251class MessageDefinition(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100252 def __init__(self, name, body, linespan=None, lexspan=None, p=None):
253 super(MessageDefinition, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
254 self._fields += ['name', 'body']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100255 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100256 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100257 self.body = body
Dusan Klinec1064fb32014-11-10 21:48:50 +0100258 Base.p(self.body, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100259
260 def accept(self, visitor):
Dusan Klinece26bb022014-11-09 12:21:37 +0100261 if visitor.visit_MessageDefinition(self):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100262 self.v(self.name, visitor)
Dusan Klinec1064fb32014-11-10 21:48:50 +0100263 self.v(self.body, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100264
265class MessageExtension(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100266 def __init__(self, name, body, linespan=None, lexspan=None, p=None):
267 super(MessageExtension, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
268 self._fields += ['name', 'body']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100269 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100270 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100271 self.body = body
Dusan Klinec1064fb32014-11-10 21:48:50 +0100272 Base.p(self.body, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100273
274 def accept(self, visitor):
275 if visitor.visit_MessageExtension(self):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100276 self.v(self.name, visitor)
Dusan Klinec1064fb32014-11-10 21:48:50 +0100277 self.v(self.body, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100278
279class MethodDefinition(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100280 def __init__(self, name, name2, name3, linespan=None, lexspan=None, p=None):
281 super(MethodDefinition, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
282 self._fields += ['name', 'name2', 'name3']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100283 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100284 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100285 self.name2 = name2
Dusan Klinec1064fb32014-11-10 21:48:50 +0100286 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100287 self.name3 = name3
Dusan Klinec1064fb32014-11-10 21:48:50 +0100288 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100289
290 def accept(self, visitor):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100291 if visitor.visit_MethodDefinition(self):
292 self.v(self.name, visitor)
293 self.v(self.name2, visitor)
294 self.v(self.name3, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100295
Dusan Klinece26bb022014-11-09 12:21:37 +0100296class ServiceDefinition(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100297 def __init__(self, name, body, linespan=None, lexspan=None, p=None):
298 super(ServiceDefinition, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
299 self._fields += ['name', 'body']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100300 self.name = name
Dusan Klinec1064fb32014-11-10 21:48:50 +0100301 Base.p(self.name, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100302 self.body = body
Dusan Klinec1064fb32014-11-10 21:48:50 +0100303 Base.p(self.body, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100304
305 def accept(self, visitor):
Dusan Klinece26bb022014-11-09 12:21:37 +0100306 if visitor.visit_ServiceDefinition(self):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100307 self.v(self.name, visitor)
Dusan Klinec1064fb32014-11-10 21:48:50 +0100308 self.v(self.body, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100309
310class ExtensionsMax(SourceElement):
311 pass
312
313class ExtensionsDirective(SourceElement):
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100314 def __init__(self, fromVal, toVal, linespan=None, lexspan=None, p=None):
315 super(ExtensionsDirective, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
316 self._fields += ['fromVal', 'toVal']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100317 self.fromVal = fromVal
Dusan Klinec1064fb32014-11-10 21:48:50 +0100318 Base.p(self.fromVal, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100319 self.toVal = toVal
Dusan Klinec1064fb32014-11-10 21:48:50 +0100320 Base.p(self.toVal, self)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100321
322 def accept(self, visitor):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100323 if visitor.visit_ExtensionsDirective(self):
324 self.v(self.fromVal, visitor)
325 self.v(self.toVal, visitor)
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100326
327class Literal(SourceElement):
328
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100329 def __init__(self, value, linespan=None, lexspan=None, p=None):
330 super(Literal, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
331 self._fields += ['value']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100332 self.value = value
333
334 def accept(self, visitor):
335 visitor.visit_Literal(self)
336
337class Name(SourceElement):
338
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100339 def __init__(self, value, linespan=None, lexspan=None, p=None):
340 super(Name, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
341 self._fields += ['value']
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100342 self.value = value
Dusan Klinecaa9ff472014-11-10 18:02:03 +0100343 self.deriveLex()
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100344
345 def append_name(self, name):
346 try:
347 self.value = self.value + '.' + name.value
348 except:
349 self.value = self.value + '.' + name
350
Dusan Klinecaa9ff472014-11-10 18:02:03 +0100351 def deriveLex(self):
352 if hasattr(self.value, "lexspan"):
353 self.lexspan = self.value.lexspan
354 self.linespan = self.value.linespan
355 else:
356 return
357
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100358 def accept(self, visitor):
359 visitor.visit_Name(self)
360
Dusan Klinecaa9ff472014-11-10 18:02:03 +0100361class DotName(Name):
362 elements = []
363 def __init__(self, elements, linespan=None, lexspan=None, p=None):
364 super(DotName, self).__init__('.'.join([str(x) for x in elements]), linespan=linespan, lexspan=lexspan, p=p)
365 self._fields += ['elements']
366 self.elements = elements
367 self.deriveLex()
368
369 def deriveLex(self):
370 if isinstance(self.elements, list) and len(self.elements)>0:
371 self.lexspan = (min([x.lexspan[0] for x in self.elements if x.lexspan[0] != 0]), max([x.lexspan[1] for x in self.elements if x.lexspan[1] != 0]))
372 self.linespan = (min([x.linespan[0] for x in self.elements if x.linespan[0] != 0]), max([x.linespan[1] for x in self.elements if x.linespan[1] != 0]))
373 elif hasattr(self.elements, "lexspan"):
374 self.lexspan = self.elements.lexspan
375 self.linespan = self.elements.linespan
376 else:
377 return
378
379 def accept(self, visitor):
380 visitor.visit_DotName(self)
381
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100382class ProtoFile(SourceElement):
Dusan Klinecccaa0d92014-11-09 03:21:31 +0100383
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100384 def __init__(self, pkg, body, linespan=None, lexspan=None, p=None):
385 super(ProtoFile, self).__init__(linespan=linespan, lexspan=lexspan, p=p)
386 self._fields += ['pkg', 'body']
387 self.pkg = pkg
Dusan Klinec1064fb32014-11-10 21:48:50 +0100388 Base.p(self.pkg, self)
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100389 self.body = body
Dusan Klinec1064fb32014-11-10 21:48:50 +0100390 Base.p(self.body, self)
Dusan Klinecc9b031a2014-11-10 13:21:08 +0100391
392 def accept(self, visitor):
393 if visitor.visit_Proto(self):
Dusan Klineca9f6d362014-11-10 21:07:08 +0100394 self.v(self.pkg, visitor)
Dusan Klinec1064fb32014-11-10 21:48:50 +0100395 self.v(self.body, visitor)