You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Until combinator will parse characters up to (but not including) one of the specified sentinel string values. If a sentinel value is not found, parsing fails.
193
-
194
-
**BNF**
195
-
196
-
```bnf
197
-
<T> ::= ? any character until ['Z'] ?
198
-
```
199
-
200
-
**TypeScript**
201
-
202
-
```typescript
203
-
const T =Runtime.Until(['Z']) // const T = {
204
-
// type: 'Until',
205
-
// values: ['Z']
206
-
// }
207
-
208
-
const R =Runtime.Parse(T, 'X Y Z') // const R = ['X Y ', 'Z']
209
-
```
210
-
211
192
### Optional
212
193
213
194
The Optional combinator parses zero or one occurrence of the interior parser, returning a tuple with one element or an empty tuple if there is no match.
ParseBox range combinators match character sequences up to one or more terminating sentinel strings. These combinators are used to match arbituary Unicode (UTF-16) sequences.
243
+
244
+
245
+
### Until
246
+
247
+
The Until combinator parses characters up to (but not including) one of the specified sentinel string values. It captures all characters encountered before the sentinel. If a sentinel value is not found in the input, parsing fails. Until succeeds even if it matches a zero-length string. This occurs if a sentinel is found immediately at the current parsing position.
248
+
249
+
**BNF**
250
+
251
+
```bnf
252
+
<T> ::= ? any character sequence (0 or more) until 'Z' ?
253
+
```
254
+
255
+
**TypeScript**
256
+
257
+
```typescript
258
+
const T =Runtime.Until(['Z']) // const T = {
259
+
// type: 'Until',
260
+
// values: ['Z']
261
+
// }
262
+
263
+
const R =Runtime.Parse(T, 'X Y Z') // const R = ['X Y ', 'Z']
264
+
```
265
+
266
+
### UntilNonEmpty
267
+
268
+
The UntilNonEmpty combinator works the same as Until, but it fails if the parsed content yields a zero-length string.
269
+
270
+
**BNF**
271
+
272
+
```bnf
273
+
<T> ::= ? any character sequence (1 or more) until 'Z'. fails on zero length ?
274
+
```
275
+
276
+
**TypeScript**
277
+
278
+
```typescript
279
+
const T =Runtime.UntilNonEmpty(['Z']) // const T = {
280
+
// type: 'UntilNonEmpty',
281
+
// values: ['Z']
282
+
// }
283
+
284
+
const R1 =Runtime.Parse(T, 'X Y Z') // const R1 = ['X Y ', 'Z']
ParseBox provides combinators for parsing common lexical tokens, such as numbers, identifiers, and strings, enabling static, optimized parsing of typical JavaScript constructs.
0 commit comments