Skip to content

Commit 6aa4c9e

Browse files
committed
Build
1 parent b582087 commit 6aa4c9e

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

src/build/common/comment.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ function FromTuple(parser: Runtime.ITuple): string {
6868
function FromUnion(parser: Runtime.IUnion): string {
6969
return parser.parsers.map((parser) => `${FromParser(parser)}`).join(' | ')
7070
}
71+
function FromUnsignedInteger(parser: Runtime.IUnsignedInteger): string {
72+
return `<UnsignedInteger>`
73+
}
74+
function FromUnsignedNumber(parser: Runtime.IUnsignedNumber): string {
75+
return `<UnsignedNumber>`
76+
}
7177
function FromUntil_1(parser: Runtime.IUntil_1): string {
7278
return `string`
7379
}
@@ -79,15 +85,17 @@ function FromParser(parser: Runtime.IParser): string {
7985
Runtime.IsArray(parser) ? FromArray(parser) :
8086
Runtime.IsBigInt(parser) ? FromBigInt(parser) :
8187
Runtime.IsConst(parser) ? FromConst(parser) :
82-
Runtime.IsInteger(parser) ? FromInteger(parser) :
8388
Runtime.IsIdent(parser) ? FromIdent(parser) :
89+
Runtime.IsInteger(parser) ? FromInteger(parser) :
8490
Runtime.IsNumber(parser) ? FromNumber(parser) :
8591
Runtime.IsOptional(parser) ? FromOptional(parser) :
8692
Runtime.IsRef(parser) ? FromRef(parser) :
8793
Runtime.IsRest(parser) ? FromRest(parser) :
8894
Runtime.IsString(parser) ? FromString(parser) :
8995
Runtime.IsTuple(parser) ? FromTuple(parser) :
9096
Runtime.IsUnion(parser) ? FromUnion(parser) :
97+
Runtime.IsUnsignedInteger(parser) ? FromUnsignedInteger(parser) :
98+
Runtime.IsUnsignedNumber(parser) ? FromUnsignedNumber(parser) :
9199
Runtime.IsUntil_1(parser) ? FromUntil_1(parser) :
92100
Runtime.IsUntil(parser) ? FromUntil(parser) :
93101
Unreachable(parser)

src/build/runtime/parse.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,18 @@ function FromUnion(name: string, parsers: Runtime.IParser[]): string {
122122
return parsers.length === 0 ? '[]' : parsers.reduceRight((result, right) => `If(${FromParser(name, right)}, ([_0, input]) => [_0, input], () => ${result})`, '[]')
123123
}
124124
// ------------------------------------------------------------------
125+
// UnsignedInteger
126+
// ------------------------------------------------------------------
127+
function FromUnsignedInteger(name: string): string {
128+
return `Token.UnsignedInteger(input)`
129+
}
130+
// ------------------------------------------------------------------
131+
// UnsignedNumber
132+
// ------------------------------------------------------------------
133+
function FromUnsignedNumber(name: string): string {
134+
return `Token.UnsignedNumber(input)`
135+
}
136+
// ------------------------------------------------------------------
125137
// Until_1
126138
// ------------------------------------------------------------------
127139
function FromUntil_1(name: string, end: string[]): string {
@@ -152,6 +164,8 @@ function FromParser(name: string, parser: Runtime.IParser): string {
152164
Runtime.IsString(parser) ? FromString(name, parser.quotes) :
153165
Runtime.IsTuple(parser) ? FromTuple(name, parser.parsers) :
154166
Runtime.IsUnion(parser) ? FromUnion(name, parser.parsers) :
167+
Runtime.IsUnsignedInteger(parser) ? FromUnsignedInteger(name) :
168+
Runtime.IsUnsignedNumber(parser) ? FromUnsignedNumber(name) :
155169
Runtime.IsUntil_1(parser) ? FromUntil_1(name, parser.end) :
156170
Runtime.IsUntil(parser) ? FromUntil(name, parser.end) :
157171
Unreachable(parser)

src/build/static/parse.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ function FromUnion(name: string, parsers: Runtime.IParser[]): string {
121121
return parsers.length === 0 ? '[]' : `(${parsers.reduceRight((result, right) => `${FromParser(name, right)} extends [infer _0, infer Input extends string] ? [_0, Input] : ${result}`, '[]')})`
122122
}
123123
// ------------------------------------------------------------------
124+
// UnsignedInteger
125+
// ------------------------------------------------------------------
126+
function FromUnsignedInteger(name: string): string {
127+
return `Token.TUnsignedInteger<Input>`
128+
}
129+
// ------------------------------------------------------------------
130+
// UnsignedNumber
131+
// ------------------------------------------------------------------
132+
function FromUnsignedNumber(name: string): string {
133+
return `Token.TUnsignedNumber<Input>`
134+
}
135+
// ------------------------------------------------------------------
124136
// Until_1
125137
// ------------------------------------------------------------------
126138
function FromUntil_1(name: string, end: string[]): string {
@@ -142,15 +154,17 @@ function FromParser(name: string, parser: Runtime.IParser): string {
142154
Runtime.IsArray(parser) ? FromArray(name, parser.parser) :
143155
Runtime.IsBigInt(parser) ? FromBigInt(name) :
144156
Runtime.IsConst(parser) ? FromConst(name, parser.const) :
145-
Runtime.IsInteger(parser) ? FromInteger(name) :
146157
Runtime.IsIdent(parser) ? FromIdent(name) :
158+
Runtime.IsInteger(parser) ? FromInteger(name) :
147159
Runtime.IsNumber(parser) ? FromNumber(name) :
148160
Runtime.IsOptional(parser) ? FromOptional(name, parser) :
149161
Runtime.IsRef(parser) ? FromRef(name, parser.ref) :
150162
Runtime.IsRest(parser) ? FromRest(name) :
151163
Runtime.IsString(parser) ? FromString(name, parser.quotes) :
152164
Runtime.IsTuple(parser) ? FromTuple(name, parser.parsers) :
153165
Runtime.IsUnion(parser) ? FromUnion(name, parser.parsers) :
166+
Runtime.IsUnsignedInteger(parser) ? FromUnsignedInteger(name) :
167+
Runtime.IsUnsignedNumber(parser) ? FromUnsignedNumber(name) :
154168
Runtime.IsUntil_1(parser) ? FromUntil_1(name, parser.end) :
155169
Runtime.IsUntil(parser) ? FromUntil(name, parser.end) :
156170
Unreachable(parser)

test/parsebox/build/json.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ const Coverage = Runtime.Union([
112112
Runtime.Until_1(['x']),
113113
Runtime.Union([]),
114114
Runtime.Optional(Runtime.Ident()),
115+
Runtime.UnsignedInteger(),
116+
Runtime.UnsignedNumber(),
115117
Runtime.Rest(),
116118
])
117119
export const JsonModule = new Runtime.Module({

0 commit comments

Comments
 (0)