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/index.esm.js CHANGED
@@ -909,8 +909,8 @@ class Options {
909
909
  }
910
910
  const children = clonePatterns(options);
911
911
  this._assignChildrenToParent(children);
912
- this._id = `or-${idIndex$6++}`;
913
- this._type = "or";
912
+ this._id = `options-${idIndex$6++}`;
913
+ this._type = "options";
914
914
  this._name = name;
915
915
  this._parent = null;
916
916
  this._children = children;
@@ -2060,7 +2060,7 @@ const bodyLine = new Sequence("body-line", [
2060
2060
  bodyLineContent,
2061
2061
  optionalLineSpaces$2,
2062
2062
  ]);
2063
- const body = new Repeat("body", bodyLine, { divider: newLine$1, min: 0 });
2063
+ const body = new Optional("optional-body", new Repeat("body", bodyLine, { divider: newLine$1 }));
2064
2064
 
2065
2065
  const optionalSpaces$1 = new Optional("optional-spaces", allSpaces);
2066
2066
  const optionalLineSpaces$1 = new Optional("options-line-spaces", lineSpaces$1);
@@ -2095,7 +2095,7 @@ const withParamsStatement = new Optional("optional-with-params-statement", new S
2095
2095
  optionalLineSpaces$1,
2096
2096
  openBracket,
2097
2097
  optionalSpaces$1,
2098
- body.clone("with-params-body"),
2098
+ body,
2099
2099
  optionalSpaces$1,
2100
2100
  closeBracket
2101
2101
  ]));
@@ -2548,11 +2548,12 @@ class Grammar {
2548
2548
  return importBlock && importBlock.children.length > 0;
2549
2549
  }
2550
2550
  _buildPatterns(ast) {
2551
- const body = ast.find(n => n.name === "body");
2551
+ const body = ast.find(n => n.name === "body" && n.findAncester(n => n.name === "head") == null);
2552
2552
  if (body == null) {
2553
2553
  return;
2554
2554
  }
2555
- body.findAll(n => n.name === "assign-statement").forEach((n) => {
2555
+ const statements = body.findAll(n => n.name === "assign-statement");
2556
+ statements.forEach((n) => {
2556
2557
  const patternNode = n.children.find(n => patternNodes[n.name] != null);
2557
2558
  if (patternNode == null) {
2558
2559
  return;
@@ -2814,7 +2815,7 @@ class Grammar {
2814
2815
  let params = [];
2815
2816
  const paramsStatement = importStatement.find(n => n.name === "with-params-statement");
2816
2817
  if (paramsStatement != null) {
2817
- const statements = paramsStatement.find(n => n.name === "with-params-body");
2818
+ const statements = paramsStatement.find(n => n.name === "body");
2818
2819
  if (statements != null) {
2819
2820
  const expression = statements.toString();
2820
2821
  const importedValues = Array.from(this