@traqula/rules-sparql-1-1 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.
Files changed (106) hide show
  1. package/README.md +0 -2
  2. package/lib/{SparqlParser.d.ts → MinimalSparqlParser.d.ts} +5 -5
  3. package/lib/{SparqlParser.js → MinimalSparqlParser.js} +6 -5
  4. package/lib/MinimalSparqlParser.js.map +1 -0
  5. package/lib/Sparql11types.d.ts +373 -62
  6. package/lib/Sparql11types.js.map +1 -1
  7. package/lib/expressionHelpers.d.ts +2 -2
  8. package/lib/expressionHelpers.js +19 -21
  9. package/lib/expressionHelpers.js.map +1 -1
  10. package/lib/factory.d.ts +66 -66
  11. package/lib/factory.js.map +1 -1
  12. package/lib/factoryMixins/ContextFactory.d.ts +1 -1
  13. package/lib/factoryMixins/ContextFactory.js.map +1 -1
  14. package/lib/factoryMixins/ExpressionFactory.d.ts +1 -1
  15. package/lib/factoryMixins/ExpressionFactory.js.map +1 -1
  16. package/lib/factoryMixins/GraphRefFactory.d.ts +1 -1
  17. package/lib/factoryMixins/GraphRefFactory.js.map +1 -1
  18. package/lib/factoryMixins/PathFactory.d.ts +1 -1
  19. package/lib/factoryMixins/PathFactory.js.map +1 -1
  20. package/lib/factoryMixins/Patternfactory.d.ts +1 -1
  21. package/lib/factoryMixins/Patternfactory.js.map +1 -1
  22. package/lib/factoryMixins/QueryFactory.d.ts +1 -1
  23. package/lib/factoryMixins/QueryFactory.js.map +1 -1
  24. package/lib/factoryMixins/SolutionModifiersFactory.d.ts +1 -1
  25. package/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -1
  26. package/lib/factoryMixins/TermFactory.d.ts +1 -1
  27. package/lib/factoryMixins/TermFactory.js +1 -4
  28. package/lib/factoryMixins/TermFactory.js.map +1 -1
  29. package/lib/factoryMixins/UpdateOperationFactory.d.ts +1 -1
  30. package/lib/factoryMixins/UpdateOperationFactory.js.map +1 -1
  31. package/lib/factoryMixins/mixins.d.ts +2 -0
  32. package/lib/factoryMixins/mixins.js +3 -0
  33. package/lib/factoryMixins/mixins.js.map +1 -1
  34. package/lib/grammar/builtIn.d.ts +2 -2
  35. package/lib/grammar/builtIn.js +66 -66
  36. package/lib/grammar/builtIn.js.map +1 -1
  37. package/lib/grammar/dataSetClause.d.ts +2 -2
  38. package/lib/grammar/dataSetClause.js +7 -7
  39. package/lib/grammar/dataSetClause.js.map +1 -1
  40. package/lib/grammar/expression.d.ts +2 -2
  41. package/lib/grammar/expression.js +47 -47
  42. package/lib/grammar/expression.js.map +1 -1
  43. package/lib/grammar/general.d.ts +2 -2
  44. package/lib/grammar/general.js +25 -25
  45. package/lib/grammar/general.js.map +1 -1
  46. package/lib/grammar/index.d.ts +9 -2
  47. package/lib/grammar/index.js +62 -2
  48. package/lib/grammar/index.js.map +1 -1
  49. package/lib/grammar/literals.d.ts +2 -2
  50. package/lib/grammar/literals.js +10 -10
  51. package/lib/grammar/literals.js.map +1 -1
  52. package/lib/grammar/propertyPaths.d.ts +3 -3
  53. package/lib/grammar/propertyPaths.js +19 -19
  54. package/lib/grammar/propertyPaths.js.map +1 -1
  55. package/lib/grammar/{queryUnit/queryUnit.d.ts → queryUnit.d.ts} +2 -2
  56. package/lib/grammar/{queryUnit/queryUnit.js → queryUnit.js} +67 -67
  57. package/lib/grammar/queryUnit.js.map +1 -0
  58. package/lib/grammar/solutionModifier.d.ts +2 -2
  59. package/lib/grammar/solutionModifier.js +29 -29
  60. package/lib/grammar/solutionModifier.js.map +1 -1
  61. package/lib/grammar/tripleBlock.d.ts +10 -10
  62. package/lib/grammar/tripleBlock.js +37 -37
  63. package/lib/grammar/tripleBlock.js.map +1 -1
  64. package/lib/grammar/{updateUnit/updateUnit.d.ts → updateUnit.d.ts} +2 -2
  65. package/lib/grammar/{updateUnit/updateUnit.js → updateUnit.js} +78 -78
  66. package/lib/grammar/updateUnit.js.map +1 -0
  67. package/lib/grammar/whereClause.d.ts +2 -2
  68. package/lib/grammar/whereClause.js +69 -69
  69. package/lib/grammar/whereClause.js.map +1 -1
  70. package/lib/index.cjs +1610 -1551
  71. package/lib/index.d.ts +2 -3
  72. package/lib/index.js +2 -3
  73. package/lib/index.js.map +1 -1
  74. package/lib/lexer/{BuildinCalls.d.ts → BuiltInCalls.d.ts} +1 -1
  75. package/lib/lexer/BuiltInCalls.js +188 -0
  76. package/lib/lexer/{BuildinCalls.js.map → BuiltInCalls.js.map} +1 -1
  77. package/lib/lexer/graph.d.ts +1 -1
  78. package/lib/lexer/index.d.ts +1 -1
  79. package/lib/lexer/index.js +1 -1
  80. package/lib/lexer/index.js.map +1 -1
  81. package/lib/lexer/lexer.d.ts +2 -2
  82. package/lib/lexer/lexer.js +2 -2
  83. package/lib/lexer/lexer.js.map +1 -1
  84. package/lib/lexer/terminals.d.ts +69 -0
  85. package/lib/lexer/terminals.js +69 -0
  86. package/lib/lexer/terminals.js.map +1 -1
  87. package/lib/sparql11HelperTypes.d.ts +68 -0
  88. package/lib/sparql11HelperTypes.js +2 -0
  89. package/lib/sparql11HelperTypes.js.map +1 -0
  90. package/lib/utils.d.ts +11 -0
  91. package/lib/utils.js +14 -0
  92. package/lib/utils.js.map +1 -1
  93. package/lib/validation/validators.d.ts +1 -1
  94. package/lib/validation/validators.js +1 -0
  95. package/lib/validation/validators.js.map +1 -1
  96. package/package.json +4 -4
  97. package/lib/RoundTripTypes.d.ts +0 -379
  98. package/lib/RoundTripTypes.js +0 -2
  99. package/lib/RoundTripTypes.js.map +0 -1
  100. package/lib/SparqlParser.js.map +0 -1
  101. package/lib/grammar/queryUnit/queryUnit.js.map +0 -1
  102. package/lib/grammar/updateUnit/updateUnit.js.map +0 -1
  103. package/lib/grammar-helpers/utils.d.ts +0 -12
  104. package/lib/grammar-helpers/utils.js +0 -16
  105. package/lib/grammar-helpers/utils.js.map +0 -1
  106. package/lib/lexer/BuildinCalls.js +0 -188
package/lib/index.cjs CHANGED
@@ -22,7 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  CommonIRIs: () => CommonIRIs,
24
24
  Factory: () => Factory,
25
- SparqlParser: () => SparqlParser,
25
+ MinimalSparqlParser: () => MinimalSparqlParser,
26
26
  baseAggregateFunc: () => baseAggregateFunc,
27
27
  checkNote13: () => checkNote13,
28
28
  completeParseContext: () => completeParseContext,
