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

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

Issue 262633005: Adding attributes to module and struct in mojom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix annotations Created 6 years, 7 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
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 def p_root(self, p): 72 def p_root(self, p):
73 """root : import root 73 """root : import root
74 | module 74 | module
75 | definitions""" 75 | definitions"""
76 if len(p) > 2: 76 if len(p) > 2:
77 p[0] = _ListFromConcat(p[1], p[2]) 77 p[0] = _ListFromConcat(p[1], p[2])
78 else: 78 else:
79 # Generator expects a module. If one wasn't specified insert one with an 79 # Generator expects a module. If one wasn't specified insert one with an
80 # empty name. 80 # empty name.
81 if p[1][0] != 'MODULE': 81 if p[1][0] != 'MODULE':
82 p[0] = [('MODULE', '', p[1])] 82 p[0] = [('MODULE', '', [], p[1])]
83 else: 83 else:
84 p[0] = [p[1]] 84 p[0] = [p[1]]
85 85
86 def p_import(self, p): 86 def p_import(self, p):
87 """import : IMPORT STRING_LITERAL""" 87 """import : IMPORT STRING_LITERAL"""
88 # 'eval' the literal to strip the quotes. 88 # 'eval' the literal to strip the quotes.
89 p[0] = ('IMPORT', eval(p[2])) 89 p[0] = ('IMPORT', eval(p[2]))
90 90
91 def p_module(self, p): 91 def p_module(self, p):
92 """module : MODULE identifier LBRACE definitions RBRACE""" 92 """module : attribute_section MODULE identifier LBRACE definitions RBRACE"""
93 p[0] = ('MODULE', p[2], p[4]) 93 p[0] = ('MODULE', p[3], p[1], p[5])
94 94
95 def p_definitions(self, p): 95 def p_definitions(self, p):
96 """definitions : definition definitions 96 """definitions : definition definitions
97 | """ 97 | """
98 if len(p) > 1: 98 if len(p) > 1:
99 p[0] = _ListFromConcat(p[1], p[2]) 99 p[0] = _ListFromConcat(p[1], p[2])
100 100
101 def p_definition(self, p): 101 def p_definition(self, p):
102 """definition : struct 102 """definition : struct
103 | interface 103 | interface
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 def Parse(source, filename): 353 def Parse(source, filename):
354 lexer = Lexer(filename) 354 lexer = Lexer(filename)
355 parser = Parser(lexer, source, filename) 355 parser = Parser(lexer, source, filename)
356 356
357 lex.lex(object=lexer) 357 lex.lex(object=lexer)
358 yacc.yacc(module=parser, debug=0, write_tables=0) 358 yacc.yacc(module=parser, debug=0, write_tables=0)
359 359
360 tree = yacc.parse(source) 360 tree = yacc.parse(source)
361 return tree 361 return tree
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/pylib/mojom/generate/data.py ('k') | mojo/public/tools/bindings/pylib/mojom/parse/translate.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698