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

Allow the same node to be matched multiple times with different tags #16

Open
JustusFluegel opened this issue Mar 3, 2024 · 14 comments

Comments

@JustusFluegel
Copy link

JustusFluegel commented Mar 3, 2024

Allow the following:

match_nodes!{
    [tag#node_1(a),tag_1#node_2(b)..,tag_2#node_2(c)..] => todo!();
};

with for example the grammar

input = { #tag = node_1 ~ ";" ~ #tag_1 = node_2*~ ";" ~ #tag_2 = node_2* }
@Nadrieril
Copy link
Owner

What are these tag things? Is that a new feature in pest?

@JustusFluegel
Copy link
Author

@Nadrieril
Copy link
Owner

I see. Did you mean to add repetition to tag_2 in your example, e.g. [tag#node_1(a), tag_1#node_2(b).., tag_2#node_2(c)..]? Do I correctly understand that this allows for multiple repetition patterns?

@Nadrieril
Copy link
Owner

Hm I guess we already could allow multiple repetition patterns today, but this allows it for the same node. That's interesting

@JustusFluegel
Copy link
Author

yea that's basically it

@JustusFluegel
Copy link
Author

Same as with #15 if you don't feel like dealing with this but think this is a welcome addition in general feel free to let me know.

@Nadrieril
Copy link
Owner

Thanks for offering! I'll give it a go because it seems easy enough, I'll ping you if I'd rather you do it instead :)

@JustusFluegel
Copy link
Author

sure that works 👍

@JustusFluegel
Copy link
Author

probably multiple repetition patterns need to be unique over the tuple (Node,Option<Tag>) I guess

@Nadrieril
Copy link
Owner

Yeah, I'm thinking I'll just do it greedily, so if someone does [node1(a).., node1(b)..], b will be empty

@JustusFluegel
Copy link
Author

or that probably also works fine 👍

@Nadrieril
Copy link
Owner

Alright, I've got tag support on master! Not yet multiple .. patterns

@Nadrieril
Copy link
Owner

Alright, multi multi patterns are on master! Can you test that this does what you want?

@JustusFluegel
Copy link
Author

Sure I'll do so sometime next week (hopefully tomorrow) since I am kinda busy right now.

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