def finalize(all_tokens, seen_ts, snippet_instance): """Adds a tabstop 0 if non is in 'seen_ts' and brings the text of the snippet instance into Vim.""" if 0 not in seen_ts: mark = all_tokens[-1][1].end # Last token is always EndOfText m1 = Position(mark.line, mark.col) TabStop(snippet_instance, 0, mark, m1)
def _resolve_ambiguity(all_tokens, seen_ts): """$1 could be a Mirror or a TabStop. This figures this out.""" for parent, token in all_tokens: if isinstance(token, MirrorToken): if token.number not in seen_ts: seen_ts[token.number] = TabStop(parent, token) else: Mirror(parent, seen_ts[token.number], token)
def _do_parse(parent, text, allowed_tokens): """Recursive function that actually creates the objects.""" tokens = list(tokenize(text, indent, parent.start, allowed_tokens)) for token in tokens: all_tokens.append((parent, token)) if isinstance(token, TabStopToken): ts = TabStop(parent, token) seen_ts[token.number] = ts _do_parse(ts, token.initial_text, allowed_tokens_in_tabstops) else: klass = token_to_textobject.get(token.__class__, None) if klass is not None: klass(parent, token)