react-dsl-editor 0.3.4 → 0.4.0
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 +17 -11
- package/dist/react-dsl-editor.js +947 -1016
- 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,19 @@ 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 function nodeName<T extends string>(node: {
|
|
78
|
+
grammar: GrammarNode<T>;
|
|
79
|
+
}): T | undefined;
|
|
80
|
+
|
|
76
81
|
export declare type NodeTypes<T> = _NodeTypes<T> | 'error';
|
|
77
82
|
|
|
78
83
|
declare type _NodeTypes<T> = T extends GrammarNode<infer U> ? U : never;
|
|
79
84
|
|
|
80
85
|
export declare function optional<T extends string>(child: GrammarNode<T>): GrammarNode<T>;
|
|
81
86
|
|
|
82
|
-
export declare interface ParserContext {
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
export declare interface ParserContext<T extends string> {
|
|
88
|
+
path: GrammarNode<T>[];
|
|
89
|
+
handleTerminalError(text: string, context: ParserContext<T>, grammar: GrammarNode<T>): ParserResult<T>;
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
export declare interface ParserError<T extends string = never> {
|
|
@@ -89,6 +94,7 @@ export declare interface ParserError<T extends string = never> {
|
|
|
89
94
|
got: string;
|
|
90
95
|
expected: string[];
|
|
91
96
|
offset: number;
|
|
97
|
+
path: GrammarNode<T>[];
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
export declare type ParserResult<T extends string = never> = ParserSuccess<T> | ParserError<T>;
|