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 # |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 # http://www.w3.org/TR/WebIDL/#idl-grammar | 186 # http://www.w3.org/TR/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] Add INLINE definition |
Jens Widell
2014/06/12 13:34:36
I don't know what this comment is about. :-) There
noelallen1
2014/06/12 19:33:37
This really should just be:
# [2]
To signify it'
| |
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] | |
noelallen1
2014/06/12 19:33:37
This does not match:
http://www.w3.org/TR/WebID
| |
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] |
440 p[0] = p[2] | |
441 else: | |
442 p[0] = p[1] | |
443 | |
444 # [31] | |
445 def p_StringifierAttributeOrOperation(self, p): | |
446 """StringifierAttributeOrOperation : Attribute | |
447 | OperationRest | |
448 | ';'""" | |
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 | 447 |
454 # [32] | 448 # [32] |
455 def p_Attribute(self, p): | 449 # def p_Serializer(self, p): |
noelallen1
2014/06/12 19:33:36
I have mixed feeling about these place holders. I
| |
456 """Attribute : Inherit ReadOnly ATTRIBUTE Type identifier ';'""" | 450 # """Serializer : SERIALIZER SerializerRest""" |
457 p[0] = self.BuildNamed('Attribute', p, 5, | 451 # NOT_IMPLEMENTED |
458 ListFromConcat(p[1], p[2], p[4])) | |
459 | 452 |
460 # [33] | 453 # [33] |
454 # def p_SerializerRest(self, p): | |
455 # """SerializerRest : OperationRest | |
456 # | '=' SerializationPattern | |
457 # |""" | |
458 # NOT_IMPLEMENTED | |
459 | |
460 # [34] | |
461 # def p_SerializationPattern(self, p): | |
462 # """SerializationPattern : '{' SerializationPatternMap '}' | |
463 # | '[' SerializationPatternList ']' | |
464 # | identifier""" | |
465 # NOT_IMPLEMENTED | |
466 | |
467 # [35] | |
468 # def p_SerializationPatternMap(self, p): | |
469 # """SerializationPatternMap : GETTER | |
470 # | INHERIT Identifiers | |
471 # | identifier Identifiers | |
472 # |""" | |
473 # NOT_IMPLEMENTED | |
474 | |
475 # [36] | |
476 # def p_SerializationPatternList(self, p): | |
477 # """SerializationPatternList : GETTER | |
478 # | identifier Identifiers | |
479 # |""" | |
480 # NOT_IMPLEMENTED | |
481 | |
482 # [37] | |
483 # def p_Identifiers(self, p): | |
484 # """Identifiers : ',' identifier Identifiers | |
485 # |""" | |
486 # return ListFromConcat(p[2], p[3]) | |
487 | |
488 # [38] | |
489 # def p_Stringifier(self, p): | |
490 # """Stringifier : STRINGIFIER StringifierRest""" | |
491 # NOT_IMPLEMENTED | |
492 | |
493 # [39] | |
494 # def p_StringifierRest(self, p): | |
495 # """StringifierRest : AttributeRest | |
496 # | ReturnType OperationRest | |
497 # | ';'""" | |
498 # NOT_IMPLEMENTED | |
499 | |
500 # [40] | |
501 def p_StaticMember(self, p): | |
502 """StaticMember : STATIC StaticMemberRest""" | |
503 p[2].AddChildren(self.BuildTrue('STATIC')) | |
504 p[0] = p[2] | |
505 | |
506 # [41] | |
507 def p_StaticMemberRest(self, p): | |
508 """StaticMemberRest : AttributeRest | |
509 | ReturnType OperationRest""" | |
510 if len(p) == 2: | |
511 p[0] = p[1] | |
512 else: | |
513 p[2].AddChildren(p[1]) | |
514 p[0] = p[2] | |
515 | |
516 # [42] | |
517 def p_Attribute(self, p): | |
518 """Attribute : Inherit AttributeRest""" | |
519 p[2].AddChildren(ListFromConcat(p[1])) | |
520 p[0] = p[2] | |
521 | |
522 # [43] | |
523 def p_AttributeRest(self, p): | |
524 """AttributeRest : ReadOnly ATTRIBUTE Type identifier ';'""" | |
525 p[0] = self.BuildNamed('Attribute', p, 4, | |
526 ListFromConcat(p[1], p[3])) | |
527 | |
528 # [44] | |
461 def p_Inherit(self, p): | 529 def p_Inherit(self, p): |
462 """Inherit : INHERIT | 530 """Inherit : INHERIT |
463 |""" | 531 |""" |
464 if len(p) > 1: | 532 if len(p) > 1: |
465 p[0] = self.BuildTrue('INHERIT') | 533 p[0] = self.BuildTrue('INHERIT') |
466 | 534 |
467 # [34] | 535 # [45] |
468 def p_ReadOnly(self, p): | 536 def p_ReadOnly(self, p): |
469 """ReadOnly : READONLY | 537 """ReadOnly : READONLY |
470 |""" | 538 |""" |
471 if len(p) > 1: | 539 if len(p) > 1: |
472 p[0] = self.BuildTrue('READONLY') | 540 p[0] = self.BuildTrue('READONLY') |
473 | 541 |
474 # [35] | 542 # [46] |
475 def p_Operation(self, p): | 543 def p_OperationOrIterator(self, p): |
476 """Operation : Qualifiers OperationRest""" | 544 """OperationOrIterator : ReturnType OperationOrIteratorRest |
477 p[2].AddChildren(p[1]) | 545 | SpecialOperation""" |
478 p[0] = p[2] | 546 if len(p) == 3: |
479 | 547 p[2].AddChildren(p[1]) |
480 # [36] | 548 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: | 549 else: |
487 p[0] = p[1] | 550 p[0] = p[1] |
488 | 551 |
489 # [37] | 552 # [47] |
553 def p_SpecialOperation(self, p): | |
554 """SpecialOperation : Special Specials ReturnType OperationRest""" | |
555 p[4].AddChildren(ListFromConcat(p[1], p[2], p[3])) | |
556 p[0] = p[4] | |
557 | |
558 # [48] | |
490 def p_Specials(self, p): | 559 def p_Specials(self, p): |
491 """Specials : Special Specials | 560 """Specials : Special Specials |
492 | """ | 561 | """ |
493 if len(p) > 1: | 562 if len(p) > 1: |
494 p[0] = ListFromConcat(p[1], p[2]) | 563 p[0] = ListFromConcat(p[1], p[2]) |
495 | 564 |
496 # [38] | 565 # [49] |
497 def p_Special(self, p): | 566 def p_Special(self, p): |
498 """Special : GETTER | 567 """Special : GETTER |
499 | SETTER | 568 | SETTER |
500 | CREATOR | 569 | CREATOR |
501 | DELETER | 570 | DELETER |
502 | LEGACYCALLER""" | 571 | LEGACYCALLER""" |
503 p[0] = self.BuildTrue(p[1].upper()) | 572 p[0] = self.BuildTrue(p[1].upper()) |
504 | 573 |
574 # [50] Removed unsupported: IteratorRest | |
575 def p_OperationOrIteratorRest(self, p): | |
576 """OperationOrIteratorRest : OperationRest""" | |
577 p[0] = p[1] | |
505 | 578 |
506 # [39] | 579 # [51] |
580 # def p_IteratorRest(self, p): | |
581 # """IteratorRest : ITERATOR OptionalIteratorInterfaceOrObject ';'""" | |
582 # NOT_IMPLEMENTED | |
583 | |
584 # [52] | |
585 # def p_OptionalIteratorInterfaceOrObject(self, p): | |
586 # """OptionalIteratorInterfaceOrObject : OptionalIteratorInterface | |
587 # | OBJECT""" | |
588 # NOT_IMPLEMENTED | |
589 | |
590 # [53] | |
591 # def p_OptionalIteratorInterface(self, p): | |
592 # """OptionalIteratorInterface : '=' identifier | |
593 # |""" | |
594 # NOT_IMPLEMENTED | |
595 | |
596 # [54] | |
507 def p_OperationRest(self, p): | 597 def p_OperationRest(self, p): |
508 """OperationRest : ReturnType OptionalIdentifier '(' ArgumentList ')' ';'""" | 598 """OperationRest : OptionalIdentifier '(' ArgumentList ')' ';'""" |
509 arguments = self.BuildProduction('Arguments', p, 3, p[4]) | 599 arguments = self.BuildProduction('Arguments', p, 2, p[3]) |
510 p[0] = self.BuildNamed('Operation', p, 2, ListFromConcat(p[1], arguments)) | 600 p[0] = self.BuildNamed('Operation', p, 1, arguments) |
511 | 601 |
512 # [40] | 602 # [55] |
513 def p_OptionalIdentifier(self, p): | 603 def p_OptionalIdentifier(self, p): |
514 """OptionalIdentifier : identifier | 604 """OptionalIdentifier : identifier |
515 |""" | 605 |""" |
516 if len(p) > 1: | 606 if len(p) > 1: |
517 p[0] = p[1] | 607 p[0] = p[1] |
518 else: | 608 else: |
519 p[0] = '_unnamed_' | 609 p[0] = '_unnamed_' |
520 | 610 |
521 # [41] | 611 # [56] |
522 def p_ArgumentList(self, p): | 612 def p_ArgumentList(self, p): |
523 """ArgumentList : Argument Arguments | 613 """ArgumentList : Argument Arguments |
524 |""" | 614 |""" |
525 if len(p) > 1: | 615 if len(p) > 1: |
526 p[0] = ListFromConcat(p[1], p[2]) | 616 p[0] = ListFromConcat(p[1], p[2]) |
527 | 617 |
528 # [41.1] ArgumentList error recovery | 618 # [56.1] ArgumentList error recovery |
529 def p_ArgumentListError(self, p): | 619 def p_ArgumentListError(self, p): |
530 """ArgumentList : error """ | 620 """ArgumentList : error """ |
531 p[0] = self.BuildError(p, 'ArgumentList') | 621 p[0] = self.BuildError(p, 'ArgumentList') |
532 | 622 |
533 # [42] | 623 # [57] |
534 def p_Arguments(self, p): | 624 def p_Arguments(self, p): |
535 """Arguments : ',' Argument Arguments | 625 """Arguments : ',' Argument Arguments |
536 |""" | 626 |""" |
537 if len(p) > 1: | 627 if len(p) > 1: |
538 p[0] = ListFromConcat(p[2], p[3]) | 628 p[0] = ListFromConcat(p[2], p[3]) |
539 | 629 |
540 # [43] | 630 # [58] |
541 def p_Argument(self, p): | 631 def p_Argument(self, p): |
542 """Argument : ExtendedAttributeList OptionalOrRequiredArgument""" | 632 """Argument : ExtendedAttributeList OptionalOrRequiredArgument""" |
543 p[2].AddChildren(p[1]) | 633 p[2].AddChildren(p[1]) |
544 p[0] = p[2] | 634 p[0] = p[2] |
545 | 635 |
546 | 636 # [59] |
547 # [44] | |
548 def p_OptionalOrRequiredArgument(self, p): | 637 def p_OptionalOrRequiredArgument(self, p): |
549 """OptionalOrRequiredArgument : OPTIONAL Type ArgumentName Default | 638 """OptionalOrRequiredArgument : OPTIONAL Type ArgumentName Default |
550 | Type Ellipsis ArgumentName""" | 639 | Type Ellipsis ArgumentName""" |
551 if len(p) > 4: | 640 if len(p) > 4: |
552 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[2], p[4])) | 641 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[2], p[4])) |
553 arg.AddChildren(self.BuildTrue('OPTIONAL')) | 642 arg.AddChildren(self.BuildTrue('OPTIONAL')) |
554 else: | 643 else: |
555 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[1], p[2])) | 644 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[1], p[2])) |
556 p[0] = arg | 645 p[0] = arg |
557 | 646 |
558 # [45] | 647 # [60] |
559 def p_ArgumentName(self, p): | 648 def p_ArgumentName(self, p): |
560 """ArgumentName : ArgumentNameKeyword | 649 """ArgumentName : ArgumentNameKeyword |
561 | identifier""" | 650 | identifier""" |
562 p[0] = p[1] | 651 p[0] = p[1] |
563 | 652 |
564 # [46] | 653 # [61] |
565 def p_Ellipsis(self, p): | 654 def p_Ellipsis(self, p): |
566 """Ellipsis : ELLIPSIS | 655 """Ellipsis : ELLIPSIS |
567 |""" | 656 |""" |
568 if len(p) > 1: | 657 if len(p) > 1: |
569 p[0] = self.BuildNamed('Argument', p, 1) | 658 p[0] = self.BuildNamed('Argument', p, 1) |
570 p[0].AddChildren(self.BuildTrue('ELLIPSIS')) | 659 p[0].AddChildren(self.BuildTrue('ELLIPSIS')) |
571 | 660 |
572 # [47] | 661 # [62] |
573 def p_ExceptionMember(self, p): | 662 def p_ExceptionMember(self, p): |
574 """ExceptionMember : Const | 663 """ExceptionMember : Const |
575 | ExceptionField""" | 664 | ExceptionField""" |
576 p[0] = p[1] | 665 p[0] = p[1] |
577 | 666 |
578 # [48] | 667 # [63] |
579 def p_ExceptionField(self, p): | 668 def p_ExceptionField(self, p): |
580 """ExceptionField : Type identifier ';'""" | 669 """ExceptionField : Type identifier ';'""" |
581 p[0] = self.BuildNamed('ExceptionField', p, 2, p[1]) | 670 p[0] = self.BuildNamed('ExceptionField', p, 2, p[1]) |
582 | 671 |
583 # [48.1] Error recovery for ExceptionMembers | 672 # [63.1] Error recovery for ExceptionMembers |
584 def p_ExceptionFieldError(self, p): | 673 def p_ExceptionFieldError(self, p): |
585 """ExceptionField : error""" | 674 """ExceptionField : error""" |
586 p[0] = self.BuildError(p, 'ExceptionField') | 675 p[0] = self.BuildError(p, 'ExceptionField') |
587 | 676 |
588 # [49] No comment version for mid statement attributes. | 677 # [64] No comment version for mid statement attributes. |
589 def p_ExtendedAttributeListNoComments(self, p): | 678 def p_ExtendedAttributeListNoComments(self, p): |
590 """ExtendedAttributeListNoComments : '[' ExtendedAttribute ExtendedAttribute s ']' | 679 """ExtendedAttributeListNoComments : '[' ExtendedAttribute ExtendedAttribute s ']' |
591 | """ | 680 | """ |
592 if len(p) > 2: | 681 if len(p) > 2: |
593 items = ListFromConcat(p[2], p[3]) | 682 items = ListFromConcat(p[2], p[3]) |
594 p[0] = self.BuildProduction('ExtAttributes', p, 1, items) | 683 p[0] = self.BuildProduction('ExtAttributes', p, 1, items) |
595 | 684 |
596 # [49.1] Add optional comment field for start of statements. | 685 # [64.1] Add optional comment field for start of statements. |
597 def p_ExtendedAttributeList(self, p): | 686 def p_ExtendedAttributeList(self, p): |
598 """ExtendedAttributeList : Comments '[' ExtendedAttribute ExtendedAttributes ']' | 687 """ExtendedAttributeList : Comments '[' ExtendedAttribute ExtendedAttributes ']' |
599 | Comments """ | 688 | Comments """ |
600 if len(p) > 2: | 689 if len(p) > 2: |
601 items = ListFromConcat(p[3], p[4]) | 690 items = ListFromConcat(p[3], p[4]) |
602 attribs = self.BuildProduction('ExtAttributes', p, 2, items) | 691 attribs = self.BuildProduction('ExtAttributes', p, 2, items) |
603 p[0] = ListFromConcat(p[1], attribs) | 692 p[0] = ListFromConcat(p[1], attribs) |
604 else: | 693 else: |
605 p[0] = p[1] | 694 p[0] = p[1] |
606 | 695 |
607 # [50] | 696 # [65] |
608 def p_ExtendedAttributes(self, p): | 697 def p_ExtendedAttributes(self, p): |
609 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes | 698 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes |
610 |""" | 699 |""" |
611 if len(p) > 1: | 700 if len(p) > 1: |
612 p[0] = ListFromConcat(p[2], p[3]) | 701 p[0] = ListFromConcat(p[2], p[3]) |
613 | 702 |
614 # We only support: | 703 # We only support: |
615 # [ identifier ] | 704 # [ identifier ] |
616 # [ identifier = identifier ] | 705 # [ identifier = identifier ] |
617 # [ identifier ( ArgumentList )] | 706 # [ identifier ( ArgumentList )] |
618 # [ identifier = identifier ( ArgumentList )] | 707 # [ identifier = identifier ( ArgumentList )] |
619 # [51] map directly to 74-77 | 708 # [66] map directly to [91-93, 95] |
620 # [52-54, 56] are unsupported | 709 # [67-69, 71] are unsupported |
621 def p_ExtendedAttribute(self, p): | 710 def p_ExtendedAttribute(self, p): |
622 """ExtendedAttribute : ExtendedAttributeNoArgs | 711 """ExtendedAttribute : ExtendedAttributeNoArgs |
623 | ExtendedAttributeArgList | 712 | ExtendedAttributeArgList |
624 | ExtendedAttributeIdent | 713 | ExtendedAttributeIdent |
625 | ExtendedAttributeNamedArgList""" | 714 | ExtendedAttributeNamedArgList""" |
626 p[0] = p[1] | 715 p[0] = p[1] |
627 | 716 |
628 # [55] | 717 # [70] |
629 def p_ArgumentNameKeyword(self, p): | 718 def p_ArgumentNameKeyword(self, p): |
630 """ArgumentNameKeyword : ATTRIBUTE | 719 """ArgumentNameKeyword : ATTRIBUTE |
631 | CALLBACK | 720 | CALLBACK |
632 | CONST | 721 | CONST |
633 | CREATOR | 722 | CREATOR |
634 | DELETER | 723 | DELETER |
635 | DICTIONARY | 724 | DICTIONARY |
636 | ENUM | 725 | ENUM |
637 | EXCEPTION | 726 | EXCEPTION |
638 | GETTER | 727 | GETTER |
639 | IMPLEMENTS | 728 | IMPLEMENTS |
640 | INHERIT | 729 | INHERIT |
641 | LEGACYCALLER | 730 | LEGACYCALLER |
642 | PARTIAL | 731 | PARTIAL |
732 | SERIALIZER | |
643 | SETTER | 733 | SETTER |
644 | STATIC | 734 | STATIC |
645 | STRINGIFIER | 735 | STRINGIFIER |
646 | TYPEDEF | 736 | TYPEDEF |
647 | UNRESTRICTED""" | 737 | UNRESTRICTED""" |
648 p[0] = p[1] | 738 p[0] = p[1] |
649 | 739 |
650 # [57] | 740 # [72] |
651 def p_Type(self, p): | 741 def p_Type(self, p): |
652 """Type : SingleType | 742 """Type : SingleType |
653 | UnionType TypeSuffix""" | 743 | UnionType TypeSuffix""" |
654 if len(p) == 2: | 744 if len(p) == 2: |
655 p[0] = self.BuildProduction('Type', p, 1, p[1]) | 745 p[0] = self.BuildProduction('Type', p, 1, p[1]) |
656 else: | 746 else: |
657 p[0] = self.BuildProduction('Type', p, 1, ListFromConcat(p[1], p[2])) | 747 p[0] = self.BuildProduction('Type', p, 1, ListFromConcat(p[1], p[2])) |
658 | 748 |
659 # [58] | 749 # [73] |
660 def p_SingleType(self, p): | 750 def p_SingleType(self, p): |
661 """SingleType : NonAnyType | 751 """SingleType : NonAnyType |
662 | ANY TypeSuffixStartingWithArray""" | 752 | ANY TypeSuffixStartingWithArray""" |
663 if len(p) == 2: | 753 if len(p) == 2: |
664 p[0] = p[1] | 754 p[0] = p[1] |
665 else: | 755 else: |
666 p[0] = ListFromConcat(self.BuildProduction('Any', p, 1), p[2]) | 756 p[0] = ListFromConcat(self.BuildProduction('Any', p, 1), p[2]) |
667 | 757 |
668 # [59] | 758 # [74] |
669 def p_UnionType(self, p): | 759 def p_UnionType(self, p): |
670 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ')'"" " | 760 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ')'"" " |
671 | 761 |
672 # [60] | 762 # [75] |
673 def p_UnionMemberType(self, p): | 763 def p_UnionMemberType(self, p): |
674 """UnionMemberType : NonAnyType | 764 """UnionMemberType : NonAnyType |
675 | UnionType TypeSuffix | 765 | UnionType TypeSuffix |
676 | ANY '[' ']' TypeSuffix""" | 766 | ANY '[' ']' TypeSuffix""" |
677 # [61] | 767 # [76] |
678 def p_UnionMemberTypes(self, p): | 768 def p_UnionMemberTypes(self, p): |
679 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes | 769 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes |
680 |""" | 770 |""" |
681 | 771 |
682 # [62] Moved DATE, DOMSTRING, OBJECT to PrimitiveType | 772 # [77] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType |
Jens Widell
2014/06/12 13:34:36
I don't know why any of these are moved, but I gue
noelallen1
2014/06/12 20:39:31
Moved just to make parsing easier. Otherwise it's
Nils Barth (inactive)
2014/06/16 06:50:47
Thanks for explaining!
Could this be aligned with
Jens Widell
2014/06/16 10:53:11
Aligning with spec would not more difficult than d
Nils Barth (inactive)
2014/06/17 05:08:18
That sounds great!
(Agreed that "primitive type" i
Jens Widell
2014/06/17 06:18:37
"Not more difficult" was apparently a bit optimist
Nils Barth (inactive)
2014/06/17 06:28:25
Got it; that's a lot of work for minor spec compli
| |
683 def p_NonAnyType(self, p): | 773 def p_NonAnyType(self, p): |
684 """NonAnyType : PrimitiveType TypeSuffix | 774 """NonAnyType : PrimitiveType TypeSuffix |
685 | identifier TypeSuffix | 775 | identifier TypeSuffix |
686 | SEQUENCE '<' Type '>' Null""" | 776 | SEQUENCE '<' Type '>' Null""" |
687 if len(p) == 3: | 777 if len(p) == 3: |
688 if type(p[1]) == str: | 778 if type(p[1]) == str: |
689 typeref = self.BuildNamed('Typeref', p, 1) | 779 typeref = self.BuildNamed('Typeref', p, 1) |
690 else: | 780 else: |
691 typeref = p[1] | 781 typeref = p[1] |
692 p[0] = ListFromConcat(typeref, p[2]) | 782 p[0] = ListFromConcat(typeref, p[2]) |
693 | 783 |
694 if len(p) == 6: | 784 if len(p) == 6: |
695 p[0] = self.BuildProduction('Sequence', p, 1, ListFromConcat(p[3], p[5])) | 785 p[0] = self.BuildProduction('Sequence', p, 1, ListFromConcat(p[3], p[5])) |
696 | 786 |
697 | 787 |
698 # [63] | 788 # [78] |
699 def p_ConstType(self, p): | 789 def p_ConstType(self, p): |
700 """ConstType : PrimitiveType Null | 790 """ConstType : PrimitiveType Null |
701 | identifier Null""" | 791 | identifier Null""" |
702 if type(p[1]) == str: | 792 if type(p[1]) == str: |
703 p[0] = self.BuildNamed('Typeref', p, 1, p[2]) | 793 p[0] = self.BuildNamed('Typeref', p, 1, p[2]) |
704 else: | 794 else: |
705 p[1].AddChildren(p[2]) | 795 p[1].AddChildren(p[2]) |
706 p[0] = p[1] | 796 p[0] = p[1] |
707 | 797 |
708 | 798 |
709 # [64] | 799 # [79] |
710 def p_PrimitiveType(self, p): | 800 def p_PrimitiveType(self, p): |
711 """PrimitiveType : UnsignedIntegerType | 801 """PrimitiveType : UnsignedIntegerType |
712 | UnrestrictedFloatType | 802 | UnrestrictedFloatType |
713 | BOOLEAN | 803 | BOOLEAN |
714 | BYTE | 804 | BYTE |
715 | OCTET | 805 | OCTET |
806 | BYTESTRING | |
716 | DOMSTRING | 807 | DOMSTRING |
808 | OBJECT | |
717 | DATE | 809 | DATE |
718 | OBJECT""" | 810 | REGEXP""" |
719 if type(p[1]) == str: | 811 if type(p[1]) == str: |
720 p[0] = self.BuildNamed('PrimitiveType', p, 1) | 812 p[0] = self.BuildNamed('PrimitiveType', p, 1) |
721 else: | 813 else: |
722 p[0] = p[1] | 814 p[0] = p[1] |
723 | 815 |
724 | 816 |
725 # [65] | 817 # [80] |
726 def p_UnrestrictedFloatType(self, p): | 818 def p_UnrestrictedFloatType(self, p): |
727 """UnrestrictedFloatType : UNRESTRICTED FloatType | 819 """UnrestrictedFloatType : UNRESTRICTED FloatType |
728 | FloatType""" | 820 | FloatType""" |
729 if len(p) == 2: | 821 if len(p) == 2: |
730 typeref = self.BuildNamed('PrimitiveType', p, 1) | 822 typeref = self.BuildNamed('PrimitiveType', p, 1) |
731 else: | 823 else: |
732 typeref = self.BuildNamed('PrimitiveType', p, 2) | 824 typeref = self.BuildNamed('PrimitiveType', p, 2) |
733 typeref.AddChildren(self.BuildTrue('UNRESTRICTED')) | 825 typeref.AddChildren(self.BuildTrue('UNRESTRICTED')) |
734 p[0] = typeref | 826 p[0] = typeref |
735 | 827 |
736 | 828 |
737 # [66] | 829 # [81] |
738 def p_FloatType(self, p): | 830 def p_FloatType(self, p): |
739 """FloatType : FLOAT | 831 """FloatType : FLOAT |
740 | DOUBLE""" | 832 | DOUBLE""" |
741 p[0] = p[1] | 833 p[0] = p[1] |
742 | 834 |
743 # [67] | 835 # [82] |
744 def p_UnsignedIntegerType(self, p): | 836 def p_UnsignedIntegerType(self, p): |
745 """UnsignedIntegerType : UNSIGNED IntegerType | 837 """UnsignedIntegerType : UNSIGNED IntegerType |
746 | IntegerType""" | 838 | IntegerType""" |
747 if len(p) == 2: | 839 if len(p) == 2: |
748 p[0] = p[1] | 840 p[0] = p[1] |
749 else: | 841 else: |
750 p[0] = 'unsigned ' + p[2] | 842 p[0] = 'unsigned ' + p[2] |
751 | 843 |
752 # [68] | 844 # [83] |
753 def p_IntegerType(self, p): | 845 def p_IntegerType(self, p): |
754 """IntegerType : SHORT | 846 """IntegerType : SHORT |
755 | LONG OptionalLong""" | 847 | LONG OptionalLong""" |
756 if len(p) == 2: | 848 if len(p) == 2: |
757 p[0] = p[1] | 849 p[0] = p[1] |
758 else: | 850 else: |
759 p[0] = p[1] + p[2] | 851 p[0] = p[1] + p[2] |
760 | 852 |
761 # [69] | 853 # [84] |
762 def p_OptionalLong(self, p): | 854 def p_OptionalLong(self, p): |
763 """OptionalLong : LONG | 855 """OptionalLong : LONG |
764 | """ | 856 | """ |
765 if len(p) > 1: | 857 if len(p) > 1: |
766 p[0] = ' ' + p[1] | 858 p[0] = ' ' + p[1] |
767 else: | 859 else: |
768 p[0] = '' | 860 p[0] = '' |
769 | 861 |
770 | 862 |
771 # [70] Add support for sized array | 863 # [85] Add support for sized array |
772 def p_TypeSuffix(self, p): | 864 def p_TypeSuffix(self, p): |
773 """TypeSuffix : '[' integer ']' TypeSuffix | 865 """TypeSuffix : '[' integer ']' TypeSuffix |
774 | '[' ']' TypeSuffix | 866 | '[' ']' TypeSuffix |
775 | '?' TypeSuffixStartingWithArray | 867 | '?' TypeSuffixStartingWithArray |
776 | """ | 868 | """ |
777 if len(p) == 5: | 869 if len(p) == 5: |
778 p[0] = self.BuildNamed('Array', p, 2, p[4]) | 870 p[0] = self.BuildNamed('Array', p, 2, p[4]) |
779 | 871 |
780 if len(p) == 4: | 872 if len(p) == 4: |
781 p[0] = self.BuildProduction('Array', p, 1, p[3]) | 873 p[0] = self.BuildProduction('Array', p, 1, p[3]) |
782 | 874 |
783 if len(p) == 3: | 875 if len(p) == 3: |
784 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) | 876 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) |
785 | 877 |
786 | 878 |
787 # [71] | 879 # [86] |
788 def p_TypeSuffixStartingWithArray(self, p): | 880 def p_TypeSuffixStartingWithArray(self, p): |
789 """TypeSuffixStartingWithArray : '[' ']' TypeSuffix | 881 """TypeSuffixStartingWithArray : '[' ']' TypeSuffix |
790 | """ | 882 | """ |
791 if len(p) > 1: | 883 if len(p) > 1: |
792 p[0] = self.BuildProduction('Array', p, 0, p[3]) | 884 p[0] = self.BuildProduction('Array', p, 0, p[3]) |
793 | 885 |
794 # [72] | 886 # [87] |
795 def p_Null(self, p): | 887 def p_Null(self, p): |
796 """Null : '?' | 888 """Null : '?' |
797 |""" | 889 |""" |
798 if len(p) > 1: | 890 if len(p) > 1: |
799 p[0] = self.BuildTrue('NULLABLE') | 891 p[0] = self.BuildTrue('NULLABLE') |
800 | 892 |
801 # [73] | 893 # [88] |
802 def p_ReturnType(self, p): | 894 def p_ReturnType(self, p): |
803 """ReturnType : Type | 895 """ReturnType : Type |
804 | VOID""" | 896 | VOID""" |
805 if p[1] == 'void': | 897 if p[1] == 'void': |
806 p[0] = self.BuildProduction('Type', p, 1) | 898 p[0] = self.BuildProduction('Type', p, 1) |
807 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1)) | 899 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1)) |
808 else: | 900 else: |
809 p[0] = p[1] | 901 p[0] = p[1] |
810 | 902 |
811 # [74] | 903 # [89] |
904 #def p_IdentifierList(self, p): | |
905 # """IdentifierList : identifier Identifiers""" | |
906 # p[0] = ListFromConcat(p[1], p[2]) | |
907 | |
908 # [90] | |
909 #def p_Identifiers(self, p): | |
Jens Widell
2014/06/12 13:34:36
Note that this is identical to [37]. Reported http
| |
910 # """Identifiers : ',' identifier Identifiers | |
911 # |""" | |
912 # if len(p) > 1: | |
913 # p[0] = ListFromConcat(p[2], p[3]) | |
914 | |
915 # [91] | |
812 def p_ExtendedAttributeNoArgs(self, p): | 916 def p_ExtendedAttributeNoArgs(self, p): |
813 """ExtendedAttributeNoArgs : identifier""" | 917 """ExtendedAttributeNoArgs : identifier""" |
814 p[0] = self.BuildNamed('ExtAttribute', p, 1) | 918 p[0] = self.BuildNamed('ExtAttribute', p, 1) |
815 | 919 |
816 # [75] | 920 # [92] |
817 def p_ExtendedAttributeArgList(self, p): | 921 def p_ExtendedAttributeArgList(self, p): |
818 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'""" | 922 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'""" |
819 arguments = self.BuildProduction('Arguments', p, 2, p[3]) | 923 arguments = self.BuildProduction('Arguments', p, 2, p[3]) |
820 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments) | 924 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments) |
821 | 925 |
822 # [76] | 926 # [93] |
823 def p_ExtendedAttributeIdent(self, p): | 927 def p_ExtendedAttributeIdent(self, p): |
824 """ExtendedAttributeIdent : identifier '=' identifier""" | 928 """ExtendedAttributeIdent : identifier '=' identifier""" |
825 value = self.BuildAttribute('VALUE', p[3]) | 929 value = self.BuildAttribute('VALUE', p[3]) |
826 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 930 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
827 | 931 |
828 # [77] | 932 # [95] |
829 def p_ExtendedAttributeNamedArgList(self, p): | 933 def p_ExtendedAttributeNamedArgList(self, p): |
830 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'""" | 934 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'""" |
831 args = self.BuildProduction('Arguments', p, 4, p[5]) | 935 args = self.BuildProduction('Arguments', p, 4, p[5]) |
832 value = self.BuildNamed('Call', p, 3, args) | 936 value = self.BuildNamed('Call', p, 3, args) |
833 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 937 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
834 | 938 |
835 # | 939 # |
836 # Parser Errors | 940 # Parser Errors |
837 # | 941 # |
838 # p_error is called whenever the parser can not find a pattern match for | 942 # 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 | 1148 |
1045 print '\n'.join(ast.Tree(accept_props=['PROD'])) | 1149 print '\n'.join(ast.Tree(accept_props=['PROD'])) |
1046 if errors: | 1150 if errors: |
1047 print '\nFound %d errors.\n' % errors | 1151 print '\nFound %d errors.\n' % errors |
1048 | 1152 |
1049 return errors | 1153 return errors |
1050 | 1154 |
1051 | 1155 |
1052 if __name__ == '__main__': | 1156 if __name__ == '__main__': |
1053 sys.exit(main(sys.argv[1:])) | 1157 sys.exit(main(sys.argv[1:])) |
OLD | NEW |