@@ -228,6 +228,7 @@ __export(grammar_exports, {
228
228
  quads: () => quads,
229
229
  quadsNotTriples: () => quadsNotTriples,
230
230
  query: () => query,
231
+ queryOrUpdate: () => queryOrUpdate,
231
232
  queryUnit: () => queryUnit,
232
233
  rdfLiteral: () => rdfLiteral,
233
234
  regexExpression: () => regexExpression,
@@ -276,7 +277,7 @@ __export(lexer_exports, {
276
277
  ask: () => ask,
277
278
  baseDecl: () => baseDecl,
278
279
  bind: () => bind,
279
- builtIn: () => BuildinCalls_exports,
280
+ builtIn: () => BuiltInCalls_exports,
280
281
  by: () => by,
281
282
  clear: () => clear,
282
283
  construct: () => construct,
@@ -313,7 +314,7 @@ __export(lexer_exports, {
313
314
  separator: () => separator,
314
315
  service: () => service,
315
316
  silent: () => silent,
316
- sparql11Tokens: () => sparql11Tokens,
317
+ sparql11LexerBuilder: () => sparql11LexerBuilder,
317
318
  symbols: () => symbols_exports,
318
319
  terminals: () => terminals_exports,
319
320
  to: () => to,
@@ -325,10 +326,10 @@ __export(lexer_exports, {
325
326
  where: () => where
326
327
  });
327
328
 
328
- // lib/lexer/BuildinCalls.ts
329
- var BuildinCalls_exports = {};
330
- __export(BuildinCalls_exports, {
331
- BuildInCalls: () => BuildInCalls,
329
+ // lib/lexer/BuiltInCalls.ts
330
+ var BuiltInCalls_exports = {};
331
+ __export(BuiltInCalls_exports, {
332
+ BuiltInCalls: () => BuiltInCalls,
332
333
  abs: () => abs,
333
334
  allBuiltInCalls: () => allBuiltInCalls,
334
335
  avg: () => avg,
@@ -721,10 +722,10 @@ var coreJsData = root_default["__core-js_shared__"];
721
722
  var coreJsData_default = coreJsData;
722
723
 
723
724
  // ../../node_modules/lodash-es/_isMasked.js
724
- var maskSrcKey = function() {
725
+ var maskSrcKey = (function() {
725
726
  var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
726
727
  return uid ? "Symbol(src)_1." + uid : "";
727
- }();
728
+ })();
728
729
  function isMasked(func) {
729
730
  return !!maskSrcKey && maskSrcKey in func;
730
731
  }
@@ -786,7 +787,7 @@ var WeakMap_default = WeakMap;
786
787
 
787
788
  // ../../node_modules/lodash-es/_baseCreate.js
788
789
  var objectCreate = Object.create;
789
- var baseCreate = /* @__PURE__ */ function() {
790
+ var baseCreate = /* @__PURE__ */ (function() {
790
791
  function object2() {
791
792
  }
792
793
  return function(proto) {
@@ -801,7 +802,7 @@ var baseCreate = /* @__PURE__ */ function() {
801
802
  object2.prototype = void 0;
802
803
  return result;
803
804
  };
804
- }();
805
+ })();
805
806
  var baseCreate_default = baseCreate;
806
807
 
807
808
  // ../../node_modules/lodash-es/_apply.js
@@ -866,14 +867,14 @@ function constant(value) {
866
867
  var constant_default = constant;
867
868
 
868
869
  // ../../node_modules/lodash-es/_defineProperty.js
869
- var defineProperty = function() {
870
+ var defineProperty = (function() {
870
871
  try {
871
872
  var func = getNative_default(Object, "defineProperty");
872
873
  func({}, "", {});
873
874
  return func;
874
875
  } catch (e) {
875
876
  }
876
- }();
877
+ })();
877
878
  var defineProperty_default = defineProperty;
878
879
 
879
880
  // ../../node_modules/lodash-es/_baseSetToString.js
@@ -1111,9 +1112,9 @@ var baseIsArguments_default = baseIsArguments;
1111
1112
  var objectProto6 = Object.prototype;
1112
1113
  var hasOwnProperty4 = objectProto6.hasOwnProperty;
1113
1114
  var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
1114
- var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
1115
+ var isArguments = baseIsArguments_default(/* @__PURE__ */ (function() {
1115
1116
  return arguments;
1116
- }()) ? baseIsArguments_default : function(value) {
1117
+ })()) ? baseIsArguments_default : function(value) {
1117
1118
  return isObjectLike_default(value) && hasOwnProperty4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
1118
1119
  };
1119
1120
  var isArguments_default = isArguments;
@@ -1179,7 +1180,7 @@ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType &&
1179
1180
  var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
1180
1181
  var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
1181
1182
  var freeProcess = moduleExports2 && freeGlobal_default.process;
1182
- var nodeUtil = function() {
1183
+ var nodeUtil = (function() {
1183
1184
  try {
1184
1185
  var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
1185
1186
  if (types) {
@@ -1188,7 +1189,7 @@ var nodeUtil = function() {
1188
1189
  return freeProcess && freeProcess.binding && freeProcess.binding("util");
1189
1190
  } catch (e) {
1190
1191
  }
1191
- }();
1192
+ })();
1192
1193
  var nodeUtil_default = nodeUtil;
1193
1194
 
1194
1195
  // ../../node_modules/lodash-es/isTypedArray.js
@@ -9733,6 +9734,7 @@ applyMixins(Parser, [
9733
9734
 
9734
9735
  // ../core/lib/lexer-builder/LexerBuilder.ts
9735
9736
  var LexerBuilder = class _LexerBuilder {
9737
+ tokens;
9736
9738
  static create(starter) {
9737
9739
  return new _LexerBuilder(starter);
9738
9740
  }
@@ -9890,71 +9892,71 @@ var Transformer = class {
9890
9892
  }
9891
9893
  };
9892
9894
 
9893
- // lib/lexer/BuildinCalls.ts
9894
- var BuildInCalls = /* @__PURE__ */ ((BuildInCalls2) => {
9895
- BuildInCalls2["Str"] = "builtInStr";
9896
- BuildInCalls2["Lang"] = "builtInLang";
9897
- BuildInCalls2["Langmatches"] = "builtInLangmatches";
9898
- BuildInCalls2["Datatype"] = "builtInDatatype";
9899
- BuildInCalls2["Bound"] = "builtInBound";
9900
- BuildInCalls2["Iri"] = "builtInIri";
9901
- BuildInCalls2["Uri"] = "builtInUri";
9902
- BuildInCalls2["Bnode"] = "builtInBnode";
9903
- BuildInCalls2["Rand"] = "builtInRand";
9904
- BuildInCalls2["Abs"] = "builtInAbs";
9905
- BuildInCalls2["Ceil"] = "builtInCeil";
9906
- BuildInCalls2["Floor"] = "builtInFloor";
9907
- BuildInCalls2["Round"] = "builtInRound";
9908
- BuildInCalls2["Concat"] = "builtInConcat";
9909
- BuildInCalls2["Strlen"] = "builtInStrlen";
9910
- BuildInCalls2["Ucase"] = "builtInUcase";
9911
- BuildInCalls2["Lcase"] = "builtInLcase";
9912
- BuildInCalls2["Encode_for_uri"] = "builtInEncode_for_uri";
9913
- BuildInCalls2["Contains"] = "builtInContains";
9914
- BuildInCalls2["Strstarts"] = "builtInStrstarts";
9915
- BuildInCalls2["Strends"] = "builtInStrends";
9916
- BuildInCalls2["Strbefore"] = "builtInStrbefore";
9917
- BuildInCalls2["Strafter"] = "builtInStrafter";
9918
- BuildInCalls2["Year"] = "builtInYear";
9919
- BuildInCalls2["Month"] = "builtInMonth";
9920
- BuildInCalls2["Day"] = "builtInDay";
9921
- BuildInCalls2["Hours"] = "builtInHours";
9922
- BuildInCalls2["Minutes"] = "builtInMinutes";
9923
- BuildInCalls2["Seconds"] = "builtInSeconds";
9924
- BuildInCalls2["Timezone"] = "builtInTimezone";
9925
- BuildInCalls2["Tz"] = "builtInTz";
9926
- BuildInCalls2["Now"] = "builtInNow";
9927
- BuildInCalls2["Uuid"] = "builtInUuid";
9928
- BuildInCalls2["Struuid"] = "builtInStruuid";
9929
- BuildInCalls2["Md5"] = "builtInMd5";
9930
- BuildInCalls2["Sha1"] = "builtInSha1";
9931
- BuildInCalls2["Sha256"] = "builtInSha256";
9932
- BuildInCalls2["Sha384"] = "builtInSha384";
9933
- BuildInCalls2["Sha512"] = "builtInSha512";
9934
- BuildInCalls2["Coalesce"] = "builtInCoalesce";
9935
- BuildInCalls2["If"] = "builtInIf";
9936
- BuildInCalls2["Strlang"] = "builtInStrlang";
9937
- BuildInCalls2["Strdt"] = "builtInStrdt";
9938
- BuildInCalls2["Sameterm"] = "builtInSameterm";
9939
- BuildInCalls2["Isiri"] = "builtInIsiri";
9940
- BuildInCalls2["Isuri"] = "builtInIsuri";
9941
- BuildInCalls2["Isblank"] = "builtInIsblank";
9942
- BuildInCalls2["Isliteral"] = "builtInIsliteral";
9943
- BuildInCalls2["Isnumeric"] = "builtInIsnumeric";
9944
- BuildInCalls2["Regex"] = "builtInRegex";
9945
- BuildInCalls2["Substr"] = "builtInSubstr";
9946
- BuildInCalls2["Replace"] = "builtInReplace";
9947
- BuildInCalls2["Exists"] = "builtInExists";
9948
- BuildInCalls2["Notexists"] = "builtInNotexists";
9949
- BuildInCalls2["Count"] = "builtInCount";
9950
- BuildInCalls2["Sum"] = "builtInSum";
9951
- BuildInCalls2["Min"] = "builtInMin";
9952
- BuildInCalls2["Max"] = "builtInMax";
9953
- BuildInCalls2["Avg"] = "builtInAvg";
9954
- BuildInCalls2["Sample"] = "builtInSample";
9955
- BuildInCalls2["Group_concat"] = "builtInGroup_concat";
9956
- return BuildInCalls2;
9957
- })(BuildInCalls || {});
9895
+ // lib/lexer/BuiltInCalls.ts
9896
+ var BuiltInCalls = /* @__PURE__ */ ((BuiltInCalls2) => {
9897
+ BuiltInCalls2["Str"] = "builtInStr";
9898
+ BuiltInCalls2["Lang"] = "builtInLang";
9899
+ BuiltInCalls2["Langmatches"] = "builtInLangmatches";
9900
+ BuiltInCalls2["Datatype"] = "builtInDatatype";
9901
+ BuiltInCalls2["Bound"] = "builtInBound";
9902
+ BuiltInCalls2["Iri"] = "builtInIri";
9903
+ BuiltInCalls2["Uri"] = "builtInUri";
9904
+ BuiltInCalls2["Bnode"] = "builtInBnode";
9905
+ BuiltInCalls2["Rand"] = "builtInRand";
9906
+ BuiltInCalls2["Abs"] = "builtInAbs";
9907
+ BuiltInCalls2["Ceil"] = "builtInCeil";
9908
+ BuiltInCalls2["Floor"] = "builtInFloor";
9909
+ BuiltInCalls2["Round"] = "builtInRound";
9910
+ BuiltInCalls2["Concat"] = "builtInConcat";
9911
+ BuiltInCalls2["Strlen"] = "builtInStrlen";
9912
+ BuiltInCalls2["Ucase"] = "builtInUcase";
9913
+ BuiltInCalls2["Lcase"] = "builtInLcase";
9914
+ BuiltInCalls2["Encode_for_uri"] = "builtInEncode_for_uri";
9915
+ BuiltInCalls2["Contains"] = "builtInContains";
9916
+ BuiltInCalls2["Strstarts"] = "builtInStrstarts";
9917
+ BuiltInCalls2["Strends"] = "builtInStrends";
9918
+ BuiltInCalls2["Strbefore"] = "builtInStrbefore";
9919
+ BuiltInCalls2["Strafter"] = "builtInStrafter";
9920
+ BuiltInCalls2["Year"] = "builtInYear";
9921
+ BuiltInCalls2["Month"] = "builtInMonth";
9922
+ BuiltInCalls2["Day"] = "builtInDay";
9923
+ BuiltInCalls2["Hours"] = "builtInHours";
9924
+ BuiltInCalls2["Minutes"] = "builtInMinutes";
9925
+ BuiltInCalls2["Seconds"] = "builtInSeconds";
9926
+ BuiltInCalls2["Timezone"] = "builtInTimezone";
9927
+ BuiltInCalls2["Tz"] = "builtInTz";
9928
+ BuiltInCalls2["Now"] = "builtInNow";
9929
+ BuiltInCalls2["Uuid"] = "builtInUuid";
9930
+ BuiltInCalls2["Struuid"] = "builtInStruuid";
9931
+ BuiltInCalls2["Md5"] = "builtInMd5";
9932
+ BuiltInCalls2["Sha1"] = "builtInSha1";
9933
+ BuiltInCalls2["Sha256"] = "builtInSha256";
9934
+ BuiltInCalls2["Sha384"] = "builtInSha384";
9935
+ BuiltInCalls2["Sha512"] = "builtInSha512";
9936
+ BuiltInCalls2["Coalesce"] = "builtInCoalesce";
9937
+ BuiltInCalls2["If"] = "builtInIf";
9938
+ BuiltInCalls2["Strlang"] = "builtInStrlang";
9939
+ BuiltInCalls2["Strdt"] = "builtInStrdt";
9940
+ BuiltInCalls2["Sameterm"] = "builtInSameterm";
9941
+ BuiltInCalls2["Isiri"] = "builtInIsiri";
9942
+ BuiltInCalls2["Isuri"] = "builtInIsuri";
9943
+ BuiltInCalls2["Isblank"] = "builtInIsblank";
9944
+ BuiltInCalls2["Isliteral"] = "builtInIsliteral";
9945
+ BuiltInCalls2["Isnumeric"] = "builtInIsnumeric";
9946
+ BuiltInCalls2["Regex"] = "builtInRegex";
9947
+ BuiltInCalls2["Substr"] = "builtInSubstr";
9948
+ BuiltInCalls2["Replace"] = "builtInReplace";
9949
+ BuiltInCalls2["Exists"] = "builtInExists";
9950
+ BuiltInCalls2["Notexists"] = "builtInNotexists";
9951
+ BuiltInCalls2["Count"] = "builtInCount";
9952
+ BuiltInCalls2["Sum"] = "builtInSum";
9953
+ BuiltInCalls2["Min"] = "builtInMin";
9954
+ BuiltInCalls2["Max"] = "builtInMax";
9955
+ BuiltInCalls2["Avg"] = "builtInAvg";
9956
+ BuiltInCalls2["Sample"] = "builtInSample";
9957
+ BuiltInCalls2["Group_concat"] = "builtInGroup_concat";
9958
+ return BuiltInCalls2;
9959
+ })(BuiltInCalls || {});
9958
9960
  function capitalize(string2) {
9959
9961
  return string2.charAt(0).toUpperCase() + string2.slice(1);
9960
9962
  }
@@ -10458,7 +10460,7 @@ var allBaseTokens = LexerBuilder.create().add(
10458
10460
  notIn,
10459
10461
  separator
10460
10462
  );
10461
- 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);
10463
+ 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);
10462
10464
 
10463
10465
  // lib/factoryMixins/ContextFactory.ts
10464
10466
  var nodeType = "contextDef";
@@ -10903,10 +10905,7 @@ function SolutionModifiersFactoryMixin(Base) {
10903
10905
  var nodeType8 = "term";
10904
10906
  function TermFactoryMixin(Base) {
10905
10907
  return class TermFactory extends Base {
10906
- constructor() {
10907
- super(...arguments);
10908
- this.__blankNodeCounter = 0;
10909
- }
10908
+ __blankNodeCounter = 0;
10910
10909
  resetBlankNodeCounter() {
10911
10910
  this.__blankNodeCounter = 0;
10912
10911
  }
@@ -11382,7 +11381,28 @@ function updateNoReuseBlankNodeLabels(updateQuery) {
11382
11381
  }
11383
11382
  }
11384
11383
 
11385
- // lib/grammar-helpers/utils.ts
11384
+ // lib/utils.ts
11385
+ function sparqlCodepointEscape(input) {
11386
+ const sanitizedInput = input.replaceAll(
11387
+ /\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,
11388
+ (_, unicode4, unicode8) => {
11389
+ if (unicode4) {
11390
+ const charCode2 = Number.parseInt(unicode4, 16);
11391
+ return String.fromCodePoint(charCode2);
11392
+ }
11393
+ const charCode = Number.parseInt(unicode8, 16);
11394
+ if (charCode < 65535) {
11395
+ return String.fromCodePoint(charCode);
11396
+ }
11397
+ const substractedCharCode = charCode - 65536;
11398
+ return String.fromCodePoint(55296 + (substractedCharCode >> 10), 56320 + (substractedCharCode & 1023));
11399
+ }
11400
+ );
11401
+ if (/[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)/u.test(sanitizedInput)) {
11402
+ throw new Error(`Invalid unicode codepoint of surrogate pair without corresponding codepoint`);
11403
+ }
11404
+ return sanitizedInput;
11405
+ }
11386
11406
  var CommonIRIs = /* @__PURE__ */ ((CommonIRIs2) => {
11387
11407
  CommonIRIs2["BOOLEAN"] = "http://www.w3.org/2001/XMLSchema#boolean";
11388
11408
  CommonIRIs2["INTEGER"] = "http://www.w3.org/2001/XMLSchema#integer";
@@ -11393,7 +11413,6 @@ var CommonIRIs = /* @__PURE__ */ ((CommonIRIs2) => {
11393
11413
  CommonIRIs2["REST"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest";
11394
11414
  CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
11395
11415
  CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
11396
- CommonIRIs2["REIFIES"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies";
11397
11416
  return CommonIRIs2;
11398
11417
  })(CommonIRIs || {});
11399
11418
 
@@ -11424,7 +11443,7 @@ function stringEscapedLexical(str2) {
11424
11443
  var rdfLiteral = {
11425
11444
  name: "rdfLiteral",
11426
11445
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION, OR }) => (C) => {
11427
- const value = SUBRULE1(string, void 0);
11446
+ const value = SUBRULE1(string);
11428
11447
  return OPTION(() => OR([
11429
11448
  { ALT: () => {
11430
11449
  const lang2 = CONSUME(terminals_exports.langTag);
@@ -11436,7 +11455,7 @@ var rdfLiteral = {
11436
11455
  } },
11437
11456
  { ALT: () => {
11438
11457
  CONSUME(symbols_exports.hathat);
11439
- const iriVal = SUBRULE1(iri2, void 0);
11458
+ const iriVal = SUBRULE1(iri2);
11440
11459
  return ACTION(() => C.factory.literalTerm(
11441
11460
  C.factory.sourceLocation(value, iriVal),
11442
11461
  value.value,
@@ -11452,7 +11471,7 @@ var rdfLiteral = {
11452
11471
  factory.printFilter(ast, () => PRINT("@", ast.langOrIri));
11453
11472
  } else {
11454
11473
  factory.printFilter(ast, () => PRINT("^^"));
11455
- SUBRULE(iri2, ast.langOrIri, void 0);
11474
+ SUBRULE(iri2, ast.langOrIri);
11456
11475
  }
11457
11476
  }
11458
11477
  }
@@ -11460,9 +11479,9 @@ var rdfLiteral = {
11460
11479
  var numericLiteral = {
11461
11480
  name: "numericLiteral",
11462
11481
  impl: ({ SUBRULE, OR }) => () => OR([
11463
- { ALT: () => SUBRULE(numericLiteralUnsigned, void 0) },
11464
- { ALT: () => SUBRULE(numericLiteralPositive, void 0) },
11465
- { ALT: () => SUBRULE(numericLiteralNegative, void 0) }
11482
+ { ALT: () => SUBRULE(numericLiteralUnsigned) },
11483
+ { ALT: () => SUBRULE(numericLiteralPositive) },
11484
+ { ALT: () => SUBRULE(numericLiteralNegative) }
11466
11485
  ])
11467
11486
  };
11468
11487
  var numericLiteralUnsigned = {
@@ -11570,10 +11589,10 @@ var string = {
11570
11589
  var iri2 = {
11571
11590
  name: "iri",
11572
11591
  impl: ({ SUBRULE, OR }) => () => OR([
11573
- { ALT: () => SUBRULE(iriFull, void 0) },
11574
- { ALT: () => SUBRULE(prefixedName, void 0) }
11592
+ { ALT: () => SUBRULE(iriFull) },
11593
+ { ALT: () => SUBRULE(prefixedName) }
11575
11594
  ]),
11576
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast, void 0) : SUBRULE(iriFull, ast, void 0)
11595
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast) : SUBRULE(iriFull, ast)
11577
11596
  };
11578
11597
  var iriFull = {
11579
11598
  name: "iriFull",
@@ -11637,93 +11656,25 @@ var verbA = {
11637
11656
  }
11638
11657
  };
11639
11658
 
11640
- // lib/grammar/dataSetClause.ts
11641
- function datasetClauseUsing(name, token) {
11642
- return {
11643
- name,
11644
- impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
11645
- const start = CONSUME(token);
11646
- return OR([
11647
- { ALT: () => {
11648
- const iri3 = SUBRULE(defaultGraphClause, void 0);
11649
- return ACTION(() => C.factory.wrap({ clauseType: "default", value: iri3 }, C.factory.sourceLocation(start, iri3)));
11650
- } },
11651
- { ALT: () => {
11652
- const namedClause = SUBRULE(namedGraphClause, void 0);
11653
- return ACTION(() => C.factory.wrap({
11654
- clauseType: "named",
11655
- value: namedClause.val
11656
- }, C.factory.sourceLocation(start, namedClause)));
11657
- } }
11658
- ]);
11659
- }
11660
- };
11661
- }
11662
- var datasetClause = datasetClauseUsing("datasetClause", from);
11663
- var defaultGraphClause = {
11664
- name: "defaultGraphClause",
11665
- impl: ({ SUBRULE }) => () => SUBRULE(sourceSelector, void 0)
11666
- };
11667
- var usingClause2 = datasetClauseUsing("usingClause", usingClause);
11668
- function datasetClauseUsingStar(name, subRule, fromUsing) {
11669
- return {
11670
- name,
11671
- impl: ({ ACTION, MANY, SUBRULE }) => (C) => {
11672
- const clauses = [];
11673
- MANY(() => {
11674
- const clause = SUBRULE(subRule, void 0);
11675
- clauses.push(clause);
11676
- });
11677
- return ACTION(() => C.factory.datasetClauses(
11678
- clauses.map((clause) => clause.val),
11679
- C.factory.sourceLocation(...clauses)
11680
- ));
11681
- },
11682
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11683
- for (const clause of ast.clauses) {
11684
- F2.printFilter(ast, () => PRINT_WORD(fromUsing));
11685
- if (clause.clauseType === "named") {
11686
- F2.printFilter(ast, () => PRINT_WORD("NAMED"));
11687
- }
11688
- SUBRULE(iri2, clause.value, void 0);
11689
- }
11690
- }
11691
- };
11692
- }
11693
- var datasetClauseStar = datasetClauseUsingStar("datasetClauses", datasetClause, "FROM");
11694
- var usingClauseStar = datasetClauseUsingStar("usingClauses", usingClause2, "USING");
11695
- var namedGraphClause = {
11696
- name: "namedGraphClause",
11697
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11698
- const named2 = CONSUME(graph_exports.named);
11699
- const iri3 = SUBRULE(sourceSelector, void 0);
11700
- return ACTION(() => C.factory.wrap(iri3, C.factory.sourceLocation(named2, iri3)));
11701
- }
11702
- };
11703
- var sourceSelector = {
11704
- name: "sourceSelector",
11705
- impl: ({ SUBRULE }) => () => SUBRULE(iri2, void 0)
11706
- };
11707
-
11708
11659
  // lib/grammar/general.ts
11709
11660
  var prologue = {
11710
11661
  name: "prologue",
11711
11662
  impl: ({ SUBRULE, MANY, OR }) => () => {
11712
11663
  const result = [];
11713
11664
  MANY(() => OR([
11714
- { ALT: () => result.push(SUBRULE(baseDecl2, void 0)) },
11665
+ { ALT: () => result.push(SUBRULE(baseDecl2)) },
11715
11666
  // TODO: the [spec](https://www.w3.org/TR/sparql11-query/#iriRefs) says you cannot redefine prefixes.
11716
11667
  // We might need to check this.
11717
- { ALT: () => result.push(SUBRULE(prefixDecl2, void 0)) }
11668
+ { ALT: () => result.push(SUBRULE(prefixDecl2)) }
11718
11669
  ]));
11719
11670
  return result;
11720
11671
  },
11721
11672
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11722
11673
  for (const context of ast) {
11723
11674
  if (F2.isContextDefinitionBase(context)) {
11724
- SUBRULE(baseDecl2, context, void 0);
11675
+ SUBRULE(baseDecl2, context);
11725
11676
  } else if (F2.isContextDefinitionPrefix(context)) {
11726
- SUBRULE(prefixDecl2, context, void 0);
11677
+ SUBRULE(prefixDecl2, context);
11727
11678
  }
11728
11679
  }
11729
11680
  }
@@ -11732,12 +11683,12 @@ var baseDecl2 = {
11732
11683
  name: "baseDecl",
11733
11684
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11734
11685
  const base = CONSUME(baseDecl);
11735
- const val = SUBRULE(iriFull, void 0);
11686
+ const val = SUBRULE(iriFull);
11736
11687
  return ACTION(() => C.factory.contextDefinitionBase(C.factory.sourceLocation(base, val), val));
11737
11688
  },
11738
11689
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11739
11690
  F2.printFilter(ast, () => PRINT_WORD("BASE"));
11740
- SUBRULE(iri2, ast.value, void 0);
11691
+ SUBRULE(iri2, ast.value);
11741
11692
  }
11742
11693
  };
11743
11694
  var prefixDecl2 = {
@@ -11745,41 +11696,41 @@ var prefixDecl2 = {
11745
11696
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11746
11697
  const prefix = CONSUME(prefixDecl);
11747
11698
  const name = CONSUME(terminals_exports.pNameNs).image.slice(0, -1);
11748
- const value = SUBRULE(iriFull, void 0);
11699
+ const value = SUBRULE(iriFull);
11749
11700
  return ACTION(() => C.factory.contextDefinitionPrefix(C.factory.sourceLocation(prefix, value), name, value));
11750
11701
  },
11751
11702
  gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { factory: F2 }) => {
11752
11703
  F2.printFilter(ast, () => {
11753
11704
  PRINT_WORDS("PREFIX", `${ast.key}:`);
11754
11705
  });
11755
- SUBRULE(iri2, ast.value, void 0);
11706
+ SUBRULE(iri2, ast.value);
11756
11707
  }
11757
11708
  };
11758
11709
  var verb = {
11759
11710
  name: "verb",
11760
11711
  impl: ({ SUBRULE, OR }) => () => OR([
11761
- { ALT: () => SUBRULE(varOrIri, void 0) },
11762
- { ALT: () => SUBRULE(verbA, void 0) }
11712
+ { ALT: () => SUBRULE(varOrIri) },
11713
+ { ALT: () => SUBRULE(verbA) }
11763
11714
  ])
11764
11715
  };
11765
11716
  var varOrTerm = {
11766
11717
  name: "varOrTerm",
11767
11718
  impl: ({ SUBRULE, OR }) => (C) => OR([
11768
- { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_, void 0) },
11769
- { ALT: () => SUBRULE(graphTerm, void 0) }
11719
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
11720
+ { ALT: () => SUBRULE(graphTerm) }
11770
11721
  ]),
11771
11722
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11772
11723
  if (F2.isTermVariable(ast)) {
11773
- return SUBRULE(var_, ast, void 0);
11724
+ return SUBRULE(var_, ast);
11774
11725
  }
11775
- return SUBRULE(graphTerm, ast, void 0);
11726
+ return SUBRULE(graphTerm, ast);
11776
11727
  }
11777
11728
  };
11778
11729
  var varOrIri = {
11779
11730
  name: "varOrIri",
11780
11731
  impl: ({ SUBRULE, OR }) => (C) => OR([
11781
- { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_, void 0) },
11782
- { ALT: () => SUBRULE(iri2, void 0) }
11732
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
11733
+ { ALT: () => SUBRULE(iri2) }
11783
11734
  ])
11784
11735
  };
11785
11736
  var var_ = {
@@ -11798,11 +11749,11 @@ var var_ = {
11798
11749
  var graphTerm = {
11799
11750
  name: "graphTerm",
11800
11751
  impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => OR([
11801
- { ALT: () => SUBRULE(iri2, void 0) },
11802
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
11803
- { ALT: () => SUBRULE(numericLiteral, void 0) },
11804
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
11805
- { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode, void 0) },
11752
+ { ALT: () => SUBRULE(iri2) },
11753
+ { ALT: () => SUBRULE(rdfLiteral) },
11754
+ { ALT: () => SUBRULE(numericLiteral) },
11755
+ { ALT: () => SUBRULE(booleanLiteral) },
11756
+ { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
11806
11757
  { ALT: () => {
11807
11758
  const tokenNil = CONSUME(terminals_exports.nil);
11808
11759
  return ACTION(() => C.factory.namedNode(C.factory.sourceLocation(tokenNil), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */));
@@ -11810,1275 +11761,1344 @@ var graphTerm = {
11810
11761
  ]),
11811
11762
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11812
11763
  if (F2.isTermNamed(ast)) {
11813
- SUBRULE(iri2, ast, void 0);
11764
+ SUBRULE(iri2, ast);
11814
11765
  } else if (F2.isTermLiteral(ast)) {
11815
- SUBRULE(rdfLiteral, ast, void 0);
11766
+ SUBRULE(rdfLiteral, ast);
11816
11767
  } else if (F2.isTermBlank(ast)) {
11817
- SUBRULE(blankNode, ast, void 0);
11768
+ SUBRULE(blankNode, ast);
11818
11769
  }
11819
11770
  }
11820
11771
  };
11821
11772
 
11822
- // lib/grammar/propertyPaths.ts
11823
- var path = {
11824
- name: "path",
11825
- impl: ({ SUBRULE }) => () => SUBRULE(pathAlternative, void 0)
11826
- };
11827
- var pathGenerator = {
11828
- name: "path",
11829
- gImpl: ({ PRINT, SUBRULE }) => (ast, { factory: F2 }, braces = true) => {
11830
- if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
11831
- SUBRULE(iri2, ast, void 0);
11832
- } else {
11833
- F2.printFilter(ast, () => braces && PRINT("("));
11834
- switch (ast.subType) {
11835
- case "|":
11836
- case "/": {
11837
- const [head2, ...tail] = ast.items;
11838
- SUBRULE(pathGenerator, head2, braces);
11839
- for (const val of tail) {
11840
- F2.printFilter(ast, () => PRINT(ast.subType));
11841
- SUBRULE(pathGenerator, val, braces);
11842
- }
11843
- break;
11844
- }
11845
- case "^":
11846
- F2.printFilter(ast, () => PRINT("^"));
11847
- SUBRULE(pathGenerator, ast.items[0], braces);
11848
- break;
11849
- case "?":
11850
- case "*":
11851
- case "+":
11852
- SUBRULE(pathGenerator, ast.items[0], braces);
11853
- F2.printFilter(ast, () => PRINT(ast.subType));
11854
- break;
11855
- case "!":
11856
- F2.printFilter(ast, () => PRINT("!"));
11857
- F2.printFilter(ast, () => PRINT("("));
11858
- SUBRULE(pathGenerator, ast.items[0], false);
11859
- F2.printFilter(ast, () => PRINT(")"));
11860
- break;
11861
- }
11862
- F2.printFilter(ast, () => braces && PRINT(")"));
11773
+ // lib/grammar/dataSetClause.ts
11774
+ function datasetClauseUsing(name, token) {
11775
+ return {
11776
+ name,
11777
+ impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
11778
+ const start = CONSUME(token);
11779
+ return OR([
11780
+ { ALT: () => {
11781
+ const iri3 = SUBRULE(defaultGraphClause);
11782
+ return ACTION(() => C.factory.wrap({ clauseType: "default", value: iri3 }, C.factory.sourceLocation(start, iri3)));
11783
+ } },
11784
+ { ALT: () => {
11785
+ const namedClause = SUBRULE(namedGraphClause);
11786
+ return ACTION(() => C.factory.wrap({
11787
+ clauseType: "named",
11788
+ value: namedClause.val
11789
+ }, C.factory.sourceLocation(start, namedClause)));
11790
+ } }
11791
+ ]);
11863
11792
  }
11864
- }
11793
+ };
11794
+ }
11795
+ var datasetClause = datasetClauseUsing("datasetClause", from);
11796
+ var defaultGraphClause = {
11797
+ name: "defaultGraphClause",
11798
+ impl: ({ SUBRULE }) => () => SUBRULE(sourceSelector)
11865
11799
  };
11866
- function pathChainHelper(name, SEP, subType, subRule) {
11800
+ var usingClause2 = datasetClauseUsing("usingClause", usingClause);
11801
+ function datasetClauseUsingStar(name, subRule, fromUsing) {
11867
11802
  return {
11868
11803
  name,
11869
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, MANY }) => (C) => {
11870
- const head2 = SUBRULE1(subRule, void 0);
11871
- let tailEnd = head2;
11872
- const tail = [];
11804
+ impl: ({ ACTION, MANY, SUBRULE }) => (C) => {
11805
+ const clauses = [];
11873
11806
  MANY(() => {
11874
- CONSUME(SEP);
11875
- tailEnd = SUBRULE2(subRule, void 0);
11876
- tail.push(tailEnd);
11807
+ const clause = SUBRULE(subRule);
11808
+ clauses.push(clause);
11877
11809
  });
11878
- return ACTION(() => tail.length === 0 ? head2 : C.factory.path(subType, [head2, ...tail], C.factory.sourceLocation(head2, tailEnd)));
11810
+ return ACTION(() => C.factory.datasetClauses(
11811
+ clauses.map((clause) => clause.val),
11812
+ C.factory.sourceLocation(...clauses)
11813
+ ));
11814
+ },
11815
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11816
+ for (const clause of ast.clauses) {
11817
+ F2.printFilter(ast, () => PRINT_WORD(fromUsing));
11818
+ if (clause.clauseType === "named") {
11819
+ F2.printFilter(ast, () => PRINT_WORD("NAMED"));
11820
+ }
11821
+ SUBRULE(iri2, clause.value);
11822
+ }
11879
11823
  }
11880
11824
  };
11881
11825
  }
11882
- var pathEltOrInverse = {
11883
- name: "pathEltOrInverse",
11884
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR }) => (C) => OR([
11885
- { ALT: () => SUBRULE1(pathElt, void 0) },
11886
- { ALT: () => {
11887
- const hat2 = CONSUME(symbols_exports.hat);
11888
- const item = SUBRULE2(pathElt, void 0);
11889
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
11890
- } }
11891
- ])
11892
- };
11893
- var pathSequence = pathChainHelper("pathSequence", symbols_exports.slash, "/", pathEltOrInverse);
11894
- var pathAlternative = pathChainHelper("pathAlternative", symbols_exports.pipe, "|", pathSequence);
11895
- var pathElt = {
11896
- name: "pathElt",
11897
- impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
11898
- const item = SUBRULE(pathPrimary, void 0);
11899
- const modification = OPTION(() => SUBRULE(pathMod, void 0));
11900
- return ACTION(() => modification === void 0 ? item : C.factory.path(modification.image, [item], C.factory.sourceLocation(item, modification)));
11901
- }
11902
- };
11903
- var pathMod = {
11904
- name: "pathMod",
11905
- impl: ({ CONSUME, OR }) => () => OR([
11906
- { ALT: () => CONSUME(symbols_exports.question) },
11907
- { ALT: () => CONSUME(symbols_exports.star) },
11908
- { ALT: () => CONSUME(symbols_exports.opPlus) }
11909
- ])
11910
- };
11911
- var pathPrimary = {
11912
- name: "pathPrimary",
11913
- impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
11914
- { ALT: () => SUBRULE(iri2, void 0) },
11915
- { ALT: () => SUBRULE(verbA, void 0) },
11916
- { ALT: () => SUBRULE(pathNegatedPropertySet, void 0) },
11917
- { ALT: () => {
11918
- CONSUME(symbols_exports.LParen);
11919
- const resRecursive = SUBRULE(path, void 0);
11920
- CONSUME(symbols_exports.RParen);
11921
- return resRecursive;
11922
- } }
11923
- ])
11924
- };
11925
- var pathNegatedPropertySet = {
11926
- name: "pathNegatedPropertySet",
11927
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, OR, MANY }) => (C) => {
11928
- const exclamation2 = CONSUME(symbols_exports.exclamation);
11929
- return OR([
11930
- { ALT: () => {
11931
- const noAlternative = SUBRULE1(pathOneInPropertySet, void 0);
11932
- return ACTION(() => C.factory.path("!", [noAlternative], C.factory.sourceLocation(exclamation2, noAlternative)));
11933
- } },
11934
- { ALT: () => {
11935
- const open = CONSUME(symbols_exports.LParen);
11936
- const head2 = SUBRULE2(pathOneInPropertySet, void 0);
11937
- const tail = [];
11938
- MANY(() => {
11939
- CONSUME(symbols_exports.pipe);
11940
- const item = SUBRULE3(pathOneInPropertySet, void 0);
11941
- tail.push(item);
11942
- });
11943
- const close = CONSUME(symbols_exports.RParen);
11944
- return ACTION(() => {
11945
- const F2 = C.factory;
11946
- if (tail.length === 0) {
11947
- return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
11948
- }
11949
- return F2.path(
11950
- "!",
11951
- [F2.path("|", [head2, ...tail], F2.sourceLocation(open, close))],
11952
- F2.sourceLocation(exclamation2, close)
11953
- );
11954
- });
11955
- } }
11956
- ]);
11826
+ var datasetClauseStar = datasetClauseUsingStar("datasetClauses", datasetClause, "FROM");
11827
+ var usingClauseStar = datasetClauseUsingStar("usingClauses", usingClause2, "USING");
11828
+ var namedGraphClause = {
11829
+ name: "namedGraphClause",
11830
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11831
+ const named2 = CONSUME(graph_exports.named);
11832
+ const iri3 = SUBRULE(sourceSelector);
11833
+ return ACTION(() => C.factory.wrap(iri3, C.factory.sourceLocation(named2, iri3)));
11957
11834
  }
11958
11835
  };
11959
- var pathOneInPropertySet = {
11960
- name: "pathOneInPropertySet",
11961
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
11962
- { ALT: () => SUBRULE1(iri2, void 0) },
11963
- { ALT: () => SUBRULE1(verbA, void 0) },
11964
- { ALT: () => {
11965
- const hat2 = CONSUME(symbols_exports.hat);
11966
- const item = OR2([
11967
- { ALT: () => SUBRULE2(iri2, void 0) },
11968
- { ALT: () => SUBRULE2(verbA, void 0) }
11969
- ]);
11970
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
11971
- } }
11972
- ])
11836
+ var sourceSelector = {
11837
+ name: "sourceSelector",
11838
+ impl: ({ SUBRULE }) => () => SUBRULE(iri2)
11973
11839
  };
11974
11840
 
11975
- // lib/grammar/tripleBlock.ts
11976
- function triplesDotSeperated(triplesSameSubjectSubrule) {
11977
- return ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME, OPTION }) => (C) => {
11978
- const triples = [];
11979
- let parsedDot = true;
11980
- let dotToken;
11981
- AT_LEAST_ONE({
11982
- GATE: () => parsedDot,
11983
- DEF: () => {
11984
- parsedDot = false;
11985
- const template = SUBRULE(triplesSameSubjectSubrule, void 0);
11986
- ACTION(() => {
11987
- triples.push(...template);
11988
- });
11989
- OPTION(() => {
11990
- dotToken = CONSUME(symbols_exports.dot);
11991
- parsedDot = true;
11992
- });
11993
- }
11994
- });
11995
- return ACTION(() => C.factory.patternBgp(triples, C.factory.sourceLocation(...triples, dotToken)));
11996
- };
11997
- }
11998
- var triplesBlock = {
11999
- name: "triplesBlock",
12000
- impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C, void 0),
12001
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12002
- for (const [index, triple] of ast.triples.entries()) {
12003
- HANDLE_LOC(triple, () => {
12004
- const nextTriple = ast.triples.at(index);
12005
- if (F2.isTripleCollection(triple)) {
12006
- SUBRULE(graphNodePath, triple, void 0);
12007
- F2.printFilter(triple, () => PRINT_WORD("."));
12008
- } else {
12009
- SUBRULE(graphNodePath, triple.subject, void 0);
12010
- if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12011
- SUBRULE(varOrTerm, triple.predicate, void 0);
12012
- } else {
12013
- SUBRULE(pathGenerator, triple.predicate, void 0);
12014
- }
12015
- SUBRULE(graphNodePath, triple.object, void 0);
12016
- if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12017
- F2.printFilter(ast, () => PRINT_WORD("."));
12018
- } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12019
- F2.printFilter(ast, () => PRINT_WORD(","));
12020
- } else {
12021
- F2.printFilter(ast, () => PRINT_WORD(";"));
12022
- }
12023
- }
12024
- });
12025
- }
12026
- }
12027
- };
12028
- function triplesSameSubjectImpl(name, allowPaths) {
11841
+ // lib/expressionHelpers.ts
11842
+ function funcExpr1(func) {
12029
11843
  return {
12030
- name,
12031
- impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
12032
- { ALT: () => {
12033
- const subject = SUBRULE(varOrTerm, void 0);
12034
- const res = SUBRULE(
12035
- allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty,
12036
- { subject: ACTION(() => C.factory.dematerialized(subject)) }
12037
- );
12038
- return ACTION(() => {
12039
- if (res.length > 0) {
12040
- res[0].subject = subject;
12041
- res[0].loc = C.factory.sourceLocation(subject, res[0]);
12042
- }
12043
- return res;
12044
- });
12045
- } },
12046
- { ALT: () => {
12047
- const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode, void 0);
12048
- const restNode = SUBRULE(
12049
- allowPaths ? propertyListPath : propertyList,
12050
- { subject: ACTION(() => C.factory.graphNodeIdentifier(subjectNode)) }
12051
- );
12052
- return ACTION(() => {
12053
- if (restNode.length === 0) {
12054
- return [subjectNode];
12055
- }
12056
- restNode[0].subject = subjectNode;
12057
- restNode[0].loc = C.factory.sourceLocation(subjectNode, restNode[0]);
12058
- return restNode;
12059
- });
12060
- } }
12061
- ])
11844
+ name: unCapitalize(func.name),
11845
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11846
+ const operator = CONSUME(func);
11847
+ CONSUME(symbols_exports.LParen);
11848
+ const arg = SUBRULE(expression);
11849
+ const close = CONSUME(symbols_exports.RParen);
11850
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11851
+ }
12062
11852
  };
12063
11853
  }
12064
- var triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
12065
- var triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
12066
- var triplesTemplate = {
12067
- name: "triplesTemplate",
12068
- impl: triplesDotSeperated(triplesSameSubject)
12069
- };
12070
- function propertyListImpl(name, allowPaths) {
11854
+ function funcExpr2(func) {
12071
11855
  return {
12072
- name,
12073
- impl: ({ SUBRULE, OPTION }) => (_, arg) => OPTION(() => SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, arg)) ?? []
11856
+ name: unCapitalize(func.name),
11857
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {
11858
+ const operator = CONSUME(func);
11859
+ CONSUME(symbols_exports.LParen);
11860
+ const arg1 = SUBRULE1(expression);
11861
+ CONSUME(symbols_exports.comma);
11862
+ const arg2 = SUBRULE2(expression);
11863
+ const close = CONSUME(symbols_exports.RParen);
11864
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2], C.factory.sourceLocation(operator, close)));
11865
+ }
12074
11866
  };
12075
11867
  }
12076
- var propertyList = propertyListImpl("propertyList", false);
12077
- var propertyListPath = propertyListImpl("propertyListPath", true);
12078
- function propertyListNotEmptyImplementation(name, allowPaths) {
11868
+ function funcExpr3(func) {
12079
11869
  return {
12080
- name,
12081
- impl: ({ ACTION, CONSUME, AT_LEAST_ONE, SUBRULE1, MANY2, OR1 }) => (_, arg) => {
12082
- const result = [];
12083
- let parsedSemi = true;
12084
- AT_LEAST_ONE({
12085
- GATE: () => parsedSemi,
12086
- DEF: () => {
12087
- parsedSemi = false;
12088
- const predicate = allowPaths ? OR1([
12089
- { ALT: () => SUBRULE1(verbPath, void 0) },
12090
- { ALT: () => SUBRULE1(verbSimple, void 0) }
12091
- ]) : SUBRULE1(verb, void 0);
12092
- const triples = SUBRULE1(
12093
- allowPaths ? objectListPath : objectList,
12094
- ACTION(() => ({ subject: arg.subject, predicate }))
12095
- );
12096
- MANY2(() => {
12097
- CONSUME(symbols_exports.semi);
12098
- parsedSemi = true;
12099
- });
12100
- ACTION(() => {
12101
- result.push(...triples);
12102
- });
12103
- }
12104
- });
12105
- return result;
11870
+ name: unCapitalize(func.name),
11871
+ impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {
11872
+ const operator = CONSUME(func);
11873
+ CONSUME(symbols_exports.LParen);
11874
+ const arg1 = SUBRULE1(expression);
11875
+ CONSUME1(symbols_exports.comma);
11876
+ const arg2 = SUBRULE2(expression);
11877
+ CONSUME2(symbols_exports.comma);
11878
+ const arg3 = SUBRULE3(expression);
11879
+ const close = CONSUME(symbols_exports.RParen);
11880
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
12106
11881
  }
12107
11882
  };
12108
11883
  }
12109
- var propertyListNotEmpty = propertyListNotEmptyImplementation("propertyListNotEmpty", false);
12110
- var propertyListPathNotEmpty = propertyListNotEmptyImplementation("propertyListPathNotEmpty", true);
12111
- var verbPath = {
12112
- name: "verbPath",
12113
- impl: ({ SUBRULE }) => () => SUBRULE(path, void 0)
12114
- };
12115
- var verbSimple = {
12116
- name: "verbSimple",
12117
- impl: ({ SUBRULE }) => () => SUBRULE(var_, void 0)
12118
- };
12119
- function objectListImpl(name, allowPaths) {
11884
+ function funcVar1(func) {
12120
11885
  return {
12121
- name,
12122
- impl: ({ ACTION, SUBRULE, AT_LEAST_ONE_SEP }) => (_, arg) => {
12123
- const objects = [];
12124
- AT_LEAST_ONE_SEP({
12125
- SEP: symbols_exports.comma,
12126
- DEF: () => {
12127
- const objectTriple = SUBRULE(allowPaths ? objectPath : object, arg);
12128
- ACTION(() => {
12129
- objects.push(objectTriple);
12130
- });
12131
- }
12132
- });
12133
- return objects;
11886
+ name: unCapitalize(func.name),
11887
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11888
+ const operator = CONSUME(func);
11889
+ CONSUME(symbols_exports.LParen);
11890
+ const arg = SUBRULE(var_);
11891
+ const close = CONSUME(symbols_exports.RParen);
11892
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12134
11893
  }
12135
11894
  };
12136
11895
  }
12137
- var objectList = objectListImpl("objectList", false);
12138
- var objectListPath = objectListImpl("objectListPath", true);
12139
- function objectImpl(name, allowPaths) {
11896
+ function funcExprOrNil1(func) {
12140
11897
  return {
12141
- name,
12142
- impl: ({ ACTION, SUBRULE }) => (C, arg) => {
12143
- const node = SUBRULE(allowPaths ? graphNodePath : graphNode, void 0);
12144
- return ACTION(() => C.factory.triple(arg.subject, arg.predicate, node));
11898
+ name: unCapitalize(func.name),
11899
+ impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
11900
+ const operator = CONSUME(func);
11901
+ return OR([
11902
+ { ALT: () => {
11903
+ CONSUME(symbols_exports.LParen);
11904
+ const arg = SUBRULE(expression);
11905
+ const close = CONSUME(symbols_exports.RParen);
11906
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11907
+ } },
11908
+ { ALT: () => {
11909
+ const nil2 = CONSUME(terminals_exports.nil);
11910
+ return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
11911
+ } }
11912
+ ]);
12145
11913
  }
12146
11914
  };
12147
11915
  }
12148
- var object = objectImpl("object", false);
12149
- var objectPath = objectImpl("objectPath", true);
12150
- function collectionImpl(name, allowPaths) {
11916
+ function funcNil1(func) {
12151
11917
  return {
12152
- name,
12153
- impl: ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME }) => (C) => {
12154
- const terms = [];
12155
- const startToken = CONSUME(symbols_exports.LParen);
12156
- AT_LEAST_ONE(() => {
12157
- terms.push(SUBRULE(allowPaths ? graphNodePath : graphNode, void 0));
12158
- });
12159
- const endToken = CONSUME(symbols_exports.RParen);
12160
- return ACTION(() => {
12161
- const F2 = C.factory;
12162
- const triples = [];
12163
- const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" /* FIRST */, void 0);
12164
- const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" /* REST */, void 0);
12165
- const predNil = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */, void 0);
12166
- const listHead = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12167
- let iterHead = listHead;
12168
- for (const [index, term] of terms.entries()) {
12169
- const lastInList = index === terms.length - 1;
12170
- const headTriple = F2.triple(
12171
- iterHead,
12172
- predFirst,
12173
- term
12174
- );
12175
- triples.push(headTriple);
12176
- if (lastInList) {
12177
- const nilTriple = F2.triple(iterHead, predRest, predNil);
12178
- triples.push(nilTriple);
12179
- } else {
12180
- const tail = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12181
- const linkTriple = F2.triple(iterHead, predRest, tail);
12182
- triples.push(linkTriple);
12183
- iterHead = tail;
12184
- }
12185
- }
12186
- return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
12187
- });
12188
- },
12189
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12190
- F2.printFilter(ast, () => PRINT_WORD("("));
12191
- for (const [idx, triple] of ast.triples.entries()) {
12192
- if (idx % 2 === 0) {
12193
- SUBRULE(allowPaths ? graphNodePath : graphNode, triple.object, void 0);
12194
- }
12195
- }
12196
- F2.printFilter(ast, () => PRINT_WORD(")"));
11918
+ name: unCapitalize(func.name),
11919
+ impl: ({ ACTION, CONSUME }) => (C) => {
11920
+ const operator = CONSUME(func);
11921
+ const nil2 = CONSUME(terminals_exports.nil);
11922
+ return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12197
11923
  }
12198
11924
  };
12199
11925
  }
12200
- var collection = collectionImpl("collection", false);
12201
- var collectionPath = collectionImpl("collectionPath", true);
12202
- function triplesNodeImpl(name, allowPaths) {
11926
+ function funcExprList1(func) {
12203
11927
  return {
12204
- name,
12205
- impl: ({ SUBRULE, OR }) => () => OR([
12206
- { ALT: () => SUBRULE(allowPaths ? collectionPath : collection, void 0) },
12207
- { ALT: () => SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, void 0) }
12208
- ]),
12209
- gImpl: ({ SUBRULE }) => (ast) => ast.subType === "list" ? SUBRULE(allowPaths ? collectionPath : collection, ast, void 0) : SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, ast, void 0)
11928
+ name: unCapitalize(func.name),
11929
+ impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11930
+ const operator = CONSUME(func);
11931
+ const args = SUBRULE(expressionList);
11932
+ return ACTION(() => C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));
11933
+ }
12210
11934
  };
12211
11935
  }
