intermediate commit
This commit is contained in:
@@ -100,5 +100,20 @@ class ParserInput:
|
||||
|
||||
return res
|
||||
|
||||
@staticmethod
|
||||
def from_tokens(tokens, text=None):
|
||||
"""
|
||||
returns a parser input, given already computed tokens
|
||||
:param tokens:
|
||||
:param text:
|
||||
:return:
|
||||
"""
|
||||
res = ParserInput(None)
|
||||
res.all_tokens = tokens
|
||||
res.original_text = text or get_text_from_tokens(tokens)
|
||||
res.pos = -1
|
||||
res.end = len(res.all_tokens)
|
||||
return res
|
||||
|
||||
def __repr__(self):
|
||||
return f"ParserInput('{self.original_text}', len={len(self.all_tokens)})"
|
||||
|
||||
Reference in New Issue
Block a user