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

Side by Side Diff: mojo/public/bindings/parser/mojo_parser.py

Issue 60203003: Add support for empty parameter lists. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 | no next file » | 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 2013 The Chromium Authors. All rights reserved. 2 # Copyright 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 """Generates a syntax tree from a Mojo IDL file.""" 6 """Generates a syntax tree from a Mojo IDL file."""
7 7
8 8
9 import sys 9 import sys
10 import os.path 10 import os.path
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 p[0] = ListFromConcat(p[1], p[2]) 178 p[0] = ListFromConcat(p[1], p[2])
179 179
180 def p_method(self, p): 180 def p_method(self, p):
181 """method : VOID NAME LPAREN parameters RPAREN ordinal SEMICOLON""" 181 """method : VOID NAME LPAREN parameters RPAREN ordinal SEMICOLON"""
182 p[0] = ('METHOD', p[2], p[4], p[6]) 182 p[0] = ('METHOD', p[2], p[4], p[6])
183 183
184 def p_parameters(self, p): 184 def p_parameters(self, p):
185 """parameters : parameter 185 """parameters : parameter
186 | parameter COMMA parameters 186 | parameter COMMA parameters
187 | """ 187 | """
188 if len(p) == 2: 188 if len(p) == 1:
189 p[0] = p[1] 189 p[0] = []
190 elif len(p) == 2:
191 p[0] = ListFromConcat(p[1])
190 elif len(p) > 3: 192 elif len(p) > 3:
191 p[0] = ListFromConcat(p[1], p[3]) 193 p[0] = ListFromConcat(p[1], p[3])
192 194
193 def p_parameter(self, p): 195 def p_parameter(self, p):
194 """parameter : typename NAME ordinal""" 196 """parameter : typename NAME ordinal"""
195 p[0] = ('PARAM', p[1], p[2], p[3]) 197 p[0] = ('PARAM', p[1], p[2], p[3])
196 198
197 def p_typename(self, p): 199 def p_typename(self, p):
198 """typename : NAME 200 """typename : NAME
199 | ARRAY""" 201 | ARRAY"""
(...skipping 23 matching lines...) Expand all
223 def Main(): 225 def Main():
224 if len(sys.argv) < 2: 226 if len(sys.argv) < 2:
225 print("usage: %s filename" % (sys.argv[0])) 227 print("usage: %s filename" % (sys.argv[0]))
226 sys.exit(1) 228 sys.exit(1)
227 tree = Parse(filename=sys.argv[1]) 229 tree = Parse(filename=sys.argv[1])
228 print(tree) 230 print(tree)
229 231
230 232
231 if __name__ == '__main__': 233 if __name__ == '__main__':
232 Main() 234 Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698