ohm-js 18.0.0-beta.2 → 18.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +114 -2
- package/dist/index.js +737 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -12
- package/dist/src/assert.d.ts +0 -2
- package/dist/src/assert.js +0 -9
- package/dist/src/assert.js.map +0 -1
- package/dist/src/createToAst.d.ts +0 -21
- package/dist/src/createToAst.js +0 -140
- package/dist/src/createToAst.js.map +0 -1
- package/dist/src/extras.d.ts +0 -12
- package/dist/src/extras.js +0 -122
- package/dist/src/extras.js.map +0 -1
- package/dist/src/miniohm.d.ts +0 -233
- package/dist/src/miniohm.js +0 -711
- package/dist/src/miniohm.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/miniohm.d.ts
|
|
2
|
+
declare const CstNodeType: {
|
|
3
|
+
readonly NONTERMINAL: 0;
|
|
4
|
+
readonly TERMINAL: 1;
|
|
5
|
+
readonly LIST: 2;
|
|
6
|
+
readonly OPT: 3;
|
|
7
|
+
readonly SEQ: 4;
|
|
8
|
+
};
|
|
9
|
+
type CstNodeType = (typeof CstNodeType)[keyof typeof CstNodeType];
|
|
10
|
+
declare class Interval {
|
|
11
|
+
startIdx: number;
|
|
12
|
+
endIdx: number;
|
|
13
|
+
constructor(sourceString: string, startIdx: number, endIdx: number);
|
|
14
|
+
get sourceString(): string;
|
|
15
|
+
get contents(): string;
|
|
16
|
+
}
|
|
17
|
+
declare class Failure {
|
|
18
|
+
constructor(description: string, fluffy: boolean);
|
|
19
|
+
isFluffy(): boolean;
|
|
20
|
+
toString(): string;
|
|
21
|
+
}
|
|
22
|
+
declare class Grammar {
|
|
23
|
+
name: string;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new Grammar object.
|
|
26
|
+
* If `bytes` is specified, the WebAssembly module will be synchronously
|
|
27
|
+
* compiled and instantiated. Use `instantiate` or `instantiateStreaming`
|
|
28
|
+
* to instantiate asynchronously.
|
|
29
|
+
*/
|
|
30
|
+
constructor(bytes?: BufferSource);
|
|
31
|
+
static instantiate(source: BufferSource): Promise<Grammar>;
|
|
32
|
+
static instantiateStreaming(source: Response | Promise<Response>): Promise<Grammar>;
|
|
33
|
+
match<T>(input: string, ruleName?: string): MatchResult;
|
|
34
|
+
getFailureDescription(id: number): string;
|
|
35
|
+
getMemorySizeBytes(): number;
|
|
36
|
+
getRightmostFailurePosition(): number;
|
|
37
|
+
}
|
|
38
|
+
type CstNode = NonterminalNode | TerminalNode | ListNode | OptNode | SeqNode;
|
|
39
|
+
type CstNodeChildren = readonly CstNode[];
|
|
40
|
+
interface CstNodeBase {
|
|
41
|
+
ctorName: string;
|
|
42
|
+
source: {
|
|
43
|
+
startIdx: number;
|
|
44
|
+
endIdx: number;
|
|
45
|
+
};
|
|
46
|
+
sourceString: string;
|
|
47
|
+
matchLength: number;
|
|
48
|
+
isNonterminal(): this is NonterminalNode;
|
|
49
|
+
isTerminal(): this is TerminalNode;
|
|
50
|
+
isOptional(): this is OptNode;
|
|
51
|
+
isSeq(): this is SeqNode;
|
|
52
|
+
isList(): this is ListNode;
|
|
53
|
+
}
|
|
54
|
+
interface NonterminalNode<TChildren extends CstNodeChildren = CstNodeChildren> extends CstNodeBase {
|
|
55
|
+
type: typeof CstNodeType.NONTERMINAL;
|
|
56
|
+
ctorName: string;
|
|
57
|
+
leadingSpaces?: NonterminalNode;
|
|
58
|
+
children: TChildren;
|
|
59
|
+
isSyntactic(): boolean;
|
|
60
|
+
isLexical(): boolean;
|
|
61
|
+
}
|
|
62
|
+
interface TerminalNode extends CstNodeBase {
|
|
63
|
+
type: typeof CstNodeType.TERMINAL;
|
|
64
|
+
ctorName: "_terminal";
|
|
65
|
+
leadingSpaces?: NonterminalNode;
|
|
66
|
+
children: readonly [];
|
|
67
|
+
value: string;
|
|
68
|
+
}
|
|
69
|
+
interface ListNode<TNode extends CstNode = CstNode> extends CstNodeBase {
|
|
70
|
+
type: typeof CstNodeType.LIST;
|
|
71
|
+
ctorName: "_list";
|
|
72
|
+
children: readonly TNode[];
|
|
73
|
+
collect: <R>(cb: (...children: CstNode[]) => R) => R[];
|
|
74
|
+
}
|
|
75
|
+
interface OptNode<TChild extends CstNode = CstNode> extends CstNodeBase {
|
|
76
|
+
type: typeof CstNodeType.OPT;
|
|
77
|
+
ctorName: "_opt";
|
|
78
|
+
children: [] | [TChild];
|
|
79
|
+
ifPresent<R>(consume: TChild extends SeqNode<infer T> ? (...children: T) => R : (child: TChild) => R, orElse?: () => R): R;
|
|
80
|
+
ifPresent<R>(consume: TChild extends SeqNode<infer T> ? (...children: T) => R : (child: TChild) => R): R | undefined;
|
|
81
|
+
isPresent(): boolean;
|
|
82
|
+
isEmpty(): boolean;
|
|
83
|
+
}
|
|
84
|
+
interface SeqNode<TChildren extends CstNodeChildren = CstNodeChildren> extends CstNodeBase {
|
|
85
|
+
type: typeof CstNodeType.SEQ;
|
|
86
|
+
ctorName: "_seq";
|
|
87
|
+
children: TChildren;
|
|
88
|
+
unpack: <R>(cb: (...children: TChildren) => R) => R;
|
|
89
|
+
}
|
|
90
|
+
declare abstract class MatchResult {
|
|
91
|
+
grammar: Grammar;
|
|
92
|
+
startExpr: string;
|
|
93
|
+
get input(): string;
|
|
94
|
+
get [Symbol.dispose](): () => void;
|
|
95
|
+
dispose(): void;
|
|
96
|
+
succeeded(): this is SucceededMatchResult;
|
|
97
|
+
failed(): this is FailedMatchResult;
|
|
98
|
+
toString(): string;
|
|
99
|
+
use<T>(cb: (r: this) => T): T;
|
|
100
|
+
}
|
|
101
|
+
declare class SucceededMatchResult extends MatchResult {
|
|
102
|
+
getCstRoot(): CstNode;
|
|
103
|
+
}
|
|
104
|
+
declare class FailedMatchResult extends MatchResult {
|
|
105
|
+
getRightmostFailurePosition(): number;
|
|
106
|
+
getRightmostFailures(): Failure[];
|
|
107
|
+
getExpectedText(): string;
|
|
108
|
+
getInterval(): Interval;
|
|
109
|
+
get message(): string;
|
|
110
|
+
get shortMessage(): string;
|
|
111
|
+
}
|
|
112
|
+
//#endregion
|
|
113
|
+
export { type CstNode, type CstNodeChildren, CstNodeType, type FailedMatchResult, type Failure, Grammar, type Interval, type ListNode, type MatchResult, type NonterminalNode, type OptNode, type SeqNode, type SucceededMatchResult, type TerminalNode };
|
|
114
|
+
//# sourceMappingURL=index.d.ts.map
|