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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
879 |""" | 879 |""" |
880 | 880 |
881 # [78] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType | 881 # [78] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType |
882 # Moving all built-in types into PrimitiveType makes it easier to | 882 # Moving all built-in types into PrimitiveType makes it easier to |
883 # differentiate between them and 'identifier', since p[1] would be a string in | 883 # differentiate between them and 'identifier', since p[1] would be a string in |
884 # both cases. | 884 # both cases. |
885 def p_NonAnyType(self, p): | 885 def p_NonAnyType(self, p): |
886 """NonAnyType : PrimitiveType TypeSuffix | 886 """NonAnyType : PrimitiveType TypeSuffix |
887 | PromiseType Null | 887 | PromiseType Null |
888 | identifier TypeSuffix | 888 | identifier TypeSuffix |
889 | SEQUENCE '<' Type '>' Null""" | 889 | SEQUENCE '<' Type '>' Null |
| 890 | FROZENARRAY '<' Type '>' Null""" |
890 if len(p) == 3: | 891 if len(p) == 3: |
891 if type(p[1]) == str: | 892 if type(p[1]) == str: |
892 typeref = self.BuildNamed('Typeref', p, 1) | 893 typeref = self.BuildNamed('Typeref', p, 1) |
893 else: | 894 else: |
894 typeref = p[1] | 895 typeref = p[1] |
895 p[0] = ListFromConcat(typeref, p[2]) | 896 p[0] = ListFromConcat(typeref, p[2]) |
896 | 897 |
897 if len(p) == 6: | 898 if len(p) == 6: |
898 p[0] = self.BuildProduction('Sequence', p, 1, ListFromConcat(p[3], p[5])) | 899 cls = 'Sequence' if p[1] == 'sequence' else 'FrozenArray' |
| 900 p[0] = self.BuildProduction(cls, p, 1, ListFromConcat(p[3], p[5])) |
899 | 901 |
900 # [79] NOT IMPLEMENTED (BufferRelatedType) | 902 # [79] NOT IMPLEMENTED (BufferRelatedType) |
901 | 903 |
902 # [80] | 904 # [80] |
903 def p_ConstType(self, p): | 905 def p_ConstType(self, p): |
904 """ConstType : PrimitiveType Null | 906 """ConstType : PrimitiveType Null |
905 | identifier Null""" | 907 | identifier Null""" |
906 if type(p[1]) == str: | 908 if type(p[1]) == str: |
907 p[0] = self.BuildNamed('Typeref', p, 1, p[2]) | 909 p[0] = self.BuildNamed('Typeref', p, 1, p[2]) |
908 else: | 910 else: |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 | 1283 |
1282 print '\n'.join(ast.Tree(accept_props=['PROD'])) | 1284 print '\n'.join(ast.Tree(accept_props=['PROD'])) |
1283 if errors: | 1285 if errors: |
1284 print '\nFound %d errors.\n' % errors | 1286 print '\nFound %d errors.\n' % errors |
1285 | 1287 |
1286 return errors | 1288 return errors |
1287 | 1289 |
1288 | 1290 |
1289 if __name__ == '__main__': | 1291 if __name__ == '__main__': |
1290 sys.exit(main(sys.argv[1:])) | 1292 sys.exit(main(sys.argv[1:])) |
OLD | NEW |