clarity-pattern-parser 8.2.0 → 8.3.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.
@@ -1,3 +1,7 @@
1
1
  {
2
- "typescript.tsdk": "node_modules/typescript/lib"
2
+ "typescript.tsdk": "node_modules/typescript/lib",
3
+ "typescript.preferences.importModuleSpecifierEnding": "minimal",
4
+ "javascript.preferences.importModuleSpecifierEnding": "minimal",
5
+ "typescript.preferences.importModuleSpecifier": "relative",
6
+ "javascript.preferences.importModuleSpecifier": "relative"
3
7
  }
package/README.md CHANGED
@@ -129,14 +129,14 @@ ast.toJson(2); // Look Below for output
129
129
  ```
130
130
 
131
131
  ## Or
132
- The `Or` pattern mathes any of the patterns given to the constructor.
132
+ The `Or` pattern matches any of the patterns given to the constructor.
133
133
  ```ts
134
134
  import { Or, Literal } from "clarity-pattern-parser";
135
135
 
136
136
  const jane = new Literal("jane", "Jane");
137
137
  const john = new Literal("john", "John");
138
138
  const firstName = new Or("first-name", [jane, john]);
139
- const { ast }= firstName.exec("Jane");
139
+ const { ast } = firstName.exec("Jane");
140
140
 
141
141
  ast.toJson(2)
142
142
  ```
@@ -1,12 +1,29 @@
1
1
  import { Pattern } from "../patterns/Pattern";
2
+ export interface GrammarMeta {
3
+ originPath?: string;
4
+ }
5
+ export interface GrammarFile {
6
+ path: string;
7
+ expression: string;
8
+ }
9
+ export interface GrammarOptions {
10
+ resolveImport?: (path: string, originPath: string | null) => Promise<GrammarFile>;
11
+ meta?: GrammarMeta | null;
12
+ }
2
13
  export declare class Grammar {
14
+ private _meta;
15
+ private _resolveImport;
3
16
  private _parseContext;
4
17
  private _autoComplete;
5
- constructor();
6
- parse(expression: string): Map<string, Pattern>;
18
+ constructor(options?: GrammarOptions);
19
+ import(path: string): Promise<Map<string, Pattern>>;
20
+ parse(expression: string): Promise<Map<string, Pattern>>;
21
+ parseString(expression: string): Map<string, Pattern>;
7
22
  private _tryToParse;
23
+ private _hasImports;
8
24
  private _cleanAst;
9
25
  private _buildPatterns;
26
+ private _resolveImports;
10
27
  private _buildLiteral;
11
28
  private _buildRegex;
12
29
  private _buildOr;
@@ -14,5 +31,7 @@ export declare class Grammar {
14
31
  private _buildAnd;
15
32
  private _buildRepeat;
16
33
  private _buildAlias;
17
- static parse(expression: string): Map<string, Pattern>;
34
+ static parse(expression: string, options?: GrammarOptions): Promise<Map<string, Pattern>>;
35
+ static import(path: string, options?: GrammarOptions): Promise<Map<string, Pattern>>;
36
+ static parseString(expression: string): Map<string, Pattern>;
18
37
  }
@@ -0,0 +1,2 @@
1
+ import { And } from "../../patterns/And";
2
+ export declare const importStatement: And;