clarity-pattern-parser 9.2.0 → 9.2.2
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/grammar/patterns/body.d.ts +2 -2
- package/dist/index.browser.js +8 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +8 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/grammar/Grammar.ts +5 -3
- package/src/grammar/patterns/body.ts +1 -1
- package/src/grammar/patterns/import.ts +1 -1
- package/src/patterns/Options.test.ts +2 -2
- package/src/patterns/Options.ts +2 -2
package/package.json
CHANGED
package/src/grammar/Grammar.ts
CHANGED
|
@@ -131,13 +131,15 @@ export class Grammar {
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
private _buildPatterns(ast: Node) {
|
|
134
|
-
const body = ast.find(n => n.name === "body");
|
|
134
|
+
const body = ast.find(n => n.name === "body" && n.findAncester(n => n.name === "head") == null);
|
|
135
135
|
|
|
136
136
|
if (body == null) {
|
|
137
137
|
return;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
body.findAll(n => n.name === "assign-statement")
|
|
140
|
+
const statements = body.findAll(n => n.name === "assign-statement");
|
|
141
|
+
|
|
142
|
+
statements.forEach((n) => {
|
|
141
143
|
const patternNode = n.children.find(n => patternNodes[n.name] != null);
|
|
142
144
|
|
|
143
145
|
if (patternNode == null) {
|
|
@@ -449,7 +451,7 @@ export class Grammar {
|
|
|
449
451
|
const paramsStatement = importStatement.find(n => n.name === "with-params-statement");
|
|
450
452
|
|
|
451
453
|
if (paramsStatement != null) {
|
|
452
|
-
const statements = paramsStatement.find(n => n.name === "
|
|
454
|
+
const statements = paramsStatement.find(n => n.name === "body");
|
|
453
455
|
|
|
454
456
|
if (statements != null) {
|
|
455
457
|
const expression = statements.toString();
|
|
@@ -43,7 +43,7 @@ describe("Options", () => {
|
|
|
43
43
|
cursor.next();
|
|
44
44
|
|
|
45
45
|
result = a.parse(cursor);
|
|
46
|
-
expected = new Node("
|
|
46
|
+
expected = new Node("options", "a-b", 0, 0, [
|
|
47
47
|
new Node("literal", "b", 0, 0, [], "B")
|
|
48
48
|
], "B");
|
|
49
49
|
});
|
|
@@ -76,7 +76,7 @@ describe("Options", () => {
|
|
|
76
76
|
test("Properties", () => {
|
|
77
77
|
const a = new Options("a", [new Literal("a", "A")]);
|
|
78
78
|
|
|
79
|
-
expect(a.type).toBe("
|
|
79
|
+
expect(a.type).toBe("options");
|
|
80
80
|
expect(a.name).toBe("a");
|
|
81
81
|
expect(a.parent).toBeNull();
|
|
82
82
|
expect(a.children[0].name).toBe("a");
|
package/src/patterns/Options.ts
CHANGED
|
@@ -48,8 +48,8 @@ export class Options implements Pattern {
|
|
|
48
48
|
const children = clonePatterns(options);
|
|
49
49
|
this._assignChildrenToParent(children);
|
|
50
50
|
|
|
51
|
-
this._id = `
|
|
52
|
-
this._type = "
|
|
51
|
+
this._id = `options-${idIndex++}`;
|
|
52
|
+
this._type = "options";
|
|
53
53
|
this._name = name;
|
|
54
54
|
this._parent = null;
|
|
55
55
|
this._children = children;
|