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

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

Issue 329853005: IDL parser: align with current Web IDL specification (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: rebased Created 6 years, 6 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
« no previous file with comments | « tools/idl_parser/idl_ppapi_lexer.py ('k') | tools/idl_parser/test_lexer/keywords.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #
11 # The parser is uses the PLY yacc library to build a set of parsing rules based 11 # The parser is uses the PLY yacc library to build a set of parsing rules based
12 # on WebIDL. 12 # on WebIDL.
13 # 13 #
14 # WebIDL, and WebIDL grammar can be found at: 14 # WebIDL, and WebIDL grammar can be found at:
15 # http://dev.w3.org/2006/webapi/WebIDL/ 15 # http://heycam.github.io/webidl/
16 # PLY can be found at: 16 # PLY can be found at:
17 # http://www.dabeaz.com/ply/ 17 # http://www.dabeaz.com/ply/
18 # 18 #
19 # The parser generates a tree by recursively matching sets of items against 19 # The parser generates a tree by recursively matching sets of items against
20 # defined patterns. When a match is made, that set of items is reduced 20 # defined patterns. When a match is made, that set of items is reduced
21 # to a new item. The new item can provide a match for parent patterns. 21 # to a new item. The new item can provide a match for parent patterns.
22 # In this way an AST is built (reduced) depth first. 22 # In this way an AST is built (reduced) depth first.
23 # 23 #
24 24
25 # 25 #
(...skipping 17 matching lines...) Expand all
43 # 43 #
44 # [0] Insert a TOP definition for Copyright and Comments 44 # [0] Insert a TOP definition for Copyright and Comments
45 def p_Top(self, p): 45 def p_Top(self, p):
46 """Top : COMMENT COMMENT Definitions""" 46 """Top : COMMENT COMMENT Definitions"""
47 Copyright = self.BuildComment('Copyright', p, 1) 47 Copyright = self.BuildComment('Copyright', p, 1)
48 Filedoc = self.BuildComment('Comment', p, 2) 48 Filedoc = self.BuildComment('Comment', p, 2)
49 p[0] = ListFromConcat(Copyright, Filedoc, p[3]) 49 p[0] = ListFromConcat(Copyright, Filedoc, p[3])
50 50
51 # 51 #
52 #The parser is based on the WebIDL standard. See: 52 #The parser is based on the WebIDL standard. See:
53 # http://www.w3.org/TR/WebIDL/#idl-grammar 53 # http://heycam.github.io/webidl/#idl-grammar
54 # 54 #
55 # [1] 55 # [1]
56 def p_Definitions(self, p): 56 def p_Definitions(self, p):
57 """Definitions : ExtendedAttributeList Definition Definitions 57 """Definitions : ExtendedAttributeList Definition Definitions
58 | """ 58 | """
59 if len(p) > 1: 59 if len(p) > 1:
60 p[2].AddChildren(p[1]) 60 p[2].AddChildren(p[1])
61 p[0] = ListFromConcat(p[2], p[3]) 61 p[0] = ListFromConcat(p[2], p[3])
62 62
63 # [2] Add INLINE definition 63 # [2] Add INLINE definition
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 print '\n'.join(ast.Tree(accept_props=['PROD', 'TYPE', 'VALUE'])) 295 print '\n'.join(ast.Tree(accept_props=['PROD', 'TYPE', 'VALUE']))
296 if errors: 296 if errors:
297 print '\nFound %d errors.\n' % errors 297 print '\nFound %d errors.\n' % errors
298 298
299 299
300 return errors 300 return errors
301 301
302 302
303 if __name__ == '__main__': 303 if __name__ == '__main__':
304 sys.exit(main(sys.argv[1:])) 304 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « tools/idl_parser/idl_ppapi_lexer.py ('k') | tools/idl_parser/test_lexer/keywords.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698