Skip to content

Until Combinator #7

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

Merged
merged 1 commit into from
May 21, 2025
Merged

Until Combinator #7

merged 1 commit into from
May 21, 2025

Conversation

sinclairzx81
Copy link
Owner

This PR adds a new combinator called Until

This combinator will parse any character up until the specified sentinel is reached. As per documentation.


Until

The Until combinator parses all characters up to (but not including) the specified string. The specified string remains unconsumed in the input. If the string is not found, parsing fails.

BNF

<T> ::= ? any character until 'Z' ?

TypeScript

const T = Runtime.Until('Z')                        // const T = {
                                                    //   type: 'Until',
                                                    //   value: 'X'
                                                    // }

const R = Runtime.Parse(T, 'X Y Z')                 // const R = ['X Y ', 'Z']

This combinator services the immediate requirement of being able to parse embedded strings (TemplateLiteral syntax) but could replace the current String combinator in subsequent revisions.

@sinclairzx81 sinclairzx81 merged commit 01ea33d into main May 21, 2025
6 checks passed
@sinclairzx81 sinclairzx81 deleted the until branch May 21, 2025 06:01
sinclairzx81 added a commit that referenced this pull request May 21, 2025
sinclairzx81 added a commit that referenced this pull request May 21, 2025
sinclairzx81 added a commit that referenced this pull request May 21, 2025
sinclairzx81 added a commit that referenced this pull request May 21, 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.

1 participant