clarity-pattern-parser 10.3.0 → 10.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clarity-pattern-parser",
3
- "version": "10.3.0",
3
+ "version": "10.3.1",
4
4
  "description": "Parsing Library for Typescript and Javascript.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.esm.js",
@@ -96,6 +96,34 @@ function createOptionsExpression() {
96
96
  return expressionPattern;
97
97
  }
98
98
 
99
+ function createTailExpression() {
100
+ const a = new Literal("a", "a");
101
+ const b = new Literal("b", "b");
102
+ const c = new Literal("c", "c");
103
+ const variable = new Options("variable", [a, b, c]);
104
+ const period = new Literal(".", ".");
105
+
106
+ const refinement = new Sequence("refinement", [period, variable]);
107
+ const refinementExpression = new Sequence("refinement-expression", [
108
+ new Reference("expression"),
109
+ refinement
110
+ ]);
111
+
112
+ const invocation = new Literal("invocation", "()");
113
+ const invocationExpression = new Sequence("invocation-expression", [
114
+ new Reference("expression"),
115
+ invocation
116
+ ]);
117
+
118
+ const expression = new ExpressionPattern("expression", [
119
+ refinementExpression,
120
+ invocationExpression,
121
+ variable
122
+ ]);
123
+
124
+ return expression;
125
+ }
126
+
99
127
  describe("Expression Pattern", () => {
100
128
  test("Single Expression", () => {
101
129
  const expression = createExpressionPattern();
@@ -113,6 +141,16 @@ describe("Expression Pattern", () => {
113
141
  expect(result).toBe(result);
114
142
  });
115
143
 
144
+ test("Tail", () => {
145
+ const expression = createTailExpression();
146
+ let result = expression.exec("a");
147
+ result = expression.exec("a.b");
148
+ result = expression.exec("a.b.c");
149
+ result = expression.exec("a.b.c()()()");
150
+
151
+ expect(result).toBe(result);
152
+ });
153
+
116
154
  test("Options like", () => {
117
155
  const expression = createOptionsExpression();
118
156
  const autoComplete = new AutoComplete(expression);
@@ -211,7 +211,6 @@ export class ExpressionPattern implements Pattern {
211
211
  }
212
212
 
213
213
  parse(cursor: Cursor): Node | null {
214
- // This is a cache to help with speed
215
214
  this._firstIndex = cursor.index;
216
215
  depthCache.incrementDepth(this._id, this._firstIndex);
217
216
 
@@ -330,7 +329,9 @@ export class ExpressionPattern implements Pattern {
330
329
  }
331
330
  break outer;
332
331
  }
333
- break;
332
+ onIndex = cursor.index;
333
+ i = -1;
334
+ continue;
334
335
  }
335
336
  }
336
337