def handle_endcall(self, span, name):
'''Should be called to signalize an endcall directive.
Args:
span (tuple of int): Start and end line of the directive.
name (str): Name of the endcall statement. Could be None, if endcall
was specified without name.
'''
self._check_for_open_block(span, 'endcall')
block = self._open_blocks.pop(-1)
directive, fname, spans = block[0:3]
self._check_if_matches_last(directive, 'call', spans[0], span,
'endcall')
callname, callargexpr, args, argnames = block[3:7]
if name is not None and name != callname:
msg = "wrong name in endcall directive "\
"(expected '{0}', got '{1}')".format(callname, name)
raise FyppFatalError(msg, fname, span)
args.append(self._curnode)
# If nextarg or endcall immediately followed call, then first argument
# is empty and should be removed (to allow for calls without arguments
# and named first argument in calls)
if args and not args[0]:
if len(argnames) == len(args):
del argnames[0]
del args[0]
del spans[1]
spans.append(span)
block = (directive, fname, spans, callname, callargexpr, args, argnames)
self._curnode = self._path.pop(-1)
self._curnode.append(block)
评论列表
文章目录