Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quoted_string railroad diagram differs when multiple #528

Open
RoDuth opened this issue Dec 10, 2023 · 1 comment
Open

quoted_string railroad diagram differs when multiple #528

RoDuth opened this issue Dec 10, 2023 · 1 comment
Assignees

Comments

@RoDuth
Copy link

RoDuth commented Dec 10, 2023

I've been updating the parser for an old project recently and can I say the railroad diagrams are a great feature!

I found an anomaly when using quoted_string in multiple places with set_result_name.

When used in a single place I get:
image

but when used in multiple places, e.g.:

from pyparsing import *


quoted_string.set_parse_action(remove_quotes)
none_token = Keyword("None")
numeric_token = Regex(r"[-]?\d+(\.\d*)?([eE]\d+)?").set_name("numeric token")
value_token = (none_token | quoted_string).set_name("value")("value")
date_value_token = (numeric_token | quoted_string).set_name("date value")("value")
generic_token = (date_value_token | value_token).set_name("generic token")
generic_token.create_diagram("test.html")

I get:
image

I did try .copy() and a few other ideas but none of them made any difference.

@ptmcg
Copy link
Member

ptmcg commented Feb 13, 2024

Yes, there is a known problem with the railroad diagrams generating empty blocks, that I've tried a few times to chase down, but it eludes me. That feels like a separate problem from this one, and I think I opened an issue on it a while ago, but closed it when I thought I had it fixed - turns out my solution was only a partial one. I'll reopen that ticket or create a new one.

It's possible that the multiple instances are actually creating separate expression copies (which is what happens internally when setting results names), and this might be part of the issue that I didn't consider before.

@ptmcg ptmcg self-assigned this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants