Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(808)

Side by Side Diff: tools/idl_parser/idl_parser.py

Issue 653343002: Support Promise<T> syntax in the IDL parser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 | AttributeOrOperationOrIterator""" 265 | AttributeOrOperationOrIterator"""
266 p[0] = p[1] 266 p[0] = p[1]
267 267
268 # [10.1] Removed unsupported: Serializer
269 def p_AttributeOrOperationOrIterator(self, p):
270 """AttributeOrOperationOrIterator : Stringifier
271 | StaticMember
272 | ReadWriteAttribute
273 | OperationOrIterator"""
274 p[0] = p[1]
275
268 # [11] 276 # [11]
269 def p_Dictionary(self, p): 277 def p_Dictionary(self, p):
270 """Dictionary : DICTIONARY identifier Inheritance '{' DictionaryMembers '}' ';'""" 278 """Dictionary : DICTIONARY identifier Inheritance '{' DictionaryMembers '}' ';'"""
271 p[0] = self.BuildNamed('Dictionary', p, 2, ListFromConcat(p[3], p[5])) 279 p[0] = self.BuildNamed('Dictionary', p, 2, ListFromConcat(p[3], p[5]))
272 280
273 # [11.1] Error recovery for regular Dictionary 281 # [11.1] Error recovery for regular Dictionary
274 def p_DictionaryError(self, p): 282 def p_DictionaryError(self, p):
275 """Dictionary : DICTIONARY error ';'""" 283 """Dictionary : DICTIONARY error ';'"""
276 p[0] = self.BuildError(p, 'Dictionary') 284 p[0] = self.BuildError(p, 'Dictionary')
277 285
278 # [12] 286 # [12]
279 def p_DictionaryMembers(self, p): 287 def p_DictionaryMembers(self, p):
280 """DictionaryMembers : ExtendedAttributeList DictionaryMember DictionaryMemb ers 288 """DictionaryMembers : ExtendedAttributeList DictionaryMember DictionaryMemb ers
281 |""" 289 |"""
282 if len(p) > 1: 290 if len(p) > 1:
283 p[2].AddChildren(p[1]) 291 p[2].AddChildren(p[1])
284 p[0] = ListFromConcat(p[2], p[3]) 292 p[0] = ListFromConcat(p[2], p[3])
285 293
286 # [13] 294 # [13]
287 def p_DictionaryMember(self, p): 295 def p_DictionaryMember(self, p):
288 """DictionaryMember : Type identifier Default ';'""" 296 """DictionaryMember : Type identifier Default ';'"""
289 p[0] = self.BuildNamed('Key', p, 2, ListFromConcat(p[1], p[3])) 297 p[0] = self.BuildNamed('Key', p, 2, ListFromConcat(p[1], p[3]))
290 298
291 # [14] 299 # [14] NOT IMPLEMENTED (Required)
300
301 # [15]
292 def p_PartialDictionary(self, p): 302 def p_PartialDictionary(self, p):
293 """PartialDictionary : DICTIONARY identifier '{' DictionaryMembers '}' ';'"" " 303 """PartialDictionary : DICTIONARY identifier '{' DictionaryMembers '}' ';'"" "
294 partial = self.BuildTrue('Partial') 304 partial = self.BuildTrue('Partial')
295 p[0] = self.BuildNamed('Dictionary', p, 2, ListFromConcat(p[4], partial)) 305 p[0] = self.BuildNamed('Dictionary', p, 2, ListFromConcat(p[4], partial))
296 306
297 # [14.1] Error recovery for Partial Dictionary 307 # [15.1] Error recovery for Partial Dictionary
298 def p_PartialDictionaryError(self, p): 308 def p_PartialDictionaryError(self, p):
299 """PartialDictionary : DICTIONARY error ';'""" 309 """PartialDictionary : DICTIONARY error ';'"""
300 p[0] = self.BuildError(p, 'PartialDictionary') 310 p[0] = self.BuildError(p, 'PartialDictionary')
301 311
302 # [15] 312 # [16]
303 def p_Default(self, p): 313 def p_Default(self, p):
304 """Default : '=' DefaultValue 314 """Default : '=' DefaultValue
305 |""" 315 |"""
306 if len(p) > 1: 316 if len(p) > 1:
307 p[0] = self.BuildProduction('Default', p, 2, p[2]) 317 p[0] = self.BuildProduction('Default', p, 2, p[2])
308 318
309 # [16] 319 # [17]
310 def p_DefaultValue(self, p): 320 def p_DefaultValue(self, p):
311 """DefaultValue : ConstValue 321 """DefaultValue : ConstValue
312 | string""" 322 | string"""
313 if type(p[1]) == str: 323 if type(p[1]) == str:
314 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'DOMString'), 324 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'DOMString'),
315 self.BuildAttribute('NAME', p[1])) 325 self.BuildAttribute('NAME', p[1]))
316 else: 326 else:
317 p[0] = p[1] 327 p[0] = p[1]
318 328
319 # [17] 329 # [] - Not specified
320 def p_Exception(self, p): 330 def p_Exception(self, p):
321 """Exception : EXCEPTION identifier Inheritance '{' ExceptionMembers '}' ';' """ 331 """Exception : EXCEPTION identifier Inheritance '{' ExceptionMembers '}' ';' """
322 p[0] = self.BuildNamed('Exception', p, 2, ListFromConcat(p[3], p[5])) 332 p[0] = self.BuildNamed('Exception', p, 2, ListFromConcat(p[3], p[5]))
323 333
324 # [18] 334 # [] - Not specified
325 def p_ExceptionMembers(self, p): 335 def p_ExceptionMembers(self, p):
326 """ExceptionMembers : ExtendedAttributeList ExceptionMember ExceptionMembers 336 """ExceptionMembers : ExtendedAttributeList ExceptionMember ExceptionMembers
327 |""" 337 |"""
328 if len(p) > 1: 338 if len(p) > 1:
329 p[2].AddChildren(p[1]) 339 p[2].AddChildren(p[1])
330 p[0] = ListFromConcat(p[2], p[3]) 340 p[0] = ListFromConcat(p[2], p[3])
331 341
332 # [18.1] Error recovery for ExceptionMembers 342 # [.1] Error recovery for ExceptionMembers - Not specified
333 def p_ExceptionMembersError(self, p): 343 def p_ExceptionMembersError(self, p):
334 """ExceptionMembers : error""" 344 """ExceptionMembers : error"""
335 p[0] = self.BuildError(p, 'ExceptionMembers') 345 p[0] = self.BuildError(p, 'ExceptionMembers')
336 346
337 # [19] 347 # [18]
338 def p_Inheritance(self, p): 348 def p_Inheritance(self, p):
339 """Inheritance : ':' identifier 349 """Inheritance : ':' identifier
340 |""" 350 |"""
341 if len(p) > 1: 351 if len(p) > 1:
342 p[0] = self.BuildNamed('Inherit', p, 2) 352 p[0] = self.BuildNamed('Inherit', p, 2)
343 353
344 # [20] 354 # [19]
345 def p_Enum(self, p): 355 def p_Enum(self, p):
346 """Enum : ENUM identifier '{' EnumValueList '}' ';'""" 356 """Enum : ENUM identifier '{' EnumValueList '}' ';'"""
347 p[0] = self.BuildNamed('Enum', p, 2, p[4]) 357 p[0] = self.BuildNamed('Enum', p, 2, p[4])
348 358
349 # [20.1] Error recovery for Enums 359 # [19.1] Error recovery for Enums
350 def p_EnumError(self, p): 360 def p_EnumError(self, p):
351 """Enum : ENUM error ';'""" 361 """Enum : ENUM error ';'"""
352 p[0] = self.BuildError(p, 'Enum') 362 p[0] = self.BuildError(p, 'Enum')
353 363
354 # [21] 364 # [20]
355 def p_EnumValueList(self, p): 365 def p_EnumValueList(self, p):
356 """EnumValueList : ExtendedAttributeList string EnumValueListComma""" 366 """EnumValueList : ExtendedAttributeList string EnumValueListComma"""
357 enum = self.BuildNamed('EnumItem', p, 2, p[1]) 367 enum = self.BuildNamed('EnumItem', p, 2, p[1])
358 p[0] = ListFromConcat(enum, p[3]) 368 p[0] = ListFromConcat(enum, p[3])
359 369
360 # [22] 370 # [21]
361 def p_EnumValueListComma(self, p): 371 def p_EnumValueListComma(self, p):
362 """EnumValueListComma : ',' EnumValueListString 372 """EnumValueListComma : ',' EnumValueListString
363 |""" 373 |"""
364 if len(p) > 1: 374 if len(p) > 1:
365 p[0] = p[2] 375 p[0] = p[2]
366 376
367 # [23] 377 # [22]
368 def p_EnumValueListString(self, p): 378 def p_EnumValueListString(self, p):
369 """EnumValueListString : ExtendedAttributeList string EnumValueListComma 379 """EnumValueListString : ExtendedAttributeList string EnumValueListComma
370 |""" 380 |"""
371 if len(p) > 1: 381 if len(p) > 1:
372 enum = self.BuildNamed('EnumItem', p, 2, p[1]) 382 enum = self.BuildNamed('EnumItem', p, 2, p[1])
373 p[0] = ListFromConcat(enum, p[3]) 383 p[0] = ListFromConcat(enum, p[3])
374 384
375 # [24] 385 # [23]
376 def p_CallbackRest(self, p): 386 def p_CallbackRest(self, p):
377 """CallbackRest : identifier '=' ReturnType '(' ArgumentList ')' ';'""" 387 """CallbackRest : identifier '=' ReturnType '(' ArgumentList ')' ';'"""
378 arguments = self.BuildProduction('Arguments', p, 4, p[5]) 388 arguments = self.BuildProduction('Arguments', p, 4, p[5])
379 p[0] = self.BuildNamed('Callback', p, 1, ListFromConcat(p[3], arguments)) 389 p[0] = self.BuildNamed('Callback', p, 1, ListFromConcat(p[3], arguments))
380 390
381 # [25] 391 # [24]
382 def p_Typedef(self, p): 392 def p_Typedef(self, p):
383 """Typedef : TYPEDEF ExtendedAttributeListNoComments Type identifier ';'""" 393 """Typedef : TYPEDEF ExtendedAttributeListNoComments Type identifier ';'"""
384 p[0] = self.BuildNamed('Typedef', p, 4, ListFromConcat(p[2], p[3])) 394 p[0] = self.BuildNamed('Typedef', p, 4, ListFromConcat(p[2], p[3]))
385 395
386 # [25.1] Error recovery for Typedefs 396 # [24.1] Error recovery for Typedefs
387 def p_TypedefError(self, p): 397 def p_TypedefError(self, p):
388 """Typedef : TYPEDEF error ';'""" 398 """Typedef : TYPEDEF error ';'"""
389 p[0] = self.BuildError(p, 'Typedef') 399 p[0] = self.BuildError(p, 'Typedef')
390 400
391 # [26] 401 # [25]
392 def p_ImplementsStatement(self, p): 402 def p_ImplementsStatement(self, p):
393 """ImplementsStatement : identifier IMPLEMENTS identifier ';'""" 403 """ImplementsStatement : identifier IMPLEMENTS identifier ';'"""
394 name = self.BuildAttribute('REFERENCE', p[3]) 404 name = self.BuildAttribute('REFERENCE', p[3])
395 p[0] = self.BuildNamed('Implements', p, 1, name) 405 p[0] = self.BuildNamed('Implements', p, 1, name)
396 406
397 # [27] 407 # [26]
398 def p_Const(self, p): 408 def p_Const(self, p):
399 """Const : CONST ConstType identifier '=' ConstValue ';'""" 409 """Const : CONST ConstType identifier '=' ConstValue ';'"""
400 value = self.BuildProduction('Value', p, 5, p[5]) 410 value = self.BuildProduction('Value', p, 5, p[5])
401 p[0] = self.BuildNamed('Const', p, 3, ListFromConcat(p[2], value)) 411 p[0] = self.BuildNamed('Const', p, 3, ListFromConcat(p[2], value))
402 412
403 # [28] 413 # [27]
404 def p_ConstValue(self, p): 414 def p_ConstValue(self, p):
405 """ConstValue : BooleanLiteral 415 """ConstValue : BooleanLiteral
406 | FloatLiteral 416 | FloatLiteral
407 | integer 417 | integer
408 | null""" 418 | null"""
409 if type(p[1]) == str: 419 if type(p[1]) == str:
410 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'integer'), 420 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'integer'),
411 self.BuildAttribute('NAME', p[1])) 421 self.BuildAttribute('NAME', p[1]))
412 else: 422 else:
413 p[0] = p[1] 423 p[0] = p[1]
414 424
415 # [28.1] Add definition for NULL 425 # [27.1] Add definition for NULL
416 def p_null(self, p): 426 def p_null(self, p):
417 """null : NULL""" 427 """null : NULL"""
418 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'NULL'), 428 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'NULL'),
419 self.BuildAttribute('NAME', 'NULL')) 429 self.BuildAttribute('NAME', 'NULL'))
420 430
421 # [29] 431 # [28]
422 def p_BooleanLiteral(self, p): 432 def p_BooleanLiteral(self, p):
423 """BooleanLiteral : TRUE 433 """BooleanLiteral : TRUE
424 | FALSE""" 434 | FALSE"""
425 value = self.BuildAttribute('VALUE', Boolean(p[1] == 'true')) 435 value = self.BuildAttribute('VALUE', Boolean(p[1] == 'true'))
426 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'boolean'), value) 436 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'boolean'), value)
427 437
428 # [30] 438 # [29]
429 def p_FloatLiteral(self, p): 439 def p_FloatLiteral(self, p):
430 """FloatLiteral : float 440 """FloatLiteral : float
431 | '-' INFINITY 441 | '-' INFINITY
432 | INFINITY 442 | INFINITY
433 | NAN """ 443 | NAN """
434 if len(p) > 2: 444 if len(p) > 2:
435 val = '-Infinity' 445 val = '-Infinity'
436 else: 446 else:
437 val = p[1] 447 val = p[1]
438 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'), 448 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'),
439 self.BuildAttribute('VALUE', val)) 449 self.BuildAttribute('VALUE', val))
440 450
441 # [31] Removed unsupported: Serializer 451 # [30-34] NOT IMPLEMENTED (Serializer)
442 def p_AttributeOrOperationOrIterator(self, p):
443 """AttributeOrOperationOrIterator : Stringifier
444 | StaticMember
445 | Attribute
446 | OperationOrIterator"""
447 p[0] = p[1]
448 452
449 # [32-37] NOT IMPLEMENTED (Serializer) 453 # [35]
450
451 # [38]
452 def p_Stringifier(self, p): 454 def p_Stringifier(self, p):
453 """Stringifier : STRINGIFIER StringifierRest""" 455 """Stringifier : STRINGIFIER StringifierRest"""
454 p[0] = self.BuildProduction('Stringifier', p, 1, p[2]) 456 p[0] = self.BuildProduction('Stringifier', p, 1, p[2])
455 457
456 # [39] 458 # [36]
457 def p_StringifierRest(self, p): 459 def p_StringifierRest(self, p):
458 """StringifierRest : AttributeRest 460 """StringifierRest : AttributeRest
459 | ReturnType OperationRest 461 | ReturnType OperationRest
460 | ';'""" 462 | ';'"""
461 if len(p) == 3: 463 if len(p) == 3:
462 p[2].AddChildren(p[1]) 464 p[2].AddChildren(p[1])
463 p[0] = p[2] 465 p[0] = p[2]
464 elif p[1] != ';': 466 elif p[1] != ';':
465 p[0] = p[1] 467 p[0] = p[1]
466 468
467 # [40] 469 # [37]
468 def p_StaticMember(self, p): 470 def p_StaticMember(self, p):
469 """StaticMember : STATIC StaticMemberRest""" 471 """StaticMember : STATIC StaticMemberRest"""
470 p[2].AddChildren(self.BuildTrue('STATIC')) 472 p[2].AddChildren(self.BuildTrue('STATIC'))
471 p[0] = p[2] 473 p[0] = p[2]
472 474
473 # [41] 475 # [38]
474 def p_StaticMemberRest(self, p): 476 def p_StaticMemberRest(self, p):
475 """StaticMemberRest : AttributeRest 477 """StaticMemberRest : AttributeRest
476 | ReturnType OperationRest""" 478 | ReturnType OperationRest"""
477 if len(p) == 2: 479 if len(p) == 2:
478 p[0] = p[1] 480 p[0] = p[1]
479 else: 481 else:
480 p[2].AddChildren(p[1]) 482 p[2].AddChildren(p[1])
481 p[0] = p[2] 483 p[0] = p[2]
482 484
483 # [42] 485 # [39] NOT IMPLEMENTED (ReadOnlyMember)
484 def p_Attribute(self, p): 486 # [40] NOT IMPLEMENTED (ReadOnlyMemberReset)
485 """Attribute : Inherit AttributeRest""" 487
488 # [41]
489 def p_ReadWriteAttribute(self, p):
490 """ReadWriteAttribute : Inherit AttributeRest"""
486 p[2].AddChildren(ListFromConcat(p[1])) 491 p[2].AddChildren(ListFromConcat(p[1]))
487 p[0] = p[2] 492 p[0] = p[2]
488 493
489 # [43] 494 # [41] Deprecated - Remove this entry after blink stops using it.
495 def p_Attribute(self, p):
496 """Attribute : ReadWriteAttribute"""
497 p[0] = p[1]
498
499 # [42]
490 def p_AttributeRest(self, p): 500 def p_AttributeRest(self, p):
491 """AttributeRest : ReadOnly ATTRIBUTE Type identifier ';'""" 501 """AttributeRest : ReadOnly ATTRIBUTE Type identifier ';'"""
492 p[0] = self.BuildNamed('Attribute', p, 4, 502 p[0] = self.BuildNamed('Attribute', p, 4,
493 ListFromConcat(p[1], p[3])) 503 ListFromConcat(p[1], p[3]))
494 504
495 # [44] 505 # [43] NOT IMPLEMENTED (AttributeName)
506 # [44] NOT IMPLEMENTED (AttributeNameKeyword)
507
508 # [45]
496 def p_Inherit(self, p): 509 def p_Inherit(self, p):
497 """Inherit : INHERIT 510 """Inherit : INHERIT
498 |""" 511 |"""
499 if len(p) > 1: 512 if len(p) > 1:
500 p[0] = self.BuildTrue('INHERIT') 513 p[0] = self.BuildTrue('INHERIT')
501 514
502 # [45] 515 # [46]
503 def p_ReadOnly(self, p): 516 def p_ReadOnly(self, p):
504 """ReadOnly : READONLY 517 """ReadOnly : READONLY
505 |""" 518 |"""
506 if len(p) > 1: 519 if len(p) > 1:
507 p[0] = self.BuildTrue('READONLY') 520 p[0] = self.BuildTrue('READONLY')
508 521
509 # [46] 522 # [47]
510 def p_OperationOrIterator(self, p): 523 def p_OperationOrIterator(self, p):
511 """OperationOrIterator : ReturnType OperationOrIteratorRest 524 """OperationOrIterator : ReturnType OperationOrIteratorRest
512 | SpecialOperation""" 525 | SpecialOperation"""
513 if len(p) == 3: 526 if len(p) == 3:
514 p[2].AddChildren(p[1]) 527 p[2].AddChildren(p[1])
515 p[0] = p[2] 528 p[0] = p[2]
516 else: 529 else:
517 p[0] = p[1] 530 p[0] = p[1]
518 531
519 # [47] 532 # [48]
520 def p_SpecialOperation(self, p): 533 def p_SpecialOperation(self, p):
521 """SpecialOperation : Special Specials ReturnType OperationRest""" 534 """SpecialOperation : Special Specials ReturnType OperationRest"""
522 p[4].AddChildren(ListFromConcat(p[1], p[2], p[3])) 535 p[4].AddChildren(ListFromConcat(p[1], p[2], p[3]))
523 p[0] = p[4] 536 p[0] = p[4]
524 537
525 # [48] 538 # [49]
526 def p_Specials(self, p): 539 def p_Specials(self, p):
527 """Specials : Special Specials 540 """Specials : Special Specials
528 | """ 541 | """
529 if len(p) > 1: 542 if len(p) > 1:
530 p[0] = ListFromConcat(p[1], p[2]) 543 p[0] = ListFromConcat(p[1], p[2])
531 544
532 # [49] 545 # [50]
533 def p_Special(self, p): 546 def p_Special(self, p):
534 """Special : GETTER 547 """Special : GETTER
535 | SETTER 548 | SETTER
536 | CREATOR 549 | CREATOR
537 | DELETER 550 | DELETER
538 | LEGACYCALLER""" 551 | LEGACYCALLER"""
539 p[0] = self.BuildTrue(p[1].upper()) 552 p[0] = self.BuildTrue(p[1].upper())
540 553
541 # [50] Removed unsupported: IteratorRest 554 # [51]
542 def p_OperationOrIteratorRest(self, p): 555 def p_OperationOrIteratorRest(self, p):
543 """OperationOrIteratorRest : OperationRest""" 556 """OperationOrIteratorRest : OperationRest"""
544 p[0] = p[1] 557 p[0] = p[1]
545 558
546 # [51-53] NOT IMPLEMENTED (IteratorRest) 559 # [51]
547
548 # [54]
549 def p_OperationRest(self, p): 560 def p_OperationRest(self, p):
550 """OperationRest : OptionalIdentifier '(' ArgumentList ')' ';'""" 561 """OperationRest : OptionalIdentifier '(' ArgumentList ')' ';'"""
551 arguments = self.BuildProduction('Arguments', p, 2, p[3]) 562 arguments = self.BuildProduction('Arguments', p, 2, p[3])
552 p[0] = self.BuildNamed('Operation', p, 1, arguments) 563 p[0] = self.BuildNamed('Operation', p, 1, arguments)
553 564
554 # [55] 565 # [52]
555 def p_OptionalIdentifier(self, p): 566 def p_OptionalIdentifier(self, p):
556 """OptionalIdentifier : identifier 567 """OptionalIdentifier : identifier
557 |""" 568 |"""
558 if len(p) > 1: 569 if len(p) > 1:
559 p[0] = p[1] 570 p[0] = p[1]
560 else: 571 else:
561 p[0] = '_unnamed_' 572 p[0] = '_unnamed_'
562 573
563 # [56] 574 # [53]
564 def p_ArgumentList(self, p): 575 def p_ArgumentList(self, p):
565 """ArgumentList : Argument Arguments 576 """ArgumentList : Argument Arguments
566 |""" 577 |"""
567 if len(p) > 1: 578 if len(p) > 1:
568 p[0] = ListFromConcat(p[1], p[2]) 579 p[0] = ListFromConcat(p[1], p[2])
569 580
570 # [56.1] ArgumentList error recovery 581 # [53.1] ArgumentList error recovery
571 def p_ArgumentListError(self, p): 582 def p_ArgumentListError(self, p):
572 """ArgumentList : error """ 583 """ArgumentList : error """
573 p[0] = self.BuildError(p, 'ArgumentList') 584 p[0] = self.BuildError(p, 'ArgumentList')
574 585
575 # [57] 586 # [54]
576 def p_Arguments(self, p): 587 def p_Arguments(self, p):
577 """Arguments : ',' Argument Arguments 588 """Arguments : ',' Argument Arguments
578 |""" 589 |"""
579 if len(p) > 1: 590 if len(p) > 1:
580 p[0] = ListFromConcat(p[2], p[3]) 591 p[0] = ListFromConcat(p[2], p[3])
581 592
582 # [58] 593 # [55]
583 def p_Argument(self, p): 594 def p_Argument(self, p):
584 """Argument : ExtendedAttributeList OptionalOrRequiredArgument""" 595 """Argument : ExtendedAttributeList OptionalOrRequiredArgument"""
585 p[2].AddChildren(p[1]) 596 p[2].AddChildren(p[1])
586 p[0] = p[2] 597 p[0] = p[2]
587 598
588 # [59] 599 # [56]
589 def p_OptionalOrRequiredArgument(self, p): 600 def p_OptionalOrRequiredArgument(self, p):
590 """OptionalOrRequiredArgument : OPTIONAL Type ArgumentName Default 601 """OptionalOrRequiredArgument : OPTIONAL Type ArgumentName Default
591 | Type Ellipsis ArgumentName""" 602 | Type Ellipsis ArgumentName"""
592 if len(p) > 4: 603 if len(p) > 4:
593 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[2], p[4])) 604 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[2], p[4]))
594 arg.AddChildren(self.BuildTrue('OPTIONAL')) 605 arg.AddChildren(self.BuildTrue('OPTIONAL'))
595 else: 606 else:
596 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[1], p[2])) 607 arg = self.BuildNamed('Argument', p, 3, ListFromConcat(p[1], p[2]))
597 p[0] = arg 608 p[0] = arg
598 609
599 # [60] 610 # [57]
600 def p_ArgumentName(self, p): 611 def p_ArgumentName(self, p):
601 """ArgumentName : ArgumentNameKeyword 612 """ArgumentName : ArgumentNameKeyword
602 | identifier""" 613 | identifier"""
603 p[0] = p[1] 614 p[0] = p[1]
604 615
605 # [61] 616 # [58]
606 def p_Ellipsis(self, p): 617 def p_Ellipsis(self, p):
607 """Ellipsis : ELLIPSIS 618 """Ellipsis : ELLIPSIS
608 |""" 619 |"""
609 if len(p) > 1: 620 if len(p) > 1:
610 p[0] = self.BuildNamed('Argument', p, 1) 621 p[0] = self.BuildNamed('Argument', p, 1)
611 p[0].AddChildren(self.BuildTrue('ELLIPSIS')) 622 p[0].AddChildren(self.BuildTrue('ELLIPSIS'))
612 623
613 # [62] 624 # [] Unspecified
614 def p_ExceptionMember(self, p): 625 def p_ExceptionMember(self, p):
615 """ExceptionMember : Const 626 """ExceptionMember : Const
616 | ExceptionField""" 627 | ExceptionField"""
617 p[0] = p[1] 628 p[0] = p[1]
618 629
619 # [63] 630 # [] Unspecified
620 def p_ExceptionField(self, p): 631 def p_ExceptionField(self, p):
621 """ExceptionField : Type identifier ';'""" 632 """ExceptionField : Type identifier ';'"""
622 p[0] = self.BuildNamed('ExceptionField', p, 2, p[1]) 633 p[0] = self.BuildNamed('ExceptionField', p, 2, p[1])
623 634
624 # [63.1] Error recovery for ExceptionMembers 635 # [] Error recovery for ExceptionMembers - Unspecified
625 def p_ExceptionFieldError(self, p): 636 def p_ExceptionFieldError(self, p):
626 """ExceptionField : error""" 637 """ExceptionField : error"""
627 p[0] = self.BuildError(p, 'ExceptionField') 638 p[0] = self.BuildError(p, 'ExceptionField')
628 639
629 # [64] No comment version for mid statement attributes. 640 # [59] NOT IMPLEMENTED (Iterable)
641 # [60] NOT IMPLEMENTED (OptionalType)
642 # [61] NOT IMPLEMENTED (ReadWriteMaplike)
643 # [62] NOT IMPLEMENTED (ReadWriteSetlike)
644 # [63] NOT IMPLEMENTED (MaplikeRest)
645 # [64] NOT IMPLEMENTED (SetlikeRest)
646
647 # [65] No comment version for mid statement attributes.
630 def p_ExtendedAttributeListNoComments(self, p): 648 def p_ExtendedAttributeListNoComments(self, p):
631 """ExtendedAttributeListNoComments : '[' ExtendedAttribute ExtendedAttribute s ']' 649 """ExtendedAttributeListNoComments : '[' ExtendedAttribute ExtendedAttribute s ']'
632 | """ 650 | """
633 if len(p) > 2: 651 if len(p) > 2:
634 items = ListFromConcat(p[2], p[3]) 652 items = ListFromConcat(p[2], p[3])
635 p[0] = self.BuildProduction('ExtAttributes', p, 1, items) 653 p[0] = self.BuildProduction('ExtAttributes', p, 1, items)
636 654
637 # [64.1] Add optional comment field for start of statements. 655 # [65.1] Add optional comment field for start of statements.
638 def p_ExtendedAttributeList(self, p): 656 def p_ExtendedAttributeList(self, p):
639 """ExtendedAttributeList : Comments '[' ExtendedAttribute ExtendedAttributes ']' 657 """ExtendedAttributeList : Comments '[' ExtendedAttribute ExtendedAttributes ']'
640 | Comments """ 658 | Comments """
641 if len(p) > 2: 659 if len(p) > 2:
642 items = ListFromConcat(p[3], p[4]) 660 items = ListFromConcat(p[3], p[4])
643 attribs = self.BuildProduction('ExtAttributes', p, 2, items) 661 attribs = self.BuildProduction('ExtAttributes', p, 2, items)
644 p[0] = ListFromConcat(p[1], attribs) 662 p[0] = ListFromConcat(p[1], attribs)
645 else: 663 else:
646 p[0] = p[1] 664 p[0] = p[1]
647 665
648 # [65] 666 # [66]
649 def p_ExtendedAttributes(self, p): 667 def p_ExtendedAttributes(self, p):
650 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes 668 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes
651 |""" 669 |"""
652 if len(p) > 1: 670 if len(p) > 1:
653 p[0] = ListFromConcat(p[2], p[3]) 671 p[0] = ListFromConcat(p[2], p[3])
654 672
655 # We only support: 673 # We only support:
656 # [ identifier ] 674 # [ identifier ]
657 # [ identifier ( ArgumentList ) ] 675 # [ identifier ( ArgumentList ) ]
658 # [ identifier = identifier ] 676 # [ identifier = identifier ]
659 # [ identifier = ( IdentifierList ) ] 677 # [ identifier = ( IdentifierList ) ]
660 # [ identifier = identifier ( ArgumentList ) ] 678 # [ identifier = identifier ( ArgumentList ) ]
661 # [66] map directly to [91-93, 95] 679 # [66] map directly to [91-93, 95]
662 # [67-69, 71] are unsupported 680 # [67-69, 71] are unsupported
663 def p_ExtendedAttribute(self, p): 681 def p_ExtendedAttribute(self, p):
664 """ExtendedAttribute : ExtendedAttributeNoArgs 682 """ExtendedAttribute : ExtendedAttributeNoArgs
665 | ExtendedAttributeArgList 683 | ExtendedAttributeArgList
666 | ExtendedAttributeIdent 684 | ExtendedAttributeIdent
667 | ExtendedAttributeIdentList 685 | ExtendedAttributeIdentList
668 | ExtendedAttributeNamedArgList""" 686 | ExtendedAttributeNamedArgList"""
669 p[0] = p[1] 687 p[0] = p[1]
670 688
671 # [70] 689 # [71]
672 def p_ArgumentNameKeyword(self, p): 690 def p_ArgumentNameKeyword(self, p):
673 """ArgumentNameKeyword : ATTRIBUTE 691 """ArgumentNameKeyword : ATTRIBUTE
674 | CALLBACK 692 | CALLBACK
675 | CONST 693 | CONST
676 | CREATOR 694 | CREATOR
677 | DELETER 695 | DELETER
678 | DICTIONARY 696 | DICTIONARY
679 | ENUM 697 | ENUM
680 | EXCEPTION 698 | EXCEPTION
681 | GETTER 699 | GETTER
682 | IMPLEMENTS 700 | IMPLEMENTS
683 | INHERIT 701 | INHERIT
684 | LEGACYCALLER 702 | LEGACYCALLER
685 | PARTIAL 703 | PARTIAL
686 | SERIALIZER 704 | SERIALIZER
687 | SETTER 705 | SETTER
688 | STATIC 706 | STATIC
689 | STRINGIFIER 707 | STRINGIFIER
690 | TYPEDEF 708 | TYPEDEF
691 | UNRESTRICTED""" 709 | UNRESTRICTED"""
692 p[0] = p[1] 710 p[0] = p[1]
693 711
694 # [72] 712 # [72] NOT IMPLEMENTED (OtherOrComma)
713
714 # [73]
695 def p_Type(self, p): 715 def p_Type(self, p):
696 """Type : SingleType 716 """Type : SingleType
697 | UnionType TypeSuffix""" 717 | UnionType TypeSuffix"""
698 if len(p) == 2: 718 if len(p) == 2:
699 p[0] = self.BuildProduction('Type', p, 1, p[1]) 719 p[0] = self.BuildProduction('Type', p, 1, p[1])
700 else: 720 else:
701 p[0] = self.BuildProduction('Type', p, 1, ListFromConcat(p[1], p[2])) 721 p[0] = self.BuildProduction('Type', p, 1, ListFromConcat(p[1], p[2]))
702 722
703 # [73] 723 # [74]
704 def p_SingleType(self, p): 724 def p_SingleType(self, p):
705 """SingleType : NonAnyType 725 """SingleType : NonAnyType
706 | ANY TypeSuffixStartingWithArray""" 726 | ANY TypeSuffixStartingWithArray"""
707 if len(p) == 2: 727 if len(p) == 2:
708 p[0] = p[1] 728 p[0] = p[1]
709 else: 729 else:
710 p[0] = ListFromConcat(self.BuildProduction('Any', p, 1), p[2]) 730 p[0] = ListFromConcat(self.BuildProduction('Any', p, 1), p[2])
711 731
712 # [74] 732 # [75]
713 def p_UnionType(self, p): 733 def p_UnionType(self, p):
714 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ')'"" " 734 """UnionType : '(' UnionMemberType OR UnionMemberType UnionMemberTypes ')'"" "
715 735
716 # [75] 736 # [76]
717 def p_UnionMemberType(self, p): 737 def p_UnionMemberType(self, p):
718 """UnionMemberType : NonAnyType 738 """UnionMemberType : NonAnyType
719 | UnionType TypeSuffix 739 | UnionType TypeSuffix
720 | ANY '[' ']' TypeSuffix""" 740 | ANY '[' ']' TypeSuffix"""
721 # [76] 741 # [77]
722 def p_UnionMemberTypes(self, p): 742 def p_UnionMemberTypes(self, p):
723 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes 743 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes
724 |""" 744 |"""
725 745
726 # [77] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType 746 # [78] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType
727 # Moving all built-in types into PrimitiveType makes it easier to 747 # Moving all built-in types into PrimitiveType makes it easier to
728 # differentiate between them and 'identifier', since p[1] would be a string in 748 # differentiate between them and 'identifier', since p[1] would be a string in
729 # both cases. 749 # both cases.
730 def p_NonAnyType(self, p): 750 def p_NonAnyType(self, p):
731 """NonAnyType : PrimitiveType TypeSuffix 751 """NonAnyType : PrimitiveType TypeSuffix
752 | PromiseType Null
732 | identifier TypeSuffix 753 | identifier TypeSuffix
733 | SEQUENCE '<' Type '>' Null""" 754 | SEQUENCE '<' Type '>' Null"""
734 if len(p) == 3: 755 if len(p) == 3:
735 if type(p[1]) == str: 756 if type(p[1]) == str:
736 typeref = self.BuildNamed('Typeref', p, 1) 757 typeref = self.BuildNamed('Typeref', p, 1)
737 else: 758 else:
738 typeref = p[1] 759 typeref = p[1]
739 p[0] = ListFromConcat(typeref, p[2]) 760 p[0] = ListFromConcat(typeref, p[2])
740 761
741 if len(p) == 6: 762 if len(p) == 6:
742 p[0] = self.BuildProduction('Sequence', p, 1, ListFromConcat(p[3], p[5])) 763 p[0] = self.BuildProduction('Sequence', p, 1, ListFromConcat(p[3], p[5]))
743 764
765 # [79] NOT IMPLEMENTED (BufferRelatedType)
744 766
745 # [78] 767 # [80]
746 def p_ConstType(self, p): 768 def p_ConstType(self, p):
747 """ConstType : PrimitiveType Null 769 """ConstType : PrimitiveType Null
748 | identifier Null""" 770 | identifier Null"""
749 if type(p[1]) == str: 771 if type(p[1]) == str:
750 p[0] = self.BuildNamed('Typeref', p, 1, p[2]) 772 p[0] = self.BuildNamed('Typeref', p, 1, p[2])
751 else: 773 else:
752 p[1].AddChildren(p[2]) 774 p[1].AddChildren(p[2])
753 p[0] = p[1] 775 p[0] = p[1]
754 776
755 777
756 # [79] Added BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP 778 # [81] Added BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP
757 def p_PrimitiveType(self, p): 779 def p_PrimitiveType(self, p):
758 """PrimitiveType : UnsignedIntegerType 780 """PrimitiveType : UnsignedIntegerType
759 | UnrestrictedFloatType 781 | UnrestrictedFloatType
760 | BOOLEAN 782 | BOOLEAN
761 | BYTE 783 | BYTE
762 | OCTET 784 | OCTET
763 | BYTESTRING 785 | BYTESTRING
764 | DOMSTRING 786 | DOMSTRING
765 | OBJECT 787 | OBJECT
766 | DATE 788 | DATE
767 | REGEXP""" 789 | REGEXP"""
768 if type(p[1]) == str: 790 if type(p[1]) == str:
769 p[0] = self.BuildNamed('PrimitiveType', p, 1) 791 p[0] = self.BuildNamed('PrimitiveType', p, 1)
770 else: 792 else:
771 p[0] = p[1] 793 p[0] = p[1]
772 794
773 795
774 # [80] 796 # [82]
775 def p_UnrestrictedFloatType(self, p): 797 def p_UnrestrictedFloatType(self, p):
776 """UnrestrictedFloatType : UNRESTRICTED FloatType 798 """UnrestrictedFloatType : UNRESTRICTED FloatType
777 | FloatType""" 799 | FloatType"""
778 if len(p) == 2: 800 if len(p) == 2:
779 typeref = self.BuildNamed('PrimitiveType', p, 1) 801 typeref = self.BuildNamed('PrimitiveType', p, 1)
780 else: 802 else:
781 typeref = self.BuildNamed('PrimitiveType', p, 2) 803 typeref = self.BuildNamed('PrimitiveType', p, 2)
782 typeref.AddChildren(self.BuildTrue('UNRESTRICTED')) 804 typeref.AddChildren(self.BuildTrue('UNRESTRICTED'))
783 p[0] = typeref 805 p[0] = typeref
784 806
785 807
786 # [81] 808 # [83]
787 def p_FloatType(self, p): 809 def p_FloatType(self, p):
788 """FloatType : FLOAT 810 """FloatType : FLOAT
789 | DOUBLE""" 811 | DOUBLE"""
790 p[0] = p[1] 812 p[0] = p[1]
791 813
792 # [82] 814 # [84]
793 def p_UnsignedIntegerType(self, p): 815 def p_UnsignedIntegerType(self, p):
794 """UnsignedIntegerType : UNSIGNED IntegerType 816 """UnsignedIntegerType : UNSIGNED IntegerType
795 | IntegerType""" 817 | IntegerType"""
796 if len(p) == 2: 818 if len(p) == 2:
797 p[0] = p[1] 819 p[0] = p[1]
798 else: 820 else:
799 p[0] = 'unsigned ' + p[2] 821 p[0] = 'unsigned ' + p[2]
800 822
801 # [83] 823 # [85]
802 def p_IntegerType(self, p): 824 def p_IntegerType(self, p):
803 """IntegerType : SHORT 825 """IntegerType : SHORT
804 | LONG OptionalLong""" 826 | LONG OptionalLong"""
805 if len(p) == 2: 827 if len(p) == 2:
806 p[0] = p[1] 828 p[0] = p[1]
807 else: 829 else:
808 p[0] = p[1] + p[2] 830 p[0] = p[1] + p[2]
809 831
810 # [84] 832 # [86]
811 def p_OptionalLong(self, p): 833 def p_OptionalLong(self, p):
812 """OptionalLong : LONG 834 """OptionalLong : LONG
813 | """ 835 | """
814 if len(p) > 1: 836 if len(p) > 1:
815 p[0] = ' ' + p[1] 837 p[0] = ' ' + p[1]
816 else: 838 else:
817 p[0] = '' 839 p[0] = ''
818 840
841 # [87] Add unqualified Promise
842 def p_PromiseType(self, p):
843 """PromiseType : PROMISE '<' ReturnType '>'
844 | PROMISE"""
845 if len(p) == 2:
846 # Promise without resolution type is not specified in the Web IDL spec.
847 # As it is used in some specs and in the blink implementation,
848 # we allow that here.
849 resolution_type = self.BuildProduction('Type', p, 1,
850 self.BuildProduction('Any', p, 1))
851 p[0] = self.BuildNamed('Promise', p, 1, resolution_type)
852 else:
853 p[0] = self.BuildNamed('Promise', p, 1, p[3])
819 854
820 # [85] Add support for sized array 855 # [88] Add support for sized array
821 def p_TypeSuffix(self, p): 856 def p_TypeSuffix(self, p):
822 """TypeSuffix : '[' integer ']' TypeSuffix 857 """TypeSuffix : '[' integer ']' TypeSuffix
823 | '[' ']' TypeSuffix 858 | '[' ']' TypeSuffix
824 | '?' TypeSuffixStartingWithArray 859 | '?' TypeSuffixStartingWithArray
825 | """ 860 | """
826 if len(p) == 5: 861 if len(p) == 5:
827 p[0] = self.BuildNamed('Array', p, 2, p[4]) 862 p[0] = self.BuildNamed('Array', p, 2, p[4])
828 863
829 if len(p) == 4: 864 if len(p) == 4:
830 p[0] = self.BuildProduction('Array', p, 1, p[3]) 865 p[0] = self.BuildProduction('Array', p, 1, p[3])
831 866
832 if len(p) == 3: 867 if len(p) == 3:
833 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2]) 868 p[0] = ListFromConcat(self.BuildTrue('NULLABLE'), p[2])
834 869
835 870
836 # [86] 871 # [89]
837 def p_TypeSuffixStartingWithArray(self, p): 872 def p_TypeSuffixStartingWithArray(self, p):
838 """TypeSuffixStartingWithArray : '[' ']' TypeSuffix 873 """TypeSuffixStartingWithArray : '[' ']' TypeSuffix
839 | """ 874 | """
840 if len(p) > 1: 875 if len(p) > 1:
841 p[0] = self.BuildProduction('Array', p, 0, p[3]) 876 p[0] = self.BuildProduction('Array', p, 0, p[3])
842 877
843 # [87] 878 # [90]
844 def p_Null(self, p): 879 def p_Null(self, p):
845 """Null : '?' 880 """Null : '?'
846 |""" 881 |"""
847 if len(p) > 1: 882 if len(p) > 1:
848 p[0] = self.BuildTrue('NULLABLE') 883 p[0] = self.BuildTrue('NULLABLE')
849 884
850 # [88] 885 # [91]
851 def p_ReturnType(self, p): 886 def p_ReturnType(self, p):
852 """ReturnType : Type 887 """ReturnType : Type
853 | VOID""" 888 | VOID"""
854 if p[1] == 'void': 889 if p[1] == 'void':
855 p[0] = self.BuildProduction('Type', p, 1) 890 p[0] = self.BuildProduction('Type', p, 1)
856 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1)) 891 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1))
857 else: 892 else:
858 p[0] = p[1] 893 p[0] = p[1]
859 894
860 # [89] 895 # [92]
861 def p_IdentifierList(self, p): 896 def p_IdentifierList(self, p):
862 """IdentifierList : identifier Identifiers""" 897 """IdentifierList : identifier Identifiers"""
863 p[0] = ListFromConcat(p[1], p[2]) 898 p[0] = ListFromConcat(p[1], p[2])
864 899
865 # [90] 900 # [93]
866 def p_Identifiers(self, p): 901 def p_Identifiers(self, p):
867 """Identifiers : ',' identifier Identifiers 902 """Identifiers : ',' identifier Identifiers
868 |""" 903 |"""
869 if len(p) > 1: 904 if len(p) > 1:
870 p[0] = ListFromConcat(p[2], p[3]) 905 p[0] = ListFromConcat(p[2], p[3])
871 906
872 # [91] 907 # [94]
873 def p_ExtendedAttributeNoArgs(self, p): 908 def p_ExtendedAttributeNoArgs(self, p):
874 """ExtendedAttributeNoArgs : identifier""" 909 """ExtendedAttributeNoArgs : identifier"""
875 p[0] = self.BuildNamed('ExtAttribute', p, 1) 910 p[0] = self.BuildNamed('ExtAttribute', p, 1)
876 911
877 # [92] 912 # [95]
878 def p_ExtendedAttributeArgList(self, p): 913 def p_ExtendedAttributeArgList(self, p):
879 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'""" 914 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'"""
880 arguments = self.BuildProduction('Arguments', p, 2, p[3]) 915 arguments = self.BuildProduction('Arguments', p, 2, p[3])
881 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments) 916 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments)
882 917
883 # [93] 918 # [96]
884 def p_ExtendedAttributeIdent(self, p): 919 def p_ExtendedAttributeIdent(self, p):
885 """ExtendedAttributeIdent : identifier '=' identifier""" 920 """ExtendedAttributeIdent : identifier '=' identifier"""
886 value = self.BuildAttribute('VALUE', p[3]) 921 value = self.BuildAttribute('VALUE', p[3])
887 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) 922 p[0] = self.BuildNamed('ExtAttribute', p, 1, value)
888 923
889 # [94] 924 # [97]
890 def p_ExtendedAttributeIdentList(self, p): 925 def p_ExtendedAttributeIdentList(self, p):
891 """ExtendedAttributeIdentList : identifier '=' '(' IdentifierList ')'""" 926 """ExtendedAttributeIdentList : identifier '=' '(' IdentifierList ')'"""
892 value = self.BuildAttribute('VALUE', p[4]) 927 value = self.BuildAttribute('VALUE', p[4])
893 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) 928 p[0] = self.BuildNamed('ExtAttribute', p, 1, value)
894 929
895 # [95] 930 # [98]
896 def p_ExtendedAttributeNamedArgList(self, p): 931 def p_ExtendedAttributeNamedArgList(self, p):
897 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'""" 932 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'"""
898 args = self.BuildProduction('Arguments', p, 4, p[5]) 933 args = self.BuildProduction('Arguments', p, 4, p[5])
899 value = self.BuildNamed('Call', p, 3, args) 934 value = self.BuildNamed('Call', p, 3, args)
900 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) 935 p[0] = self.BuildNamed('ExtAttribute', p, 1, value)
901 936
902 # [96] NOT IMPLEMENTED (ExtendedAttributeTypePair)
903
904 # 937 #
905 # Parser Errors 938 # Parser Errors
906 # 939 #
907 # p_error is called whenever the parser can not find a pattern match for 940 # p_error is called whenever the parser can not find a pattern match for
908 # a set of items from the current state. The p_error function defined here 941 # a set of items from the current state. The p_error function defined here
909 # is triggered logging an error, and parsing recovery happens as the 942 # is triggered logging an error, and parsing recovery happens as the
910 # p_<type>_error functions defined above are called. This allows the parser 943 # p_<type>_error functions defined above are called. This allows the parser
911 # to continue so as to capture more than one error per file. 944 # to continue so as to capture more than one error per file.
912 # 945 #
913 def p_error(self, t): 946 def p_error(self, t):
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1146
1114 print '\n'.join(ast.Tree(accept_props=['PROD'])) 1147 print '\n'.join(ast.Tree(accept_props=['PROD']))
1115 if errors: 1148 if errors:
1116 print '\nFound %d errors.\n' % errors 1149 print '\nFound %d errors.\n' % errors
1117 1150
1118 return errors 1151 return errors
1119 1152
1120 1153
1121 if __name__ == '__main__': 1154 if __name__ == '__main__':
1122 sys.exit(main(sys.argv[1:])) 1155 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698