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

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

Issue 364003002: Mojo: Mojom: Disallow trailing commas in parameter 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_tests/parse/parser_unittest.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 """Generates a syntax tree from a Mojo IDL file.""" 5 """Generates a syntax tree from a Mojo IDL file."""
6 6
7 import imp 7 import imp
8 import os.path 8 import os.path
9 import sys 9 import sys
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 def p_response(self, p): 170 def p_response(self, p):
171 """response : RESPONSE LPAREN parameter_list RPAREN 171 """response : RESPONSE LPAREN parameter_list RPAREN
172 | """ 172 | """
173 if len(p) > 3: 173 if len(p) > 3:
174 p[0] = p[3] 174 p[0] = p[3]
175 175
176 def p_method(self, p): 176 def p_method(self, p):
177 """method : NAME ordinal LPAREN parameter_list RPAREN response SEMI""" 177 """method : NAME ordinal LPAREN parameter_list RPAREN response SEMI"""
178 p[0] = ('METHOD', p[1], p[4], p[2], p[6]) 178 p[0] = ('METHOD', p[1], p[4], p[2], p[6])
179 179
180 def p_parameter_list(self, p): 180 def p_parameter_list_1(self, p):
jamesr 2014/07/02 22:03:01 do _1 / _2 have any particular meaning? i'd expect
181 """parameter_list : parameter 181 """parameter_list : """
182 | parameter COMMA parameter_list 182 p[0] = []
183 | """ 183
184 if len(p) == 1: 184 def p_parameter_list_2(self, p):
185 p[0] = [] 185 """parameter_list : nonempty_parameter_list"""
186 elif len(p) == 2: 186 p[0] = p[1]
187 p[0] = [p[1]] 187
188 else: 188 def p_nonempty_parameter_list_1(self, p):
189 p[0] = [p[1]] + p[3] 189 """nonempty_parameter_list : parameter"""
190 p[0] = [p[1]]
191
192 def p_nonempty_parameter_list_2(self, p):
193 """nonempty_parameter_list : nonempty_parameter_list COMMA parameter"""
194 p[0] = p[1]
195 p[0].append(p[3])
190 196
191 def p_parameter(self, p): 197 def p_parameter(self, p):
192 """parameter : typename NAME ordinal""" 198 """parameter : typename NAME ordinal"""
193 p[0] = ast.Parameter(p[1], p[2], p[3], 199 p[0] = ast.Parameter(p[1], p[2], p[3],
194 filename=self.filename, lineno=p.lineno(1)) 200 filename=self.filename, lineno=p.lineno(1))
195 201
196 def p_typename(self, p): 202 def p_typename(self, p):
197 """typename : basictypename 203 """typename : basictypename
198 | array 204 | array
199 | fixed_array 205 | fixed_array
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 332
327 def Parse(source, filename): 333 def Parse(source, filename):
328 lexer = Lexer(filename) 334 lexer = Lexer(filename)
329 parser = Parser(lexer, source, filename) 335 parser = Parser(lexer, source, filename)
330 336
331 lex.lex(object=lexer) 337 lex.lex(object=lexer)
332 yacc.yacc(module=parser, debug=0, write_tables=0) 338 yacc.yacc(module=parser, debug=0, write_tables=0)
333 339
334 tree = yacc.parse(source) 340 tree = yacc.parse(source)
335 return tree 341 return tree
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/pylib/mojom_tests/parse/parser_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698