232 lineno = lineno + src.count('\n', last_lineno_pos, start) |
234 lineno = lineno + src.count('\n', last_lineno_pos, start) |
233 last_lineno_pos = start |
235 last_lineno_pos = start |
234 # close all interfaces/modules indented at least as much |
236 # close all interfaces/modules indented at least as much |
235 while classstack and \ |
237 while classstack and \ |
236 classstack[-1][1] >= thisindent: |
238 classstack[-1][1] >= thisindent: |
|
239 if classstack[-1][0] is not None: |
|
240 # record the end line |
|
241 classstack[-1][0].setEndLine(lineno - 1) |
237 del classstack[-1] |
242 del classstack[-1] |
238 if classstack: |
243 if classstack: |
239 # it's an interface/module method |
244 # it's an interface/module method |
240 cur_class = classstack[-1][0] |
245 cur_class = classstack[-1][0] |
241 if isinstance(cur_class, Interface) or isinstance(cur_class, Module): |
246 if isinstance(cur_class, Interface) or isinstance(cur_class, Module): |
242 # it's a method |
247 # it's a method |
243 f = Function(None, meth_name, |
248 f = Function(None, meth_name, |
244 file, lineno, meth_sig) |
249 file, lineno, meth_sig) |
245 cur_class._addmethod(meth_name, f) |
250 cur_class._addmethod(meth_name, f) |
246 # else it's a nested def |
251 # else it's a nested def |
|
252 else: |
|
253 f = None |
247 else: |
254 else: |
248 # it's a function |
255 # it's a function |
249 f = Function(module, meth_name, |
256 f = Function(module, meth_name, |
250 file, lineno, meth_sig) |
257 file, lineno, meth_sig) |
251 if meth_name in dict_counts: |
258 if meth_name in dict_counts: |
252 dict_counts[meth_name] += 1 |
259 dict_counts[meth_name] += 1 |
253 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
260 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
254 else: |
261 else: |
255 dict_counts[meth_name] = 0 |
262 dict_counts[meth_name] = 0 |
256 dict[meth_name] = f |
263 dict[meth_name] = f |
|
264 if not classstack: |
|
265 if lastGlobalEntry: |
|
266 lastGlobalEntry.setEndLine(lineno - 1) |
|
267 lastGlobalEntry = f |
|
268 if cur_obj and isinstance(cur_obj, Function): |
|
269 cur_obj.setEndLine(lineno - 1) |
|
270 cur_obj = f |
257 classstack.append((f, thisindent)) # Marker for nested fns |
271 classstack.append((f, thisindent)) # Marker for nested fns |
258 |
272 |
259 elif m.start("String") >= 0: |
273 elif m.start("String") >= 0: |
260 pass |
274 pass |
261 |
275 |
267 thisindent = indent |
281 thisindent = indent |
268 indent += 1 |
282 indent += 1 |
269 # close all interfaces/modules indented at least as much |
283 # close all interfaces/modules indented at least as much |
270 while classstack and \ |
284 while classstack and \ |
271 classstack[-1][1] >= thisindent: |
285 classstack[-1][1] >= thisindent: |
|
286 if classstack[-1][0] is not None: |
|
287 # record the end line |
|
288 classstack[-1][0].setEndLine(lineno - 1) |
272 del classstack[-1] |
289 del classstack[-1] |
273 lineno = lineno + src.count('\n', last_lineno_pos, start) |
290 lineno = lineno + src.count('\n', last_lineno_pos, start) |
274 last_lineno_pos = start |
291 last_lineno_pos = start |
275 class_name = m.group("InterfaceName") |
292 class_name = m.group("InterfaceName") |
276 inherit = m.group("InterfaceSupers") |
293 inherit = m.group("InterfaceSupers") |
284 if not classstack: |
301 if not classstack: |
285 dict[class_name] = cur_class |
302 dict[class_name] = cur_class |
286 else: |
303 else: |
287 cls = classstack[-1][0] |
304 cls = classstack[-1][0] |
288 cls._addclass(class_name, cur_class) |
305 cls._addclass(class_name, cur_class) |
|
306 if not classstack: |
|
307 if lastGlobalEntry: |
|
308 lastGlobalEntry.setEndLine(lineno - 1) |
|
309 lastGlobalEntry = cur_class |
|
310 if cur_obj and isinstance(cur_obj, Function): |
|
311 cur_obj.setEndLine(lineno - 1) |
|
312 cur_obj = cur_class |
289 classstack.append((cur_class, thisindent)) |
313 classstack.append((cur_class, thisindent)) |
290 |
314 |
291 elif m.start("Module") >= 0: |
315 elif m.start("Module") >= 0: |
292 # we found a module definition |
316 # we found a module definition |
293 thisindent = indent |
317 thisindent = indent |
294 indent += 1 |
318 indent += 1 |
295 # close all interfaces/modules indented at least as much |
319 # close all interfaces/modules indented at least as much |
296 while classstack and \ |
320 while classstack and \ |
297 classstack[-1][1] >= thisindent: |
321 classstack[-1][1] >= thisindent: |
|
322 if classstack[-1][0] is not None: |
|
323 # record the end line |
|
324 classstack[-1][0].setEndLine(lineno - 1) |
298 del classstack[-1] |
325 del classstack[-1] |
299 lineno = lineno + src.count('\n', last_lineno_pos, start) |
326 lineno = lineno + src.count('\n', last_lineno_pos, start) |
300 last_lineno_pos = start |
327 last_lineno_pos = start |
301 module_name = m.group("ModuleName") |
328 module_name = m.group("ModuleName") |
302 # remember this module |
329 # remember this module |
303 cur_class = Module(module, module_name, file, lineno) |
330 cur_class = Module(module, module_name, file, lineno) |
304 if not classstack: |
331 if not classstack: |
305 dict[module_name] = cur_class |
332 dict[module_name] = cur_class |
|
333 if lastGlobalEntry: |
|
334 lastGlobalEntry.setEndLine(lineno - 1) |
|
335 lastGlobalEntry = cur_class |
|
336 if cur_obj and isinstance(cur_obj, Function): |
|
337 cur_obj.setEndLine(lineno - 1) |
|
338 cur_obj = cur_class |
306 classstack.append((cur_class, thisindent)) |
339 classstack.append((cur_class, thisindent)) |
307 |
340 |
308 elif m.start("Attribute") >= 0: |
341 elif m.start("Attribute") >= 0: |
309 lineno = lineno + src.count('\n', last_lineno_pos, start) |
342 lineno = lineno + src.count('\n', last_lineno_pos, start) |
310 last_lineno_pos = start |
343 last_lineno_pos = start |