OLD | NEW |
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 RBRACE SEMI""" | 123 RBRACE SEMI""" |
124 p[0] = ('INTERFACE', p[3], p[1], p[5]) | 124 p[0] = ('INTERFACE', p[3], p[1], p[5]) |
125 | 125 |
126 def p_interface_body(self, p): | 126 def p_interface_body(self, p): |
127 """interface_body : method interface_body | 127 """interface_body : method interface_body |
128 | enum interface_body | 128 | enum interface_body |
129 | """ | 129 | """ |
130 if len(p) > 1: | 130 if len(p) > 1: |
131 p[0] = ListFromConcat(p[1], p[2]) | 131 p[0] = ListFromConcat(p[1], p[2]) |
132 | 132 |
| 133 def p_response(self, p): |
| 134 """response : RESPONSE LPAREN parameters RPAREN |
| 135 | """ |
| 136 if len(p) > 3: |
| 137 p[0] = p[3] |
| 138 |
133 def p_method(self, p): | 139 def p_method(self, p): |
134 """method : NAME LPAREN parameters RPAREN ordinal SEMI""" | 140 """method : NAME ordinal LPAREN parameters RPAREN response SEMI""" |
135 p[0] = ('METHOD', p[1], p[3], p[5]) | 141 p[0] = ('METHOD', p[1], p[4], p[2], p[6]) |
136 | 142 |
137 def p_parameters(self, p): | 143 def p_parameters(self, p): |
138 """parameters : parameter | 144 """parameters : parameter |
139 | parameter COMMA parameters | 145 | parameter COMMA parameters |
140 | """ | 146 | """ |
141 if len(p) == 1: | 147 if len(p) == 1: |
142 p[0] = [] | 148 p[0] = [] |
143 elif len(p) == 2: | 149 elif len(p) == 2: |
144 p[0] = ListFromConcat(p[1]) | 150 p[0] = ListFromConcat(p[1]) |
145 elif len(p) > 3: | 151 elif len(p) > 3: |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 def Main(): | 341 def Main(): |
336 if len(sys.argv) < 2: | 342 if len(sys.argv) < 2: |
337 print("usage: %s filename" % (sys.argv[0])) | 343 print("usage: %s filename" % (sys.argv[0])) |
338 sys.exit(1) | 344 sys.exit(1) |
339 tree = Parse(filename=sys.argv[1]) | 345 tree = Parse(filename=sys.argv[1]) |
340 print(tree) | 346 print(tree) |
341 | 347 |
342 | 348 |
343 if __name__ == '__main__': | 349 if __name__ == '__main__': |
344 Main() | 350 Main() |
OLD | NEW |