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

How to refer to a previously parsed string? #1687

Open
ckp95 opened this issue Aug 17, 2023 · 1 comment
Open

How to refer to a previously parsed string? #1687

ckp95 opened this issue Aug 17, 2023 · 1 comment

Comments

@ckp95
Copy link

ckp95 commented Aug 17, 2023

Conceptual question, I wasn't able to figure this out from reading the docs. Let's say I have some XML-like language where you can have tags with arbitrary alphanumeric text in them, and they have to be symmetric, like this:

some text <foo>some more text</foo> even more text!

The possible tags aren't hardcoded ahead of time, they can be anything so long as the tags balance. So this is invalid:

some text <foo>some more text</bar> even more text!

The parser for the second tag would have to look for the exact string matched by the parser for the first tag (kinda like regex capture groups), but I don't know how to express that in this library.

@Xiretza
Copy link
Contributor

Xiretza commented Aug 17, 2023

Your parser would match an arbitrary start tag (which gives it the tag name), followed by the contents (some more text) followed by an end tag with the same name as the start tag. Since it's all one parser, it knows the start tag.

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