12212
- var triplesNode = triplesNodeImpl("triplesNode", false);
12213
- var triplesNodePath = triplesNodeImpl("triplesNodePath", true);
12214
- function blankNodePropertyListImpl(name, allowPaths) {
12215
- const propertyPathNotEmptyImpl = allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty;
11936
+ function funcExpr2or3(func) {
12216
11937
  return {
12217
- name,
12218
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12219
- const startToken = CONSUME(symbols_exports.LSquare);
12220
- const blankNode2 = ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocationNoMaterialize()));
12221
- const propList = SUBRULE(propertyPathNotEmptyImpl, { subject: blankNode2 });
12222
- const endToken = CONSUME(symbols_exports.RSquare);
12223
- return ACTION(() => C.factory.tripleCollectionBlankNodeProperties(
12224
- blankNode2,
12225
- propList,
12226
- C.factory.sourceLocation(startToken, endToken)
11938
+ name: unCapitalize(func.name),
11939
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) => (C) => {
11940
+ const operator = CONSUME(func);
11941
+ CONSUME(symbols_exports.LParen);
11942
+ const arg1 = SUBRULE1(expression);
11943
+ CONSUME1(symbols_exports.comma);
11944
+ const arg2 = SUBRULE2(expression);
11945
+ const arg3 = OPTION(() => {
11946
+ CONSUME2(symbols_exports.comma);
11947
+ return SUBRULE3(expression);
11948
+ });
11949
+ const close = CONSUME(symbols_exports.RParen);
11950
+ return ACTION(() => C.factory.expressionOperation(
11951
+ operator.image,
11952
+ arg3 ? [arg1, arg2, arg3] : [arg1, arg2],
11953
+ C.factory.sourceLocation(operator, close)
12227
11954
  ));
12228
- },
12229
- gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12230
- F2.printFilter(ast, () => PRINT("["));
12231
- for (const triple of ast.triples) {
12232
- HANDLE_LOC(triple, () => {
12233
- if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12234
- SUBRULE(varOrTerm, triple.predicate, void 0);
12235
- } else {
12236
- SUBRULE(pathGenerator, triple.predicate, void 0);
12237
- }
12238
- SUBRULE(graphNodePath, triple.object, void 0);
12239
- F2.printFilter(ast, () => PRINT_WORD(";"));
12240
- });
12241
- }
12242
- F2.printFilter(ast, () => PRINT("]"));
12243
11955
  }
12244
11956
  };
12245
11957
  }
12246
- var blankNodePropertyList = blankNodePropertyListImpl("blankNodePropertyList", false);
12247
- var blankNodePropertyListPath = blankNodePropertyListImpl("blankNodePropertyListPath", true);
12248
- function graphNodeImpl(name, allowPaths) {
12249
- const triplesNodeRule = allowPaths ? triplesNodePath : triplesNode;
11958
+ function funcExpr3or4(func) {
12250
11959
  return {
12251
- name,
12252
- impl: ({ SUBRULE, OR }) => (C) => OR([
12253
- { ALT: () => SUBRULE(varOrTerm, void 0) },
12254
- {
12255
- GATE: () => C.parseMode.has("canCreateBlankNodes"),
12256
- ALT: () => SUBRULE(triplesNodeRule, void 0)
12257
- }
12258
- ]),
12259
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12260
- if (F2.isTerm(ast)) {
12261
- SUBRULE(varOrTerm, ast, void 0);
12262
- } else {
12263
- SUBRULE(triplesNodeRule, ast, void 0);
12264
- }
11960
+ name: unCapitalize(func.name),
11961
+ impl: ({
11962
+ ACTION,
11963
+ CONSUME,
11964
+ SUBRULE1,
11965
+ SUBRULE2,
11966
+ SUBRULE3,
11967
+ SUBRULE4,
11968
+ CONSUME1,
11969
+ OPTION,
11970
+ CONSUME2,
11971
+ CONSUME3
11972
+ }) => (C) => {
11973
+ const operator = CONSUME(func);
11974
+ CONSUME(symbols_exports.LParen);
11975
+ const arg1 = SUBRULE1(expression);
11976
+ CONSUME1(symbols_exports.comma);
11977
+ const arg2 = SUBRULE2(expression);
11978
+ CONSUME2(symbols_exports.comma);
11979
+ const arg3 = SUBRULE3(expression);
11980
+ const arg4 = OPTION(() => {
11981
+ CONSUME3(symbols_exports.comma);
11982
+ return SUBRULE4(expression);
11983
+ });
11984
+ const close = CONSUME(symbols_exports.RParen);
11985
+ return ACTION(() => C.factory.expressionOperation(
11986
+ operator.image,
11987
+ arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3],
11988
+ C.factory.sourceLocation(operator, close)
11989
+ ));
11990
+ }
11991
+ };
11992
+ }
11993
+ function funcGroupGraphPattern(func) {
11994
+ return {
11995
+ name: unCapitalize(func.name),
11996
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11997
+ const operator = CONSUME(func);
11998
+ const group = SUBRULE(groupGraphPattern);
11999
+ return ACTION(() => C.factory.expressionPatternOperation(
12000
+ operator.image,
12001
+ group,
12002
+ C.factory.sourceLocation(operator, group)
12003
+ ));
12004
+ }
12005
+ };
12006
+ }
12007
+ function baseAggregateFunc(func) {
12008
+ return {
12009
+ name: unCapitalize(func.name),
12010
+ impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
12011
+ const operator = CONSUME(func);
12012
+ CONSUME(symbols_exports.LParen);
12013
+ const distinct2 = OPTION(() => CONSUME(distinct));
12014
+ const expr1 = SUBRULE(expression);
12015
+ const close = CONSUME(symbols_exports.RParen);
12016
+ return ACTION(() => C.factory.aggregate(
12017
+ operator.image,
12018
+ distinct2 !== void 0,
12019
+ expr1,
12020
+ void 0,
12021
+ C.factory.sourceLocation(operator, close)
12022
+ ));
12265
12023
  }
12266
12024
  };
12267
12025
  }
12268
- var graphNode = graphNodeImpl("graphNode", false);
12269
- var graphNodePath = graphNodeImpl("graphNodePath", true);
12270
12026
 
12271
- // lib/grammar/whereClause.ts
12272
- var whereClause = {
12273
- name: "whereClause",
12274
- impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
12275
- const where2 = OPTION(() => CONSUME(where));
12276
- const group = SUBRULE(groupGraphPattern, void 0);
12277
- return ACTION(() => C.factory.wrap(group, C.factory.sourceLocation(where2, group)));
12278
- },
12279
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12280
- F2.printFilter(ast, () => PRINT_WORD("WHERE"));
12281
- SUBRULE(groupGraphPattern, ast.val, void 0);
12027
+ // lib/grammar/builtIn.ts
12028
+ var builtInStr = funcExpr1(BuiltInCalls_exports.str);
12029
+ var builtInLang = funcExpr1(BuiltInCalls_exports.lang);
12030
+ var builtInLangmatches = funcExpr2(BuiltInCalls_exports.langmatches);
12031
+ var builtInDatatype = funcExpr1(BuiltInCalls_exports.datatype);
12032
+ var builtInBound = funcVar1(BuiltInCalls_exports.bound);
12033
+ var builtInIri = funcExpr1(BuiltInCalls_exports.iri);
12034
+ var builtInUri = funcExpr1(BuiltInCalls_exports.uri);
12035
+ var builtInBnodeSparqlJs = funcExprOrNil1(BuiltInCalls_exports.bnode);
12036
+ var builtInRand = funcNil1(BuiltInCalls_exports.rand);
12037
+ var builtInAbs = funcExpr1(BuiltInCalls_exports.abs);
12038
+ var builtInCeil = funcExpr1(BuiltInCalls_exports.ceil);
12039
+ var builtInFloor = funcExpr1(BuiltInCalls_exports.floor);
12040
+ var builtInRound = funcExpr1(BuiltInCalls_exports.round);
12041
+ var builtInConcat = funcExprList1(BuiltInCalls_exports.concat);
12042
+ var builtInStrlen = funcExpr1(BuiltInCalls_exports.strlen);
12043
+ var builtInUcase = funcExpr1(BuiltInCalls_exports.ucase);
12044
+ var builtInLcase = funcExpr1(BuiltInCalls_exports.lcase);
12045
+ var builtInEncode_for_uri = funcExpr1(BuiltInCalls_exports.encode_for_uri);
12046
+ var builtInContains = funcExpr2(BuiltInCalls_exports.contains);
12047
+ var builtInStrstarts = funcExpr2(BuiltInCalls_exports.strstarts);
12048
+ var builtInStrends = funcExpr2(BuiltInCalls_exports.strends);
12049
+ var builtInStrbefore = funcExpr2(BuiltInCalls_exports.strbefore);
12050
+ var builtInStrafter = funcExpr2(BuiltInCalls_exports.strafter);
12051
+ var builtInYear = funcExpr1(BuiltInCalls_exports.year);
12052
+ var builtInMonth = funcExpr1(BuiltInCalls_exports.month);
12053
+ var builtInDay = funcExpr1(BuiltInCalls_exports.day);
12054
+ var builtInHours = funcExpr1(BuiltInCalls_exports.hours);
12055
+ var builtInMinutes = funcExpr1(BuiltInCalls_exports.minutes);
12056
+ var builtInSeconds = funcExpr1(BuiltInCalls_exports.seconds);
12057
+ var builtInTimezone = funcExpr1(BuiltInCalls_exports.timezone);
12058
+ var builtInTz = funcExpr1(BuiltInCalls_exports.tz);
12059
+ var builtInNow = funcNil1(BuiltInCalls_exports.now);
12060
+ var builtInUuid = funcNil1(BuiltInCalls_exports.uuid);
12061
+ var builtInStruuid = funcNil1(BuiltInCalls_exports.struuid);
12062
+ var builtInMd5 = funcExpr1(BuiltInCalls_exports.md5);
12063
+ var builtInSha1 = funcExpr1(BuiltInCalls_exports.sha1);
12064
+ var builtInSha256 = funcExpr1(BuiltInCalls_exports.sha256);
12065
+ var builtInSha384 = funcExpr1(BuiltInCalls_exports.sha384);
12066
+ var builtInSha512 = funcExpr1(BuiltInCalls_exports.sha512);
12067
+ var builtInCoalesce = funcExprList1(BuiltInCalls_exports.coalesce);
12068
+ var builtInIf = funcExpr3(BuiltInCalls_exports.if_);
12069
+ var builtInStrlang = funcExpr2(BuiltInCalls_exports.strlang);
12070
+ var builtInStrdt = funcExpr2(BuiltInCalls_exports.strdt);
12071
+ var builtInSameterm = funcExpr2(BuiltInCalls_exports.sameterm);
12072
+ var builtInIsiri = funcExpr1(BuiltInCalls_exports.isiri);
12073
+ var builtInIsuri = funcExpr1(BuiltInCalls_exports.isuri);
12074
+ var builtInIsblank = funcExpr1(BuiltInCalls_exports.isblank);
12075
+ var builtInIsliteral = funcExpr1(BuiltInCalls_exports.isliteral);
12076
+ var builtInIsnumeric = funcExpr1(BuiltInCalls_exports.isnumeric);
12077
+ function builtInCallList(SUBRULE) {
12078
+ return [
12079
+ { ALT: () => SUBRULE(aggregate) },
12080
+ { ALT: () => SUBRULE(builtInStr) },
12081
+ { ALT: () => SUBRULE(builtInLang) },
12082
+ { ALT: () => SUBRULE(builtInLangmatches) },
12083
+ { ALT: () => SUBRULE(builtInDatatype) },
12084
+ { ALT: () => SUBRULE(builtInBound) },
12085
+ { ALT: () => SUBRULE(builtInIri) },
12086
+ { ALT: () => SUBRULE(builtInUri) },
12087
+ { ALT: () => SUBRULE(builtInBnodeSparqlJs) },
12088
+ { ALT: () => SUBRULE(builtInRand) },
12089
+ { ALT: () => SUBRULE(builtInAbs) },
12090
+ { ALT: () => SUBRULE(builtInCeil) },
12091
+ { ALT: () => SUBRULE(builtInFloor) },
12092
+ { ALT: () => SUBRULE(builtInRound) },
12093
+ { ALT: () => SUBRULE(builtInConcat) },
12094
+ { ALT: () => SUBRULE(substringExpression) },
12095
+ { ALT: () => SUBRULE(builtInStrlen) },
12096
+ { ALT: () => SUBRULE(strReplaceExpression) },
12097
+ { ALT: () => SUBRULE(builtInUcase) },
12098
+ { ALT: () => SUBRULE(builtInLcase) },
12099
+ { ALT: () => SUBRULE(builtInEncode_for_uri) },
12100
+ { ALT: () => SUBRULE(builtInContains) },
12101
+ { ALT: () => SUBRULE(builtInStrstarts) },
12102
+ { ALT: () => SUBRULE(builtInStrends) },
12103
+ { ALT: () => SUBRULE(builtInStrbefore) },
12104
+ { ALT: () => SUBRULE(builtInStrafter) },
12105
+ { ALT: () => SUBRULE(builtInYear) },
12106
+ { ALT: () => SUBRULE(builtInMonth) },
12107
+ { ALT: () => SUBRULE(builtInDay) },
12108
+ { ALT: () => SUBRULE(builtInHours) },
12109
+ { ALT: () => SUBRULE(builtInMinutes) },
12110
+ { ALT: () => SUBRULE(builtInSeconds) },
12111
+ { ALT: () => SUBRULE(builtInTimezone) },
12112
+ { ALT: () => SUBRULE(builtInTz) },
12113
+ { ALT: () => SUBRULE(builtInNow) },
12114
+ { ALT: () => SUBRULE(builtInUuid) },
12115
+ { ALT: () => SUBRULE(builtInStruuid) },
12116
+ { ALT: () => SUBRULE(builtInMd5) },
12117
+ { ALT: () => SUBRULE(builtInSha1) },
12118
+ { ALT: () => SUBRULE(builtInSha256) },
12119
+ { ALT: () => SUBRULE(builtInSha384) },
12120
+ { ALT: () => SUBRULE(builtInSha512) },
12121
+ { ALT: () => SUBRULE(builtInCoalesce) },
12122
+ { ALT: () => SUBRULE(builtInIf) },
12123
+ { ALT: () => SUBRULE(builtInStrlang) },
12124
+ { ALT: () => SUBRULE(builtInStrdt) },
12125
+ { ALT: () => SUBRULE(builtInSameterm) },
12126
+ { ALT: () => SUBRULE(builtInIsiri) },
12127
+ { ALT: () => SUBRULE(builtInIsuri) },
12128
+ { ALT: () => SUBRULE(builtInIsblank) },
12129
+ { ALT: () => SUBRULE(builtInIsliteral) },
12130
+ { ALT: () => SUBRULE(builtInIsnumeric) },
12131
+ { ALT: () => SUBRULE(regexExpression) },
12132
+ { ALT: () => SUBRULE(existsFunc) },
12133
+ { ALT: () => SUBRULE(notExistsFunc) }
12134
+ ];
12135
+ }
12136
+ var builtInCall = {
12137
+ name: "builtInCall",
12138
+ impl: ({ OR, SUBRULE, cache }) => () => {
12139
+ const cached = cache.get(builtInCall);
12140
+ if (cached) {
12141
+ return OR(cached);
12142
+ }
12143
+ const builtIns = builtInCallList(SUBRULE);
12144
+ cache.set(builtInCall, builtIns);
12145
+ return OR(builtIns);
12282
12146
  }
12283
12147
  };
12284
- var groupGraphPattern = {
12285
- name: "groupGraphPattern",
12286
- impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
12287
- const open = CONSUME(symbols_exports.LCurly);
12288
- const patterns = OR([
12289
- { ALT: () => [SUBRULE(subSelect, void 0)] },
12290
- { ALT: () => SUBRULE(groupGraphPatternSub, void 0) }
12148
+ var regexExpression = funcExpr2or3(BuiltInCalls_exports.regex);
12149
+ var substringExpression = funcExpr2or3(BuiltInCalls_exports.substr);
12150
+ var strReplaceExpression = funcExpr3or4(BuiltInCalls_exports.replace);
12151
+ var existsFunc = funcGroupGraphPattern(BuiltInCalls_exports.exists);
12152
+ var notExistsFunc = funcGroupGraphPattern(BuiltInCalls_exports.notexists);
12153
+ var aggregateCount = {
12154
+ name: unCapitalize(BuiltInCalls_exports.count.name),
12155
+ impl: ({ ACTION, CONSUME, SUBRULE, OR, OPTION }) => (C) => {
12156
+ const operatorToken = CONSUME(BuiltInCalls_exports.count);
12157
+ CONSUME(symbols_exports.LParen);
12158
+ const distinctToken = OPTION(() => CONSUME(distinct));
12159
+ const expressionVal = OR([
12160
+ { ALT: () => {
12161
+ const starToken = CONSUME(symbols_exports.star);
12162
+ return ACTION(() => C.factory.wildcard(C.factory.sourceLocation(starToken)));
12163
+ } },
12164
+ { ALT: () => SUBRULE(expression) }
12291
12165
  ]);
12292
- const close = CONSUME(symbols_exports.RCurly);
12293
- return ACTION(() => C.factory.patternGroup(patterns, C.factory.sourceLocation(open, close)));
12294
- },
12295
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12296
- F2.printFilter(ast, () => PRINT_WORD("{"));
12297
- for (const pattern of ast.patterns) {
12298
- SUBRULE(generatePattern, pattern, void 0);
12299
- }
12300
- F2.printFilter(ast, () => PRINT_WORD("}"));
12166
+ const closeToken = CONSUME(symbols_exports.RParen);
12167
+ return ACTION(() => {
12168
+ const F2 = C.factory;
12169
+ if (C.factory.isWildcard(expressionVal)) {
12170
+ return F2.aggregate(
12171
+ operatorToken.image,
12172
+ Boolean(distinctToken),
12173
+ expressionVal,
12174
+ void 0,
12175
+ C.factory.sourceLocation(operatorToken, closeToken)
12176
+ );
12177
+ }
12178
+ return F2.aggregate(
12179
+ operatorToken.image,
12180
+ Boolean(distinctToken),
12181
+ expressionVal,
12182
+ void 0,
12183
+ C.factory.sourceLocation(operatorToken, closeToken)
12184
+ );
12185
+ });
12301
12186
  }
12302
12187
  };
12303
- var generatePattern = {
12304
- name: "generatePattern",
12305
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12306
- if (ast.type === "query") {
12307
- SUBRULE(query, F2.querySelect({
12308
- context: [],
12309
- datasets: F2.datasetClauses([], F2.sourceLocation()),
12310
- where: ast.where,
12311
- variables: ast.variables,
12312
- solutionModifiers: ast.solutionModifiers,
12313
- values: ast.values,
12314
- distinct: ast.distinct,
12315
- reduced: ast.reduced
12316
- }, ast.loc), void 0);
12317
- } else if (ast.subType === "group") {
12318
- SUBRULE(groupGraphPattern, ast, void 0);
12319
- } else if (ast.subType === "bgp") {
12320
- SUBRULE(triplesBlock, ast, void 0);
12321
- } else {
12322
- SUBRULE(graphPatternNotTriples, ast, void 0);
12323
- }
12188
+ var aggregateSum = baseAggregateFunc(BuiltInCalls_exports.sum);
12189
+ var aggregateMin = baseAggregateFunc(BuiltInCalls_exports.min);
12190
+ var aggregateMax = baseAggregateFunc(BuiltInCalls_exports.max);
12191
+ var aggregateAvg = baseAggregateFunc(BuiltInCalls_exports.avg);
12192
+ var aggregateSample = baseAggregateFunc(BuiltInCalls_exports.sample);
12193
+ var aggregateGroup_concat = {
12194
+ name: unCapitalize(BuiltInCalls_exports.groupConcat.name),
12195
+ impl: ({ ACTION, CONSUME, OPTION1, SUBRULE, OPTION2 }) => (C) => {
12196
+ const operatorToken = CONSUME(BuiltInCalls_exports.groupConcat);
12197
+ CONSUME(symbols_exports.LParen);
12198
+ const distinctToken = OPTION1(() => CONSUME(distinct));
12199
+ const expr = SUBRULE(expression);
12200
+ const sep = OPTION2(() => {
12201
+ CONSUME(symbols_exports.semi);
12202
+ CONSUME(separator);
12203
+ CONSUME(symbols_exports.equal);
12204
+ return SUBRULE(string);
12205
+ });
12206
+ const closeToken = CONSUME(symbols_exports.RParen);
12207
+ return ACTION(() => {
12208
+ const F2 = C.factory;
12209
+ return F2.aggregate(
12210
+ operatorToken.image,
12211
+ Boolean(distinctToken),
12212
+ expr,
12213
+ sep?.value ?? " ",
12214
+ F2.sourceLocation(operatorToken, closeToken)
12215
+ );
12216
+ });
12324
12217
  }
12325
12218
  };
12326
- var groupGraphPatternSub = {
12327
- name: "groupGraphPatternSub",
12328
- impl: ({ ACTION, SUBRULE, CONSUME, MANY, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OPTION3 }) => () => {
12329
- const patterns = [];
12330
- const bgpPattern = OPTION1(() => SUBRULE1(triplesBlock, void 0));
12331
- if (bgpPattern) {
12332
- patterns.push(bgpPattern);
12333
- }
12334
- MANY(() => {
12335
- const notTriples = SUBRULE(graphPatternNotTriples, void 0);
12336
- patterns.push(notTriples);
12337
- OPTION2(() => CONSUME(symbols_exports.dot));
12338
- const moreTriples = OPTION3(() => SUBRULE2(triplesBlock, void 0));
12339
- if (moreTriples) {
12340
- patterns.push(moreTriples);
12219
+ var aggregate = {
12220
+ name: "aggregate",
12221
+ impl: ({ ACTION, SUBRULE, OR }) => (C) => {
12222
+ const wasInAggregate = ACTION(() => C.parseMode.has("inAggregate"));
12223
+ ACTION(() => C.parseMode.add("inAggregate"));
12224
+ const result = OR([
12225
+ { ALT: () => SUBRULE(aggregateCount) },
12226
+ { ALT: () => SUBRULE(aggregateSum) },
12227
+ { ALT: () => SUBRULE(aggregateMin) },
12228
+ { ALT: () => SUBRULE(aggregateMax) },
12229
+ { ALT: () => SUBRULE(aggregateAvg) },
12230
+ { ALT: () => SUBRULE(aggregateSample) },
12231
+ { ALT: () => SUBRULE(aggregateGroup_concat) }
12232
+ ]);
12233
+ ACTION(() => !wasInAggregate && C.parseMode.delete("inAggregate"));
12234
+ ACTION(() => {
12235
+ if (!C.parseMode.has("canParseAggregate")) {
12236
+ throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");
12237
+ }
12238
+ if (C.parseMode.has("inAggregate")) {
12239
+ throw new Error("An aggregate function is not allowed within an aggregate function.");
12341
12240
  }
12342
12241
  });
12343
- ACTION(() => checkNote13(patterns));
12344
- return patterns;
12242
+ return result;
12243
+ },
12244
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12245
+ F2.printFilter(ast, () => {
12246
+ PRINT_WORD(ast.aggregation, "(");
12247
+ if (ast.distinct) {
12248
+ PRINT_WORD("DISTINCT");
12249
+ }
12250
+ });
12251
+ const arg = ast.expression[0];
12252
+ if (F2.isWildcard(arg)) {
12253
+ F2.printFilter(ast, () => PRINT_WORD("*"));
12254
+ } else {
12255
+ SUBRULE(expression, arg);
12256
+ }
12257
+ if (F2.isExpressionAggregateSeparator(ast)) {
12258
+ F2.printFilter(ast, () => PRINT_WORD(";", "SEPARATOR", "=", stringEscapedLexical(ast.separator)));
12259
+ }
12260
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12345
12261
  }
12346
12262
  };
12347
- var graphPatternNotTriples = {
12348
- name: "graphPatternNotTriples",
12349
- impl: ({ SUBRULE, OR }) => () => OR([
12350
- { ALT: () => SUBRULE(groupOrUnionGraphPattern, void 0) },
12351
- { ALT: () => SUBRULE(optionalGraphPattern, void 0) },
12352
- { ALT: () => SUBRULE(minusGraphPattern, void 0) },
12353
- { ALT: () => SUBRULE(graphGraphPattern, void 0) },
12354
- { ALT: () => SUBRULE(serviceGraphPattern, void 0) },
12355
- { ALT: () => SUBRULE(filter3, void 0) },
12356
- { ALT: () => SUBRULE(bind2, void 0) },
12357
- { ALT: () => SUBRULE(inlineData, void 0) }
12358
- ]),
12359
- gImpl: ({ SUBRULE }) => (ast) => {
12360
- switch (ast.subType) {
12361
- case "group":
12362
- case "union":
12363
- SUBRULE(groupOrUnionGraphPattern, ast, void 0);
12364
- break;
12365
- case "optional":
12366
- SUBRULE(optionalGraphPattern, ast, void 0);
12367
- break;
12368
- case "minus":
12369
- SUBRULE(minusGraphPattern, ast, void 0);
12370
- break;
12371
- case "graph":
12372
- SUBRULE(graphGraphPattern, ast, void 0);
12373
- break;
12374
- case "service":
12375
- SUBRULE(serviceGraphPattern, ast, void 0);
12376
- break;
12377
- case "filter":
12378
- SUBRULE(filter3, ast, void 0);
12379
- break;
12380
- case "bind":
12381
- SUBRULE(bind2, ast, void 0);
12382
- break;
12383
- case "values":
12384
- SUBRULE(inlineData, ast, void 0);
12385
- break;
12386
- }
12387
- }
12388
- };
12389
- var optionalGraphPattern = {
12390
- name: "optionalGraphPattern",
12391
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12392
- const optional2 = CONSUME(optional);
12393
- const group = SUBRULE(groupGraphPattern, void 0);
12394
- return ACTION(() => C.factory.patternOptional(group.patterns, C.factory.sourceLocation(optional2, group)));
12395
- },
12396
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12397
- F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
12398
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12399
- }
12400
- };
12401
- var graphGraphPattern = {
12402
- name: "graphGraphPattern",
12403
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12404
- const graph2 = CONSUME(graph_exports.graph);
12405
- const name = SUBRULE(varOrIri, void 0);
12406
- const group = SUBRULE(groupGraphPattern, void 0);
12407
- return ACTION(() => C.factory.patternGraph(name, group.patterns, C.factory.sourceLocation(graph2, group)));
12408
- },
12409
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12410
- F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
12411
- SUBRULE(varOrTerm, ast.name, void 0);
12412
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12413
- }
12414
- };
12415
- var serviceGraphPattern = {
12416
- name: "serviceGraphPattern",
12417
- impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
12418
- const service2 = CONSUME(service);
12419
- const silent2 = OPTION(() => {
12420
- CONSUME(silent);
12421
- return true;
12422
- }) ?? false;
12423
- const name = SUBRULE1(varOrIri, void 0);
12424
- const group = SUBRULE1(groupGraphPattern, void 0);
12425
- return ACTION(() => C.factory.patternService(name, group.patterns, silent2, C.factory.sourceLocation(service2, group)));
12426
- },
12427
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12428
- F2.printFilter(ast, () => {
12429
- PRINT_WORD("SERVICE");
12430
- if (ast.silent) {
12431
- PRINT_WORD("SILENT");
12432
- }
12433
- });
12434
- SUBRULE(varOrTerm, ast.name, void 0);
12435
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12436
- }
12437
- };
12438
- var bind2 = {
12439
- name: "bind",
12440
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12441
- const bind3 = CONSUME(bind);
12442
- CONSUME(symbols_exports.LParen);
12443
- const expressionVal = SUBRULE(expression, void 0);
12444
- CONSUME(as);
12445
- const variable = SUBRULE(var_, void 0);
12446
- const close = CONSUME(symbols_exports.RParen);
12447
- return ACTION(() => C.factory.patternBind(expressionVal, variable, C.factory.sourceLocation(bind3, close)));
12448
- },
12449
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12450
- F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12451
- SUBRULE(expression, ast.expression, void 0);
12452
- F2.printFilter(ast, () => PRINT_WORD("AS"));
12453
- SUBRULE(var_, ast.variable, void 0);
12454
- F2.printFilter(ast, () => PRINT_WORD(")"));
12455
- }
12263
+
12264
+ // lib/grammar/propertyPaths.ts
12265
+ var path = {
12266
+ name: "path",
12267
+ impl: ({ SUBRULE }) => () => SUBRULE(pathAlternative)
12456
12268
  };
12457
- var inlineData = {
12458
- name: "inlineData",
12459
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12460
- const values3 = CONSUME(values2);
12461
- const datablock = SUBRULE(dataBlock, void 0);
12462
- return ACTION(() => C.factory.patternValues(datablock.val, C.factory.sourceLocation(values3, datablock)));
12463
- },
12464
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12465
- const variables = Object.keys(ast.values[0]);
12466
- F2.printFilter(ast, () => {
12467
- PRINT_WORD("VALUES", "(");
12468
- for (const variable of variables) {
12469
- PRINT_WORD(`?${variable}`);
12470
- }
12471
- PRINT_WORD(")", "{");
12472
- });
12473
- for (const mapping of ast.values) {
12474
- F2.printFilter(ast, () => PRINT_WORD("("));
12475
- for (const variable of variables) {
12476
- if (mapping[variable] === void 0) {
12477
- F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
12478
- } else {
12479
- SUBRULE(graphNodePath, mapping[variable], void 0);
12269
+ var pathGenerator = {
12270
+ name: "path",
12271
+ gImpl: ({ PRINT, SUBRULE }) => (ast, { factory: F2 }, braces = true) => {
12272
+ if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
12273
+ SUBRULE(iri2, ast);
12274
+ } else {
12275
+ F2.printFilter(ast, () => braces && PRINT("("));
12276
+ switch (ast.subType) {
12277
+ case "|":
12278
+ case "/": {
12279
+ const [head2, ...tail] = ast.items;
12280
+ SUBRULE(pathGenerator, head2, braces);
12281
+ for (const val of tail) {
12282
+ F2.printFilter(ast, () => PRINT(ast.subType));
12283
+ SUBRULE(pathGenerator, val, braces);
12284
+ }
12285
+ break;
12480
12286
  }
12287
+ case "^":
12288
+ F2.printFilter(ast, () => PRINT("^"));
12289
+ SUBRULE(pathGenerator, ast.items[0], braces);
12290
+ break;
12291
+ case "?":
12292
+ case "*":
12293
+ case "+":
12294
+ SUBRULE(pathGenerator, ast.items[0], braces);
12295
+ F2.printFilter(ast, () => PRINT(ast.subType));
12296
+ break;
12297
+ case "!":
12298
+ F2.printFilter(ast, () => PRINT("!"));
12299
+ F2.printFilter(ast, () => PRINT("("));
12300
+ SUBRULE(pathGenerator, ast.items[0], false);
12301
+ F2.printFilter(ast, () => PRINT(")"));
12302
+ break;
12481
12303
  }
12482
- F2.printFilter(ast, () => PRINT_WORD(")"));
12304
+ F2.printFilter(ast, () => braces && PRINT(")"));
12483
12305
  }
12484
- F2.printFilter(ast, () => PRINT_WORD("}"));
12485
12306
  }
12486
12307
  };
12487
- var dataBlock = {
12488
- name: "dataBlock",
12489
- impl: ({ SUBRULE, OR }) => () => OR([
12490
- { ALT: () => SUBRULE(inlineDataOneVar, void 0) },
12491
- { ALT: () => SUBRULE(inlineDataFull, void 0) }
12308
+ function pathChainHelper(name, SEP, subType, subRule) {
12309
+ return {
12310
+ name,
12311
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, MANY }) => (C) => {
12312
+ const head2 = SUBRULE1(subRule);
12313
+ let tailEnd = head2;
12314
+ const tail = [];
12315
+ MANY(() => {
12316
+ CONSUME(SEP);
12317
+ tailEnd = SUBRULE2(subRule);
12318
+ tail.push(tailEnd);
12319
+ });
12320
+ return ACTION(() => tail.length === 0 ? head2 : C.factory.path(subType, [head2, ...tail], C.factory.sourceLocation(head2, tailEnd)));
12321
+ }
12322
+ };
12323
+ }
12324
+ var pathEltOrInverse = {
12325
+ name: "pathEltOrInverse",
12326
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR }) => (C) => OR([
12327
+ { ALT: () => SUBRULE1(pathElt) },
12328
+ { ALT: () => {
12329
+ const hat2 = CONSUME(symbols_exports.hat);
12330
+ const item = SUBRULE2(pathElt);
12331
+ return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12332
+ } }
12492
12333
  ])
12493
12334
  };
12494
- var inlineDataOneVar = {
12495
- name: "inlineDataOneVar",
12496
- impl: ({ ACTION, SUBRULE, CONSUME, MANY }) => (C) => {
12497
- const res = [];
12498
- const varVal = SUBRULE(var_, void 0);
12499
- CONSUME(symbols_exports.LCurly);
12500
- MANY(() => {
12501
- const value = SUBRULE(dataBlockValue, void 0);
12502
- ACTION(() => {
12503
- res.push({ [varVal.value]: value });
12504
- });
12505
- });
12506
- const close = CONSUME(symbols_exports.RCurly);
12507
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(varVal, close)));
12335
+ var pathSequence = pathChainHelper("pathSequence", symbols_exports.slash, "/", pathEltOrInverse);
12336
+ var pathAlternative = pathChainHelper("pathAlternative", symbols_exports.pipe, "|", pathSequence);
12337
+ var pathElt = {
12338
+ name: "pathElt",
12339
+ impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
12340
+ const item = SUBRULE(pathPrimary);
12341
+ const modification = OPTION(() => SUBRULE(pathMod));
12342
+ return ACTION(() => modification === void 0 ? item : C.factory.path(modification.image, [item], C.factory.sourceLocation(item, modification)));
12508
12343
  }
12509
12344
  };
12510
- var inlineDataFull = {
12511
- name: "inlineDataFull",
12512
- impl: ({
12513
- ACTION,
12514
- OR,
12515
- MANY1,
12516
- MANY2,
12517
- MANY3,
12518
- MANY4,
12519
- SUBRULE,
12520
- CONSUME1,
12521
- CONSUME2
12522
- }) => (C) => {
12523
- const res = [];
12524
- const vars = [];
12525
- return OR([
12526
- { ALT: () => {
12527
- const nil2 = CONSUME1(terminals_exports.nil);
12528
- CONSUME1(symbols_exports.LCurly);
12529
- MANY1(() => {
12530
- CONSUME2(terminals_exports.nil);
12531
- res.push({});
12532
- });
12533
- const close = CONSUME1(symbols_exports.RCurly);
12534
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(nil2, close)));
12535
- } },
12536
- { ALT: () => {
12537
- const open = CONSUME1(symbols_exports.LParen);
12538
- MANY2(() => {
12539
- vars.push(SUBRULE(var_, void 0));
12540
- });
12541
- CONSUME1(symbols_exports.RParen);
12542
- CONSUME2(symbols_exports.LCurly);
12543
- MANY3(() => {
12544
- let parsedValues = 0;
12545
- const currentRow = {};
12546
- CONSUME2(symbols_exports.LParen);
12547
- MANY4(() => {
12548
- if (parsedValues >= vars.length) {
12549
- throw new Error("Number of dataBlockValues does not match number of variables. Too much values.");
12550
- }
12551
- const value = SUBRULE(dataBlockValue, void 0);
12552
- ACTION(() => {
12553
- currentRow[vars[parsedValues].value] = value;
12554
- parsedValues++;
12555
- });
12556
- });
12557
- CONSUME2(symbols_exports.RParen);
12558
- ACTION(() => {
12559
- res.push(currentRow);
12560
- if (vars.length !== parsedValues) {
12561
- throw new Error("Number of dataBlockValues does not match number of variables. Too few values.");
12562
- }
12563
- });
12564
- });
12565
- const close = CONSUME2(symbols_exports.RCurly);
12566
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(open, close)));
12567
- } }
12568
- ]);
12569
- }
12345
+ var pathMod = {
12346
+ name: "pathMod",
12347
+ impl: ({ CONSUME, OR }) => () => OR([
12348
+ { ALT: () => CONSUME(symbols_exports.question) },
12349
+ { ALT: () => CONSUME(symbols_exports.star) },
12350
+ { ALT: () => CONSUME(symbols_exports.opPlus) }
12351
+ ])
12570
12352
  };
12571
- var dataBlockValue = {
12572
- name: "dataBlockValue",
12353
+ var pathPrimary = {
12354
+ name: "pathPrimary",
12573
12355
  impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
12574
- { ALT: () => SUBRULE(iri2, void 0) },
12575
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
12576
- { ALT: () => SUBRULE(numericLiteral, void 0) },
12577
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
12356
+ { ALT: () => SUBRULE(iri2) },
12357
+ { ALT: () => SUBRULE(verbA) },
12358
+ { ALT: () => SUBRULE(pathNegatedPropertySet) },
12578
12359
  { ALT: () => {
12579
- CONSUME(undef);
12580
- return void 0;
12360
+ CONSUME(symbols_exports.LParen);
12361
+ const resRecursive = SUBRULE(path);
12362
+ CONSUME(symbols_exports.RParen);
12363
+ return resRecursive;
12581
12364
  } }
12582
12365
  ])
12583
12366
  };
12584
- var minusGraphPattern = {
12585
- name: "minusGraphPattern",
12586
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12587
- const minus2 = CONSUME(minus);
12588
- const group = SUBRULE(groupGraphPattern, void 0);
12589
- return ACTION(() => C.factory.patternMinus(group.patterns, C.factory.sourceLocation(minus2, group)));
12590
- },
12591
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12592
- F2.printFilter(ast, () => PRINT_WORD("MINUS"));
12593
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12367
+ var pathNegatedPropertySet = {
12368
+ name: "pathNegatedPropertySet",
12369
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, OR, MANY }) => (C) => {
12370
+ const exclamation2 = CONSUME(symbols_exports.exclamation);
12371
+ return OR([
12372
+ { ALT: () => {
12373
+ const noAlternative = SUBRULE1(pathOneInPropertySet);
12374
+ return ACTION(() => C.factory.path("!", [noAlternative], C.factory.sourceLocation(exclamation2, noAlternative)));
12375
+ } },
12376
+ { ALT: () => {
12377
+ const open = CONSUME(symbols_exports.LParen);
12378
+ const head2 = SUBRULE2(pathOneInPropertySet);
12379
+ const tail = [];
12380
+ MANY(() => {
12381
+ CONSUME(symbols_exports.pipe);
12382
+ const item = SUBRULE3(pathOneInPropertySet);
12383
+ tail.push(item);
12384
+ });
12385
+ const close = CONSUME(symbols_exports.RParen);
12386
+ return ACTION(() => {
12387
+ const F2 = C.factory;
12388
+ if (tail.length === 0) {
12389
+ return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
12390
+ }
12391
+ return F2.path(
12392
+ "!",
12393
+ [F2.path("|", [head2, ...tail], F2.sourceLocation(open, close))],
12394
+ F2.sourceLocation(exclamation2, close)
12395
+ );
12396
+ });
12397
+ } }
12398
+ ]);
12594
12399
  }
12595
12400
  };
12596
- var groupOrUnionGraphPattern = {
12597
- name: "groupOrUnionGraphPattern",
12598
- impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => {
12599
- const groups = [];
12600
- const group = SUBRULE1(groupGraphPattern, void 0);
12601
- groups.push(group);
12602
- MANY(() => {
12603
- CONSUME(union);
12604
- const group2 = SUBRULE2(groupGraphPattern, void 0);
12605
- groups.push(group2);
12606
- });
12607
- return ACTION(() => groups.length === 1 ? groups[0] : C.factory.patternUnion(
12608
- groups,
12609
- C.factory.sourceLocation(group, groups.at(-1))
12610
- ));
12611
- },
12612
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12613
- if (F2.isPatternUnion(ast)) {
12614
- const [head2, ...tail] = ast.patterns;
12615
- SUBRULE(groupGraphPattern, head2, void 0);
12616
- for (const pattern of tail) {
12617
- F2.printFilter(ast, () => PRINT_WORD("UNION"));
12618
- SUBRULE(groupGraphPattern, pattern, void 0);
12401
+ var pathOneInPropertySet = {
12402
+ name: "pathOneInPropertySet",
12403
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
12404
+ { ALT: () => SUBRULE1(iri2) },
12405
+ { ALT: () => SUBRULE1(verbA) },
12406
+ { ALT: () => {
12407
+ const hat2 = CONSUME(symbols_exports.hat);
12408
+ const item = OR2([
12409
+ { ALT: () => SUBRULE2(iri2) },
12410
+ { ALT: () => SUBRULE2(verbA) }
12411
+ ]);
12412
+ return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12413
+ } }
12414
+ ])
12415
+ };
12416
+
12417
+ // lib/grammar/tripleBlock.ts
12418
+ function triplesDotSeperated(triplesSameSubjectSubrule) {
12419
+ return ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME, OPTION }) => (C) => {
12420
+ const triples = [];
12421
+ let parsedDot = true;
12422
+ let dotToken;
12423
+ AT_LEAST_ONE({
12424
+ GATE: () => parsedDot,
12425
+ DEF: () => {
12426
+ parsedDot = false;
12427
+ const template = SUBRULE(triplesSameSubjectSubrule);
12428
+ ACTION(() => {
12429
+ triples.push(...template);
12430
+ });
12431
+ OPTION(() => {
12432
+ dotToken = CONSUME(symbols_exports.dot);
12433
+ parsedDot = true;
12434
+ });
12619
12435
  }
12620
- } else {
12621
- SUBRULE(groupGraphPattern, ast, void 0);
12436
+ });
12437
+ return ACTION(() => C.factory.patternBgp(triples, C.factory.sourceLocation(...triples, dotToken)));
12438
+ };
12439
+ }
12440
+ var triplesBlock = {
12441
+ name: "triplesBlock",
12442
+ impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
12443
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12444
+ for (const [index, triple] of ast.triples.entries()) {
12445
+ HANDLE_LOC(triple, () => {
12446
+ const nextTriple = ast.triples.at(index);
12447
+ if (F2.isTripleCollection(triple)) {
12448
+ SUBRULE(graphNodePath, triple);
12449
+ F2.printFilter(triple, () => PRINT_WORD("."));
12450
+ } else {
12451
+ SUBRULE(graphNodePath, triple.subject);
12452
+ if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12453
+ SUBRULE(varOrTerm, triple.predicate);
12454
+ } else {
12455
+ SUBRULE(pathGenerator, triple.predicate, void 0);
12456
+ }
12457
+ SUBRULE(graphNodePath, triple.object);
12458
+ if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12459
+ F2.printFilter(ast, () => PRINT_WORD("."));
12460
+ } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12461
+ F2.printFilter(ast, () => PRINT_WORD(","));
12462
+ } else {
12463
+ F2.printFilter(ast, () => PRINT_WORD(";"));
12464
+ }
12465
+ }
12466
+ });
12622
12467
  }
12623
12468
  }
12624
12469
  };
12625
- var filter3 = {
12626
- name: "filter",
12627
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12628
- const filterToken = CONSUME(filter2);
12629
- const expression2 = SUBRULE(constraint, void 0);
12630
- return ACTION(() => C.factory.patternFilter(expression2, C.factory.sourceLocation(filterToken, expression2)));
12631
- },
12632
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12633
- F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
12634
- SUBRULE(expression, ast.expression, void 0);
12635
- F2.printFilter(ast, () => PRINT_WORD(")"));
12636
- }
12637
- };
12638
- var constraint = {
12639
- name: "constraint",
12640
- impl: ({ SUBRULE, OR }) => () => OR([
12641
- { ALT: () => SUBRULE(brackettedExpression, void 0) },
12642
- { ALT: () => SUBRULE(builtInCall, void 0) },
12643
- { ALT: () => SUBRULE(functionCall, void 0) }
12644
- ])
12645
- };
12646
- var functionCall = {
12647
- name: "functionCall",
12648
- impl: ({ ACTION, SUBRULE }) => (C) => {
12649
- const func = SUBRULE(iri2, void 0);
12650
- const args = SUBRULE(argList, void 0);
12651
- return ACTION(() => C.factory.expressionFunctionCall(
12652
- func,
12653
- args.val.args,
12654
- args.val.distinct,
12655
- C.factory.sourceLocation(func, args)
12656
- ));
12657
- }
12470
+ function triplesSameSubjectImpl(name, allowPaths) {
12471
+ return {
12472
+ name,
12473
+ impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
12474
+ { ALT: () => {
12475
+ const subject = SUBRULE(varOrTerm);
12476
+ const res = SUBRULE(
12477
+ allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty,
12478
+ ACTION(() => C.factory.dematerialized(subject))
12479
+ );
12480
+ return ACTION(() => {
12481
+ if (res.length > 0) {
12482
+ res[0].subject = subject;
12483
+ res[0].loc = C.factory.sourceLocation(subject, res[0]);
12484
+ }
12485
+ return res;
12486
+ });
12487
+ } },
12488
+ { ALT: () => {
12489
+ const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode);
12490
+ const restNode = SUBRULE(
12491
+ allowPaths ? propertyListPath : propertyList,
12492
+ ACTION(() => C.factory.graphNodeIdentifier(subjectNode))
12493
+ );
12494
+ return ACTION(() => {
12495
+ if (restNode.length === 0) {
12496
+ return [subjectNode];
12497
+ }
12498
+ restNode[0].subject = subjectNode;
12499
+ restNode[0].loc = C.factory.sourceLocation(subjectNode, restNode[0]);
12500
+ return restNode;
12501
+ });
12502
+ } }
12503
+ ])
12504
+ };
12505
+ }
12506
+ var triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
12507
+ var triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
12508
+ var triplesTemplate = {
12509
+ name: "triplesTemplate",
12510
+ impl: triplesDotSeperated(triplesSameSubject)
12658
12511
  };
12659
-
12660
- // lib/expressionHelpers.ts
12661
- function funcExpr1(func) {
12512
+ function propertyListImpl(name, allowPaths) {
12662
12513
  return {
12663
- name: unCapitalize(func.name),
12664
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12665
- const operator = CONSUME(func);
12666
- CONSUME(symbols_exports.LParen);
12667
- const arg = SUBRULE(expression, void 0);
12668
- const close = CONSUME(symbols_exports.RParen);
12669
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12670
- }
12514
+ name,
12515
+ impl: ({ SUBRULE, OPTION }) => (_, subject) => OPTION(() => SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, subject)) ?? []
12671
12516
  };
12672
12517
  }
12673
- function funcExpr2(func) {
12518
+ var propertyList = propertyListImpl("propertyList", false);
12519
+ var propertyListPath = propertyListImpl("propertyListPath", true);
12520
+ function propertyListNotEmptyImplementation(name, allowPaths) {
12674
12521
  return {
12675
- name: unCapitalize(func.name),
12676
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {
12677
- const operator = CONSUME(func);
12678
- CONSUME(symbols_exports.LParen);
12679
- const arg1 = SUBRULE1(expression, void 0);
12680
- CONSUME(symbols_exports.comma);
12681
- const arg2 = SUBRULE2(expression, void 0);
12682
- const close = CONSUME(symbols_exports.RParen);
12683
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2], C.factory.sourceLocation(operator, close)));
12522
+ name,
12523
+ impl: ({ ACTION, CONSUME, AT_LEAST_ONE, SUBRULE1, MANY2, OR1 }) => (_, subject) => {
12524
+ const result = [];
12525
+ let parsedSemi = true;
12526
+ AT_LEAST_ONE({
12527
+ GATE: () => parsedSemi,
12528
+ DEF: () => {
12529
+ parsedSemi = false;
12530
+ const predicate = allowPaths ? OR1([
12531
+ { ALT: () => SUBRULE1(verbPath) },
12532
+ { ALT: () => SUBRULE1(verbSimple) }
12533
+ ]) : SUBRULE1(verb);
12534
+ const triples = SUBRULE1(
12535
+ allowPaths ? objectListPath : objectList,
12536
+ subject,
12537
+ predicate
12538
+ );
12539
+ MANY2(() => {
12540
+ CONSUME(symbols_exports.semi);
12541
+ parsedSemi = true;
12542
+ });
12543
+ ACTION(() => {
12544
+ result.push(...triples);
12545
+ });
12546
+ }
12547
+ });
12548
+ return result;
12684
12549
  }
12685
12550
  };
12686
12551
  }
12687
- function funcExpr3(func) {
12552
+ var propertyListNotEmpty = propertyListNotEmptyImplementation("propertyListNotEmpty", false);
12553
+ var propertyListPathNotEmpty = propertyListNotEmptyImplementation("propertyListPathNotEmpty", true);
12554
+ var verbPath = {
12555
+ name: "verbPath",
12556
+ impl: ({ SUBRULE }) => () => SUBRULE(path)
12557
+ };
12558
+ var verbSimple = {
12559
+ name: "verbSimple",
12560
+ impl: ({ SUBRULE }) => () => SUBRULE(var_)
12561
+ };
12562
+ function objectListImpl(name, allowPaths) {
12688
12563
  return {
12689
- name: unCapitalize(func.name),
12690
- impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {
12691
- const operator = CONSUME(func);
12692
- CONSUME(symbols_exports.LParen);
12693
- const arg1 = SUBRULE1(expression, void 0);
12694
- CONSUME1(symbols_exports.comma);
12695
- const arg2 = SUBRULE2(expression, void 0);
12696
- CONSUME2(symbols_exports.comma);
12697
- const arg3 = SUBRULE3(expression, void 0);
12698
- const close = CONSUME(symbols_exports.RParen);
12699
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
12564
+ name,
12565
+ impl: ({ ACTION, SUBRULE, AT_LEAST_ONE_SEP }) => (_, subj, pred) => {
12566
+ const objects = [];
12567
+ AT_LEAST_ONE_SEP({
12568
+ SEP: symbols_exports.comma,
12569
+ DEF: () => {
12570
+ const objectTriple = SUBRULE(allowPaths ? objectPath : object, subj, pred);
12571
+ ACTION(() => {
12572
+ objects.push(objectTriple);
12573
+ });
12574
+ }
12575
+ });
12576
+ return objects;
12700
12577
  }
12701
12578
  };
12702
12579
  }
12703
- function funcVar1(func) {
12580
+ var objectList = objectListImpl("objectList", false);
12581
+ var objectListPath = objectListImpl("objectListPath", true);
12582
+ function objectImpl(name, allowPaths) {
12704
12583
  return {
12705
- name: unCapitalize(func.name),
12706
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12707
- const operator = CONSUME(func);
12708
- CONSUME(symbols_exports.LParen);
12709
- const arg = SUBRULE(var_, void 0);
12710
- const close = CONSUME(symbols_exports.RParen);
12711
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12584
+ name,
12585
+ impl: ({ ACTION, SUBRULE }) => (C, subject, predicate) => {
12586
+ const node = SUBRULE(allowPaths ? graphNodePath : graphNode);
12587
+ return ACTION(() => C.factory.triple(subject, predicate, node));
12712
12588
  }
12713
12589
  };
12714
12590
  }
12715
- function funcExprOrNil1(func) {
12716
- return {
12717
- name: unCapitalize(func.name),
12718
- impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
12719
- const operator = CONSUME(func);
12720
- return OR([
12721
- { ALT: () => {
12722
- CONSUME(symbols_exports.LParen);
12723
- const arg = SUBRULE(expression, void 0);
12724
- const close = CONSUME(symbols_exports.RParen);
12725
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12726
- } },
12727
- { ALT: () => {
12728
- const nil2 = CONSUME(terminals_exports.nil);
12729
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12730
- } }
12731
- ]);
12732
- }
12733
- };
12734
- }
12735
- function funcNil1(func) {
12736
- return {
12737
- name: unCapitalize(func.name),
12738
- impl: ({ ACTION, CONSUME }) => (C) => {
12739
- const operator = CONSUME(func);
12740
- const nil2 = CONSUME(terminals_exports.nil);
12741
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12742
- }
12743
- };
12744
- }
12745
- function funcExprList1(func) {
12746
- return {
12747
- name: unCapitalize(func.name),
12748
- impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
12749
- const operator = CONSUME(func);
12750
- const args = SUBRULE(expressionList, void 0);
12751
- return ACTION(() => C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));
12752
- }
12753
- };
12754
- }
12755
- function funcExpr2or3(func) {
12591
+ var object = objectImpl("object", false);
12592
+ var objectPath = objectImpl("objectPath", true);
12593
+ function collectionImpl(name, allowPaths) {
12756
12594
  return {
12757
- name: unCapitalize(func.name),
12758
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) => (C) => {
12759
- const operator = CONSUME(func);
12760
- CONSUME(symbols_exports.LParen);
12761
- const arg1 = SUBRULE1(expression, void 0);
12762
- CONSUME1(symbols_exports.comma);
12763
- const arg2 = SUBRULE2(expression, void 0);
12764
- const arg3 = OPTION(() => {
12765
- CONSUME2(symbols_exports.comma);
12766
- return SUBRULE3(expression, void 0);
12595
+ name,
12596
+ impl: ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME }) => (C) => {
12597
+ const terms = [];
12598
+ const startToken = CONSUME(symbols_exports.LParen);
12599
+ AT_LEAST_ONE(() => {
12600
+ terms.push(SUBRULE(allowPaths ? graphNodePath : graphNode));
12767
12601
  });
12768
- const close = CONSUME(symbols_exports.RParen);
12769
- return ACTION(() => C.factory.expressionOperation(
12770
- operator.image,
12771
- arg3 ? [arg1, arg2, arg3] : [arg1, arg2],
12772
- C.factory.sourceLocation(operator, close)
12773
- ));
12602
+ const endToken = CONSUME(symbols_exports.RParen);
12603
+ return ACTION(() => {
12604
+ const F2 = C.factory;
12605
+ const triples = [];
12606
+ const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" /* FIRST */, void 0);
12607
+ const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" /* REST */, void 0);
12608
+ const predNil = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */, void 0);
12609
+ const listHead = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12610
+ let iterHead = listHead;
12611
+ for (const [index, term] of terms.entries()) {
12612
+ const lastInList = index === terms.length - 1;
12613
+ const headTriple = F2.triple(
12614
+ iterHead,
12615
+ predFirst,
12616
+ term
12617
+ );
12618
+ triples.push(headTriple);
12619
+ if (lastInList) {
12620
+ const nilTriple = F2.triple(iterHead, predRest, predNil);
12621
+ triples.push(nilTriple);
12622
+ } else {
12623
+ const tail = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12624
+ const linkTriple = F2.triple(iterHead, predRest, tail);
12625
+ triples.push(linkTriple);
12626
+ iterHead = tail;
12627
+ }
12628
+ }
12629
+ return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
12630
+ });
12631
+ },
12632
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12633
+ F2.printFilter(ast, () => PRINT_WORD("("));
12634
+ for (const [idx, triple] of ast.triples.entries()) {
12635
+ if (idx % 2 === 0) {
12636
+ SUBRULE(allowPaths ? graphNodePath : graphNode, triple.object);
12637
+ }
12638
+ }
12639
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12774
12640
  }
12775
12641
  };
12776
12642
  }
12777
- function funcExpr3or4(func) {
12643
+ var collection = collectionImpl("collection", false);
12644
+ var collectionPath = collectionImpl("collectionPath", true);
12645
+ function triplesNodeImpl(name, allowPaths) {
12778
12646
  return {
12779
- name: unCapitalize(func.name),
12780
- impl: ({
12781
- ACTION,
12782
- CONSUME,
12783
- SUBRULE1,
12784
- SUBRULE2,
12785
- SUBRULE3,
12786
- SUBRULE4,
12787
- CONSUME1,
12788
- OPTION,
12789
- CONSUME2,
12790
- CONSUME3
12791
- }) => (C) => {
12792
- const operator = CONSUME(func);
12793
- CONSUME(symbols_exports.LParen);
12794
- const arg1 = SUBRULE1(expression, void 0);
12795
- CONSUME1(symbols_exports.comma);
12796
- const arg2 = SUBRULE2(expression, void 0);
12797
- CONSUME2(symbols_exports.comma);
12798
- const arg3 = SUBRULE3(expression, void 0);
12799
- const arg4 = OPTION(() => {
12800
- CONSUME3(symbols_exports.comma);
12801
- return SUBRULE4(expression, void 0);
12802
- });
12803
- const close = CONSUME(symbols_exports.RParen);
12804
- return ACTION(() => C.factory.expressionOperation(
12805
- operator.image,
12806
- arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3],
12807
- C.factory.sourceLocation(operator, close)
12808
- ));
12809
- }
12647
+ name,
12648
+ impl: ({ SUBRULE, OR }) => () => OR([
12649
+ { ALT: () => SUBRULE(allowPaths ? collectionPath : collection) },
12650
+ { ALT: () => SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList) }
12651
+ ]),
12652
+ gImpl: ({ SUBRULE }) => (ast) => ast.subType === "list" ? SUBRULE(allowPaths ? collectionPath : collection, ast) : SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, ast)
12810
12653
  };
12811
12654
  }
12812
- function funcGroupGraphPattern(func) {
12655
+ var triplesNode = triplesNodeImpl("triplesNode", false);
12656
+ var triplesNodePath = triplesNodeImpl("triplesNodePath", true);
12657
+ function blankNodePropertyListImpl(name, allowPaths) {
12658
+ const propertyPathNotEmptyImpl = allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty;
12813
12659
  return {
12814
- name: unCapitalize(func.name),
12660
+ name,
12815
12661
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12816
- const operator = CONSUME(func);
12817
- const group = SUBRULE(groupGraphPattern, void 0);
12818
- return ACTION(() => C.factory.expressionPatternOperation(
12819
- operator.image,
12820
- group,
12821
- C.factory.sourceLocation(operator, group)
12662
+ const startToken = CONSUME(symbols_exports.LSquare);
12663
+ const blankNode2 = ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocationNoMaterialize()));
12664
+ const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
12665
+ const endToken = CONSUME(symbols_exports.RSquare);
12666
+ return ACTION(() => C.factory.tripleCollectionBlankNodeProperties(
12667
+ blankNode2,
12668
+ propList,
12669
+ C.factory.sourceLocation(startToken, endToken)
12822
12670
  ));
12671
+ },
12672
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12673
+ F2.printFilter(ast, () => PRINT("["));
12674
+ for (const triple of ast.triples) {
12675
+ HANDLE_LOC(triple, () => {
12676
+ if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12677
+ SUBRULE(varOrTerm, triple.predicate);
12678
+ } else {
12679
+ SUBRULE(pathGenerator, triple.predicate, void 0);
12680
+ }
12681
+ SUBRULE(graphNodePath, triple.object);
12682
+ F2.printFilter(ast, () => PRINT_WORD(";"));
12683
+ });
12684
+ }
12685
+ F2.printFilter(ast, () => PRINT("]"));
12823
12686
  }
12824
12687
  };
12825
12688
  }
12826
- function baseAggregateFunc(func) {
12689
+ var blankNodePropertyList = blankNodePropertyListImpl("blankNodePropertyList", false);
12690
+ var blankNodePropertyListPath = blankNodePropertyListImpl("blankNodePropertyListPath", true);
12691
+ function graphNodeImpl(name, allowPaths) {
12692
+ const triplesNodeRule = allowPaths ? triplesNodePath : triplesNode;
12827
12693
  return {
12828
- name: unCapitalize(func.name),
12829
- impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
12830
- const operator = CONSUME(func);
12831
- CONSUME(symbols_exports.LParen);
12832
- const distinct2 = OPTION(() => CONSUME(distinct));
12833
- const expr1 = SUBRULE(expression, void 0);
12834
- const close = CONSUME(symbols_exports.RParen);
12835
- return ACTION(() => C.factory.aggregate(
12836
- operator.image,
12837
- distinct2 !== void 0,
12838
- expr1,
12839
- void 0,
12840
- C.factory.sourceLocation(operator, close)
12841
- ));
12694
+ name,
12695
+ impl: ({ SUBRULE, OR }) => (C) => OR([
12696
+ { ALT: () => SUBRULE(varOrTerm) },
12697
+ {
12698
+ GATE: () => C.parseMode.has("canCreateBlankNodes"),
12699
+ ALT: () => SUBRULE(triplesNodeRule)
12700
+ }
12701
+ ]),
12702
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12703
+ if (F2.isTerm(ast)) {
12704
+ SUBRULE(varOrTerm, ast);
12705
+ } else {
12706
+ SUBRULE(triplesNodeRule, ast);
12707
+ }
12842
12708
  }
12843
12709
  };
12844
12710
  }
12711
+ var graphNode = graphNodeImpl("graphNode", false);
12712
+ var graphNodePath = graphNodeImpl("graphNodePath", true);
12845
12713
 
12846
- // lib/grammar/builtIn.ts
12847
- var builtInStr = funcExpr1(BuildinCalls_exports.str);
12848
- var builtInLang = funcExpr1(BuildinCalls_exports.lang);
12849
- var builtInLangmatches = funcExpr2(BuildinCalls_exports.langmatches);
12850
- var builtInDatatype = funcExpr1(BuildinCalls_exports.datatype);
12851
- var builtInBound = funcVar1(BuildinCalls_exports.bound);
12852
- var builtInIri = funcExpr1(BuildinCalls_exports.iri);
12853
- var builtInUri = funcExpr1(BuildinCalls_exports.uri);
12854
- var builtInBnodeSparqlJs = funcExprOrNil1(BuildinCalls_exports.bnode);
12855
- var builtInRand = funcNil1(BuildinCalls_exports.rand);
12856
- var builtInAbs = funcExpr1(BuildinCalls_exports.abs);
12857
- var builtInCeil = funcExpr1(BuildinCalls_exports.ceil);
12858
- var builtInFloor = funcExpr1(BuildinCalls_exports.floor);
12859
- var builtInRound = funcExpr1(BuildinCalls_exports.round);
12860
- var builtInConcat = funcExprList1(BuildinCalls_exports.concat);
12861
- var builtInStrlen = funcExpr1(BuildinCalls_exports.strlen);
12862
- var builtInUcase = funcExpr1(BuildinCalls_exports.ucase);
12863
- var builtInLcase = funcExpr1(BuildinCalls_exports.lcase);
12864
- var builtInEncode_for_uri = funcExpr1(BuildinCalls_exports.encode_for_uri);
12865
- var builtInContains = funcExpr2(BuildinCalls_exports.contains);
12866
- var builtInStrstarts = funcExpr2(BuildinCalls_exports.strstarts);
12867
- var builtInStrends = funcExpr2(BuildinCalls_exports.strends);
12868
- var builtInStrbefore = funcExpr2(BuildinCalls_exports.strbefore);
12869
- var builtInStrafter = funcExpr2(BuildinCalls_exports.strafter);
12870
- var builtInYear = funcExpr1(BuildinCalls_exports.year);
12871
- var builtInMonth = funcExpr1(BuildinCalls_exports.month);
12872
- var builtInDay = funcExpr1(BuildinCalls_exports.day);
12873
- var builtInHours = funcExpr1(BuildinCalls_exports.hours);
12874
- var builtInMinutes = funcExpr1(BuildinCalls_exports.minutes);
12875
- var builtInSeconds = funcExpr1(BuildinCalls_exports.seconds);
12876
- var builtInTimezone = funcExpr1(BuildinCalls_exports.timezone);
12877
- var builtInTz = funcExpr1(BuildinCalls_exports.tz);
12878
- var builtInNow = funcNil1(BuildinCalls_exports.now);
12879
- var builtInUuid = funcNil1(BuildinCalls_exports.uuid);
12880
- var builtInStruuid = funcNil1(BuildinCalls_exports.struuid);
12881
- var builtInMd5 = funcExpr1(BuildinCalls_exports.md5);
12882
- var builtInSha1 = funcExpr1(BuildinCalls_exports.sha1);
12883
- var builtInSha256 = funcExpr1(BuildinCalls_exports.sha256);
12884
- var builtInSha384 = funcExpr1(BuildinCalls_exports.sha384);
12885
- var builtInSha512 = funcExpr1(BuildinCalls_exports.sha512);
12886
- var builtInCoalesce = funcExprList1(BuildinCalls_exports.coalesce);
12887
- var builtInIf = funcExpr3(BuildinCalls_exports.if_);
12888
- var builtInStrlang = funcExpr2(BuildinCalls_exports.strlang);
12889
- var builtInStrdt = funcExpr2(BuildinCalls_exports.strdt);
12890
- var builtInSameterm = funcExpr2(BuildinCalls_exports.sameterm);
12891
- var builtInIsiri = funcExpr1(BuildinCalls_exports.isiri);
12892
- var builtInIsuri = funcExpr1(BuildinCalls_exports.isuri);
12893
- var builtInIsblank = funcExpr1(BuildinCalls_exports.isblank);
12894
- var builtInIsliteral = funcExpr1(BuildinCalls_exports.isliteral);
12895
- var builtInIsnumeric = funcExpr1(BuildinCalls_exports.isnumeric);
12896
- function builtInCallList(SUBRULE) {
12897
- return [
12898
- { ALT: () => SUBRULE(aggregate, void 0) },
12899
- { ALT: () => SUBRULE(builtInStr, void 0) },
12900
- { ALT: () => SUBRULE(builtInLang, void 0) },
12901
- { ALT: () => SUBRULE(builtInLangmatches, void 0) },
12902
- { ALT: () => SUBRULE(builtInDatatype, void 0) },
12903
- { ALT: () => SUBRULE(builtInBound, void 0) },
12904
- { ALT: () => SUBRULE(builtInIri, void 0) },
12905
- { ALT: () => SUBRULE(builtInUri, void 0) },
12906
- { ALT: () => SUBRULE(builtInBnodeSparqlJs, void 0) },
12907
- { ALT: () => SUBRULE(builtInRand, void 0) },
12908
- { ALT: () => SUBRULE(builtInAbs, void 0) },
12909
- { ALT: () => SUBRULE(builtInCeil, void 0) },
12910
- { ALT: () => SUBRULE(builtInFloor, void 0) },
12911
- { ALT: () => SUBRULE(builtInRound, void 0) },
12912
- { ALT: () => SUBRULE(builtInConcat, void 0) },
12913
- { ALT: () => SUBRULE(substringExpression, void 0) },
12914
- { ALT: () => SUBRULE(builtInStrlen, void 0) },
12915
- { ALT: () => SUBRULE(strReplaceExpression, void 0) },
12916
- { ALT: () => SUBRULE(builtInUcase, void 0) },
12917
- { ALT: () => SUBRULE(builtInLcase, void 0) },
12918
- { ALT: () => SUBRULE(builtInEncode_for_uri, void 0) },
12919
- { ALT: () => SUBRULE(builtInContains, void 0) },
12920
- { ALT: () => SUBRULE(builtInStrstarts, void 0) },
12921
- { ALT: () => SUBRULE(builtInStrends, void 0) },
12922
- { ALT: () => SUBRULE(builtInStrbefore, void 0) },
12923
- { ALT: () => SUBRULE(builtInStrafter, void 0) },
12924
- { ALT: () => SUBRULE(builtInYear, void 0) },
12925
- { ALT: () => SUBRULE(builtInMonth, void 0) },
12926
- { ALT: () => SUBRULE(builtInDay, void 0) },
12927
- { ALT: () => SUBRULE(builtInHours, void 0) },
12928
- { ALT: () => SUBRULE(builtInMinutes, void 0) },
12929
- { ALT: () => SUBRULE(builtInSeconds, void 0) },
12930
- { ALT: () => SUBRULE(builtInTimezone, void 0) },
12931
- { ALT: () => SUBRULE(builtInTz, void 0) },
12932
- { ALT: () => SUBRULE(builtInNow, void 0) },
12933
- { ALT: () => SUBRULE(builtInUuid, void 0) },
12934
- { ALT: () => SUBRULE(builtInStruuid, void 0) },
12935
- { ALT: () => SUBRULE(builtInMd5, void 0) },
12936
- { ALT: () => SUBRULE(builtInSha1, void 0) },
12937
- { ALT: () => SUBRULE(builtInSha256, void 0) },
12938
- { ALT: () => SUBRULE(builtInSha384, void 0) },
12939
- { ALT: () => SUBRULE(builtInSha512, void 0) },
12940
- { ALT: () => SUBRULE(builtInCoalesce, void 0) },
12941
- { ALT: () => SUBRULE(builtInIf, void 0) },
12942
- { ALT: () => SUBRULE(builtInStrlang, void 0) },
12943
- { ALT: () => SUBRULE(builtInStrdt, void 0) },
12944
- { ALT: () => SUBRULE(builtInSameterm, void 0) },
12945
- { ALT: () => SUBRULE(builtInIsiri, void 0) },
12946
- { ALT: () => SUBRULE(builtInIsuri, void 0) },
12947
- { ALT: () => SUBRULE(builtInIsblank, void 0) },
12948
- { ALT: () => SUBRULE(builtInIsliteral, void 0) },
12949
- { ALT: () => SUBRULE(builtInIsnumeric, void 0) },
12950
- { ALT: () => SUBRULE(regexExpression, void 0) },
12951
- { ALT: () => SUBRULE(existsFunc, void 0) },
12952
- { ALT: () => SUBRULE(notExistsFunc, void 0) }
12953
- ];
12954
- }
12955
- var builtInCall = {
12956
- name: "builtInCall",
12957
- impl: ({ OR, SUBRULE, cache }) => () => {
12958
- const cached = cache.get(builtInCall);
12959
- if (cached) {
12960
- return OR(cached);
12714
+ // lib/grammar/whereClause.ts
12715
+ var whereClause = {
12716
+ name: "whereClause",
12717
+ impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
12718
+ const where2 = OPTION(() => CONSUME(where));
12719
+ const group = SUBRULE(groupGraphPattern);
12720
+ return ACTION(() => C.factory.wrap(group, C.factory.sourceLocation(where2, group)));
12721
+ },
12722
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12723
+ F2.printFilter(ast, () => PRINT_WORD("WHERE"));
12724
+ SUBRULE(groupGraphPattern, ast.val);
12725
+ }
12726
+ };
12727
+ var groupGraphPattern = {
12728
+ name: "groupGraphPattern",
12729
+ impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
12730
+ const open = CONSUME(symbols_exports.LCurly);
12731
+ const patterns = OR([
12732
+ { ALT: () => [SUBRULE(subSelect)] },
12733
+ { ALT: () => SUBRULE(groupGraphPatternSub) }
12734
+ ]);
12735
+ const close = CONSUME(symbols_exports.RCurly);
12736
+ return ACTION(() => C.factory.patternGroup(patterns, C.factory.sourceLocation(open, close)));
12737
+ },
12738
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12739
+ F2.printFilter(ast, () => PRINT_WORD("{"));
12740
+ for (const pattern of ast.patterns) {
12741
+ SUBRULE(generatePattern, pattern);
12742
+ }
12743
+ F2.printFilter(ast, () => PRINT_WORD("}"));
12744
+ }
12745
+ };
12746
+ var generatePattern = {
12747
+ name: "generatePattern",
12748
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12749
+ if (ast.type === "query") {
12750
+ SUBRULE(query, F2.querySelect({
12751
+ context: [],
12752
+ datasets: F2.datasetClauses([], F2.sourceLocation()),
12753
+ where: ast.where,
12754
+ variables: ast.variables,
12755
+ solutionModifiers: ast.solutionModifiers,
12756
+ values: ast.values,
12757
+ distinct: ast.distinct,
12758
+ reduced: ast.reduced
12759
+ }, ast.loc));
12760
+ } else if (ast.subType === "group") {
12761
+ SUBRULE(groupGraphPattern, ast);
12762
+ } else if (ast.subType === "bgp") {
12763
+ SUBRULE(triplesBlock, ast);
12764
+ } else {
12765
+ SUBRULE(graphPatternNotTriples, ast);
12766
+ }
12767
+ }
12768
+ };
12769
+ var groupGraphPatternSub = {
12770
+ name: "groupGraphPatternSub",
12771
+ impl: ({ ACTION, SUBRULE, CONSUME, MANY, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OPTION3 }) => () => {
12772
+ const patterns = [];
12773
+ const bgpPattern = OPTION1(() => SUBRULE1(triplesBlock));
12774
+ if (bgpPattern) {
12775
+ patterns.push(bgpPattern);
12776
+ }
12777
+ MANY(() => {
12778
+ const notTriples = SUBRULE(graphPatternNotTriples);
12779
+ patterns.push(notTriples);
12780
+ OPTION2(() => CONSUME(symbols_exports.dot));
12781
+ const moreTriples = OPTION3(() => SUBRULE2(triplesBlock));
12782
+ if (moreTriples) {
12783
+ patterns.push(moreTriples);
12784
+ }
12785
+ });
12786
+ ACTION(() => checkNote13(patterns));
12787
+ return patterns;
12788
+ }
12789
+ };
12790
+ var graphPatternNotTriples = {
12791
+ name: "graphPatternNotTriples",
12792
+ impl: ({ SUBRULE, OR }) => () => OR([
12793
+ { ALT: () => SUBRULE(groupOrUnionGraphPattern) },
12794
+ { ALT: () => SUBRULE(optionalGraphPattern) },
12795
+ { ALT: () => SUBRULE(minusGraphPattern) },
12796
+ { ALT: () => SUBRULE(graphGraphPattern) },
12797
+ { ALT: () => SUBRULE(serviceGraphPattern) },
12798
+ { ALT: () => SUBRULE(filter3) },
12799
+ { ALT: () => SUBRULE(bind2) },
12800
+ { ALT: () => SUBRULE(inlineData) }
12801
+ ]),
12802
+ gImpl: ({ SUBRULE }) => (ast) => {
12803
+ switch (ast.subType) {
12804
+ case "group":
12805
+ case "union":
12806
+ SUBRULE(groupOrUnionGraphPattern, ast);
12807
+ break;
12808
+ case "optional":
12809
+ SUBRULE(optionalGraphPattern, ast);
12810
+ break;
12811
+ case "minus":
12812
+ SUBRULE(minusGraphPattern, ast);
12813
+ break;
12814
+ case "graph":
12815
+ SUBRULE(graphGraphPattern, ast);
12816
+ break;
12817
+ case "service":
12818
+ SUBRULE(serviceGraphPattern, ast);
12819
+ break;
12820
+ case "filter":
12821
+ SUBRULE(filter3, ast);
12822
+ break;
12823
+ case "bind":
12824
+ SUBRULE(bind2, ast);
12825
+ break;
12826
+ case "values":
12827
+ SUBRULE(inlineData, ast);
12828
+ break;
12829
+ }
12830
+ }
12831
+ };
12832
+ var optionalGraphPattern = {
12833
+ name: "optionalGraphPattern",
12834
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12835
+ const optional2 = CONSUME(optional);
12836
+ const group = SUBRULE(groupGraphPattern);
12837
+ return ACTION(() => C.factory.patternOptional(group.patterns, C.factory.sourceLocation(optional2, group)));
12838
+ },
12839
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12840
+ F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
12841
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12842
+ }
12843
+ };
12844
+ var graphGraphPattern = {
12845
+ name: "graphGraphPattern",
12846
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12847
+ const graph2 = CONSUME(graph_exports.graph);
12848
+ const name = SUBRULE(varOrIri);
12849
+ const group = SUBRULE(groupGraphPattern);
12850
+ return ACTION(() => C.factory.patternGraph(name, group.patterns, C.factory.sourceLocation(graph2, group)));
12851
+ },
12852
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12853
+ F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
12854
+ SUBRULE(varOrTerm, ast.name);
12855
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12856
+ }
12857
+ };
12858
+ var serviceGraphPattern = {
12859
+ name: "serviceGraphPattern",
12860
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
12861
+ const service2 = CONSUME(service);
12862
+ const silent2 = OPTION(() => {
12863
+ CONSUME(silent);
12864
+ return true;
12865
+ }) ?? false;
12866
+ const name = SUBRULE1(varOrIri);
12867
+ const group = SUBRULE1(groupGraphPattern);
12868
+ return ACTION(() => C.factory.patternService(name, group.patterns, silent2, C.factory.sourceLocation(service2, group)));
12869
+ },
12870
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12871
+ F2.printFilter(ast, () => {
12872
+ PRINT_WORD("SERVICE");
12873
+ if (ast.silent) {
12874
+ PRINT_WORD("SILENT");
12875
+ }
12876
+ });
12877
+ SUBRULE(varOrTerm, ast.name);
12878
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12879
+ }
12880
+ };
12881
+ var bind2 = {
12882
+ name: "bind",
12883
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12884
+ const bind3 = CONSUME(bind);
12885
+ CONSUME(symbols_exports.LParen);
12886
+ const expressionVal = SUBRULE(expression);
12887
+ CONSUME(as);
12888
+ const variable = SUBRULE(var_);
12889
+ const close = CONSUME(symbols_exports.RParen);
12890
+ return ACTION(() => C.factory.patternBind(expressionVal, variable, C.factory.sourceLocation(bind3, close)));
12891
+ },
12892
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12893
+ F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12894
+ SUBRULE(expression, ast.expression);
12895
+ F2.printFilter(ast, () => PRINT_WORD("AS"));
12896
+ SUBRULE(var_, ast.variable);
12897
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12898
+ }
12899
+ };
12900
+ var inlineData = {
12901
+ name: "inlineData",
12902
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12903
+ const values3 = CONSUME(values2);
12904
+ const datablock = SUBRULE(dataBlock);
12905
+ return ACTION(() => C.factory.patternValues(datablock.val, C.factory.sourceLocation(values3, datablock)));
12906
+ },
12907
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12908
+ const variables = Object.keys(ast.values[0]);
12909
+ F2.printFilter(ast, () => {
12910
+ PRINT_WORD("VALUES", "(");
12911
+ for (const variable of variables) {
12912
+ PRINT_WORD(`?${variable}`);
12913
+ }
12914
+ PRINT_WORD(")", "{");
12915
+ });
12916
+ for (const mapping of ast.values) {
12917
+ F2.printFilter(ast, () => PRINT_WORD("("));
12918
+ for (const variable of variables) {
12919
+ if (mapping[variable] === void 0) {
12920
+ F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
12921
+ } else {
12922
+ SUBRULE(graphNodePath, mapping[variable]);
12923
+ }
12924
+ }
12925
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12961
12926
  }
