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

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 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 def p_UnionMemberTypes(self, p): 722 def p_UnionMemberTypes(self, p):
723 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes 723 """UnionMemberTypes : OR UnionMemberType UnionMemberTypes
724 |""" 724 |"""
725 725
726 # [77] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType 726 # [77] Moved BYTESTRING, DOMSTRING, OBJECT, DATE, REGEXP to PrimitiveType
727 # Moving all built-in types into PrimitiveType makes it easier to 727 # 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 728 # differentiate between them and 'identifier', since p[1] would be a string in
729 # both cases. 729 # both cases.
730 def p_NonAnyType(self, p): 730 def p_NonAnyType(self, p):
731 """NonAnyType : PrimitiveType TypeSuffix 731 """NonAnyType : PrimitiveType TypeSuffix
732 | PromiseType Null
732 | identifier TypeSuffix 733 | identifier TypeSuffix
733 | SEQUENCE '<' Type '>' Null""" 734 | SEQUENCE '<' Type '>' Null"""
734 if len(p) == 3: 735 if len(p) == 3:
735 if type(p[1]) == str: 736 if type(p[1]) == str:
736 typeref = self.BuildNamed('Typeref', p, 1) 737 typeref = self.BuildNamed('Typeref', p, 1)
737 else: 738 else:
738 typeref = p[1] 739 typeref = p[1]
739 p[0] = ListFromConcat(typeref, p[2]) 740 p[0] = ListFromConcat(typeref, p[2])
740 741
741 if len(p) == 6: 742 if len(p) == 6:
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 895
895 # [95] 896 # [95]
896 def p_ExtendedAttributeNamedArgList(self, p): 897 def p_ExtendedAttributeNamedArgList(self, p):
897 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'""" 898 """ExtendedAttributeNamedArgList : identifier '=' identifier '(' ArgumentLis t ')'"""
898 args = self.BuildProduction('Arguments', p, 4, p[5]) 899 args = self.BuildProduction('Arguments', p, 4, p[5])
899 value = self.BuildNamed('Call', p, 3, args) 900 value = self.BuildNamed('Call', p, 3, args)
900 p[0] = self.BuildNamed('ExtAttribute', p, 1, value) 901 p[0] = self.BuildNamed('ExtAttribute', p, 1, value)
901 902
902 # [96] NOT IMPLEMENTED (ExtendedAttributeTypePair) 903 # [96] NOT IMPLEMENTED (ExtendedAttributeTypePair)
903 904
905 # [97]
Jens Widell 2014/10/15 07:22:17 Supposed to be [87]. Looks like a lot of these pro
noelallen1 2014/10/15 18:12:32 Agreed to both. If you change to a different vers
yhirano 2014/10/16 05:25:47 Done. I removed numbers from idl_ppapi_parser.py,
906 def p_PromiseType(self, p):
907 """PromiseType : PROMISE '<' ReturnType '>'
908 | PROMISE"""
909 if len(p) == 2:
910 # Promise without resolution type is not specified in the Web IDL spec.
911 # As it is used in some specs and in the blink implementation,
912 # we allow that here.
913 type = self.BuildAttribute('ResolutionType',
914 self.BuildProduction('Any', p, 1))
915 else:
916 type = self.BuildAttribute('ResolutionType', p[3])
917 p[0] = self.BuildNamed('Promise', p, 1, type)
918
904 # 919 #
905 # Parser Errors 920 # Parser Errors
906 # 921 #
907 # p_error is called whenever the parser can not find a pattern match for 922 # 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 923 # 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 924 # is triggered logging an error, and parsing recovery happens as the
910 # p_<type>_error functions defined above are called. This allows the parser 925 # 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. 926 # to continue so as to capture more than one error per file.
912 # 927 #
913 def p_error(self, t): 928 def p_error(self, t):
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 1128
1114 print '\n'.join(ast.Tree(accept_props=['PROD'])) 1129 print '\n'.join(ast.Tree(accept_props=['PROD']))
1115 if errors: 1130 if errors:
1116 print '\nFound %d errors.\n' % errors 1131 print '\nFound %d errors.\n' % errors
1117 1132
1118 return errors 1133 return errors
1119 1134
1120 1135
1121 if __name__ == '__main__': 1136 if __name__ == '__main__':
1122 sys.exit(main(sys.argv[1:])) 1137 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698