Skip to content

Commit

Permalink
Fix issue #361
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmcg committed Mar 29, 2022
1 parent 27519e1 commit ac30c72
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyparsing/__init__.py
Expand Up @@ -129,7 +129,7 @@ def __repr__(self):


__version_info__ = version_info(3, 0, 8, "final", 0)
__version_time__ = "25 Mar 2022 21:00 UTC"
__version_time__ = "29 Mar 2022 16:15 UTC"
__version__ = __version_info__.__version__
__versionTime__ = __version_time__
__author__ = "Paul McGuire <ptmcg.gm+pyparsing@gmail.com>"
Expand Down
8 changes: 6 additions & 2 deletions pyparsing/diagram/__init__.py
Expand Up @@ -54,7 +54,7 @@ class AnnotatedItem(railroad.Group):
"""

def __init__(self, label: str, item):
super().__init__(item=item, label="[{}]".format(label))
super().__init__(item=item, label="[{}]".format(label) if label else label)


class EditablePartial(Generic[T]):
Expand Down Expand Up @@ -437,7 +437,7 @@ def _to_diagram_element(
if isinstance(
element,
(
pyparsing.TokenConverter,
# pyparsing.TokenConverter,
# pyparsing.Forward,
pyparsing.Located,
),
Expand Down Expand Up @@ -510,6 +510,10 @@ def _to_diagram_element(
ret = EditablePartial.from_call(AnnotatedItem, label="LOOKAHEAD", item="")
elif isinstance(element, pyparsing.PrecededBy):
ret = EditablePartial.from_call(AnnotatedItem, label="LOOKBEHIND", item="")
elif isinstance(element, pyparsing.Group):
ret = EditablePartial.from_call(AnnotatedItem, label="", item="")
elif isinstance(element, pyparsing.TokenConverter):
ret = EditablePartial.from_call(AnnotatedItem, label=type(element).__name__.lower(), item="")
elif isinstance(element, pyparsing.Opt):
ret = EditablePartial.from_call(railroad.Optional, item="")
elif isinstance(element, pyparsing.OneOrMore):
Expand Down

0 comments on commit ac30c72

Please sign in to comment.