diff --git a/tatsu/ngcodegen/python.py b/tatsu/ngcodegen/python.py index ca03350f..c4305483 100644 --- a/tatsu/ngcodegen/python.py +++ b/tatsu/ngcodegen/python.py @@ -127,11 +127,11 @@ def param_repr(p): self.print() self.print( f""" - @tatsumasu({params})\ - {leftrec}\ - {nomemo}\ - {isname} - def _{rule.name}_(self): + @tatsumasu({params})\ + {leftrec}\ + {nomemo}\ + {isname}\ + \ndef _{rule.name}_(self): """, ) with self.indent(): diff --git a/test/grammar/keyword_test.py b/test/grammar/keyword_test.py index 43452d07..2b6ed8bc 100644 --- a/test/grammar/keyword_test.py +++ b/test/grammar/keyword_test.py @@ -72,6 +72,7 @@ def test_check_keywords(self): """ model = compile(grammar, 'test') c = codegen(model) + print(c) parse(c) ast = model.parse('hello world') diff --git a/test/grammar/pattern_test.py b/test/grammar/pattern_test.py index 009ba9f5..9b1de687 100644 --- a/test/grammar/pattern_test.py +++ b/test/grammar/pattern_test.py @@ -112,7 +112,7 @@ def test_multiline_pattern(self): model = compile(grammar=trim(grammar)) print(codegen(model.rules[0].exp.sequence[0])) self.assertEqual( - codegen(model.rules[0].exp.sequence[0]), + codegen(model.rules[0].exp.sequence[0]).strip(), repr("self._pattern('(?x)\nfoo\nbar\n')").strip('"\''), )