Commit a4b462d9 authored by eckhart's avatar eckhart
Browse files

parse.py: better str()-serialization for parser `Synonym`

parent 0d476268
......@@ -2901,6 +2901,9 @@ class Synonym(UnaryParser):
return Node(self.tag_name, (node,)), text
return node, text
def __str__(self):
return self.pname + (' = ' if self.pname else '') + self.parser.repr
def __repr__(self):
return self.pname or self.parser.repr
......
......@@ -417,6 +417,7 @@ class TestGrammar:
gr = grammar_provider("@drop = whitespace, token" + lang)()
st = gr('eins 1 zwei2drei 3')
st = gr('-3')
assert str(gr['S']) == "S = ~", str(gr['S'])
class TestSeries:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment