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

Aggregate captures with _SAVE/_SAVE_AS #10

Open
2 tasks
xparq opened this issue Sep 4, 2023 · 0 comments
Open
2 tasks

Aggregate captures with _SAVE/_SAVE_AS #10

xparq opened this issue Sep 4, 2023 · 0 comments

Comments

@xparq
Copy link
Owner

xparq commented Sep 4, 2023

In "looping" rules (like ANY/MANY), or for SAVE_AS rules with the same name, repeated captures should append to a list, not just overwrite the last one...

  • IOW, match collection should be transactional.

Only... this could wreak havoc with recursion; just trying to think about backtracking from partial matches hurts already.

Clearing the results on backtracking would be like stack unwinding with exception handling: there should be a reference baseline "catch" point in the backtracking path, where any tentatively successful "sub-results" should be unrolled on failure.

And that point is just there implicitly right before every match: if that match failed, everything that had been collected during that (i.e. by successful child (sub-) matches) should be undone, as if the match hadn't happened at all.

  • Actually, with appends, just by remembering the last "watermark" positions in the results containers (e.g. vectors), unrolling on a failed match could work very efficiently.
@xparq xparq mentioned this issue Sep 8, 2023
8 tasks
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

1 participant