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.js CHANGED
@@ -913,8 +913,8 @@ class Options {
913
913
  }
914
914
  const children = clonePatterns(options);
915
915
  this._assignChildrenToParent(children);
916
- this._id = `or-${idIndex$6++}`;
917
- this._type = "or";
916
+ this._id = `options-${idIndex$6++}`;
917
+ this._type = "options";
918
918
  this._name = name;
919
919
  this._parent = null;
920
920
  this._children = children;
@@ -2064,7 +2064,7 @@ const bodyLine = new Sequence("body-line", [
2064
2064
  bodyLineContent,
2065
2065
  optionalLineSpaces$2,
2066
2066
  ]);
2067
- const body = new Repeat("body", bodyLine, { divider: newLine$1, min: 0 });
2067
+ const body = new Optional("optional-body", new Repeat("body", bodyLine, { divider: newLine$1 }));
2068
2068
 
2069
2069
  const optionalSpaces$1 = new Optional("optional-spaces", allSpaces);
2070
2070
  const optionalLineSpaces$1 = new Optional("options-line-spaces", lineSpaces$1);
@@ -2099,7 +2099,7 @@ const withParamsStatement = new Optional("optional-with-params-statement", new S
2099
2099
  optionalLineSpaces$1,
2100
2100
  openBracket,
2101
2101
  optionalSpaces$1,
2102
- body.clone("with-params-body"),
2102
+ body,
2103
2103
  optionalSpaces$1,
2104
2104
  closeBracket
2105
2105
  ]));
@@ -2552,11 +2552,12 @@ class Grammar {
2552
2552
  return importBlock && importBlock.children.length > 0;
2553
2553
  }
2554
2554
  _buildPatterns(ast) {
2555
- const body = ast.find(n => n.name === "body");
2555
+ const body = ast.find(n => n.name === "body" && n.findAncester(n => n.name === "head") == null);
2556
2556
  if (body == null) {
2557
2557
  return;
2558
2558
  }
2559
- body.findAll(n => n.name === "assign-statement").forEach((n) => {
2559
+ const statements = body.findAll(n => n.name === "assign-statement");
2560
+ statements.forEach((n) => {
2560
2561
  const patternNode = n.children.find(n => patternNodes[n.name] != null);
2561
2562
  if (patternNode == null) {
2562
2563
  return;
@@ -2818,7 +2819,7 @@ class Grammar {
2818
2819
  let params = [];
2819
2820
  const paramsStatement = importStatement.find(n => n.name === "with-params-statement");
2820
2821
  if (paramsStatement != null) {
2821
- const statements = paramsStatement.find(n => n.name === "with-params-body");
2822
+ const statements = paramsStatement.find(n => n.name === "body");
2822
2823
  if (statements != null) {
2823
2824
  const expression = statements.toString();
2824
2825
  const importedValues = Array.from(this