clarity-pattern-parser 6.0.0 → 7.0.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.
Files changed (94) hide show
  1. package/TODO.md +1 -76
  2. package/dist/ast/Node.d.ts +1 -0
  3. package/dist/grammar/Grammar.d.ts +17 -0
  4. package/dist/grammar/patterns/andLiteral.d.ts +2 -0
  5. package/dist/grammar/patterns/comment.d.ts +2 -0
  6. package/dist/grammar/patterns/grammar.d.ts +2 -0
  7. package/dist/grammar/patterns/literal.d.ts +2 -0
  8. package/dist/grammar/patterns/name.d.ts +2 -0
  9. package/dist/grammar/patterns/orLiteral.d.ts +2 -0
  10. package/dist/grammar/patterns/pattern.d.ts +2 -0
  11. package/dist/grammar/patterns/regexLiteral.d.ts +2 -0
  12. package/dist/grammar/patterns/repeatLiteral.d.ts +3 -0
  13. package/dist/grammar/patterns/spaces.d.ts +2 -0
  14. package/dist/grammar/patterns/statement.d.ts +2 -0
  15. package/dist/index.browser.js +1205 -550
  16. package/dist/index.browser.js.map +1 -1
  17. package/dist/index.d.ts +5 -4
  18. package/dist/index.esm.js +1203 -549
  19. package/dist/index.esm.js.map +1 -1
  20. package/dist/index.js +1203 -548
  21. package/dist/index.js.map +1 -1
  22. package/dist/intellisense/AutoComplete.d.ts +9 -7
  23. package/dist/intellisense/Suggestion.d.ts +1 -2
  24. package/dist/patterns/And.d.ts +2 -1
  25. package/dist/patterns/Cursor.d.ts +1 -0
  26. package/dist/patterns/CursorHistory.d.ts +2 -1
  27. package/dist/patterns/FiniteRepeat.d.ts +39 -0
  28. package/dist/patterns/InfiniteRepeat.d.ts +47 -0
  29. package/dist/patterns/Literal.d.ts +2 -1
  30. package/dist/patterns/Not.d.ts +2 -1
  31. package/dist/patterns/Or.d.ts +2 -1
  32. package/dist/patterns/Pattern.d.ts +3 -2
  33. package/dist/patterns/Reference.d.ts +2 -1
  34. package/dist/patterns/Regex.d.ts +2 -1
  35. package/dist/patterns/Repeat.d.ts +19 -22
  36. package/jest.config.js +0 -1
  37. package/jest.coverage.config.js +13 -0
  38. package/package.json +3 -3
  39. package/src/ast/Node.test.ts +21 -0
  40. package/src/ast/Node.ts +12 -6
  41. package/src/grammar/Grammar.test.ts +288 -0
  42. package/src/grammar/Grammar.ts +234 -0
  43. package/src/grammar/patterns/andLiteral.ts +8 -0
  44. package/src/grammar/patterns/comment.ts +3 -0
  45. package/src/grammar/patterns/grammar.ts +19 -0
  46. package/src/grammar/patterns/literal.ts +5 -0
  47. package/src/grammar/patterns/name.ts +3 -0
  48. package/src/grammar/patterns/orLiteral.ts +8 -0
  49. package/src/grammar/patterns/pattern.ts +13 -0
  50. package/src/grammar/patterns/regexLiteral.ts +4 -0
  51. package/src/grammar/patterns/repeatLiteral.ts +72 -0
  52. package/src/grammar/patterns/spaces.ts +4 -0
  53. package/src/grammar/patterns/statement.ts +35 -0
  54. package/src/grammar/spec.md +142 -0
  55. package/src/index.ts +6 -3
  56. package/src/intellisense/AutoComplete.test.ts +125 -39
  57. package/src/intellisense/AutoComplete.ts +52 -36
  58. package/src/intellisense/Suggestion.ts +1 -2
  59. package/src/intellisense/css/cssValue.ts +1 -1
  60. package/src/intellisense/css/method.ts +1 -1
  61. package/src/intellisense/css/values.ts +1 -1
  62. package/src/intellisense/javascript/Javascript.test.ts +34 -11
  63. package/src/intellisense/javascript/arrayLiteral.ts +1 -1
  64. package/src/intellisense/javascript/{expressionStatement.ts → assignment.ts} +7 -8
  65. package/src/intellisense/javascript/expression.ts +45 -27
  66. package/src/intellisense/javascript/infixOperator.ts +6 -2
  67. package/src/intellisense/javascript/invocation.ts +1 -1
  68. package/src/intellisense/javascript/keywords.ts +3 -0
  69. package/src/intellisense/javascript/objectAccess.ts +9 -0
  70. package/src/intellisense/javascript/objectLiteral.ts +3 -3
  71. package/src/intellisense/javascript/parameters.ts +1 -1
  72. package/src/intellisense/javascript/propertyAccess.ts +8 -3
  73. package/src/intellisense/javascript/stringLiteral.ts +14 -8
  74. package/src/patterns/And.test.ts +16 -3
  75. package/src/patterns/And.ts +25 -17
  76. package/src/patterns/Cursor.ts +4 -0
  77. package/src/patterns/CursorHistory.ts +34 -5
  78. package/src/patterns/FiniteRepeat.test.ts +481 -0
  79. package/src/patterns/FiniteRepeat.ts +231 -0
  80. package/src/patterns/InfiniteRepeat.test.ts +296 -0
  81. package/src/patterns/InfiniteRepeat.ts +329 -0
  82. package/src/patterns/Literal.test.ts +13 -4
  83. package/src/patterns/Literal.ts +5 -1
  84. package/src/patterns/Not.test.ts +20 -9
  85. package/src/patterns/Not.ts +5 -1
  86. package/src/patterns/Or.test.ts +18 -7
  87. package/src/patterns/Or.ts +11 -1
  88. package/src/patterns/Pattern.ts +3 -2
  89. package/src/patterns/Reference.test.ts +18 -8
  90. package/src/patterns/Reference.ts +5 -1
  91. package/src/patterns/Regex.test.ts +13 -4
  92. package/src/patterns/Regex.ts +5 -1
  93. package/src/patterns/Repeat.test.ts +162 -158
  94. package/src/patterns/Repeat.ts +95 -226
