react-dsl-editor 0.3.4 → 0.4.1
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 +24 -12
- package/dist/react-dsl-editor.js +917 -928
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -40,29 +40,30 @@ export declare function DslEditor<T extends string>({ code, onChange, onParsed,
|
|
|
40
40
|
|
|
41
41
|
export declare interface DSLError {
|
|
42
42
|
message: string;
|
|
43
|
+
expected?: string[];
|
|
43
44
|
start: number;
|
|
44
45
|
end: number;
|
|
46
|
+
depth: number;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
export declare class DSLParser<T extends string> {
|
|
48
50
|
private readonly grammar;
|
|
49
51
|
constructor(grammar: GrammarNode<T>);
|
|
52
|
+
private _parseStrict;
|
|
53
|
+
parseStrict(input: string): ParserSuccess<T> | undefined;
|
|
50
54
|
parse(input: string): DSL<T>;
|
|
51
55
|
}
|
|
52
56
|
|
|
53
|
-
export declare const eof: GrammarNode
|
|
57
|
+
export declare const eof: GrammarNode<never>;
|
|
54
58
|
|
|
55
|
-
export declare function error<T extends string>(param:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
got: string;
|
|
59
|
-
expected: string[];
|
|
60
|
-
};
|
|
59
|
+
export declare function error<T extends string>(param: ParserError<T>): ParserError<T>;
|
|
60
|
+
|
|
61
|
+
export declare type FaultToleranceMode = 'skip-parser' | 'skip-input' | 'fuzzy-match' | 'partial-match';
|
|
61
62
|
|
|
62
63
|
export declare interface GrammarNode<T extends string = never> {
|
|
63
64
|
type: T;
|
|
64
65
|
suggestions(): string[];
|
|
65
|
-
parse(text: string, context: ParserContext): ParserResult<T>;
|
|
66
|
+
parse(text: string, context: ParserContext<T>): ParserResult<T>;
|
|
66
67
|
children: GrammarNode<T>[];
|
|
67
68
|
meta?: Record<string, unknown>;
|
|
68
69
|
}
|
|
@@ -73,15 +74,21 @@ export declare function isParserSuccess<T extends string>(result: ParserResult<T
|
|
|
73
74
|
|
|
74
75
|
export declare function named<T extends string, K extends string>(name: T, child: GrammarNode<K>): GrammarNode<T | K>;
|
|
75
76
|
|
|
77
|
+
export declare const newline: GrammarNode<never>;
|
|
78
|
+
|
|
79
|
+
export declare function nodeName<T extends string>(node: {
|
|
80
|
+
grammar: GrammarNode<T>;
|
|
81
|
+
}): T | undefined;
|
|
82
|
+
|
|
76
83
|
export declare type NodeTypes<T> = _NodeTypes<T> | 'error';
|
|
77
84
|
|
|
78
85
|
declare type _NodeTypes<T> = T extends GrammarNode<infer U> ? U : never;
|
|
79
86
|
|
|
80
87
|
export declare function optional<T extends string>(child: GrammarNode<T>): GrammarNode<T>;
|
|
81
88
|
|
|
82
|
-
export declare interface ParserContext {
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
export declare interface ParserContext<T extends string> {
|
|
90
|
+
path: GrammarNode<T>[];
|
|
91
|
+
handleTerminalError(text: string, context: ParserContext<T>, grammar: GrammarNode<T>): ParserResult<T>;
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
export declare interface ParserError<T extends string = never> {
|
|
@@ -89,6 +96,7 @@ export declare interface ParserError<T extends string = never> {
|
|
|
89
96
|
got: string;
|
|
90
97
|
expected: string[];
|
|
91
98
|
offset: number;
|
|
99
|
+
path: GrammarNode<T>[];
|
|
92
100
|
}
|
|
93
101
|
|
|
94
102
|
export declare type ParserResult<T extends string = never> = ParserSuccess<T> | ParserError<T>;
|
|
@@ -97,13 +105,15 @@ export declare interface ParserSuccess<T extends string = never> {
|
|
|
97
105
|
text: string;
|
|
98
106
|
grammar: GrammarNode<T>;
|
|
99
107
|
children: ParserSuccess<T>[];
|
|
100
|
-
|
|
108
|
+
errorLabel?: ParserError<T>;
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
export declare class ParsingError extends Error {
|
|
104
112
|
constructor(msg: string);
|
|
105
113
|
}
|
|
106
114
|
|
|
115
|
+
export declare function pathToString(v: GrammarNode<string>[]): string;
|
|
116
|
+
|
|
107
117
|
export declare function pattern(regex: RegExp): GrammarNode<never>;
|
|
108
118
|
|
|
109
119
|
export declare const rational: GrammarNode<never>;
|
|
@@ -127,6 +137,8 @@ declare const themes: {
|
|
|
127
137
|
|
|
128
138
|
export declare function visit<T extends string, V = string>(parserResult: ParserSuccess<T>, type: T[], extractor?: (node: ParserSuccess<T>) => V): V[];
|
|
129
139
|
|
|
140
|
+
export declare function visitPredicate<T extends string, V = string>(parserResult: ParserSuccess<T>, filter: (v: ParserSuccess<T>) => boolean, extractor?: (node: ParserSuccess<T>) => V): V[];
|
|
141
|
+
|
|
130
142
|
export declare const ws: GrammarNode<never>;
|
|
131
143
|
|
|
132
144
|
export { }
|