Skip to content

Conversation

@sinclairzx81
Copy link
Owner

This PR adds an additional Until combinator (UntilNonEmpty) which fails if the parser matches on a zero length string (indicating the sentinel was the next character). This is used to mirror (one or more) semantics, where the original Until combinator handled (zero or more).

This combinator is envisioned for use in recursive matching scenarios to mitigate stack overflow for non-consuming matches. It's noted that in the Until case, stack overflow was difficult to avoid when matches would succeed for zero captures (meaning the cursor never advances). This combinator aims to enable an alternative parsing strategy where parsing can terminate for zero length, with subsequent Const used to explicitly consume the sentinel.

@sinclairzx81 sinclairzx81 merged commit 906cbf9 into main May 28, 2025
6 checks passed
@sinclairzx81 sinclairzx81 deleted the until branch May 28, 2025 16:45
sinclairzx81 added a commit that referenced this pull request May 28, 2025
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

Successfully merging this pull request may close these issues.

2 participants