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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 | 647 |
648 # [65] | 648 # [65] |
649 def p_ExtendedAttributes(self, p): | 649 def p_ExtendedAttributes(self, p): |
650 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes | 650 """ExtendedAttributes : ',' ExtendedAttribute ExtendedAttributes |
651 |""" | 651 |""" |
652 if len(p) > 1: | 652 if len(p) > 1: |
653 p[0] = ListFromConcat(p[2], p[3]) | 653 p[0] = ListFromConcat(p[2], p[3]) |
654 | 654 |
655 # We only support: | 655 # We only support: |
656 # [ identifier ] | 656 # [ identifier ] |
| 657 # [ identifier ( ArgumentList ) ] |
657 # [ identifier = identifier ] | 658 # [ identifier = identifier ] |
658 # [ identifier ( ArgumentList )] | 659 # [ identifier = ( IdentifierList ) ] |
659 # [ identifier = identifier ( ArgumentList )] | 660 # [ identifier = identifier ( ArgumentList ) ] |
660 # [66] map directly to [91-93, 95] | 661 # [66] map directly to [91-93, 95] |
661 # [67-69, 71] are unsupported | 662 # [67-69, 71] are unsupported |
662 def p_ExtendedAttribute(self, p): | 663 def p_ExtendedAttribute(self, p): |
663 """ExtendedAttribute : ExtendedAttributeNoArgs | 664 """ExtendedAttribute : ExtendedAttributeNoArgs |
664 | ExtendedAttributeArgList | 665 | ExtendedAttributeArgList |
665 | ExtendedAttributeIdent | 666 | ExtendedAttributeIdent |
| 667 | ExtendedAttributeIdentList |
666 | ExtendedAttributeNamedArgList""" | 668 | ExtendedAttributeNamedArgList""" |
667 p[0] = p[1] | 669 p[0] = p[1] |
668 | 670 |
669 # [70] | 671 # [70] |
670 def p_ArgumentNameKeyword(self, p): | 672 def p_ArgumentNameKeyword(self, p): |
671 """ArgumentNameKeyword : ATTRIBUTE | 673 """ArgumentNameKeyword : ATTRIBUTE |
672 | CALLBACK | 674 | CALLBACK |
673 | CONST | 675 | CONST |
674 | CREATOR | 676 | CREATOR |
675 | DELETER | 677 | DELETER |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 # [88] | 850 # [88] |
849 def p_ReturnType(self, p): | 851 def p_ReturnType(self, p): |
850 """ReturnType : Type | 852 """ReturnType : Type |
851 | VOID""" | 853 | VOID""" |
852 if p[1] == 'void': | 854 if p[1] == 'void': |
853 p[0] = self.BuildProduction('Type', p, 1) | 855 p[0] = self.BuildProduction('Type', p, 1) |
854 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1)) | 856 p[0].AddChildren(self.BuildNamed('PrimitiveType', p, 1)) |
855 else: | 857 else: |
856 p[0] = p[1] | 858 p[0] = p[1] |
857 | 859 |
858 # [89-90] NOT IMPLEMENTED (IdentifierList) | 860 # [89] |
| 861 def p_IdentifierList(self, p): |
| 862 """IdentifierList : identifier Identifiers""" |
| 863 p[0] = ListFromConcat(p[1], p[2]) |
| 864 |
| 865 # [90] |
| 866 def p_Identifiers(self, p): |
| 867 """Identifiers : ',' identifier Identifiers |
| 868 |""" |
| 869 if len(p) > 1: |
| 870 p[0] = ListFromConcat(p[2], p[3]) |
859 | 871 |
860 # [91] | 872 # [91] |
861 def p_ExtendedAttributeNoArgs(self, p): | 873 def p_ExtendedAttributeNoArgs(self, p): |
862 """ExtendedAttributeNoArgs : identifier""" | 874 """ExtendedAttributeNoArgs : identifier""" |
863 p[0] = self.BuildNamed('ExtAttribute', p, 1) | 875 p[0] = self.BuildNamed('ExtAttribute', p, 1) |
864 | 876 |
865 # [92] | 877 # [92] |
866 def p_ExtendedAttributeArgList(self, p): | 878 def p_ExtendedAttributeArgList(self, p): |
867 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'""" | 879 """ExtendedAttributeArgList : identifier '(' ArgumentList ')'""" |
868 arguments = self.BuildProduction('Arguments', p, 2, p[3]) | 880 arguments = self.BuildProduction('Arguments', p, 2, p[3]) |
869 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments) | 881 p[0] = self.BuildNamed('ExtAttribute', p, 1, arguments) |
870 | 882 |
871 # [93] | 883 # [93] |
872 def p_ExtendedAttributeIdent(self, p): | 884 def p_ExtendedAttributeIdent(self, p): |
873 """ExtendedAttributeIdent : identifier '=' identifier""" | 885 """ExtendedAttributeIdent : identifier '=' identifier""" |
874 value = self.BuildAttribute('VALUE', p[3]) | 886 value = self.BuildAttribute('VALUE', p[3]) |
875 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 887 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
876 | 888 |
877 # [94] NOT IMPLEMENTED (ExtendedAttributeIdentList) | 889 # [94] |
| 890 def p_ExtendedAttributeIdentList(self, p): |
| 891 """ExtendedAttributeIdentList : identifier '=' '(' IdentifierList ')'""" |
| 892 value = self.BuildAttribute('VALUE', p[4]) |
| 893 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
878 | 894 |
879 # [95] | 895 # [95] |
880 def p_ExtendedAttributeNamedArgList(self, p): | 896 def p_ExtendedAttributeNamedArgList(self, p): |
881 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis
t ')'""" | 897 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis
t ')'""" |
882 args = self.BuildProduction('Arguments', p, 4, p[5]) | 898 args = self.BuildProduction('Arguments', p, 4, p[5]) |
883 value = self.BuildNamed('Call', p, 3, args) | 899 value = self.BuildNamed('Call', p, 3, args) |
884 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) | 900 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) |
885 | 901 |
886 # [96] NOT IMPLEMENTED (ExtendedAttributeTypePair) | 902 # [96] NOT IMPLEMENTED (ExtendedAttributeTypePair) |
887 | 903 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 | 1113 |
1098 print '\n'.join(ast.Tree(accept_props=['PROD'])) | 1114 print '\n'.join(ast.Tree(accept_props=['PROD'])) |
1099 if errors: | 1115 if errors: |
1100 print '\nFound %d errors.\n' % errors | 1116 print '\nFound %d errors.\n' % errors |
1101 | 1117 |
1102 return errors | 1118 return errors |
1103 | 1119 |
1104 | 1120 |
1105 if __name__ == '__main__': | 1121 if __name__ == '__main__': |
1106 sys.exit(main(sys.argv[1:])) | 1122 sys.exit(main(sys.argv[1:])) |
OLD | NEW |