Skip to content

Commit

Permalink
[ngcodegen][python] debut with what unit tests say
Browse files Browse the repository at this point in the history
  • Loading branch information
apalala committed Nov 30, 2023
1 parent e6aebf1 commit b8f4bdd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions tatsu/ngcodegen/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
1 change: 1 addition & 0 deletions test/grammar/keyword_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion test/grammar/pattern_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('"\''),
)

Expand Down

0 comments on commit b8f4bdd

Please sign in to comment.