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

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

Issue 378383002: Mojo: Mojom: Add an AST node type for the module "statement". (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 Module(NodeBase):
87 """Represents a module statement."""
88
89 def __init__(self, name, attribute_list, **kwargs):
90 # |name| is either none or a "wrapped identifier".
91 assert name is None or isinstance(name, tuple)
92 assert attribute_list is None or isinstance(attribute_list, AttributeList)
93 NodeBase.__init__(self, **kwargs)
94 self.name = name
95 self.attribute_list = attribute_list
96
97 def __eq__(self, other):
98 return self.name == other.name and \
99 self.attribute_list == other.attribute_list
100
101
86 class Ordinal(NodeBase): 102 class Ordinal(NodeBase):
87 """Represents an ordinal value labeling, e.g., a struct field.""" 103 """Represents an ordinal value labeling, e.g., a struct field."""
88 104
89 def __init__(self, value, **kwargs): 105 def __init__(self, value, **kwargs):
90 assert value is None or isinstance(value, int) 106 assert value is None or isinstance(value, int)
91 NodeBase.__init__(self, **kwargs) 107 NodeBase.__init__(self, **kwargs)
92 self.value = value 108 self.value = value
93 109
94 def __eq__(self, other): 110 def __eq__(self, other):
95 return self.value == other.value 111 return self.value == other.value
(...skipping 12 matching lines...) Expand all
108 def __eq__(self, other): 124 def __eq__(self, other):
109 return self.typename == other.typename and \ 125 return self.typename == other.typename and \
110 self.name == other.name and \ 126 self.name == other.name and \
111 self.ordinal == other.ordinal 127 self.ordinal == other.ordinal
112 128
113 129
114 class ParameterList(NodeListBase): 130 class ParameterList(NodeListBase):
115 """Represents a list of (method request or response) parameters.""" 131 """Represents a list of (method request or response) parameters."""
116 132
117 _list_item_type = Parameter 133 _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