OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 # | 261 # |
262 # Modifier List | 262 # Modifier List |
263 # | 263 # |
264 # | 264 # |
265 def p_modifiers(self, p): | 265 def p_modifiers(self, p): |
266 """modifiers : comments ext_attr_block""" | 266 """modifiers : comments ext_attr_block""" |
267 p[0] = ListFromConcat(p[1], p[2]) | 267 p[0] = ListFromConcat(p[1], p[2]) |
268 if self.parse_debug: DumpReduction('modifiers', p) | 268 if self.parse_debug: DumpReduction('modifiers', p) |
269 | 269 |
270 # | 270 # |
271 # Type reference (with an optional namespace). | |
272 # | |
273 # | |
274 def p_typeref(self, p): | |
275 """typeref : SYMBOL | |
noelallen_use_chromium
2014/03/13 16:31:05
This does not appear to be recursive. It only sup
mtomasz
2014/03/14 00:36:44
Done.
Nils Barth (inactive)
2014/03/14 00:41:45
Good point! (>.<)
Actually, this grammar rule is
Nils Barth (inactive)
2014/03/14 00:52:11
Discussed offline; syntactically they're the same,
| |
276 | SYMBOL '.' SYMBOL""" | |
277 p[0] = "".join(p[1:]) | |
Nils Barth (inactive)
2014/03/13 07:24:54
Style: '' (single quotes in Python).
mtomasz
2014/03/14 00:36:44
Done.
| |
278 if self.parse_debug: DumpReduction('typeref', p) | |
279 | |
280 # | |
271 # Comments | 281 # Comments |
272 # | 282 # |
273 # Comments are optional list of C style comment objects. Comments are returned | 283 # Comments are optional list of C style comment objects. Comments are returned |
274 # as a list or None. | 284 # as a list or None. |
275 # | 285 # |
276 def p_comments(self, p): | 286 def p_comments(self, p): |
277 """comments : COMMENT comments | 287 """comments : COMMENT comments |
278 | """ | 288 | """ |
279 if len(p) > 1: | 289 if len(p) > 1: |
280 child = self.BuildComment('Comment', p, 1) | 290 child = self.BuildComment('Comment', p, 1) |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
593 """param_list : '(' param_item param_cont ')' | 603 """param_list : '(' param_item param_cont ')' |
594 | '(' ')' """ | 604 | '(' ')' """ |
595 if len(p) > 3: | 605 if len(p) > 3: |
596 args = ListFromConcat(p[2], p[3]) | 606 args = ListFromConcat(p[2], p[3]) |
597 else: | 607 else: |
598 args = [] | 608 args = [] |
599 p[0] = self.BuildProduction('Callspec', p, 1, args) | 609 p[0] = self.BuildProduction('Callspec', p, 1, args) |
600 if self.parse_debug: DumpReduction('param_list', p) | 610 if self.parse_debug: DumpReduction('param_list', p) |
601 | 611 |
602 def p_param_item(self, p): | 612 def p_param_item(self, p): |
603 """param_item : modifiers optional SYMBOL arrays identifier""" | 613 """param_item : modifiers optional typeref arrays identifier""" |
604 typeref = self.BuildAttribute('TYPEREF', p[3]) | 614 typeref = self.BuildAttribute('TYPEREF', p[3]) |
605 children = ListFromConcat(p[1], p[2], typeref, p[4]) | 615 children = ListFromConcat(p[1], p[2], typeref, p[4]) |
606 p[0] = self.BuildNamed('Param', p, 5, children) | 616 p[0] = self.BuildNamed('Param', p, 5, children) |
607 if self.parse_debug: DumpReduction('param_item', p) | 617 if self.parse_debug: DumpReduction('param_item', p) |
608 | 618 |
609 def p_optional(self, p): | 619 def p_optional(self, p): |
610 """optional : OPTIONAL | 620 """optional : OPTIONAL |
611 | """ | 621 | """ |
612 if len(p) == 2: | 622 if len(p) == 2: |
613 p[0] = self.BuildAttribute('OPTIONAL', True) | 623 p[0] = self.BuildAttribute('OPTIONAL', True) |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
725 p[0] = p[2] | 735 p[0] = p[2] |
726 if self.parse_debug: DumpReduction('label_error', p) | 736 if self.parse_debug: DumpReduction('label_error', p) |
727 | 737 |
728 | 738 |
729 # | 739 # |
730 # Members | 740 # Members |
731 # | 741 # |
732 # A member attribute or function of a struct or interface. | 742 # A member attribute or function of a struct or interface. |
733 # | 743 # |
734 def p_member_attribute(self, p): | 744 def p_member_attribute(self, p): |
735 """member_attribute : modifiers SYMBOL arrays questionmark identifier""" | 745 """member_attribute : modifiers typeref arrays questionmark identifier""" |
736 typeref = self.BuildAttribute('TYPEREF', p[2]) | 746 typeref = self.BuildAttribute('TYPEREF', p[2]) |
737 children = ListFromConcat(p[1], typeref, p[3], p[4]) | 747 children = ListFromConcat(p[1], typeref, p[3], p[4]) |
738 p[0] = self.BuildNamed('Member', p, 5, children) | 748 p[0] = self.BuildNamed('Member', p, 5, children) |
739 if self.parse_debug: DumpReduction('attribute', p) | 749 if self.parse_debug: DumpReduction('attribute', p) |
740 | 750 |
741 def p_member_function(self, p): | 751 def p_member_function(self, p): |
742 """member_function : modifiers static SYMBOL arrays SYMBOL param_list""" | 752 """member_function : modifiers static typeref arrays SYMBOL param_list""" |
743 typeref = self.BuildAttribute('TYPEREF', p[3]) | 753 typeref = self.BuildAttribute('TYPEREF', p[3]) |
744 children = ListFromConcat(p[1], p[2], typeref, p[4], p[6]) | 754 children = ListFromConcat(p[1], p[2], typeref, p[4], p[6]) |
745 p[0] = self.BuildNamed('Member', p, 5, children) | 755 p[0] = self.BuildNamed('Member', p, 5, children) |
746 if self.parse_debug: DumpReduction('function', p) | 756 if self.parse_debug: DumpReduction('function', p) |
747 | 757 |
748 def p_static(self, p): | 758 def p_static(self, p): |
749 """static : STATIC | 759 """static : STATIC |
750 | """ | 760 | """ |
751 if len(p) == 2: | 761 if len(p) == 2: |
752 p[0] = self.BuildAttribute('STATIC', True) | 762 p[0] = self.BuildAttribute('STATIC', True) |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1227 errs = ast.GetProperty('ERRORS') | 1237 errs = ast.GetProperty('ERRORS') |
1228 if errs: | 1238 if errs: |
1229 ErrOut.Log('Found %d error(s).' % errs); | 1239 ErrOut.Log('Found %d error(s).' % errs); |
1230 InfoOut.Log("%d files processed." % len(filenames)) | 1240 InfoOut.Log("%d files processed." % len(filenames)) |
1231 return errs | 1241 return errs |
1232 | 1242 |
1233 | 1243 |
1234 if __name__ == '__main__': | 1244 if __name__ == '__main__': |
1235 sys.exit(Main(sys.argv[1:])) | 1245 sys.exit(Main(sys.argv[1:])) |
1236 | 1246 |
OLD | NEW |