| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 if len(p) > 2: | 427 if len(p) > 2: |
| 428 val = '-Infinity' | 428 val = '-Infinity' |
| 429 else: | 429 else: |
| 430 val = p[1] | 430 val = p[1] |
| 431 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'), | 431 p[0] = ListFromConcat(self.BuildAttribute('TYPE', 'float'), |
| 432 self.BuildAttribute('VALUE', val)) | 432 self.BuildAttribute('VALUE', val)) |
| 433 | 433 |
| 434 # [30] | 434 # [30] |
| 435 def p_AttributeOrOperation(self, p): | 435 def p_AttributeOrOperation(self, p): |
| 436 """AttributeOrOperation : STRINGIFIER StringifierAttributeOrOperation | 436 """AttributeOrOperation : STRINGIFIER StringifierAttributeOrOperation |
| 437 | StaticAttribute |
| 437 | Attribute | 438 | Attribute |
| 438 | Operation""" | 439 | Operation""" |
| 439 if len(p) > 2: | 440 if len(p) > 2: |
| 440 p[0] = p[2] | 441 p[0] = p[2] |
| 441 else: | 442 else: |
| 442 p[0] = p[1] | 443 p[0] = p[1] |
| 443 | 444 |
| 444 # [31] | 445 # [31] |
| 445 def p_StringifierAttributeOrOperation(self, p): | 446 def p_StringifierAttributeOrOperation(self, p): |
| 446 """StringifierAttributeOrOperation : Attribute | 447 """StringifierAttributeOrOperation : Attribute |
| 447 | OperationRest | 448 | OperationRest |
| 448 | ';'""" | 449 | ';'""" |
| 449 if p[1] == ';': | 450 if p[1] == ';': |
| 450 p[0] = self.BuildAttribute('STRINGIFIER', Boolean(True)) | 451 p[0] = self.BuildAttribute('STRINGIFIER', Boolean(True)) |
| 451 else: | 452 else: |
| 452 p[0] = ListFromConcat(self.BuildAttribute('STRINGIFIER', p[1]), p[1]) | 453 p[0] = ListFromConcat(self.BuildAttribute('STRINGIFIER', p[1]), p[1]) |
| 453 | 454 |
| 455 # [31.1] FIXME: temporary production as part of moving |static| into |
| 456 # base parser |
| 457 def p_StaticAttribute(self, p): |
| 458 """StaticAttribute : STATIC Attribute""" |
| 459 p[2].AddChildren(self.BuildTrue('STATIC')) |
| 460 p[0] = p[2] |
| 461 |
| 454 # [32] | 462 # [32] |
| 455 def p_Attribute(self, p): | 463 def p_Attribute(self, p): |
| 456 """Attribute : Inherit ReadOnly ATTRIBUTE Type identifier ';'""" | 464 """Attribute : Inherit ReadOnly ATTRIBUTE Type identifier ';'""" |
| 457 p[0] = self.BuildNamed('Attribute', p, 5, | 465 p[0] = self.BuildNamed('Attribute', p, 5, |
| 458 ListFromConcat(p[1], p[2], p[4])) | 466 ListFromConcat(p[1], p[2], p[4])) |
| 459 | 467 |
| 460 # [33] | 468 # [33] |
| 461 def p_Inherit(self, p): | 469 def p_Inherit(self, p): |
| 462 """Inherit : INHERIT | 470 """Inherit : INHERIT |
| 463 |""" | 471 |""" |
| (...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1044 | 1052 |
| 1045 print '\n'.join(ast.Tree(accept_props=['PROD'])) | 1053 print '\n'.join(ast.Tree(accept_props=['PROD'])) |
| 1046 if errors: | 1054 if errors: |
| 1047 print '\nFound %d errors.\n' % errors | 1055 print '\nFound %d errors.\n' % errors |
| 1048 | 1056 |
| 1049 return errors | 1057 return errors |
| 1050 | 1058 |
| 1051 | 1059 |
| 1052 if __name__ == '__main__': | 1060 if __name__ == '__main__': |
| 1053 sys.exit(main(sys.argv[1:])) | 1061 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |