@traqula/rules-sparql-1-1-adjust 0.0.3 → 0.0.5

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/lib/index.cjs CHANGED
@@ -29,7 +29,7 @@ module.exports = __toCommonJS(index_exports);
29
29
  var grammar_exports2 = {};
30
30
  __export(grammar_exports2, {
31
31
  builtInAdjust: () => builtInAdjust,
32
- existingBuildInCall: () => existingBuildInCall
32
+ builtInPatch: () => builtInPatch
33
33
  });
34
34
 
35
35
  // ../rules-sparql-1-1/lib/grammar/index.ts
@@ -215,6 +215,7 @@ __export(grammar_exports, {
215
215
  quads: () => quads,
216
216
  quadsNotTriples: () => quadsNotTriples,
217
217
  query: () => query,
218
+ queryOrUpdate: () => queryOrUpdate,
218
219
  queryUnit: () => queryUnit,
219
220
  rdfLiteral: () => rdfLiteral,
220
221
  regexExpression: () => regexExpression,
@@ -253,10 +254,10 @@ __export(grammar_exports, {
253
254
  whereClause: () => whereClause
254
255
  });
255
256
 
256
- // ../rules-sparql-1-1/lib/lexer/BuildinCalls.ts
257
- var BuildinCalls_exports = {};
258
- __export(BuildinCalls_exports, {
259
- BuildInCalls: () => BuildInCalls,
257
+ // ../rules-sparql-1-1/lib/lexer/BuiltInCalls.ts
258
+ var BuiltInCalls_exports = {};
259
+ __export(BuiltInCalls_exports, {
260
+ BuiltInCalls: () => BuiltInCalls,
260
261
  abs: () => abs,
261
262
  allBuiltInCalls: () => allBuiltInCalls,
262
263
  avg: () => avg,
@@ -649,10 +650,10 @@ var coreJsData = root_default["__core-js_shared__"];
649
650
  var coreJsData_default = coreJsData;
650
651
 
651
652
  // ../../node_modules/lodash-es/_isMasked.js
652
- var maskSrcKey = function() {
653
+ var maskSrcKey = (function() {
653
654
  var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
654
655
  return uid ? "Symbol(src)_1." + uid : "";
655
- }();
656
+ })();
656
657
  function isMasked(func) {
657
658
  return !!maskSrcKey && maskSrcKey in func;
658
659
  }
@@ -714,7 +715,7 @@ var WeakMap_default = WeakMap;
714
715
 
715
716
  // ../../node_modules/lodash-es/_baseCreate.js
716
717
  var objectCreate = Object.create;
717
- var baseCreate = /* @__PURE__ */ function() {
718
+ var baseCreate = /* @__PURE__ */ (function() {
718
719
  function object2() {
719
720
  }
720
721
  return function(proto) {
@@ -729,7 +730,7 @@ var baseCreate = /* @__PURE__ */ function() {
729
730
  object2.prototype = void 0;
730
731
  return result;
731
732
  };
732
- }();
733
+ })();
733
734
  var baseCreate_default = baseCreate;
734
735
 
735
736
  // ../../node_modules/lodash-es/_apply.js
@@ -794,14 +795,14 @@ function constant(value) {
794
795
  var constant_default = constant;
795
796
 
796
797
  // ../../node_modules/lodash-es/_defineProperty.js
797
- var defineProperty = function() {
798
+ var defineProperty = (function() {
798
799
  try {
799
800
  var func = getNative_default(Object, "defineProperty");
800
801
  func({}, "", {});
801
802
  return func;
802
803
  } catch (e) {
803
804
  }
804
- }();
805
+ })();
805
806
  var defineProperty_default = defineProperty;
806
807
 
807
808
  // ../../node_modules/lodash-es/_baseSetToString.js
@@ -1039,9 +1040,9 @@ var baseIsArguments_default = baseIsArguments;
1039
1040
  var objectProto6 = Object.prototype;
1040
1041
  var hasOwnProperty4 = objectProto6.hasOwnProperty;
1041
1042
  var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
1042
- var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
1043
+ var isArguments = baseIsArguments_default(/* @__PURE__ */ (function() {
1043
1044
  return arguments;
1044
- }()) ? baseIsArguments_default : function(value) {
1045
+ })()) ? baseIsArguments_default : function(value) {
1045
1046
  return isObjectLike_default(value) && hasOwnProperty4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
1046
1047
  };
1047
1048
  var isArguments_default = isArguments;
@@ -1107,7 +1108,7 @@ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType &&
1107
1108
  var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
1108
1109
  var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
1109
1110
  var freeProcess = moduleExports2 && freeGlobal_default.process;
1110
- var nodeUtil = function() {
1111
+ var nodeUtil = (function() {
1111
1112
  try {
1112
1113
  var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
1113
1114
  if (types) {
@@ -1116,7 +1117,7 @@ var nodeUtil = function() {
1116
1117
  return freeProcess && freeProcess.binding && freeProcess.binding("util");
1117
1118
  } catch (e) {
1118
1119
  }
1119
- }();
1120
+ })();
1120
1121
  var nodeUtil_default = nodeUtil;
1121
1122
 
1122
1123
  // ../../node_modules/lodash-es/isTypedArray.js
@@ -9661,6 +9662,7 @@ applyMixins(Parser, [
9661
9662
 
9662
9663
  // ../core/lib/lexer-builder/LexerBuilder.ts
9663
9664
  var LexerBuilder = class _LexerBuilder {
9665
+ tokens;
9664
9666
  static create(starter) {
9665
9667
  return new _LexerBuilder(starter);
9666
9668
  }
@@ -9818,71 +9820,71 @@ var Transformer = class {
9818
9820
  }
9819
9821
  };
9820
9822
 
9821
- // ../rules-sparql-1-1/lib/lexer/BuildinCalls.ts
9822
- var BuildInCalls = /* @__PURE__ */ ((BuildInCalls2) => {
9823
- BuildInCalls2["Str"] = "builtInStr";
9824
- BuildInCalls2["Lang"] = "builtInLang";
9825
- BuildInCalls2["Langmatches"] = "builtInLangmatches";
9826
- BuildInCalls2["Datatype"] = "builtInDatatype";
9827
- BuildInCalls2["Bound"] = "builtInBound";
9828
- BuildInCalls2["Iri"] = "builtInIri";
9829
- BuildInCalls2["Uri"] = "builtInUri";
9830
- BuildInCalls2["Bnode"] = "builtInBnode";
9831
- BuildInCalls2["Rand"] = "builtInRand";
9832
- BuildInCalls2["Abs"] = "builtInAbs";
9833
- BuildInCalls2["Ceil"] = "builtInCeil";
9834
- BuildInCalls2["Floor"] = "builtInFloor";
9835
- BuildInCalls2["Round"] = "builtInRound";
9836
- BuildInCalls2["Concat"] = "builtInConcat";
9837
- BuildInCalls2["Strlen"] = "builtInStrlen";
9838
- BuildInCalls2["Ucase"] = "builtInUcase";
9839
- BuildInCalls2["Lcase"] = "builtInLcase";
9840
- BuildInCalls2["Encode_for_uri"] = "builtInEncode_for_uri";
9841
- BuildInCalls2["Contains"] = "builtInContains";
9842
- BuildInCalls2["Strstarts"] = "builtInStrstarts";
9843
- BuildInCalls2["Strends"] = "builtInStrends";
9844
- BuildInCalls2["Strbefore"] = "builtInStrbefore";
9845
- BuildInCalls2["Strafter"] = "builtInStrafter";
9846
- BuildInCalls2["Year"] = "builtInYear";
9847
- BuildInCalls2["Month"] = "builtInMonth";
9848
- BuildInCalls2["Day"] = "builtInDay";
9849
- BuildInCalls2["Hours"] = "builtInHours";
9850
- BuildInCalls2["Minutes"] = "builtInMinutes";
9851
- BuildInCalls2["Seconds"] = "builtInSeconds";
9852
- BuildInCalls2["Timezone"] = "builtInTimezone";
9853
- BuildInCalls2["Tz"] = "builtInTz";
9854
- BuildInCalls2["Now"] = "builtInNow";
9855
- BuildInCalls2["Uuid"] = "builtInUuid";
9856
- BuildInCalls2["Struuid"] = "builtInStruuid";
9857
- BuildInCalls2["Md5"] = "builtInMd5";
9858
- BuildInCalls2["Sha1"] = "builtInSha1";
9859
- BuildInCalls2["Sha256"] = "builtInSha256";
9860
- BuildInCalls2["Sha384"] = "builtInSha384";
9861
- BuildInCalls2["Sha512"] = "builtInSha512";
9862
- BuildInCalls2["Coalesce"] = "builtInCoalesce";
9863
- BuildInCalls2["If"] = "builtInIf";
9864
- BuildInCalls2["Strlang"] = "builtInStrlang";
9865
- BuildInCalls2["Strdt"] = "builtInStrdt";
9866
- BuildInCalls2["Sameterm"] = "builtInSameterm";
9867
- BuildInCalls2["Isiri"] = "builtInIsiri";
9868
- BuildInCalls2["Isuri"] = "builtInIsuri";
9869
- BuildInCalls2["Isblank"] = "builtInIsblank";
9870
- BuildInCalls2["Isliteral"] = "builtInIsliteral";
9871
- BuildInCalls2["Isnumeric"] = "builtInIsnumeric";
9872
- BuildInCalls2["Regex"] = "builtInRegex";
9873
- BuildInCalls2["Substr"] = "builtInSubstr";
9874
- BuildInCalls2["Replace"] = "builtInReplace";
9875
- BuildInCalls2["Exists"] = "builtInExists";
9876
- BuildInCalls2["Notexists"] = "builtInNotexists";
9877
- BuildInCalls2["Count"] = "builtInCount";
9878
- BuildInCalls2["Sum"] = "builtInSum";
9879
- BuildInCalls2["Min"] = "builtInMin";
9880
- BuildInCalls2["Max"] = "builtInMax";
9881
- BuildInCalls2["Avg"] = "builtInAvg";
9882
- BuildInCalls2["Sample"] = "builtInSample";
9883
- BuildInCalls2["Group_concat"] = "builtInGroup_concat";
9884
- return BuildInCalls2;
9885
- })(BuildInCalls || {});
9823
+ // ../rules-sparql-1-1/lib/lexer/BuiltInCalls.ts
9824
+ var BuiltInCalls = /* @__PURE__ */ ((BuiltInCalls2) => {
9825
+ BuiltInCalls2["Str"] = "builtInStr";
9826
+ BuiltInCalls2["Lang"] = "builtInLang";
9827
+ BuiltInCalls2["Langmatches"] = "builtInLangmatches";
9828
+ BuiltInCalls2["Datatype"] = "builtInDatatype";
9829
+ BuiltInCalls2["Bound"] = "builtInBound";
9830
+ BuiltInCalls2["Iri"] = "builtInIri";
9831
+ BuiltInCalls2["Uri"] = "builtInUri";
9832
+ BuiltInCalls2["Bnode"] = "builtInBnode";
9833
+ BuiltInCalls2["Rand"] = "builtInRand";
9834
+ BuiltInCalls2["Abs"] = "builtInAbs";
9835
+ BuiltInCalls2["Ceil"] = "builtInCeil";
9836
+ BuiltInCalls2["Floor"] = "builtInFloor";
9837
+ BuiltInCalls2["Round"] = "builtInRound";
9838
+ BuiltInCalls2["Concat"] = "builtInConcat";
9839
+ BuiltInCalls2["Strlen"] = "builtInStrlen";
9840
+ BuiltInCalls2["Ucase"] = "builtInUcase";
9841
+ BuiltInCalls2["Lcase"] = "builtInLcase";
9842
+ BuiltInCalls2["Encode_for_uri"] = "builtInEncode_for_uri";
9843
+ BuiltInCalls2["Contains"] = "builtInContains";
9844
+ BuiltInCalls2["Strstarts"] = "builtInStrstarts";
9845
+ BuiltInCalls2["Strends"] = "builtInStrends";
9846
+ BuiltInCalls2["Strbefore"] = "builtInStrbefore";
9847
+ BuiltInCalls2["Strafter"] = "builtInStrafter";
9848
+ BuiltInCalls2["Year"] = "builtInYear";
9849
+ BuiltInCalls2["Month"] = "builtInMonth";
9850
+ BuiltInCalls2["Day"] = "builtInDay";
9851
+ BuiltInCalls2["Hours"] = "builtInHours";
9852
+ BuiltInCalls2["Minutes"] = "builtInMinutes";
9853
+ BuiltInCalls2["Seconds"] = "builtInSeconds";
9854
+ BuiltInCalls2["Timezone"] = "builtInTimezone";
9855
+ BuiltInCalls2["Tz"] = "builtInTz";
9856
+ BuiltInCalls2["Now"] = "builtInNow";
9857
+ BuiltInCalls2["Uuid"] = "builtInUuid";
9858
+ BuiltInCalls2["Struuid"] = "builtInStruuid";
9859
+ BuiltInCalls2["Md5"] = "builtInMd5";
9860
+ BuiltInCalls2["Sha1"] = "builtInSha1";
9861
+ BuiltInCalls2["Sha256"] = "builtInSha256";
9862
+ BuiltInCalls2["Sha384"] = "builtInSha384";
9863
+ BuiltInCalls2["Sha512"] = "builtInSha512";
9864
+ BuiltInCalls2["Coalesce"] = "builtInCoalesce";
9865
+ BuiltInCalls2["If"] = "builtInIf";
9866
+ BuiltInCalls2["Strlang"] = "builtInStrlang";
9867
+ BuiltInCalls2["Strdt"] = "builtInStrdt";
9868
+ BuiltInCalls2["Sameterm"] = "builtInSameterm";
9869
+ BuiltInCalls2["Isiri"] = "builtInIsiri";
9870
+ BuiltInCalls2["Isuri"] = "builtInIsuri";
9871
+ BuiltInCalls2["Isblank"] = "builtInIsblank";
9872
+ BuiltInCalls2["Isliteral"] = "builtInIsliteral";
9873
+ BuiltInCalls2["Isnumeric"] = "builtInIsnumeric";
9874
+ BuiltInCalls2["Regex"] = "builtInRegex";
9875
+ BuiltInCalls2["Substr"] = "builtInSubstr";
9876
+ BuiltInCalls2["Replace"] = "builtInReplace";
9877
+ BuiltInCalls2["Exists"] = "builtInExists";
9878
+ BuiltInCalls2["Notexists"] = "builtInNotexists";
9879
+ BuiltInCalls2["Count"] = "builtInCount";
9880
+ BuiltInCalls2["Sum"] = "builtInSum";
9881
+ BuiltInCalls2["Min"] = "builtInMin";
9882
+ BuiltInCalls2["Max"] = "builtInMax";
9883
+ BuiltInCalls2["Avg"] = "builtInAvg";
9884
+ BuiltInCalls2["Sample"] = "builtInSample";
9885
+ BuiltInCalls2["Group_concat"] = "builtInGroup_concat";
9886
+ return BuiltInCalls2;
9887
+ })(BuiltInCalls || {});
9886
9888
  function capitalize(string2) {
9887
9889
  return string2.charAt(0).toUpperCase() + string2.slice(1);
9888
9890
  }
@@ -10386,7 +10388,7 @@ var allBaseTokens = LexerBuilder.create().add(
10386
10388
  notIn,
10387
10389
  separator
10388
10390
  );
10389
- var sparql11Tokens = LexerBuilder.create(allTerminals).merge(allBaseTokens).merge(allBuiltInCalls).merge(allGraphTokens).merge(allSymbols).moveBefore(datatype, dataClause).moveAfter(avg, a).moveBefore(a, graphAll).moveAfter(groupConcat, groupByGroup);
10391
+ var sparql11LexerBuilder = LexerBuilder.create(allTerminals).merge(allBaseTokens).merge(allBuiltInCalls).merge(allGraphTokens).merge(allSymbols).moveBefore(datatype, dataClause).moveAfter(avg, a).moveBefore(a, graphAll).moveAfter(groupConcat, groupByGroup);
10390
10392
 
10391
10393
  // ../rules-sparql-1-1/lib/factoryMixins/ContextFactory.ts
10392
10394
  var nodeType = "contextDef";
@@ -10831,10 +10833,7 @@ function SolutionModifiersFactoryMixin(Base) {
10831
10833
  var nodeType8 = "term";
10832
10834
  function TermFactoryMixin(Base) {
10833
10835
  return class TermFactory extends Base {
10834
- constructor() {
10835
- super(...arguments);
10836
- this.__blankNodeCounter = 0;
10837
- }
10836
+ __blankNodeCounter = 0;
10838
10837
  resetBlankNodeCounter() {
10839
10838
  this.__blankNodeCounter = 0;
10840
10839
  }
@@ -11337,7 +11336,7 @@ function stringEscapedLexical(str2) {
11337
11336
  var rdfLiteral = {
11338
11337
  name: "rdfLiteral",
11339
11338
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION, OR }) => (C) => {
11340
- const value = SUBRULE1(string, void 0);
11339
+ const value = SUBRULE1(string);
11341
11340
  return OPTION(() => OR([
11342
11341
  { ALT: () => {
11343
11342
  const lang2 = CONSUME(terminals_exports.langTag);
@@ -11349,7 +11348,7 @@ var rdfLiteral = {
11349
11348
  } },
11350
11349
  { ALT: () => {
11351
11350
  CONSUME(symbols_exports.hathat);
11352
- const iriVal = SUBRULE1(iri2, void 0);
11351
+ const iriVal = SUBRULE1(iri2);
11353
11352
  return ACTION(() => C.factory.literalTerm(
11354
11353
  C.factory.sourceLocation(value, iriVal),
11355
11354
  value.value,
@@ -11365,7 +11364,7 @@ var rdfLiteral = {
11365
11364
  factory.printFilter(ast, () => PRINT("@", ast.langOrIri));
11366
11365
  } else {
11367
11366
  factory.printFilter(ast, () => PRINT("^^"));
11368
- SUBRULE(iri2, ast.langOrIri, void 0);
11367
+ SUBRULE(iri2, ast.langOrIri);
11369
11368
  }
11370
11369
  }
11371
11370
  }
@@ -11373,9 +11372,9 @@ var rdfLiteral = {
11373
11372
  var numericLiteral = {
11374
11373
  name: "numericLiteral",
11375
11374
  impl: ({ SUBRULE, OR }) => () => OR([
11376
- { ALT: () => SUBRULE(numericLiteralUnsigned, void 0) },
11377
- { ALT: () => SUBRULE(numericLiteralPositive, void 0) },
11378
- { ALT: () => SUBRULE(numericLiteralNegative, void 0) }
11375
+ { ALT: () => SUBRULE(numericLiteralUnsigned) },
11376
+ { ALT: () => SUBRULE(numericLiteralPositive) },
11377
+ { ALT: () => SUBRULE(numericLiteralNegative) }
11379
11378
  ])
11380
11379
  };
11381
11380
  var numericLiteralUnsigned = {
@@ -11483,10 +11482,10 @@ var string = {
11483
11482
  var iri2 = {
11484
11483
  name: "iri",
11485
11484
  impl: ({ SUBRULE, OR }) => () => OR([
11486
- { ALT: () => SUBRULE(iriFull, void 0) },
11487
- { ALT: () => SUBRULE(prefixedName, void 0) }
11485
+ { ALT: () => SUBRULE(iriFull) },
11486
+ { ALT: () => SUBRULE(prefixedName) }
11488
11487
  ]),
11489
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast, void 0) : SUBRULE(iriFull, ast, void 0)
11488
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast) : SUBRULE(iriFull, ast)
11490
11489
  };
11491
11490
  var iriFull = {
11492
11491
  name: "iriFull",
@@ -11550,93 +11549,25 @@ var verbA = {
11550
11549
  }
11551
11550
  };
11552
11551
 
11553
- // ../rules-sparql-1-1/lib/grammar/dataSetClause.ts
11554
- function datasetClauseUsing(name, token) {
11555
- return {
11556
- name,
11557
- impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
11558
- const start = CONSUME(token);
11559
- return OR([
11560
- { ALT: () => {
11561
- const iri3 = SUBRULE(defaultGraphClause, void 0);
11562
- return ACTION(() => C.factory.wrap({ clauseType: "default", value: iri3 }, C.factory.sourceLocation(start, iri3)));
11563
- } },
11564
- { ALT: () => {
11565
- const namedClause = SUBRULE(namedGraphClause, void 0);
11566
- return ACTION(() => C.factory.wrap({
11567
- clauseType: "named",
11568
- value: namedClause.val
11569
- }, C.factory.sourceLocation(start, namedClause)));
11570
- } }
11571
- ]);
11572
- }
11573
- };
11574
- }
11575
- var datasetClause = datasetClauseUsing("datasetClause", from);
11576
- var defaultGraphClause = {
11577
- name: "defaultGraphClause",
11578
- impl: ({ SUBRULE }) => () => SUBRULE(sourceSelector, void 0)
11579
- };
11580
- var usingClause2 = datasetClauseUsing("usingClause", usingClause);
11581
- function datasetClauseUsingStar(name, subRule, fromUsing) {
11582
- return {
11583
- name,
11584
- impl: ({ ACTION, MANY, SUBRULE }) => (C) => {
11585
- const clauses = [];
11586
- MANY(() => {
11587
- const clause = SUBRULE(subRule, void 0);
11588
- clauses.push(clause);
11589
- });
11590
- return ACTION(() => C.factory.datasetClauses(
11591
- clauses.map((clause) => clause.val),
11592
- C.factory.sourceLocation(...clauses)
11593
- ));
11594
- },
11595
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11596
- for (const clause of ast.clauses) {
11597
- F2.printFilter(ast, () => PRINT_WORD(fromUsing));
11598
- if (clause.clauseType === "named") {
11599
- F2.printFilter(ast, () => PRINT_WORD("NAMED"));
11600
- }
11601
- SUBRULE(iri2, clause.value, void 0);
11602
- }
11603
- }
11604
- };
11605
- }
11606
- var datasetClauseStar = datasetClauseUsingStar("datasetClauses", datasetClause, "FROM");
11607
- var usingClauseStar = datasetClauseUsingStar("usingClauses", usingClause2, "USING");
11608
- var namedGraphClause = {
11609
- name: "namedGraphClause",
11610
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11611
- const named2 = CONSUME(graph_exports.named);
11612
- const iri3 = SUBRULE(sourceSelector, void 0);
11613
- return ACTION(() => C.factory.wrap(iri3, C.factory.sourceLocation(named2, iri3)));
11614
- }
11615
- };
11616
- var sourceSelector = {
11617
- name: "sourceSelector",
11618
- impl: ({ SUBRULE }) => () => SUBRULE(iri2, void 0)
11619
- };
11620
-
11621
11552
  // ../rules-sparql-1-1/lib/grammar/general.ts
11622
11553
  var prologue = {
11623
11554
  name: "prologue",
11624
11555
  impl: ({ SUBRULE, MANY, OR }) => () => {
11625
11556
  const result = [];
11626
11557
  MANY(() => OR([
11627
- { ALT: () => result.push(SUBRULE(baseDecl2, void 0)) },
11558
+ { ALT: () => result.push(SUBRULE(baseDecl2)) },
11628
11559
  // TODO: the [spec](https://www.w3.org/TR/sparql11-query/#iriRefs) says you cannot redefine prefixes.
11629
11560
  // We might need to check this.
11630
- { ALT: () => result.push(SUBRULE(prefixDecl2, void 0)) }
11561
+ { ALT: () => result.push(SUBRULE(prefixDecl2)) }
11631
11562
  ]));
11632
11563
  return result;
11633
11564
  },
11634
11565
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11635
11566
  for (const context of ast) {
11636
11567
  if (F2.isContextDefinitionBase(context)) {
11637
- SUBRULE(baseDecl2, context, void 0);
11568
+ SUBRULE(baseDecl2, context);
11638
11569
  } else if (F2.isContextDefinitionPrefix(context)) {
11639
- SUBRULE(prefixDecl2, context, void 0);
11570
+ SUBRULE(prefixDecl2, context);
11640
11571
  }
11641
11572
  }
11642
11573
  }
@@ -11645,12 +11576,12 @@ var baseDecl2 = {
11645
11576
  name: "baseDecl",
11646
11577
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11647
11578
  const base = CONSUME(baseDecl);
11648
- const val = SUBRULE(iriFull, void 0);
11579
+ const val = SUBRULE(iriFull);
11649
11580
  return ACTION(() => C.factory.contextDefinitionBase(C.factory.sourceLocation(base, val), val));
11650
11581
  },
11651
11582
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11652
11583
  F2.printFilter(ast, () => PRINT_WORD("BASE"));
11653
- SUBRULE(iri2, ast.value, void 0);
11584
+ SUBRULE(iri2, ast.value);
11654
11585
  }
11655
11586
  };
11656
11587
  var prefixDecl2 = {
@@ -11658,41 +11589,41 @@ var prefixDecl2 = {
11658
11589
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11659
11590
  const prefix = CONSUME(prefixDecl);
11660
11591
  const name = CONSUME(terminals_exports.pNameNs).image.slice(0, -1);
11661
- const value = SUBRULE(iriFull, void 0);
11592
+ const value = SUBRULE(iriFull);
11662
11593
  return ACTION(() => C.factory.contextDefinitionPrefix(C.factory.sourceLocation(prefix, value), name, value));
11663
11594
  },
11664
11595
  gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { factory: F2 }) => {
11665
11596
  F2.printFilter(ast, () => {
11666
11597
  PRINT_WORDS("PREFIX", `${ast.key}:`);
11667
11598
  });
11668
- SUBRULE(iri2, ast.value, void 0);
11599
+ SUBRULE(iri2, ast.value);
11669
11600
  }
11670
11601
  };
11671
11602
  var verb = {
11672
11603
  name: "verb",
11673
11604
  impl: ({ SUBRULE, OR }) => () => OR([
11674
- { ALT: () => SUBRULE(varOrIri, void 0) },
11675
- { ALT: () => SUBRULE(verbA, void 0) }
11605
+ { ALT: () => SUBRULE(varOrIri) },
11606
+ { ALT: () => SUBRULE(verbA) }
11676
11607
  ])
11677
11608
  };
11678
11609
  var varOrTerm = {
11679
11610
  name: "varOrTerm",
11680
11611
  impl: ({ SUBRULE, OR }) => (C) => OR([
11681
- { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_, void 0) },
11682
- { ALT: () => SUBRULE(graphTerm, void 0) }
11612
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
11613
+ { ALT: () => SUBRULE(graphTerm) }
11683
11614
  ]),
11684
11615
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11685
11616
  if (F2.isTermVariable(ast)) {
11686
- return SUBRULE(var_, ast, void 0);
11617
+ return SUBRULE(var_, ast);
11687
11618
  }
11688
- return SUBRULE(graphTerm, ast, void 0);
11619
+ return SUBRULE(graphTerm, ast);
11689
11620
  }
11690
11621
  };
11691
11622
  var varOrIri = {
11692
11623
  name: "varOrIri",
11693
11624
  impl: ({ SUBRULE, OR }) => (C) => OR([
11694
- { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_, void 0) },
11695
- { ALT: () => SUBRULE(iri2, void 0) }
11625
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
11626
+ { ALT: () => SUBRULE(iri2) }
11696
11627
  ])
11697
11628
  };
11698
11629
  var var_ = {
@@ -11711,11 +11642,11 @@ var var_ = {
11711
11642
  var graphTerm = {
11712
11643
  name: "graphTerm",
11713
11644
  impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => OR([
11714
- { ALT: () => SUBRULE(iri2, void 0) },
11715
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
11716
- { ALT: () => SUBRULE(numericLiteral, void 0) },
11717
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
11718
- { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode, void 0) },
11645
+ { ALT: () => SUBRULE(iri2) },
11646
+ { ALT: () => SUBRULE(rdfLiteral) },
11647
+ { ALT: () => SUBRULE(numericLiteral) },
11648
+ { ALT: () => SUBRULE(booleanLiteral) },
11649
+ { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
11719
11650
  { ALT: () => {
11720
11651
  const tokenNil = CONSUME(terminals_exports.nil);
11721
11652
  return ACTION(() => C.factory.namedNode(C.factory.sourceLocation(tokenNil), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */));
@@ -11723,1275 +11654,1344 @@ var graphTerm = {
11723
11654
  ]),
11724
11655
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11725
11656
  if (F2.isTermNamed(ast)) {
11726
- SUBRULE(iri2, ast, void 0);
11657
+ SUBRULE(iri2, ast);
11727
11658
  } else if (F2.isTermLiteral(ast)) {
11728
- SUBRULE(rdfLiteral, ast, void 0);
11659
+ SUBRULE(rdfLiteral, ast);
11729
11660
  } else if (F2.isTermBlank(ast)) {
11730
- SUBRULE(blankNode, ast, void 0);
11661
+ SUBRULE(blankNode, ast);
11731
11662
  }
11732
11663
  }
11733
11664
  };
11734
11665
 
11735
- // ../rules-sparql-1-1/lib/grammar/propertyPaths.ts
11736
- var path = {
11737
- name: "path",
11738
- impl: ({ SUBRULE }) => () => SUBRULE(pathAlternative, void 0)
11739
- };
11740
- var pathGenerator = {
11741
- name: "path",
11742
- gImpl: ({ PRINT, SUBRULE }) => (ast, { factory: F2 }, braces = true) => {
11743
- if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
11744
- SUBRULE(iri2, ast, void 0);
11745
- } else {
11746
- F2.printFilter(ast, () => braces && PRINT("("));
11747
- switch (ast.subType) {
11748
- case "|":
11749
- case "/": {
11750
- const [head2, ...tail] = ast.items;
11751
- SUBRULE(pathGenerator, head2, braces);
11752
- for (const val of tail) {
11753
- F2.printFilter(ast, () => PRINT(ast.subType));
11754
- SUBRULE(pathGenerator, val, braces);
11755
- }
11756
- break;
11757
- }
11758
- case "^":
11759
- F2.printFilter(ast, () => PRINT("^"));
11760
- SUBRULE(pathGenerator, ast.items[0], braces);
11761
- break;
11762
- case "?":
11763
- case "*":
11764
- case "+":
11765
- SUBRULE(pathGenerator, ast.items[0], braces);
11766
- F2.printFilter(ast, () => PRINT(ast.subType));
11767
- break;
11768
- case "!":
11769
- F2.printFilter(ast, () => PRINT("!"));
11770
- F2.printFilter(ast, () => PRINT("("));
11771
- SUBRULE(pathGenerator, ast.items[0], false);
11772
- F2.printFilter(ast, () => PRINT(")"));
11773
- break;
11774
- }
11775
- F2.printFilter(ast, () => braces && PRINT(")"));
11666
+ // ../rules-sparql-1-1/lib/grammar/dataSetClause.ts
11667
+ function datasetClauseUsing(name, token) {
11668
+ return {
11669
+ name,
11670
+ impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
11671
+ const start = CONSUME(token);
11672
+ return OR([
11673
+ { ALT: () => {
11674
+ const iri3 = SUBRULE(defaultGraphClause);
11675
+ return ACTION(() => C.factory.wrap({ clauseType: "default", value: iri3 }, C.factory.sourceLocation(start, iri3)));
11676
+ } },
11677
+ { ALT: () => {
11678
+ const namedClause = SUBRULE(namedGraphClause);
11679
+ return ACTION(() => C.factory.wrap({
11680
+ clauseType: "named",
11681
+ value: namedClause.val
11682
+ }, C.factory.sourceLocation(start, namedClause)));
11683
+ } }
11684
+ ]);
11776
11685
  }
11777
- }
11686
+ };
11687
+ }
11688
+ var datasetClause = datasetClauseUsing("datasetClause", from);
11689
+ var defaultGraphClause = {
11690
+ name: "defaultGraphClause",
11691
+ impl: ({ SUBRULE }) => () => SUBRULE(sourceSelector)
11778
11692
  };
11779
- function pathChainHelper(name, SEP, subType, subRule) {
11693
+ var usingClause2 = datasetClauseUsing("usingClause", usingClause);
11694
+ function datasetClauseUsingStar(name, subRule, fromUsing) {
11780
11695
  return {
11781
11696
  name,
11782
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, MANY }) => (C) => {
11783
- const head2 = SUBRULE1(subRule, void 0);
11784
- let tailEnd = head2;
11785
- const tail = [];
11697
+ impl: ({ ACTION, MANY, SUBRULE }) => (C) => {
11698
+ const clauses = [];
11786
11699
  MANY(() => {
11787
- CONSUME(SEP);
11788
- tailEnd = SUBRULE2(subRule, void 0);
11789
- tail.push(tailEnd);
11700
+ const clause = SUBRULE(subRule);
11701
+ clauses.push(clause);
11790
11702
  });
11791
- return ACTION(() => tail.length === 0 ? head2 : C.factory.path(subType, [head2, ...tail], C.factory.sourceLocation(head2, tailEnd)));
11703
+ return ACTION(() => C.factory.datasetClauses(
11704
+ clauses.map((clause) => clause.val),
11705
+ C.factory.sourceLocation(...clauses)
11706
+ ));
11707
+ },
11708
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11709
+ for (const clause of ast.clauses) {
11710
+ F2.printFilter(ast, () => PRINT_WORD(fromUsing));
11711
+ if (clause.clauseType === "named") {
11712
+ F2.printFilter(ast, () => PRINT_WORD("NAMED"));
11713
+ }
11714
+ SUBRULE(iri2, clause.value);
11715
+ }
11792
11716
  }
11793
11717
  };
11794
11718
  }
11795
- var pathEltOrInverse = {
11796
- name: "pathEltOrInverse",
11797
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR }) => (C) => OR([
11798
- { ALT: () => SUBRULE1(pathElt, void 0) },
11799
- { ALT: () => {
11800
- const hat2 = CONSUME(symbols_exports.hat);
11801
- const item = SUBRULE2(pathElt, void 0);
11802
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
11803
- } }
11804
- ])
11805
- };
11806
- var pathSequence = pathChainHelper("pathSequence", symbols_exports.slash, "/", pathEltOrInverse);
11807
- var pathAlternative = pathChainHelper("pathAlternative", symbols_exports.pipe, "|", pathSequence);
11808
- var pathElt = {
11809
- name: "pathElt",
11810
- impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
11811
- const item = SUBRULE(pathPrimary, void 0);
11812
- const modification = OPTION(() => SUBRULE(pathMod, void 0));
11813
- return ACTION(() => modification === void 0 ? item : C.factory.path(modification.image, [item], C.factory.sourceLocation(item, modification)));
11814
- }
11815
- };
11816
- var pathMod = {
11817
- name: "pathMod",
11818
- impl: ({ CONSUME, OR }) => () => OR([
11819
- { ALT: () => CONSUME(symbols_exports.question) },
11820
- { ALT: () => CONSUME(symbols_exports.star) },
11821
- { ALT: () => CONSUME(symbols_exports.opPlus) }
11822
- ])
11823
- };
11824
- var pathPrimary = {
11825
- name: "pathPrimary",
11826
- impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
11827
- { ALT: () => SUBRULE(iri2, void 0) },
11828
- { ALT: () => SUBRULE(verbA, void 0) },
11829
- { ALT: () => SUBRULE(pathNegatedPropertySet, void 0) },
11830
- { ALT: () => {
11831
- CONSUME(symbols_exports.LParen);
11832
- const resRecursive = SUBRULE(path, void 0);
11833
- CONSUME(symbols_exports.RParen);
11834
- return resRecursive;
11835
- } }
11836
- ])
11837
- };
11838
- var pathNegatedPropertySet = {
11839
- name: "pathNegatedPropertySet",
11840
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, OR, MANY }) => (C) => {
11841
- const exclamation2 = CONSUME(symbols_exports.exclamation);
11842
- return OR([
11843
- { ALT: () => {
11844
- const noAlternative = SUBRULE1(pathOneInPropertySet, void 0);
11845
- return ACTION(() => C.factory.path("!", [noAlternative], C.factory.sourceLocation(exclamation2, noAlternative)));
11846
- } },
11847
- { ALT: () => {
11848
- const open = CONSUME(symbols_exports.LParen);
11849
- const head2 = SUBRULE2(pathOneInPropertySet, void 0);
11850
- const tail = [];
11851
- MANY(() => {
11852
- CONSUME(symbols_exports.pipe);
11853
- const item = SUBRULE3(pathOneInPropertySet, void 0);
11854
- tail.push(item);
11855
- });
11856
- const close = CONSUME(symbols_exports.RParen);
11857
- return ACTION(() => {
11858
- const F2 = C.factory;
11859
- if (tail.length === 0) {
11860
- return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
11861
- }
11862
- return F2.path(
11863
- "!",
11864
- [F2.path("|", [head2, ...tail], F2.sourceLocation(open, close))],
11865
- F2.sourceLocation(exclamation2, close)
11866
- );
11867
- });
11868
- } }
11869
- ]);
11719
+ var datasetClauseStar = datasetClauseUsingStar("datasetClauses", datasetClause, "FROM");
11720
+ var usingClauseStar = datasetClauseUsingStar("usingClauses", usingClause2, "USING");
11721
+ var namedGraphClause = {
11722
+ name: "namedGraphClause",
11723
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11724
+ const named2 = CONSUME(graph_exports.named);
11725
+ const iri3 = SUBRULE(sourceSelector);
11726
+ return ACTION(() => C.factory.wrap(iri3, C.factory.sourceLocation(named2, iri3)));
11870
11727
  }
11871
11728
  };
11872
- var pathOneInPropertySet = {
11873
- name: "pathOneInPropertySet",
11874
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
11875
- { ALT: () => SUBRULE1(iri2, void 0) },
11876
- { ALT: () => SUBRULE1(verbA, void 0) },
11877
- { ALT: () => {
11878
- const hat2 = CONSUME(symbols_exports.hat);
11879
- const item = OR2([
11880
- { ALT: () => SUBRULE2(iri2, void 0) },
11881
- { ALT: () => SUBRULE2(verbA, void 0) }
11882
- ]);
11883
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
11884
- } }
11885
- ])
11729
+ var sourceSelector = {
11730
+ name: "sourceSelector",
11731
+ impl: ({ SUBRULE }) => () => SUBRULE(iri2)
11886
11732
  };
11887
11733
 
11888
- // ../rules-sparql-1-1/lib/grammar/tripleBlock.ts
11889
- function triplesDotSeperated(triplesSameSubjectSubrule) {
11890
- return ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME, OPTION }) => (C) => {
11891
- const triples = [];
11892
- let parsedDot = true;
11893
- let dotToken;
11894
- AT_LEAST_ONE({
11895
- GATE: () => parsedDot,
11896
- DEF: () => {
11897
- parsedDot = false;
11898
- const template = SUBRULE(triplesSameSubjectSubrule, void 0);
11899
- ACTION(() => {
11900
- triples.push(...template);
11901
- });
11902
- OPTION(() => {
11903
- dotToken = CONSUME(symbols_exports.dot);
11904
- parsedDot = true;
11905
- });
11906
- }
11907
- });
11908
- return ACTION(() => C.factory.patternBgp(triples, C.factory.sourceLocation(...triples, dotToken)));
11909
- };
11910
- }
11911
- var triplesBlock = {
11912
- name: "triplesBlock",
11913
- impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C, void 0),
11914
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
11915
- for (const [index, triple] of ast.triples.entries()) {
11916
- HANDLE_LOC(triple, () => {
11917
- const nextTriple = ast.triples.at(index);
11918
- if (F2.isTripleCollection(triple)) {
11919
- SUBRULE(graphNodePath, triple, void 0);
11920
- F2.printFilter(triple, () => PRINT_WORD("."));
11921
- } else {
11922
- SUBRULE(graphNodePath, triple.subject, void 0);
11923
- if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
11924
- SUBRULE(varOrTerm, triple.predicate, void 0);
11925
- } else {
11926
- SUBRULE(pathGenerator, triple.predicate, void 0);
11927
- }
11928
- SUBRULE(graphNodePath, triple.object, void 0);
11929
- if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
11930
- F2.printFilter(ast, () => PRINT_WORD("."));
11931
- } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
11932
- F2.printFilter(ast, () => PRINT_WORD(","));
11933
- } else {
11934
- F2.printFilter(ast, () => PRINT_WORD(";"));
11935
- }
11936
- }
11937
- });
11938
- }
11939
- }
11940
- };
11941
- function triplesSameSubjectImpl(name, allowPaths) {
11734
+ // ../rules-sparql-1-1/lib/expressionHelpers.ts
11735
+ function funcExpr1(func) {
11942
11736
  return {
11943
- name,
11944
- impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
11945
- { ALT: () => {
11946
- const subject = SUBRULE(varOrTerm, void 0);
11947
- const res = SUBRULE(
11948
- allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty,
11949
- { subject: ACTION(() => C.factory.dematerialized(subject)) }
11950
- );
11951
- return ACTION(() => {
11952
- if (res.length > 0) {
11953
- res[0].subject = subject;
11954
- res[0].loc = C.factory.sourceLocation(subject, res[0]);
11955
- }
11956
- return res;
11957
- });
11958
- } },
11959
- { ALT: () => {
11960
- const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode, void 0);
11961
- const restNode = SUBRULE(
11962
- allowPaths ? propertyListPath : propertyList,
11963
- { subject: ACTION(() => C.factory.graphNodeIdentifier(subjectNode)) }
11964
- );
11965
- return ACTION(() => {
11966
- if (restNode.length === 0) {
11967
- return [subjectNode];
11968
- }
11969
- restNode[0].subject = subjectNode;
11970
- restNode[0].loc = C.factory.sourceLocation(subjectNode, restNode[0]);
11971
- return restNode;
11972
- });
11973
- } }
11974
- ])
11737
+ name: unCapitalize(func.name),
11738
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11739
+ const operator = CONSUME(func);
11740
+ CONSUME(symbols_exports.LParen);
11741
+ const arg = SUBRULE(expression);
11742
+ const close = CONSUME(symbols_exports.RParen);
11743
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11744
+ }
11975
11745
  };
11976
11746
  }
11977
- var triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
11978
- var triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
11979
- var triplesTemplate = {
11980
- name: "triplesTemplate",
11981
- impl: triplesDotSeperated(triplesSameSubject)
11982
- };
11983
- function propertyListImpl(name, allowPaths) {
11747
+ function funcExpr2(func) {
11984
11748
  return {
11985
- name,
11986
- impl: ({ SUBRULE, OPTION }) => (_, arg) => OPTION(() => SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, arg)) ?? []
11749
+ name: unCapitalize(func.name),
11750
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {
11751
+ const operator = CONSUME(func);
11752
+ CONSUME(symbols_exports.LParen);
11753
+ const arg1 = SUBRULE1(expression);
11754
+ CONSUME(symbols_exports.comma);
11755
+ const arg2 = SUBRULE2(expression);
11756
+ const close = CONSUME(symbols_exports.RParen);
11757
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2], C.factory.sourceLocation(operator, close)));
11758
+ }
11987
11759
  };
11988
11760
  }
11989
- var propertyList = propertyListImpl("propertyList", false);
11990
- var propertyListPath = propertyListImpl("propertyListPath", true);
11991
- function propertyListNotEmptyImplementation(name, allowPaths) {
11761
+ function funcExpr3(func) {
11992
11762
  return {
11993
- name,
11994
- impl: ({ ACTION, CONSUME, AT_LEAST_ONE, SUBRULE1, MANY2, OR1 }) => (_, arg) => {
11995
- const result = [];
11996
- let parsedSemi = true;
11997
- AT_LEAST_ONE({
11998
- GATE: () => parsedSemi,
11999
- DEF: () => {
12000
- parsedSemi = false;
12001
- const predicate = allowPaths ? OR1([
12002
- { ALT: () => SUBRULE1(verbPath, void 0) },
12003
- { ALT: () => SUBRULE1(verbSimple, void 0) }
12004
- ]) : SUBRULE1(verb, void 0);
12005
- const triples = SUBRULE1(
12006
- allowPaths ? objectListPath : objectList,
12007
- ACTION(() => ({ subject: arg.subject, predicate }))
12008
- );
12009
- MANY2(() => {
12010
- CONSUME(symbols_exports.semi);
12011
- parsedSemi = true;
12012
- });
12013
- ACTION(() => {
12014
- result.push(...triples);
12015
- });
12016
- }
12017
- });
12018
- return result;
11763
+ name: unCapitalize(func.name),
11764
+ impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {
11765
+ const operator = CONSUME(func);
11766
+ CONSUME(symbols_exports.LParen);
11767
+ const arg1 = SUBRULE1(expression);
11768
+ CONSUME1(symbols_exports.comma);
11769
+ const arg2 = SUBRULE2(expression);
11770
+ CONSUME2(symbols_exports.comma);
11771
+ const arg3 = SUBRULE3(expression);
11772
+ const close = CONSUME(symbols_exports.RParen);
11773
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
12019
11774
  }
12020
11775
  };
12021
11776
  }
12022
- var propertyListNotEmpty = propertyListNotEmptyImplementation("propertyListNotEmpty", false);
12023
- var propertyListPathNotEmpty = propertyListNotEmptyImplementation("propertyListPathNotEmpty", true);
12024
- var verbPath = {
12025
- name: "verbPath",
12026
- impl: ({ SUBRULE }) => () => SUBRULE(path, void 0)
12027
- };
12028
- var verbSimple = {
12029
- name: "verbSimple",
12030
- impl: ({ SUBRULE }) => () => SUBRULE(var_, void 0)
12031
- };
12032
- function objectListImpl(name, allowPaths) {
11777
+ function funcVar1(func) {
12033
11778
  return {
12034
- name,
12035
- impl: ({ ACTION, SUBRULE, AT_LEAST_ONE_SEP }) => (_, arg) => {
12036
- const objects = [];
12037
- AT_LEAST_ONE_SEP({
12038
- SEP: symbols_exports.comma,
12039
- DEF: () => {
12040
- const objectTriple = SUBRULE(allowPaths ? objectPath : object, arg);
12041
- ACTION(() => {
12042
- objects.push(objectTriple);
12043
- });
12044
- }
12045
- });
12046
- return objects;
11779
+ name: unCapitalize(func.name),
11780
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11781
+ const operator = CONSUME(func);
11782
+ CONSUME(symbols_exports.LParen);
11783
+ const arg = SUBRULE(var_);
11784
+ const close = CONSUME(symbols_exports.RParen);
11785
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12047
11786
  }
12048
11787
  };
12049
11788
  }
12050
- var objectList = objectListImpl("objectList", false);
12051
- var objectListPath = objectListImpl("objectListPath", true);
12052
- function objectImpl(name, allowPaths) {
11789
+ function funcExprOrNil1(func) {
12053
11790
  return {
12054
- name,
12055
- impl: ({ ACTION, SUBRULE }) => (C, arg) => {
12056
- const node = SUBRULE(allowPaths ? graphNodePath : graphNode, void 0);
12057
- return ACTION(() => C.factory.triple(arg.subject, arg.predicate, node));
11791
+ name: unCapitalize(func.name),
11792
+ impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
11793
+ const operator = CONSUME(func);
11794
+ return OR([
11795
+ { ALT: () => {
11796
+ CONSUME(symbols_exports.LParen);
11797
+ const arg = SUBRULE(expression);
11798
+ const close = CONSUME(symbols_exports.RParen);
11799
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11800
+ } },
11801
+ { ALT: () => {
11802
+ const nil2 = CONSUME(terminals_exports.nil);
11803
+ return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
11804
+ } }
11805
+ ]);
12058
11806
  }
12059
11807
  };
12060
11808
  }
12061
- var object = objectImpl("object", false);
12062
- var objectPath = objectImpl("objectPath", true);
12063
- function collectionImpl(name, allowPaths) {
11809
+ function funcNil1(func) {
12064
11810
  return {
12065
- name,
12066
- impl: ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME }) => (C) => {
12067
- const terms = [];
12068
- const startToken = CONSUME(symbols_exports.LParen);
12069
- AT_LEAST_ONE(() => {
12070
- terms.push(SUBRULE(allowPaths ? graphNodePath : graphNode, void 0));
12071
- });
12072
- const endToken = CONSUME(symbols_exports.RParen);
12073
- return ACTION(() => {
12074
- const F2 = C.factory;
12075
- const triples = [];
12076
- const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" /* FIRST */, void 0);
12077
- const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" /* REST */, void 0);
12078
- const predNil = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */, void 0);
12079
- const listHead = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12080
- let iterHead = listHead;
12081
- for (const [index, term] of terms.entries()) {
12082
- const lastInList = index === terms.length - 1;
12083
- const headTriple = F2.triple(
12084
- iterHead,
12085
- predFirst,
12086
- term
12087
- );
12088
- triples.push(headTriple);
12089
- if (lastInList) {
12090
- const nilTriple = F2.triple(iterHead, predRest, predNil);
12091
- triples.push(nilTriple);
12092
- } else {
12093
- const tail = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12094
- const linkTriple = F2.triple(iterHead, predRest, tail);
12095
- triples.push(linkTriple);
12096
- iterHead = tail;
12097
- }
12098
- }
12099
- return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
12100
- });
12101
- },
12102
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12103
- F2.printFilter(ast, () => PRINT_WORD("("));
12104
- for (const [idx, triple] of ast.triples.entries()) {
12105
- if (idx % 2 === 0) {
12106
- SUBRULE(allowPaths ? graphNodePath : graphNode, triple.object, void 0);
12107
- }
12108
- }
12109
- F2.printFilter(ast, () => PRINT_WORD(")"));
11811
+ name: unCapitalize(func.name),
11812
+ impl: ({ ACTION, CONSUME }) => (C) => {
11813
+ const operator = CONSUME(func);
11814
+ const nil2 = CONSUME(terminals_exports.nil);
11815
+ return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12110
11816
  }
12111
11817
  };
12112
11818
  }
12113
- var collection = collectionImpl("collection", false);
12114
- var collectionPath = collectionImpl("collectionPath", true);
12115
- function triplesNodeImpl(name, allowPaths) {
11819
+ function funcExprList1(func) {
12116
11820
  return {
12117
- name,
12118
- impl: ({ SUBRULE, OR }) => () => OR([
12119
- { ALT: () => SUBRULE(allowPaths ? collectionPath : collection, void 0) },
12120
- { ALT: () => SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, void 0) }
12121
- ]),
12122
- gImpl: ({ SUBRULE }) => (ast) => ast.subType === "list" ? SUBRULE(allowPaths ? collectionPath : collection, ast, void 0) : SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, ast, void 0)
11821
+ name: unCapitalize(func.name),
11822
+ impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11823
+ const operator = CONSUME(func);
11824
+ const args = SUBRULE(expressionList);
11825
+ return ACTION(() => C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));
11826
+ }
12123
11827
  };
12124
11828
  }
12125
- var triplesNode = triplesNodeImpl("triplesNode", false);
12126
- var triplesNodePath = triplesNodeImpl("triplesNodePath", true);
12127
- function blankNodePropertyListImpl(name, allowPaths) {
12128
- const propertyPathNotEmptyImpl = allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty;
11829
+ function funcExpr2or3(func) {
12129
11830
  return {
12130
- name,
12131
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12132
- const startToken = CONSUME(symbols_exports.LSquare);
12133
- const blankNode2 = ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocationNoMaterialize()));
12134
- const propList = SUBRULE(propertyPathNotEmptyImpl, { subject: blankNode2 });
12135
- const endToken = CONSUME(symbols_exports.RSquare);
12136
- return ACTION(() => C.factory.tripleCollectionBlankNodeProperties(
12137
- blankNode2,
12138
- propList,
12139
- C.factory.sourceLocation(startToken, endToken)
11831
+ name: unCapitalize(func.name),
11832
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) => (C) => {
11833
+ const operator = CONSUME(func);
11834
+ CONSUME(symbols_exports.LParen);
11835
+ const arg1 = SUBRULE1(expression);
11836
+ CONSUME1(symbols_exports.comma);
11837
+ const arg2 = SUBRULE2(expression);
11838
+ const arg3 = OPTION(() => {
11839
+ CONSUME2(symbols_exports.comma);
11840
+ return SUBRULE3(expression);
11841
+ });
11842
+ const close = CONSUME(symbols_exports.RParen);
11843
+ return ACTION(() => C.factory.expressionOperation(
11844
+ operator.image,
11845
+ arg3 ? [arg1, arg2, arg3] : [arg1, arg2],
11846
+ C.factory.sourceLocation(operator, close)
12140
11847
  ));
12141
- },
12142
- gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12143
- F2.printFilter(ast, () => PRINT("["));
12144
- for (const triple of ast.triples) {
12145
- HANDLE_LOC(triple, () => {
12146
- if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12147
- SUBRULE(varOrTerm, triple.predicate, void 0);
12148
- } else {
12149
- SUBRULE(pathGenerator, triple.predicate, void 0);
12150
- }
12151
- SUBRULE(graphNodePath, triple.object, void 0);
12152
- F2.printFilter(ast, () => PRINT_WORD(";"));
12153
- });
12154
- }
12155
- F2.printFilter(ast, () => PRINT("]"));
12156
11848
  }
12157
11849
  };
12158
11850
  }
12159
- var blankNodePropertyList = blankNodePropertyListImpl("blankNodePropertyList", false);
12160
- var blankNodePropertyListPath = blankNodePropertyListImpl("blankNodePropertyListPath", true);
12161
- function graphNodeImpl(name, allowPaths) {
12162
- const triplesNodeRule = allowPaths ? triplesNodePath : triplesNode;
11851
+ function funcExpr3or4(func) {
12163
11852
  return {
12164
- name,
12165
- impl: ({ SUBRULE, OR }) => (C) => OR([
12166
- { ALT: () => SUBRULE(varOrTerm, void 0) },
12167
- {
12168
- GATE: () => C.parseMode.has("canCreateBlankNodes"),
12169
- ALT: () => SUBRULE(triplesNodeRule, void 0)
12170
- }
12171
- ]),
12172
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12173
- if (F2.isTerm(ast)) {
12174
- SUBRULE(varOrTerm, ast, void 0);
12175
- } else {
12176
- SUBRULE(triplesNodeRule, ast, void 0);
12177
- }
11853
+ name: unCapitalize(func.name),
11854
+ impl: ({
11855
+ ACTION,
11856
+ CONSUME,
11857
+ SUBRULE1,
11858
+ SUBRULE2,
11859
+ SUBRULE3,
11860
+ SUBRULE4,
11861
+ CONSUME1,
11862
+ OPTION,
11863
+ CONSUME2,
11864
+ CONSUME3
11865
+ }) => (C) => {
11866
+ const operator = CONSUME(func);
11867
+ CONSUME(symbols_exports.LParen);
11868
+ const arg1 = SUBRULE1(expression);
11869
+ CONSUME1(symbols_exports.comma);
11870
+ const arg2 = SUBRULE2(expression);
11871
+ CONSUME2(symbols_exports.comma);
11872
+ const arg3 = SUBRULE3(expression);
11873
+ const arg4 = OPTION(() => {
11874
+ CONSUME3(symbols_exports.comma);
11875
+ return SUBRULE4(expression);
11876
+ });
11877
+ const close = CONSUME(symbols_exports.RParen);
11878
+ return ACTION(() => C.factory.expressionOperation(
11879
+ operator.image,
11880
+ arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3],
11881
+ C.factory.sourceLocation(operator, close)
11882
+ ));
11883
+ }
11884
+ };
11885
+ }
11886
+ function funcGroupGraphPattern(func) {
11887
+ return {
11888
+ name: unCapitalize(func.name),
11889
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11890
+ const operator = CONSUME(func);
11891
+ const group = SUBRULE(groupGraphPattern);
11892
+ return ACTION(() => C.factory.expressionPatternOperation(
11893
+ operator.image,
11894
+ group,
11895
+ C.factory.sourceLocation(operator, group)
11896
+ ));
11897
+ }
11898
+ };
11899
+ }
11900
+ function baseAggregateFunc(func) {
11901
+ return {
11902
+ name: unCapitalize(func.name),
11903
+ impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
11904
+ const operator = CONSUME(func);
11905
+ CONSUME(symbols_exports.LParen);
11906
+ const distinct2 = OPTION(() => CONSUME(distinct));
11907
+ const expr1 = SUBRULE(expression);
11908
+ const close = CONSUME(symbols_exports.RParen);
11909
+ return ACTION(() => C.factory.aggregate(
11910
+ operator.image,
11911
+ distinct2 !== void 0,
11912
+ expr1,
11913
+ void 0,
11914
+ C.factory.sourceLocation(operator, close)
11915
+ ));
12178
11916
  }
12179
11917
  };
12180
11918
  }
12181
- var graphNode = graphNodeImpl("graphNode", false);
12182
- var graphNodePath = graphNodeImpl("graphNodePath", true);
12183
11919
 
12184
- // ../rules-sparql-1-1/lib/grammar/whereClause.ts
12185
- var whereClause = {
12186
- name: "whereClause",
12187
- impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
12188
- const where2 = OPTION(() => CONSUME(where));
12189
- const group = SUBRULE(groupGraphPattern, void 0);
12190
- return ACTION(() => C.factory.wrap(group, C.factory.sourceLocation(where2, group)));
12191
- },
12192
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12193
- F2.printFilter(ast, () => PRINT_WORD("WHERE"));
12194
- SUBRULE(groupGraphPattern, ast.val, void 0);
11920
+ // ../rules-sparql-1-1/lib/grammar/builtIn.ts
11921
+ var builtInStr = funcExpr1(BuiltInCalls_exports.str);
11922
+ var builtInLang = funcExpr1(BuiltInCalls_exports.lang);
11923
+ var builtInLangmatches = funcExpr2(BuiltInCalls_exports.langmatches);
11924
+ var builtInDatatype = funcExpr1(BuiltInCalls_exports.datatype);
11925
+ var builtInBound = funcVar1(BuiltInCalls_exports.bound);
11926
+ var builtInIri = funcExpr1(BuiltInCalls_exports.iri);
11927
+ var builtInUri = funcExpr1(BuiltInCalls_exports.uri);
11928
+ var builtInBnodeSparqlJs = funcExprOrNil1(BuiltInCalls_exports.bnode);
11929
+ var builtInRand = funcNil1(BuiltInCalls_exports.rand);
11930
+ var builtInAbs = funcExpr1(BuiltInCalls_exports.abs);
11931
+ var builtInCeil = funcExpr1(BuiltInCalls_exports.ceil);
11932
+ var builtInFloor = funcExpr1(BuiltInCalls_exports.floor);
11933
+ var builtInRound = funcExpr1(BuiltInCalls_exports.round);
11934
+ var builtInConcat = funcExprList1(BuiltInCalls_exports.concat);
11935
+ var builtInStrlen = funcExpr1(BuiltInCalls_exports.strlen);
11936
+ var builtInUcase = funcExpr1(BuiltInCalls_exports.ucase);
11937
+ var builtInLcase = funcExpr1(BuiltInCalls_exports.lcase);
11938
+ var builtInEncode_for_uri = funcExpr1(BuiltInCalls_exports.encode_for_uri);
11939
+ var builtInContains = funcExpr2(BuiltInCalls_exports.contains);
11940
+ var builtInStrstarts = funcExpr2(BuiltInCalls_exports.strstarts);
11941
+ var builtInStrends = funcExpr2(BuiltInCalls_exports.strends);
11942
+ var builtInStrbefore = funcExpr2(BuiltInCalls_exports.strbefore);
11943
+ var builtInStrafter = funcExpr2(BuiltInCalls_exports.strafter);
11944
+ var builtInYear = funcExpr1(BuiltInCalls_exports.year);
11945
+ var builtInMonth = funcExpr1(BuiltInCalls_exports.month);
11946
+ var builtInDay = funcExpr1(BuiltInCalls_exports.day);
11947
+ var builtInHours = funcExpr1(BuiltInCalls_exports.hours);
11948
+ var builtInMinutes = funcExpr1(BuiltInCalls_exports.minutes);
11949
+ var builtInSeconds = funcExpr1(BuiltInCalls_exports.seconds);
11950
+ var builtInTimezone = funcExpr1(BuiltInCalls_exports.timezone);
11951
+ var builtInTz = funcExpr1(BuiltInCalls_exports.tz);
11952
+ var builtInNow = funcNil1(BuiltInCalls_exports.now);
11953
+ var builtInUuid = funcNil1(BuiltInCalls_exports.uuid);
11954
+ var builtInStruuid = funcNil1(BuiltInCalls_exports.struuid);
11955
+ var builtInMd5 = funcExpr1(BuiltInCalls_exports.md5);
11956
+ var builtInSha1 = funcExpr1(BuiltInCalls_exports.sha1);
11957
+ var builtInSha256 = funcExpr1(BuiltInCalls_exports.sha256);
11958
+ var builtInSha384 = funcExpr1(BuiltInCalls_exports.sha384);
11959
+ var builtInSha512 = funcExpr1(BuiltInCalls_exports.sha512);
11960
+ var builtInCoalesce = funcExprList1(BuiltInCalls_exports.coalesce);
11961
+ var builtInIf = funcExpr3(BuiltInCalls_exports.if_);
11962
+ var builtInStrlang = funcExpr2(BuiltInCalls_exports.strlang);
11963
+ var builtInStrdt = funcExpr2(BuiltInCalls_exports.strdt);
11964
+ var builtInSameterm = funcExpr2(BuiltInCalls_exports.sameterm);
11965
+ var builtInIsiri = funcExpr1(BuiltInCalls_exports.isiri);
11966
+ var builtInIsuri = funcExpr1(BuiltInCalls_exports.isuri);
11967
+ var builtInIsblank = funcExpr1(BuiltInCalls_exports.isblank);
11968
+ var builtInIsliteral = funcExpr1(BuiltInCalls_exports.isliteral);
11969
+ var builtInIsnumeric = funcExpr1(BuiltInCalls_exports.isnumeric);
11970
+ function builtInCallList(SUBRULE) {
11971
+ return [
11972
+ { ALT: () => SUBRULE(aggregate) },
11973
+ { ALT: () => SUBRULE(builtInStr) },
11974
+ { ALT: () => SUBRULE(builtInLang) },
11975
+ { ALT: () => SUBRULE(builtInLangmatches) },
11976
+ { ALT: () => SUBRULE(builtInDatatype) },
11977
+ { ALT: () => SUBRULE(builtInBound) },
11978
+ { ALT: () => SUBRULE(builtInIri) },
11979
+ { ALT: () => SUBRULE(builtInUri) },
11980
+ { ALT: () => SUBRULE(builtInBnodeSparqlJs) },
11981
+ { ALT: () => SUBRULE(builtInRand) },
11982
+ { ALT: () => SUBRULE(builtInAbs) },
11983
+ { ALT: () => SUBRULE(builtInCeil) },
11984
+ { ALT: () => SUBRULE(builtInFloor) },
11985
+ { ALT: () => SUBRULE(builtInRound) },
11986
+ { ALT: () => SUBRULE(builtInConcat) },
11987
+ { ALT: () => SUBRULE(substringExpression) },
11988
+ { ALT: () => SUBRULE(builtInStrlen) },
11989
+ { ALT: () => SUBRULE(strReplaceExpression) },
11990
+ { ALT: () => SUBRULE(builtInUcase) },
11991
+ { ALT: () => SUBRULE(builtInLcase) },
11992
+ { ALT: () => SUBRULE(builtInEncode_for_uri) },
11993
+ { ALT: () => SUBRULE(builtInContains) },
11994
+ { ALT: () => SUBRULE(builtInStrstarts) },
11995
+ { ALT: () => SUBRULE(builtInStrends) },
11996
+ { ALT: () => SUBRULE(builtInStrbefore) },
11997
+ { ALT: () => SUBRULE(builtInStrafter) },
11998
+ { ALT: () => SUBRULE(builtInYear) },
11999
+ { ALT: () => SUBRULE(builtInMonth) },
12000
+ { ALT: () => SUBRULE(builtInDay) },
12001
+ { ALT: () => SUBRULE(builtInHours) },
12002
+ { ALT: () => SUBRULE(builtInMinutes) },
12003
+ { ALT: () => SUBRULE(builtInSeconds) },
12004
+ { ALT: () => SUBRULE(builtInTimezone) },
12005
+ { ALT: () => SUBRULE(builtInTz) },
12006
+ { ALT: () => SUBRULE(builtInNow) },
12007
+ { ALT: () => SUBRULE(builtInUuid) },
12008
+ { ALT: () => SUBRULE(builtInStruuid) },
12009
+ { ALT: () => SUBRULE(builtInMd5) },
12010
+ { ALT: () => SUBRULE(builtInSha1) },
12011
+ { ALT: () => SUBRULE(builtInSha256) },
12012
+ { ALT: () => SUBRULE(builtInSha384) },
12013
+ { ALT: () => SUBRULE(builtInSha512) },
12014
+ { ALT: () => SUBRULE(builtInCoalesce) },
12015
+ { ALT: () => SUBRULE(builtInIf) },
12016
+ { ALT: () => SUBRULE(builtInStrlang) },
12017
+ { ALT: () => SUBRULE(builtInStrdt) },
12018
+ { ALT: () => SUBRULE(builtInSameterm) },
12019
+ { ALT: () => SUBRULE(builtInIsiri) },
12020
+ { ALT: () => SUBRULE(builtInIsuri) },
12021
+ { ALT: () => SUBRULE(builtInIsblank) },
12022
+ { ALT: () => SUBRULE(builtInIsliteral) },
12023
+ { ALT: () => SUBRULE(builtInIsnumeric) },
12024
+ { ALT: () => SUBRULE(regexExpression) },
12025
+ { ALT: () => SUBRULE(existsFunc) },
12026
+ { ALT: () => SUBRULE(notExistsFunc) }
12027
+ ];
12028
+ }
12029
+ var builtInCall = {
12030
+ name: "builtInCall",
12031
+ impl: ({ OR, SUBRULE, cache }) => () => {
12032
+ const cached = cache.get(builtInCall);
12033
+ if (cached) {
12034
+ return OR(cached);
12035
+ }
12036
+ const builtIns = builtInCallList(SUBRULE);
12037
+ cache.set(builtInCall, builtIns);
12038
+ return OR(builtIns);
12195
12039
  }
12196
12040
  };
12197
- var groupGraphPattern = {
12198
- name: "groupGraphPattern",
12199
- impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
12200
- const open = CONSUME(symbols_exports.LCurly);
12201
- const patterns = OR([
12202
- { ALT: () => [SUBRULE(subSelect, void 0)] },
12203
- { ALT: () => SUBRULE(groupGraphPatternSub, void 0) }
12041
+ var regexExpression = funcExpr2or3(BuiltInCalls_exports.regex);
12042
+ var substringExpression = funcExpr2or3(BuiltInCalls_exports.substr);
12043
+ var strReplaceExpression = funcExpr3or4(BuiltInCalls_exports.replace);
12044
+ var existsFunc = funcGroupGraphPattern(BuiltInCalls_exports.exists);
12045
+ var notExistsFunc = funcGroupGraphPattern(BuiltInCalls_exports.notexists);
12046
+ var aggregateCount = {
12047
+ name: unCapitalize(BuiltInCalls_exports.count.name),
12048
+ impl: ({ ACTION, CONSUME, SUBRULE, OR, OPTION }) => (C) => {
12049
+ const operatorToken = CONSUME(BuiltInCalls_exports.count);
12050
+ CONSUME(symbols_exports.LParen);
12051
+ const distinctToken = OPTION(() => CONSUME(distinct));
12052
+ const expressionVal = OR([
12053
+ { ALT: () => {
12054
+ const starToken = CONSUME(symbols_exports.star);
12055
+ return ACTION(() => C.factory.wildcard(C.factory.sourceLocation(starToken)));
12056
+ } },
12057
+ { ALT: () => SUBRULE(expression) }
12204
12058
  ]);
12205
- const close = CONSUME(symbols_exports.RCurly);
12206
- return ACTION(() => C.factory.patternGroup(patterns, C.factory.sourceLocation(open, close)));
12207
- },
12208
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12209
- F2.printFilter(ast, () => PRINT_WORD("{"));
12210
- for (const pattern of ast.patterns) {
12211
- SUBRULE(generatePattern, pattern, void 0);
12212
- }
12213
- F2.printFilter(ast, () => PRINT_WORD("}"));
12059
+ const closeToken = CONSUME(symbols_exports.RParen);
12060
+ return ACTION(() => {
12061
+ const F2 = C.factory;
12062
+ if (C.factory.isWildcard(expressionVal)) {
12063
+ return F2.aggregate(
12064
+ operatorToken.image,
12065
+ Boolean(distinctToken),
12066
+ expressionVal,
12067
+ void 0,
12068
+ C.factory.sourceLocation(operatorToken, closeToken)
12069
+ );
12070
+ }
12071
+ return F2.aggregate(
12072
+ operatorToken.image,
12073
+ Boolean(distinctToken),
12074
+ expressionVal,
12075
+ void 0,
12076
+ C.factory.sourceLocation(operatorToken, closeToken)
12077
+ );
12078
+ });
12214
12079
  }
12215
12080
  };
12216
- var generatePattern = {
12217
- name: "generatePattern",
12218
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12219
- if (ast.type === "query") {
12220
- SUBRULE(query, F2.querySelect({
12221
- context: [],
12222
- datasets: F2.datasetClauses([], F2.sourceLocation()),
12223
- where: ast.where,
12224
- variables: ast.variables,
12225
- solutionModifiers: ast.solutionModifiers,
12226
- values: ast.values,
12227
- distinct: ast.distinct,
12228
- reduced: ast.reduced
12229
- }, ast.loc), void 0);
12230
- } else if (ast.subType === "group") {
12231
- SUBRULE(groupGraphPattern, ast, void 0);
12232
- } else if (ast.subType === "bgp") {
12233
- SUBRULE(triplesBlock, ast, void 0);
12234
- } else {
12235
- SUBRULE(graphPatternNotTriples, ast, void 0);
12236
- }
12081
+ var aggregateSum = baseAggregateFunc(BuiltInCalls_exports.sum);
12082
+ var aggregateMin = baseAggregateFunc(BuiltInCalls_exports.min);
12083
+ var aggregateMax = baseAggregateFunc(BuiltInCalls_exports.max);
12084
+ var aggregateAvg = baseAggregateFunc(BuiltInCalls_exports.avg);
12085
+ var aggregateSample = baseAggregateFunc(BuiltInCalls_exports.sample);
12086
+ var aggregateGroup_concat = {
12087
+ name: unCapitalize(BuiltInCalls_exports.groupConcat.name),
12088
+ impl: ({ ACTION, CONSUME, OPTION1, SUBRULE, OPTION2 }) => (C) => {
12089
+ const operatorToken = CONSUME(BuiltInCalls_exports.groupConcat);
12090
+ CONSUME(symbols_exports.LParen);
12091
+ const distinctToken = OPTION1(() => CONSUME(distinct));
12092
+ const expr = SUBRULE(expression);
12093
+ const sep = OPTION2(() => {
12094
+ CONSUME(symbols_exports.semi);
12095
+ CONSUME(separator);
12096
+ CONSUME(symbols_exports.equal);
12097
+ return SUBRULE(string);
12098
+ });
12099
+ const closeToken = CONSUME(symbols_exports.RParen);
12100
+ return ACTION(() => {
12101
+ const F2 = C.factory;
12102
+ return F2.aggregate(
12103
+ operatorToken.image,
12104
+ Boolean(distinctToken),
12105
+ expr,
12106
+ sep?.value ?? " ",
12107
+ F2.sourceLocation(operatorToken, closeToken)
12108
+ );
12109
+ });
12237
12110
  }
12238
12111
  };
12239
- var groupGraphPatternSub = {
12240
- name: "groupGraphPatternSub",
12241
- impl: ({ ACTION, SUBRULE, CONSUME, MANY, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OPTION3 }) => () => {
12242
- const patterns = [];
12243
- const bgpPattern = OPTION1(() => SUBRULE1(triplesBlock, void 0));
12244
- if (bgpPattern) {
12245
- patterns.push(bgpPattern);
12246
- }
12247
- MANY(() => {
12248
- const notTriples = SUBRULE(graphPatternNotTriples, void 0);
12249
- patterns.push(notTriples);
12250
- OPTION2(() => CONSUME(symbols_exports.dot));
12251
- const moreTriples = OPTION3(() => SUBRULE2(triplesBlock, void 0));
12252
- if (moreTriples) {
12253
- patterns.push(moreTriples);
12112
+ var aggregate = {
12113
+ name: "aggregate",
12114
+ impl: ({ ACTION, SUBRULE, OR }) => (C) => {
12115
+ const wasInAggregate = ACTION(() => C.parseMode.has("inAggregate"));
12116
+ ACTION(() => C.parseMode.add("inAggregate"));
12117
+ const result = OR([
12118
+ { ALT: () => SUBRULE(aggregateCount) },
12119
+ { ALT: () => SUBRULE(aggregateSum) },
12120
+ { ALT: () => SUBRULE(aggregateMin) },
12121
+ { ALT: () => SUBRULE(aggregateMax) },
12122
+ { ALT: () => SUBRULE(aggregateAvg) },
12123
+ { ALT: () => SUBRULE(aggregateSample) },
12124
+ { ALT: () => SUBRULE(aggregateGroup_concat) }
12125
+ ]);
12126
+ ACTION(() => !wasInAggregate && C.parseMode.delete("inAggregate"));
12127
+ ACTION(() => {
12128
+ if (!C.parseMode.has("canParseAggregate")) {
12129
+ throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");
12130
+ }
12131
+ if (C.parseMode.has("inAggregate")) {
12132
+ throw new Error("An aggregate function is not allowed within an aggregate function.");
12254
12133
  }
12255
12134
  });
12256
- ACTION(() => checkNote13(patterns));
12257
- return patterns;
12258
- }
12259
- };
12260
- var graphPatternNotTriples = {
12261
- name: "graphPatternNotTriples",
12262
- impl: ({ SUBRULE, OR }) => () => OR([
12263
- { ALT: () => SUBRULE(groupOrUnionGraphPattern, void 0) },
12264
- { ALT: () => SUBRULE(optionalGraphPattern, void 0) },
12265
- { ALT: () => SUBRULE(minusGraphPattern, void 0) },
12266
- { ALT: () => SUBRULE(graphGraphPattern, void 0) },
12267
- { ALT: () => SUBRULE(serviceGraphPattern, void 0) },
12268
- { ALT: () => SUBRULE(filter3, void 0) },
12269
- { ALT: () => SUBRULE(bind2, void 0) },
12270
- { ALT: () => SUBRULE(inlineData, void 0) }
12271
- ]),
12272
- gImpl: ({ SUBRULE }) => (ast) => {
12273
- switch (ast.subType) {
12274
- case "group":
12275
- case "union":
12276
- SUBRULE(groupOrUnionGraphPattern, ast, void 0);
12277
- break;
12278
- case "optional":
12279
- SUBRULE(optionalGraphPattern, ast, void 0);
12280
- break;
12281
- case "minus":
12282
- SUBRULE(minusGraphPattern, ast, void 0);
12283
- break;
12284
- case "graph":
12285
- SUBRULE(graphGraphPattern, ast, void 0);
12286
- break;
12287
- case "service":
12288
- SUBRULE(serviceGraphPattern, ast, void 0);
12289
- break;
12290
- case "filter":
12291
- SUBRULE(filter3, ast, void 0);
12292
- break;
12293
- case "bind":
12294
- SUBRULE(bind2, ast, void 0);
12295
- break;
12296
- case "values":
12297
- SUBRULE(inlineData, ast, void 0);
12298
- break;
12135
+ return result;
12136
+ },
12137
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12138
+ F2.printFilter(ast, () => {
12139
+ PRINT_WORD(ast.aggregation, "(");
12140
+ if (ast.distinct) {
12141
+ PRINT_WORD("DISTINCT");
12142
+ }
12143
+ });
12144
+ const arg = ast.expression[0];
12145
+ if (F2.isWildcard(arg)) {
12146
+ F2.printFilter(ast, () => PRINT_WORD("*"));
12147
+ } else {
12148
+ SUBRULE(expression, arg);
12149
+ }
12150
+ if (F2.isExpressionAggregateSeparator(ast)) {
12151
+ F2.printFilter(ast, () => PRINT_WORD(";", "SEPARATOR", "=", stringEscapedLexical(ast.separator)));
12299
12152
  }
12153
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12300
12154
  }
12301
12155
  };
12302
- var optionalGraphPattern = {
12303
- name: "optionalGraphPattern",
12304
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12305
- const optional2 = CONSUME(optional);
12306
- const group = SUBRULE(groupGraphPattern, void 0);
12307
- return ACTION(() => C.factory.patternOptional(group.patterns, C.factory.sourceLocation(optional2, group)));
12308
- },
12309
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12310
- F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
12311
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12312
- }
12313
- };
12314
- var graphGraphPattern = {
12315
- name: "graphGraphPattern",
12316
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12317
- const graph2 = CONSUME(graph_exports.graph);
12318
- const name = SUBRULE(varOrIri, void 0);
12319
- const group = SUBRULE(groupGraphPattern, void 0);
12320
- return ACTION(() => C.factory.patternGraph(name, group.patterns, C.factory.sourceLocation(graph2, group)));
12321
- },
12322
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12323
- F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
12324
- SUBRULE(varOrTerm, ast.name, void 0);
12325
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12326
- }
12327
- };
12328
- var serviceGraphPattern = {
12329
- name: "serviceGraphPattern",
12330
- impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
12331
- const service2 = CONSUME(service);
12332
- const silent2 = OPTION(() => {
12333
- CONSUME(silent);
12334
- return true;
12335
- }) ?? false;
12336
- const name = SUBRULE1(varOrIri, void 0);
12337
- const group = SUBRULE1(groupGraphPattern, void 0);
12338
- return ACTION(() => C.factory.patternService(name, group.patterns, silent2, C.factory.sourceLocation(service2, group)));
12339
- },
12340
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12341
- F2.printFilter(ast, () => {
12342
- PRINT_WORD("SERVICE");
12343
- if (ast.silent) {
12344
- PRINT_WORD("SILENT");
12345
- }
12346
- });
12347
- SUBRULE(varOrTerm, ast.name, void 0);
12348
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12349
- }
12350
- };
12351
- var bind2 = {
12352
- name: "bind",
12353
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12354
- const bind3 = CONSUME(bind);
12355
- CONSUME(symbols_exports.LParen);
12356
- const expressionVal = SUBRULE(expression, void 0);
12357
- CONSUME(as);
12358
- const variable = SUBRULE(var_, void 0);
12359
- const close = CONSUME(symbols_exports.RParen);
12360
- return ACTION(() => C.factory.patternBind(expressionVal, variable, C.factory.sourceLocation(bind3, close)));
12361
- },
12362
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12363
- F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12364
- SUBRULE(expression, ast.expression, void 0);
12365
- F2.printFilter(ast, () => PRINT_WORD("AS"));
12366
- SUBRULE(var_, ast.variable, void 0);
12367
- F2.printFilter(ast, () => PRINT_WORD(")"));
12368
- }
12156
+
12157
+ // ../rules-sparql-1-1/lib/grammar/propertyPaths.ts
12158
+ var path = {
12159
+ name: "path",
12160
+ impl: ({ SUBRULE }) => () => SUBRULE(pathAlternative)
12369
12161
  };
12370
- var inlineData = {
12371
- name: "inlineData",
12372
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12373
- const values3 = CONSUME(values2);
12374
- const datablock = SUBRULE(dataBlock, void 0);
12375
- return ACTION(() => C.factory.patternValues(datablock.val, C.factory.sourceLocation(values3, datablock)));
12376
- },
12377
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12378
- const variables = Object.keys(ast.values[0]);
12379
- F2.printFilter(ast, () => {
12380
- PRINT_WORD("VALUES", "(");
12381
- for (const variable of variables) {
12382
- PRINT_WORD(`?${variable}`);
12383
- }
12384
- PRINT_WORD(")", "{");
12385
- });
12386
- for (const mapping of ast.values) {
12387
- F2.printFilter(ast, () => PRINT_WORD("("));
12388
- for (const variable of variables) {
12389
- if (mapping[variable] === void 0) {
12390
- F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
12391
- } else {
12392
- SUBRULE(graphNodePath, mapping[variable], void 0);
12162
+ var pathGenerator = {
12163
+ name: "path",
12164
+ gImpl: ({ PRINT, SUBRULE }) => (ast, { factory: F2 }, braces = true) => {
12165
+ if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
12166
+ SUBRULE(iri2, ast);
12167
+ } else {
12168
+ F2.printFilter(ast, () => braces && PRINT("("));
12169
+ switch (ast.subType) {
12170
+ case "|":
12171
+ case "/": {
12172
+ const [head2, ...tail] = ast.items;
12173
+ SUBRULE(pathGenerator, head2, braces);
12174
+ for (const val of tail) {
12175
+ F2.printFilter(ast, () => PRINT(ast.subType));
12176
+ SUBRULE(pathGenerator, val, braces);
12177
+ }
12178
+ break;
12393
12179
  }
12180
+ case "^":
12181
+ F2.printFilter(ast, () => PRINT("^"));
12182
+ SUBRULE(pathGenerator, ast.items[0], braces);
12183
+ break;
12184
+ case "?":
12185
+ case "*":
12186
+ case "+":
12187
+ SUBRULE(pathGenerator, ast.items[0], braces);
12188
+ F2.printFilter(ast, () => PRINT(ast.subType));
12189
+ break;
12190
+ case "!":
12191
+ F2.printFilter(ast, () => PRINT("!"));
12192
+ F2.printFilter(ast, () => PRINT("("));
12193
+ SUBRULE(pathGenerator, ast.items[0], false);
12194
+ F2.printFilter(ast, () => PRINT(")"));
12195
+ break;
12394
12196
  }
12395
- F2.printFilter(ast, () => PRINT_WORD(")"));
12197
+ F2.printFilter(ast, () => braces && PRINT(")"));
12396
12198
  }
12397
- F2.printFilter(ast, () => PRINT_WORD("}"));
12398
12199
  }
12399
12200
  };
12400
- var dataBlock = {
12401
- name: "dataBlock",
12402
- impl: ({ SUBRULE, OR }) => () => OR([
12403
- { ALT: () => SUBRULE(inlineDataOneVar, void 0) },
12404
- { ALT: () => SUBRULE(inlineDataFull, void 0) }
12405
- ])
12406
- };
12407
- var inlineDataOneVar = {
12408
- name: "inlineDataOneVar",
12409
- impl: ({ ACTION, SUBRULE, CONSUME, MANY }) => (C) => {
12410
- const res = [];
12411
- const varVal = SUBRULE(var_, void 0);
12412
- CONSUME(symbols_exports.LCurly);
12413
- MANY(() => {
12414
- const value = SUBRULE(dataBlockValue, void 0);
12415
- ACTION(() => {
12416
- res.push({ [varVal.value]: value });
12201
+ function pathChainHelper(name, SEP, subType, subRule) {
12202
+ return {
12203
+ name,
12204
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, MANY }) => (C) => {
12205
+ const head2 = SUBRULE1(subRule);
12206
+ let tailEnd = head2;
12207
+ const tail = [];
12208
+ MANY(() => {
12209
+ CONSUME(SEP);
12210
+ tailEnd = SUBRULE2(subRule);
12211
+ tail.push(tailEnd);
12417
12212
  });
12418
- });
12419
- const close = CONSUME(symbols_exports.RCurly);
12420
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(varVal, close)));
12421
- }
12422
- };
12423
- var inlineDataFull = {
12424
- name: "inlineDataFull",
12425
- impl: ({
12426
- ACTION,
12427
- OR,
12428
- MANY1,
12429
- MANY2,
12430
- MANY3,
12431
- MANY4,
12432
- SUBRULE,
12433
- CONSUME1,
12434
- CONSUME2
12435
- }) => (C) => {
12436
- const res = [];
12437
- const vars = [];
12438
- return OR([
12439
- { ALT: () => {
12440
- const nil2 = CONSUME1(terminals_exports.nil);
12441
- CONSUME1(symbols_exports.LCurly);
12442
- MANY1(() => {
12443
- CONSUME2(terminals_exports.nil);
12444
- res.push({});
12445
- });
12446
- const close = CONSUME1(symbols_exports.RCurly);
12447
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(nil2, close)));
12448
- } },
12449
- { ALT: () => {
12450
- const open = CONSUME1(symbols_exports.LParen);
12451
- MANY2(() => {
12452
- vars.push(SUBRULE(var_, void 0));
12453
- });
12454
- CONSUME1(symbols_exports.RParen);
12455
- CONSUME2(symbols_exports.LCurly);
12456
- MANY3(() => {
12457
- let parsedValues = 0;
12458
- const currentRow = {};
12459
- CONSUME2(symbols_exports.LParen);
12460
- MANY4(() => {
12461
- if (parsedValues >= vars.length) {
12462
- throw new Error("Number of dataBlockValues does not match number of variables. Too much values.");
12463
- }
12464
- const value = SUBRULE(dataBlockValue, void 0);
12465
- ACTION(() => {
12466
- currentRow[vars[parsedValues].value] = value;
12467
- parsedValues++;
12468
- });
12469
- });
12470
- CONSUME2(symbols_exports.RParen);
12471
- ACTION(() => {
12472
- res.push(currentRow);
12473
- if (vars.length !== parsedValues) {
12474
- throw new Error("Number of dataBlockValues does not match number of variables. Too few values.");
12475
- }
12476
- });
12477
- });
12478
- const close = CONSUME2(symbols_exports.RCurly);
12479
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(open, close)));
12480
- } }
12481
- ]);
12482
- }
12483
- };
12484
- var dataBlockValue = {
12485
- name: "dataBlockValue",
12486
- impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
12487
- { ALT: () => SUBRULE(iri2, void 0) },
12488
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
12489
- { ALT: () => SUBRULE(numericLiteral, void 0) },
12490
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
12213
+ return ACTION(() => tail.length === 0 ? head2 : C.factory.path(subType, [head2, ...tail], C.factory.sourceLocation(head2, tailEnd)));
12214
+ }
12215
+ };
12216
+ }
12217
+ var pathEltOrInverse = {
12218
+ name: "pathEltOrInverse",
12219
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR }) => (C) => OR([
12220
+ { ALT: () => SUBRULE1(pathElt) },
12491
12221
  { ALT: () => {
12492
- CONSUME(undef);
12493
- return void 0;
12222
+ const hat2 = CONSUME(symbols_exports.hat);
12223
+ const item = SUBRULE2(pathElt);
12224
+ return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12494
12225
  } }
12495
12226
  ])
12496
12227
  };
12497
- var minusGraphPattern = {
12498
- name: "minusGraphPattern",
12499
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12500
- const minus2 = CONSUME(minus);
12501
- const group = SUBRULE(groupGraphPattern, void 0);
12502
- return ACTION(() => C.factory.patternMinus(group.patterns, C.factory.sourceLocation(minus2, group)));
12503
- },
12504
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12505
- F2.printFilter(ast, () => PRINT_WORD("MINUS"));
12506
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12507
- }
12508
- };
12509
- var groupOrUnionGraphPattern = {
12510
- name: "groupOrUnionGraphPattern",
12511
- impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => {
12512
- const groups = [];
12513
- const group = SUBRULE1(groupGraphPattern, void 0);
12514
- groups.push(group);
12515
- MANY(() => {
12516
- CONSUME(union);
12517
- const group2 = SUBRULE2(groupGraphPattern, void 0);
12518
- groups.push(group2);
12519
- });
12520
- return ACTION(() => groups.length === 1 ? groups[0] : C.factory.patternUnion(
12521
- groups,
12522
- C.factory.sourceLocation(group, groups.at(-1))
12523
- ));
12524
- },
12525
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12526
- if (F2.isPatternUnion(ast)) {
12527
- const [head2, ...tail] = ast.patterns;
12528
- SUBRULE(groupGraphPattern, head2, void 0);
12529
- for (const pattern of tail) {
12530
- F2.printFilter(ast, () => PRINT_WORD("UNION"));
12531
- SUBRULE(groupGraphPattern, pattern, void 0);
12532
- }
12533
- } else {
12534
- SUBRULE(groupGraphPattern, ast, void 0);
12535
- }
12228
+ var pathSequence = pathChainHelper("pathSequence", symbols_exports.slash, "/", pathEltOrInverse);
12229
+ var pathAlternative = pathChainHelper("pathAlternative", symbols_exports.pipe, "|", pathSequence);
12230
+ var pathElt = {
12231
+ name: "pathElt",
12232
+ impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
12233
+ const item = SUBRULE(pathPrimary);
12234
+ const modification = OPTION(() => SUBRULE(pathMod));
12235
+ return ACTION(() => modification === void 0 ? item : C.factory.path(modification.image, [item], C.factory.sourceLocation(item, modification)));
12536
12236
  }
12537
12237
  };
12538
- var filter3 = {
12539
- name: "filter",
12540
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12541
- const filterToken = CONSUME(filter2);
12542
- const expression2 = SUBRULE(constraint, void 0);
12543
- return ACTION(() => C.factory.patternFilter(expression2, C.factory.sourceLocation(filterToken, expression2)));
12544
- },
12545
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12546
- F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
12547
- SUBRULE(expression, ast.expression, void 0);
12548
- F2.printFilter(ast, () => PRINT_WORD(")"));
12549
- }
12238
+ var pathMod = {
12239
+ name: "pathMod",
12240
+ impl: ({ CONSUME, OR }) => () => OR([
12241
+ { ALT: () => CONSUME(symbols_exports.question) },
12242
+ { ALT: () => CONSUME(symbols_exports.star) },
12243
+ { ALT: () => CONSUME(symbols_exports.opPlus) }
12244
+ ])
12550
12245
  };
12551
- var constraint = {
12552
- name: "constraint",
12553
- impl: ({ SUBRULE, OR }) => () => OR([
12554
- { ALT: () => SUBRULE(brackettedExpression, void 0) },
12555
- { ALT: () => SUBRULE(builtInCall, void 0) },
12556
- { ALT: () => SUBRULE(functionCall, void 0) }
12246
+ var pathPrimary = {
12247
+ name: "pathPrimary",
12248
+ impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
12249
+ { ALT: () => SUBRULE(iri2) },
12250
+ { ALT: () => SUBRULE(verbA) },
12251
+ { ALT: () => SUBRULE(pathNegatedPropertySet) },
12252
+ { ALT: () => {
12253
+ CONSUME(symbols_exports.LParen);
12254
+ const resRecursive = SUBRULE(path);
12255
+ CONSUME(symbols_exports.RParen);
12256
+ return resRecursive;
12257
+ } }
12557
12258
  ])
12558
12259
  };
12559
- var functionCall = {
12560
- name: "functionCall",
12561
- impl: ({ ACTION, SUBRULE }) => (C) => {
12562
- const func = SUBRULE(iri2, void 0);
12563
- const args = SUBRULE(argList, void 0);
12564
- return ACTION(() => C.factory.expressionFunctionCall(
12565
- func,
12566
- args.val.args,
12567
- args.val.distinct,
12568
- C.factory.sourceLocation(func, args)
12569
- ));
12260
+ var pathNegatedPropertySet = {
12261
+ name: "pathNegatedPropertySet",
12262
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, OR, MANY }) => (C) => {
12263
+ const exclamation2 = CONSUME(symbols_exports.exclamation);
12264
+ return OR([
12265
+ { ALT: () => {
12266
+ const noAlternative = SUBRULE1(pathOneInPropertySet);
12267
+ return ACTION(() => C.factory.path("!", [noAlternative], C.factory.sourceLocation(exclamation2, noAlternative)));
12268
+ } },
12269
+ { ALT: () => {
12270
+ const open = CONSUME(symbols_exports.LParen);
12271
+ const head2 = SUBRULE2(pathOneInPropertySet);
12272
+ const tail = [];
12273
+ MANY(() => {
12274
+ CONSUME(symbols_exports.pipe);
12275
+ const item = SUBRULE3(pathOneInPropertySet);
12276
+ tail.push(item);
12277
+ });
12278
+ const close = CONSUME(symbols_exports.RParen);
12279
+ return ACTION(() => {
12280
+ const F2 = C.factory;
12281
+ if (tail.length === 0) {
12282
+ return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
12283
+ }
12284
+ return F2.path(
12285
+ "!",
12286
+ [F2.path("|", [head2, ...tail], F2.sourceLocation(open, close))],
12287
+ F2.sourceLocation(exclamation2, close)
12288
+ );
12289
+ });
12290
+ } }
12291
+ ]);
12570
12292
  }
12571
12293
  };
12294
+ var pathOneInPropertySet = {
12295
+ name: "pathOneInPropertySet",
12296
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
12297
+ { ALT: () => SUBRULE1(iri2) },
12298
+ { ALT: () => SUBRULE1(verbA) },
12299
+ { ALT: () => {
12300
+ const hat2 = CONSUME(symbols_exports.hat);
12301
+ const item = OR2([
12302
+ { ALT: () => SUBRULE2(iri2) },
12303
+ { ALT: () => SUBRULE2(verbA) }
12304
+ ]);
12305
+ return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12306
+ } }
12307
+ ])
12308
+ };
12572
12309
 
12573
- // ../rules-sparql-1-1/lib/expressionHelpers.ts
12574
- function funcExpr1(func) {
12575
- return {
12576
- name: unCapitalize(func.name),
12577
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12578
- const operator = CONSUME(func);
12579
- CONSUME(symbols_exports.LParen);
12580
- const arg = SUBRULE(expression, void 0);
12581
- const close = CONSUME(symbols_exports.RParen);
12582
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12583
- }
12310
+ // ../rules-sparql-1-1/lib/grammar/tripleBlock.ts
12311
+ function triplesDotSeperated(triplesSameSubjectSubrule) {
12312
+ return ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME, OPTION }) => (C) => {
12313
+ const triples = [];
12314
+ let parsedDot = true;
12315
+ let dotToken;
12316
+ AT_LEAST_ONE({
12317
+ GATE: () => parsedDot,
12318
+ DEF: () => {
12319
+ parsedDot = false;
12320
+ const template = SUBRULE(triplesSameSubjectSubrule);
12321
+ ACTION(() => {
12322
+ triples.push(...template);
12323
+ });
12324
+ OPTION(() => {
12325
+ dotToken = CONSUME(symbols_exports.dot);
12326
+ parsedDot = true;
12327
+ });
12328
+ }
12329
+ });
12330
+ return ACTION(() => C.factory.patternBgp(triples, C.factory.sourceLocation(...triples, dotToken)));
12584
12331
  };
12585
12332
  }
12586
- function funcExpr2(func) {
12587
- return {
12588
- name: unCapitalize(func.name),
12589
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {
12590
- const operator = CONSUME(func);
12591
- CONSUME(symbols_exports.LParen);
12592
- const arg1 = SUBRULE1(expression, void 0);
12593
- CONSUME(symbols_exports.comma);
12594
- const arg2 = SUBRULE2(expression, void 0);
12595
- const close = CONSUME(symbols_exports.RParen);
12596
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2], C.factory.sourceLocation(operator, close)));
12333
+ var triplesBlock = {
12334
+ name: "triplesBlock",
12335
+ impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
12336
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12337
+ for (const [index, triple] of ast.triples.entries()) {
12338
+ HANDLE_LOC(triple, () => {
12339
+ const nextTriple = ast.triples.at(index);
12340
+ if (F2.isTripleCollection(triple)) {
12341
+ SUBRULE(graphNodePath, triple);
12342
+ F2.printFilter(triple, () => PRINT_WORD("."));
12343
+ } else {
12344
+ SUBRULE(graphNodePath, triple.subject);
12345
+ if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12346
+ SUBRULE(varOrTerm, triple.predicate);
12347
+ } else {
12348
+ SUBRULE(pathGenerator, triple.predicate, void 0);
12349
+ }
12350
+ SUBRULE(graphNodePath, triple.object);
12351
+ if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12352
+ F2.printFilter(ast, () => PRINT_WORD("."));
12353
+ } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12354
+ F2.printFilter(ast, () => PRINT_WORD(","));
12355
+ } else {
12356
+ F2.printFilter(ast, () => PRINT_WORD(";"));
12357
+ }
12358
+ }
12359
+ });
12597
12360
  }
12598
- };
12599
- }
12600
- function funcExpr3(func) {
12361
+ }
12362
+ };
12363
+ function triplesSameSubjectImpl(name, allowPaths) {
12601
12364
  return {
12602
- name: unCapitalize(func.name),
12603
- impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {
12604
- const operator = CONSUME(func);
12605
- CONSUME(symbols_exports.LParen);
12606
- const arg1 = SUBRULE1(expression, void 0);
12607
- CONSUME1(symbols_exports.comma);
12608
- const arg2 = SUBRULE2(expression, void 0);
12609
- CONSUME2(symbols_exports.comma);
12610
- const arg3 = SUBRULE3(expression, void 0);
12611
- const close = CONSUME(symbols_exports.RParen);
12612
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
12613
- }
12365
+ name,
12366
+ impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
12367
+ { ALT: () => {
12368
+ const subject = SUBRULE(varOrTerm);
12369
+ const res = SUBRULE(
12370
+ allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty,
12371
+ ACTION(() => C.factory.dematerialized(subject))
12372
+ );
12373
+ return ACTION(() => {
12374
+ if (res.length > 0) {
12375
+ res[0].subject = subject;
12376
+ res[0].loc = C.factory.sourceLocation(subject, res[0]);
12377
+ }
12378
+ return res;
12379
+ });
12380
+ } },
12381
+ { ALT: () => {
12382
+ const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode);
12383
+ const restNode = SUBRULE(
12384
+ allowPaths ? propertyListPath : propertyList,
12385
+ ACTION(() => C.factory.graphNodeIdentifier(subjectNode))
12386
+ );
12387
+ return ACTION(() => {
12388
+ if (restNode.length === 0) {
12389
+ return [subjectNode];
12390
+ }
12391
+ restNode[0].subject = subjectNode;
12392
+ restNode[0].loc = C.factory.sourceLocation(subjectNode, restNode[0]);
12393
+ return restNode;
12394
+ });
12395
+ } }
12396
+ ])
12614
12397
  };
12615
12398
  }
12616
- function funcVar1(func) {
12399
+ var triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
12400
+ var triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
12401
+ var triplesTemplate = {
12402
+ name: "triplesTemplate",
12403
+ impl: triplesDotSeperated(triplesSameSubject)
12404
+ };
12405
+ function propertyListImpl(name, allowPaths) {
12617
12406
  return {
12618
- name: unCapitalize(func.name),
12619
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12620
- const operator = CONSUME(func);
12621
- CONSUME(symbols_exports.LParen);
12622
- const arg = SUBRULE(var_, void 0);
12623
- const close = CONSUME(symbols_exports.RParen);
12624
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12625
- }
12407
+ name,
12408
+ impl: ({ SUBRULE, OPTION }) => (_, subject) => OPTION(() => SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, subject)) ?? []
12626
12409
  };
12627
12410
  }
12628
- function funcExprOrNil1(func) {
12411
+ var propertyList = propertyListImpl("propertyList", false);
12412
+ var propertyListPath = propertyListImpl("propertyListPath", true);
12413
+ function propertyListNotEmptyImplementation(name, allowPaths) {
12629
12414
  return {
12630
- name: unCapitalize(func.name),
12631
- impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
12632
- const operator = CONSUME(func);
12633
- return OR([
12634
- { ALT: () => {
12635
- CONSUME(symbols_exports.LParen);
12636
- const arg = SUBRULE(expression, void 0);
12637
- const close = CONSUME(symbols_exports.RParen);
12638
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12639
- } },
12640
- { ALT: () => {
12641
- const nil2 = CONSUME(terminals_exports.nil);
12642
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12643
- } }
12644
- ]);
12415
+ name,
12416
+ impl: ({ ACTION, CONSUME, AT_LEAST_ONE, SUBRULE1, MANY2, OR1 }) => (_, subject) => {
12417
+ const result = [];
12418
+ let parsedSemi = true;
12419
+ AT_LEAST_ONE({
12420
+ GATE: () => parsedSemi,
12421
+ DEF: () => {
12422
+ parsedSemi = false;
12423
+ const predicate = allowPaths ? OR1([
12424
+ { ALT: () => SUBRULE1(verbPath) },
12425
+ { ALT: () => SUBRULE1(verbSimple) }
12426
+ ]) : SUBRULE1(verb);
12427
+ const triples = SUBRULE1(
12428
+ allowPaths ? objectListPath : objectList,
12429
+ subject,
12430
+ predicate
12431
+ );
12432
+ MANY2(() => {
12433
+ CONSUME(symbols_exports.semi);
12434
+ parsedSemi = true;
12435
+ });
12436
+ ACTION(() => {
12437
+ result.push(...triples);
12438
+ });
12439
+ }
12440
+ });
12441
+ return result;
12645
12442
  }
12646
12443
  };
12647
12444
  }
12648
- function funcNil1(func) {
12445
+ var propertyListNotEmpty = propertyListNotEmptyImplementation("propertyListNotEmpty", false);
12446
+ var propertyListPathNotEmpty = propertyListNotEmptyImplementation("propertyListPathNotEmpty", true);
12447
+ var verbPath = {
12448
+ name: "verbPath",
12449
+ impl: ({ SUBRULE }) => () => SUBRULE(path)
12450
+ };
12451
+ var verbSimple = {
12452
+ name: "verbSimple",
12453
+ impl: ({ SUBRULE }) => () => SUBRULE(var_)
12454
+ };
12455
+ function objectListImpl(name, allowPaths) {
12649
12456
  return {
12650
- name: unCapitalize(func.name),
12651
- impl: ({ ACTION, CONSUME }) => (C) => {
12652
- const operator = CONSUME(func);
12653
- const nil2 = CONSUME(terminals_exports.nil);
12654
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12457
+ name,
12458
+ impl: ({ ACTION, SUBRULE, AT_LEAST_ONE_SEP }) => (_, subj, pred) => {
12459
+ const objects = [];
12460
+ AT_LEAST_ONE_SEP({
12461
+ SEP: symbols_exports.comma,
12462
+ DEF: () => {
12463
+ const objectTriple = SUBRULE(allowPaths ? objectPath : object, subj, pred);
12464
+ ACTION(() => {
12465
+ objects.push(objectTriple);
12466
+ });
12467
+ }
12468
+ });
12469
+ return objects;
12655
12470
  }
12656
12471
  };
12657
12472
  }
12658
- function funcExprList1(func) {
12473
+ var objectList = objectListImpl("objectList", false);
12474
+ var objectListPath = objectListImpl("objectListPath", true);
12475
+ function objectImpl(name, allowPaths) {
12659
12476
  return {
12660
- name: unCapitalize(func.name),
12661
- impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
12662
- const operator = CONSUME(func);
12663
- const args = SUBRULE(expressionList, void 0);
12664
- return ACTION(() => C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));
12477
+ name,
12478
+ impl: ({ ACTION, SUBRULE }) => (C, subject, predicate) => {
12479
+ const node = SUBRULE(allowPaths ? graphNodePath : graphNode);
12480
+ return ACTION(() => C.factory.triple(subject, predicate, node));
12665
12481
  }
12666
12482
  };
12667
12483
  }
12668
- function funcExpr2or3(func) {
12484
+ var object = objectImpl("object", false);
12485
+ var objectPath = objectImpl("objectPath", true);
12486
+ function collectionImpl(name, allowPaths) {
12669
12487
  return {
12670
- name: unCapitalize(func.name),
12671
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) => (C) => {
12672
- const operator = CONSUME(func);
12673
- CONSUME(symbols_exports.LParen);
12674
- const arg1 = SUBRULE1(expression, void 0);
12675
- CONSUME1(symbols_exports.comma);
12676
- const arg2 = SUBRULE2(expression, void 0);
12677
- const arg3 = OPTION(() => {
12678
- CONSUME2(symbols_exports.comma);
12679
- return SUBRULE3(expression, void 0);
12488
+ name,
12489
+ impl: ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME }) => (C) => {
12490
+ const terms = [];
12491
+ const startToken = CONSUME(symbols_exports.LParen);
12492
+ AT_LEAST_ONE(() => {
12493
+ terms.push(SUBRULE(allowPaths ? graphNodePath : graphNode));
12680
12494
  });
12681
- const close = CONSUME(symbols_exports.RParen);
12682
- return ACTION(() => C.factory.expressionOperation(
12683
- operator.image,
12684
- arg3 ? [arg1, arg2, arg3] : [arg1, arg2],
12685
- C.factory.sourceLocation(operator, close)
12686
- ));
12495
+ const endToken = CONSUME(symbols_exports.RParen);
12496
+ return ACTION(() => {
12497
+ const F2 = C.factory;
12498
+ const triples = [];
12499
+ const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" /* FIRST */, void 0);
12500
+ const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" /* REST */, void 0);
12501
+ const predNil = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */, void 0);
12502
+ const listHead = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12503
+ let iterHead = listHead;
12504
+ for (const [index, term] of terms.entries()) {
12505
+ const lastInList = index === terms.length - 1;
12506
+ const headTriple = F2.triple(
12507
+ iterHead,
12508
+ predFirst,
12509
+ term
12510
+ );
12511
+ triples.push(headTriple);
12512
+ if (lastInList) {
12513
+ const nilTriple = F2.triple(iterHead, predRest, predNil);
12514
+ triples.push(nilTriple);
12515
+ } else {
12516
+ const tail = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12517
+ const linkTriple = F2.triple(iterHead, predRest, tail);
12518
+ triples.push(linkTriple);
12519
+ iterHead = tail;
12520
+ }
12521
+ }
12522
+ return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
12523
+ });
12524
+ },
12525
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12526
+ F2.printFilter(ast, () => PRINT_WORD("("));
12527
+ for (const [idx, triple] of ast.triples.entries()) {
12528
+ if (idx % 2 === 0) {
12529
+ SUBRULE(allowPaths ? graphNodePath : graphNode, triple.object);
12530
+ }
12531
+ }
12532
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12687
12533
  }
12688
12534
  };
12689
12535
  }
12690
- function funcExpr3or4(func) {
12536
+ var collection = collectionImpl("collection", false);
12537
+ var collectionPath = collectionImpl("collectionPath", true);
12538
+ function triplesNodeImpl(name, allowPaths) {
12691
12539
  return {
12692
- name: unCapitalize(func.name),
12693
- impl: ({
12694
- ACTION,
12695
- CONSUME,
12696
- SUBRULE1,
12697
- SUBRULE2,
12698
- SUBRULE3,
12699
- SUBRULE4,
12700
- CONSUME1,
12701
- OPTION,
12702
- CONSUME2,
12703
- CONSUME3
12704
- }) => (C) => {
12705
- const operator = CONSUME(func);
12706
- CONSUME(symbols_exports.LParen);
12707
- const arg1 = SUBRULE1(expression, void 0);
12708
- CONSUME1(symbols_exports.comma);
12709
- const arg2 = SUBRULE2(expression, void 0);
12710
- CONSUME2(symbols_exports.comma);
12711
- const arg3 = SUBRULE3(expression, void 0);
12712
- const arg4 = OPTION(() => {
12713
- CONSUME3(symbols_exports.comma);
12714
- return SUBRULE4(expression, void 0);
12715
- });
12716
- const close = CONSUME(symbols_exports.RParen);
12717
- return ACTION(() => C.factory.expressionOperation(
12718
- operator.image,
12719
- arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3],
12720
- C.factory.sourceLocation(operator, close)
12721
- ));
12722
- }
12540
+ name,
12541
+ impl: ({ SUBRULE, OR }) => () => OR([
12542
+ { ALT: () => SUBRULE(allowPaths ? collectionPath : collection) },
12543
+ { ALT: () => SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList) }
12544
+ ]),
12545
+ gImpl: ({ SUBRULE }) => (ast) => ast.subType === "list" ? SUBRULE(allowPaths ? collectionPath : collection, ast) : SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, ast)
12723
12546
  };
12724
12547
  }
12725
- function funcGroupGraphPattern(func) {
12548
+ var triplesNode = triplesNodeImpl("triplesNode", false);
12549
+ var triplesNodePath = triplesNodeImpl("triplesNodePath", true);
12550
+ function blankNodePropertyListImpl(name, allowPaths) {
12551
+ const propertyPathNotEmptyImpl = allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty;
12726
12552
  return {
12727
- name: unCapitalize(func.name),
12553
+ name,
12728
12554
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12729
- const operator = CONSUME(func);
12730
- const group = SUBRULE(groupGraphPattern, void 0);
12731
- return ACTION(() => C.factory.expressionPatternOperation(
12732
- operator.image,
12733
- group,
12734
- C.factory.sourceLocation(operator, group)
12555
+ const startToken = CONSUME(symbols_exports.LSquare);
12556
+ const blankNode2 = ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocationNoMaterialize()));
12557
+ const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
12558
+ const endToken = CONSUME(symbols_exports.RSquare);
12559
+ return ACTION(() => C.factory.tripleCollectionBlankNodeProperties(
12560
+ blankNode2,
12561
+ propList,
12562
+ C.factory.sourceLocation(startToken, endToken)
12735
12563
  ));
12564
+ },
12565
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12566
+ F2.printFilter(ast, () => PRINT("["));
12567
+ for (const triple of ast.triples) {
12568
+ HANDLE_LOC(triple, () => {
12569
+ if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12570
+ SUBRULE(varOrTerm, triple.predicate);
12571
+ } else {
12572
+ SUBRULE(pathGenerator, triple.predicate, void 0);
12573
+ }
12574
+ SUBRULE(graphNodePath, triple.object);
12575
+ F2.printFilter(ast, () => PRINT_WORD(";"));
12576
+ });
12577
+ }
12578
+ F2.printFilter(ast, () => PRINT("]"));
12736
12579
  }
12737
12580
  };
12738
12581
  }
12739
- function baseAggregateFunc(func) {
12582
+ var blankNodePropertyList = blankNodePropertyListImpl("blankNodePropertyList", false);
12583
+ var blankNodePropertyListPath = blankNodePropertyListImpl("blankNodePropertyListPath", true);
12584
+ function graphNodeImpl(name, allowPaths) {
12585
+ const triplesNodeRule = allowPaths ? triplesNodePath : triplesNode;
12740
12586
  return {
12741
- name: unCapitalize(func.name),
12742
- impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
12743
- const operator = CONSUME(func);
12744
- CONSUME(symbols_exports.LParen);
12745
- const distinct2 = OPTION(() => CONSUME(distinct));
12746
- const expr1 = SUBRULE(expression, void 0);
12747
- const close = CONSUME(symbols_exports.RParen);
12748
- return ACTION(() => C.factory.aggregate(
12749
- operator.image,
12750
- distinct2 !== void 0,
12751
- expr1,
12752
- void 0,
12753
- C.factory.sourceLocation(operator, close)
12754
- ));
12587
+ name,
12588
+ impl: ({ SUBRULE, OR }) => (C) => OR([
12589
+ { ALT: () => SUBRULE(varOrTerm) },
12590
+ {
12591
+ GATE: () => C.parseMode.has("canCreateBlankNodes"),
12592
+ ALT: () => SUBRULE(triplesNodeRule)
12593
+ }
12594
+ ]),
12595
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12596
+ if (F2.isTerm(ast)) {
12597
+ SUBRULE(varOrTerm, ast);
12598
+ } else {
12599
+ SUBRULE(triplesNodeRule, ast);
12600
+ }
12755
12601
  }
12756
12602
  };
12757
12603
  }
12604
+ var graphNode = graphNodeImpl("graphNode", false);
12605
+ var graphNodePath = graphNodeImpl("graphNodePath", true);
12758
12606
 
12759
- // ../rules-sparql-1-1/lib/grammar/builtIn.ts
12760
- var builtInStr = funcExpr1(BuildinCalls_exports.str);
12761
- var builtInLang = funcExpr1(BuildinCalls_exports.lang);
12762
- var builtInLangmatches = funcExpr2(BuildinCalls_exports.langmatches);
12763
- var builtInDatatype = funcExpr1(BuildinCalls_exports.datatype);
12764
- var builtInBound = funcVar1(BuildinCalls_exports.bound);
12765
- var builtInIri = funcExpr1(BuildinCalls_exports.iri);
12766
- var builtInUri = funcExpr1(BuildinCalls_exports.uri);
12767
- var builtInBnodeSparqlJs = funcExprOrNil1(BuildinCalls_exports.bnode);
12768
- var builtInRand = funcNil1(BuildinCalls_exports.rand);
12769
- var builtInAbs = funcExpr1(BuildinCalls_exports.abs);
12770
- var builtInCeil = funcExpr1(BuildinCalls_exports.ceil);
12771
- var builtInFloor = funcExpr1(BuildinCalls_exports.floor);
12772
- var builtInRound = funcExpr1(BuildinCalls_exports.round);
12773
- var builtInConcat = funcExprList1(BuildinCalls_exports.concat);
12774
- var builtInStrlen = funcExpr1(BuildinCalls_exports.strlen);
12775
- var builtInUcase = funcExpr1(BuildinCalls_exports.ucase);
12776
- var builtInLcase = funcExpr1(BuildinCalls_exports.lcase);
12777
- var builtInEncode_for_uri = funcExpr1(BuildinCalls_exports.encode_for_uri);
12778
- var builtInContains = funcExpr2(BuildinCalls_exports.contains);
12779
- var builtInStrstarts = funcExpr2(BuildinCalls_exports.strstarts);
12780
- var builtInStrends = funcExpr2(BuildinCalls_exports.strends);
12781
- var builtInStrbefore = funcExpr2(BuildinCalls_exports.strbefore);
12782
- var builtInStrafter = funcExpr2(BuildinCalls_exports.strafter);
12783
- var builtInYear = funcExpr1(BuildinCalls_exports.year);
12784
- var builtInMonth = funcExpr1(BuildinCalls_exports.month);
12785
- var builtInDay = funcExpr1(BuildinCalls_exports.day);
12786
- var builtInHours = funcExpr1(BuildinCalls_exports.hours);
12787
- var builtInMinutes = funcExpr1(BuildinCalls_exports.minutes);
12788
- var builtInSeconds = funcExpr1(BuildinCalls_exports.seconds);
12789
- var builtInTimezone = funcExpr1(BuildinCalls_exports.timezone);
12790
- var builtInTz = funcExpr1(BuildinCalls_exports.tz);
12791
- var builtInNow = funcNil1(BuildinCalls_exports.now);
12792
- var builtInUuid = funcNil1(BuildinCalls_exports.uuid);
12793
- var builtInStruuid = funcNil1(BuildinCalls_exports.struuid);
12794
- var builtInMd5 = funcExpr1(BuildinCalls_exports.md5);
12795
- var builtInSha1 = funcExpr1(BuildinCalls_exports.sha1);
12796
- var builtInSha256 = funcExpr1(BuildinCalls_exports.sha256);
12797
- var builtInSha384 = funcExpr1(BuildinCalls_exports.sha384);
12798
- var builtInSha512 = funcExpr1(BuildinCalls_exports.sha512);
12799
- var builtInCoalesce = funcExprList1(BuildinCalls_exports.coalesce);
12800
- var builtInIf = funcExpr3(BuildinCalls_exports.if_);
12801
- var builtInStrlang = funcExpr2(BuildinCalls_exports.strlang);
12802
- var builtInStrdt = funcExpr2(BuildinCalls_exports.strdt);
12803
- var builtInSameterm = funcExpr2(BuildinCalls_exports.sameterm);
12804
- var builtInIsiri = funcExpr1(BuildinCalls_exports.isiri);
12805
- var builtInIsuri = funcExpr1(BuildinCalls_exports.isuri);
12806
- var builtInIsblank = funcExpr1(BuildinCalls_exports.isblank);
12807
- var builtInIsliteral = funcExpr1(BuildinCalls_exports.isliteral);
12808
- var builtInIsnumeric = funcExpr1(BuildinCalls_exports.isnumeric);
12809
- function builtInCallList(SUBRULE) {
12810
- return [
12811
- { ALT: () => SUBRULE(aggregate, void 0) },
12812
- { ALT: () => SUBRULE(builtInStr, void 0) },
12813
- { ALT: () => SUBRULE(builtInLang, void 0) },
12814
- { ALT: () => SUBRULE(builtInLangmatches, void 0) },
12815
- { ALT: () => SUBRULE(builtInDatatype, void 0) },
12816
- { ALT: () => SUBRULE(builtInBound, void 0) },
12817
- { ALT: () => SUBRULE(builtInIri, void 0) },
12818
- { ALT: () => SUBRULE(builtInUri, void 0) },
12819
- { ALT: () => SUBRULE(builtInBnodeSparqlJs, void 0) },
12820
- { ALT: () => SUBRULE(builtInRand, void 0) },
12821
- { ALT: () => SUBRULE(builtInAbs, void 0) },
12822
- { ALT: () => SUBRULE(builtInCeil, void 0) },
12823
- { ALT: () => SUBRULE(builtInFloor, void 0) },
12824
- { ALT: () => SUBRULE(builtInRound, void 0) },
12825
- { ALT: () => SUBRULE(builtInConcat, void 0) },
12826
- { ALT: () => SUBRULE(substringExpression, void 0) },
12827
- { ALT: () => SUBRULE(builtInStrlen, void 0) },
12828
- { ALT: () => SUBRULE(strReplaceExpression, void 0) },
12829
- { ALT: () => SUBRULE(builtInUcase, void 0) },
12830
- { ALT: () => SUBRULE(builtInLcase, void 0) },
12831
- { ALT: () => SUBRULE(builtInEncode_for_uri, void 0) },
12832
- { ALT: () => SUBRULE(builtInContains, void 0) },
12833
- { ALT: () => SUBRULE(builtInStrstarts, void 0) },
12834
- { ALT: () => SUBRULE(builtInStrends, void 0) },
12835
- { ALT: () => SUBRULE(builtInStrbefore, void 0) },
12836
- { ALT: () => SUBRULE(builtInStrafter, void 0) },
12837
- { ALT: () => SUBRULE(builtInYear, void 0) },
12838
- { ALT: () => SUBRULE(builtInMonth, void 0) },
12839
- { ALT: () => SUBRULE(builtInDay, void 0) },
12840
- { ALT: () => SUBRULE(builtInHours, void 0) },
12841
- { ALT: () => SUBRULE(builtInMinutes, void 0) },
12842
- { ALT: () => SUBRULE(builtInSeconds, void 0) },
12843
- { ALT: () => SUBRULE(builtInTimezone, void 0) },
12844
- { ALT: () => SUBRULE(builtInTz, void 0) },
12845
- { ALT: () => SUBRULE(builtInNow, void 0) },
12846
- { ALT: () => SUBRULE(builtInUuid, void 0) },
12847
- { ALT: () => SUBRULE(builtInStruuid, void 0) },
12848
- { ALT: () => SUBRULE(builtInMd5, void 0) },
12849
- { ALT: () => SUBRULE(builtInSha1, void 0) },
12850
- { ALT: () => SUBRULE(builtInSha256, void 0) },
12851
- { ALT: () => SUBRULE(builtInSha384, void 0) },
12852
- { ALT: () => SUBRULE(builtInSha512, void 0) },
12853
- { ALT: () => SUBRULE(builtInCoalesce, void 0) },
12854
- { ALT: () => SUBRULE(builtInIf, void 0) },
12855
- { ALT: () => SUBRULE(builtInStrlang, void 0) },
12856
- { ALT: () => SUBRULE(builtInStrdt, void 0) },
12857
- { ALT: () => SUBRULE(builtInSameterm, void 0) },
12858
- { ALT: () => SUBRULE(builtInIsiri, void 0) },
12859
- { ALT: () => SUBRULE(builtInIsuri, void 0) },
12860
- { ALT: () => SUBRULE(builtInIsblank, void 0) },
12861
- { ALT: () => SUBRULE(builtInIsliteral, void 0) },
12862
- { ALT: () => SUBRULE(builtInIsnumeric, void 0) },
12863
- { ALT: () => SUBRULE(regexExpression, void 0) },
12864
- { ALT: () => SUBRULE(existsFunc, void 0) },
12865
- { ALT: () => SUBRULE(notExistsFunc, void 0) }
12866
- ];
12867
- }
12868
- var builtInCall = {
12869
- name: "builtInCall",
12870
- impl: ({ OR, SUBRULE, cache }) => () => {
12871
- const cached = cache.get(builtInCall);
12872
- if (cached) {
12873
- return OR(cached);
12874
- }
12875
- const builtIns = builtInCallList(SUBRULE);
12876
- cache.set(builtInCall, builtIns);
12877
- return OR(builtIns);
12607
+ // ../rules-sparql-1-1/lib/grammar/whereClause.ts
12608
+ var whereClause = {
12609
+ name: "whereClause",
12610
+ impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
12611
+ const where2 = OPTION(() => CONSUME(where));
12612
+ const group = SUBRULE(groupGraphPattern);
12613
+ return ACTION(() => C.factory.wrap(group, C.factory.sourceLocation(where2, group)));
12614
+ },
12615
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12616
+ F2.printFilter(ast, () => PRINT_WORD("WHERE"));
12617
+ SUBRULE(groupGraphPattern, ast.val);
12878
12618
  }
12879
12619
  };
12880
- var regexExpression = funcExpr2or3(BuildinCalls_exports.regex);
12881
- var substringExpression = funcExpr2or3(BuildinCalls_exports.substr);
12882
- var strReplaceExpression = funcExpr3or4(BuildinCalls_exports.replace);
12883
- var existsFunc = funcGroupGraphPattern(BuildinCalls_exports.exists);
12884
- var notExistsFunc = funcGroupGraphPattern(BuildinCalls_exports.notexists);
12885
- var aggregateCount = {
12886
- name: unCapitalize(BuildinCalls_exports.count.name),
12887
- impl: ({ ACTION, CONSUME, SUBRULE, OR, OPTION }) => (C) => {
12888
- const operatorToken = CONSUME(BuildinCalls_exports.count);
12889
- CONSUME(symbols_exports.LParen);
12890
- const distinctToken = OPTION(() => CONSUME(distinct));
12891
- const expressionVal = OR([
12892
- { ALT: () => {
12893
- const starToken = CONSUME(symbols_exports.star);
12894
- return ACTION(() => C.factory.wildcard(C.factory.sourceLocation(starToken)));
12895
- } },
12896
- { ALT: () => SUBRULE(expression, void 0) }
12620
+ var groupGraphPattern = {
12621
+ name: "groupGraphPattern",
12622
+ impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
12623
+ const open = CONSUME(symbols_exports.LCurly);
12624
+ const patterns = OR([
12625
+ { ALT: () => [SUBRULE(subSelect)] },
12626
+ { ALT: () => SUBRULE(groupGraphPatternSub) }
12897
12627
  ]);
12898
- const closeToken = CONSUME(symbols_exports.RParen);
12899
- return ACTION(() => {
12900
- const F2 = C.factory;
12901
- if (C.factory.isWildcard(expressionVal)) {
12902
- return F2.aggregate(
12903
- operatorToken.image,
12904
- Boolean(distinctToken),
12905
- expressionVal,
12906
- void 0,
12907
- C.factory.sourceLocation(operatorToken, closeToken)
12908
- );
12628
+ const close = CONSUME(symbols_exports.RCurly);
12629
+ return ACTION(() => C.factory.patternGroup(patterns, C.factory.sourceLocation(open, close)));
12630
+ },
12631
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12632
+ F2.printFilter(ast, () => PRINT_WORD("{"));
12633
+ for (const pattern of ast.patterns) {
12634
+ SUBRULE(generatePattern, pattern);
12635
+ }
12636
+ F2.printFilter(ast, () => PRINT_WORD("}"));
12637
+ }
12638
+ };
12639
+ var generatePattern = {
12640
+ name: "generatePattern",
12641
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12642
+ if (ast.type === "query") {
12643
+ SUBRULE(query, F2.querySelect({
12644
+ context: [],
12645
+ datasets: F2.datasetClauses([], F2.sourceLocation()),
12646
+ where: ast.where,
12647
+ variables: ast.variables,
12648
+ solutionModifiers: ast.solutionModifiers,
12649
+ values: ast.values,
12650
+ distinct: ast.distinct,
12651
+ reduced: ast.reduced
12652
+ }, ast.loc));
12653
+ } else if (ast.subType === "group") {
12654
+ SUBRULE(groupGraphPattern, ast);
12655
+ } else if (ast.subType === "bgp") {
12656
+ SUBRULE(triplesBlock, ast);
12657
+ } else {
12658
+ SUBRULE(graphPatternNotTriples, ast);
12659
+ }
12660
+ }
12661
+ };
12662
+ var groupGraphPatternSub = {
12663
+ name: "groupGraphPatternSub",
12664
+ impl: ({ ACTION, SUBRULE, CONSUME, MANY, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OPTION3 }) => () => {
12665
+ const patterns = [];
12666
+ const bgpPattern = OPTION1(() => SUBRULE1(triplesBlock));
12667
+ if (bgpPattern) {
12668
+ patterns.push(bgpPattern);
12669
+ }
12670
+ MANY(() => {
12671
+ const notTriples = SUBRULE(graphPatternNotTriples);
12672
+ patterns.push(notTriples);
12673
+ OPTION2(() => CONSUME(symbols_exports.dot));
12674
+ const moreTriples = OPTION3(() => SUBRULE2(triplesBlock));
12675
+ if (moreTriples) {
12676
+ patterns.push(moreTriples);
12677
+ }
12678
+ });
12679
+ ACTION(() => checkNote13(patterns));
12680
+ return patterns;
12681
+ }
12682
+ };
12683
+ var graphPatternNotTriples = {
12684
+ name: "graphPatternNotTriples",
12685
+ impl: ({ SUBRULE, OR }) => () => OR([
12686
+ { ALT: () => SUBRULE(groupOrUnionGraphPattern) },
12687
+ { ALT: () => SUBRULE(optionalGraphPattern) },
12688
+ { ALT: () => SUBRULE(minusGraphPattern) },
12689
+ { ALT: () => SUBRULE(graphGraphPattern) },
12690
+ { ALT: () => SUBRULE(serviceGraphPattern) },
12691
+ { ALT: () => SUBRULE(filter3) },
12692
+ { ALT: () => SUBRULE(bind2) },
12693
+ { ALT: () => SUBRULE(inlineData) }
12694
+ ]),
12695
+ gImpl: ({ SUBRULE }) => (ast) => {
12696
+ switch (ast.subType) {
12697
+ case "group":
12698
+ case "union":
12699
+ SUBRULE(groupOrUnionGraphPattern, ast);
12700
+ break;
12701
+ case "optional":
12702
+ SUBRULE(optionalGraphPattern, ast);
12703
+ break;
12704
+ case "minus":
12705
+ SUBRULE(minusGraphPattern, ast);
12706
+ break;
12707
+ case "graph":
12708
+ SUBRULE(graphGraphPattern, ast);
12709
+ break;
12710
+ case "service":
12711
+ SUBRULE(serviceGraphPattern, ast);
12712
+ break;
12713
+ case "filter":
12714
+ SUBRULE(filter3, ast);
12715
+ break;
12716
+ case "bind":
12717
+ SUBRULE(bind2, ast);
12718
+ break;
12719
+ case "values":
12720
+ SUBRULE(inlineData, ast);
12721
+ break;
12722
+ }
12723
+ }
12724
+ };
12725
+ var optionalGraphPattern = {
12726
+ name: "optionalGraphPattern",
12727
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12728
+ const optional2 = CONSUME(optional);
12729
+ const group = SUBRULE(groupGraphPattern);
12730
+ return ACTION(() => C.factory.patternOptional(group.patterns, C.factory.sourceLocation(optional2, group)));
12731
+ },
12732
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12733
+ F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
12734
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12735
+ }
12736
+ };
12737
+ var graphGraphPattern = {
12738
+ name: "graphGraphPattern",
12739
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12740
+ const graph2 = CONSUME(graph_exports.graph);
12741
+ const name = SUBRULE(varOrIri);
12742
+ const group = SUBRULE(groupGraphPattern);
12743
+ return ACTION(() => C.factory.patternGraph(name, group.patterns, C.factory.sourceLocation(graph2, group)));
12744
+ },
12745
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12746
+ F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
12747
+ SUBRULE(varOrTerm, ast.name);
12748
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12749
+ }
12750
+ };
12751
+ var serviceGraphPattern = {
12752
+ name: "serviceGraphPattern",
12753
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
12754
+ const service2 = CONSUME(service);
12755
+ const silent2 = OPTION(() => {
12756
+ CONSUME(silent);
12757
+ return true;
12758
+ }) ?? false;
12759
+ const name = SUBRULE1(varOrIri);
12760
+ const group = SUBRULE1(groupGraphPattern);
12761
+ return ACTION(() => C.factory.patternService(name, group.patterns, silent2, C.factory.sourceLocation(service2, group)));
12762
+ },
12763
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12764
+ F2.printFilter(ast, () => {
12765
+ PRINT_WORD("SERVICE");
12766
+ if (ast.silent) {
12767
+ PRINT_WORD("SILENT");
12909
12768
  }
12910
- return F2.aggregate(
12911
- operatorToken.image,
12912
- Boolean(distinctToken),
12913
- expressionVal,
12914
- void 0,
12915
- C.factory.sourceLocation(operatorToken, closeToken)
12916
- );
12917
12769
  });
12770
+ SUBRULE(varOrTerm, ast.name);
12771
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12918
12772
  }
12919
12773
  };
12920
- var aggregateSum = baseAggregateFunc(BuildinCalls_exports.sum);
12921
- var aggregateMin = baseAggregateFunc(BuildinCalls_exports.min);
12922
- var aggregateMax = baseAggregateFunc(BuildinCalls_exports.max);
12923
- var aggregateAvg = baseAggregateFunc(BuildinCalls_exports.avg);
12924
- var aggregateSample = baseAggregateFunc(BuildinCalls_exports.sample);
12925
- var aggregateGroup_concat = {
12926
- name: unCapitalize(BuildinCalls_exports.groupConcat.name),
12927
- impl: ({ ACTION, CONSUME, OPTION1, SUBRULE, OPTION2 }) => (C) => {
12928
- const operatorToken = CONSUME(BuildinCalls_exports.groupConcat);
12774
+ var bind2 = {
12775
+ name: "bind",
12776
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12777
+ const bind3 = CONSUME(bind);
12929
12778
  CONSUME(symbols_exports.LParen);
12930
- const distinctToken = OPTION1(() => CONSUME(distinct));
12931
- const expr = SUBRULE(expression, void 0);
12932
- const sep = OPTION2(() => {
12933
- CONSUME(symbols_exports.semi);
12934
- CONSUME(separator);
12935
- CONSUME(symbols_exports.equal);
12936
- return SUBRULE(string, void 0);
12779
+ const expressionVal = SUBRULE(expression);
12780
+ CONSUME(as);
12781
+ const variable = SUBRULE(var_);
12782
+ const close = CONSUME(symbols_exports.RParen);
12783
+ return ACTION(() => C.factory.patternBind(expressionVal, variable, C.factory.sourceLocation(bind3, close)));
12784
+ },
12785
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12786
+ F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12787
+ SUBRULE(expression, ast.expression);
12788
+ F2.printFilter(ast, () => PRINT_WORD("AS"));
12789
+ SUBRULE(var_, ast.variable);
12790
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12791
+ }
12792
+ };
12793
+ var inlineData = {
12794
+ name: "inlineData",
12795
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12796
+ const values3 = CONSUME(values2);
12797
+ const datablock = SUBRULE(dataBlock);
12798
+ return ACTION(() => C.factory.patternValues(datablock.val, C.factory.sourceLocation(values3, datablock)));
12799
+ },
12800
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12801
+ const variables = Object.keys(ast.values[0]);
12802
+ F2.printFilter(ast, () => {
12803
+ PRINT_WORD("VALUES", "(");
12804
+ for (const variable of variables) {
12805
+ PRINT_WORD(`?${variable}`);
12806
+ }
12807
+ PRINT_WORD(")", "{");
12937
12808
  });
12938
- const closeToken = CONSUME(symbols_exports.RParen);
12939
- return ACTION(() => {
12940
- const F2 = C.factory;
12941
- return F2.aggregate(
12942
- operatorToken.image,
12943
- Boolean(distinctToken),
12944
- expr,
12945
- sep?.value ?? " ",
12946
- F2.sourceLocation(operatorToken, closeToken)
12947
- );
12809
+ for (const mapping of ast.values) {
12810
+ F2.printFilter(ast, () => PRINT_WORD("("));
12811
+ for (const variable of variables) {
12812
+ if (mapping[variable] === void 0) {
12813
+ F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
12814
+ } else {
12815
+ SUBRULE(graphNodePath, mapping[variable]);
12816
+ }
12817
+ }
12818
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12819
+ }
12820
+ F2.printFilter(ast, () => PRINT_WORD("}"));
12821
+ }
12822
+ };
12823
+ var dataBlock = {
12824
+ name: "dataBlock",
12825
+ impl: ({ SUBRULE, OR }) => () => OR([
12826
+ { ALT: () => SUBRULE(inlineDataOneVar) },
12827
+ { ALT: () => SUBRULE(inlineDataFull) }
12828
+ ])
12829
+ };
12830
+ var inlineDataOneVar = {
12831
+ name: "inlineDataOneVar",
12832
+ impl: ({ ACTION, SUBRULE, CONSUME, MANY }) => (C) => {
12833
+ const res = [];
12834
+ const varVal = SUBRULE(var_);
12835
+ CONSUME(symbols_exports.LCurly);
12836
+ MANY(() => {
12837
+ const value = SUBRULE(dataBlockValue);
12838
+ ACTION(() => {
12839
+ res.push({ [varVal.value]: value });
12840
+ });
12948
12841
  });
12842
+ const close = CONSUME(symbols_exports.RCurly);
12843
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(varVal, close)));
12949
12844
  }
12950
12845
  };
12951
- var aggregate = {
12952
- name: "aggregate",
12953
- impl: ({ ACTION, SUBRULE, OR }) => (C) => {
12954
- const wasInAggregate = ACTION(() => C.parseMode.has("inAggregate"));
12955
- ACTION(() => C.parseMode.add("inAggregate"));
12956
- const result = OR([
12957
- { ALT: () => SUBRULE(aggregateCount, void 0) },
12958
- { ALT: () => SUBRULE(aggregateSum, void 0) },
12959
- { ALT: () => SUBRULE(aggregateMin, void 0) },
12960
- { ALT: () => SUBRULE(aggregateMax, void 0) },
12961
- { ALT: () => SUBRULE(aggregateAvg, void 0) },
12962
- { ALT: () => SUBRULE(aggregateSample, void 0) },
12963
- { ALT: () => SUBRULE(aggregateGroup_concat, void 0) }
12846
+ var inlineDataFull = {
12847
+ name: "inlineDataFull",
12848
+ impl: ({
12849
+ ACTION,
12850
+ OR,
12851
+ MANY1,
12852
+ MANY2,
12853
+ MANY3,
12854
+ MANY4,
12855
+ SUBRULE,
12856
+ CONSUME1,
12857
+ CONSUME2
12858
+ }) => (C) => {
12859
+ const res = [];
12860
+ const vars = [];
12861
+ return OR([
12862
+ { ALT: () => {
12863
+ const nil2 = CONSUME1(terminals_exports.nil);
12864
+ CONSUME1(symbols_exports.LCurly);
12865
+ MANY1(() => {
12866
+ CONSUME2(terminals_exports.nil);
12867
+ res.push({});
12868
+ });
12869
+ const close = CONSUME1(symbols_exports.RCurly);
12870
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(nil2, close)));
12871
+ } },
12872
+ { ALT: () => {
12873
+ const open = CONSUME1(symbols_exports.LParen);
12874
+ MANY2(() => {
12875
+ vars.push(SUBRULE(var_));
12876
+ });
12877
+ CONSUME1(symbols_exports.RParen);
12878
+ CONSUME2(symbols_exports.LCurly);
12879
+ MANY3(() => {
12880
+ let parsedValues = 0;
12881
+ const currentRow = {};
12882
+ CONSUME2(symbols_exports.LParen);
12883
+ MANY4(() => {
12884
+ if (parsedValues >= vars.length) {
12885
+ throw new Error("Number of dataBlockValues does not match number of variables. Too much values.");
12886
+ }
12887
+ const value = SUBRULE(dataBlockValue);
12888
+ ACTION(() => {
12889
+ currentRow[vars[parsedValues].value] = value;
12890
+ parsedValues++;
12891
+ });
12892
+ });
12893
+ CONSUME2(symbols_exports.RParen);
12894
+ ACTION(() => {
12895
+ res.push(currentRow);
12896
+ if (vars.length !== parsedValues) {
12897
+ throw new Error("Number of dataBlockValues does not match number of variables. Too few values.");
12898
+ }
12899
+ });
12900
+ });
12901
+ const close = CONSUME2(symbols_exports.RCurly);
12902
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(open, close)));
12903
+ } }
12964
12904
  ]);
12965
- ACTION(() => !wasInAggregate && C.parseMode.delete("inAggregate"));
12966
- ACTION(() => {
12967
- if (!C.parseMode.has("canParseAggregate")) {
12968
- throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");
12969
- }
12970
- if (C.parseMode.has("inAggregate")) {
12971
- throw new Error("An aggregate function is not allowed within an aggregate function.");
12972
- }
12905
+ }
12906
+ };
12907
+ var dataBlockValue = {
12908
+ name: "dataBlockValue",
12909
+ impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
12910
+ { ALT: () => SUBRULE(iri2) },
12911
+ { ALT: () => SUBRULE(rdfLiteral) },
12912
+ { ALT: () => SUBRULE(numericLiteral) },
12913
+ { ALT: () => SUBRULE(booleanLiteral) },
12914
+ { ALT: () => {
12915
+ CONSUME(undef);
12916
+ return void 0;
12917
+ } }
12918
+ ])
12919
+ };
12920
+ var minusGraphPattern = {
12921
+ name: "minusGraphPattern",
12922
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12923
+ const minus2 = CONSUME(minus);
12924
+ const group = SUBRULE(groupGraphPattern);
12925
+ return ACTION(() => C.factory.patternMinus(group.patterns, C.factory.sourceLocation(minus2, group)));
12926
+ },
12927
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12928
+ F2.printFilter(ast, () => PRINT_WORD("MINUS"));
12929
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12930
+ }
12931
+ };
12932
+ var groupOrUnionGraphPattern = {
12933
+ name: "groupOrUnionGraphPattern",
12934
+ impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => {
12935
+ const groups = [];
12936
+ const group = SUBRULE1(groupGraphPattern);
12937
+ groups.push(group);
12938
+ MANY(() => {
12939
+ CONSUME(union);
12940
+ const group2 = SUBRULE2(groupGraphPattern);
12941
+ groups.push(group2);
12973
12942
  });
12974
- return result;
12943
+ return ACTION(() => groups.length === 1 ? groups[0] : C.factory.patternUnion(
12944
+ groups,
12945
+ C.factory.sourceLocation(group, groups.at(-1))
12946
+ ));
12975
12947
  },
12976
12948
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12977
- F2.printFilter(ast, () => {
12978
- PRINT_WORD(ast.aggregation, "(");
12979
- if (ast.distinct) {
12980
- PRINT_WORD("DISTINCT");
12949
+ if (F2.isPatternUnion(ast)) {
12950
+ const [head2, ...tail] = ast.patterns;
12951
+ SUBRULE(groupGraphPattern, head2);
12952
+ for (const pattern of tail) {
12953
+ F2.printFilter(ast, () => PRINT_WORD("UNION"));
12954
+ SUBRULE(groupGraphPattern, pattern);
12981
12955
  }
12982
- });
12983
- const arg = ast.expression[0];
12984
- if (F2.isWildcard(arg)) {
12985
- F2.printFilter(ast, () => PRINT_WORD("*"));
12986
12956
  } else {
12987
- SUBRULE(expression, arg, void 0);
12988
- }
12989
- if (F2.isExpressionAggregateSeparator(ast)) {
12990
- F2.printFilter(ast, () => PRINT_WORD(";", "SEPARATOR", "=", stringEscapedLexical(ast.separator)));
12957
+ SUBRULE(groupGraphPattern, ast);
12991
12958
  }
12959
+ }
12960
+ };
12961
+ var filter3 = {
12962
+ name: "filter",
12963
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12964
+ const filterToken = CONSUME(filter2);
12965
+ const expression2 = SUBRULE(constraint);
12966
+ return ACTION(() => C.factory.patternFilter(expression2, C.factory.sourceLocation(filterToken, expression2)));
12967
+ },
12968
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12969
+ F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
12970
+ SUBRULE(expression, ast.expression);
12992
12971
  F2.printFilter(ast, () => PRINT_WORD(")"));
12993
12972
  }
12994
12973
  };
12974
+ var constraint = {
12975
+ name: "constraint",
12976
+ impl: ({ SUBRULE, OR }) => () => OR([
12977
+ { ALT: () => SUBRULE(brackettedExpression) },
12978
+ { ALT: () => SUBRULE(builtInCall) },
12979
+ { ALT: () => SUBRULE(functionCall) }
12980
+ ])
12981
+ };
12982
+ var functionCall = {
12983
+ name: "functionCall",
12984
+ impl: ({ ACTION, SUBRULE }) => (C) => {
12985
+ const func = SUBRULE(iri2);
12986
+ const args = SUBRULE(argList);
12987
+ return ACTION(() => C.factory.expressionFunctionCall(
12988
+ func,
12989
+ args.val.args,
12990
+ args.val.distinct,
12991
+ C.factory.sourceLocation(func, args)
12992
+ ));
12993
+ }
12994
+ };
12995
12995
 
12996
12996
  // ../rules-sparql-1-1/lib/grammar/expression.ts
12997
12997
  var argList = {
@@ -13011,7 +13011,7 @@ var argList = {
13011
13011
  AT_LEAST_ONE_SEP({
13012
13012
  SEP: symbols_exports.comma,
13013
13013
  DEF: () => {
13014
- const arg = SUBRULE1(expression, void 0);
13014
+ const arg = SUBRULE1(expression);
13015
13015
  args.push(arg);
13016
13016
  }
13017
13017
  });
@@ -13028,11 +13028,11 @@ var argList = {
13028
13028
  });
13029
13029
  const [head2, ...tail] = ast.val.args;
13030
13030
  if (head2) {
13031
- SUBRULE(expression, head2, void 0);
13031
+ SUBRULE(expression, head2);
13032
13032
  }
13033
13033
  for (const expr of tail) {
13034
13034
  F2.printFilter(ast, () => PRINT_WORD(","));
13035
- SUBRULE(expression, expr, void 0);
13035
+ SUBRULE(expression, expr);
13036
13036
  }
13037
13037
  F2.printFilter(ast, () => PRINT_WORD(")"));
13038
13038
  }
@@ -13046,11 +13046,11 @@ var expressionList = {
13046
13046
  } },
13047
13047
  { ALT: () => {
13048
13048
  const open = CONSUME(symbols_exports.LParen);
13049
- const expr1 = SUBRULE1(expression, void 0);
13049
+ const expr1 = SUBRULE1(expression);
13050
13050
  const args = [expr1];
13051
13051
  MANY(() => {
13052
13052
  CONSUME(symbols_exports.comma);
13053
- const expr = SUBRULE2(expression, void 0);
13053
+ const expr = SUBRULE2(expression);
13054
13054
  args.push(expr);
13055
13055
  });
13056
13056
  const close = CONSUME(symbols_exports.RParen);
@@ -13062,15 +13062,15 @@ var infixOperators = /* @__PURE__ */ new Set(["in", "notin", "||", "&&", "=", "!
13062
13062
  var prefixOperator = /* @__PURE__ */ new Set(["!", "UPLUS", "UMINUS"]);
13063
13063
  var expression = {
13064
13064
  name: "expression",
13065
- impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression, void 0),
13065
+ impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression),
13066
13066
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13067
13067
  if (F2.isTerm(ast)) {
13068
- SUBRULE(varOrTerm, ast, void 0);
13068
+ SUBRULE(varOrTerm, ast);
13069
13069
  } else if (F2.isExpressionOperator(ast)) {
13070
13070
  if (infixOperators.has(ast.operator)) {
13071
13071
  const [left, ...right] = ast.args;
13072
13072
  F2.printFilter(ast, () => PRINT_WORD("("));
13073
- SUBRULE(expression, left, void 0);
13073
+ SUBRULE(expression, left);
13074
13074
  F2.printFilter(ast, () => {
13075
13075
  if (ast.operator === "notin") {
13076
13076
  PRINT_WORD("NOT IN");
@@ -13081,35 +13081,35 @@ var expression = {
13081
13081
  }
13082
13082
  });
13083
13083
  if (right.length === 1) {
13084
- SUBRULE(expression, right[0], void 0);
13084
+ SUBRULE(expression, right[0]);
13085
13085
  } else {
13086
- SUBRULE(argList, F2.wrap({ args: right, distinct: false }, ast.loc), void 0);
13086
+ SUBRULE(argList, F2.wrap({ args: right, distinct: false }, ast.loc));
13087
13087
  }
13088
13088
  F2.printFilter(ast, () => PRINT_WORD(")"));
13089
13089
  } else if (prefixOperator.has(ast.operator)) {
13090
13090
  const [expr] = ast.args;
13091
13091
  F2.printFilter(ast, () => PRINT_WORD(ast.operator));
13092
- SUBRULE(expression, expr, void 0);
13092
+ SUBRULE(expression, expr);
13093
13093
  } else {
13094
13094
  F2.printFilter(ast, () => PRINT_WORD(ast.operator, "("));
13095
13095
  const [head2, ...tail] = ast.args;
13096
13096
  if (head2) {
13097
- SUBRULE(expression, head2, void 0);
13097
+ SUBRULE(expression, head2);
13098
13098
  }
13099
13099
  for (const arg of tail) {
13100
13100
  F2.printFilter(ast, () => PRINT_WORD(","));
13101
- SUBRULE(expression, arg, void 0);
13101
+ SUBRULE(expression, arg);
13102
13102
  }
13103
13103
  F2.printFilter(ast, () => PRINT_WORD(")"));
13104
13104
  }
13105
13105
  } else if (F2.isExpressionPatternOperation(ast)) {
13106
13106
  const patterns = ast.args;
13107
13107
  F2.printFilter(ast, () => PRINT_WORD(ast.operator === "exists" ? "EXISTS" : "NOT EXISTS"));
13108
- SUBRULE(groupGraphPattern, patterns, void 0);
13108
+ SUBRULE(groupGraphPattern, patterns);
13109
13109
  } else if (F2.isExpressionFunctionCall(ast)) {
13110
- SUBRULE(iriOrFunction, ast, void 0);
13110
+ SUBRULE(iriOrFunction, ast);
13111
13111
  } else if (F2.isExpressionAggregate(ast)) {
13112
- SUBRULE(aggregate, ast, void 0);
13112
+ SUBRULE(aggregate, ast);
13113
13113
  }
13114
13114
  }
13115
13115
  };
@@ -13126,10 +13126,10 @@ function constructLeftDeep(startGenerator, restGenerator, ACTION, MANY) {
13126
13126
  var conditionalOrExpression = {
13127
13127
  name: "conditionalOrExpression",
13128
13128
  impl: ({ ACTION, MANY, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => constructLeftDeep(
13129
- () => SUBRULE1(conditionalAndExpression, void 0),
13129
+ () => SUBRULE1(conditionalAndExpression),
13130
13130
  () => {
13131
13131
  CONSUME(symbols_exports.logicOr);
13132
- const args = SUBRULE2(conditionalAndExpression, void 0);
13132
+ const args = SUBRULE2(conditionalAndExpression);
13133
13133
  return (left) => ACTION(() => C.factory.expressionOperation("||", [left, args], C.factory.sourceLocation(left, args)));
13134
13134
  },
13135
13135
  ACTION,
@@ -13139,10 +13139,10 @@ var conditionalOrExpression = {
13139
13139
  var conditionalAndExpression = {
13140
13140
  name: "conditionalAndExpression",
13141
13141
  impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => constructLeftDeep(
13142
- () => SUBRULE1(valueLogical, void 0),
13142
+ () => SUBRULE1(valueLogical),
13143
13143
  () => {
13144
13144
  CONSUME(symbols_exports.logicAnd);
13145
- const arg = SUBRULE2(valueLogical, void 0);
13145
+ const arg = SUBRULE2(valueLogical);
13146
13146
  return (left) => ACTION(() => C.factory.expressionOperation("&&", [left, arg], C.factory.sourceLocation(left, arg)));
13147
13147
  },
13148
13148
  ACTION,
@@ -13151,12 +13151,12 @@ var conditionalAndExpression = {
13151
13151
  };
13152
13152
  var valueLogical = {
13153
13153
  name: "valueLogical",
13154
- impl: ({ SUBRULE }) => () => SUBRULE(relationalExpression, void 0)
13154
+ impl: ({ SUBRULE }) => () => SUBRULE(relationalExpression)
13155
13155
  };
13156
13156
  var relationalExpression = {
13157
13157
  name: "relationalExpression",
13158
13158
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION, OR1, OR2, OR3 }) => (C) => {
13159
- const args1 = SUBRULE1(numericExpression, void 0);
13159
+ const args1 = SUBRULE1(numericExpression);
13160
13160
  const expression2 = OPTION(() => OR1([
13161
13161
  { ALT: () => {
13162
13162
  const operator = OR2([
@@ -13167,7 +13167,7 @@ var relationalExpression = {
13167
13167
  { ALT: () => CONSUME(symbols_exports.lessThanEqual) },
13168
13168
  { ALT: () => CONSUME(symbols_exports.greaterThanEqual) }
13169
13169
  ]);
13170
- const expr = SUBRULE2(numericExpression, void 0);
13170
+ const expr = SUBRULE2(numericExpression);
13171
13171
  return ACTION(() => C.factory.expressionOperation(
13172
13172
  operator.image,
13173
13173
  [args1, expr],
@@ -13179,7 +13179,7 @@ var relationalExpression = {
13179
13179
  { ALT: () => CONSUME(in_) },
13180
13180
  { ALT: () => CONSUME(notIn) }
13181
13181
  ]);
13182
- const args = SUBRULE1(expressionList, void 0);
13182
+ const args = SUBRULE1(expressionList);
13183
13183
  return ACTION(() => C.factory.expressionOperation(
13184
13184
  operator.image,
13185
13185
  [args1, ...args.val],
@@ -13192,25 +13192,25 @@ var relationalExpression = {
13192
13192
  };
13193
13193
  var numericExpression = {
13194
13194
  name: "numericExpression",
13195
- impl: ({ SUBRULE }) => () => SUBRULE(additiveExpression, void 0)
13195
+ impl: ({ SUBRULE }) => () => SUBRULE(additiveExpression)
13196
13196
  };
13197
13197
  var additiveExpression = {
13198
13198
  name: "additiveExpression",
13199
13199
  impl: ({ ACTION, SUBRULE, CONSUME, SUBRULE1, SUBRULE2, MANY1, MANY2, OR1, OR2, OR3, OR4 }) => (C) => constructLeftDeep(
13200
- () => SUBRULE1(multiplicativeExpression, void 0),
13200
+ () => SUBRULE1(multiplicativeExpression),
13201
13201
  () => OR1([
13202
13202
  { ALT: () => {
13203
13203
  const operator = OR2([
13204
13204
  { ALT: () => CONSUME(symbols_exports.opPlus) },
13205
13205
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13206
13206
  ]);
13207
- const arg = SUBRULE2(multiplicativeExpression, void 0);
13207
+ const arg = SUBRULE2(multiplicativeExpression);
13208
13208
  return ACTION(() => (left) => C.factory.expressionOperation(operator.image, [left, arg], C.factory.sourceLocation(left, arg)));
13209
13209
  } },
13210
13210
  { ALT: () => {
13211
13211
  const { operator, startInt } = OR3([
13212
13212
  { ALT: () => {
13213
- const integer2 = SUBRULE(numericLiteralPositive, void 0);
13213
+ const integer2 = SUBRULE(numericLiteralPositive);
13214
13214
  return ACTION(() => {
13215
13215
  integer2.value = integer2.value.replace(/^\+/u, "");
13216
13216
  return {
@@ -13220,7 +13220,7 @@ var additiveExpression = {
13220
13220
  });
13221
13221
  } },
13222
13222
  { ALT: () => {
13223
- const integer2 = SUBRULE(numericLiteralNegative, void 0);
13223
+ const integer2 = SUBRULE(numericLiteralNegative);
13224
13224
  return ACTION(() => {
13225
13225
  integer2.value = integer2.value.replace(/^-/u, "");
13226
13226
  return {
@@ -13237,7 +13237,7 @@ var additiveExpression = {
13237
13237
  { ALT: () => CONSUME(symbols_exports.star) },
13238
13238
  { ALT: () => CONSUME(symbols_exports.slash) }
13239
13239
  ]);
13240
- const innerExpr = SUBRULE1(unaryExpression, void 0);
13240
+ const innerExpr = SUBRULE1(unaryExpression);
13241
13241
  return ACTION(() => (leftInner) => C.factory.expressionOperation(
13242
13242
  innerOperator.image,
13243
13243
  [leftInner, innerExpr],
@@ -13261,13 +13261,13 @@ var additiveExpression = {
13261
13261
  var multiplicativeExpression = {
13262
13262
  name: "multiplicativeExpression",
13263
13263
  impl: ({ ACTION, CONSUME, MANY, SUBRULE1, SUBRULE2, OR }) => (C) => constructLeftDeep(
13264
- () => SUBRULE1(unaryExpression, void 0),
13264
+ () => SUBRULE1(unaryExpression),
13265
13265
  () => {
13266
13266
  const operator = OR([
13267
13267
  { ALT: () => CONSUME(symbols_exports.star) },
13268
13268
  { ALT: () => CONSUME(symbols_exports.slash) }
13269
13269
  ]);
13270
- const expr = SUBRULE2(unaryExpression, void 0);
13270
+ const expr = SUBRULE2(unaryExpression);
13271
13271
  return (left) => ({
13272
13272
  type: "expression",
13273
13273
  subType: "operation",
@@ -13283,14 +13283,14 @@ var multiplicativeExpression = {
13283
13283
  var unaryExpression = {
13284
13284
  name: "unaryExpression",
13285
13285
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
13286
- { ALT: () => SUBRULE1(primaryExpression, void 0) },
13286
+ { ALT: () => SUBRULE1(primaryExpression) },
13287
13287
  { ALT: () => {
13288
13288
  const operator = OR2([
13289
13289
  { ALT: () => CONSUME(symbols_exports.exclamation) },
13290
13290
  { ALT: () => CONSUME(symbols_exports.opPlus) },
13291
13291
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13292
13292
  ]);
13293
- const expr = SUBRULE2(primaryExpression, void 0);
13293
+ const expr = SUBRULE2(primaryExpression);
13294
13294
  return ACTION(() => ({
13295
13295
  type: "expression",
13296
13296
  subType: "operation",
@@ -13304,20 +13304,20 @@ var unaryExpression = {
13304
13304
  var primaryExpression = {
13305
13305
  name: "primaryExpression",
13306
13306
  impl: ({ SUBRULE, OR }) => () => OR([
13307
- { ALT: () => SUBRULE(brackettedExpression, void 0) },
13308
- { ALT: () => SUBRULE(builtInCall, void 0) },
13309
- { ALT: () => SUBRULE(iriOrFunction, void 0) },
13310
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
13311
- { ALT: () => SUBRULE(numericLiteral, void 0) },
13312
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
13313
- { ALT: () => SUBRULE(var_, void 0) }
13307
+ { ALT: () => SUBRULE(brackettedExpression) },
13308
+ { ALT: () => SUBRULE(builtInCall) },
13309
+ { ALT: () => SUBRULE(iriOrFunction) },
13310
+ { ALT: () => SUBRULE(rdfLiteral) },
13311
+ { ALT: () => SUBRULE(numericLiteral) },
13312
+ { ALT: () => SUBRULE(booleanLiteral) },
13313
+ { ALT: () => SUBRULE(var_) }
13314
13314
  ])
13315
13315
  };
13316
13316
  var brackettedExpression = {
13317
13317
  name: "brackettedExpression",
13318
13318
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13319
13319
  const open = CONSUME(symbols_exports.LParen);
13320
- const expr = SUBRULE(expression, void 0);
13320
+ const expr = SUBRULE(expression);
13321
13321
  const close = CONSUME(symbols_exports.RParen);
13322
13322
  return ACTION(() => {
13323
13323
  expr.loc = C.factory.sourceLocation(open, close);
@@ -13328,9 +13328,9 @@ var brackettedExpression = {
13328
13328
  var iriOrFunction = {
13329
13329
  name: "iriOrFunction",
13330
13330
  impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
13331
- const iriVal = SUBRULE(iri2, void 0);
13331
+ const iriVal = SUBRULE(iri2);
13332
13332
  const functionCall2 = OPTION(() => {
13333
- const args = SUBRULE(argList, void 0);
13333
+ const args = SUBRULE(argList);
13334
13334
  return ACTION(() => {
13335
13335
  const distinct2 = args.val.distinct;
13336
13336
  if (!C.parseMode.has("canParseAggregate") && distinct2) {
@@ -13350,10 +13350,10 @@ var iriOrFunction = {
13350
13350
  },
13351
13351
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13352
13352
  if (F2.isTermNamed(ast)) {
13353
- SUBRULE(iri2, ast, void 0);
13353
+ SUBRULE(iri2, ast);
13354
13354
  } else {
13355
- SUBRULE(iri2, ast.function, void 0);
13356
- SUBRULE(argList, F2.wrap({ args: ast.args, distinct: ast.distinct }, ast.loc), void 0);
13355
+ SUBRULE(iri2, ast.function);
13356
+ SUBRULE(argList, F2.wrap({ args: ast.args, distinct: ast.distinct }, ast.loc));
13357
13357
  }
13358
13358
  }
13359
13359
  };
@@ -13362,10 +13362,10 @@ var iriOrFunction = {
13362
13362
  var solutionModifier = {
13363
13363
  name: "solutionModifier",
13364
13364
  impl: ({ ACTION, SUBRULE, OPTION1, OPTION2, OPTION3, OPTION4 }) => () => {
13365
- const group = OPTION1(() => SUBRULE(groupClause, void 0));
13366
- const having2 = OPTION2(() => SUBRULE(havingClause, void 0));
13367
- const order2 = OPTION3(() => SUBRULE(orderClause, void 0));
13368
- const limitOffset = OPTION4(() => SUBRULE(limitOffsetClauses, void 0));
13365
+ const group = OPTION1(() => SUBRULE(groupClause));
13366
+ const having2 = OPTION2(() => SUBRULE(havingClause));
13367
+ const order2 = OPTION3(() => SUBRULE(orderClause));
13368
+ const limitOffset = OPTION4(() => SUBRULE(limitOffsetClauses));
13369
13369
  return ACTION(() => ({
13370
13370
  ...limitOffset && { limitOffset },
13371
13371
  ...group && { group },
@@ -13375,16 +13375,16 @@ var solutionModifier = {
13375
13375
  },
13376
13376
  gImpl: ({ SUBRULE }) => (ast) => {
13377
13377
  if (ast.group) {
13378
- SUBRULE(groupClause, ast.group, void 0);
13378
+ SUBRULE(groupClause, ast.group);
13379
13379
  }
13380
13380
  if (ast.having) {
13381
- SUBRULE(havingClause, ast.having, void 0);
13381
+ SUBRULE(havingClause, ast.having);
13382
13382
  }
13383
13383
  if (ast.order) {
13384
- SUBRULE(orderClause, ast.order, void 0);
13384
+ SUBRULE(orderClause, ast.order);
13385
13385
  }
13386
13386
  if (ast.limitOffset) {
13387
- SUBRULE(limitOffsetClauses, ast.limitOffset, void 0);
13387
+ SUBRULE(limitOffsetClauses, ast.limitOffset);
13388
13388
  }
13389
13389
  }
13390
13390
  };
@@ -13395,7 +13395,7 @@ var groupClause = {
13395
13395
  const start = CONSUME(groupByGroup);
13396
13396
  CONSUME(by);
13397
13397
  AT_LEAST_ONE(() => {
13398
- groupings.push(SUBRULE1(groupCondition, void 0));
13398
+ groupings.push(SUBRULE1(groupCondition));
13399
13399
  });
13400
13400
  return ACTION(() => ({
13401
13401
  type: "solutionModifier",
@@ -13408,12 +13408,12 @@ var groupClause = {
13408
13408
  F2.printFilter(ast, () => PRINT_WORDS("GROUP", "BY"));
13409
13409
  for (const grouping of ast.groupings) {
13410
13410
  if (F2.isExpression(grouping)) {
13411
- SUBRULE(expression, grouping, void 0);
13411
+ SUBRULE(expression, grouping);
13412
13412
  } else {
13413
13413
  F2.printFilter(ast, () => PRINT_WORDS("("));
13414
- SUBRULE(expression, grouping.value, void 0);
13414
+ SUBRULE(expression, grouping.value);
13415
13415
  F2.printFilter(ast, () => PRINT_WORDS("AS"));
13416
- SUBRULE(var_, grouping.variable, void 0);
13416
+ SUBRULE(var_, grouping.variable);
13417
13417
  F2.printFilter(ast, () => PRINT_WORDS(")"));
13418
13418
  }
13419
13419
  }
@@ -13422,16 +13422,16 @@ var groupClause = {
13422
13422
  var groupCondition = {
13423
13423
  name: "groupCondition",
13424
13424
  impl: ({ ACTION, SUBRULE, CONSUME, SUBRULE1, SUBRULE2, OPTION, OR }) => (C) => OR([
13425
- { ALT: () => SUBRULE(builtInCall, void 0) },
13426
- { ALT: () => SUBRULE(functionCall, void 0) },
13427
- { ALT: () => SUBRULE2(var_, void 0) },
13425
+ { ALT: () => SUBRULE(builtInCall) },
13426
+ { ALT: () => SUBRULE(functionCall) },
13427
+ { ALT: () => SUBRULE2(var_) },
13428
13428
  {
13429
13429
  ALT: () => {
13430
13430
  const open = CONSUME(symbols_exports.LParen);
13431
- const expressionValue = SUBRULE(expression, void 0);
13431
+ const expressionValue = SUBRULE(expression);
13432
13432
  const variable = OPTION(() => {
13433
13433
  CONSUME(as);
13434
- return SUBRULE1(var_, void 0);
13434
+ return SUBRULE1(var_);
13435
13435
  });
13436
13436
  const close = CONSUME(symbols_exports.RParen);
13437
13437
  return ACTION(() => {
@@ -13455,7 +13455,7 @@ var havingClause = {
13455
13455
  const expressions = [];
13456
13456
  const couldParseAgg = ACTION(() => C.parseMode.has("canParseAggregate") || !C.parseMode.add("canParseAggregate"));
13457
13457
  AT_LEAST_ONE(() => {
13458
- expressions.push(SUBRULE(havingCondition, void 0));
13458
+ expressions.push(SUBRULE(havingCondition));
13459
13459
  });
13460
13460
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13461
13461
  return ACTION(() => C.factory.solutionModifierHaving(expressions, C.factory.sourceLocation(having2, expressions.at(-1))));
@@ -13463,13 +13463,13 @@ var havingClause = {
13463
13463
  gImpl: ({ PRINT_WORD, SUBRULE }) => (ast, { factory: F2 }) => {
13464
13464
  F2.printFilter(ast, () => PRINT_WORD("HAVING"));
13465
13465
  for (const having2 of ast.having) {
13466
- SUBRULE(expression, having2, void 0);
13466
+ SUBRULE(expression, having2);
13467
13467
  }
13468
13468
  }
13469
13469
  };
13470
13470
  var havingCondition = {
13471
13471
  name: "havingCondition",
13472
- impl: ({ SUBRULE }) => () => SUBRULE(constraint, void 0)
13472
+ impl: ({ SUBRULE }) => () => SUBRULE(constraint)
13473
13473
  };
13474
13474
  var orderClause = {
13475
13475
  name: "orderClause",
@@ -13479,7 +13479,7 @@ var orderClause = {
13479
13479
  const orderings = [];
13480
13480
  const couldParseAgg = ACTION(() => C.parseMode.has("canParseAggregate") || !C.parseMode.add("canParseAggregate"));
13481
13481
  AT_LEAST_ONE(() => {
13482
- orderings.push(SUBRULE1(orderCondition, void 0));
13482
+ orderings.push(SUBRULE1(orderCondition));
13483
13483
  });
13484
13484
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13485
13485
  return ACTION(() => C.factory.solutionModifierOrder(orderings, C.factory.sourceLocation(order2, orderings.at(-1))));
@@ -13493,7 +13493,7 @@ var orderClause = {
13493
13493
  F2.printFilter(ast, () => PRINT_WORDS("ASC"));
13494
13494
  }
13495
13495
  F2.printFilter(ast, () => PRINT_WORDS("("));
13496
- SUBRULE(expression, ordering.expression, void 0);
13496
+ SUBRULE(expression, ordering.expression);
13497
13497
  F2.printFilter(ast, () => PRINT_WORDS(")"));
13498
13498
  }
13499
13499
  }
@@ -13512,7 +13512,7 @@ var orderCondition = {
13512
13512
  return [true, token];
13513
13513
  } }
13514
13514
  ]);
13515
- const expr = SUBRULE(brackettedExpression, void 0);
13515
+ const expr = SUBRULE(brackettedExpression);
13516
13516
  return ACTION(() => ({
13517
13517
  expression: expr,
13518
13518
  descending: descending[0],
@@ -13520,11 +13520,11 @@ var orderCondition = {
13520
13520
  }));
13521
13521
  } },
13522
13522
  { ALT: () => {
13523
- const expr = SUBRULE(constraint, void 0);
13523
+ const expr = SUBRULE(constraint);
13524
13524
  return ACTION(() => ({ expression: expr, descending: false, loc: expr.loc }));
13525
13525
  } },
13526
13526
  { ALT: () => {
13527
- const expr = SUBRULE(var_, void 0);
13527
+ const expr = SUBRULE(var_);
13528
13528
  return ACTION(() => ({ expression: expr, descending: false, loc: expr.loc }));
13529
13529
  } }
13530
13530
  ])
@@ -13533,8 +13533,8 @@ var limitOffsetClauses = {
13533
13533
  name: "limitOffsetClauses",
13534
13534
  impl: ({ ACTION, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => OR([
13535
13535
  { ALT: () => {
13536
- const limit2 = SUBRULE1(limitClause, void 0);
13537
- const offset2 = OPTION1(() => SUBRULE1(offsetClause, void 0));
13536
+ const limit2 = SUBRULE1(limitClause);
13537
+ const offset2 = OPTION1(() => SUBRULE1(offsetClause));
13538
13538
  return ACTION(() => C.factory.solutionModifierLimitOffset(
13539
13539
  limit2.val,
13540
13540
  offset2?.val,
@@ -13542,8 +13542,8 @@ var limitOffsetClauses = {
13542
13542
  ));
13543
13543
  } },
13544
13544
  { ALT: () => {
13545
- const offset2 = SUBRULE2(offsetClause, void 0);
13546
- const limit2 = OPTION2(() => SUBRULE2(limitClause, void 0));
13545
+ const offset2 = SUBRULE2(offsetClause);
13546
+ const limit2 = OPTION2(() => SUBRULE2(limitClause));
13547
13547
  return ACTION(() => C.factory.solutionModifierLimitOffset(
13548
13548
  limit2?.val,
13549
13549
  offset2.val,
@@ -13581,22 +13581,22 @@ var offsetClause = {
13581
13581
  }
13582
13582
  };
13583
13583
 
13584
- // ../rules-sparql-1-1/lib/grammar/queryUnit/queryUnit.ts
13584
+ // ../rules-sparql-1-1/lib/grammar/queryUnit.ts
13585
13585
  var queryUnit = {
13586
13586
  name: "queryUnit",
13587
- impl: ({ SUBRULE }) => () => SUBRULE(query, void 0)
13587
+ impl: ({ SUBRULE }) => () => SUBRULE(query)
13588
13588
  };
13589
13589
  var query = {
13590
13590
  name: "query",
13591
13591
  impl: ({ ACTION, SUBRULE, OR }) => (C) => {
13592
- const prologueValues = SUBRULE(prologue, void 0);
13592
+ const prologueValues = SUBRULE(prologue);
13593
13593
  const subType = OR([
13594
- { ALT: () => SUBRULE(selectQuery, void 0) },
13595
- { ALT: () => SUBRULE(constructQuery, void 0) },
13596
- { ALT: () => SUBRULE(describeQuery, void 0) },
13597
- { ALT: () => SUBRULE(askQuery, void 0) }
13594
+ { ALT: () => SUBRULE(selectQuery) },
13595
+ { ALT: () => SUBRULE(constructQuery) },
13596
+ { ALT: () => SUBRULE(describeQuery) },
13597
+ { ALT: () => SUBRULE(askQuery) }
13598
13598
  ]);
13599
- const values3 = SUBRULE(valuesClause, void 0);
13599
+ const values3 = SUBRULE(valuesClause);
13600
13600
  return ACTION(() => ({
13601
13601
  context: prologueValues,
13602
13602
  ...subType,
@@ -13610,28 +13610,28 @@ var query = {
13610
13610
  }));
13611
13611
  },
13612
13612
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13613
- SUBRULE(prologue, ast.context, void 0);
13613
+ SUBRULE(prologue, ast.context);
13614
13614
  if (F2.isQuerySelect(ast)) {
13615
- SUBRULE(selectQuery, ast, void 0);
13615
+ SUBRULE(selectQuery, ast);
13616
13616
  } else if (F2.isQueryConstruct(ast)) {
13617
- SUBRULE(constructQuery, ast, void 0);
13617
+ SUBRULE(constructQuery, ast);
13618
13618
  } else if (F2.isQueryDescribe(ast)) {
13619
- SUBRULE(describeQuery, ast, void 0);
13619
+ SUBRULE(describeQuery, ast);
13620
13620
  } else if (F2.isQueryAsk(ast)) {
13621
- SUBRULE(askQuery, ast, void 0);
13621
+ SUBRULE(askQuery, ast);
13622
13622
  }
13623
13623
  if (ast.values) {
13624
- SUBRULE(inlineData, ast.values, void 0);
13624
+ SUBRULE(inlineData, ast.values);
13625
13625
  }
13626
13626
  }
13627
13627
  };
13628
13628
  var selectQuery = {
13629
13629
  name: "selectQuery",
13630
13630
  impl: ({ ACTION, SUBRULE }) => (C) => {
13631
- const selectVal = SUBRULE(selectClause, void 0);
13632
- const from2 = SUBRULE(datasetClauseStar, void 0);
13633
- const where2 = SUBRULE(whereClause, void 0);
13634
- const modifiers = SUBRULE(solutionModifier, void 0);
13631
+ const selectVal = SUBRULE(selectClause);
13632
+ const from2 = SUBRULE(datasetClauseStar);
13633
+ const where2 = SUBRULE(whereClause);
13634
+ const modifiers = SUBRULE(solutionModifier);
13635
13635
  return ACTION(() => {
13636
13636
  const ret = {
13637
13637
  subType: "select",
@@ -13657,19 +13657,19 @@ var selectQuery = {
13657
13657
  variables: ast.variables,
13658
13658
  distinct: ast.distinct,
13659
13659
  reduced: ast.reduced
13660
- }, F2.sourceLocation(...ast.variables)), void 0);
13661
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
13662
- SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc), void 0);
13663
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
13660
+ }, F2.sourceLocation(...ast.variables)));
13661
+ SUBRULE(datasetClauseStar, ast.datasets);
13662
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc));
13663
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13664
13664
  }
13665
13665
  };
13666
13666
  var subSelect = {
13667
13667
  name: "subSelect",
13668
13668
  impl: ({ ACTION, SUBRULE }) => (C) => {
13669
- const selectVal = SUBRULE(selectClause, void 0);
13670
- const where2 = SUBRULE(whereClause, void 0);
13671
- const modifiers = SUBRULE(solutionModifier, void 0);
13672
- const values3 = SUBRULE(valuesClause, void 0);
13669
+ const selectVal = SUBRULE(selectClause);
13670
+ const where2 = SUBRULE(whereClause);
13671
+ const modifiers = SUBRULE(solutionModifier);
13672
+ const values3 = SUBRULE(valuesClause);
13673
13673
  return ACTION(() => C.factory.querySelect({
13674
13674
  where: where2.val,
13675
13675
  datasets: C.factory.datasetClauses([], C.factory.sourceLocation()),
@@ -13734,7 +13734,7 @@ var selectClause = {
13734
13734
  const variables = [];
13735
13735
  AT_LEAST_ONE(() => OR3([
13736
13736
  { ALT: () => {
13737
- const raw = SUBRULE1(var_, void 0);
13737
+ const raw = SUBRULE1(var_);
13738
13738
  ACTION(() => {
13739
13739
  if (usedVars.some((v) => v.value === raw.value)) {
13740
13740
  throw new Error(`Variable ${raw.value} used more than once in SELECT clause`);
@@ -13746,9 +13746,9 @@ var selectClause = {
13746
13746
  } },
13747
13747
  { ALT: () => {
13748
13748
  const open = CONSUME(symbols_exports.LParen);
13749
- const expr = SUBRULE1(expression, void 0);
13749
+ const expr = SUBRULE1(expression);
13750
13750
  CONSUME(as);
13751
- const variable = SUBRULE2(var_, void 0);
13751
+ const variable = SUBRULE2(var_);
13752
13752
  const close = CONSUME(symbols_exports.RParen);
13753
13753
  ACTION(() => {
13754
13754
  last2 = close;
@@ -13779,12 +13779,12 @@ var selectClause = {
13779
13779
  if (F2.isWildcard(variable)) {
13780
13780
  F2.printFilter(ast, () => PRINT_WORD("*"));
13781
13781
  } else if (F2.isTerm(variable)) {
13782
- SUBRULE(var_, variable, void 0);
13782
+ SUBRULE(var_, variable);
13783
13783
  } else {
13784
13784
  F2.printFilter(ast, () => PRINT_WORD("("));
13785
- SUBRULE(expression, variable.expression, void 0);
13785
+ SUBRULE(expression, variable.expression);
13786
13786
  F2.printFilter(ast, () => PRINT_WORD("AS"));
13787
- SUBRULE(var_, variable.variable, void 0);
13787
+ SUBRULE(var_, variable.variable);
13788
13788
  F2.printFilter(ast, () => PRINT_WORD(")"));
13789
13789
  }
13790
13790
  }
@@ -13796,10 +13796,10 @@ var constructQuery = {
13796
13796
  const construct2 = CONSUME(construct);
13797
13797
  return OR([
13798
13798
  { ALT: () => {
13799
- const template = SUBRULE1(constructTemplate, void 0);
13800
- const from2 = SUBRULE1(datasetClauseStar, void 0);
13801
- const where2 = SUBRULE1(whereClause, void 0);
13802
- const modifiers = SUBRULE1(solutionModifier, void 0);
13799
+ const template = SUBRULE1(constructTemplate);
13800
+ const from2 = SUBRULE1(datasetClauseStar);
13801
+ const where2 = SUBRULE1(whereClause);
13802
+ const modifiers = SUBRULE1(solutionModifier);
13803
13803
  return ACTION(() => ({
13804
13804
  subType: "construct",
13805
13805
  template: template.val,
@@ -13817,10 +13817,10 @@ var constructQuery = {
13817
13817
  }));
13818
13818
  } },
13819
13819
  { ALT: () => {
13820
- const from2 = SUBRULE2(datasetClauseStar, void 0);
13820
+ const from2 = SUBRULE2(datasetClauseStar);
13821
13821
  CONSUME(where);
13822
- const template = SUBRULE2(constructTemplate, void 0);
13823
- const modifiers = SUBRULE2(solutionModifier, void 0);
13822
+ const template = SUBRULE2(constructTemplate);
13823
+ const modifiers = SUBRULE2(solutionModifier);
13824
13824
  return ACTION(() => ({
13825
13825
  subType: "construct",
13826
13826
  template: template.val,
@@ -13843,16 +13843,16 @@ var constructQuery = {
13843
13843
  F2.printFilter(ast, () => PRINT_WORD("CONSTRUCT"));
13844
13844
  if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
13845
13845
  F2.printFilter(ast, () => PRINT_WORD("{"));
13846
- SUBRULE(triplesBlock, ast.template, void 0);
13846
+ SUBRULE(triplesBlock, ast.template);
13847
13847
  F2.printFilter(ast, () => PRINT_WORD("}"));
13848
13848
  }
13849
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
13849
+ SUBRULE(datasetClauseStar, ast.datasets);
13850
13850
  if (F2.isSourceLocationNoMaterialize(ast.where.loc)) {
13851
- SUBRULE(whereClause, F2.wrap(F2.patternGroup([ast.template], ast.template.loc), ast.template.loc), void 0);
13851
+ SUBRULE(whereClause, F2.wrap(F2.patternGroup([ast.template], ast.template.loc), ast.template.loc));
13852
13852
  } else {
13853
- SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc), void 0);
13853
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc));
13854
13854
  }
13855
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
13855
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13856
13856
  }
13857
13857
  };
13858
13858
  var describeQuery = {
@@ -13863,7 +13863,7 @@ var describeQuery = {
13863
13863
  { ALT: () => {
13864
13864
  const variables2 = [];
13865
13865
  AT_LEAST_ONE(() => {
13866
- variables2.push(SUBRULE1(varOrIri, void 0));
13866
+ variables2.push(SUBRULE1(varOrIri));
13867
13867
  });
13868
13868
  return variables2;
13869
13869
  } },
@@ -13872,9 +13872,9 @@ var describeQuery = {
13872
13872
  return [ACTION(() => C.factory.wildcard(C.factory.sourceLocation(star2)))];
13873
13873
  } }
13874
13874
  ]);
13875
- const from2 = SUBRULE1(datasetClauseStar, void 0);
13876
- const where2 = OPTION(() => SUBRULE1(whereClause, void 0));
13877
- const modifiers = SUBRULE1(solutionModifier, void 0);
13875
+ const from2 = SUBRULE1(datasetClauseStar);
13876
+ const where2 = OPTION(() => SUBRULE1(whereClause));
13877
+ const modifiers = SUBRULE1(solutionModifier);
13878
13878
  return ACTION(() => ({
13879
13879
  subType: "describe",
13880
13880
  variables,
@@ -13899,23 +13899,23 @@ var describeQuery = {
13899
13899
  F2.printFilter(ast, () => PRINT_WORD("*"));
13900
13900
  } else {
13901
13901
  for (const variable of ast.variables) {
13902
- SUBRULE(varOrTerm, variable, void 0);
13902
+ SUBRULE(varOrTerm, variable);
13903
13903
  }
13904
13904
  }
13905
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
13905
+ SUBRULE(datasetClauseStar, ast.datasets);
13906
13906
  if (ast.where) {
13907
- SUBRULE(whereClause, F2.wrap(ast.where, ast.loc), void 0);
13907
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
13908
13908
  }
13909
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
13909
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13910
13910
  }
13911
13911
  };
13912
13912
  var askQuery = {
13913
13913
  name: "askQuery",
13914
13914
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13915
13915
  const ask2 = CONSUME(ask);
13916
- const from2 = SUBRULE(datasetClauseStar, void 0);
13917
- const where2 = SUBRULE(whereClause, void 0);
13918
- const modifiers = SUBRULE(solutionModifier, void 0);
13916
+ const from2 = SUBRULE(datasetClauseStar);
13917
+ const where2 = SUBRULE(whereClause);
13918
+ const modifiers = SUBRULE(solutionModifier);
13919
13919
  return ACTION(() => ({
13920
13920
  subType: "ask",
13921
13921
  datasets: from2,
@@ -13934,20 +13934,20 @@ var askQuery = {
13934
13934
  },
13935
13935
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13936
13936
  F2.printFilter(ast, () => PRINT_WORD("ASK"));
13937
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
13938
- SUBRULE(whereClause, F2.wrap(ast.where, ast.loc), void 0);
13939
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
13937
+ SUBRULE(datasetClauseStar, ast.datasets);
13938
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
13939
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13940
13940
  }
13941
13941
  };
13942
13942
  var valuesClause = {
13943
13943
  name: "valuesClause",
13944
- impl: ({ OPTION, SUBRULE }) => () => OPTION(() => SUBRULE(inlineData, void 0))
13944
+ impl: ({ OPTION, SUBRULE }) => () => OPTION(() => SUBRULE(inlineData))
13945
13945
  };
13946
13946
  var constructTemplate = {
13947
13947
  name: "constructTemplate",
13948
13948
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
13949
13949
  const open = CONSUME(symbols_exports.LCurly);
13950
- const triples = OPTION(() => SUBRULE1(constructTriples, void 0));
13950
+ const triples = OPTION(() => SUBRULE1(constructTriples));
13951
13951
  const close = CONSUME(symbols_exports.RCurly);
13952
13952
  return ACTION(() => C.factory.wrap(
13953
13953
  triples ?? C.factory.patternBgp([], C.factory.sourceLocation()),
@@ -13960,27 +13960,27 @@ var constructTriples = {
13960
13960
  impl: triplesTemplate.impl
13961
13961
  };
13962
13962
 
13963
- // ../rules-sparql-1-1/lib/grammar/updateUnit/updateUnit.ts
13963
+ // ../rules-sparql-1-1/lib/grammar/updateUnit.ts
13964
13964
  var updateUnit = {
13965
13965
  name: "updateUnit",
13966
- impl: ({ SUBRULE }) => () => SUBRULE(update, void 0)
13966
+ impl: ({ SUBRULE }) => () => SUBRULE(update)
13967
13967
  };
13968
13968
  var update = {
13969
13969
  name: "update",
13970
13970
  impl: ({ ACTION, SUBRULE, SUBRULE1, SUBRULE2, CONSUME, OPTION1, MANY }) => (C) => {
13971
13971
  const updates = [];
13972
- const prologueValues = SUBRULE1(prologue, void 0);
13972
+ const prologueValues = SUBRULE1(prologue);
13973
13973
  updates.push({ context: prologueValues });
13974
13974
  let parsedSemi = true;
13975
13975
  MANY({
13976
13976
  GATE: () => parsedSemi,
13977
13977
  DEF: () => {
13978
13978
  parsedSemi = false;
13979
- updates.at(-1).operation = SUBRULE(update1, void 0);
13979
+ updates.at(-1).operation = SUBRULE(update1);
13980
13980
  OPTION1(() => {
13981
13981
  CONSUME(symbols_exports.semi);
13982
13982
  parsedSemi = true;
13983
- const innerPrologue = SUBRULE2(prologue, void 0);
13983
+ const innerPrologue = SUBRULE2(prologue);
13984
13984
  updates.push({ context: innerPrologue });
13985
13985
  });
13986
13986
  }
@@ -14002,9 +14002,9 @@ var update = {
14002
14002
  },
14003
14003
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14004
14004
  for (const update2 of ast.updates) {
14005
- SUBRULE(prologue, update2.context, void 0);
14005
+ SUBRULE(prologue, update2.context);
14006
14006
  if (update2.operation) {
14007
- SUBRULE(update1, update2.operation, void 0);
14007
+ SUBRULE(update1, update2.operation);
14008
14008
  F2.printFilter(ast, () => PRINT_WORD(" ;\n"));
14009
14009
  }
14010
14010
  }
@@ -14013,52 +14013,52 @@ var update = {
14013
14013
  var update1 = {
14014
14014
  name: "update1",
14015
14015
  impl: ({ SUBRULE, OR }) => () => OR([
14016
- { ALT: () => SUBRULE(load2, void 0) },
14017
- { ALT: () => SUBRULE(clear2, void 0) },
14018
- { ALT: () => SUBRULE(drop3, void 0) },
14019
- { ALT: () => SUBRULE(add2, void 0) },
14020
- { ALT: () => SUBRULE(move2, void 0) },
14021
- { ALT: () => SUBRULE(copy2, void 0) },
14022
- { ALT: () => SUBRULE(create2, void 0) },
14023
- { ALT: () => SUBRULE(insertData, void 0) },
14024
- { ALT: () => SUBRULE(deleteData, void 0) },
14025
- { ALT: () => SUBRULE(deleteWhere, void 0) },
14026
- { ALT: () => SUBRULE(modify, void 0) }
14016
+ { ALT: () => SUBRULE(load2) },
14017
+ { ALT: () => SUBRULE(clear2) },
14018
+ { ALT: () => SUBRULE(drop3) },
14019
+ { ALT: () => SUBRULE(add2) },
14020
+ { ALT: () => SUBRULE(move2) },
14021
+ { ALT: () => SUBRULE(copy2) },
14022
+ { ALT: () => SUBRULE(create2) },
14023
+ { ALT: () => SUBRULE(insertData) },
14024
+ { ALT: () => SUBRULE(deleteData) },
14025
+ { ALT: () => SUBRULE(deleteWhere) },
14026
+ { ALT: () => SUBRULE(modify) }
14027
14027
  ]),
14028
14028
  gImpl: ({ SUBRULE }) => (ast) => {
14029
14029
  switch (ast.subType) {
14030
14030
  case "load":
14031
- SUBRULE(load2, ast, void 0);
14031
+ SUBRULE(load2, ast);
14032
14032
  break;
14033
14033
  case "clear":
14034
- SUBRULE(clear2, ast, void 0);
14034
+ SUBRULE(clear2, ast);
14035
14035
  break;
14036
14036
  case "drop":
14037
- SUBRULE(drop3, ast, void 0);
14037
+ SUBRULE(drop3, ast);
14038
14038
  break;
14039
14039
  case "add":
14040
- SUBRULE(add2, ast, void 0);
14040
+ SUBRULE(add2, ast);
14041
14041
  break;
14042
14042
  case "move":
14043
- SUBRULE(move2, ast, void 0);
14043
+ SUBRULE(move2, ast);
14044
14044
  break;
14045
14045
  case "copy":
14046
- SUBRULE(copy2, ast, void 0);
14046
+ SUBRULE(copy2, ast);
14047
14047
  break;
14048
14048
  case "create":
14049
- SUBRULE(create2, ast, void 0);
14049
+ SUBRULE(create2, ast);
14050
14050
  break;
14051
14051
  case "insertdata":
14052
- SUBRULE(insertData, ast, void 0);
14052
+ SUBRULE(insertData, ast);
14053
14053
  break;
14054
14054
  case "deletedata":
14055
- SUBRULE(deleteData, ast, void 0);
14055
+ SUBRULE(deleteData, ast);
14056
14056
  break;
14057
14057
  case "deletewhere":
14058
- SUBRULE(deleteWhere, ast, void 0);
14058
+ SUBRULE(deleteWhere, ast);
14059
14059
  break;
14060
14060
  case "modify":
14061
- SUBRULE(modify, ast, void 0);
14061
+ SUBRULE(modify, ast);
14062
14062
  break;
14063
14063
  }
14064
14064
  }
@@ -14068,10 +14068,10 @@ var load2 = {
14068
14068
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION1, OPTION2 }) => (C) => {
14069
14069
  const loadToken = CONSUME(load);
14070
14070
  const silent2 = OPTION1(() => CONSUME(silent));
14071
- const source = SUBRULE1(iri2, void 0);
14071
+ const source = SUBRULE1(iri2);
14072
14072
  const destination = OPTION2(() => {
14073
14073
  CONSUME(loadInto);
14074
- return SUBRULE1(graphRef, void 0);
14074
+ return SUBRULE1(graphRef);
14075
14075
  });
14076
14076
  return ACTION(() => C.factory.updateOperationLoad(
14077
14077
  C.factory.sourceLocation(loadToken, source, destination),
@@ -14087,10 +14087,10 @@ var load2 = {
14087
14087
  PRINT_WORD("SILENT");
14088
14088
  }
14089
14089
  });
14090
- SUBRULE(iri2, ast.source, void 0);
14090
+ SUBRULE(iri2, ast.source);
14091
14091
  if (ast.destination) {
14092
14092
  F2.printFilter(ast, () => PRINT_WORD("INTO"));
14093
- SUBRULE(graphRefAll, ast.destination, void 0);
14093
+ SUBRULE(graphRefAll, ast.destination);
14094
14094
  }
14095
14095
  }
14096
14096
  };
@@ -14100,7 +14100,7 @@ function clearOrDrop(operation) {
14100
14100
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14101
14101
  const opToken = CONSUME(operation);
14102
14102
  const silent2 = OPTION(() => CONSUME(silent));
14103
- const destination = SUBRULE1(graphRefAll, void 0);
14103
+ const destination = SUBRULE1(graphRefAll);
14104
14104
  return ACTION(() => C.factory.updateOperationClearDrop(
14105
14105
  unCapitalize(operation.name),
14106
14106
  Boolean(silent2),
@@ -14115,7 +14115,7 @@ function clearOrDrop(operation) {
14115
14115
  PRINT_WORD("SILENT");
14116
14116
  }
14117
14117
  });
14118
- SUBRULE(graphRefAll, ast.destination, void 0);
14118
+ SUBRULE(graphRefAll, ast.destination);
14119
14119
  }
14120
14120
  };
14121
14121
  }
@@ -14126,7 +14126,7 @@ var create2 = {
14126
14126
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14127
14127
  const createToken3 = CONSUME(create);
14128
14128
  const silent2 = OPTION(() => CONSUME(silent));
14129
- const destination = SUBRULE1(graphRef, void 0);
14129
+ const destination = SUBRULE1(graphRef);
14130
14130
  return ACTION(() => C.factory.updateOperationCreate(
14131
14131
  destination,
14132
14132
  Boolean(silent2),
@@ -14140,7 +14140,7 @@ var create2 = {
14140
14140
  PRINT_WORD("SILENT");
14141
14141
  }
14142
14142
  });
14143
- SUBRULE(graphRefAll, ast.destination, void 0);
14143
+ SUBRULE(graphRefAll, ast.destination);
14144
14144
  }
14145
14145
  };
14146
14146
  function copyMoveAddOperation(operation) {
@@ -14149,9 +14149,9 @@ function copyMoveAddOperation(operation) {
14149
14149
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION }) => (C) => {
14150
14150
  const op = CONSUME(operation);
14151
14151
  const silent2 = OPTION(() => CONSUME(silent));
14152
- const source = SUBRULE1(graphOrDefault, void 0);
14152
+ const source = SUBRULE1(graphOrDefault);
14153
14153
  CONSUME(to);
14154
- const destination = SUBRULE2(graphOrDefault, void 0);
14154
+ const destination = SUBRULE2(graphOrDefault);
14155
14155
  return ACTION(() => C.factory.updateOperationAddMoveCopy(
14156
14156
  unCapitalize(operation.name),
14157
14157
  source,
@@ -14167,9 +14167,9 @@ function copyMoveAddOperation(operation) {
14167
14167
  PRINT_WORD("SILENT");
14168
14168
  }
14169
14169
  });
14170
- SUBRULE(graphRefAll, ast.source, void 0);
14170
+ SUBRULE(graphRefAll, ast.source);
14171
14171
  F2.printFilter(ast, () => PRINT_WORD("TO"));
14172
- SUBRULE(graphRefAll, ast.destination, void 0);
14172
+ SUBRULE(graphRefAll, ast.destination);
14173
14173
  }
14174
14174
  };
14175
14175
  }
@@ -14180,7 +14180,7 @@ var quadPattern = {
14180
14180
  name: "quadPattern",
14181
14181
  impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
14182
14182
  const open = CONSUME(symbols_exports.LCurly);
14183
- const val = SUBRULE1(quads, void 0);
14183
+ const val = SUBRULE1(quads);
14184
14184
  const close = CONSUME(symbols_exports.RCurly);
14185
14185
  return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
14186
14186
  }
@@ -14190,7 +14190,7 @@ var quadData = {
14190
14190
  impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
14191
14191
  const open = CONSUME(symbols_exports.LCurly);
14192
14192
  const couldParseVars = ACTION(() => C.parseMode.delete("canParseVars"));
14193
- const val = SUBRULE1(quads, void 0);
14193
+ const val = SUBRULE1(quads);
14194
14194
  ACTION(() => couldParseVars && C.parseMode.add("canParseVars"));
14195
14195
  const close = CONSUME(symbols_exports.RCurly);
14196
14196
  return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
@@ -14206,7 +14206,7 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14206
14206
  if (name !== "insertData") {
14207
14207
  couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
14208
14208
  }
14209
- const data = SUBRULE1(dataRule, void 0);
14209
+ const data = SUBRULE1(dataRule);
14210
14210
  if (name !== "insertData") {
14211
14211
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14212
14212
  }
@@ -14217,7 +14217,7 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14217
14217
  subType === "insertdata" ? "INSERT DATA" : subType === "deletedata" ? "DELETE DATA" : "DELETE WHERE",
14218
14218
  "{"
14219
14219
  ));
14220
- SUBRULE(quads, F2.wrap(ast.data, ast.loc), void 0);
14220
+ SUBRULE(quads, F2.wrap(ast.data, ast.loc));
14221
14221
  F2.printFilter(ast, () => PRINT_WORD("}"));
14222
14222
  }
14223
14223
  };
@@ -14230,23 +14230,23 @@ var modify = {
14230
14230
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => {
14231
14231
  const graph2 = OPTION1(() => {
14232
14232
  const withToken = CONSUME(modifyWith);
14233
- const graph3 = SUBRULE1(iri2, void 0);
14233
+ const graph3 = SUBRULE1(iri2);
14234
14234
  return { withToken, graph: graph3 };
14235
14235
  });
14236
14236
  const { insert, del } = OR([
14237
14237
  { ALT: () => {
14238
- const del2 = SUBRULE1(deleteClause2, void 0);
14239
- const insert2 = OPTION2(() => SUBRULE1(insertClause2, void 0));
14238
+ const del2 = SUBRULE1(deleteClause2);
14239
+ const insert2 = OPTION2(() => SUBRULE1(insertClause2));
14240
14240
  return { del: del2, insert: insert2 };
14241
14241
  } },
14242
14242
  { ALT: () => {
14243
- const insert2 = SUBRULE2(insertClause2, void 0);
14243
+ const insert2 = SUBRULE2(insertClause2);
14244
14244
  return { insert: insert2, del: void 0 };
14245
14245
  } }
14246
14246
  ]);
14247
- const using = SUBRULE1(usingClauseStar, void 0);
14247
+ const using = SUBRULE1(usingClauseStar);
14248
14248
  CONSUME(where);
14249
- const where2 = SUBRULE1(groupGraphPattern, void 0);
14249
+ const where2 = SUBRULE1(groupGraphPattern);
14250
14250
  return ACTION(() => C.factory.updateOperationModify(
14251
14251
  C.factory.sourceLocation(graph2?.withToken, del, insert, where2),
14252
14252
  insert?.val ?? [],
@@ -14259,21 +14259,21 @@ var modify = {
14259
14259
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14260
14260
  if (ast.graph) {
14261
14261
  F2.printFilter(ast, () => PRINT_WORD("WITH"));
14262
- SUBRULE(iri2, ast.graph, void 0);
14262
+ SUBRULE(iri2, ast.graph);
14263
14263
  }
14264
14264
  if (ast.delete.length > 0) {
14265
14265
  F2.printFilter(ast, () => PRINT_WORD("DELETE", "{"));
14266
- SUBRULE(quads, F2.wrap(ast.delete, ast.loc), void 0);
14266
+ SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
14267
14267
  F2.printFilter(ast, () => PRINT_WORD("}"));
14268
14268
  }
14269
14269
  if (ast.insert.length > 0) {
14270
14270
  F2.printFilter(ast, () => PRINT_WORD("INSERT", "{"));
14271
- SUBRULE(quads, F2.wrap(ast.insert, ast.loc), void 0);
14271
+ SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
14272
14272
  F2.printFilter(ast, () => PRINT_WORD("}"));
14273
14273
  }
14274
- SUBRULE(usingClauseStar, ast.from, void 0);
14274
+ SUBRULE(usingClauseStar, ast.from);
14275
14275
  F2.printFilter(ast, () => PRINT_WORD("WHERE"));
14276
- SUBRULE(groupGraphPattern, ast.where, void 0);
14276
+ SUBRULE(groupGraphPattern, ast.where);
14277
14277
  }
14278
14278
  };
14279
14279
  var deleteClause2 = {
@@ -14281,7 +14281,7 @@ var deleteClause2 = {
14281
14281
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14282
14282
  const delToken = CONSUME(deleteClause);
14283
14283
  const couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
14284
- const del = SUBRULE(quadPattern, void 0);
14284
+ const del = SUBRULE(quadPattern);
14285
14285
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14286
14286
  return ACTION(() => C.factory.wrap(del.val, C.factory.sourceLocation(delToken, del)));
14287
14287
  }
@@ -14290,7 +14290,7 @@ var insertClause2 = {
14290
14290
  name: "insertClause",
14291
14291
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14292
14292
  const insertToken = CONSUME(insertClause);
14293
- const insert = SUBRULE(quadPattern, void 0);
14293
+ const insert = SUBRULE(quadPattern);
14294
14294
  return ACTION(() => C.factory.wrap(insert.val, C.factory.sourceLocation(insertToken, insert)));
14295
14295
  }
14296
14296
  };
@@ -14303,7 +14303,7 @@ var graphOrDefault = {
14303
14303
  } },
14304
14304
  { ALT: () => {
14305
14305
  const graph2 = OPTION(() => CONSUME(graph_exports.graph));
14306
- const name = SUBRULE1(iri2, void 0);
14306
+ const name = SUBRULE1(iri2);
14307
14307
  return ACTION(() => C.factory.graphRefSpecific(name, C.factory.sourceLocation(graph2, name)));
14308
14308
  } }
14309
14309
  ])
@@ -14312,18 +14312,18 @@ var graphRef = {
14312
14312
  name: "graphRef",
14313
14313
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14314
14314
  const graph2 = CONSUME(graph_exports.graph);
14315
- const val = SUBRULE(iri2, void 0);
14315
+ const val = SUBRULE(iri2);
14316
14316
  return ACTION(() => C.factory.graphRefSpecific(val, C.factory.sourceLocation(graph2, val)));
14317
14317
  },
14318
14318
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14319
14319
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14320
- SUBRULE(iri2, ast.graph, void 0);
14320
+ SUBRULE(iri2, ast.graph);
14321
14321
  }
14322
14322
  };
14323
14323
  var graphRefAll = {
14324
14324
  name: "graphRefAll",
14325
14325
  impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => OR([
14326
- { ALT: () => SUBRULE(graphRef, void 0) },
14326
+ { ALT: () => SUBRULE(graphRef) },
14327
14327
  { ALT: () => {
14328
14328
  const def = CONSUME(graph_exports.default_);
14329
14329
  return ACTION(() => C.factory.graphRefDefault(C.factory.sourceLocation(def)));
@@ -14339,7 +14339,7 @@ var graphRefAll = {
14339
14339
  ]),
14340
14340
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14341
14341
  if (F2.isGraphRefSpecific(ast)) {
14342
- SUBRULE(graphRef, ast, void 0);
14342
+ SUBRULE(graphRef, ast);
14343
14343
  } else if (F2.isGraphRefDefault(ast)) {
14344
14344
  F2.printFilter(ast, () => PRINT_WORD("DEFAULT"));
14345
14345
  } else if (F2.isGraphRefNamed(ast)) {
@@ -14355,12 +14355,12 @@ var quads = {
14355
14355
  const quads2 = [];
14356
14356
  let last2;
14357
14357
  OPTION1(() => {
14358
- const triples = SUBRULE1(triplesTemplate, void 0);
14358
+ const triples = SUBRULE1(triplesTemplate);
14359
14359
  last2 = triples;
14360
14360
  ACTION(() => quads2.push(triples));
14361
14361
  });
14362
14362
  MANY(() => {
14363
- const notTriples = SUBRULE(quadsNotTriples, void 0);
14363
+ const notTriples = SUBRULE(quadsNotTriples);
14364
14364
  last2 = notTriples;
14365
14365
  quads2.push(notTriples);
14366
14366
  OPTION2(() => {
@@ -14369,7 +14369,7 @@ var quads = {
14369
14369
  return dotToken;
14370
14370
  });
14371
14371
  OPTION3(() => {
14372
- const triples = SUBRULE2(triplesTemplate, void 0);
14372
+ const triples = SUBRULE2(triplesTemplate);
14373
14373
  last2 = triples;
14374
14374
  ACTION(() => quads2.push(triples));
14375
14375
  });
@@ -14379,9 +14379,9 @@ var quads = {
14379
14379
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
14380
14380
  for (const quad of ast.val) {
14381
14381
  if (F2.isPattern(quad)) {
14382
- SUBRULE(triplesBlock, quad, void 0);
14382
+ SUBRULE(triplesBlock, quad);
14383
14383
  } else {
14384
- SUBRULE(quadsNotTriples, quad, void 0);
14384
+ SUBRULE(quadsNotTriples, quad);
14385
14385
  }
14386
14386
  }
14387
14387
  }
@@ -14390,9 +14390,9 @@ var quadsNotTriples = {
14390
14390
  name: "quadsNotTriples",
14391
14391
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14392
14392
  const graph2 = CONSUME(graph_exports.graph);
14393
- const name = SUBRULE1(varOrIri, void 0);
14393
+ const name = SUBRULE1(varOrIri);
14394
14394
  CONSUME(symbols_exports.LCurly);
14395
- const triples = OPTION(() => SUBRULE1(triplesTemplate, void 0));
14395
+ const triples = OPTION(() => SUBRULE1(triplesTemplate));
14396
14396
  const close = CONSUME(symbols_exports.RCurly);
14397
14397
  return ACTION(() => C.factory.graphQuads(
14398
14398
  name,
@@ -14402,13 +14402,75 @@ var quadsNotTriples = {
14402
14402
  },
14403
14403
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14404
14404
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14405
- SUBRULE(varOrTerm, ast.graph, void 0);
14405
+ SUBRULE(varOrTerm, ast.graph);
14406
14406
  F2.printFilter(ast, () => PRINT_WORD("{"));
14407
- SUBRULE(triplesBlock, ast.triples, void 0);
14407
+ SUBRULE(triplesBlock, ast.triples);
14408
14408
  F2.printFilter(ast, () => PRINT_WORD("}"));
14409
14409
  }
14410
14410
  };
14411
14411
 
14412
+ // ../rules-sparql-1-1/lib/grammar/index.ts
14413
+ var queryOrUpdate = {
14414
+ name: "queryOrUpdate",
14415
+ impl: ({ ACTION, SUBRULE, OR1, OR2, MANY, OPTION1, CONSUME, SUBRULE2 }) => (C) => {
14416
+ const prologueValues = SUBRULE(prologue);
14417
+ return OR1([
14418
+ { ALT: () => {
14419
+ const subType = OR2([
14420
+ { ALT: () => SUBRULE(selectQuery) },
14421
+ { ALT: () => SUBRULE(constructQuery) },
14422
+ { ALT: () => SUBRULE(describeQuery) },
14423
+ { ALT: () => SUBRULE(askQuery) }
14424
+ ]);
14425
+ const values3 = SUBRULE(valuesClause);
14426
+ return ACTION(() => ({
14427
+ context: prologueValues,
14428
+ ...subType,
14429
+ type: "query",
14430
+ ...values3 && { values: values3 },
14431
+ loc: C.factory.sourceLocation(
14432
+ prologueValues.at(0),
14433
+ subType,
14434
+ values3
14435
+ )
14436
+ }));
14437
+ } },
14438
+ { ALT: () => {
14439
+ const updates = [];
14440
+ updates.push({ context: prologueValues });
14441
+ let parsedSemi = true;
14442
+ MANY({
14443
+ GATE: () => parsedSemi,
14444
+ DEF: () => {
14445
+ parsedSemi = false;
14446
+ updates.at(-1).operation = SUBRULE(update1);
14447
+ OPTION1(() => {
14448
+ CONSUME(symbols_exports.semi);
14449
+ parsedSemi = true;
14450
+ const innerPrologue = SUBRULE2(prologue);
14451
+ updates.push({ context: innerPrologue });
14452
+ });
14453
+ }
14454
+ });
14455
+ return ACTION(() => {
14456
+ const update2 = {
14457
+ type: "update",
14458
+ updates,
14459
+ loc: C.factory.sourceLocation(
14460
+ ...updates[0].context,
14461
+ updates[0].operation,
14462
+ ...updates.at(-1).context,
14463
+ updates.at(-1)?.operation
14464
+ )
14465
+ };
14466
+ updateNoReuseBlankNodeLabels(update2);
14467
+ return update2;
14468
+ });
14469
+ } }
14470
+ ]);
14471
+ }
14472
+ };
14473
+
14412
14474
  // lib/lexer.ts
14413
14475
  var lexer_exports2 = {};
14414
14476
  __export(lexer_exports2, {
@@ -14418,9 +14480,12 @@ var BuiltInAdjust = createToken2({ name: "BuiltInAdjust", pattern: "ADJUST" });
14418
14480
 
14419
14481
  // lib/grammar.ts
14420
14482
  var builtInAdjust = funcExpr2(BuiltInAdjust);
14421
- var existingBuildInCall = {
14422
- name: "existingBuildInCall",
14423
- impl: grammar_exports.builtInCall.impl
14483
+ var builtInPatch = {
14484
+ name: grammar_exports.builtInCall.name,
14485
+ impl: ($) => (C) => $.OR2([
14486
+ { ALT: () => $.SUBRULE(builtInAdjust) },
14487
+ { ALT: () => grammar_exports.builtInCall.impl($)(C) }
14488
+ ])
14424
14489
  };
14425
14490
  /*! Bundled license information:
14426
14491