Skip to content

Commit fa56a34

Browse files
committed
updates
1 parent 569f3a4 commit fa56a34

File tree

7 files changed

+31
-88
lines changed

7 files changed

+31
-88
lines changed

src/compile/common/comment.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ THE SOFTWARE.
2727
---------------------------------------------------------------------------*/
2828

2929
// deno-fmt-ignore-file
30-
// deno-lint-ignore-file
3130

31+
import { Unreachable } from '../../system/unreachable/index.ts'
3232
import { Runtime } from '../../runtime/index.ts'
33-
import { Unreachable } from './unreachable.ts'
3433
import { Escape } from './escape.ts'
3534

3635
function FromArray(parser: Runtime.IArray): string {
@@ -69,17 +68,17 @@ function FromUntilNonEmpty(parser: Runtime.IUntilNonEmpty): string {
6968
function FromParser(parser: Runtime.IParser): string {
7069
return (
7170
Runtime.IsArray(parser) ? FromArray(parser) :
72-
Runtime.IsConst(parser) ? FromConst(parser) :
73-
Runtime.IsIdent(parser) ? FromIdent(parser) :
74-
Runtime.IsNumber(parser) ? FromNumber(parser) :
75-
Runtime.IsOptional(parser) ? FromOptional(parser) :
76-
Runtime.IsRef(parser) ? FromRef(parser) :
77-
Runtime.IsString(parser) ? FromString(parser) :
78-
Runtime.IsTuple(parser) ? FromTuple(parser) :
79-
Runtime.IsUnion(parser) ? FromUnion(parser) :
80-
Runtime.IsUntil(parser) ? FromUntil(parser) :
81-
Runtime.IsUntilNonEmpty(parser) ? FromUntilNonEmpty(parser) :
82-
Unreachable(parser)
71+
Runtime.IsConst(parser) ? FromConst(parser) :
72+
Runtime.IsIdent(parser) ? FromIdent(parser) :
73+
Runtime.IsNumber(parser) ? FromNumber(parser) :
74+
Runtime.IsOptional(parser) ? FromOptional(parser) :
75+
Runtime.IsRef(parser) ? FromRef(parser) :
76+
Runtime.IsString(parser) ? FromString(parser) :
77+
Runtime.IsTuple(parser) ? FromTuple(parser) :
78+
Runtime.IsUnion(parser) ? FromUnion(parser) :
79+
Runtime.IsUntil(parser) ? FromUntil(parser) :
80+
Runtime.IsUntilNonEmpty(parser) ? FromUntilNonEmpty(parser) :
81+
Unreachable(parser)
8382
)
8483
}
8584
export function CompileComment(name: string, parser: Runtime.IParser): string {

src/compile/common/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ THE SOFTWARE.
2929
export * from './comment.ts'
3030
export * from './escape.ts'
3131
export * from './infer.ts'
32-
export * from './unreachable.ts'

src/compile/common/infer.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ THE SOFTWARE.
2929
// deno-fmt-ignore-file
3030
// deno-lint-ignore-file no-unused-vars
3131

32+
import { Unreachable } from '../../system/unreachable/index.ts'
3233
import { Runtime } from '../../runtime/index.ts'
33-
import { Unreachable } from './unreachable.ts'
3434

3535
function InferArray(parser: Runtime.IParser): string {
3636
return `(${Infer(parser)})[]`
@@ -68,16 +68,16 @@ function InferUntilNonEmpty(parser: Runtime.IUntilNonEmpty) {
6868
export function Infer(parser: Runtime.IParser): string {
6969
return (
7070
Runtime.IsArray(parser) ? InferArray(parser.parser) :
71-
Runtime.IsConst(parser) ? InferConst(parser) :
72-
Runtime.IsIdent(parser) ? InferIdent(parser) :
73-
Runtime.IsNumber(parser) ? InferNumber(parser) :
74-
Runtime.IsOptional(parser) ? InferOptional(parser.parser) :
75-
Runtime.IsRef(parser) ? InferRef(parser) :
76-
Runtime.IsString(parser) ? InferString(parser) :
77-
Runtime.IsTuple(parser) ? InferTuple(parser.parsers) :
78-
Runtime.IsUnion(parser) ? InferUnion(parser.parsers) :
79-
Runtime.IsUntil(parser) ? InferUntil(parser) :
80-
Runtime.IsUntilNonEmpty(parser) ? InferUntilNonEmpty(parser) :
81-
Unreachable(parser)
71+
Runtime.IsConst(parser) ? InferConst(parser) :
72+
Runtime.IsIdent(parser) ? InferIdent(parser) :
73+
Runtime.IsNumber(parser) ? InferNumber(parser) :
74+
Runtime.IsOptional(parser) ? InferOptional(parser.parser) :
75+
Runtime.IsRef(parser) ? InferRef(parser) :
76+
Runtime.IsString(parser) ? InferString(parser) :
77+
Runtime.IsTuple(parser) ? InferTuple(parser.parsers) :
78+
Runtime.IsUnion(parser) ? InferUnion(parser.parsers) :
79+
Runtime.IsUntil(parser) ? InferUntil(parser) :
80+
Runtime.IsUntilNonEmpty(parser) ? InferUntilNonEmpty(parser) :
81+
Unreachable(parser)
8282
)
8383
}

src/compile/func/func.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ THE SOFTWARE.
2929
// deno-fmt-ignore-file
3030
// deno-lint-ignore-file
3131

32+
import { Unreachable } from '../../system/unreachable/index.ts'
3233
import { Runtime } from '../../runtime/index.ts'
33-
import { Infer, Escape, Unreachable } from '../common/index.ts'
34+
import { Infer, Escape } from '../common/index.ts'
3435

3536
// ------------------------------------------------------------------
3637
// CompileState

src/runtime/guard.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@ THE SOFTWARE.
2626
2727
---------------------------------------------------------------------------*/
2828

29-
export type TUnreachable = never
30-
31-
export function Unreachable(): TUnreachable {
32-
throw new Error('Unreachable')
33-
}
29+
export * from './unreachable.ts'
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,9 @@ THE SOFTWARE.
2626
2727
---------------------------------------------------------------------------*/
2828

29-
// deno-fmt-ignore-file
29+
export type TUnreachable = never
3030

31-
import { Runtime } from '../../runtime/index.ts'
32-
33-
export class UnreachableError extends Error {
34-
constructor(public parser: Runtime.IParser) {
35-
super('unreachable')
36-
}
31+
export function Unreachable(cause: unknown = undefined): TUnreachable {
32+
// @ts-ignore - cause unknown to .d.ts
33+
throw new Error('Unreachable', { cause })
3734
}
38-
39-
export function Unreachable(parser: Runtime.IParser): never {
40-
throw new UnreachableError(parser)
41-
}

0 commit comments

Comments
 (0)