12962
- const builtIns = builtInCallList(SUBRULE);
12963
- cache.set(builtInCall, builtIns);
12964
- return OR(builtIns);
12927
+ F2.printFilter(ast, () => PRINT_WORD("}"));
12965
12928
  }
12966
12929
  };
12967
- var regexExpression = funcExpr2or3(BuildinCalls_exports.regex);
12968
- var substringExpression = funcExpr2or3(BuildinCalls_exports.substr);
12969
- var strReplaceExpression = funcExpr3or4(BuildinCalls_exports.replace);
12970
- var existsFunc = funcGroupGraphPattern(BuildinCalls_exports.exists);
12971
- var notExistsFunc = funcGroupGraphPattern(BuildinCalls_exports.notexists);
12972
- var aggregateCount = {
12973
- name: unCapitalize(BuildinCalls_exports.count.name),
12974
- impl: ({ ACTION, CONSUME, SUBRULE, OR, OPTION }) => (C) => {
12975
- const operatorToken = CONSUME(BuildinCalls_exports.count);
12976
- CONSUME(symbols_exports.LParen);
12977
- const distinctToken = OPTION(() => CONSUME(distinct));
12978
- const expressionVal = OR([
12930
+ var dataBlock = {
12931
+ name: "dataBlock",
12932
+ impl: ({ SUBRULE, OR }) => () => OR([
12933
+ { ALT: () => SUBRULE(inlineDataOneVar) },
12934
+ { ALT: () => SUBRULE(inlineDataFull) }
12935
+ ])
12936
+ };
12937
+ var inlineDataOneVar = {
12938
+ name: "inlineDataOneVar",
12939
+ impl: ({ ACTION, SUBRULE, CONSUME, MANY }) => (C) => {
12940
+ const res = [];
12941
+ const varVal = SUBRULE(var_);
12942
+ CONSUME(symbols_exports.LCurly);
12943
+ MANY(() => {
12944
+ const value = SUBRULE(dataBlockValue);
12945
+ ACTION(() => {
12946
+ res.push({ [varVal.value]: value });
12947
+ });
12948
+ });
12949
+ const close = CONSUME(symbols_exports.RCurly);
12950
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(varVal, close)));
12951
+ }
12952
+ };
12953
+ var inlineDataFull = {
12954
+ name: "inlineDataFull",
12955
+ impl: ({
12956
+ ACTION,
12957
+ OR,
12958
+ MANY1,
12959
+ MANY2,
12960
+ MANY3,
12961
+ MANY4,
12962
+ SUBRULE,
12963
+ CONSUME1,
12964
+ CONSUME2
12965
+ }) => (C) => {
12966
+ const res = [];
12967
+ const vars = [];
12968
+ return OR([
12979
12969
  { ALT: () => {
12980
- const starToken = CONSUME(symbols_exports.star);
12981
- return ACTION(() => C.factory.wildcard(C.factory.sourceLocation(starToken)));
12970
+ const nil2 = CONSUME1(terminals_exports.nil);
12971
+ CONSUME1(symbols_exports.LCurly);
12972
+ MANY1(() => {
12973
+ CONSUME2(terminals_exports.nil);
12974
+ res.push({});
12975
+ });
12976
+ const close = CONSUME1(symbols_exports.RCurly);
12977
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(nil2, close)));
12982
12978
  } },
12983
- { ALT: () => SUBRULE(expression, void 0) }
12979
+ { ALT: () => {
12980
+ const open = CONSUME1(symbols_exports.LParen);
12981
+ MANY2(() => {
12982
+ vars.push(SUBRULE(var_));
12983
+ });
12984
+ CONSUME1(symbols_exports.RParen);
12985
+ CONSUME2(symbols_exports.LCurly);
12986
+ MANY3(() => {
12987
+ let parsedValues = 0;
12988
+ const currentRow = {};
12989
+ CONSUME2(symbols_exports.LParen);
12990
+ MANY4(() => {
12991
+ if (parsedValues >= vars.length) {
12992
+ throw new Error("Number of dataBlockValues does not match number of variables. Too much values.");
12993
+ }
12994
+ const value = SUBRULE(dataBlockValue);
12995
+ ACTION(() => {
12996
+ currentRow[vars[parsedValues].value] = value;
12997
+ parsedValues++;
12998
+ });
12999
+ });
13000
+ CONSUME2(symbols_exports.RParen);
13001
+ ACTION(() => {
13002
+ res.push(currentRow);
13003
+ if (vars.length !== parsedValues) {
13004
+ throw new Error("Number of dataBlockValues does not match number of variables. Too few values.");
13005
+ }
13006
+ });
13007
+ });
13008
+ const close = CONSUME2(symbols_exports.RCurly);
13009
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(open, close)));
13010
+ } }
12984
13011
  ]);
12985
- const closeToken = CONSUME(symbols_exports.RParen);
12986
- return ACTION(() => {
12987
- const F2 = C.factory;
12988
- if (C.factory.isWildcard(expressionVal)) {
12989
- return F2.aggregate(
12990
- operatorToken.image,
12991
- Boolean(distinctToken),
12992
- expressionVal,
12993
- void 0,
12994
- C.factory.sourceLocation(operatorToken, closeToken)
12995
- );
12996
- }
12997
- return F2.aggregate(
12998
- operatorToken.image,
12999
- Boolean(distinctToken),
13000
- expressionVal,
13001
- void 0,
13002
- C.factory.sourceLocation(operatorToken, closeToken)
13003
- );
13004
- });
13005
13012
  }
13006
13013
  };
13007
- var aggregateSum = baseAggregateFunc(BuildinCalls_exports.sum);
13008
- var aggregateMin = baseAggregateFunc(BuildinCalls_exports.min);
13009
- var aggregateMax = baseAggregateFunc(BuildinCalls_exports.max);
13010
- var aggregateAvg = baseAggregateFunc(BuildinCalls_exports.avg);
13011
- var aggregateSample = baseAggregateFunc(BuildinCalls_exports.sample);
13012
- var aggregateGroup_concat = {
13013
- name: unCapitalize(BuildinCalls_exports.groupConcat.name),
13014
- impl: ({ ACTION, CONSUME, OPTION1, SUBRULE, OPTION2 }) => (C) => {
13015
- const operatorToken = CONSUME(BuildinCalls_exports.groupConcat);
13016
- CONSUME(symbols_exports.LParen);
13017
- const distinctToken = OPTION1(() => CONSUME(distinct));
13018
- const expr = SUBRULE(expression, void 0);
13019
- const sep = OPTION2(() => {
13020
- CONSUME(symbols_exports.semi);
13021
- CONSUME(separator);
13022
- CONSUME(symbols_exports.equal);
13023
- return SUBRULE(string, void 0);
13024
- });
13025
- const closeToken = CONSUME(symbols_exports.RParen);
13026
- return ACTION(() => {
13027
- const F2 = C.factory;
13028
- return F2.aggregate(
13029
- operatorToken.image,
13030
- Boolean(distinctToken),
13031
- expr,
13032
- sep?.value ?? " ",
13033
- F2.sourceLocation(operatorToken, closeToken)
13034
- );
13035
- });
13014
+ var dataBlockValue = {
13015
+ name: "dataBlockValue",
13016
+ impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
13017
+ { ALT: () => SUBRULE(iri2) },
13018
+ { ALT: () => SUBRULE(rdfLiteral) },
13019
+ { ALT: () => SUBRULE(numericLiteral) },
13020
+ { ALT: () => SUBRULE(booleanLiteral) },
13021
+ { ALT: () => {
13022
+ CONSUME(undef);
13023
+ return void 0;
13024
+ } }
13025
+ ])
13026
+ };
13027
+ var minusGraphPattern = {
13028
+ name: "minusGraphPattern",
13029
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13030
+ const minus2 = CONSUME(minus);
13031
+ const group = SUBRULE(groupGraphPattern);
13032
+ return ACTION(() => C.factory.patternMinus(group.patterns, C.factory.sourceLocation(minus2, group)));
13033
+ },
13034
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13035
+ F2.printFilter(ast, () => PRINT_WORD("MINUS"));
13036
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
13036
13037
  }
13037
13038
  };
