Skip to content

Commit be56838

Browse files
committed
updates
1 parent 311e951 commit be56838

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

example/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,4 @@ console.log(Json)
142142
})
143143
console.log(project.parser) // parser file content
144144
console.log(project.mapping) // semantic mapping file content
145-
}
146-
147-
145+
}

example/typebox/interpreted/runtime.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ const Reference = Runtime.Ident((result, context) => ReferenceMapping(result, co
139139
function TemplateTextMapping(input: string) {
140140
return T.Literal(input)
141141
}
142-
const TemplateText = Runtime.Union([
143-
Runtime.Until('${'),
144-
Runtime.Until('`'),
145-
], TemplateTextMapping)
142+
const TemplateText = Runtime.Until(['`', '${'], TemplateTextMapping)
146143
// ------------------------------------------------------------------
147144
// TemplateInterpolate
148145
// ------------------------------------------------------------------

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,20 +189,20 @@ const R3 = Runtime.Parse(T, 'Y Z') // const R3 = [[], 'Y Z']
189189

190190
### Until
191191

192-
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.
192+
The Until combinator will parse characters up to (but not including) one of the specified sentinal string values. If a sentinal string value is not found, parsing fails.
193193

194194
**BNF**
195195

196196
```bnf
197-
<T> ::= ? any character until 'Z' ?
197+
<T> ::= ? any character until ['Z'] ?
198198
```
199199

200200
**TypeScript**
201201

202202
```typescript
203-
const T = Runtime.Until('Z') // const T = {
203+
const T = Runtime.Until(['Z']) // const T = {
204204
// type: 'Until',
205-
// value: 'Z'
205+
// values: ['Z']
206206
// }
207207

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

test/__tests__/runtime/parse.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ Deno.test('Until', () => {
2929
Assert(Runtime.Parse(Runtime.Until(['A']), 'A'), ['', 'A'])
3030
Assert(Runtime.Parse(Runtime.Until(['A']), ' A'), [' ', 'A'])
3131
Assert(Runtime.Parse(Runtime.Until(['A']), ' A '), [' ', 'A '])
32+
33+
Assert(Runtime.Parse(Runtime.Until(['A', 'B']), ''), [])
34+
Assert(Runtime.Parse(Runtime.Until(['A', 'B']), 'BA'), ['', 'BA'])
35+
Assert(Runtime.Parse(Runtime.Until(['A', 'B']), ' BA'), [' ', 'BA'])
36+
Assert(Runtime.Parse(Runtime.Until(['A', 'B']), ' BA '), [' ', 'BA '])
3237
})
38+
3339
// ----------------------------------------------------------------
3440
// Ident
3541
// ----------------------------------------------------------------

test/__tests__/static/parse.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ Assert<Static.Parse<Static.Until<['A']>, ''>, []>()
2828
Assert<Static.Parse<Static.Until<['A']>, 'A'>, ['', 'A']>()
2929
Assert<Static.Parse<Static.Until<['A']>, ' A'>, [' ', 'A']>()
3030
Assert<Static.Parse<Static.Until<['A']>, ' A '>, [' ', 'A ']>()
31+
32+
Assert<Static.Parse<Static.Until<['A', 'B']>, ''>, []>
33+
Assert<Static.Parse<Static.Until<['A', 'B']>, 'BA'>, ['', 'BA']>
34+
Assert<Static.Parse<Static.Until<['A', 'B']>, ' BA'>, [' ', 'BA']>
35+
Assert<Static.Parse<Static.Until<['A', 'B']>, ' BA '>, [' ', 'BA ']>
36+
3137
// ------------------------------------------------------------------
3238
// Ident
3339
// ------------------------------------------------------------------

0 commit comments

Comments
 (0)