def _rewrite(self, text, source, symbol_table=None): character_table = symbol_table or self._character_table factory = Factory(character_table) macros = MacroFactory(self) parser = Parser(factory.as_tokens(text, source), factory, Context(definitions=macros.all())) return parser.process()
def _do_test_with(self, input, output): parser = Parser(self._factory.as_tokens(input, "Unknown"), self._factory, self._engine, self._environment) tokens = parser.rewrite() self._verify_output_is(output, tokens)
def _evaluate(self, expression): parser = Parser(self._factory.as_tokens(expression, "Unknown"), self._factory, self._environment) return "".join(map(str, parser.evaluate()))
def _classify(self, expression): parser = Parser(self._factory.as_tokens(expression, "Unknown"), self._factory, self._environment) parser.evaluate() return parser.shall_expand()
def _do_test_with(self, collected, expected): parser = Parser(self._factory.as_tokens(collected, "Unknown"), self._factory, self._environment) tokens = parser.process() self._verify_output_is(expected, tokens)
def _rewrite(self, text, source, symbol_table=SymbolTable.default()): factory = Factory(symbol_table) parser = Parser(factory.as_tokens(text, source), factory, self, Context()) return parser.rewrite()
def _do_test_with(self, input, output): parser = Parser(self._factory.as_tokens(input, "Unknown"), self._factory, self._environment) tokens = parser.rewrite() self._verify_output_is(output, tokens)
def _rewrite(self, text, source, symbol_table=SymbolTable.default()): factory = Factory(symbol_table) macros = MacroFactory(self) parser = Parser(factory.as_tokens(text, source), factory, Context(definitions=macros.all())) return parser.rewrite()