From f39f0a1f797d8e919948a06df9f835c9cf4c20fa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo@lysator.liu.se>
Date: Tue, 19 Sep 2023 07:24:14 +0200
Subject: [PATCH] Improve documentation and output for `name` and `tag` in
 parser combinator.

---
 muppet/parser_combinator.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/muppet/parser_combinator.py b/muppet/parser_combinator.py
index cc549f5..f0e75f9 100644
--- a/muppet/parser_combinator.py
+++ b/muppet/parser_combinator.py
@@ -383,7 +383,7 @@ class name(ParseDirective):
         return parser.get(self.form)
 
     def __repr__(self) -> str:
-        return f'{self.name}'
+        return f'[{self.name}]'
 
 
 def optional(parser: ParseDirective) -> ParseDirective:
@@ -670,6 +670,9 @@ class tag(ParseDirective):
         result = parser.get(self.parser)
         return [MatchCompound(type=self.tag, matched=result)]
 
+    def __repr__(self) -> str:
+        return f'{self.tag}({self.parser!r})'
+
 
 def delimited(delim: Items, parser: Items) -> ParseDirective:
     """
-- 
GitLab