OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ Parser for PPAPI IDL """ | 6 """ Parser for PPAPI IDL """ |
7 | 7 |
8 # | 8 # |
9 # IDL Parser | 9 # IDL Parser |
10 # | 10 # |
11 # The parser is uses the PLY yacc library to build a set of parsing rules based | 11 # The parser is uses the PLY yacc library to build a set of parsing rules based |
12 # on WebIDL. | 12 # on WebIDL. |
13 # | 13 # |
14 # WebIDL, and WebIDL grammar can be found at: | 14 # WebIDL, and WebIDL grammar can be found at: |
15 # http://dev.w3.org/2006/webapi/WebIDL/ | 15 # http://heycam.github.io/webidl/ |
16 # PLY can be found at: | 16 # PLY can be found at: |
17 # http://www.dabeaz.com/ply/ | 17 # http://www.dabeaz.com/ply/ |
18 # | 18 # |
19 # The parser generates a tree by recursively matching sets of items against | 19 # The parser generates a tree by recursively matching sets of items against |
20 # defined patterns. When a match is made, that set of items is reduced | 20 # defined patterns. When a match is made, that set of items is reduced |
21 # to a new item. The new item can provide a match for parent patterns. | 21 # to a new item. The new item can provide a match for parent patterns. |
22 # In this way an AST is built (reduced) depth first. | 22 # In this way an AST is built (reduced) depth first. |
23 # | 23 # |
24 | 24 |
25 # | 25 # |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 # separated by the "|". | 137 # separated by the "|". |
138 # | 138 # |
139 # The function is called with an object 'p' where p[0] is the output object | 139 # The function is called with an object 'p' where p[0] is the output object |
140 # and p[n] is the set of inputs for positive values of 'n'. Len(p) can be | 140 # and p[n] is the set of inputs for positive values of 'n'. Len(p) can be |
141 # used to distinguish between multiple item sets in the pattern. | 141 # used to distinguish between multiple item sets in the pattern. |
142 # | 142 # |
143 # For more details on parsing refer to the PLY documentation at | 143 # For more details on parsing refer to the PLY documentation at |
144 # http://www.dabeaz.com/ply/ | 144 # http://www.dabeaz.com/ply/ |
145 # | 145 # |
146 # The parser is based on the WebIDL standard. See: | 146 # The parser is based on the WebIDL standard. See: |
147 # http://www.w3.org/TR/WebIDL/#idl-grammar | 147 # http://heycam.github.io/webidl/#idl-grammar |
148 # | 148 # |
149 # The various productions are annotated so that the WHOLE number greater than | 149 # The various productions are annotated so that the WHOLE number greater than |
150 # zero in the comment denotes the matching WebIDL grammar definition. | 150 # zero in the comment denotes the matching WebIDL grammar definition. |
151 # | 151 # |
152 # Productions with a fractional component in the comment denote additions to | 152 # Productions with a fractional component in the comment denote additions to |
153 # the WebIDL spec, such as comments. | 153 # the WebIDL spec, such as comments. |
154 # | 154 # |
155 | 155 |
156 | 156 |
157 class IDLParser(object): | 157 class IDLParser(object): |
(...skipping 18 matching lines...) Expand all Loading... | |
176 # [0.2] Produce a COMMENT and aggregate sibling comments | 176 # [0.2] Produce a COMMENT and aggregate sibling comments |
177 def p_CommentsRest(self, p): | 177 def p_CommentsRest(self, p): |
178 """CommentsRest : COMMENT CommentsRest | 178 """CommentsRest : COMMENT CommentsRest |
179 | """ | 179 | """ |
180 if len(p) > 1: | 180 if len(p) > 1: |
181 p[0] = ListFromConcat(self.BuildComment('Comment', p, 1), p[2]) | 181 p[0] = ListFromConcat(self.BuildComment('Comment', p, 1), p[2]) |
182 | 182 |
183 | 183 |
184 # | 184 # |
185 #The parser is based on the WebIDL standard. See: | 185 #The parser is based on the WebIDL standard. See: |
186 # http://www.w3.org/TR/WebIDL/#idl-grammar | 186 # http://heycam.github.io/webidl/#idl-grammar |
187 # | 187 # |
188 # [1] | 188 # [1] |
189 def p_Definitions(self, p): | 189 def p_Definitions(self, p): |
190 """Definitions : ExtendedAttributeList Definition Definitions | 190 """Definitions : ExtendedAttributeList Definition Definitions |
191 | """ | 191 | """ |
192 if len(p) > 1: | 192 if len(p) > 1: |
193 p[2].AddChildren(p[1]) | 193 p[2].AddChildren(p[1]) |
194 p[0] = ListFromConcat(p[2], p[3]) | 194 p[0] = ListFromConcat(p[2], p[3]) |
195 | 195 |
196 # [2] Add INLINE definition | 196 # [2] |
197 def p_Definition(self, p): | 197 def p_Definition(self, p): |
198 """Definition : CallbackOrInterface | 198 """Definition : CallbackOrInterface |
199 | Partial | 199 | Partial |
200 | Dictionary | 200 | Dictionary |
201 | Exception | 201 | Exception |
202 | Enum | 202 | Enum |
203 | Typedef | 203 | Typedef |
204 | ImplementsStatement""" | 204 | ImplementsStatement""" |
205 p[0] = p[1] | 205 p[0] = p[1] |
206 | 206 |
(...skipping 15 matching lines...) Expand all Loading... | |
222 def p_CallbackRestOrInterface(self, p): | 222 def p_CallbackRestOrInterface(self, p): |
223 """CallbackRestOrInterface : CallbackRest | 223 """CallbackRestOrInterface : CallbackRest |
224 | Interface""" | 224 | Interface""" |
225 p[0] = p[1] | 225 p[0] = p[1] |
226 | 226 |
227 # [5] | 227 # [5] |
228 def p_Interface(self, p): | 228 def p_Interface(self, p): |
229 """Interface : INTERFACE identifier Inheritance '{' InterfaceMembers '}' ';' """ | 229 """Interface : INTERFACE identifier Inheritance '{' InterfaceMembers '}' ';' """ |
230 p[0] = self.BuildNamed('Interface', p, 2, ListFromConcat(p[3], p[5])) | 230 p[0] = self.BuildNamed('Interface', p, 2, ListFromConcat(p[3], p[5])) |
231 | 231 |
232 # [6] Error recovery for PARTIAL | 232 # [6] |
233 def p_Partial(self, p): | 233 def p_Partial(self, p): |
234 """Partial : PARTIAL PartialDefinition""" | 234 """Partial : PARTIAL PartialDefinition""" |
235 p[2].AddChildren(self.BuildTrue('Partial')) | 235 p[2].AddChildren(self.BuildTrue('Partial')) |
236 p[0] = p[2] | 236 p[0] = p[2] |
237 | 237 |
238 # [6.1] Error recovery for Enums | 238 # [6.1] Error recovery for Partial |
239 def p_PartialError(self, p): | 239 def p_PartialError(self, p): |
240 """Partial : PARTIAL error""" | 240 """Partial : PARTIAL error""" |
241 p[0] = self.BuildError(p, 'Partial') | 241 p[0] = self.BuildError(p, 'Partial') |
242 | 242 |
243 # [7] | 243 # [7] |
244 def p_PartialDefinition(self, p): | 244 def p_PartialDefinition(self, p): |
245 """PartialDefinition : PartialDictionary | 245 """PartialDefinition : PartialDictionary |
246 | PartialInterface""" | 246 | PartialInterface""" |
247 p[0] = p[1] | 247 p[0] = p[1] |
248 | 248 |
249 # [8] | 249 # [8] |
250 def p_PartialInterface(self, p): | 250 def p_PartialInterface(self, p): |
251 """PartialInterface : INTERFACE identifier '{' InterfaceMembers '}' ';'""" | 251 """PartialInterface : INTERFACE identifier '{' InterfaceMembers '}' ';'""" |
252 p[0] = self.BuildNamed('Interface', p, 2, p[4]) | 252 p[0] = self.BuildNamed('Interface', p, 2, p[4]) |
253 | 253 |
254 # [9] | 254 # [9] |
255 def p_InterfaceMembers(self, p): | 255 def p_InterfaceMembers(self, p): |
256 """InterfaceMembers : ExtendedAttributeList InterfaceMember InterfaceMembers | 256 """InterfaceMembers : ExtendedAttributeList InterfaceMember InterfaceMembers |
257 |""" | 257 |""" |
258 if len(p) > 1: | 258 if len(p) > 1: |
259 p[2].AddChildren(p[1]) | 259 p[2].AddChildren(p[1]) |
260 p[0] = ListFromConcat(p[2], p[3]) | 260 p[0] = ListFromConcat(p[2], p[3]) |
261 | 261 |
262 # [10] | 262 # [10] |
263 def p_InterfaceMember(self, p): | 263 def p_InterfaceMember(self, p): |
264 """InterfaceMember : Const | 264 """InterfaceMember : Const |
265 | AttributeOrOperation""" | 265 | AttributeOrOperationOrIterator""" |
266 p[0] = p[1] | 266 p[0] = p[1] |
267 | 267 |
268 # [11] | 268 # [11] |
269 def p_Dictionary(self, p): | 269 def p_Dictionary(self, p): |
270 """Dictionary : DICTIONARY identifier Inheritance '{' DictionaryMembers '}' ';'""" | 270 """Dictionary : DICTIONARY identifier Inheritance '{' DictionaryMembers '}' ';'""" |
271 p[0] = self.BuildNamed('Dictionary', p, 2, ListFromConcat(p[3], p[5])) | 271 p[0] = self.BuildNamed('Dictionary', p, 2, ListFromConcat(p[3], p[5])) |
272 | 272 |
273 # [11.1] Error recovery for regular Dictionary | 273 # [11.1] Error recovery for regular Dictionary |
274 def p_DictionaryError(self, p): | 274 def p_DictionaryError(self, p): |
275 """Dictionary : DICTIONARY error ';'""" | 275 """Dictionary : DICTIONARY error ';'""" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 """Enum : ENUM identifier '{' EnumValueList '}' ';'""" | 346 """Enum : ENUM identifier '{' EnumValueList '}' ';'""" |
347 p[0] = self.BuildNamed('Enum', p, 2, p[4]) | 347 p[0] = self.BuildNamed('Enum', p, 2, p[4]) |
348 | 348 |
349 # [20.1] Error recovery for Enums | 349 # [20.1] Error recovery for Enums |
350 def p_EnumError(self, p): | 350 def p_EnumError(self, p): |
351 """Enum : ENUM error ';'""" | 351 """Enum : ENUM error ';'""" |
352 p[0] = self.BuildError(p, 'Enum') | 352 p[0] = self.BuildError(p, 'Enum') |
353 | 353 |
354 # [21] | 354 # [21] |
355 def p_EnumValueList(self, p): | 355 def p_EnumValueList(self, p): |
356 """EnumValueList : ExtendedAttributeList string EnumValues""" | 356 """EnumValueList : ExtendedAttributeList string EnumValueListComma""" |
357 enum = self.BuildNamed('EnumItem', p, 2, p[1]) | 357 enum = self.BuildNamed('EnumItem', p, 2, p[1]) |
358 p[0] = ListFromConcat(enum, p[3]) | 358 p[0] = ListFromConcat(enum, p[3]) |
359 | 359 |
360 # [22] | 360 # [22] |
361 def p_EnumValues(self, p): | 361 def p_EnumValueListComma(self, p): |
362 """EnumValues : ',' ExtendedAttributeList string EnumValues | 362 """EnumValueListComma : ',' EnumValueListString |
363 |""" | 363 |""" |
364 if len(p) > 1: | 364 if len(p) > 1: |
365 enum = self.BuildNamed('EnumItem', p, 3, p[2]) | 365 p[0] = p[2] |
366 p[0] = ListFromConcat(enum, p[4]) | |
367 | 366 |
368 # [23] | 367 # [23] |
368 def p_EnumValueListString(self, p): | |
369 """EnumValueListString : ExtendedAttributeList string EnumValueListComma | |
370 |""" | |
371 if len(p) > 1: | |
372 enum = self.BuildNamed('EnumItem', p, 2, p[1]) | |
373 p[0] = ListFromConcat(enum, p[3]) | |
374 | |
375 # [24] | |
369 def p_CallbackRest(self, p): | 376 def p_CallbackRest(self, p): |
370 """CallbackRest : identifier '=' ReturnType '(' ArgumentList ')' ';'""" | 377 """CallbackRest : identifier '=' ReturnType '(' ArgumentList ')' ';'""" |
371 arguments = self.BuildProduction('Arguments', p, 4, p[5]) | 378 arguments = self.BuildProduction('Arguments', p, 4, p[5]) |
372 p[0] = self.BuildNamed('Callback', p, 1, ListFromConcat(p[3], arguments)) | 379 p[0] = self.BuildNamed('Callback', p, 1, ListFromConcat(p[3], arguments)) |
373 | 380 |
374 # [24] | 381 # [25] |
375 def p_Typedef(self, p): | 382 def p_Typedef(self, p): |
376 """Typedef : TYPEDEF ExtendedAttributeListNoComments Type identifier ';'""" | 383 """Typedef : TYPEDEF ExtendedAttributeListNoComments Type identifier ';'""" |
377 p[0] = self.BuildNamed('Typedef', p, 4, ListFromConcat(p[2], p[3])) | 384 p[0] = self.BuildNamed('Typedef', p, 4, ListFromConcat(p[2], p[3])) |
378 | 385 |
379 # [24.1] Error recovery for Typedefs | 386 # [25.1] Error recovery for Typedefs |
380 def p_TypedefError(self, p): | 387 def p_TypedefError(self, p): |
381 """Typedef : TYPEDEF error ';'""" | 388 """Typedef : TYPEDEF error ';'""" |
382 p[0] = self.BuildError(p, 'Typedef') | 389 p[0] = self.BuildError(p, 'Typedef') |
383 | 390 |
384 # [25] | 391 # [26] |
385 def p_ImplementsStatement(self, p): | 392 def p_ImplementsStatement(self, p): |
386 """ImplementsStatement : identifier IMPLEMENTS identifier ';'""" | 393 """ImplementsStatement : identifier IMPLEMENTS identifier ';'""" |
387 name = self.BuildAttribute('REFERENCE', p[3]) | 394 name = self.BuildAttribute('REFERENCE', p[3]) |
388 p[0] = self.BuildNamed('Implements', p, 1, name) | 395 p[0] = self.BuildNamed('Implements', p, 1, name) |
389 | 396 |
390 # [26] | 397 # [27] |
391 def p_Const(self, p): | 398 def p_Const(self, p): |
392 """Const : CONST ConstType identifier '=' ConstValue ';'""" | 399 """Const : CONST ConstType identifier '=' ConstValue ';'""" |
393 value = self.BuildProduction('Value', p, 5, p[5]) | 400 value = self.BuildProduction('Value', p, 5, p[5]) |
394 p[0] = self.BuildNamed('Const', p, 3, ListFromConcat(p[2], value)) | 401 p[0] = self.BuildNamed('Const', p, 3, ListFromConcat(p[2], value)) |
395 | 402 |
396 # [27] | 403 # [28] |
397 def p_ConstValue(self, p): | 404 def p_ConstValue(self, p): |
398 """ConstValue : BooleanLiteral | 405 """ConstValue : BooleanLiteral |
399 | FloatLiteral | 406 | FloatLiteral |
400 | integer | 407 | integer |
401 | null""" | 408 | null""" |
402 if type(p[1]) == str: | 409 if type(p[1]) == str: |
403 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'integer'), | 410 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'integer'), |
404 self.BuildAttribute('NAME', p[1])) | 411 self.BuildAttribute('NAME', p[1])) |
405 else: | 412 else: |
406 p[0] = p[1] | 413 p[0] = p[1] |
407 | 414 |
408 # [27.1] Add definition for NULL | 415 # [28.1] Add definition for NULL |
409 def p_null(self, p): | 416 def p_null(self, p): |
410 """null : NULL""" | 417 """null : NULL""" |
411 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'NULL'), | 418 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'NULL'), |
412 self.BuildAttribute('NAME', 'NULL')) | 419 self.BuildAttribute('NAME', 'NULL')) |
413 | 420 |
414 # [28] | 421 # [29] |
415 def p_BooleanLiteral(self, p): | 422 def p_BooleanLiteral(self, p): |
416 """BooleanLiteral : TRUE | 423 """BooleanLiteral : TRUE |
417 | FALSE""" | 424 | FALSE""" |
418 value = self.BuildAttribute('VALUE', Boolean(p[1] == 'true')) | 425 value = self.BuildAttribute('VALUE', Boolean(p[1] == 'true')) |
419 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'boolean'), value) | 426 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'boolean'), value) |
420 | 427 |
421 # [29] | 428 # [30] |
422 def p_FloatLiteral(self, p): | 429 def p_FloatLiteral(self, p): |
423 """FloatLiteral : float | 430 """FloatLiteral : float |
424 | '-' INFINITY | 431 | '-' INFINITY |
425 | INFINITY | 432 | INFINITY |
426 | NAN """ | 433 | NAN """ |
427 if len(p) > 2: | 434 if len(p) > 2: |
428 val = '-Infinity' | 435 val = '-Infinity' |
429 else: | 436 else: |
430 val = p[1] | 437 val = p[1] |
431 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'), | 438 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'), |
432 self.BuildAttribute('VALUE', val)) | 439 self.BuildAttribute('VALUE', val)) |
433 | 440 |
434 # [30] | 441 # [31] Removed unsupported: Serializer, Stringifier |
435 def p_AttributeOrOperation(self, p): | 442 def p_AttributeOrOperationOrIterator(self, p): |
436 """AttributeOrOperation : STRINGIFIER StringifierAttributeOrOperation | 443 """AttributeOrOperationOrIterator : StaticMember |
437 | Attribute | 444 | Attribute |
438 | Operation""" | 445 | OperationOrIterator""" |
439 if len(p) > 2: | 446 p[0] = p[1] |
447 | |
448 # [32-39] NOT IMPLEMENTED | |
Nils Barth (inactive)
2014/06/16 06:50:48
Could you link to the stringifier bug?
// FIXME: N
| |
449 | |
450 # [40] | |
451 def p_StaticMember(self, p): | |
452 """StaticMember : STATIC StaticMemberRest""" | |
453 p[2].AddChildren(self.BuildTrue('STATIC')) | |
454 p[0] = p[2] | |
455 | |
456 # [41] | |
457 def p_StaticMemberRest(self, p): | |
458 """StaticMemberRest : AttributeRest | |
459 | ReturnType OperationRest""" | |
460 if len(p) == 2: | |
461 p[0] = p[1] | |
462 else: | |
463 p[2].AddChildren(p[1]) | |
440 p[0] = p[2] | 464 p[0] = p[2] |
441 else: | |
442 p[0] = p[1] | |
443 | 465 |
444 # [31] | 466 # [42] |
445 def p_StringifierAttributeOrOperation(self, p): | 467 def p_Attribute(self, p): |
446 """StringifierAttributeOrOperation : Attribute | 468 """Attribute : Inherit AttributeRest""" |
447 | OperationRest | 469 p[2].AddChildren(ListFromConcat(p[1])) |
448 | ';'""" | 470 p[0] = p[2] |
449 if p[1] == ';': | |
450 p[0] = self.BuildAttribute('STRINGIFIER', Boolean(True)) | |
451 else: | |
452 p[0] = ListFromConcat(self.BuildAttribute('STRINGIFIER', p[1]), p[1]) | |
453 | 471 |
454 # [32] | 472 # [43] |
455 def p_Attribute(self, p): | 473 def p_AttributeRest(self, p): |
456 """Attribute : Inherit ReadOnly ATTRIBUTE Type identifier ';'""" | 474 """AttributeRest : ReadOnly ATTRIBUTE Type identifier ';'""" |
457 p[0] = self.BuildNamed('Attribute', p, 5, | 475 p[0] = self.BuildNamed('Attribute', p, 4, |
458 ListFromConcat(p[1], p[2], p[4])) | 476 ListFromConcat(p[1], p[3])) |
459 | 477 |
460 # [33] | 478 # [44] |
461 def p_Inherit(self, p): | 479 def p_Inherit(self, p): |
462 """Inherit : INHERIT | 480 """Inherit : INHERIT |
463 |""" | 481 |""" |
464 if len(p) > 1: | 482 if len(p) > 1: |
465 p[0] = self.BuildTrue('INHERIT') | 483 p[0] = self.BuildTrue('INHERIT') |
466 | 484 |
467 # [34] | 485 # [45] |
468 def p_ReadOnly(self, p): | 486 def p_ReadOnly(self, p): |
469 """ReadOnly : READONLY | 487 """ReadOnly : READONLY |
470 |""" | 488 |""" |
471 if len(p) > 1: | 489 if len(p) > 1: |
472 p[0] = self.BuildTrue('READONLY') | 490 p[0] = self.BuildTrue('READONLY') |
473 | 491 |
474 # [35] | 492 # [46] |
475 def p_Operation(self, p): | 493 def p_OperationOrIterator(self, p): |
476 """Operation : Qualifiers OperationRest""" | 494 """OperationOrIterator : ReturnType OperationOrIteratorRest |
477 p[2].AddChildren(p[1]) | 495 | SpecialOperation""" |
478 p[0] = p[2] | 496 if len(p) == 3: |
479 | 497 p[2].AddChildren(p[1]) |
480 # [36] | 498 p[0] = p[2] |
481 def p_Qualifiers(self, p): | |
482 """Qualifiers : STATIC | |
483 | Specials""" | |
484 if p[1] == 'static': | |
485 p[0] = self.BuildTrue('STATIC') | |
486 else: | 499 else: |
487 p[0] = p[1] | 500 p[0] = p[1] |
488 | 501 |
489 # [37] | 502 # [47] |
503 def p_SpecialOperation(self, p): | |
504 """SpecialOperation : Special Specials ReturnType OperationRest""" | |
505 p[4].AddChildren(ListFromConcat(p[1], p[2], p[3])) | |
506 p[0] = p[4] | |
507 | |
508 # [48] | |
490 def p_Specials(self, p): | 509 def p_Specials(self, p): |
491 """Specials : Special Specials | 510 """Specials : Special Specials |
492 | """ | 511 | """ |
493 if len(p) > 1: | 512 if len(p) > 1: |
494 p[0] = ListFromConcat(p[1], p[2]) | 513 p[0] = ListFromConcat(p[1], p[2]) |
495 | 514 |
496 # [38] | 515 # [49] |
497 def p_Special(self, p): | 516 def p_Special(self, p): |
498 """Special : GETTER | 517 """Special : GETTER |
499 | SETTER | 518 | SETTER |
500 | CREATOR | 519 | CREATOR |
501 | DELETER | 520 | DELETER |
502 | LEGACYCALLER""" | 521 | LEGACYCALLER""" |
503 p[0] = self.BuildTrue(p[1].upper()) | 522 p[0] = self.BuildTrue(p[1].upper()) |
504 | 523 |
524 # [50] Removed unsupported: IteratorRest | |
525 def p_OperationOrIteratorRest(self, p): | |
526 """OperationOrIteratorRest : OperationRest""" | |
527 p[0] = p[1] | |
505 | 528 |
506 # [39] | 529 # [51-53] NOT IMPLEMENTED |
Nils Barth (inactive)
2014/06/16 06:50:48
Could you elab as "NOT IMPLEMENTED (iterator)"
Do
Jens Widell
2014/06/16 10:39:49
I had no plans right now, at least. Implementing s
Nils Barth (inactive)
2014/06/17 05:08:18
Got it; as a rule we don't add support for anythin
| |
530 | |
531 # [54] | |
507 def p_OperationRest(self, p): | 532 def p_OperationRest(self, p): |
508 """OperationRest : ReturnType OptionalIdentifier '(' ArgumentList ')' ';'""" | 533 """OperationRest : OptionalIdentifier '(' ArgumentList ')' ';'""" |
509 arguments = self.BuildProduction('Arguments', p, 3, p[4]) | 534 arguments = self.BuildProduction('Arguments', p, 2, p[3]) |
510 p[0] = self.BuildNamed('Operation', p, 2, ListFromConcat(p[1], arguments)) | 535 p[0] = self.BuildNamed('Operation', p, 1, arguments) |
511 | 536 |
512 # [40] | 537 # [55] |
513 def p_OptionalIdentifier(self, p): | 538 def p_OptionalIdentifier(self, p): |
514 """OptionalIdentifier : identifier | 539 """OptionalIdentifier : identifier |
515 |""" | 540 |""" |
516 if len(p) > 1: | 541 if len(p) > 1: |
517 p[0] = p[1] | 542 p[0] = p[1] |
518 else: | 543 else: |
519 p[0] = '_unnamed_' | 544 p[0] = '_unnamed_' |
520 | 545 |
521 # [41] | 546 # [56] |
522 def p_ArgumentList(self, p): | 547 def p_ArgumentList(self, p): |
523 """ArgumentList : Argument Arguments | 548 """ArgumentList : Argument Arguments |
524 |""" | 549 |""" |
525 if len(p) > 1: | 550 if len(p) > 1: |
526 p[0] = ListFromConcat(p[1], p[2]) | 551 p[0] = ListFromConcat(p[1], p[2]) |
527 | 552 |
528 # [41.1] ArgumentList error recovery | 553 # [56.1] ArgumentList error recovery |
529 def p_ArgumentListError(self, p): | 554 def p_ArgumentListError(self, p): |
530 """ArgumentList : error """ | 555 """ArgumentList : error """ |
531 p[0] = self.BuildError(p, 'ArgumentList') | 556 p[0] = self.BuildError(p, 'ArgumentList') |
532 | 557 |
533 # [42] | 558 # [57] |
534 def p_Arguments(self, p): | 559 def p_Arguments(self, p): |
535 """Arguments : ',' Argument Arguments | 560 """Arguments : ',' Argument Arguments |
536 |""" | 561 |""" |
537 if len(p) > 1: | 562 if len(p) > 1: |
538 p[0] = ListFromConcat(p[2], p[3]) | 563 p[0] = ListFromConcat(p[2], p[3]) |
539 | 564 |
540 # [43] | 565 # [58] |
541 def p_Argument(self, p): | 566 def p_Argument(self, p): |
542 """Argument : ExtendedAttributeList OptionalOrRequiredArgument""" | 567 """Argument : ExtendedAttributeList OptionalOrRequiredArgument""" |
543 p[2].AddChildren(p[1]) | 568 p[2].AddChildren(p[1]) |
544 p[0] = p[2] | 569 p[0] = p[2] |
545 | 570 |
546 | 571 # [59] |
547 # [44] | |
548 def p_OptionalOrRequiredArgument(self, p): | 572 def p_OptionalOrRequiredArgument(self, p): |
549 """OptionalOrRequiredArgument : OPTIONAL Type ArgumentName Default | 573 """OptionalOrRequiredArgument : OPTIONAL Type ArgumentName Default |
550 | Type Ellipsis ArgumentName""" | 574 | Type Ellipsis ArgumentName""" |
551 if len(p) > 4: | 575 if len(p) > 4: |
552 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[2], p[4])) | 576 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[2], p[4])) |
553 arg.AddChildren(self.BuildTrue('OPTIONAL')) | 577 arg.AddChildren(self.BuildTrue('OPTIONAL')) |
554 else: | 578 else: |
555 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[1], p[2])) | 579 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[1], p[2])) |
556 p[0] = arg | 580 p[0] = arg |
557 | 581 |
558 # [45] | 582 # [60] |
559 def p_ArgumentName(self, p): | 583 def p_ArgumentName(self, p): |
560 """ArgumentName : ArgumentNameKeyword | 584 """ArgumentName : ArgumentNameKeyword |
561 | identifier""" | 585 | identifier""" |
562 p[0] = p[1] | 586 p[0] = p[1] |
563 | 587 |
564 # [46] | 588 # [61] |
565 def p_Ellipsis(self, p): | 589 def p_Ellipsis(self, p): |
566 """Ellipsis : ELLIPSIS | 590 """Ellipsis : ELLIPSIS |
567 |""" | 591 |""" |
568 if len(p) > 1: | 592 if len(p) > 1: |
569 p[0] = self.BuildNamed('Argument', p, 1) | 593 p[0] = self.BuildNamed('Argument', p, 1) |
570 p[0].AddChildren(self.BuildTrue('ELLIPSIS')) | 594 p[0].AddChildren(self.BuildTrue('ELLIPSIS')) |
571 | 595 |
572 # [47] | 596 # [62] |
573 def p_ExceptionMember(self, p): | 597 def p_ExceptionMember(self, p): |
574 """ExceptionMember : Const | 598 """ExceptionMember : Const |
575 | ExceptionField""" | 599 | ExceptionField""" |
576 p[0] = p[1] | 600 p[0] = p[1] |
577 | 601 |
578 # [48] | 602 # [63] |
579 def p_ExceptionField(self, p): | 603 def p_ExceptionField(self, p): |
580 """ExceptionField : Type identifier ';'""" | 604 """ExceptionField : Type identifier ';'""" |
581 p[0] = self.BuildNamed('ExceptionField', p, 2, p[1]) | 605 p[0] = self.BuildNamed('ExceptionField', p, 2, p[1]) |
582 | 606 |
583 # [48.1] Error recovery for ExceptionMembers | 607 # [63.1] Error recovery for ExceptionMembers |
584 def p_ExceptionFieldError(self, p): | 608 def p_ExceptionFieldError(self, p): |
585 """ExceptionField : error""" | 609 """ExceptionField : error""" |
586 p[0] = self.BuildError(p, 'ExceptionField') | 610 p[0] = self.BuildError(p, 'ExceptionField') |
587 | 611 |
588 # [49] No comment version for mid statement attributes. | 612 # [64] No comment version for mid statement attributes. |
589 def p_ExtendedAttributeListNoComments(self, p): | 613 def p_ExtendedAttributeListNoComments(self, p): |
590 """ExtendedAttributeListNoComments : '[' ExtendedAttribute ExtendedAttribute s ']' | 614 """ExtendedAttributeListNoComments : '[' ExtendedAttribute ExtendedAttribute s ']' |
591 | """ | 615 | """ |
592 if len(p) > 2: | 616 if len(p) > 2: |
593 items = ListFromConcat(p[2], p[3]) | 617 items = ListFromConcat(p[2], p[3]) |
594 p[0] = self.BuildProduction('ExtAttributes', p, 1, items) | 618 p[0] = self.BuildProduction('ExtAttributes', p, 1, items) |
595 | 619 |
596 # [49.1] Add optional comment field for start of statements. | 620 # [64.1] Add optional comment field for start of statements. |
597 def p_ExtendedAttributeList(self, p): | 621 def p_ExtendedAttributeList(self, p): |
598 """ExtendedAttributeList : Comments '[' ExtendedAttribute ExtendedAttributes ']' | 622 """ExtendedAttributeList : Comments '[' ExtendedAttribute ExtendedAttributes ']' |
599 | Comments """ | 623 | Comments """ |
600 if len(p) > 2: | 624 if len(p) > 2: |
601 items = ListFromConcat(p[3], p[4]) | 625 items = ListFromConcat(p[3], p[4]) |
602 attribs = self.BuildProduction('ExtAttributes', p, 2, items) | 626 attribs = self.BuildProduction('ExtAttributes', p, 2, items) |
603 p[0] = ListFromConcat(p[1], attribs) | 627 p[0] = ListFromConcat(p[1], attribs) |
604 else: | 628 else: |
605 p[0] = p[1] | 629 p[0] = p[1] |
606 | 630 |
607 # [50] | 631 # [65] |
608 def p_ExtendedAttributes(self, p): | 632 def p_ExtendedAttributes(self, p): |
609 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes | 633 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes |
610 |""" | 634 |""" |
611 if len(p) > 1: | 635 if len(p) > 1: |
612 p[0] = ListFromConcat(p[2], p[3]) | 636 p[0] = ListFromConcat(p[2], p[3]) |
613 | 637 |
614 # We only support: | 638 # We only support: |
615 # [ identifier ] | 639 # [ identifier ] |
616 # [ identifier = identifier ] | 640 # [ identifier = identifier ] |
617 # [ identifier ( ArgumentList )] | 641 # [ identifier ( ArgumentList )] |
618 # [ identifier = identifier ( ArgumentList )] | 642 # [ identifier = identifier ( ArgumentList )] |
619 # [51] map directly to 74-77 | 643 # [66] map directly to [91-93, 95] |
620 # [52-54, 56] are unsupported | 644 # [67-69, 71] are unsupported |
621 def p_ExtendedAttribute(self, p): | 645 def p_ExtendedAttribute(self, p): |
622 """ExtendedAttribute : ExtendedAttributeNoArgs | 646 """ExtendedAttribute : ExtendedAttributeNoArgs |
623 | ExtendedAttributeArgList | 647 | ExtendedAttributeArgList |
624 | ExtendedAttributeIdent | 648 | ExtendedAttributeIdent |
625 | ExtendedAttributeNamedArgList""" | 649 | ExtendedAttributeNamedArgList""" |
626 p[0] = p[1] | 650 p[0] = p[1] |
627 | 651 |
628 # [55] | 652 # [70] |
629 def p_ArgumentNameKeyword(self, p): | 653 def p_ArgumentNameKeyword(self, p): |
630 """ArgumentNameKeyword : ATTRIBUTE | 654 """ArgumentNameKeyword : ATTRIBUTE |
631 | CALLBACK | 655 | CALLBACK |
632 | CONST | 656 | CONST |
633 | CREATOR | 657 | CREATOR |
634 | DELETER | 658 | DELETER |
635 | DICTIONARY | 659 | DICTIONARY |
636 | ENUM | 660 | ENUM |
637 | EXCEPTION | 661 | EXCEPTION |
638 | GETTER | 662 | GETTER |
639 | IMPLEMENTS | 663 | IMPLEMENTS |
640 | INHERIT | 664 | INHERIT |
641 | LEGACYCALLER | 665 | LEGACYCALLER |
642 | PARTIAL | 666 | PARTIAL |
667 | SERIALIZER | |
643 | SETTER | 668 | SETTER |
644 | STATIC | 669 | STATIC |
645 | STRINGIFIER | 670 | STRINGIFIER |
646 | TYPEDEF | 671 | TYPEDEF |
647 | UNRESTRICTED""" | 672 | UNRESTRICTED""" |
648 p[0] = p[1] | 673 p[0] = p[1] |
649 | 674 |
650 # [57] | 675 # [72] |
651 def p_Type(self, p): | 676 def p_Type(self, p): |
652 """Type : SingleType | 677 """Type : SingleType |
653 | UnionType TypeSuffix""" | 678 | UnionType TypeSuffix""" |
654 if len(p) == 2: | 679 if len(p) == 2: |
655 p[0] = self.BuildProduction('Type', p, 1, p[1]) | 680 p[0] = self.BuildProduction('Type', p, 1, p[1]) |
656 else: | 681 else: |
657 p[0] = self.BuildProduction('Type', p, 1, ListFromConcat(p[1], p[2])) | 682 p[0] = self.BuildProduction('Type', p, 1, ListFromConcat(p[1], p[2])) |
658 | 683 |
659 # [58] | 684 # [73] |
660 def p_SingleType(self, p): | 685 def p_SingleType(self, p): |
661 """SingleType : NonAnyType | 686 """SingleType : NonAnyType |
662 | ANY TypeSuffixStartingWithArray""" | 687 | ANY TypeSuffixStartingWithArray""" |
663 if len(p) == 2: | 688 if len(p) == 2: |
664 p[0] = p[1] | 689 p[0] = p[1] |
665 else: | 690 else: |
666 p[0] = ListFromConcat(self.BuildProduction('Any', p, 1), p[2]) | 691 p[0] = ListFromConcat(self.BuildProduction('Any', p, 1), p[2]) |
667 | 692 |
668 # [59] | 693 # [74] |
669 def p_UnionType(self, p): | 694 def p_UnionType(self, p): |
670 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ')'"" " | 695 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ')'"" " |
671 | 696 |
672 # [60] | 697 # [75] |
673 def p_UnionMemberType(self, p): | 698 def p_UnionMemberType(self, p): |
674 """UnionMemberType : NonAnyType | 699 """UnionMemberType : NonAnyType |
675 | UnionType TypeSuffix | 700 | UnionType TypeSuffix |
676 | ANY '[' ']' TypeSuffix""" | 701 | ANY '[' ']' TypeSuffix""" |
677 # [61] | 702 # [76] |
678 def p_UnionMemberTypes(self, p): | 703 def p_UnionMemberTypes(self, p): |
679 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes | 704 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes |
680 |""" | 705 |""" |
681 | 706 |
682 # [62] Moved DATE, DOMSTRING, OBJECT to PrimitiveType | 707 # [77] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType |
683 def p_NonAnyType(self, p): | 708 def p_NonAnyType(self, p): |
684 """NonAnyType : PrimitiveType TypeSuffix | 709 """NonAnyType : PrimitiveType TypeSuffix |
685 | identifier TypeSuffix | 710 | identifier TypeSuffix |
686 | SEQUENCE '<' Type '>' Null""" | 711 | SEQUENCE '<' Type '>' Null""" |
687 if len(p) == 3: | 712 if len(p) == 3: |
688 if type(p[1]) == str: | 713 if type(p[1]) == str: |
689 typeref = self.BuildNamed('Typeref', p, 1) | 714 typeref = self.BuildNamed('Typeref', p, 1) |
690 else: | 715 else: |
691 typeref = p[1] | 716 typeref = p[1] |
692 p[0] = ListFromConcat(typeref, p[2]) | 717 p[0] = ListFromConcat(typeref, p[2]) |
693 | 718 |
694 if len(p) == 6: | 719 if len(p) == 6: |
695 p[0] = self.BuildProduction('Sequence', p, 1, ListFromConcat(p[3], p[5])) | 720 p[0] = self.BuildProduction('Sequence', p, 1, ListFromConcat(p[3], p[5])) |
696 | 721 |
697 | 722 |
698 # [63] | 723 # [78] |
699 def p_ConstType(self, p): | 724 def p_ConstType(self, p): |
700 """ConstType : PrimitiveType Null | 725 """ConstType : PrimitiveType Null |
701 | identifier Null""" | 726 | identifier Null""" |
702 if type(p[1]) == str: | 727 if type(p[1]) == str: |
703 p[0] = self.BuildNamed('Typeref', p, 1, p[2]) | 728 p[0] = self.BuildNamed('Typeref', p, 1, p[2]) |
704 else: | 729 else: |
705 p[1].AddChildren(p[2]) | 730 p[1].AddChildren(p[2]) |
706 p[0] = p[1] | 731 p[0] = p[1] |
707 | 732 |
708 | 733 |
709 # [64] | 734 # [79] |
Nils Barth (inactive)
2014/06/16 06:50:47
Could you note that we've added BYTESTRING etc.?
| |
710 def p_PrimitiveType(self, p): | 735 def p_PrimitiveType(self, p): |
711 """PrimitiveType : UnsignedIntegerType | 736 """PrimitiveType : UnsignedIntegerType |
712 | UnrestrictedFloatType | 737 | UnrestrictedFloatType |
713 | BOOLEAN | 738 | BOOLEAN |
714 | BYTE | 739 | BYTE |
715 | OCTET | 740 | OCTET |
741 | BYTESTRING | |
716 | DOMSTRING | 742 | DOMSTRING |
743 | OBJECT | |
717 | DATE | 744 | DATE |
718 | OBJECT""" | 745 | REGEXP""" |
719 if type(p[1]) == str: | 746 if type(p[1]) == str: |
720 p[0] = self.BuildNamed('PrimitiveType', p, 1) | 747 p[0] = self.BuildNamed('PrimitiveType', p, 1) |
721 else: | 748 else: |
722 p[0] = p[1] | 749 p[0] = p[1] |
723 | 750 |
724 | 751 |
725 # [65] | 752 # [80] |
726 def p_UnrestrictedFloatType(self, p): | 753 def p_UnrestrictedFloatType(self, p): |
727 """UnrestrictedFloatType : UNRESTRICTED FloatType | 754 """UnrestrictedFloatType : UNRESTRICTED FloatType |
728 | FloatType""" | 755 | FloatType""" |
729 if len(p) == 2: | 756 if len(p) == 2: |
730 typeref = self.BuildNamed('PrimitiveType', p, 1) | 757 typeref = self.BuildNamed('PrimitiveType', p, 1) |
731 else: | 758 else: |
732 typeref = self.BuildNamed('PrimitiveType', p, 2) | 759 typeref = self.BuildNamed('PrimitiveType', p, 2) |
733 typeref.AddChildren(self.BuildTrue('UNRESTRICTED')) | 760 typeref.AddChildren(self.BuildTrue('UNRESTRICTED')) |
734 p[0] = typeref | 761 p[0] = typeref |
735 | 762 |
736 | 763 |
737 # [66] | 764 # [81] |
738 def p_FloatType(self, p): | 765 def p_FloatType(self, p): |
739 """FloatType : FLOAT | 766 """FloatType : FLOAT |
740 | DOUBLE""" | 767 | DOUBLE""" |
741 p[0] = p[1] | 768 p[0] = p[1] |
742 | 769 |
743 # [67] | 770 # [82] |
744 def p_UnsignedIntegerType(self, p): | 771 def p_UnsignedIntegerType(self, p): |
745 """UnsignedIntegerType : UNSIGNED IntegerType | 772 """UnsignedIntegerType : UNSIGNED IntegerType |
746 | IntegerType""" | 773 | IntegerType""" |
747 if len(p) == 2: | 774 if len(p) == 2: |
748 p[0] = p[1] | 775 p[0] = p[1] |
749 else: | 776 else: |
750 p[0] = 'unsigned ' + p[2] | 777 p[0] = 'unsigned ' + p[2] |
751 | 778 |
752 # [68] | 779 # [83] |
753 def p_IntegerType(self, p): | 780 def p_IntegerType(self, p): |
754 """IntegerType : SHORT | 781 """IntegerType : SHORT |
755 | LONG OptionalLong""" | 782 | LONG OptionalLong""" |
756 if len(p) == 2: | 783 if len(p) == 2: |
757 p[0] = p[1] | 784 p[0] = p[1] |
758 else: | 785 else: |
759 p[0] = p[1] + p[2] | 786 p[0] = p[1] + p[2] |
760 | 787 |
761 # [69] | 788 # [84] |
762 def p_OptionalLong(self, p): | 789 def p_OptionalLong(self, p): |
763 """OptionalLong : LONG | 790 """OptionalLong : LONG |
764 | """ | 791 | """ |
765 if len(p) > 1: | 792 if len(p) > 1: |
766 p[0] = ' ' + p[1] | 793 p[0] = ' ' + p[1] |
767 else: | 794 else: |
768 p[0] = '' | 795 p[0] = '' |
769 | 796 |
770 | 797 |
771 # [70] Add support for sized array | 798 # [85] Add support for sized array |
772 def p_TypeSuffix(self, p): | 799 def p_TypeSuffix(self, p): |
773 """TypeSuffix : '[' integer ']' TypeSuffix | 800 """TypeSuffix : '[' integer ']' TypeSuffix |
774 | '[' ']' TypeSuffix | 801 | '[' ']' TypeSuffix |
775 | '?' TypeSuffixStartingWithArray | 802 | '?' TypeSuffixStartingWithArray |
776 | """ | 803 | """ |
777 if len(p) == 5: | 804 if len(p) == 5: |
778 p[0] = self.BuildNamed('Array', p, 2, p[4]) | 805 p[0] = self.BuildNamed('Array', p, 2, p[4]) |
779 | 806 |
780 if len(p) == 4: | 807 if len(p) == 4: |
781 p[0] = self.BuildProduction('Array', p, 1, p[3]) | 808 p[0] = self.BuildProduction('Array', p, 1, p[3]) |
782 | 809 |
783 if len(p) == 3: | 810 if len(p) == 3: |
784 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) | 811 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) |
785 | 812 |
786 | 813 |
787 # [71] | 814 # [86] |
788 def p_TypeSuffixStartingWithArray(self, p): | 815 def p_TypeSuffixStartingWithArray(self, p): |
789 """TypeSuffixStartingWithArray : '[' ']' TypeSuffix | 816 """TypeSuffixStartingWithArray : '[' ']' TypeSuffix |
790 | """ | 817 | """ |
791 if len(p) > 1: | 818 if len(p) > 1: |
792 p[0] = self.BuildProduction('Array', p, 0, p[3]) | 819 p[0] = self.BuildProduction('Array', p, 0, p[3]) |
793 | 820 |
794 # [72] | 821 # [87] |
795 def p_Null(self, p): | 822 def p_Null(self, p): |
796 """Null : '?' | 823 """Null : '?' |
797 |""" | 824 |""" |
798 if len(p) > 1: | 825 if len(p) > 1: |
799 p[0] = self.BuildTrue('NULLABLE') | 826 p[0] = self.BuildTrue('NULLABLE') |
800 | 827 |
801 # [73] | 828 # [88] |
802 def p_ReturnType(self, p): | 829 def p_ReturnType(self, p): |
803 """ReturnType : Type | 830 """ReturnType : Type |
804 | VOID""" | 831 | VOID""" |
805 if p[1] == 'void': | 832 if p[1] == 'void': |
806 p[0] = self.BuildProduction('Type', p, 1) | 833 p[0] = self.BuildProduction('Type', p, 1) |
807 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1)) | 834 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1)) |
808 else: | 835 else: |
809 p[0] = p[1] | 836 p[0] = p[1] |
810 | 837 |
811 # [74] | 838 # [89-90] NOT IMPLEMENTED |
Nils Barth (inactive)
2014/06/16 06:50:48
Gloss: (IdentifierList)
| |
839 | |
840 # [91] | |
812 def p_ExtendedAttributeNoArgs(self, p): | 841 def p_ExtendedAttributeNoArgs(self, p): |
813 """ExtendedAttributeNoArgs : identifier""" | 842 """ExtendedAttributeNoArgs : identifier""" |
814 p[0] = self.BuildNamed('ExtAttribute', p, 1) | 843 p[0] = self.BuildNamed('ExtAttribute', p, 1) |
815 | 844 |
816 # [75] | 845 # [92] |
817 def p_ExtendedAttributeArgList(self, p): | 846 def p_ExtendedAttributeArgList(self, p): |
818 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'""" | 847 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'""" |
819 arguments = self.BuildProduction('Arguments', p, 2, p[3]) | 848 arguments = self.BuildProduction('Arguments', p, 2, p[3]) |
820 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments) | 849 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments) |
821 | 850 |
822 # [76] | 851 # [93] |
823 def p_ExtendedAttributeIdent(self, p): | 852 def p_ExtendedAttributeIdent(self, p): |
824 """ExtendedAttributeIdent : identifier '=' identifier""" | 853 """ExtendedAttributeIdent : identifier '=' identifier""" |
825 value = self.BuildAttribute('VALUE', p[3]) | 854 value = self.BuildAttribute('VALUE', p[3]) |
826 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 855 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
827 | 856 |
828 # [77] | 857 # [95] |
Nils Barth (inactive)
2014/06/16 06:50:48
# [94] NOT IMPLEMENTED (ExtendedAttributeIdentList
| |
829 def p_ExtendedAttributeNamedArgList(self, p): | 858 def p_ExtendedAttributeNamedArgList(self, p): |
830 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'""" | 859 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'""" |
831 args = self.BuildProduction('Arguments', p, 4, p[5]) | 860 args = self.BuildProduction('Arguments', p, 4, p[5]) |
832 value = self.BuildNamed('Call', p, 3, args) | 861 value = self.BuildNamed('Call', p, 3, args) |
833 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 862 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
834 | 863 |
835 # | 864 # |
836 # Parser Errors | 865 # Parser Errors |
837 # | 866 # |
838 # p_error is called whenever the parser can not find a pattern match for | 867 # p_error is called whenever the parser can not find a pattern match for |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1044 | 1073 |
1045 print '\n'.join(ast.Tree(accept_props=['PROD'])) | 1074 print '\n'.join(ast.Tree(accept_props=['PROD'])) |
1046 if errors: | 1075 if errors: |
1047 print '\nFound %d errors.\n' % errors | 1076 print '\nFound %d errors.\n' % errors |
1048 | 1077 |
1049 return errors | 1078 return errors |
1050 | 1079 |
1051 | 1080 |
1052 if __name__ == '__main__': | 1081 if __name__ == '__main__': |
1053 sys.exit(main(sys.argv[1:])) | 1082 sys.exit(main(sys.argv[1:])) |
OLD | NEW |