package/TODO.md CHANGED
@@ -1,76 +1 @@
1
- ## Grammar Ideas
2
- ```
3
- #comment
4
- integer = /0|([1-9][0-9]+)/
5
- method-name = "subtract" | "add" | "multiply"
6
- divider = /\s*,\s*/
7
- open-paren = "("
8
- close-paren = ")"
9
- argument = integer | method
10
- arguments = argument* divider
11
- not-integer = !integer
12
- optional-integer = integer?
13
- method = method-name & open-paren & arguments & close-paren
14
-
15
- integer.tokens = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
16
- integer.enableContextualTokenAggregation
17
- arguments.shouldReduceAst
18
-
19
- export (method, arguments)
20
- ```
21
-
22
- Using Grammar for a simple JSON Parser
23
- ```
24
- # Number Integer
25
- integer = /([1-9][0-9])*|0/
26
- digit = /\d+/
27
-
28
- # Number Fraction
29
- period = "."
30
- fraction = period & digit
31
-
32
- # Number Exponent
33
- e = "e" | "E"
34
- sign = "+" | "-"
35
- number-exponent = e & sign? & digit
36
-
37
- # Number
38
- number = integer & fraction? & number-exponent?
39
-
40
- # String Unicode
41
- hex-digit = /[0-9a-fA-F]/
42
- unicode = "u" & hex-digit & hex-digit & hex-digit & hex-digit
43
- special-character =
44
- "'" |
45
- "\"" |
46
- "\\" |
47
- "/" |
48
- "b" |
49
- "f" |
50
- "n" |
51
- "r" |
52
- "t" |
53
- unicode
54
-
55
- normal-character = /[^\\"]+/
56
- escaped-character = "\\" & special-character
57
- character = normal-character | special-character
58
- characters = character*
59
-
60
- # String
61
- string = "\"" & characters & "\""
62
-
63
- # Boolean
64
- boolean = "true" | "false"
65
-
66
- spaces /\s+/
67
-
68
- array-item = number | boolean | string | array | object
69
- array-items = array-items* /\s+,\s+/
70
- array = "[" & spaces? & array-items & spaces? & "]"
71
-
72
-
73
- ```
74
-
75
- // Other file
76
- import (method, arguments) from "./method.grammar"
1
+ * Need to Rename Repeat.ts to InfiniteRepeat and them make a new class that is Repeat.ts that is a fascade to FiniteRepeat and InfiniteRepeat, so its easier to use.
@@ -42,6 +42,7 @@ export declare class Node {
42
42
  walkDown(callback: (node: Node) => void): void;
43
43
  flatten(): Node[];
44
44
  reduce(): void;
45
+ remove(): void;
45
46
  clone(): Node;
46
47
  toString(): string;
47
48
  toCycleFreeObject(): CycleFreeNode;
@@ -0,0 +1,17 @@
1
+ import { Pattern } from "../patterns/Pattern";
2
+ export declare class Grammar {
3
+ private _parseContext;
4
+ private _autoComplete;
5
+ constructor();
6
+ parse(expression: string): Map<string, Pattern>;
7
+ private _tryToParse;
8
+ private _cleanAst;
9
+ private _buildPatterns;
10
+ private _buildLiteral;
11
+ private _buildRegex;
12
+ private _buildOr;
13
+ private _getPattern;
14
+ private _buildAnd;
15
+ private _buildRepeat;
16
+ static parse(expression: string): Map<string, Pattern>;
17
+ }
@@ -0,0 +1,2 @@
1
+ import { Repeat } from "../../patterns/Repeat";
2
+ export declare const andLiteral: Repeat;
@@ -0,0 +1,2 @@
1
+ import { Regex } from "../../patterns/Regex";
2
+ export declare const comment: Regex;
@@ -0,0 +1,2 @@
1
+ import { Repeat } from "../../patterns/Repeat";
2
+ export declare const grammar: Repeat;
@@ -0,0 +1,2 @@
1
+ import { Regex } from "../../patterns/Regex";
2
+ export declare const literal: Regex;
@@ -0,0 +1,2 @@
1
+ import { Regex } from "../../patterns/Regex";
2
+ export declare const name: Regex;
@@ -0,0 +1,2 @@
1
+ import { Repeat } from "../../patterns/Repeat";
2
+ export declare const orLiteral: Repeat;
@@ -0,0 +1,2 @@
1
+ import { And } from "../../patterns/And";
2
+ export declare const pattern: And;
@@ -0,0 +1,2 @@
1
+ import { Regex } from "../../patterns/Regex";
2
+ export declare const regexLiteral: Regex;
@@ -0,0 +1,3 @@
1
+ import { And } from "../../patterns/And";
2
+ export declare const pattern: And;
3
+ export declare const repeatLiteral: And;
@@ -0,0 +1,2 @@
1
+ import { Regex } from "../../patterns/Regex";
2
+ export declare const spaces: Regex;
@@ -0,0 +1,2 @@
1
+ import { And } from "../../patterns/And";
2
+ export declare const statement: And;