Skip to content

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.

2 participants