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

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/parse/ast.py

Issue 382553004: Mojo: Mojom: Add AST types for imports and import lists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/parse/parser.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Node objects for the AST for a Mojo IDL file.""" 5 """Node objects for the AST for a Mojo IDL file."""
6 6
7 # Note: For convenience of testing, you probably want to define __eq__() methods 7 # Note: For convenience of testing, you probably want to define __eq__() methods
8 # for all node types; it's okay to be slightly lax (e.g., not compare filename 8 # for all node types; it's okay to be slightly lax (e.g., not compare filename
9 # and lineno). 9 # and lineno).
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 def __eq__(self, other): 76 def __eq__(self, other):
77 return self.key == other.key and self.value == other.value 77 return self.key == other.key and self.value == other.value
78 78
79 79
80 class AttributeList(NodeListBase): 80 class AttributeList(NodeListBase):
81 """Represents a list attributes.""" 81 """Represents a list attributes."""
82 82
83 _list_item_type = Attribute 83 _list_item_type = Attribute
84 84
85 85
86 class Import(NodeBase):
87 """Represents an import statement."""
88
89 def __init__(self, import_filename, **kwargs):
90 assert isinstance(import_filename, str)
91 NodeBase.__init__(self, **kwargs)
92 self.import_filename = import_filename
93
94 def __eq__(self, other):
95 return self.import_filename == other.import_filename
96
97
98 class ImportList(NodeListBase):
99 """Represents a list (i.e., sequence) of import statements."""
100
101 _list_item_type = Import
102
103
86 class Module(NodeBase): 104 class Module(NodeBase):
87 """Represents a module statement.""" 105 """Represents a module statement."""
88 106
89 def __init__(self, name, attribute_list, **kwargs): 107 def __init__(self, name, attribute_list, **kwargs):
90 # |name| is either none or a "wrapped identifier". 108 # |name| is either none or a "wrapped identifier".
91 assert name is None or isinstance(name, tuple) 109 assert name is None or isinstance(name, tuple)
92 assert attribute_list is None or isinstance(attribute_list, AttributeList) 110 assert attribute_list is None or isinstance(attribute_list, AttributeList)
93 NodeBase.__init__(self, **kwargs) 111 NodeBase.__init__(self, **kwargs)
94 self.name = name 112 self.name = name
95 self.attribute_list = attribute_list 113 self.attribute_list = attribute_list
(...skipping 28 matching lines...) Expand all
124 def __eq__(self, other): 142 def __eq__(self, other):
125 return self.typename == other.typename and \ 143 return self.typename == other.typename and \
126 self.name == other.name and \ 144 self.name == other.name and \
127 self.ordinal == other.ordinal 145 self.ordinal == other.ordinal
128 146
129 147
130 class ParameterList(NodeListBase): 148 class ParameterList(NodeListBase):
131 """Represents a list of (method request or response) parameters.""" 149 """Represents a list of (method request or response) parameters."""
132 150
133 _list_item_type = Parameter 151 _list_item_type = Parameter
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom/parse/parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698