def parse(self, text, goal=None): if goal is None: parser = self.parser_class() else: parser = self.parser_class(goal=goal) lexer = self.tokenize(parser) lexer.write(text) return lexer.close()
def assert_can_close_after(self, s): parser = JSParser() lexer = JSLexer(parser) if isinstance(s, list): for chunk in s: lexer.write(chunk) else: lexer.write(s) self.assertTrue(lexer.can_close())