13038
- var aggregate = {
13039
- name: "aggregate",
13040
- impl: ({ ACTION, SUBRULE, OR }) => (C) => {
13041
- const wasInAggregate = ACTION(() => C.parseMode.has("inAggregate"));
13042
- ACTION(() => C.parseMode.add("inAggregate"));
13043
- const result = OR([
13044
- { ALT: () => SUBRULE(aggregateCount, void 0) },
13045
- { ALT: () => SUBRULE(aggregateSum, void 0) },
13046
- { ALT: () => SUBRULE(aggregateMin, void 0) },
13047
- { ALT: () => SUBRULE(aggregateMax, void 0) },
13048
- { ALT: () => SUBRULE(aggregateAvg, void 0) },
13049
- { ALT: () => SUBRULE(aggregateSample, void 0) },
13050
- { ALT: () => SUBRULE(aggregateGroup_concat, void 0) }
13051
- ]);
13052
- ACTION(() => !wasInAggregate && C.parseMode.delete("inAggregate"));
13053
- ACTION(() => {
13054
- if (!C.parseMode.has("canParseAggregate")) {
13055
- throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");
13056
- }
13057
- if (C.parseMode.has("inAggregate")) {
13058
- throw new Error("An aggregate function is not allowed within an aggregate function.");
13059
- }
13039
+ var groupOrUnionGraphPattern = {
13040
+ name: "groupOrUnionGraphPattern",
13041
+ impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => {
13042
+ const groups = [];
13043
+ const group = SUBRULE1(groupGraphPattern);
13044
+ groups.push(group);
13045
+ MANY(() => {
13046
+ CONSUME(union);
13047
+ const group2 = SUBRULE2(groupGraphPattern);
13048
+ groups.push(group2);
13060
13049
  });
13061
- return result;
13050
+ return ACTION(() => groups.length === 1 ? groups[0] : C.factory.patternUnion(
13051
+ groups,
13052
+ C.factory.sourceLocation(group, groups.at(-1))
13053
+ ));
13062
13054
  },
13063
13055
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13064
- F2.printFilter(ast, () => {
13065
- PRINT_WORD(ast.aggregation, "(");
13066
- if (ast.distinct) {
13067
- PRINT_WORD("DISTINCT");
13056
+ if (F2.isPatternUnion(ast)) {
13057
+ const [head2, ...tail] = ast.patterns;
13058
+ SUBRULE(groupGraphPattern, head2);
13059
+ for (const pattern of tail) {
13060
+ F2.printFilter(ast, () => PRINT_WORD("UNION"));
13061
+ SUBRULE(groupGraphPattern, pattern);
13068
13062
  }
13069
- });
13070
- const arg = ast.expression[0];
13071
- if (F2.isWildcard(arg)) {
13072
- F2.printFilter(ast, () => PRINT_WORD("*"));
13073
13063
  } else {
13074
- SUBRULE(expression, arg, void 0);
13075
- }
13076
- if (F2.isExpressionAggregateSeparator(ast)) {
13077
- F2.printFilter(ast, () => PRINT_WORD(";", "SEPARATOR", "=", stringEscapedLexical(ast.separator)));
13064
+ SUBRULE(groupGraphPattern, ast);
13078
13065
  }
13066
+ }
13067
+ };
13068
+ var filter3 = {
13069
+ name: "filter",
13070
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13071
+ const filterToken = CONSUME(filter2);
13072
+ const expression2 = SUBRULE(constraint);
13073
+ return ACTION(() => C.factory.patternFilter(expression2, C.factory.sourceLocation(filterToken, expression2)));
13074
+ },
13075
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13076
+ F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
13077
+ SUBRULE(expression, ast.expression);
13079
13078
  F2.printFilter(ast, () => PRINT_WORD(")"));
13080
13079
  }
13081
13080
  };
13081
+ var constraint = {
13082
+ name: "constraint",
13083
+ impl: ({ SUBRULE, OR }) => () => OR([
13084
+ { ALT: () => SUBRULE(brackettedExpression) },
13085
+ { ALT: () => SUBRULE(builtInCall) },
13086
+ { ALT: () => SUBRULE(functionCall) }
13087
+ ])
13088
+ };
13089
+ var functionCall = {
13090
+ name: "functionCall",
13091
+ impl: ({ ACTION, SUBRULE }) => (C) => {
13092
+ const func = SUBRULE(iri2);
13093
+ const args = SUBRULE(argList);
13094
+ return ACTION(() => C.factory.expressionFunctionCall(
13095
+ func,
13096
+ args.val.args,
13097
+ args.val.distinct,
13098
+ C.factory.sourceLocation(func, args)
13099
+ ));
13100
+ }
13101
+ };
13082
13102
 
13083
13103
  // lib/grammar/expression.ts
13084
13104
  var argList = {
@@ -13098,7 +13118,7 @@ var argList = {
13098
13118
  AT_LEAST_ONE_SEP({
13099
13119
  SEP: symbols_exports.comma,
13100
13120
  DEF: () => {
13101
- const arg = SUBRULE1(expression, void 0);
13121
+ const arg = SUBRULE1(expression);
13102
13122
  args.push(arg);
13103
13123
  }
13104
13124
  });
@@ -13115,11 +13135,11 @@ var argList = {
13115
13135
  });
13116
13136
  const [head2, ...tail] = ast.val.args;
13117
13137
  if (head2) {
13118
- SUBRULE(expression, head2, void 0);
13138
+ SUBRULE(expression, head2);
13119
13139
  }
13120
13140
  for (const expr of tail) {
13121
13141
  F2.printFilter(ast, () => PRINT_WORD(","));
13122
- SUBRULE(expression, expr, void 0);
13142
+ SUBRULE(expression, expr);
13123
13143
  }
13124
13144
  F2.printFilter(ast, () => PRINT_WORD(")"));
13125
13145
  }
@@ -13133,11 +13153,11 @@ var expressionList = {
13133
13153
  } },
13134
13154
  { ALT: () => {
13135
13155
  const open = CONSUME(symbols_exports.LParen);
13136
- const expr1 = SUBRULE1(expression, void 0);
13156
+ const expr1 = SUBRULE1(expression);
13137
13157
  const args = [expr1];
13138
13158
  MANY(() => {
13139
13159
  CONSUME(symbols_exports.comma);
13140
- const expr = SUBRULE2(expression, void 0);
13160
+ const expr = SUBRULE2(expression);
13141
13161
  args.push(expr);
13142
13162
  });
13143
13163
  const close = CONSUME(symbols_exports.RParen);
@@ -13149,15 +13169,15 @@ var infixOperators = /* @__PURE__ */ new Set(["in", "notin", "||", "&&", "=", "!
13149
13169
  var prefixOperator = /* @__PURE__ */ new Set(["!", "UPLUS", "UMINUS"]);
13150
13170
  var expression = {
13151
13171
  name: "expression",
13152
- impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression, void 0),
13172
+ impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression),
13153
13173
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13154
13174
  if (F2.isTerm(ast)) {
13155
- SUBRULE(varOrTerm, ast, void 0);
13175
+ SUBRULE(varOrTerm, ast);
13156
13176
  } else if (F2.isExpressionOperator(ast)) {
13157
13177
  if (infixOperators.has(ast.operator)) {
13158
13178
  const [left, ...right] = ast.args;
13159
13179
  F2.printFilter(ast, () => PRINT_WORD("("));
13160
- SUBRULE(expression, left, void 0);
13180
+ SUBRULE(expression, left);
13161
13181
  F2.printFilter(ast, () => {
13162
13182
  if (ast.operator === "notin") {
13163
13183
  PRINT_WORD("NOT IN");
@@ -13168,35 +13188,35 @@ var expression = {
13168
13188
  }
13169
13189
  });
13170
13190
  if (right.length === 1) {
13171
- SUBRULE(expression, right[0], void 0);
13191
+ SUBRULE(expression, right[0]);
13172
13192
  } else {
13173
- SUBRULE(argList, F2.wrap({ args: right, distinct: false }, ast.loc), void 0);
13193
+ SUBRULE(argList, F2.wrap({ args: right, distinct: false }, ast.loc));
13174
13194
  }
13175
13195
  F2.printFilter(ast, () => PRINT_WORD(")"));
13176
13196
  } else if (prefixOperator.has(ast.operator)) {
13177
13197
  const [expr] = ast.args;
13178
13198
  F2.printFilter(ast, () => PRINT_WORD(ast.operator));
13179
- SUBRULE(expression, expr, void 0);
13199
+ SUBRULE(expression, expr);
13180
13200
  } else {
13181
13201
  F2.printFilter(ast, () => PRINT_WORD(ast.operator, "("));
13182
13202
  const [head2, ...tail] = ast.args;
13183
13203
  if (head2) {
13184
- SUBRULE(expression, head2, void 0);
13204
+ SUBRULE(expression, head2);
13185
13205
  }
13186
13206
  for (const arg of tail) {
13187
13207
  F2.printFilter(ast, () => PRINT_WORD(","));
13188
- SUBRULE(expression, arg, void 0);
13208
+ SUBRULE(expression, arg);
13189
13209
  }
13190
13210
  F2.printFilter(ast, () => PRINT_WORD(")"));
13191
13211
  }
13192
13212
  } else if (F2.isExpressionPatternOperation(ast)) {
13193
13213
  const patterns = ast.args;
13194
13214
  F2.printFilter(ast, () => PRINT_WORD(ast.operator === "exists" ? "EXISTS" : "NOT EXISTS"));
13195
- SUBRULE(groupGraphPattern, patterns, void 0);
13215
+ SUBRULE(groupGraphPattern, patterns);
13196
13216
  } else if (F2.isExpressionFunctionCall(ast)) {
13197
- SUBRULE(iriOrFunction, ast, void 0);
13217
+ SUBRULE(iriOrFunction, ast);
13198
13218
  } else if (F2.isExpressionAggregate(ast)) {
13199
- SUBRULE(aggregate, ast, void 0);
13219
+ SUBRULE(aggregate, ast);
13200
13220
  }
13201
13221
  }
13202
13222
  };
@@ -13213,10 +13233,10 @@ function constructLeftDeep(startGenerator, restGenerator, ACTION, MANY) {
13213
13233
  var conditionalOrExpression = {
13214
13234
  name: "conditionalOrExpression",
13215
13235
  impl: ({ ACTION, MANY, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => constructLeftDeep(
13216
- () => SUBRULE1(conditionalAndExpression, void 0),
13236
+ () => SUBRULE1(conditionalAndExpression),
13217
13237
  () => {
13218
13238
  CONSUME(symbols_exports.logicOr);
13219
- const args = SUBRULE2(conditionalAndExpression, void 0);
13239
+ const args = SUBRULE2(conditionalAndExpression);
13220
13240
  return (left) => ACTION(() => C.factory.expressionOperation("||", [left, args], C.factory.sourceLocation(left, args)));
13221
13241
  },
13222
13242
  ACTION,
@@ -13226,10 +13246,10 @@ var conditionalOrExpression = {
13226
13246
  var conditionalAndExpression = {
13227
13247
  name: "conditionalAndExpression",
13228
13248
  impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => constructLeftDeep(
13229
- () => SUBRULE1(valueLogical, void 0),
13249
+ () => SUBRULE1(valueLogical),
13230
13250
  () => {
13231
13251
  CONSUME(symbols_exports.logicAnd);
13232
- const arg = SUBRULE2(valueLogical, void 0);
13252
+ const arg = SUBRULE2(valueLogical);
13233
13253
  return (left) => ACTION(() => C.factory.expressionOperation("&&", [left, arg], C.factory.sourceLocation(left, arg)));
13234
13254
  },
13235
13255
  ACTION,
@@ -13238,12 +13258,12 @@ var conditionalAndExpression = {
13238
13258
  };
13239
13259
  var valueLogical = {
13240
13260
  name: "valueLogical",
13241
- impl: ({ SUBRULE }) => () => SUBRULE(relationalExpression, void 0)
13261
+ impl: ({ SUBRULE }) => () => SUBRULE(relationalExpression)
13242
13262
  };
13243
13263
  var relationalExpression = {
13244
13264
  name: "relationalExpression",
13245
13265
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION, OR1, OR2, OR3 }) => (C) => {
13246
- const args1 = SUBRULE1(numericExpression, void 0);
13266
+ const args1 = SUBRULE1(numericExpression);
13247
13267
  const expression2 = OPTION(() => OR1([
13248
13268
  { ALT: () => {
13249
13269
  const operator = OR2([
@@ -13254,7 +13274,7 @@ var relationalExpression = {
13254
13274
  { ALT: () => CONSUME(symbols_exports.lessThanEqual) },
13255
13275
  { ALT: () => CONSUME(symbols_exports.greaterThanEqual) }
13256
13276
  ]);
13257
- const expr = SUBRULE2(numericExpression, void 0);
13277
+ const expr = SUBRULE2(numericExpression);
13258
13278
  return ACTION(() => C.factory.expressionOperation(
13259
13279
  operator.image,
13260
13280
  [args1, expr],
@@ -13266,7 +13286,7 @@ var relationalExpression = {
13266
13286
  { ALT: () => CONSUME(in_) },
13267
13287
  { ALT: () => CONSUME(notIn) }
13268
13288
  ]);
13269
- const args = SUBRULE1(expressionList, void 0);
13289
+ const args = SUBRULE1(expressionList);
13270
13290
  return ACTION(() => C.factory.expressionOperation(
13271
13291
  operator.image,
13272
13292
  [args1, ...args.val],
@@ -13279,25 +13299,25 @@ var relationalExpression = {
13279
13299
  };
13280
13300
  var numericExpression = {
13281
13301
  name: "numericExpression",
13282
- impl: ({ SUBRULE }) => () => SUBRULE(additiveExpression, void 0)
13302
+ impl: ({ SUBRULE }) => () => SUBRULE(additiveExpression)
13283
13303
  };
13284
13304
  var additiveExpression = {
13285
13305
  name: "additiveExpression",
13286
13306
  impl: ({ ACTION, SUBRULE, CONSUME, SUBRULE1, SUBRULE2, MANY1, MANY2, OR1, OR2, OR3, OR4 }) => (C) => constructLeftDeep(
13287
- () => SUBRULE1(multiplicativeExpression, void 0),
13307
+ () => SUBRULE1(multiplicativeExpression),
13288
13308
  () => OR1([
13289
13309
  { ALT: () => {
13290
13310
  const operator = OR2([
13291
13311
  { ALT: () => CONSUME(symbols_exports.opPlus) },
13292
13312
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13293
13313
  ]);
13294
- const arg = SUBRULE2(multiplicativeExpression, void 0);
13314
+ const arg = SUBRULE2(multiplicativeExpression);
13295
13315
  return ACTION(() => (left) => C.factory.expressionOperation(operator.image, [left, arg], C.factory.sourceLocation(left, arg)));
13296
13316
  } },
13297
13317
  { ALT: () => {
13298
13318
  const { operator, startInt } = OR3([
13299
13319
  { ALT: () => {
13300
- const integer2 = SUBRULE(numericLiteralPositive, void 0);
13320
+ const integer2 = SUBRULE(numericLiteralPositive);
13301
13321
  return ACTION(() => {
13302
13322
  integer2.value = integer2.value.replace(/^\+/u, "");
13303
13323
  return {
@@ -13307,7 +13327,7 @@ var additiveExpression = {
13307
13327
  });
13308
13328
  } },
13309
13329
  { ALT: () => {
13310
- const integer2 = SUBRULE(numericLiteralNegative, void 0);
13330
+ const integer2 = SUBRULE(numericLiteralNegative);
13311
13331
  return ACTION(() => {
13312
13332
  integer2.value = integer2.value.replace(/^-/u, "");
13313
13333
  return {
@@ -13324,7 +13344,7 @@ var additiveExpression = {
13324
13344
  { ALT: () => CONSUME(symbols_exports.star) },
13325
13345
  { ALT: () => CONSUME(symbols_exports.slash) }
13326
13346
  ]);
13327
- const innerExpr = SUBRULE1(unaryExpression, void 0);
13347
+ const innerExpr = SUBRULE1(unaryExpression);
13328
13348
  return ACTION(() => (leftInner) => C.factory.expressionOperation(
13329
13349
  innerOperator.image,
13330
13350
  [leftInner, innerExpr],
@@ -13348,13 +13368,13 @@ var additiveExpression = {
13348
13368
  var multiplicativeExpression = {
13349
13369
  name: "multiplicativeExpression",
13350
13370
  impl: ({ ACTION, CONSUME, MANY, SUBRULE1, SUBRULE2, OR }) => (C) => constructLeftDeep(
13351
- () => SUBRULE1(unaryExpression, void 0),
13371
+ () => SUBRULE1(unaryExpression),
13352
13372
  () => {
13353
13373
  const operator = OR([
13354
13374
  { ALT: () => CONSUME(symbols_exports.star) },
13355
13375
  { ALT: () => CONSUME(symbols_exports.slash) }
13356
13376
  ]);
13357
- const expr = SUBRULE2(unaryExpression, void 0);
13377
+ const expr = SUBRULE2(unaryExpression);
13358
13378
  return (left) => ({
13359
13379
  type: "expression",
13360
13380
  subType: "operation",
@@ -13370,14 +13390,14 @@ var multiplicativeExpression = {
13370
13390
  var unaryExpression = {
13371
13391
  name: "unaryExpression",
13372
13392
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
13373
- { ALT: () => SUBRULE1(primaryExpression, void 0) },
13393
+ { ALT: () => SUBRULE1(primaryExpression) },
13374
13394
  { ALT: () => {
13375
13395
  const operator = OR2([
13376
13396
  { ALT: () => CONSUME(symbols_exports.exclamation) },
13377
13397
  { ALT: () => CONSUME(symbols_exports.opPlus) },
13378
13398
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13379
13399
  ]);
13380
- const expr = SUBRULE2(primaryExpression, void 0);
13400
+ const expr = SUBRULE2(primaryExpression);
13381
13401
  return ACTION(() => ({
13382
13402
  type: "expression",
13383
13403
  subType: "operation",
@@ -13391,20 +13411,20 @@ var unaryExpression = {
13391
13411
  var primaryExpression = {
13392
13412
  name: "primaryExpression",
13393
13413
  impl: ({ SUBRULE, OR }) => () => OR([
13394
- { ALT: () => SUBRULE(brackettedExpression, void 0) },
13395
- { ALT: () => SUBRULE(builtInCall, void 0) },
13396
- { ALT: () => SUBRULE(iriOrFunction, void 0) },
13397
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
13398
- { ALT: () => SUBRULE(numericLiteral, void 0) },
13399
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
13400
- { ALT: () => SUBRULE(var_, void 0) }
13414
+ { ALT: () => SUBRULE(brackettedExpression) },
13415
+ { ALT: () => SUBRULE(builtInCall) },
13416
+ { ALT: () => SUBRULE(iriOrFunction) },
13417
+ { ALT: () => SUBRULE(rdfLiteral) },
13418
+ { ALT: () => SUBRULE(numericLiteral) },
13419
+ { ALT: () => SUBRULE(booleanLiteral) },
13420
+ { ALT: () => SUBRULE(var_) }
13401
13421
  ])
13402
13422
  };
13403
13423
  var brackettedExpression = {
13404
13424
  name: "brackettedExpression",
13405
13425
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13406
13426
  const open = CONSUME(symbols_exports.LParen);
13407
- const expr = SUBRULE(expression, void 0);
13427
+ const expr = SUBRULE(expression);
13408
13428
  const close = CONSUME(symbols_exports.RParen);
13409
13429
  return ACTION(() => {
13410
13430
  expr.loc = C.factory.sourceLocation(open, close);
@@ -13415,9 +13435,9 @@ var brackettedExpression = {
13415
13435
  var iriOrFunction = {
13416
13436
  name: "iriOrFunction",
13417
13437
  impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
13418
- const iriVal = SUBRULE(iri2, void 0);
13438
+ const iriVal = SUBRULE(iri2);
13419
13439
  const functionCall2 = OPTION(() => {
13420
- const args = SUBRULE(argList, void 0);
13440
+ const args = SUBRULE(argList);
13421
13441
  return ACTION(() => {
13422
13442
  const distinct2 = args.val.distinct;
13423
13443
  if (!C.parseMode.has("canParseAggregate") && distinct2) {
@@ -13437,10 +13457,10 @@ var iriOrFunction = {
13437
13457
  },
13438
13458
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13439
13459
  if (F2.isTermNamed(ast)) {
13440
- SUBRULE(iri2, ast, void 0);
13460
+ SUBRULE(iri2, ast);
13441
13461
  } else {
13442
- SUBRULE(iri2, ast.function, void 0);
13443
- SUBRULE(argList, F2.wrap({ args: ast.args, distinct: ast.distinct }, ast.loc), void 0);
13462
+ SUBRULE(iri2, ast.function);
13463
+ SUBRULE(argList, F2.wrap({ args: ast.args, distinct: ast.distinct }, ast.loc));
13444
13464
  }
13445
13465
  }
13446
13466
  };
@@ -13449,10 +13469,10 @@ var iriOrFunction = {
13449
13469
  var solutionModifier = {
13450
13470
  name: "solutionModifier",
13451
13471
  impl: ({ ACTION, SUBRULE, OPTION1, OPTION2, OPTION3, OPTION4 }) => () => {
13452
- const group = OPTION1(() => SUBRULE(groupClause, void 0));
13453
- const having2 = OPTION2(() => SUBRULE(havingClause, void 0));
13454
- const order2 = OPTION3(() => SUBRULE(orderClause, void 0));
13455
- const limitOffset = OPTION4(() => SUBRULE(limitOffsetClauses, void 0));
13472
+ const group = OPTION1(() => SUBRULE(groupClause));
13473
+ const having2 = OPTION2(() => SUBRULE(havingClause));
13474
+ const order2 = OPTION3(() => SUBRULE(orderClause));
13475
+ const limitOffset = OPTION4(() => SUBRULE(limitOffsetClauses));
13456
13476
  return ACTION(() => ({
13457
13477
  ...limitOffset && { limitOffset },
13458
13478
  ...group && { group },
@@ -13462,16 +13482,16 @@ var solutionModifier = {
13462
13482
  },
13463
13483
  gImpl: ({ SUBRULE }) => (ast) => {
13464
13484
  if (ast.group) {
13465
- SUBRULE(groupClause, ast.group, void 0);
13485
+ SUBRULE(groupClause, ast.group);
13466
13486
  }
13467
13487
  if (ast.having) {
13468
- SUBRULE(havingClause, ast.having, void 0);
13488
+ SUBRULE(havingClause, ast.having);
13469
13489
  }
13470
13490
  if (ast.order) {
13471
- SUBRULE(orderClause, ast.order, void 0);
13491
+ SUBRULE(orderClause, ast.order);
13472
13492
  }
13473
13493
  if (ast.limitOffset) {
13474
- SUBRULE(limitOffsetClauses, ast.limitOffset, void 0);
13494
+ SUBRULE(limitOffsetClauses, ast.limitOffset);
13475
13495
  }
13476
13496
  }
13477
13497
  };
@@ -13482,7 +13502,7 @@ var groupClause = {
13482
13502
  const start = CONSUME(groupByGroup);
13483
13503
  CONSUME(by);
13484
13504
  AT_LEAST_ONE(() => {
13485
- groupings.push(SUBRULE1(groupCondition, void 0));
13505
+ groupings.push(SUBRULE1(groupCondition));
13486
13506
  });
13487
13507
  return ACTION(() => ({
13488
13508
  type: "solutionModifier",
@@ -13495,12 +13515,12 @@ var groupClause = {
13495
13515
  F2.printFilter(ast, () => PRINT_WORDS("GROUP", "BY"));
13496
13516
  for (const grouping of ast.groupings) {
13497
13517
  if (F2.isExpression(grouping)) {
13498
- SUBRULE(expression, grouping, void 0);
13518
+ SUBRULE(expression, grouping);
13499
13519
  } else {
13500
13520
  F2.printFilter(ast, () => PRINT_WORDS("("));
13501
- SUBRULE(expression, grouping.value, void 0);
13521
+ SUBRULE(expression, grouping.value);
13502
13522
  F2.printFilter(ast, () => PRINT_WORDS("AS"));
13503
- SUBRULE(var_, grouping.variable, void 0);
13523
+ SUBRULE(var_, grouping.variable);
13504
13524
  F2.printFilter(ast, () => PRINT_WORDS(")"));
13505
13525
  }
13506
13526
  }
@@ -13509,16 +13529,16 @@ var groupClause = {
13509
13529
  var groupCondition = {
13510
13530
  name: "groupCondition",
13511
13531
  impl: ({ ACTION, SUBRULE, CONSUME, SUBRULE1, SUBRULE2, OPTION, OR }) => (C) => OR([
13512
- { ALT: () => SUBRULE(builtInCall, void 0) },
13513
- { ALT: () => SUBRULE(functionCall, void 0) },
13514
- { ALT: () => SUBRULE2(var_, void 0) },
13532
+ { ALT: () => SUBRULE(builtInCall) },
13533
+ { ALT: () => SUBRULE(functionCall) },
13534
+ { ALT: () => SUBRULE2(var_) },
13515
13535
  {
13516
13536
  ALT: () => {
13517
13537
  const open = CONSUME(symbols_exports.LParen);
13518
- const expressionValue = SUBRULE(expression, void 0);
13538
+ const expressionValue = SUBRULE(expression);
13519
13539
  const variable = OPTION(() => {
13520
13540
  CONSUME(as);
13521
- return SUBRULE1(var_, void 0);
13541
+ return SUBRULE1(var_);
13522
13542
  });
13523
13543
  const close = CONSUME(symbols_exports.RParen);
13524
13544
  return ACTION(() => {
@@ -13542,7 +13562,7 @@ var havingClause = {
13542
13562
  const expressions = [];
13543
13563
  const couldParseAgg = ACTION(() => C.parseMode.has("canParseAggregate") || !C.parseMode.add("canParseAggregate"));
13544
13564
  AT_LEAST_ONE(() => {
13545
- expressions.push(SUBRULE(havingCondition, void 0));
13565
+ expressions.push(SUBRULE(havingCondition));
13546
13566
  });
13547
13567
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13548
13568
  return ACTION(() => C.factory.solutionModifierHaving(expressions, C.factory.sourceLocation(having2, expressions.at(-1))));
@@ -13550,13 +13570,13 @@ var havingClause = {
13550
13570
  gImpl: ({ PRINT_WORD, SUBRULE }) => (ast, { factory: F2 }) => {
13551
13571
  F2.printFilter(ast, () => PRINT_WORD("HAVING"));
13552
13572
  for (const having2 of ast.having) {
13553
- SUBRULE(expression, having2, void 0);
13573
+ SUBRULE(expression, having2);
13554
13574
  }
13555
13575
  }
13556
13576
  };
13557
13577
  var havingCondition = {
13558
13578
  name: "havingCondition",
13559
- impl: ({ SUBRULE }) => () => SUBRULE(constraint, void 0)
13579
+ impl: ({ SUBRULE }) => () => SUBRULE(constraint)
13560
13580
  };
13561
13581
  var orderClause = {
13562
13582
  name: "orderClause",
@@ -13566,7 +13586,7 @@ var orderClause = {
13566
13586
  const orderings = [];
13567
13587
  const couldParseAgg = ACTION(() => C.parseMode.has("canParseAggregate") || !C.parseMode.add("canParseAggregate"));
13568
13588
  AT_LEAST_ONE(() => {
13569
- orderings.push(SUBRULE1(orderCondition, void 0));
13589
+ orderings.push(SUBRULE1(orderCondition));
13570
13590
  });
13571
13591
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13572
13592
  return ACTION(() => C.factory.solutionModifierOrder(orderings, C.factory.sourceLocation(order2, orderings.at(-1))));
@@ -13580,7 +13600,7 @@ var orderClause = {
13580
13600
  F2.printFilter(ast, () => PRINT_WORDS("ASC"));
13581
13601
  }
13582
13602
  F2.printFilter(ast, () => PRINT_WORDS("("));
13583
- SUBRULE(expression, ordering.expression, void 0);
13603
+ SUBRULE(expression, ordering.expression);
13584
13604
  F2.printFilter(ast, () => PRINT_WORDS(")"));
13585
13605
  }
13586
13606
  }
@@ -13599,7 +13619,7 @@ var orderCondition = {
13599
13619
  return [true, token];
13600
13620
  } }
13601
13621
  ]);
13602
- const expr = SUBRULE(brackettedExpression, void 0);
13622
+ const expr = SUBRULE(brackettedExpression);
13603
13623
  return ACTION(() => ({
13604
13624
  expression: expr,
13605
13625
  descending: descending[0],
@@ -13607,11 +13627,11 @@ var orderCondition = {
13607
13627
  }));
13608
13628
  } },
13609
13629
  { ALT: () => {
13610
- const expr = SUBRULE(constraint, void 0);
13630
+ const expr = SUBRULE(constraint);
13611
13631
  return ACTION(() => ({ expression: expr, descending: false, loc: expr.loc }));
13612
13632
  } },
13613
13633
  { ALT: () => {
13614
- const expr = SUBRULE(var_, void 0);
13634
+ const expr = SUBRULE(var_);
13615
13635
  return ACTION(() => ({ expression: expr, descending: false, loc: expr.loc }));
13616
13636
  } }
13617
13637
  ])
@@ -13620,8 +13640,8 @@ var limitOffsetClauses = {
13620
13640
  name: "limitOffsetClauses",
13621
13641
  impl: ({ ACTION, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => OR([
13622
13642
  { ALT: () => {
13623
- const limit2 = SUBRULE1(limitClause, void 0);
13624
- const offset2 = OPTION1(() => SUBRULE1(offsetClause, void 0));
13643
+ const limit2 = SUBRULE1(limitClause);
13644
+ const offset2 = OPTION1(() => SUBRULE1(offsetClause));
13625
13645
  return ACTION(() => C.factory.solutionModifierLimitOffset(
13626
13646
  limit2.val,
13627
13647
  offset2?.val,
@@ -13629,8 +13649,8 @@ var limitOffsetClauses = {
13629
13649
  ));
13630
13650
  } },
13631
13651
  { ALT: () => {
13632
- const offset2 = SUBRULE2(offsetClause, void 0);
13633
- const limit2 = OPTION2(() => SUBRULE2(limitClause, void 0));
13652
+ const offset2 = SUBRULE2(offsetClause);
13653
+ const limit2 = OPTION2(() => SUBRULE2(limitClause));
13634
13654
  return ACTION(() => C.factory.solutionModifierLimitOffset(
13635
13655
  limit2?.val,
13636
13656
  offset2.val,
@@ -13668,22 +13688,22 @@ var offsetClause = {
13668
13688
  }
13669
13689
  };
13670
13690
 
13671
- // lib/grammar/queryUnit/queryUnit.ts
13691
+ // lib/grammar/queryUnit.ts
13672
13692
  var queryUnit = {
13673
13693
  name: "queryUnit",
13674
- impl: ({ SUBRULE }) => () => SUBRULE(query, void 0)
13694
+ impl: ({ SUBRULE }) => () => SUBRULE(query)
13675
13695
  };
13676
13696
  var query = {
13677
13697
  name: "query",
13678
13698
  impl: ({ ACTION, SUBRULE, OR }) => (C) => {
13679
- const prologueValues = SUBRULE(prologue, void 0);
13699
+ const prologueValues = SUBRULE(prologue);
13680
13700
  const subType = OR([
13681
- { ALT: () => SUBRULE(selectQuery, void 0) },
13682
- { ALT: () => SUBRULE(constructQuery, void 0) },
13683
- { ALT: () => SUBRULE(describeQuery, void 0) },
13684
- { ALT: () => SUBRULE(askQuery, void 0) }
13701
+ { ALT: () => SUBRULE(selectQuery) },
13702
+ { ALT: () => SUBRULE(constructQuery) },
13703
+ { ALT: () => SUBRULE(describeQuery) },
13704
+ { ALT: () => SUBRULE(askQuery) }
13685
13705
  ]);
13686
- const values3 = SUBRULE(valuesClause, void 0);
13706
+ const values3 = SUBRULE(valuesClause);
13687
13707
  return ACTION(() => ({
13688
13708
  context: prologueValues,
13689
13709
  ...subType,
@@ -13697,28 +13717,28 @@ var query = {
13697
13717
  }));
13698
13718
  },
13699
13719
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13700
- SUBRULE(prologue, ast.context, void 0);
13720
+ SUBRULE(prologue, ast.context);
13701
13721
  if (F2.isQuerySelect(ast)) {
13702
- SUBRULE(selectQuery, ast, void 0);
13722
+ SUBRULE(selectQuery, ast);
13703
13723
  } else if (F2.isQueryConstruct(ast)) {
13704
- SUBRULE(constructQuery, ast, void 0);
13724
+ SUBRULE(constructQuery, ast);
13705
13725
  } else if (F2.isQueryDescribe(ast)) {
13706
- SUBRULE(describeQuery, ast, void 0);
13726
+ SUBRULE(describeQuery, ast);
13707
13727
  } else if (F2.isQueryAsk(ast)) {
13708
- SUBRULE(askQuery, ast, void 0);
13728
+ SUBRULE(askQuery, ast);
13709
13729
  }
13710
13730
  if (ast.values) {
13711
- SUBRULE(inlineData, ast.values, void 0);
13731
+ SUBRULE(inlineData, ast.values);
13712
13732
  }
13713
13733
  }
13714
13734
  };
13715
13735
  var selectQuery = {
13716
13736
  name: "selectQuery",
13717
13737
  impl: ({ ACTION, SUBRULE }) => (C) => {
13718
- const selectVal = SUBRULE(selectClause, void 0);
13719
- const from2 = SUBRULE(datasetClauseStar, void 0);
13720
- const where2 = SUBRULE(whereClause, void 0);
13721
- const modifiers = SUBRULE(solutionModifier, void 0);
13738
+ const selectVal = SUBRULE(selectClause);
13739
+ const from2 = SUBRULE(datasetClauseStar);
13740
+ const where2 = SUBRULE(whereClause);
13741
+ const modifiers = SUBRULE(solutionModifier);
13722
13742
  return ACTION(() => {
13723
13743
  const ret = {
13724
13744
  subType: "select",
@@ -13744,19 +13764,19 @@ var selectQuery = {
13744
13764
  variables: ast.variables,
13745
13765
  distinct: ast.distinct,
13746
13766
  reduced: ast.reduced
13747
- }, F2.sourceLocation(...ast.variables)), void 0);
13748
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
13749
- SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc), void 0);
13750
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
13767
+ }, F2.sourceLocation(...ast.variables)));
13768
+ SUBRULE(datasetClauseStar, ast.datasets);
13769
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc));
13770
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13751
13771
  }
13752
13772
  };
13753
13773
  var subSelect = {
13754
13774
  name: "subSelect",
13755
13775
  impl: ({ ACTION, SUBRULE }) => (C) => {
13756
- const selectVal = SUBRULE(selectClause, void 0);
13757
- const where2 = SUBRULE(whereClause, void 0);
13758
- const modifiers = SUBRULE(solutionModifier, void 0);
13759
- const values3 = SUBRULE(valuesClause, void 0);
13776
+ const selectVal = SUBRULE(selectClause);
13777
+ const where2 = SUBRULE(whereClause);
13778
+ const modifiers = SUBRULE(solutionModifier);
13779
+ const values3 = SUBRULE(valuesClause);
13760
13780
  return ACTION(() => C.factory.querySelect({
13761
13781
  where: where2.val,
13762
13782
  datasets: C.factory.datasetClauses([], C.factory.sourceLocation()),
@@ -13821,7 +13841,7 @@ var selectClause = {
13821
13841
  const variables = [];
13822
13842
  AT_LEAST_ONE(() => OR3([
13823
13843
  { ALT: () => {
13824
- const raw = SUBRULE1(var_, void 0);
13844
+ const raw = SUBRULE1(var_);
13825
13845
  ACTION(() => {
13826
13846
  if (usedVars.some((v) => v.value === raw.value)) {
13827
13847
  throw new Error(`Variable ${raw.value} used more than once in SELECT clause`);
@@ -13833,9 +13853,9 @@ var selectClause = {
13833
13853
  } },
13834
13854
  { ALT: () => {
13835
13855
  const open = CONSUME(symbols_exports.LParen);
13836
- const expr = SUBRULE1(expression, void 0);
13856
+ const expr = SUBRULE1(expression);
13837
13857
  CONSUME(as);
13838
- const variable = SUBRULE2(var_, void 0);
13858
+ const variable = SUBRULE2(var_);
13839
13859
  const close = CONSUME(symbols_exports.RParen);
13840
13860
  ACTION(() => {
13841
13861
  last2 = close;
@@ -13866,12 +13886,12 @@ var selectClause = {
13866
13886
  if (F2.isWildcard(variable)) {
13867
13887
  F2.printFilter(ast, () => PRINT_WORD("*"));
13868
13888
  } else if (F2.isTerm(variable)) {
13869
- SUBRULE(var_, variable, void 0);
13889
+ SUBRULE(var_, variable);
13870
13890
  } else {
13871
13891
  F2.printFilter(ast, () => PRINT_WORD("("));
13872
- SUBRULE(expression, variable.expression, void 0);
13892
+ SUBRULE(expression, variable.expression);
13873
13893
  F2.printFilter(ast, () => PRINT_WORD("AS"));
13874
- SUBRULE(var_, variable.variable, void 0);
13894
+ SUBRULE(var_, variable.variable);
13875
13895
  F2.printFilter(ast, () => PRINT_WORD(")"));
13876
13896
  }
13877
13897
  }
@@ -13883,10 +13903,10 @@ var constructQuery = {
13883
13903
  const construct2 = CONSUME(construct);
13884
13904
  return OR([
13885
13905
  { ALT: () => {
13886
- const template = SUBRULE1(constructTemplate, void 0);
13887
- const from2 = SUBRULE1(datasetClauseStar, void 0);
13888
- const where2 = SUBRULE1(whereClause, void 0);
13889
- const modifiers = SUBRULE1(solutionModifier, void 0);
13906
+ const template = SUBRULE1(constructTemplate);
13907
+ const from2 = SUBRULE1(datasetClauseStar);
13908
+ const where2 = SUBRULE1(whereClause);
13909
+ const modifiers = SUBRULE1(solutionModifier);
13890
13910
  return ACTION(() => ({
13891
13911
  subType: "construct",
13892
13912
  template: template.val,
@@ -13904,10 +13924,10 @@ var constructQuery = {
13904
13924
  }));
13905
13925
  } },
13906
13926
  { ALT: () => {
13907
- const from2 = SUBRULE2(datasetClauseStar, void 0);
13927
+ const from2 = SUBRULE2(datasetClauseStar);
13908
13928
  CONSUME(where);
13909
- const template = SUBRULE2(constructTemplate, void 0);
13910
- const modifiers = SUBRULE2(solutionModifier, void 0);
13929
+ const template = SUBRULE2(constructTemplate);
13930
+ const modifiers = SUBRULE2(solutionModifier);
13911
13931
  return ACTION(() => ({
13912
13932
  subType: "construct",
13913
13933
  template: template.val,
@@ -13930,16 +13950,16 @@ var constructQuery = {
13930
13950
  F2.printFilter(ast, () => PRINT_WORD("CONSTRUCT"));
13931
13951
  if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
13932
13952
  F2.printFilter(ast, () => PRINT_WORD("{"));
13933
- SUBRULE(triplesBlock, ast.template, void 0);
13953
+ SUBRULE(triplesBlock, ast.template);
13934
13954
  F2.printFilter(ast, () => PRINT_WORD("}"));
13935
13955
  }
13936
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
13956
+ SUBRULE(datasetClauseStar, ast.datasets);
13937
13957
  if (F2.isSourceLocationNoMaterialize(ast.where.loc)) {
13938
- SUBRULE(whereClause, F2.wrap(F2.patternGroup([ast.template], ast.template.loc), ast.template.loc), void 0);
13958
+ SUBRULE(whereClause, F2.wrap(F2.patternGroup([ast.template], ast.template.loc), ast.template.loc));
13939
13959
  } else {
13940
- SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc), void 0);
13960
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc));
13941
13961
  }
13942
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
13962
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13943
13963
  }
13944
13964
  };
13945
13965
  var describeQuery = {
@@ -13950,7 +13970,7 @@ var describeQuery = {
13950
13970
  { ALT: () => {
13951
13971
  const variables2 = [];
13952
13972
  AT_LEAST_ONE(() => {
13953
- variables2.push(SUBRULE1(varOrIri, void 0));
13973
+ variables2.push(SUBRULE1(varOrIri));
13954
13974
  });
13955
13975
  return variables2;
13956
13976
  } },
@@ -13959,9 +13979,9 @@ var describeQuery = {
13959
13979
  return [ACTION(() => C.factory.wildcard(C.factory.sourceLocation(star2)))];
13960
13980
  } }
13961
13981
  ]);
13962
- const from2 = SUBRULE1(datasetClauseStar, void 0);
13963
- const where2 = OPTION(() => SUBRULE1(whereClause, void 0));
13964
- const modifiers = SUBRULE1(solutionModifier, void 0);
13982
+ const from2 = SUBRULE1(datasetClauseStar);
13983
+ const where2 = OPTION(() => SUBRULE1(whereClause));
13984
+ const modifiers = SUBRULE1(solutionModifier);
13965
13985
  return ACTION(() => ({
13966
13986
  subType: "describe",
13967
13987
  variables,
@@ -13986,23 +14006,23 @@ var describeQuery = {
13986
14006
  F2.printFilter(ast, () => PRINT_WORD("*"));
13987
14007
  } else {
13988
14008
  for (const variable of ast.variables) {
13989
- SUBRULE(varOrTerm, variable, void 0);
14009
+ SUBRULE(varOrTerm, variable);
13990
14010
  }
13991
14011
  }
13992
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
14012
+ SUBRULE(datasetClauseStar, ast.datasets);
13993
14013
  if (ast.where) {
13994
- SUBRULE(whereClause, F2.wrap(ast.where, ast.loc), void 0);
14014
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
13995
14015
  }
13996
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
14016
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13997
14017
  }
13998
14018
  };
13999
14019
  var askQuery = {
14000
14020
  name: "askQuery",
14001
14021
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14002
14022
  const ask2 = CONSUME(ask);
14003
- const from2 = SUBRULE(datasetClauseStar, void 0);
14004
- const where2 = SUBRULE(whereClause, void 0);
14005
- const modifiers = SUBRULE(solutionModifier, void 0);
14023
+ const from2 = SUBRULE(datasetClauseStar);
14024
+ const where2 = SUBRULE(whereClause);
14025
+ const modifiers = SUBRULE(solutionModifier);
14006
14026
  return ACTION(() => ({
14007
14027
  subType: "ask",
14008
14028
  datasets: from2,
@@ -14021,20 +14041,20 @@ var askQuery = {
14021
14041
  },
14022
14042
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14023
14043
  F2.printFilter(ast, () => PRINT_WORD("ASK"));
14024
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
14025
- SUBRULE(whereClause, F2.wrap(ast.where, ast.loc), void 0);
14026
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
14044
+ SUBRULE(datasetClauseStar, ast.datasets);
14045
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
14046
+ SUBRULE(solutionModifier, ast.solutionModifiers);
14027
14047
  }
14028
14048
  };
14029
14049
  var valuesClause = {
14030
14050
  name: "valuesClause",
14031
- impl: ({ OPTION, SUBRULE }) => () => OPTION(() => SUBRULE(inlineData, void 0))
14051
+ impl: ({ OPTION, SUBRULE }) => () => OPTION(() => SUBRULE(inlineData))
14032
14052
  };
14033
14053
  var constructTemplate = {
14034
14054
  name: "constructTemplate",
14035
14055
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14036
14056
  const open = CONSUME(symbols_exports.LCurly);
14037
- const triples = OPTION(() => SUBRULE1(constructTriples, void 0));
14057
+ const triples = OPTION(() => SUBRULE1(constructTriples));
14038
14058
  const close = CONSUME(symbols_exports.RCurly);
14039
14059
  return ACTION(() => C.factory.wrap(
14040
14060
  triples ?? C.factory.patternBgp([], C.factory.sourceLocation()),
@@ -14047,27 +14067,27 @@ var constructTriples = {
14047
14067
  impl: triplesTemplate.impl
14048
14068
  };
14049
14069
 
14050
- // lib/grammar/updateUnit/updateUnit.ts
14070
+ // lib/grammar/updateUnit.ts
14051
14071
  var updateUnit = {
14052
14072
  name: "updateUnit",
14053
- impl: ({ SUBRULE }) => () => SUBRULE(update, void 0)
14073
+ impl: ({ SUBRULE }) => () => SUBRULE(update)
14054
14074
  };
14055
14075
  var update = {
14056
14076
  name: "update",
14057
14077
  impl: ({ ACTION, SUBRULE, SUBRULE1, SUBRULE2, CONSUME, OPTION1, MANY }) => (C) => {
14058
14078
  const updates = [];
14059
- const prologueValues = SUBRULE1(prologue, void 0);
14079
+ const prologueValues = SUBRULE1(prologue);
14060
14080
  updates.push({ context: prologueValues });
14061
14081
  let parsedSemi = true;
14062
14082
  MANY({
14063
14083
  GATE: () => parsedSemi,
14064
14084
  DEF: () => {
14065
14085
  parsedSemi = false;
14066
- updates.at(-1).operation = SUBRULE(update1, void 0);
14086
+ updates.at(-1).operation = SUBRULE(update1);
14067
14087
  OPTION1(() => {
14068
14088
  CONSUME(symbols_exports.semi);
14069
14089
  parsedSemi = true;
14070
- const innerPrologue = SUBRULE2(prologue, void 0);
14090
+ const innerPrologue = SUBRULE2(prologue);
14071
14091
  updates.push({ context: innerPrologue });
14072
14092
  });
14073
14093
  }
@@ -14089,9 +14109,9 @@ var update = {
14089
14109
  },
14090
14110
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14091
14111
  for (const update2 of ast.updates) {
14092
- SUBRULE(prologue, update2.context, void 0);
14112
+ SUBRULE(prologue, update2.context);
14093
14113
  if (update2.operation) {
14094
- SUBRULE(update1, update2.operation, void 0);
14114
+ SUBRULE(update1, update2.operation);
14095
14115
  F2.printFilter(ast, () => PRINT_WORD(" ;\n"));
14096
14116
  }
14097
14117
  }
@@ -14100,52 +14120,52 @@ var update = {
14100
14120
  var update1 = {
14101
14121
  name: "update1",
14102
14122
  impl: ({ SUBRULE, OR }) => () => OR([
14103
- { ALT: () => SUBRULE(load2, void 0) },
14104
- { ALT: () => SUBRULE(clear2, void 0) },
14105
- { ALT: () => SUBRULE(drop3, void 0) },
14106
- { ALT: () => SUBRULE(add2, void 0) },
14107
- { ALT: () => SUBRULE(move2, void 0) },
14108
- { ALT: () => SUBRULE(copy2, void 0) },
14109
- { ALT: () => SUBRULE(create2, void 0) },
14110
- { ALT: () => SUBRULE(insertData, void 0) },
14111
- { ALT: () => SUBRULE(deleteData, void 0) },
14112
- { ALT: () => SUBRULE(deleteWhere, void 0) },
14113
- { ALT: () => SUBRULE(modify, void 0) }
14123
+ { ALT: () => SUBRULE(load2) },
14124
+ { ALT: () => SUBRULE(clear2) },
14125
+ { ALT: () => SUBRULE(drop3) },
14126
+ { ALT: () => SUBRULE(add2) },
14127
+ { ALT: () => SUBRULE(move2) },
14128
+ { ALT: () => SUBRULE(copy2) },
14129
+ { ALT: () => SUBRULE(create2) },
14130
+ { ALT: () => SUBRULE(insertData) },
14131
+ { ALT: () => SUBRULE(deleteData) },
14132
+ { ALT: () => SUBRULE(deleteWhere) },
14133
+ { ALT: () => SUBRULE(modify) }
14114
14134
  ]),
14115
14135
  gImpl: ({ SUBRULE }) => (ast) => {
14116
14136
  switch (ast.subType) {
14117
14137
  case "load":
14118
- SUBRULE(load2, ast, void 0);
14138
+ SUBRULE(load2, ast);
14119
14139
  break;
14120
14140
  case "clear":
14121
- SUBRULE(clear2, ast, void 0);
14141
+ SUBRULE(clear2, ast);
14122
14142
  break;
14123
14143
  case "drop":
14124
- SUBRULE(drop3, ast, void 0);
14144
+ SUBRULE(drop3, ast);
14125
14145
  break;
14126
14146
  case "add":
14127
- SUBRULE(add2, ast, void 0);
14147
+ SUBRULE(add2, ast);
14128
14148
  break;
14129
14149
  case "move":
14130
- SUBRULE(move2, ast, void 0);
14150
+ SUBRULE(move2, ast);
14131
14151
  break;
14132
14152
  case "copy":
14133
- SUBRULE(copy2, ast, void 0);
14153
+ SUBRULE(copy2, ast);
14134
14154
  break;
14135
14155
  case "create":
14136
- SUBRULE(create2, ast, void 0);
14156
+ SUBRULE(create2, ast);
14137
14157
  break;
14138
14158
  case "insertdata":
14139
- SUBRULE(insertData, ast, void 0);
14159
+ SUBRULE(insertData, ast);
14140
14160
  break;
14141
14161
  case "deletedata":
14142
- SUBRULE(deleteData, ast, void 0);
14162
+ SUBRULE(deleteData, ast);
14143
14163
  break;
14144
14164
  case "deletewhere":
14145
- SUBRULE(deleteWhere, ast, void 0);
14165
+ SUBRULE(deleteWhere, ast);
14146
14166
  break;
14147
14167
  case "modify":
14148
- SUBRULE(modify, ast, void 0);
14168
+ SUBRULE(modify, ast);
14149
14169
  break;
14150
14170
  }
14151
14171
  }
@@ -14155,10 +14175,10 @@ var load2 = {
14155
14175
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION1, OPTION2 }) => (C) => {
14156
14176
  const loadToken = CONSUME(load);
14157
14177
  const silent2 = OPTION1(() => CONSUME(silent));
14158
- const source = SUBRULE1(iri2, void 0);
14178
+ const source = SUBRULE1(iri2);
14159
14179
  const destination = OPTION2(() => {
14160
14180
  CONSUME(loadInto);
14161
- return SUBRULE1(graphRef, void 0);
14181
+ return SUBRULE1(graphRef);
14162
14182
  });
14163
14183
  return ACTION(() => C.factory.updateOperationLoad(
14164
14184
  C.factory.sourceLocation(loadToken, source, destination),
@@ -14174,10 +14194,10 @@ var load2 = {
14174
14194
  PRINT_WORD("SILENT");
14175
14195
  }
14176
14196
  });
14177
- SUBRULE(iri2, ast.source, void 0);
14197
+ SUBRULE(iri2, ast.source);
14178
14198
  if (ast.destination) {
14179
14199
  F2.printFilter(ast, () => PRINT_WORD("INTO"));
14180
- SUBRULE(graphRefAll, ast.destination, void 0);
14200
+ SUBRULE(graphRefAll, ast.destination);
14181
14201
  }
14182
14202
  }
14183
14203
  };
@@ -14187,7 +14207,7 @@ function clearOrDrop(operation) {
14187
14207
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14188
14208
  const opToken = CONSUME(operation);
14189
14209
  const silent2 = OPTION(() => CONSUME(silent));
14190
- const destination = SUBRULE1(graphRefAll, void 0);
14210
+ const destination = SUBRULE1(graphRefAll);
14191
14211
  return ACTION(() => C.factory.updateOperationClearDrop(
14192
14212
  unCapitalize(operation.name),
14193
14213
  Boolean(silent2),
@@ -14202,7 +14222,7 @@ function clearOrDrop(operation) {
14202
14222
  PRINT_WORD("SILENT");
14203
14223
  }
14204
14224
  });
14205
- SUBRULE(graphRefAll, ast.destination, void 0);
14225
+ SUBRULE(graphRefAll, ast.destination);
14206
14226
  }
14207
14227
  };
14208
14228
  }
@@ -14213,7 +14233,7 @@ var create2 = {
14213
14233
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14214
14234
  const createToken3 = CONSUME(create);
14215
14235
  const silent2 = OPTION(() => CONSUME(silent));
14216
- const destination = SUBRULE1(graphRef, void 0);
14236
+ const destination = SUBRULE1(graphRef);
14217
14237
  return ACTION(() => C.factory.updateOperationCreate(
14218
14238
  destination,
14219
14239
  Boolean(silent2),
@@ -14227,7 +14247,7 @@ var create2 = {
14227
14247
  PRINT_WORD("SILENT");
14228
14248
  }
14229
14249
  });
14230
- SUBRULE(graphRefAll, ast.destination, void 0);
14250
+ SUBRULE(graphRefAll, ast.destination);
14231
14251
  }
14232
14252
  };
14233
14253
  function copyMoveAddOperation(operation) {
@@ -14236,9 +14256,9 @@ function copyMoveAddOperation(operation) {
14236
14256
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION }) => (C) => {
14237
14257
  const op = CONSUME(operation);
14238
14258
  const silent2 = OPTION(() => CONSUME(silent));
14239
- const source = SUBRULE1(graphOrDefault, void 0);
14259
+ const source = SUBRULE1(graphOrDefault);
14240
14260
  CONSUME(to);
14241
- const destination = SUBRULE2(graphOrDefault, void 0);
14261
+ const destination = SUBRULE2(graphOrDefault);
14242
14262
  return ACTION(() => C.factory.updateOperationAddMoveCopy(
14243
14263
  unCapitalize(operation.name),
14244
14264
  source,
@@ -14254,9 +14274,9 @@ function copyMoveAddOperation(operation) {
14254
14274
  PRINT_WORD("SILENT");
14255
14275
  }
14256
14276
  });
14257
- SUBRULE(graphRefAll, ast.source, void 0);
14277
+ SUBRULE(graphRefAll, ast.source);
14258
14278
  F2.printFilter(ast, () => PRINT_WORD("TO"));
14259
- SUBRULE(graphRefAll, ast.destination, void 0);
14279
+ SUBRULE(graphRefAll, ast.destination);
14260
14280
  }
14261
14281
  };
14262
14282
  }
@@ -14267,7 +14287,7 @@ var quadPattern = {
14267
14287
  name: "quadPattern",
14268
14288
  impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
14269
14289
  const open = CONSUME(symbols_exports.LCurly);
14270
- const val = SUBRULE1(quads, void 0);
14290
+ const val = SUBRULE1(quads);
14271
14291
  const close = CONSUME(symbols_exports.RCurly);
14272
14292
  return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
14273
14293
  }
@@ -14277,7 +14297,7 @@ var quadData = {
14277
14297
  impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
14278
14298
  const open = CONSUME(symbols_exports.LCurly);
14279
14299
  const couldParseVars = ACTION(() => C.parseMode.delete("canParseVars"));
14280
- const val = SUBRULE1(quads, void 0);
14300
+ const val = SUBRULE1(quads);
14281
14301
  ACTION(() => couldParseVars && C.parseMode.add("canParseVars"));
14282
14302
  const close = CONSUME(symbols_exports.RCurly);
14283
14303
  return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
@@ -14293,7 +14313,7 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14293
14313
  if (name !== "insertData") {
14294
14314
  couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
14295
14315
  }
14296
- const data = SUBRULE1(dataRule, void 0);
14316
+ const data = SUBRULE1(dataRule);
14297
14317
  if (name !== "insertData") {
14298
14318
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14299
14319
  }
@@ -14304,7 +14324,7 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14304
14324
  subType === "insertdata" ? "INSERT DATA" : subType === "deletedata" ? "DELETE DATA" : "DELETE WHERE",
14305
14325
  "{"
14306
14326
  ));
14307
- SUBRULE(quads, F2.wrap(ast.data, ast.loc), void 0);
14327
+ SUBRULE(quads, F2.wrap(ast.data, ast.loc));
14308
14328
  F2.printFilter(ast, () => PRINT_WORD("}"));
14309
14329
  }
14310
14330
  };
@@ -14317,23 +14337,23 @@ var modify = {
14317
14337
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => {
14318
14338
  const graph2 = OPTION1(() => {
14319
14339
  const withToken = CONSUME(modifyWith);
14320
- const graph3 = SUBRULE1(iri2, void 0);
14340
+ const graph3 = SUBRULE1(iri2);
14321
14341
  return { withToken, graph: graph3 };
14322
14342
  });
14323
14343
  const { insert, del } = OR([
14324
14344
  { ALT: () => {
14325
- const del2 = SUBRULE1(deleteClause2, void 0);
14326
- const insert2 = OPTION2(() => SUBRULE1(insertClause2, void 0));
14345
+ const del2 = SUBRULE1(deleteClause2);
14346
+ const insert2 = OPTION2(() => SUBRULE1(insertClause2));
14327
14347
  return { del: del2, insert: insert2 };
14328
14348
  } },
14329
14349
  { ALT: () => {
14330
- const insert2 = SUBRULE2(insertClause2, void 0);
14350
+ const insert2 = SUBRULE2(insertClause2);
14331
14351
  return { insert: insert2, del: void 0 };
14332
14352
  } }
14333
14353
  ]);
14334
- const using = SUBRULE1(usingClauseStar, void 0);
14354
+ const using = SUBRULE1(usingClauseStar);
14335
14355
  CONSUME(where);
14336
- const where2 = SUBRULE1(groupGraphPattern, void 0);
14356
+ const where2 = SUBRULE1(groupGraphPattern);
14337
14357
  return ACTION(() => C.factory.updateOperationModify(
14338
14358
  C.factory.sourceLocation(graph2?.withToken, del, insert, where2),
14339
14359
  insert?.val ?? [],
@@ -14346,21 +14366,21 @@ var modify = {
14346
14366
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14347
14367
  if (ast.graph) {
14348
14368
  F2.printFilter(ast, () => PRINT_WORD("WITH"));
14349
- SUBRULE(iri2, ast.graph, void 0);
14369
+ SUBRULE(iri2, ast.graph);
14350
14370
  }
14351
14371
  if (ast.delete.length > 0) {
14352
14372
  F2.printFilter(ast, () => PRINT_WORD("DELETE", "{"));
14353
- SUBRULE(quads, F2.wrap(ast.delete, ast.loc), void 0);
14373
+ SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
14354
14374
  F2.printFilter(ast, () => PRINT_WORD("}"));
14355
14375
  }
14356
14376
  if (ast.insert.length > 0) {
14357
14377
  F2.printFilter(ast, () => PRINT_WORD("INSERT", "{"));
14358
- SUBRULE(quads, F2.wrap(ast.insert, ast.loc), void 0);
14378
+ SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
14359
14379
  F2.printFilter(ast, () => PRINT_WORD("}"));
14360
14380
  }
14361
- SUBRULE(usingClauseStar, ast.from, void 0);
14381
+ SUBRULE(usingClauseStar, ast.from);
14362
14382
  F2.printFilter(ast, () => PRINT_WORD("WHERE"));
14363
- SUBRULE(groupGraphPattern, ast.where, void 0);
14383
+ SUBRULE(groupGraphPattern, ast.where);
14364
14384
  }
14365
14385
  };
14366
14386
  var deleteClause2 = {
@@ -14368,7 +14388,7 @@ var deleteClause2 = {
14368
14388
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14369
14389
  const delToken = CONSUME(deleteClause);
14370
14390
  const couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
14371
- const del = SUBRULE(quadPattern, void 0);
14391
+ const del = SUBRULE(quadPattern);
14372
14392
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14373
14393
  return ACTION(() => C.factory.wrap(del.val, C.factory.sourceLocation(delToken, del)));
14374
14394
  }
@@ -14377,7 +14397,7 @@ var insertClause2 = {
14377
14397
  name: "insertClause",
14378
14398
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14379
14399
  const insertToken = CONSUME(insertClause);
14380
- const insert = SUBRULE(quadPattern, void 0);
14400
+ const insert = SUBRULE(quadPattern);
14381
14401
  return ACTION(() => C.factory.wrap(insert.val, C.factory.sourceLocation(insertToken, insert)));
14382
14402
  }
14383
14403
  };
@@ -14390,7 +14410,7 @@ var graphOrDefault = {
14390
14410
  } },
14391
14411
  { ALT: () => {
14392
14412
  const graph2 = OPTION(() => CONSUME(graph_exports.graph));
14393
- const name = SUBRULE1(iri2, void 0);
14413
+ const name = SUBRULE1(iri2);
14394
14414
  return ACTION(() => C.factory.graphRefSpecific(name, C.factory.sourceLocation(graph2, name)));
14395
14415
  } }
14396
14416
  ])
@@ -14399,18 +14419,18 @@ var graphRef = {
14399
14419
  name: "graphRef",
14400
14420
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14401
14421
  const graph2 = CONSUME(graph_exports.graph);
14402
- const val = SUBRULE(iri2, void 0);
14422
+ const val = SUBRULE(iri2);
14403
14423
  return ACTION(() => C.factory.graphRefSpecific(val, C.factory.sourceLocation(graph2, val)));
14404
14424
  },
14405
14425
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14406
14426
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14407
- SUBRULE(iri2, ast.graph, void 0);
14427
+ SUBRULE(iri2, ast.graph);
14408
14428
  }
14409
14429
  };
14410
14430
  var graphRefAll = {
14411
14431
  name: "graphRefAll",
14412
14432
  impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => OR([
14413
- { ALT: () => SUBRULE(graphRef, void 0) },
14433
+ { ALT: () => SUBRULE(graphRef) },
14414
14434
  { ALT: () => {
14415
14435
  const def = CONSUME(graph_exports.default_);
14416
14436
  return ACTION(() => C.factory.graphRefDefault(C.factory.sourceLocation(def)));
@@ -14426,7 +14446,7 @@ var graphRefAll = {
14426
14446
  ]),
14427
14447
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14428
14448
  if (F2.isGraphRefSpecific(ast)) {
14429
- SUBRULE(graphRef, ast, void 0);
14449
+ SUBRULE(graphRef, ast);
14430
14450
  } else if (F2.isGraphRefDefault(ast)) {
14431
14451
  F2.printFilter(ast, () => PRINT_WORD("DEFAULT"));
14432
14452
  } else if (F2.isGraphRefNamed(ast)) {
@@ -14442,12 +14462,12 @@ var quads = {
14442
14462
  const quads2 = [];
14443
14463
  let last2;
14444
14464
  OPTION1(() => {
14445
- const triples = SUBRULE1(triplesTemplate, void 0);
14465
+ const triples = SUBRULE1(triplesTemplate);
14446
14466
  last2 = triples;
14447
14467
  ACTION(() => quads2.push(triples));
14448
14468
  });
14449
14469
  MANY(() => {
14450
- const notTriples = SUBRULE(quadsNotTriples, void 0);
14470
+ const notTriples = SUBRULE(quadsNotTriples);
14451
14471
  last2 = notTriples;
14452
14472
  quads2.push(notTriples);
14453
14473
  OPTION2(() => {
@@ -14456,7 +14476,7 @@ var quads = {
14456
14476
  return dotToken;
14457
14477
  });
14458
14478
  OPTION3(() => {
14459
- const triples = SUBRULE2(triplesTemplate, void 0);
14479
+ const triples = SUBRULE2(triplesTemplate);
14460
14480
  last2 = triples;
14461
14481
  ACTION(() => quads2.push(triples));
14462
14482
  });
@@ -14466,9 +14486,9 @@ var quads = {
14466
14486
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
14467
14487
  for (const quad of ast.val) {
14468
14488
  if (F2.isPattern(quad)) {
14469
- SUBRULE(triplesBlock, quad, void 0);
14489
+ SUBRULE(triplesBlock, quad);
14470
14490
  } else {
14471
- SUBRULE(quadsNotTriples, quad, void 0);
14491
+ SUBRULE(quadsNotTriples, quad);
14472
14492
  }
14473
14493
  }
14474
14494
  }
@@ -14477,9 +14497,9 @@ var quadsNotTriples = {
14477
14497
  name: "quadsNotTriples",
14478
14498
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14479
14499
  const graph2 = CONSUME(graph_exports.graph);
14480
- const name = SUBRULE1(varOrIri, void 0);
14500
+ const name = SUBRULE1(varOrIri);
14481
14501
  CONSUME(symbols_exports.LCurly);
14482
- const triples = OPTION(() => SUBRULE1(triplesTemplate, void 0));
14502
+ const triples = OPTION(() => SUBRULE1(triplesTemplate));
14483
14503
  const close = CONSUME(symbols_exports.RCurly);
14484
14504
  return ACTION(() => C.factory.graphQuads(
14485
14505
  name,
@@ -14489,14 +14509,76 @@ var quadsNotTriples = {
14489
14509
  },
14490
14510
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14491
14511
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14492
- SUBRULE(varOrTerm, ast.graph, void 0);
14512
+ SUBRULE(varOrTerm, ast.graph);
14493
14513
  F2.printFilter(ast, () => PRINT_WORD("{"));
14494
- SUBRULE(triplesBlock, ast.triples, void 0);
14514
+ SUBRULE(triplesBlock, ast.triples);
14495
14515
  F2.printFilter(ast, () => PRINT_WORD("}"));
14496
14516
  }
14497
14517
  };
14498
14518
 
14499
- // lib/SparqlParser.ts
14519
+ // lib/grammar/index.ts
14520
+ var queryOrUpdate = {
14521
+ name: "queryOrUpdate",
14522
+ impl: ({ ACTION, SUBRULE, OR1, OR2, MANY, OPTION1, CONSUME, SUBRULE2 }) => (C) => {
14523
+ const prologueValues = SUBRULE(prologue);
14524
+ return OR1([
14525
+ { ALT: () => {
14526
+ const subType = OR2([
14527
+ { ALT: () => SUBRULE(selectQuery) },
14528
+ { ALT: () => SUBRULE(constructQuery) },
14529
+ { ALT: () => SUBRULE(describeQuery) },
14530
+ { ALT: () => SUBRULE(askQuery) }
14531
+ ]);
14532
+ const values3 = SUBRULE(valuesClause);
14533
+ return ACTION(() => ({
14534
+ context: prologueValues,
14535
+ ...subType,
14536
+ type: "query",
14537
+ ...values3 && { values: values3 },
14538
+ loc: C.factory.sourceLocation(
14539
+ prologueValues.at(0),
14540
+ subType,
14541
+ values3
14542
+ )
14543
+ }));
14544
+ } },
14545
+ { ALT: () => {
14546
+ const updates = [];
14547
+ updates.push({ context: prologueValues });
14548
+ let parsedSemi = true;
14549
+ MANY({
14550
+ GATE: () => parsedSemi,
14551
+ DEF: () => {
14552
+ parsedSemi = false;
14553
+ updates.at(-1).operation = SUBRULE(update1);
14554
+ OPTION1(() => {
14555
+ CONSUME(symbols_exports.semi);
14556
+ parsedSemi = true;
14557
+ const innerPrologue = SUBRULE2(prologue);
14558
+ updates.push({ context: innerPrologue });
14559
+ });
14560
+ }
14561
+ });
14562
+ return ACTION(() => {
14563
+ const update2 = {
14564
+ type: "update",
14565
+ updates,
14566
+ loc: C.factory.sourceLocation(
14567
+ ...updates[0].context,
14568
+ updates[0].operation,
14569
+ ...updates.at(-1).context,
14570
+ updates.at(-1)?.operation
14571
+ )
14572
+ };
14573
+ updateNoReuseBlankNodeLabels(update2);
14574
+ return update2;
14575
+ });
14576
+ } }
14577
+ ]);
14578
+ }
14579
+ };
14580
+
14581
+ // lib/MinimalSparqlParser.ts
14500
14582
  function completeParseContext(context) {
14501
14583
  return {
14502
14584
  factory: context.factory ?? new Factory(),
@@ -14508,16 +14590,16 @@ function completeParseContext(context) {
14508
14590
  skipValidation: context.skipValidation ?? false
14509
14591
  };
14510
14592
  }
14511
- var SparqlParser = class {
14593
+ var MinimalSparqlParser = class {
14512
14594
  constructor(parser) {
14513
14595
  this.parser = parser;
14514
- this.F = new Factory();
14515
14596
  }
14597
+ F = new Factory();
14516
14598
  parse(query2, context = {}) {
14517
- return this.parser.queryOrUpdate(query2, completeParseContext(context), void 0);
14599
+ return this.parser.queryOrUpdate(query2, completeParseContext(context));
14518
14600
  }
14519
14601
  parsePath(query2, context = {}) {
14520
- const result = this.parser.path(query2, completeParseContext(context), void 0);
14602
+ const result = this.parser.path(query2, completeParseContext(context));
14521
14603
  if (this.F.isPathPure(result)) {
14522
14604
  return {
14523
14605
  ...result,
@@ -14527,29 +14609,6 @@ var SparqlParser = class {
14527
14609
  return result;
14528
14610
  }
14529
14611
  };
14530
-
14531
- // lib/utils.ts
14532
- function sparqlCodepointEscape(input) {
14533
- const sanitizedInput = input.replaceAll(
14534
- /\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{8})/gu,
14535
- (_, unicode4, unicode8) => {
14536
- if (unicode4) {
14537
- const charCode2 = Number.parseInt(unicode4, 16);
14538
- return String.fromCodePoint(charCode2);
14539
- }
14540
- const charCode = Number.parseInt(unicode8, 16);
14541
- if (charCode < 65535) {
14542
- return String.fromCodePoint(charCode);
14543
- }
14544
- const substractedCharCode = charCode - 65536;
14545
- return String.fromCodePoint(55296 + (substractedCharCode >> 10), 56320 + (substractedCharCode & 1023));
14546
- }
14547
- );
14548
- if (/[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)/u.test(sanitizedInput)) {
14549
- throw new Error(`Invalid unicode codepoint of surrogate pair without corresponding codepoint`);
14550
- }
14551
- return sanitizedInput;
14552
- }
14553
14612
  /*! Bundled license information:
14554
14613
 
14555
14614
  lodash-es/lodash.js: