@traqula/generator-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.
package/lib/index.cjs CHANGED
@@ -156,92 +156,8 @@ var CoreFactory = class {
156
156
  var DynamicGenerator = class {
157
157
  constructor(rules) {
158
158
  this.rules = rules;
159
- this.factory = new CoreFactory();
160
- this.__context = void 0;
161
- this.origSource = "";
162
- this.generatedUntil = 0;
163
- this.stringBuilder = [];
164
- this.subrule = (cstDef, ast, arg) => {
165
- const def = this.rules[cstDef.name];
166
- if (!def) {
167
- throw new Error(`Rule ${cstDef.name} not found`);
168
- }
169
- const generate = () => def.gImpl({
170
- SUBRULE: this.subrule,
171
- PRINT: this.print,
172
- PRINT_SPACE_LEFT: this.printSpaceLeft,
173
- PRINT_WORD: this.printWord,
174
- PRINT_WORDS: this.printWords,
175
- CATCHUP: this.catchup,
176
- HANDLE_LOC: this.handleLoc
177
- })(ast, this.getSafeContext(), arg);
178
- if (this.factory.isLocalized(ast)) {
179
- this.handleLoc(ast, generate);
180
- } else {
181
- generate();
182
- }
183
- };
184
- this.handleLoc = (localized, handle) => {
185
- if (this.factory.isSourceLocationNoMaterialize(localized.loc)) {
186
- return;
187
- }
188
- if (this.factory.isSourceLocationStringReplace(localized.loc)) {
189
- this.catchup(localized.loc.start);
190
- this.print(localized.loc.newSource);
191
- this.generatedUntil = localized.loc.end;
192
- return;
193
- }
194
- if (this.factory.isSourceLocationNodeReplace(localized.loc)) {
195
- this.catchup(localized.loc.start);
196
- this.generatedUntil = localized.loc.end;
197
- }
198
- if (this.factory.isSourceLocationSource(localized.loc)) {
199
- this.catchup(localized.loc.start);
200
- }
201
- const ret = handle();
202
- if (this.factory.isSourceLocationSource(localized.loc)) {
203
- this.catchup(localized.loc.end);
204
- }
205
- return ret;
206
- };
207
- this.catchup = (until) => {
208
- const start = this.generatedUntil;
209
- if (start < until) {
210
- this.print(this.origSource.slice(start, until));
211
- }
212
- this.generatedUntil = Math.max(this.generatedUntil, until);
213
- };
214
- this.print = (...args) => {
215
- const pureArgs = args.filter((x) => x.length > 0);
216
- if (pureArgs.length > 0) {
217
- const [head2, ...tail] = pureArgs;
218
- if (this.expectsSpace) {
219
- this.expectsSpace = false;
220
- const blanks = /* @__PURE__ */ new Set(["\n", " ", " "]);
221
- if (this.stringBuilder.length > 0 && !(blanks.has(head2[0]) || blanks.has(this.stringBuilder.at(-1).at(-1)))) {
222
- this.stringBuilder.push(" ");
223
- }
224
- }
225
- this.stringBuilder.push(head2);
226
- this.stringBuilder.push(...tail);
227
- }
228
- };
229
- this.printWord = (...args) => {
230
- this.expectsSpace = true;
231
- this.print(...args);
232
- this.expectsSpace = true;
233
- };
234
- this.printSpaceLeft = (...args) => {
235
- this.expectsSpace = true;
236
- this.print(...args);
237
- };
238
- this.printWords = (...args) => {
239
- for (const arg of args) {
240
- this.printWord(arg);
241
- }
242
- };
243
159
  for (const rule of Object.values(rules)) {
244
- this[rule.name] = (input, context, args) => {
160
+ this[rule.name] = ((input, context, args) => {
245
161
  this.expectsSpace = false;
246
162
  this.stringBuilder.length = 0;
247
163
  this.origSource = context.origSource;
@@ -250,15 +166,100 @@ var DynamicGenerator = class {
250
166
  this.subrule(rule, input, args);
251
167
  this.catchup(this.origSource.length);
252
168
  return this.stringBuilder.join("");
253
- };
169
+ });
254
170
  }
255
171
  }
172
+ factory = new CoreFactory();
173
+ __context = void 0;
174
+ origSource = "";
175
+ generatedUntil = 0;
176
+ expectsSpace;
177
+ stringBuilder = [];
256
178
  setContext(context) {
257
179
  this.__context = context;
258
180
  }
259
181
  getSafeContext() {
260
182
  return this.__context;
261
183
  }
184
+ subrule = (cstDef, ast, ...arg) => {
185
+ const def = this.rules[cstDef.name];
186
+ if (!def) {
187
+ throw new Error(`Rule ${cstDef.name} not found`);
188
+ }
189
+ const generate = () => def.gImpl({
190
+ SUBRULE: this.subrule,
191
+ PRINT: this.print,
192
+ PRINT_SPACE_LEFT: this.printSpaceLeft,
193
+ PRINT_WORD: this.printWord,
194
+ PRINT_WORDS: this.printWords,
195
+ CATCHUP: this.catchup,
196
+ HANDLE_LOC: this.handleLoc
197
+ })(ast, this.getSafeContext(), ...arg);
198
+ if (this.factory.isLocalized(ast)) {
199
+ this.handleLoc(ast, generate);
200
+ } else {
201
+ generate();
202
+ }
203
+ };
204
+ handleLoc = (localized, handle) => {
205
+ if (this.factory.isSourceLocationNoMaterialize(localized.loc)) {
206
+ return;
207
+ }
208
+ if (this.factory.isSourceLocationStringReplace(localized.loc)) {
209
+ this.catchup(localized.loc.start);
210
+ this.print(localized.loc.newSource);
211
+ this.generatedUntil = localized.loc.end;
212
+ return;
213
+ }
214
+ if (this.factory.isSourceLocationNodeReplace(localized.loc)) {
215
+ this.catchup(localized.loc.start);
216
+ this.generatedUntil = localized.loc.end;
217
+ }
218
+ if (this.factory.isSourceLocationSource(localized.loc)) {
219
+ this.catchup(localized.loc.start);
220
+ }
221
+ const ret = handle();
222
+ if (this.factory.isSourceLocationSource(localized.loc)) {
223
+ this.catchup(localized.loc.end);
224
+ }
225
+ return ret;
226
+ };
227
+ catchup = (until) => {
228
+ const start = this.generatedUntil;
229
+ if (start < until) {
230
+ this.print(this.origSource.slice(start, until));
231
+ }
232
+ this.generatedUntil = Math.max(this.generatedUntil, until);
233
+ };
234
+ print = (...args) => {
235
+ const pureArgs = args.filter((x) => x.length > 0);
236
+ if (pureArgs.length > 0) {
237
+ const [head2, ...tail] = pureArgs;
238
+ if (this.expectsSpace) {
239
+ this.expectsSpace = false;
240
+ const blanks = /* @__PURE__ */ new Set(["\n", " ", " "]);
241
+ if (this.stringBuilder.length > 0 && !(blanks.has(head2[0]) || blanks.has(this.stringBuilder.at(-1).at(-1)))) {
242
+ this.stringBuilder.push(" ");
243
+ }
244
+ }
245
+ this.stringBuilder.push(head2);
246
+ this.stringBuilder.push(...tail);
247
+ }
248
+ };
249
+ printWord = (...args) => {
250
+ this.expectsSpace = true;
251
+ this.print(...args);
252
+ this.expectsSpace = true;
253
+ };
254
+ printSpaceLeft = (...args) => {
255
+ this.expectsSpace = true;
256
+ this.print(...args);
257
+ };
258
+ printWords = (...args) => {
259
+ for (const arg of args) {
260
+ this.printWord(arg);
261
+ }
262
+ };
262
263
  };
263
264
 
264
265
  // ../../packages/core/lib/generator-builder/generatorBuilder.ts
@@ -276,6 +277,7 @@ var GeneratorBuilder = class _GeneratorBuilder {
276
277
  }
277
278
  return new _GeneratorBuilder(listToRuleDefMap(start));
278
279
  }
280
+ rules;
279
281
  constructor(startRules) {
280
282
  this.rules = startRules;
281
283
  }
@@ -558,10 +560,10 @@ var coreJsData = root_default["__core-js_shared__"];
558
560
  var coreJsData_default = coreJsData;
559
561
 
560
562
  // ../../node_modules/lodash-es/_isMasked.js
561
- var maskSrcKey = function() {
563
+ var maskSrcKey = (function() {
562
564
  var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
563
565
  return uid ? "Symbol(src)_1." + uid : "";
564
- }();
566
+ })();
565
567
  function isMasked(func) {
566
568
  return !!maskSrcKey && maskSrcKey in func;
567
569
  }
@@ -623,7 +625,7 @@ var WeakMap_default = WeakMap;
623
625
 
624
626
  // ../../node_modules/lodash-es/_baseCreate.js
625
627
  var objectCreate = Object.create;
626
- var baseCreate = /* @__PURE__ */ function() {
628
+ var baseCreate = /* @__PURE__ */ (function() {
627
629
  function object2() {
628
630
  }
629
631
  return function(proto) {
@@ -638,7 +640,7 @@ var baseCreate = /* @__PURE__ */ function() {
638
640
  object2.prototype = void 0;
639
641
  return result;
640
642
  };
641
- }();
643
+ })();
642
644
  var baseCreate_default = baseCreate;
643
645
 
644
646
  // ../../node_modules/lodash-es/_apply.js
@@ -703,14 +705,14 @@ function constant(value) {
703
705
  var constant_default = constant;
704
706
 
705
707
  // ../../node_modules/lodash-es/_defineProperty.js
706
- var defineProperty = function() {
708
+ var defineProperty = (function() {
707
709
  try {
708
710
  var func = getNative_default(Object, "defineProperty");
709
711
  func({}, "", {});
710
712
  return func;
711
713
  } catch (e) {
712
714
  }
713
- }();
715
+ })();
714
716
  var defineProperty_default = defineProperty;
715
717
 
716
718
  // ../../node_modules/lodash-es/_baseSetToString.js
@@ -948,9 +950,9 @@ var baseIsArguments_default = baseIsArguments;
948
950
  var objectProto6 = Object.prototype;
949
951
  var hasOwnProperty4 = objectProto6.hasOwnProperty;
950
952
  var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
951
- var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
953
+ var isArguments = baseIsArguments_default(/* @__PURE__ */ (function() {
952
954
  return arguments;
953
- }()) ? baseIsArguments_default : function(value) {
955
+ })()) ? baseIsArguments_default : function(value) {
954
956
  return isObjectLike_default(value) && hasOwnProperty4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
955
957
  };
956
958
  var isArguments_default = isArguments;
@@ -1016,7 +1018,7 @@ var freeExports2 = typeof exports == "object" && exports && !exports.nodeType &&
1016
1018
  var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
1017
1019
  var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
1018
1020
  var freeProcess = moduleExports2 && freeGlobal_default.process;
1019
- var nodeUtil = function() {
1021
+ var nodeUtil = (function() {
1020
1022
  try {
1021
1023
  var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
1022
1024
  if (types) {
@@ -1025,7 +1027,7 @@ var nodeUtil = function() {
1025
1027
  return freeProcess && freeProcess.binding && freeProcess.binding("util");
1026
1028
  } catch (e) {
1027
1029
  }
1028
- }();
1030
+ })();
1029
1031
  var nodeUtil_default = nodeUtil;
1030
1032
 
1031
1033
  // ../../node_modules/lodash-es/isTypedArray.js
@@ -9570,6 +9572,7 @@ applyMixins(Parser, [
9570
9572
 
9571
9573
  // ../../packages/core/lib/lexer-builder/LexerBuilder.ts
9572
9574
  var LexerBuilder = class _LexerBuilder {
9575
+ tokens;
9573
9576
  static create(starter) {
9574
9577
  return new _LexerBuilder(starter);
9575
9578
  }
@@ -9910,6 +9913,7 @@ __export(grammar_exports, {
9910
9913
  quads: () => quads,
9911
9914
  quadsNotTriples: () => quadsNotTriples,
9912
9915
  query: () => query,
9916
+ queryOrUpdate: () => queryOrUpdate,
9913
9917
  queryUnit: () => queryUnit,
9914
9918
  rdfLiteral: () => rdfLiteral,
9915
9919
  regexExpression: () => regexExpression,
@@ -9948,10 +9952,10 @@ __export(grammar_exports, {
9948
9952
  whereClause: () => whereClause
9949
9953
  });
9950
9954
 
9951
- // ../../packages/rules-sparql-1-1/lib/lexer/BuildinCalls.ts
9952
- var BuildinCalls_exports = {};
9953
- __export(BuildinCalls_exports, {
9954
- BuildInCalls: () => BuildInCalls,
9955
+ // ../../packages/rules-sparql-1-1/lib/lexer/BuiltInCalls.ts
9956
+ var BuiltInCalls_exports = {};
9957
+ __export(BuiltInCalls_exports, {
9958
+ BuiltInCalls: () => BuiltInCalls,
9955
9959
  abs: () => abs,
9956
9960
  allBuiltInCalls: () => allBuiltInCalls,
9957
9961
  avg: () => avg,
@@ -10015,70 +10019,70 @@ __export(BuildinCalls_exports, {
10015
10019
  uuid: () => uuid,
10016
10020
  year: () => year
10017
10021
  });
10018
- var BuildInCalls = /* @__PURE__ */ ((BuildInCalls2) => {
10019
- BuildInCalls2["Str"] = "builtInStr";
10020
- BuildInCalls2["Lang"] = "builtInLang";
10021
- BuildInCalls2["Langmatches"] = "builtInLangmatches";
10022
- BuildInCalls2["Datatype"] = "builtInDatatype";
10023
- BuildInCalls2["Bound"] = "builtInBound";
10024
- BuildInCalls2["Iri"] = "builtInIri";
10025
- BuildInCalls2["Uri"] = "builtInUri";
10026
- BuildInCalls2["Bnode"] = "builtInBnode";
10027
- BuildInCalls2["Rand"] = "builtInRand";
10028
- BuildInCalls2["Abs"] = "builtInAbs";
10029
- BuildInCalls2["Ceil"] = "builtInCeil";
10030
- BuildInCalls2["Floor"] = "builtInFloor";
10031
- BuildInCalls2["Round"] = "builtInRound";
10032
- BuildInCalls2["Concat"] = "builtInConcat";
10033
- BuildInCalls2["Strlen"] = "builtInStrlen";
10034
- BuildInCalls2["Ucase"] = "builtInUcase";
10035
- BuildInCalls2["Lcase"] = "builtInLcase";
10036
- BuildInCalls2["Encode_for_uri"] = "builtInEncode_for_uri";
10037
- BuildInCalls2["Contains"] = "builtInContains";
10038
- BuildInCalls2["Strstarts"] = "builtInStrstarts";
10039
- BuildInCalls2["Strends"] = "builtInStrends";
10040
- BuildInCalls2["Strbefore"] = "builtInStrbefore";
10041
- BuildInCalls2["Strafter"] = "builtInStrafter";
10042
- BuildInCalls2["Year"] = "builtInYear";
10043
- BuildInCalls2["Month"] = "builtInMonth";
10044
- BuildInCalls2["Day"] = "builtInDay";
10045
- BuildInCalls2["Hours"] = "builtInHours";
10046
- BuildInCalls2["Minutes"] = "builtInMinutes";
10047
- BuildInCalls2["Seconds"] = "builtInSeconds";
10048
- BuildInCalls2["Timezone"] = "builtInTimezone";
10049
- BuildInCalls2["Tz"] = "builtInTz";
10050
- BuildInCalls2["Now"] = "builtInNow";
10051
- BuildInCalls2["Uuid"] = "builtInUuid";
10052
- BuildInCalls2["Struuid"] = "builtInStruuid";
10053
- BuildInCalls2["Md5"] = "builtInMd5";
10054
- BuildInCalls2["Sha1"] = "builtInSha1";
10055
- BuildInCalls2["Sha256"] = "builtInSha256";
10056
- BuildInCalls2["Sha384"] = "builtInSha384";
10057
- BuildInCalls2["Sha512"] = "builtInSha512";
10058
- BuildInCalls2["Coalesce"] = "builtInCoalesce";
10059
- BuildInCalls2["If"] = "builtInIf";
10060
- BuildInCalls2["Strlang"] = "builtInStrlang";
10061
- BuildInCalls2["Strdt"] = "builtInStrdt";
10062
- BuildInCalls2["Sameterm"] = "builtInSameterm";
10063
- BuildInCalls2["Isiri"] = "builtInIsiri";
10064
- BuildInCalls2["Isuri"] = "builtInIsuri";
10065
- BuildInCalls2["Isblank"] = "builtInIsblank";
10066
- BuildInCalls2["Isliteral"] = "builtInIsliteral";
10067
- BuildInCalls2["Isnumeric"] = "builtInIsnumeric";
10068
- BuildInCalls2["Regex"] = "builtInRegex";
10069
- BuildInCalls2["Substr"] = "builtInSubstr";
10070
- BuildInCalls2["Replace"] = "builtInReplace";
10071
- BuildInCalls2["Exists"] = "builtInExists";
10072
- BuildInCalls2["Notexists"] = "builtInNotexists";
10073
- BuildInCalls2["Count"] = "builtInCount";
10074
- BuildInCalls2["Sum"] = "builtInSum";
10075
- BuildInCalls2["Min"] = "builtInMin";
10076
- BuildInCalls2["Max"] = "builtInMax";
10077
- BuildInCalls2["Avg"] = "builtInAvg";
10078
- BuildInCalls2["Sample"] = "builtInSample";
10079
- BuildInCalls2["Group_concat"] = "builtInGroup_concat";
10080
- return BuildInCalls2;
10081
- })(BuildInCalls || {});
10022
+ var BuiltInCalls = /* @__PURE__ */ ((BuiltInCalls2) => {
10023
+ BuiltInCalls2["Str"] = "builtInStr";
10024
+ BuiltInCalls2["Lang"] = "builtInLang";
10025
+ BuiltInCalls2["Langmatches"] = "builtInLangmatches";
10026
+ BuiltInCalls2["Datatype"] = "builtInDatatype";
10027
+ BuiltInCalls2["Bound"] = "builtInBound";
10028
+ BuiltInCalls2["Iri"] = "builtInIri";
10029
+ BuiltInCalls2["Uri"] = "builtInUri";
10030
+ BuiltInCalls2["Bnode"] = "builtInBnode";
10031
+ BuiltInCalls2["Rand"] = "builtInRand";
10032
+ BuiltInCalls2["Abs"] = "builtInAbs";
10033
+ BuiltInCalls2["Ceil"] = "builtInCeil";
10034
+ BuiltInCalls2["Floor"] = "builtInFloor";
10035
+ BuiltInCalls2["Round"] = "builtInRound";
10036
+ BuiltInCalls2["Concat"] = "builtInConcat";
10037
+ BuiltInCalls2["Strlen"] = "builtInStrlen";
10038
+ BuiltInCalls2["Ucase"] = "builtInUcase";
10039
+ BuiltInCalls2["Lcase"] = "builtInLcase";
10040
+ BuiltInCalls2["Encode_for_uri"] = "builtInEncode_for_uri";
10041
+ BuiltInCalls2["Contains"] = "builtInContains";
10042
+ BuiltInCalls2["Strstarts"] = "builtInStrstarts";
10043
+ BuiltInCalls2["Strends"] = "builtInStrends";
10044
+ BuiltInCalls2["Strbefore"] = "builtInStrbefore";
10045
+ BuiltInCalls2["Strafter"] = "builtInStrafter";
10046
+ BuiltInCalls2["Year"] = "builtInYear";
10047
+ BuiltInCalls2["Month"] = "builtInMonth";
10048
+ BuiltInCalls2["Day"] = "builtInDay";
10049
+ BuiltInCalls2["Hours"] = "builtInHours";
10050
+ BuiltInCalls2["Minutes"] = "builtInMinutes";
10051
+ BuiltInCalls2["Seconds"] = "builtInSeconds";
10052
+ BuiltInCalls2["Timezone"] = "builtInTimezone";
10053
+ BuiltInCalls2["Tz"] = "builtInTz";
10054
+ BuiltInCalls2["Now"] = "builtInNow";
10055
+ BuiltInCalls2["Uuid"] = "builtInUuid";
10056
+ BuiltInCalls2["Struuid"] = "builtInStruuid";
10057
+ BuiltInCalls2["Md5"] = "builtInMd5";
10058
+ BuiltInCalls2["Sha1"] = "builtInSha1";
10059
+ BuiltInCalls2["Sha256"] = "builtInSha256";
10060
+ BuiltInCalls2["Sha384"] = "builtInSha384";
10061
+ BuiltInCalls2["Sha512"] = "builtInSha512";
10062
+ BuiltInCalls2["Coalesce"] = "builtInCoalesce";
10063
+ BuiltInCalls2["If"] = "builtInIf";
10064
+ BuiltInCalls2["Strlang"] = "builtInStrlang";
10065
+ BuiltInCalls2["Strdt"] = "builtInStrdt";
10066
+ BuiltInCalls2["Sameterm"] = "builtInSameterm";
10067
+ BuiltInCalls2["Isiri"] = "builtInIsiri";
10068
+ BuiltInCalls2["Isuri"] = "builtInIsuri";
10069
+ BuiltInCalls2["Isblank"] = "builtInIsblank";
10070
+ BuiltInCalls2["Isliteral"] = "builtInIsliteral";
10071
+ BuiltInCalls2["Isnumeric"] = "builtInIsnumeric";
10072
+ BuiltInCalls2["Regex"] = "builtInRegex";
10073
+ BuiltInCalls2["Substr"] = "builtInSubstr";
10074
+ BuiltInCalls2["Replace"] = "builtInReplace";
10075
+ BuiltInCalls2["Exists"] = "builtInExists";
10076
+ BuiltInCalls2["Notexists"] = "builtInNotexists";
10077
+ BuiltInCalls2["Count"] = "builtInCount";
10078
+ BuiltInCalls2["Sum"] = "builtInSum";
10079
+ BuiltInCalls2["Min"] = "builtInMin";
10080
+ BuiltInCalls2["Max"] = "builtInMax";
10081
+ BuiltInCalls2["Avg"] = "builtInAvg";
10082
+ BuiltInCalls2["Sample"] = "builtInSample";
10083
+ BuiltInCalls2["Group_concat"] = "builtInGroup_concat";
10084
+ return BuiltInCalls2;
10085
+ })(BuiltInCalls || {});
10082
10086
  function capitalize(string2) {
10083
10087
  return string2.charAt(0).toUpperCase() + string2.slice(1);
10084
10088
  }
@@ -10582,7 +10586,7 @@ var allBaseTokens = LexerBuilder.create().add(
10582
10586
  notIn,
10583
10587
  separator
10584
10588
  );
10585
- 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);
10589
+ 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);
10586
10590
 
10587
10591
  // ../../packages/rules-sparql-1-1/lib/factoryMixins/ContextFactory.ts
10588
10592
  var nodeType = "contextDef";
@@ -11027,10 +11031,7 @@ function SolutionModifiersFactoryMixin(Base) {
11027
11031
  var nodeType8 = "term";
11028
11032
  function TermFactoryMixin(Base) {
11029
11033
  return class TermFactory extends Base {
11030
- constructor() {
11031
- super(...arguments);
11032
- this.__blankNodeCounter = 0;
11033
- }
11034
+ __blankNodeCounter = 0;
11034
11035
  resetBlankNodeCounter() {
11035
11036
  this.__blankNodeCounter = 0;
11036
11037
  }
@@ -11533,7 +11534,7 @@ function stringEscapedLexical(str2) {
11533
11534
  var rdfLiteral = {
11534
11535
  name: "rdfLiteral",
11535
11536
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION, OR }) => (C) => {
11536
- const value = SUBRULE1(string, void 0);
11537
+ const value = SUBRULE1(string);
11537
11538
  return OPTION(() => OR([
11538
11539
  { ALT: () => {
11539
11540
  const lang2 = CONSUME(terminals_exports.langTag);
@@ -11545,7 +11546,7 @@ var rdfLiteral = {
11545
11546
  } },
11546
11547
  { ALT: () => {
11547
11548
  CONSUME(symbols_exports.hathat);
11548
- const iriVal = SUBRULE1(iri2, void 0);
11549
+ const iriVal = SUBRULE1(iri2);
11549
11550
  return ACTION(() => C.factory.literalTerm(
11550
11551
  C.factory.sourceLocation(value, iriVal),
11551
11552
  value.value,
@@ -11561,7 +11562,7 @@ var rdfLiteral = {
11561
11562
  factory.printFilter(ast, () => PRINT("@", ast.langOrIri));
11562
11563
  } else {
11563
11564
  factory.printFilter(ast, () => PRINT("^^"));
11564
- SUBRULE(iri2, ast.langOrIri, void 0);
11565
+ SUBRULE(iri2, ast.langOrIri);
11565
11566
  }
11566
11567
  }
11567
11568
  }
@@ -11569,9 +11570,9 @@ var rdfLiteral = {
11569
11570
  var numericLiteral = {
11570
11571
  name: "numericLiteral",
11571
11572
  impl: ({ SUBRULE, OR }) => () => OR([
11572
- { ALT: () => SUBRULE(numericLiteralUnsigned, void 0) },
11573
- { ALT: () => SUBRULE(numericLiteralPositive, void 0) },
11574
- { ALT: () => SUBRULE(numericLiteralNegative, void 0) }
11573
+ { ALT: () => SUBRULE(numericLiteralUnsigned) },
11574
+ { ALT: () => SUBRULE(numericLiteralPositive) },
11575
+ { ALT: () => SUBRULE(numericLiteralNegative) }
11575
11576
  ])
11576
11577
  };
11577
11578
  var numericLiteralUnsigned = {
@@ -11679,10 +11680,10 @@ var string = {
11679
11680
  var iri2 = {
11680
11681
  name: "iri",
11681
11682
  impl: ({ SUBRULE, OR }) => () => OR([
11682
- { ALT: () => SUBRULE(iriFull, void 0) },
11683
- { ALT: () => SUBRULE(prefixedName, void 0) }
11683
+ { ALT: () => SUBRULE(iriFull) },
11684
+ { ALT: () => SUBRULE(prefixedName) }
11684
11685
  ]),
11685
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast, void 0) : SUBRULE(iriFull, ast, void 0)
11686
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast) : SUBRULE(iriFull, ast)
11686
11687
  };
11687
11688
  var iriFull = {
11688
11689
  name: "iriFull",
@@ -11746,93 +11747,25 @@ var verbA = {
11746
11747
  }
11747
11748
  };
11748
11749
 
11749
- // ../../packages/rules-sparql-1-1/lib/grammar/dataSetClause.ts
11750
- function datasetClauseUsing(name, token) {
11751
- return {
11752
- name,
11753
- impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
11754
- const start = CONSUME(token);
11755
- return OR([
11756
- { ALT: () => {
11757
- const iri3 = SUBRULE(defaultGraphClause, void 0);
11758
- return ACTION(() => C.factory.wrap({ clauseType: "default", value: iri3 }, C.factory.sourceLocation(start, iri3)));
11759
- } },
11760
- { ALT: () => {
11761
- const namedClause = SUBRULE(namedGraphClause, void 0);
11762
- return ACTION(() => C.factory.wrap({
11763
- clauseType: "named",
11764
- value: namedClause.val
11765
- }, C.factory.sourceLocation(start, namedClause)));
11766
- } }
11767
- ]);
11768
- }
11769
- };
11770
- }
11771
- var datasetClause = datasetClauseUsing("datasetClause", from);
11772
- var defaultGraphClause = {
11773
- name: "defaultGraphClause",
11774
- impl: ({ SUBRULE }) => () => SUBRULE(sourceSelector, void 0)
11775
- };
11776
- var usingClause2 = datasetClauseUsing("usingClause", usingClause);
11777
- function datasetClauseUsingStar(name, subRule, fromUsing) {
11778
- return {
11779
- name,
11780
- impl: ({ ACTION, MANY, SUBRULE }) => (C) => {
11781
- const clauses = [];
11782
- MANY(() => {
11783
- const clause = SUBRULE(subRule, void 0);
11784
- clauses.push(clause);
11785
- });
11786
- return ACTION(() => C.factory.datasetClauses(
11787
- clauses.map((clause) => clause.val),
11788
- C.factory.sourceLocation(...clauses)
11789
- ));
11790
- },
11791
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11792
- for (const clause of ast.clauses) {
11793
- F2.printFilter(ast, () => PRINT_WORD(fromUsing));
11794
- if (clause.clauseType === "named") {
11795
- F2.printFilter(ast, () => PRINT_WORD("NAMED"));
11796
- }
11797
- SUBRULE(iri2, clause.value, void 0);
11798
- }
11799
- }
11800
- };
11801
- }
11802
- var datasetClauseStar = datasetClauseUsingStar("datasetClauses", datasetClause, "FROM");
11803
- var usingClauseStar = datasetClauseUsingStar("usingClauses", usingClause2, "USING");
11804
- var namedGraphClause = {
11805
- name: "namedGraphClause",
11806
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11807
- const named2 = CONSUME(graph_exports.named);
11808
- const iri3 = SUBRULE(sourceSelector, void 0);
11809
- return ACTION(() => C.factory.wrap(iri3, C.factory.sourceLocation(named2, iri3)));
11810
- }
11811
- };
11812
- var sourceSelector = {
11813
- name: "sourceSelector",
11814
- impl: ({ SUBRULE }) => () => SUBRULE(iri2, void 0)
11815
- };
11816
-
11817
11750
  // ../../packages/rules-sparql-1-1/lib/grammar/general.ts
11818
11751
  var prologue = {
11819
11752
  name: "prologue",
11820
11753
  impl: ({ SUBRULE, MANY, OR }) => () => {
11821
11754
  const result = [];
11822
11755
  MANY(() => OR([
11823
- { ALT: () => result.push(SUBRULE(baseDecl2, void 0)) },
11756
+ { ALT: () => result.push(SUBRULE(baseDecl2)) },
11824
11757
  // TODO: the [spec](https://www.w3.org/TR/sparql11-query/#iriRefs) says you cannot redefine prefixes.
11825
11758
  // We might need to check this.
11826
- { ALT: () => result.push(SUBRULE(prefixDecl2, void 0)) }
11759
+ { ALT: () => result.push(SUBRULE(prefixDecl2)) }
11827
11760
  ]));
11828
11761
  return result;
11829
11762
  },
11830
11763
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11831
11764
  for (const context of ast) {
11832
11765
  if (F2.isContextDefinitionBase(context)) {
11833
- SUBRULE(baseDecl2, context, void 0);
11766
+ SUBRULE(baseDecl2, context);
11834
11767
  } else if (F2.isContextDefinitionPrefix(context)) {
11835
- SUBRULE(prefixDecl2, context, void 0);
11768
+ SUBRULE(prefixDecl2, context);
11836
11769
  }
11837
11770
  }
11838
11771
  }
@@ -11841,12 +11774,12 @@ var baseDecl2 = {
11841
11774
  name: "baseDecl",
11842
11775
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11843
11776
  const base = CONSUME(baseDecl);
11844
- const val = SUBRULE(iriFull, void 0);
11777
+ const val = SUBRULE(iriFull);
11845
11778
  return ACTION(() => C.factory.contextDefinitionBase(C.factory.sourceLocation(base, val), val));
11846
11779
  },
11847
11780
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11848
11781
  F2.printFilter(ast, () => PRINT_WORD("BASE"));
11849
- SUBRULE(iri2, ast.value, void 0);
11782
+ SUBRULE(iri2, ast.value);
11850
11783
  }
11851
11784
  };
11852
11785
  var prefixDecl2 = {
@@ -11854,41 +11787,41 @@ var prefixDecl2 = {
11854
11787
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11855
11788
  const prefix = CONSUME(prefixDecl);
11856
11789
  const name = CONSUME(terminals_exports.pNameNs).image.slice(0, -1);
11857
- const value = SUBRULE(iriFull, void 0);
11790
+ const value = SUBRULE(iriFull);
11858
11791
  return ACTION(() => C.factory.contextDefinitionPrefix(C.factory.sourceLocation(prefix, value), name, value));
11859
11792
  },
11860
11793
  gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { factory: F2 }) => {
11861
11794
  F2.printFilter(ast, () => {
11862
11795
  PRINT_WORDS("PREFIX", `${ast.key}:`);
11863
11796
  });
11864
- SUBRULE(iri2, ast.value, void 0);
11797
+ SUBRULE(iri2, ast.value);
11865
11798
  }
11866
11799
  };
11867
11800
  var verb = {
11868
11801
  name: "verb",
11869
11802
  impl: ({ SUBRULE, OR }) => () => OR([
11870
- { ALT: () => SUBRULE(varOrIri, void 0) },
11871
- { ALT: () => SUBRULE(verbA, void 0) }
11803
+ { ALT: () => SUBRULE(varOrIri) },
11804
+ { ALT: () => SUBRULE(verbA) }
11872
11805
  ])
11873
11806
  };
11874
11807
  var varOrTerm = {
11875
11808
  name: "varOrTerm",
11876
11809
  impl: ({ SUBRULE, OR }) => (C) => OR([
11877
- { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_, void 0) },
11878
- { ALT: () => SUBRULE(graphTerm, void 0) }
11810
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
11811
+ { ALT: () => SUBRULE(graphTerm) }
11879
11812
  ]),
11880
11813
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11881
11814
  if (F2.isTermVariable(ast)) {
11882
- return SUBRULE(var_, ast, void 0);
11815
+ return SUBRULE(var_, ast);
11883
11816
  }
11884
- return SUBRULE(graphTerm, ast, void 0);
11817
+ return SUBRULE(graphTerm, ast);
11885
11818
  }
11886
11819
  };
11887
11820
  var varOrIri = {
11888
11821
  name: "varOrIri",
11889
11822
  impl: ({ SUBRULE, OR }) => (C) => OR([
11890
- { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_, void 0) },
11891
- { ALT: () => SUBRULE(iri2, void 0) }
11823
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
11824
+ { ALT: () => SUBRULE(iri2) }
11892
11825
  ])
11893
11826
  };
11894
11827
  var var_ = {
@@ -11907,11 +11840,11 @@ var var_ = {
11907
11840
  var graphTerm = {
11908
11841
  name: "graphTerm",
11909
11842
  impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => OR([
11910
- { ALT: () => SUBRULE(iri2, void 0) },
11911
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
11912
- { ALT: () => SUBRULE(numericLiteral, void 0) },
11913
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
11914
- { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode, void 0) },
11843
+ { ALT: () => SUBRULE(iri2) },
11844
+ { ALT: () => SUBRULE(rdfLiteral) },
11845
+ { ALT: () => SUBRULE(numericLiteral) },
11846
+ { ALT: () => SUBRULE(booleanLiteral) },
11847
+ { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
11915
11848
  { ALT: () => {
11916
11849
  const tokenNil = CONSUME(terminals_exports.nil);
11917
11850
  return ACTION(() => C.factory.namedNode(C.factory.sourceLocation(tokenNil), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */));
@@ -11919,1275 +11852,1344 @@ var graphTerm = {
11919
11852
  ]),
11920
11853
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11921
11854
  if (F2.isTermNamed(ast)) {
11922
- SUBRULE(iri2, ast, void 0);
11855
+ SUBRULE(iri2, ast);
11923
11856
  } else if (F2.isTermLiteral(ast)) {
11924
- SUBRULE(rdfLiteral, ast, void 0);
11857
+ SUBRULE(rdfLiteral, ast);
11925
11858
  } else if (F2.isTermBlank(ast)) {
11926
- SUBRULE(blankNode, ast, void 0);
11859
+ SUBRULE(blankNode, ast);
11927
11860
  }
11928
11861
  }
11929
11862
  };
11930
11863
 
11931
- // ../../packages/rules-sparql-1-1/lib/grammar/propertyPaths.ts
11932
- var path = {
11933
- name: "path",
11934
- impl: ({ SUBRULE }) => () => SUBRULE(pathAlternative, void 0)
11935
- };
11936
- var pathGenerator = {
11937
- name: "path",
11938
- gImpl: ({ PRINT, SUBRULE }) => (ast, { factory: F2 }, braces = true) => {
11939
- if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
11940
- SUBRULE(iri2, ast, void 0);
11941
- } else {
11942
- F2.printFilter(ast, () => braces && PRINT("("));
11943
- switch (ast.subType) {
11944
- case "|":
11945
- case "/": {
11946
- const [head2, ...tail] = ast.items;
11947
- SUBRULE(pathGenerator, head2, braces);
11948
- for (const val of tail) {
11949
- F2.printFilter(ast, () => PRINT(ast.subType));
11950
- SUBRULE(pathGenerator, val, braces);
11951
- }
11952
- break;
11953
- }
11954
- case "^":
11955
- F2.printFilter(ast, () => PRINT("^"));
11956
- SUBRULE(pathGenerator, ast.items[0], braces);
11957
- break;
11958
- case "?":
11959
- case "*":
11960
- case "+":
11961
- SUBRULE(pathGenerator, ast.items[0], braces);
11962
- F2.printFilter(ast, () => PRINT(ast.subType));
11963
- break;
11964
- case "!":
11965
- F2.printFilter(ast, () => PRINT("!"));
11966
- F2.printFilter(ast, () => PRINT("("));
11967
- SUBRULE(pathGenerator, ast.items[0], false);
11968
- F2.printFilter(ast, () => PRINT(")"));
11969
- break;
11970
- }
11971
- F2.printFilter(ast, () => braces && PRINT(")"));
11864
+ // ../../packages/rules-sparql-1-1/lib/grammar/dataSetClause.ts
11865
+ function datasetClauseUsing(name, token) {
11866
+ return {
11867
+ name,
11868
+ impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
11869
+ const start = CONSUME(token);
11870
+ return OR([
11871
+ { ALT: () => {
11872
+ const iri3 = SUBRULE(defaultGraphClause);
11873
+ return ACTION(() => C.factory.wrap({ clauseType: "default", value: iri3 }, C.factory.sourceLocation(start, iri3)));
11874
+ } },
11875
+ { ALT: () => {
11876
+ const namedClause = SUBRULE(namedGraphClause);
11877
+ return ACTION(() => C.factory.wrap({
11878
+ clauseType: "named",
11879
+ value: namedClause.val
11880
+ }, C.factory.sourceLocation(start, namedClause)));
11881
+ } }
11882
+ ]);
11972
11883
  }
11973
- }
11884
+ };
11885
+ }
11886
+ var datasetClause = datasetClauseUsing("datasetClause", from);
11887
+ var defaultGraphClause = {
11888
+ name: "defaultGraphClause",
11889
+ impl: ({ SUBRULE }) => () => SUBRULE(sourceSelector)
11974
11890
  };
11975
- function pathChainHelper(name, SEP, subType, subRule) {
11891
+ var usingClause2 = datasetClauseUsing("usingClause", usingClause);
11892
+ function datasetClauseUsingStar(name, subRule, fromUsing) {
11976
11893
  return {
11977
11894
  name,
11978
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, MANY }) => (C) => {
11979
- const head2 = SUBRULE1(subRule, void 0);
11980
- let tailEnd = head2;
11981
- const tail = [];
11895
+ impl: ({ ACTION, MANY, SUBRULE }) => (C) => {
11896
+ const clauses = [];
11982
11897
  MANY(() => {
11983
- CONSUME(SEP);
11984
- tailEnd = SUBRULE2(subRule, void 0);
11985
- tail.push(tailEnd);
11898
+ const clause = SUBRULE(subRule);
11899
+ clauses.push(clause);
11986
11900
  });
11987
- return ACTION(() => tail.length === 0 ? head2 : C.factory.path(subType, [head2, ...tail], C.factory.sourceLocation(head2, tailEnd)));
11901
+ return ACTION(() => C.factory.datasetClauses(
11902
+ clauses.map((clause) => clause.val),
11903
+ C.factory.sourceLocation(...clauses)
11904
+ ));
11905
+ },
11906
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11907
+ for (const clause of ast.clauses) {
11908
+ F2.printFilter(ast, () => PRINT_WORD(fromUsing));
11909
+ if (clause.clauseType === "named") {
11910
+ F2.printFilter(ast, () => PRINT_WORD("NAMED"));
11911
+ }
11912
+ SUBRULE(iri2, clause.value);
11913
+ }
11988
11914
  }
11989
11915
  };
11990
11916
  }
11991
- var pathEltOrInverse = {
11992
- name: "pathEltOrInverse",
11993
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR }) => (C) => OR([
11994
- { ALT: () => SUBRULE1(pathElt, void 0) },
11995
- { ALT: () => {
11996
- const hat2 = CONSUME(symbols_exports.hat);
11997
- const item = SUBRULE2(pathElt, void 0);
11998
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
11999
- } }
12000
- ])
12001
- };
12002
- var pathSequence = pathChainHelper("pathSequence", symbols_exports.slash, "/", pathEltOrInverse);
12003
- var pathAlternative = pathChainHelper("pathAlternative", symbols_exports.pipe, "|", pathSequence);
12004
- var pathElt = {
12005
- name: "pathElt",
12006
- impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
12007
- const item = SUBRULE(pathPrimary, void 0);
12008
- const modification = OPTION(() => SUBRULE(pathMod, void 0));
12009
- return ACTION(() => modification === void 0 ? item : C.factory.path(modification.image, [item], C.factory.sourceLocation(item, modification)));
11917
+ var datasetClauseStar = datasetClauseUsingStar("datasetClauses", datasetClause, "FROM");
11918
+ var usingClauseStar = datasetClauseUsingStar("usingClauses", usingClause2, "USING");
11919
+ var namedGraphClause = {
11920
+ name: "namedGraphClause",
11921
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11922
+ const named2 = CONSUME(graph_exports.named);
11923
+ const iri3 = SUBRULE(sourceSelector);
11924
+ return ACTION(() => C.factory.wrap(iri3, C.factory.sourceLocation(named2, iri3)));
12010
11925
  }
12011
11926
  };
12012
- var pathMod = {
12013
- name: "pathMod",
12014
- impl: ({ CONSUME, OR }) => () => OR([
12015
- { ALT: () => CONSUME(symbols_exports.question) },
12016
- { ALT: () => CONSUME(symbols_exports.star) },
12017
- { ALT: () => CONSUME(symbols_exports.opPlus) }
12018
- ])
11927
+ var sourceSelector = {
11928
+ name: "sourceSelector",
11929
+ impl: ({ SUBRULE }) => () => SUBRULE(iri2)
12019
11930
  };
12020
- var pathPrimary = {
12021
- name: "pathPrimary",
12022
- impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
12023
- { ALT: () => SUBRULE(iri2, void 0) },
12024
- { ALT: () => SUBRULE(verbA, void 0) },
12025
- { ALT: () => SUBRULE(pathNegatedPropertySet, void 0) },
12026
- { ALT: () => {
11931
+
11932
+ // ../../packages/rules-sparql-1-1/lib/expressionHelpers.ts
11933
+ function funcExpr1(func) {
11934
+ return {
11935
+ name: unCapitalize(func.name),
11936
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11937
+ const operator = CONSUME(func);
12027
11938
  CONSUME(symbols_exports.LParen);
12028
- const resRecursive = SUBRULE(path, void 0);
12029
- CONSUME(symbols_exports.RParen);
12030
- return resRecursive;
12031
- } }
12032
- ])
12033
- };
12034
- var pathNegatedPropertySet = {
12035
- name: "pathNegatedPropertySet",
12036
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, OR, MANY }) => (C) => {
12037
- const exclamation2 = CONSUME(symbols_exports.exclamation);
12038
- return OR([
12039
- { ALT: () => {
12040
- const noAlternative = SUBRULE1(pathOneInPropertySet, void 0);
12041
- return ACTION(() => C.factory.path("!", [noAlternative], C.factory.sourceLocation(exclamation2, noAlternative)));
12042
- } },
12043
- { ALT: () => {
12044
- const open = CONSUME(symbols_exports.LParen);
12045
- const head2 = SUBRULE2(pathOneInPropertySet, void 0);
12046
- const tail = [];
12047
- MANY(() => {
12048
- CONSUME(symbols_exports.pipe);
12049
- const item = SUBRULE3(pathOneInPropertySet, void 0);
12050
- tail.push(item);
12051
- });
12052
- const close = CONSUME(symbols_exports.RParen);
12053
- return ACTION(() => {
12054
- const F2 = C.factory;
12055
- if (tail.length === 0) {
12056
- return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
12057
- }
12058
- return F2.path(
12059
- "!",
12060
- [F2.path("|", [head2, ...tail], F2.sourceLocation(open, close))],
12061
- F2.sourceLocation(exclamation2, close)
12062
- );
12063
- });
12064
- } }
12065
- ]);
12066
- }
12067
- };
12068
- var pathOneInPropertySet = {
12069
- name: "pathOneInPropertySet",
12070
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
12071
- { ALT: () => SUBRULE1(iri2, void 0) },
12072
- { ALT: () => SUBRULE1(verbA, void 0) },
12073
- { ALT: () => {
12074
- const hat2 = CONSUME(symbols_exports.hat);
12075
- const item = OR2([
12076
- { ALT: () => SUBRULE2(iri2, void 0) },
12077
- { ALT: () => SUBRULE2(verbA, void 0) }
12078
- ]);
12079
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12080
- } }
12081
- ])
12082
- };
12083
-
12084
- // ../../packages/rules-sparql-1-1/lib/grammar/tripleBlock.ts
12085
- function triplesDotSeperated(triplesSameSubjectSubrule) {
12086
- return ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME, OPTION }) => (C) => {
12087
- const triples = [];
12088
- let parsedDot = true;
12089
- let dotToken;
12090
- AT_LEAST_ONE({
12091
- GATE: () => parsedDot,
12092
- DEF: () => {
12093
- parsedDot = false;
12094
- const template = SUBRULE(triplesSameSubjectSubrule, void 0);
12095
- ACTION(() => {
12096
- triples.push(...template);
12097
- });
12098
- OPTION(() => {
12099
- dotToken = CONSUME(symbols_exports.dot);
12100
- parsedDot = true;
12101
- });
12102
- }
12103
- });
12104
- return ACTION(() => C.factory.patternBgp(triples, C.factory.sourceLocation(...triples, dotToken)));
11939
+ const arg = SUBRULE(expression);
11940
+ const close = CONSUME(symbols_exports.RParen);
11941
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11942
+ }
12105
11943
  };
12106
11944
  }
12107
- var triplesBlock = {
12108
- name: "triplesBlock",
12109
- impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C, void 0),
12110
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12111
- for (const [index, triple] of ast.triples.entries()) {
12112
- HANDLE_LOC(triple, () => {
12113
- const nextTriple = ast.triples.at(index);
12114
- if (F2.isTripleCollection(triple)) {
12115
- SUBRULE(graphNodePath, triple, void 0);
12116
- F2.printFilter(triple, () => PRINT_WORD("."));
12117
- } else {
12118
- SUBRULE(graphNodePath, triple.subject, void 0);
12119
- if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12120
- SUBRULE(varOrTerm, triple.predicate, void 0);
12121
- } else {
12122
- SUBRULE(pathGenerator, triple.predicate, void 0);
12123
- }
12124
- SUBRULE(graphNodePath, triple.object, void 0);
12125
- if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12126
- F2.printFilter(ast, () => PRINT_WORD("."));
12127
- } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12128
- F2.printFilter(ast, () => PRINT_WORD(","));
12129
- } else {
12130
- F2.printFilter(ast, () => PRINT_WORD(";"));
12131
- }
12132
- }
12133
- });
11945
+ function funcExpr2(func) {
11946
+ return {
11947
+ name: unCapitalize(func.name),
11948
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {
11949
+ const operator = CONSUME(func);
11950
+ CONSUME(symbols_exports.LParen);
11951
+ const arg1 = SUBRULE1(expression);
11952
+ CONSUME(symbols_exports.comma);
11953
+ const arg2 = SUBRULE2(expression);
11954
+ const close = CONSUME(symbols_exports.RParen);
11955
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2], C.factory.sourceLocation(operator, close)));
12134
11956
  }
12135
- }
12136
- };
12137
- function triplesSameSubjectImpl(name, allowPaths) {
11957
+ };
11958
+ }
11959
+ function funcExpr3(func) {
12138
11960
  return {
12139
- name,
12140
- impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
12141
- { ALT: () => {
12142
- const subject = SUBRULE(varOrTerm, void 0);
12143
- const res = SUBRULE(
12144
- allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty,
12145
- { subject: ACTION(() => C.factory.dematerialized(subject)) }
12146
- );
12147
- return ACTION(() => {
12148
- if (res.length > 0) {
12149
- res[0].subject = subject;
12150
- res[0].loc = C.factory.sourceLocation(subject, res[0]);
12151
- }
12152
- return res;
12153
- });
12154
- } },
12155
- { ALT: () => {
12156
- const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode, void 0);
12157
- const restNode = SUBRULE(
12158
- allowPaths ? propertyListPath : propertyList,
12159
- { subject: ACTION(() => C.factory.graphNodeIdentifier(subjectNode)) }
12160
- );
12161
- return ACTION(() => {
12162
- if (restNode.length === 0) {
12163
- return [subjectNode];
12164
- }
12165
- restNode[0].subject = subjectNode;
12166
- restNode[0].loc = C.factory.sourceLocation(subjectNode, restNode[0]);
12167
- return restNode;
12168
- });
12169
- } }
12170
- ])
11961
+ name: unCapitalize(func.name),
11962
+ impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {
11963
+ const operator = CONSUME(func);
11964
+ CONSUME(symbols_exports.LParen);
11965
+ const arg1 = SUBRULE1(expression);
11966
+ CONSUME1(symbols_exports.comma);
11967
+ const arg2 = SUBRULE2(expression);
11968
+ CONSUME2(symbols_exports.comma);
11969
+ const arg3 = SUBRULE3(expression);
11970
+ const close = CONSUME(symbols_exports.RParen);
11971
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
11972
+ }
12171
11973
  };
12172
11974
  }
12173
- var triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
12174
- var triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
12175
- var triplesTemplate = {
12176
- name: "triplesTemplate",
12177
- impl: triplesDotSeperated(triplesSameSubject)
12178
- };
12179
- function propertyListImpl(name, allowPaths) {
11975
+ function funcVar1(func) {
12180
11976
  return {
12181
- name,
12182
- impl: ({ SUBRULE, OPTION }) => (_, arg) => OPTION(() => SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, arg)) ?? []
11977
+ name: unCapitalize(func.name),
11978
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11979
+ const operator = CONSUME(func);
11980
+ CONSUME(symbols_exports.LParen);
11981
+ const arg = SUBRULE(var_);
11982
+ const close = CONSUME(symbols_exports.RParen);
11983
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11984
+ }
12183
11985
  };
12184
11986
  }
12185
- var propertyList = propertyListImpl("propertyList", false);
12186
- var propertyListPath = propertyListImpl("propertyListPath", true);
12187
- function propertyListNotEmptyImplementation(name, allowPaths) {
11987
+ function funcExprOrNil1(func) {
12188
11988
  return {
12189
- name,
12190
- impl: ({ ACTION, CONSUME, AT_LEAST_ONE, SUBRULE1, MANY2, OR1 }) => (_, arg) => {
12191
- const result = [];
12192
- let parsedSemi = true;
12193
- AT_LEAST_ONE({
12194
- GATE: () => parsedSemi,
12195
- DEF: () => {
12196
- parsedSemi = false;
12197
- const predicate = allowPaths ? OR1([
12198
- { ALT: () => SUBRULE1(verbPath, void 0) },
12199
- { ALT: () => SUBRULE1(verbSimple, void 0) }
12200
- ]) : SUBRULE1(verb, void 0);
12201
- const triples = SUBRULE1(
12202
- allowPaths ? objectListPath : objectList,
12203
- ACTION(() => ({ subject: arg.subject, predicate }))
12204
- );
12205
- MANY2(() => {
12206
- CONSUME(symbols_exports.semi);
12207
- parsedSemi = true;
12208
- });
12209
- ACTION(() => {
12210
- result.push(...triples);
12211
- });
12212
- }
12213
- });
12214
- return result;
11989
+ name: unCapitalize(func.name),
11990
+ impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
11991
+ const operator = CONSUME(func);
11992
+ return OR([
11993
+ { ALT: () => {
11994
+ CONSUME(symbols_exports.LParen);
11995
+ const arg = SUBRULE(expression);
11996
+ const close = CONSUME(symbols_exports.RParen);
11997
+ return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11998
+ } },
11999
+ { ALT: () => {
12000
+ const nil2 = CONSUME(terminals_exports.nil);
12001
+ return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12002
+ } }
12003
+ ]);
12215
12004
  }
12216
12005
  };
12217
12006
  }
12218
- var propertyListNotEmpty = propertyListNotEmptyImplementation("propertyListNotEmpty", false);
12219
- var propertyListPathNotEmpty = propertyListNotEmptyImplementation("propertyListPathNotEmpty", true);
12220
- var verbPath = {
12221
- name: "verbPath",
12222
- impl: ({ SUBRULE }) => () => SUBRULE(path, void 0)
12223
- };
12224
- var verbSimple = {
12225
- name: "verbSimple",
12226
- impl: ({ SUBRULE }) => () => SUBRULE(var_, void 0)
12227
- };
12228
- function objectListImpl(name, allowPaths) {
12007
+ function funcNil1(func) {
12229
12008
  return {
12230
- name,
12231
- impl: ({ ACTION, SUBRULE, AT_LEAST_ONE_SEP }) => (_, arg) => {
12232
- const objects = [];
12233
- AT_LEAST_ONE_SEP({
12234
- SEP: symbols_exports.comma,
12235
- DEF: () => {
12236
- const objectTriple = SUBRULE(allowPaths ? objectPath : object, arg);
12237
- ACTION(() => {
12238
- objects.push(objectTriple);
12239
- });
12240
- }
12241
- });
12242
- return objects;
12009
+ name: unCapitalize(func.name),
12010
+ impl: ({ ACTION, CONSUME }) => (C) => {
12011
+ const operator = CONSUME(func);
12012
+ const nil2 = CONSUME(terminals_exports.nil);
12013
+ return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12243
12014
  }
12244
12015
  };
12245
12016
  }
12246
- var objectList = objectListImpl("objectList", false);
12247
- var objectListPath = objectListImpl("objectListPath", true);
12248
- function objectImpl(name, allowPaths) {
12017
+ function funcExprList1(func) {
12249
12018
  return {
12250
- name,
12251
- impl: ({ ACTION, SUBRULE }) => (C, arg) => {
12252
- const node = SUBRULE(allowPaths ? graphNodePath : graphNode, void 0);
12253
- return ACTION(() => C.factory.triple(arg.subject, arg.predicate, node));
12019
+ name: unCapitalize(func.name),
12020
+ impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
12021
+ const operator = CONSUME(func);
12022
+ const args = SUBRULE(expressionList);
12023
+ return ACTION(() => C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));
12254
12024
  }
12255
12025
  };
12256
12026
  }
12257
- var object = objectImpl("object", false);
12258
- var objectPath = objectImpl("objectPath", true);
12259
- function collectionImpl(name, allowPaths) {
12027
+ function funcExpr2or3(func) {
12260
12028
  return {
12261
- name,
12262
- impl: ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME }) => (C) => {
12263
- const terms = [];
12264
- const startToken = CONSUME(symbols_exports.LParen);
12265
- AT_LEAST_ONE(() => {
12266
- terms.push(SUBRULE(allowPaths ? graphNodePath : graphNode, void 0));
12029
+ name: unCapitalize(func.name),
12030
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) => (C) => {
12031
+ const operator = CONSUME(func);
12032
+ CONSUME(symbols_exports.LParen);
12033
+ const arg1 = SUBRULE1(expression);
12034
+ CONSUME1(symbols_exports.comma);
12035
+ const arg2 = SUBRULE2(expression);
12036
+ const arg3 = OPTION(() => {
12037
+ CONSUME2(symbols_exports.comma);
12038
+ return SUBRULE3(expression);
12267
12039
  });
12268
- const endToken = CONSUME(symbols_exports.RParen);
12269
- return ACTION(() => {
12270
- const F2 = C.factory;
12271
- const triples = [];
12272
- const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" /* FIRST */, void 0);
12273
- const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" /* REST */, void 0);
12274
- const predNil = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */, void 0);
12275
- const listHead = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12276
- let iterHead = listHead;
12277
- for (const [index, term] of terms.entries()) {
12278
- const lastInList = index === terms.length - 1;
12279
- const headTriple = F2.triple(
12280
- iterHead,
12281
- predFirst,
12282
- term
12283
- );
12284
- triples.push(headTriple);
12285
- if (lastInList) {
12286
- const nilTriple = F2.triple(iterHead, predRest, predNil);
12287
- triples.push(nilTriple);
12288
- } else {
12289
- const tail = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12290
- const linkTriple = F2.triple(iterHead, predRest, tail);
12291
- triples.push(linkTriple);
12292
- iterHead = tail;
12293
- }
12294
- }
12295
- return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
12296
- });
12297
- },
12298
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12299
- F2.printFilter(ast, () => PRINT_WORD("("));
12300
- for (const [idx, triple] of ast.triples.entries()) {
12301
- if (idx % 2 === 0) {
12302
- SUBRULE(allowPaths ? graphNodePath : graphNode, triple.object, void 0);
12303
- }
12304
- }
12305
- F2.printFilter(ast, () => PRINT_WORD(")"));
12040
+ const close = CONSUME(symbols_exports.RParen);
12041
+ return ACTION(() => C.factory.expressionOperation(
12042
+ operator.image,
12043
+ arg3 ? [arg1, arg2, arg3] : [arg1, arg2],
12044
+ C.factory.sourceLocation(operator, close)
12045
+ ));
12306
12046
  }
12307
12047
  };
12308
12048
  }
12309
- var collection = collectionImpl("collection", false);
12310
- var collectionPath = collectionImpl("collectionPath", true);
12311
- function triplesNodeImpl(name, allowPaths) {
12049
+ function funcExpr3or4(func) {
12312
12050
  return {
12313
- name,
12314
- impl: ({ SUBRULE, OR }) => () => OR([
12315
- { ALT: () => SUBRULE(allowPaths ? collectionPath : collection, void 0) },
12316
- { ALT: () => SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, void 0) }
12317
- ]),
12318
- gImpl: ({ SUBRULE }) => (ast) => ast.subType === "list" ? SUBRULE(allowPaths ? collectionPath : collection, ast, void 0) : SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, ast, void 0)
12051
+ name: unCapitalize(func.name),
12052
+ impl: ({
12053
+ ACTION,
12054
+ CONSUME,
12055
+ SUBRULE1,
12056
+ SUBRULE2,
12057
+ SUBRULE3,
12058
+ SUBRULE4,
12059
+ CONSUME1,
12060
+ OPTION,
12061
+ CONSUME2,
12062
+ CONSUME3
12063
+ }) => (C) => {
12064
+ const operator = CONSUME(func);
12065
+ CONSUME(symbols_exports.LParen);
12066
+ const arg1 = SUBRULE1(expression);
12067
+ CONSUME1(symbols_exports.comma);
12068
+ const arg2 = SUBRULE2(expression);
12069
+ CONSUME2(symbols_exports.comma);
12070
+ const arg3 = SUBRULE3(expression);
12071
+ const arg4 = OPTION(() => {
12072
+ CONSUME3(symbols_exports.comma);
12073
+ return SUBRULE4(expression);
12074
+ });
12075
+ const close = CONSUME(symbols_exports.RParen);
12076
+ return ACTION(() => C.factory.expressionOperation(
12077
+ operator.image,
12078
+ arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3],
12079
+ C.factory.sourceLocation(operator, close)
12080
+ ));
12081
+ }
12319
12082
  };
12320
12083
  }
12321
- var triplesNode = triplesNodeImpl("triplesNode", false);
12322
- var triplesNodePath = triplesNodeImpl("triplesNodePath", true);
12323
- function blankNodePropertyListImpl(name, allowPaths) {
12324
- const propertyPathNotEmptyImpl = allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty;
12084
+ function funcGroupGraphPattern(func) {
12325
12085
  return {
12326
- name,
12086
+ name: unCapitalize(func.name),
12327
12087
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12328
- const startToken = CONSUME(symbols_exports.LSquare);
12329
- const blankNode2 = ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocationNoMaterialize()));
12330
- const propList = SUBRULE(propertyPathNotEmptyImpl, { subject: blankNode2 });
12331
- const endToken = CONSUME(symbols_exports.RSquare);
12332
- return ACTION(() => C.factory.tripleCollectionBlankNodeProperties(
12333
- blankNode2,
12334
- propList,
12335
- C.factory.sourceLocation(startToken, endToken)
12088
+ const operator = CONSUME(func);
12089
+ const group = SUBRULE(groupGraphPattern);
12090
+ return ACTION(() => C.factory.expressionPatternOperation(
12091
+ operator.image,
12092
+ group,
12093
+ C.factory.sourceLocation(operator, group)
12336
12094
  ));
12337
- },
12338
- gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12339
- F2.printFilter(ast, () => PRINT("["));
12340
- for (const triple of ast.triples) {
12341
- HANDLE_LOC(triple, () => {
12342
- if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12343
- SUBRULE(varOrTerm, triple.predicate, void 0);
12344
- } else {
12345
- SUBRULE(pathGenerator, triple.predicate, void 0);
12346
- }
12347
- SUBRULE(graphNodePath, triple.object, void 0);
12348
- F2.printFilter(ast, () => PRINT_WORD(";"));
12349
- });
12350
- }
12351
- F2.printFilter(ast, () => PRINT("]"));
12352
12095
  }
12353
12096
  };
12354
12097
  }
12355
- var blankNodePropertyList = blankNodePropertyListImpl("blankNodePropertyList", false);
12356
- var blankNodePropertyListPath = blankNodePropertyListImpl("blankNodePropertyListPath", true);
12357
- function graphNodeImpl(name, allowPaths) {
12358
- const triplesNodeRule = allowPaths ? triplesNodePath : triplesNode;
12098
+ function baseAggregateFunc(func) {
12359
12099
  return {
12360
- name,
12361
- impl: ({ SUBRULE, OR }) => (C) => OR([
12362
- { ALT: () => SUBRULE(varOrTerm, void 0) },
12363
- {
12364
- GATE: () => C.parseMode.has("canCreateBlankNodes"),
12365
- ALT: () => SUBRULE(triplesNodeRule, void 0)
12366
- }
12367
- ]),
12368
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12369
- if (F2.isTerm(ast)) {
12370
- SUBRULE(varOrTerm, ast, void 0);
12371
- } else {
12372
- SUBRULE(triplesNodeRule, ast, void 0);
12373
- }
12100
+ name: unCapitalize(func.name),
12101
+ impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
12102
+ const operator = CONSUME(func);
12103
+ CONSUME(symbols_exports.LParen);
12104
+ const distinct2 = OPTION(() => CONSUME(distinct));
12105
+ const expr1 = SUBRULE(expression);
12106
+ const close = CONSUME(symbols_exports.RParen);
12107
+ return ACTION(() => C.factory.aggregate(
12108
+ operator.image,
12109
+ distinct2 !== void 0,
12110
+ expr1,
12111
+ void 0,
12112
+ C.factory.sourceLocation(operator, close)
12113
+ ));
12374
12114
  }
12375
12115
  };
12376
12116
  }
12377
- var graphNode = graphNodeImpl("graphNode", false);
12378
- var graphNodePath = graphNodeImpl("graphNodePath", true);
12379
12117
 
12380
- // ../../packages/rules-sparql-1-1/lib/grammar/whereClause.ts
12381
- var whereClause = {
12382
- name: "whereClause",
12383
- impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
12384
- const where2 = OPTION(() => CONSUME(where));
12385
- const group = SUBRULE(groupGraphPattern, void 0);
12386
- return ACTION(() => C.factory.wrap(group, C.factory.sourceLocation(where2, group)));
12387
- },
12388
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12389
- F2.printFilter(ast, () => PRINT_WORD("WHERE"));
12390
- SUBRULE(groupGraphPattern, ast.val, void 0);
12118
+ // ../../packages/rules-sparql-1-1/lib/grammar/builtIn.ts
12119
+ var builtInStr = funcExpr1(BuiltInCalls_exports.str);
12120
+ var builtInLang = funcExpr1(BuiltInCalls_exports.lang);
12121
+ var builtInLangmatches = funcExpr2(BuiltInCalls_exports.langmatches);
12122
+ var builtInDatatype = funcExpr1(BuiltInCalls_exports.datatype);
12123
+ var builtInBound = funcVar1(BuiltInCalls_exports.bound);
12124
+ var builtInIri = funcExpr1(BuiltInCalls_exports.iri);
12125
+ var builtInUri = funcExpr1(BuiltInCalls_exports.uri);
12126
+ var builtInBnodeSparqlJs = funcExprOrNil1(BuiltInCalls_exports.bnode);
12127
+ var builtInRand = funcNil1(BuiltInCalls_exports.rand);
12128
+ var builtInAbs = funcExpr1(BuiltInCalls_exports.abs);
12129
+ var builtInCeil = funcExpr1(BuiltInCalls_exports.ceil);
12130
+ var builtInFloor = funcExpr1(BuiltInCalls_exports.floor);
12131
+ var builtInRound = funcExpr1(BuiltInCalls_exports.round);
12132
+ var builtInConcat = funcExprList1(BuiltInCalls_exports.concat);
12133
+ var builtInStrlen = funcExpr1(BuiltInCalls_exports.strlen);
12134
+ var builtInUcase = funcExpr1(BuiltInCalls_exports.ucase);
12135
+ var builtInLcase = funcExpr1(BuiltInCalls_exports.lcase);
12136
+ var builtInEncode_for_uri = funcExpr1(BuiltInCalls_exports.encode_for_uri);
12137
+ var builtInContains = funcExpr2(BuiltInCalls_exports.contains);
12138
+ var builtInStrstarts = funcExpr2(BuiltInCalls_exports.strstarts);
12139
+ var builtInStrends = funcExpr2(BuiltInCalls_exports.strends);
12140
+ var builtInStrbefore = funcExpr2(BuiltInCalls_exports.strbefore);
12141
+ var builtInStrafter = funcExpr2(BuiltInCalls_exports.strafter);
12142
+ var builtInYear = funcExpr1(BuiltInCalls_exports.year);
12143
+ var builtInMonth = funcExpr1(BuiltInCalls_exports.month);
12144
+ var builtInDay = funcExpr1(BuiltInCalls_exports.day);
12145
+ var builtInHours = funcExpr1(BuiltInCalls_exports.hours);
12146
+ var builtInMinutes = funcExpr1(BuiltInCalls_exports.minutes);
12147
+ var builtInSeconds = funcExpr1(BuiltInCalls_exports.seconds);
12148
+ var builtInTimezone = funcExpr1(BuiltInCalls_exports.timezone);
12149
+ var builtInTz = funcExpr1(BuiltInCalls_exports.tz);
12150
+ var builtInNow = funcNil1(BuiltInCalls_exports.now);
12151
+ var builtInUuid = funcNil1(BuiltInCalls_exports.uuid);
12152
+ var builtInStruuid = funcNil1(BuiltInCalls_exports.struuid);
12153
+ var builtInMd5 = funcExpr1(BuiltInCalls_exports.md5);
12154
+ var builtInSha1 = funcExpr1(BuiltInCalls_exports.sha1);
12155
+ var builtInSha256 = funcExpr1(BuiltInCalls_exports.sha256);
12156
+ var builtInSha384 = funcExpr1(BuiltInCalls_exports.sha384);
12157
+ var builtInSha512 = funcExpr1(BuiltInCalls_exports.sha512);
12158
+ var builtInCoalesce = funcExprList1(BuiltInCalls_exports.coalesce);
12159
+ var builtInIf = funcExpr3(BuiltInCalls_exports.if_);
12160
+ var builtInStrlang = funcExpr2(BuiltInCalls_exports.strlang);
12161
+ var builtInStrdt = funcExpr2(BuiltInCalls_exports.strdt);
12162
+ var builtInSameterm = funcExpr2(BuiltInCalls_exports.sameterm);
12163
+ var builtInIsiri = funcExpr1(BuiltInCalls_exports.isiri);
12164
+ var builtInIsuri = funcExpr1(BuiltInCalls_exports.isuri);
12165
+ var builtInIsblank = funcExpr1(BuiltInCalls_exports.isblank);
12166
+ var builtInIsliteral = funcExpr1(BuiltInCalls_exports.isliteral);
12167
+ var builtInIsnumeric = funcExpr1(BuiltInCalls_exports.isnumeric);
12168
+ function builtInCallList(SUBRULE) {
12169
+ return [
12170
+ { ALT: () => SUBRULE(aggregate) },
12171
+ { ALT: () => SUBRULE(builtInStr) },
12172
+ { ALT: () => SUBRULE(builtInLang) },
12173
+ { ALT: () => SUBRULE(builtInLangmatches) },
12174
+ { ALT: () => SUBRULE(builtInDatatype) },
12175
+ { ALT: () => SUBRULE(builtInBound) },
12176
+ { ALT: () => SUBRULE(builtInIri) },
12177
+ { ALT: () => SUBRULE(builtInUri) },
12178
+ { ALT: () => SUBRULE(builtInBnodeSparqlJs) },
12179
+ { ALT: () => SUBRULE(builtInRand) },
12180
+ { ALT: () => SUBRULE(builtInAbs) },
12181
+ { ALT: () => SUBRULE(builtInCeil) },
12182
+ { ALT: () => SUBRULE(builtInFloor) },
12183
+ { ALT: () => SUBRULE(builtInRound) },
12184
+ { ALT: () => SUBRULE(builtInConcat) },
12185
+ { ALT: () => SUBRULE(substringExpression) },
12186
+ { ALT: () => SUBRULE(builtInStrlen) },
12187
+ { ALT: () => SUBRULE(strReplaceExpression) },
12188
+ { ALT: () => SUBRULE(builtInUcase) },
12189
+ { ALT: () => SUBRULE(builtInLcase) },
12190
+ { ALT: () => SUBRULE(builtInEncode_for_uri) },
12191
+ { ALT: () => SUBRULE(builtInContains) },
12192
+ { ALT: () => SUBRULE(builtInStrstarts) },
12193
+ { ALT: () => SUBRULE(builtInStrends) },
12194
+ { ALT: () => SUBRULE(builtInStrbefore) },
12195
+ { ALT: () => SUBRULE(builtInStrafter) },
12196
+ { ALT: () => SUBRULE(builtInYear) },
12197
+ { ALT: () => SUBRULE(builtInMonth) },
12198
+ { ALT: () => SUBRULE(builtInDay) },
12199
+ { ALT: () => SUBRULE(builtInHours) },
12200
+ { ALT: () => SUBRULE(builtInMinutes) },
12201
+ { ALT: () => SUBRULE(builtInSeconds) },
12202
+ { ALT: () => SUBRULE(builtInTimezone) },
12203
+ { ALT: () => SUBRULE(builtInTz) },
12204
+ { ALT: () => SUBRULE(builtInNow) },
12205
+ { ALT: () => SUBRULE(builtInUuid) },
12206
+ { ALT: () => SUBRULE(builtInStruuid) },
12207
+ { ALT: () => SUBRULE(builtInMd5) },
12208
+ { ALT: () => SUBRULE(builtInSha1) },
12209
+ { ALT: () => SUBRULE(builtInSha256) },
12210
+ { ALT: () => SUBRULE(builtInSha384) },
12211
+ { ALT: () => SUBRULE(builtInSha512) },
12212
+ { ALT: () => SUBRULE(builtInCoalesce) },
12213
+ { ALT: () => SUBRULE(builtInIf) },
12214
+ { ALT: () => SUBRULE(builtInStrlang) },
12215
+ { ALT: () => SUBRULE(builtInStrdt) },
12216
+ { ALT: () => SUBRULE(builtInSameterm) },
12217
+ { ALT: () => SUBRULE(builtInIsiri) },
12218
+ { ALT: () => SUBRULE(builtInIsuri) },
12219
+ { ALT: () => SUBRULE(builtInIsblank) },
12220
+ { ALT: () => SUBRULE(builtInIsliteral) },
12221
+ { ALT: () => SUBRULE(builtInIsnumeric) },
12222
+ { ALT: () => SUBRULE(regexExpression) },
12223
+ { ALT: () => SUBRULE(existsFunc) },
12224
+ { ALT: () => SUBRULE(notExistsFunc) }
12225
+ ];
12226
+ }
12227
+ var builtInCall = {
12228
+ name: "builtInCall",
12229
+ impl: ({ OR, SUBRULE, cache }) => () => {
12230
+ const cached = cache.get(builtInCall);
12231
+ if (cached) {
12232
+ return OR(cached);
12233
+ }
12234
+ const builtIns = builtInCallList(SUBRULE);
12235
+ cache.set(builtInCall, builtIns);
12236
+ return OR(builtIns);
12391
12237
  }
12392
12238
  };
12393
- var groupGraphPattern = {
12394
- name: "groupGraphPattern",
12395
- impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
12396
- const open = CONSUME(symbols_exports.LCurly);
12397
- const patterns = OR([
12398
- { ALT: () => [SUBRULE(subSelect, void 0)] },
12399
- { ALT: () => SUBRULE(groupGraphPatternSub, void 0) }
12239
+ var regexExpression = funcExpr2or3(BuiltInCalls_exports.regex);
12240
+ var substringExpression = funcExpr2or3(BuiltInCalls_exports.substr);
12241
+ var strReplaceExpression = funcExpr3or4(BuiltInCalls_exports.replace);
12242
+ var existsFunc = funcGroupGraphPattern(BuiltInCalls_exports.exists);
12243
+ var notExistsFunc = funcGroupGraphPattern(BuiltInCalls_exports.notexists);
12244
+ var aggregateCount = {
12245
+ name: unCapitalize(BuiltInCalls_exports.count.name),
12246
+ impl: ({ ACTION, CONSUME, SUBRULE, OR, OPTION }) => (C) => {
12247
+ const operatorToken = CONSUME(BuiltInCalls_exports.count);
12248
+ CONSUME(symbols_exports.LParen);
12249
+ const distinctToken = OPTION(() => CONSUME(distinct));
12250
+ const expressionVal = OR([
12251
+ { ALT: () => {
12252
+ const starToken = CONSUME(symbols_exports.star);
12253
+ return ACTION(() => C.factory.wildcard(C.factory.sourceLocation(starToken)));
12254
+ } },
12255
+ { ALT: () => SUBRULE(expression) }
12400
12256
  ]);
12401
- const close = CONSUME(symbols_exports.RCurly);
12402
- return ACTION(() => C.factory.patternGroup(patterns, C.factory.sourceLocation(open, close)));
12403
- },
12404
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12405
- F2.printFilter(ast, () => PRINT_WORD("{"));
12406
- for (const pattern of ast.patterns) {
12407
- SUBRULE(generatePattern, pattern, void 0);
12408
- }
12409
- F2.printFilter(ast, () => PRINT_WORD("}"));
12257
+ const closeToken = CONSUME(symbols_exports.RParen);
12258
+ return ACTION(() => {
12259
+ const F2 = C.factory;
12260
+ if (C.factory.isWildcard(expressionVal)) {
12261
+ return F2.aggregate(
12262
+ operatorToken.image,
12263
+ Boolean(distinctToken),
12264
+ expressionVal,
12265
+ void 0,
12266
+ C.factory.sourceLocation(operatorToken, closeToken)
12267
+ );
12268
+ }
12269
+ return F2.aggregate(
12270
+ operatorToken.image,
12271
+ Boolean(distinctToken),
12272
+ expressionVal,
12273
+ void 0,
12274
+ C.factory.sourceLocation(operatorToken, closeToken)
12275
+ );
12276
+ });
12410
12277
  }
12411
12278
  };
12412
- var generatePattern = {
12413
- name: "generatePattern",
12414
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12415
- if (ast.type === "query") {
12416
- SUBRULE(query, F2.querySelect({
12417
- context: [],
12418
- datasets: F2.datasetClauses([], F2.sourceLocation()),
12419
- where: ast.where,
12420
- variables: ast.variables,
12421
- solutionModifiers: ast.solutionModifiers,
12422
- values: ast.values,
12423
- distinct: ast.distinct,
12424
- reduced: ast.reduced
12425
- }, ast.loc), void 0);
12426
- } else if (ast.subType === "group") {
12427
- SUBRULE(groupGraphPattern, ast, void 0);
12428
- } else if (ast.subType === "bgp") {
12429
- SUBRULE(triplesBlock, ast, void 0);
12430
- } else {
12431
- SUBRULE(graphPatternNotTriples, ast, void 0);
12432
- }
12279
+ var aggregateSum = baseAggregateFunc(BuiltInCalls_exports.sum);
12280
+ var aggregateMin = baseAggregateFunc(BuiltInCalls_exports.min);
12281
+ var aggregateMax = baseAggregateFunc(BuiltInCalls_exports.max);
12282
+ var aggregateAvg = baseAggregateFunc(BuiltInCalls_exports.avg);
12283
+ var aggregateSample = baseAggregateFunc(BuiltInCalls_exports.sample);
12284
+ var aggregateGroup_concat = {
12285
+ name: unCapitalize(BuiltInCalls_exports.groupConcat.name),
12286
+ impl: ({ ACTION, CONSUME, OPTION1, SUBRULE, OPTION2 }) => (C) => {
12287
+ const operatorToken = CONSUME(BuiltInCalls_exports.groupConcat);
12288
+ CONSUME(symbols_exports.LParen);
12289
+ const distinctToken = OPTION1(() => CONSUME(distinct));
12290
+ const expr = SUBRULE(expression);
12291
+ const sep = OPTION2(() => {
12292
+ CONSUME(symbols_exports.semi);
12293
+ CONSUME(separator);
12294
+ CONSUME(symbols_exports.equal);
12295
+ return SUBRULE(string);
12296
+ });
12297
+ const closeToken = CONSUME(symbols_exports.RParen);
12298
+ return ACTION(() => {
12299
+ const F2 = C.factory;
12300
+ return F2.aggregate(
12301
+ operatorToken.image,
12302
+ Boolean(distinctToken),
12303
+ expr,
12304
+ sep?.value ?? " ",
12305
+ F2.sourceLocation(operatorToken, closeToken)
12306
+ );
12307
+ });
12433
12308
  }
12434
12309
  };
12435
- var groupGraphPatternSub = {
12436
- name: "groupGraphPatternSub",
12437
- impl: ({ ACTION, SUBRULE, CONSUME, MANY, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OPTION3 }) => () => {
12438
- const patterns = [];
12439
- const bgpPattern = OPTION1(() => SUBRULE1(triplesBlock, void 0));
12440
- if (bgpPattern) {
12441
- patterns.push(bgpPattern);
12442
- }
12443
- MANY(() => {
12444
- const notTriples = SUBRULE(graphPatternNotTriples, void 0);
12445
- patterns.push(notTriples);
12446
- OPTION2(() => CONSUME(symbols_exports.dot));
12447
- const moreTriples = OPTION3(() => SUBRULE2(triplesBlock, void 0));
12448
- if (moreTriples) {
12449
- patterns.push(moreTriples);
12310
+ var aggregate = {
12311
+ name: "aggregate",
12312
+ impl: ({ ACTION, SUBRULE, OR }) => (C) => {
12313
+ const wasInAggregate = ACTION(() => C.parseMode.has("inAggregate"));
12314
+ ACTION(() => C.parseMode.add("inAggregate"));
12315
+ const result = OR([
12316
+ { ALT: () => SUBRULE(aggregateCount) },
12317
+ { ALT: () => SUBRULE(aggregateSum) },
12318
+ { ALT: () => SUBRULE(aggregateMin) },
12319
+ { ALT: () => SUBRULE(aggregateMax) },
12320
+ { ALT: () => SUBRULE(aggregateAvg) },
12321
+ { ALT: () => SUBRULE(aggregateSample) },
12322
+ { ALT: () => SUBRULE(aggregateGroup_concat) }
12323
+ ]);
12324
+ ACTION(() => !wasInAggregate && C.parseMode.delete("inAggregate"));
12325
+ ACTION(() => {
12326
+ if (!C.parseMode.has("canParseAggregate")) {
12327
+ throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");
12328
+ }
12329
+ if (C.parseMode.has("inAggregate")) {
12330
+ throw new Error("An aggregate function is not allowed within an aggregate function.");
12450
12331
  }
12451
12332
  });
12452
- ACTION(() => checkNote13(patterns));
12453
- return patterns;
12454
- }
12455
- };
12456
- var graphPatternNotTriples = {
12457
- name: "graphPatternNotTriples",
12458
- impl: ({ SUBRULE, OR }) => () => OR([
12459
- { ALT: () => SUBRULE(groupOrUnionGraphPattern, void 0) },
12460
- { ALT: () => SUBRULE(optionalGraphPattern, void 0) },
12461
- { ALT: () => SUBRULE(minusGraphPattern, void 0) },
12462
- { ALT: () => SUBRULE(graphGraphPattern, void 0) },
12463
- { ALT: () => SUBRULE(serviceGraphPattern, void 0) },
12464
- { ALT: () => SUBRULE(filter3, void 0) },
12465
- { ALT: () => SUBRULE(bind2, void 0) },
12466
- { ALT: () => SUBRULE(inlineData, void 0) }
12467
- ]),
12468
- gImpl: ({ SUBRULE }) => (ast) => {
12469
- switch (ast.subType) {
12470
- case "group":
12471
- case "union":
12472
- SUBRULE(groupOrUnionGraphPattern, ast, void 0);
12473
- break;
12474
- case "optional":
12475
- SUBRULE(optionalGraphPattern, ast, void 0);
12476
- break;
12477
- case "minus":
12478
- SUBRULE(minusGraphPattern, ast, void 0);
12479
- break;
12480
- case "graph":
12481
- SUBRULE(graphGraphPattern, ast, void 0);
12482
- break;
12483
- case "service":
12484
- SUBRULE(serviceGraphPattern, ast, void 0);
12485
- break;
12486
- case "filter":
12487
- SUBRULE(filter3, ast, void 0);
12488
- break;
12489
- case "bind":
12490
- SUBRULE(bind2, ast, void 0);
12491
- break;
12492
- case "values":
12493
- SUBRULE(inlineData, ast, void 0);
12494
- break;
12495
- }
12496
- }
12497
- };
12498
- var optionalGraphPattern = {
12499
- name: "optionalGraphPattern",
12500
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12501
- const optional2 = CONSUME(optional);
12502
- const group = SUBRULE(groupGraphPattern, void 0);
12503
- return ACTION(() => C.factory.patternOptional(group.patterns, C.factory.sourceLocation(optional2, group)));
12504
- },
12505
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12506
- F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
12507
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12508
- }
12509
- };
12510
- var graphGraphPattern = {
12511
- name: "graphGraphPattern",
12512
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12513
- const graph2 = CONSUME(graph_exports.graph);
12514
- const name = SUBRULE(varOrIri, void 0);
12515
- const group = SUBRULE(groupGraphPattern, void 0);
12516
- return ACTION(() => C.factory.patternGraph(name, group.patterns, C.factory.sourceLocation(graph2, group)));
12517
- },
12518
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12519
- F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
12520
- SUBRULE(varOrTerm, ast.name, void 0);
12521
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12522
- }
12523
- };
12524
- var serviceGraphPattern = {
12525
- name: "serviceGraphPattern",
12526
- impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
12527
- const service2 = CONSUME(service);
12528
- const silent2 = OPTION(() => {
12529
- CONSUME(silent);
12530
- return true;
12531
- }) ?? false;
12532
- const name = SUBRULE1(varOrIri, void 0);
12533
- const group = SUBRULE1(groupGraphPattern, void 0);
12534
- return ACTION(() => C.factory.patternService(name, group.patterns, silent2, C.factory.sourceLocation(service2, group)));
12333
+ return result;
12535
12334
  },
12536
12335
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12537
12336
  F2.printFilter(ast, () => {
12538
- PRINT_WORD("SERVICE");
12539
- if (ast.silent) {
12540
- PRINT_WORD("SILENT");
12337
+ PRINT_WORD(ast.aggregation, "(");
12338
+ if (ast.distinct) {
12339
+ PRINT_WORD("DISTINCT");
12541
12340
  }
12542
12341
  });
12543
- SUBRULE(varOrTerm, ast.name, void 0);
12544
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12545
- }
12546
- };
12547
- var bind2 = {
12548
- name: "bind",
12549
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12550
- const bind3 = CONSUME(bind);
12551
- CONSUME(symbols_exports.LParen);
12552
- const expressionVal = SUBRULE(expression, void 0);
12553
- CONSUME(as);
12554
- const variable = SUBRULE(var_, void 0);
12555
- const close = CONSUME(symbols_exports.RParen);
12556
- return ACTION(() => C.factory.patternBind(expressionVal, variable, C.factory.sourceLocation(bind3, close)));
12557
- },
12558
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12559
- F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12560
- SUBRULE(expression, ast.expression, void 0);
12561
- F2.printFilter(ast, () => PRINT_WORD("AS"));
12562
- SUBRULE(var_, ast.variable, void 0);
12342
+ const arg = ast.expression[0];
12343
+ if (F2.isWildcard(arg)) {
12344
+ F2.printFilter(ast, () => PRINT_WORD("*"));
12345
+ } else {
12346
+ SUBRULE(expression, arg);
12347
+ }
12348
+ if (F2.isExpressionAggregateSeparator(ast)) {
12349
+ F2.printFilter(ast, () => PRINT_WORD(";", "SEPARATOR", "=", stringEscapedLexical(ast.separator)));
12350
+ }
12563
12351
  F2.printFilter(ast, () => PRINT_WORD(")"));
12564
12352
  }
12565
12353
  };
12566
- var inlineData = {
12567
- name: "inlineData",
12568
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12569
- const values3 = CONSUME(values2);
12570
- const datablock = SUBRULE(dataBlock, void 0);
12571
- return ACTION(() => C.factory.patternValues(datablock.val, C.factory.sourceLocation(values3, datablock)));
12572
- },
12573
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12574
- const variables = Object.keys(ast.values[0]);
12575
- F2.printFilter(ast, () => {
12576
- PRINT_WORD("VALUES", "(");
12577
- for (const variable of variables) {
12578
- PRINT_WORD(`?${variable}`);
12579
- }
12580
- PRINT_WORD(")", "{");
12581
- });
12582
- for (const mapping of ast.values) {
12583
- F2.printFilter(ast, () => PRINT_WORD("("));
12584
- for (const variable of variables) {
12585
- if (mapping[variable] === void 0) {
12586
- F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
12587
- } else {
12588
- SUBRULE(graphNodePath, mapping[variable], void 0);
12354
+
12355
+ // ../../packages/rules-sparql-1-1/lib/grammar/propertyPaths.ts
12356
+ var path = {
12357
+ name: "path",
12358
+ impl: ({ SUBRULE }) => () => SUBRULE(pathAlternative)
12359
+ };
12360
+ var pathGenerator = {
12361
+ name: "path",
12362
+ gImpl: ({ PRINT, SUBRULE }) => (ast, { factory: F2 }, braces = true) => {
12363
+ if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
12364
+ SUBRULE(iri2, ast);
12365
+ } else {
12366
+ F2.printFilter(ast, () => braces && PRINT("("));
12367
+ switch (ast.subType) {
12368
+ case "|":
12369
+ case "/": {
12370
+ const [head2, ...tail] = ast.items;
12371
+ SUBRULE(pathGenerator, head2, braces);
12372
+ for (const val of tail) {
12373
+ F2.printFilter(ast, () => PRINT(ast.subType));
12374
+ SUBRULE(pathGenerator, val, braces);
12375
+ }
12376
+ break;
12589
12377
  }
12378
+ case "^":
12379
+ F2.printFilter(ast, () => PRINT("^"));
12380
+ SUBRULE(pathGenerator, ast.items[0], braces);
12381
+ break;
12382
+ case "?":
12383
+ case "*":
12384
+ case "+":
12385
+ SUBRULE(pathGenerator, ast.items[0], braces);
12386
+ F2.printFilter(ast, () => PRINT(ast.subType));
12387
+ break;
12388
+ case "!":
12389
+ F2.printFilter(ast, () => PRINT("!"));
12390
+ F2.printFilter(ast, () => PRINT("("));
12391
+ SUBRULE(pathGenerator, ast.items[0], false);
12392
+ F2.printFilter(ast, () => PRINT(")"));
12393
+ break;
12590
12394
  }
12591
- F2.printFilter(ast, () => PRINT_WORD(")"));
12395
+ F2.printFilter(ast, () => braces && PRINT(")"));
12592
12396
  }
12593
- F2.printFilter(ast, () => PRINT_WORD("}"));
12594
12397
  }
12595
12398
  };
12596
- var dataBlock = {
12597
- name: "dataBlock",
12598
- impl: ({ SUBRULE, OR }) => () => OR([
12599
- { ALT: () => SUBRULE(inlineDataOneVar, void 0) },
12600
- { ALT: () => SUBRULE(inlineDataFull, void 0) }
12399
+ function pathChainHelper(name, SEP, subType, subRule) {
12400
+ return {
12401
+ name,
12402
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, MANY }) => (C) => {
12403
+ const head2 = SUBRULE1(subRule);
12404
+ let tailEnd = head2;
12405
+ const tail = [];
12406
+ MANY(() => {
12407
+ CONSUME(SEP);
12408
+ tailEnd = SUBRULE2(subRule);
12409
+ tail.push(tailEnd);
12410
+ });
12411
+ return ACTION(() => tail.length === 0 ? head2 : C.factory.path(subType, [head2, ...tail], C.factory.sourceLocation(head2, tailEnd)));
12412
+ }
12413
+ };
12414
+ }
12415
+ var pathEltOrInverse = {
12416
+ name: "pathEltOrInverse",
12417
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR }) => (C) => OR([
12418
+ { ALT: () => SUBRULE1(pathElt) },
12419
+ { ALT: () => {
12420
+ const hat2 = CONSUME(symbols_exports.hat);
12421
+ const item = SUBRULE2(pathElt);
12422
+ return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12423
+ } }
12601
12424
  ])
12602
12425
  };
12603
- var inlineDataOneVar = {
12604
- name: "inlineDataOneVar",
12605
- impl: ({ ACTION, SUBRULE, CONSUME, MANY }) => (C) => {
12606
- const res = [];
12607
- const varVal = SUBRULE(var_, void 0);
12608
- CONSUME(symbols_exports.LCurly);
12609
- MANY(() => {
12610
- const value = SUBRULE(dataBlockValue, void 0);
12611
- ACTION(() => {
12612
- res.push({ [varVal.value]: value });
12613
- });
12614
- });
12615
- const close = CONSUME(symbols_exports.RCurly);
12616
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(varVal, close)));
12426
+ var pathSequence = pathChainHelper("pathSequence", symbols_exports.slash, "/", pathEltOrInverse);
12427
+ var pathAlternative = pathChainHelper("pathAlternative", symbols_exports.pipe, "|", pathSequence);
12428
+ var pathElt = {
12429
+ name: "pathElt",
12430
+ impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
12431
+ const item = SUBRULE(pathPrimary);
12432
+ const modification = OPTION(() => SUBRULE(pathMod));
12433
+ return ACTION(() => modification === void 0 ? item : C.factory.path(modification.image, [item], C.factory.sourceLocation(item, modification)));
12617
12434
  }
12618
12435
  };
12619
- var inlineDataFull = {
12620
- name: "inlineDataFull",
12621
- impl: ({
12622
- ACTION,
12623
- OR,
12624
- MANY1,
12625
- MANY2,
12626
- MANY3,
12627
- MANY4,
12628
- SUBRULE,
12629
- CONSUME1,
12630
- CONSUME2
12631
- }) => (C) => {
12632
- const res = [];
12633
- const vars = [];
12634
- return OR([
12635
- { ALT: () => {
12636
- const nil2 = CONSUME1(terminals_exports.nil);
12637
- CONSUME1(symbols_exports.LCurly);
12638
- MANY1(() => {
12639
- CONSUME2(terminals_exports.nil);
12640
- res.push({});
12641
- });
12642
- const close = CONSUME1(symbols_exports.RCurly);
12643
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(nil2, close)));
12644
- } },
12645
- { ALT: () => {
12646
- const open = CONSUME1(symbols_exports.LParen);
12647
- MANY2(() => {
12648
- vars.push(SUBRULE(var_, void 0));
12649
- });
12650
- CONSUME1(symbols_exports.RParen);
12651
- CONSUME2(symbols_exports.LCurly);
12652
- MANY3(() => {
12653
- let parsedValues = 0;
12654
- const currentRow = {};
12655
- CONSUME2(symbols_exports.LParen);
12656
- MANY4(() => {
12657
- if (parsedValues >= vars.length) {
12658
- throw new Error("Number of dataBlockValues does not match number of variables. Too much values.");
12659
- }
12660
- const value = SUBRULE(dataBlockValue, void 0);
12661
- ACTION(() => {
12662
- currentRow[vars[parsedValues].value] = value;
12663
- parsedValues++;
12664
- });
12665
- });
12666
- CONSUME2(symbols_exports.RParen);
12667
- ACTION(() => {
12668
- res.push(currentRow);
12669
- if (vars.length !== parsedValues) {
12670
- throw new Error("Number of dataBlockValues does not match number of variables. Too few values.");
12671
- }
12672
- });
12673
- });
12674
- const close = CONSUME2(symbols_exports.RCurly);
12675
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(open, close)));
12676
- } }
12677
- ]);
12678
- }
12436
+ var pathMod = {
12437
+ name: "pathMod",
12438
+ impl: ({ CONSUME, OR }) => () => OR([
12439
+ { ALT: () => CONSUME(symbols_exports.question) },
12440
+ { ALT: () => CONSUME(symbols_exports.star) },
12441
+ { ALT: () => CONSUME(symbols_exports.opPlus) }
12442
+ ])
12679
12443
  };
12680
- var dataBlockValue = {
12681
- name: "dataBlockValue",
12444
+ var pathPrimary = {
12445
+ name: "pathPrimary",
12682
12446
  impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
12683
- { ALT: () => SUBRULE(iri2, void 0) },
12684
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
12685
- { ALT: () => SUBRULE(numericLiteral, void 0) },
12686
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
12447
+ { ALT: () => SUBRULE(iri2) },
12448
+ { ALT: () => SUBRULE(verbA) },
12449
+ { ALT: () => SUBRULE(pathNegatedPropertySet) },
12687
12450
  { ALT: () => {
12688
- CONSUME(undef);
12689
- return void 0;
12451
+ CONSUME(symbols_exports.LParen);
12452
+ const resRecursive = SUBRULE(path);
12453
+ CONSUME(symbols_exports.RParen);
12454
+ return resRecursive;
12690
12455
  } }
12691
12456
  ])
12692
12457
  };
12693
- var minusGraphPattern = {
12694
- name: "minusGraphPattern",
12695
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12696
- const minus2 = CONSUME(minus);
12697
- const group = SUBRULE(groupGraphPattern, void 0);
12698
- return ACTION(() => C.factory.patternMinus(group.patterns, C.factory.sourceLocation(minus2, group)));
12699
- },
12700
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12701
- F2.printFilter(ast, () => PRINT_WORD("MINUS"));
12702
- SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc), void 0);
12703
- }
12704
- };
12705
- var groupOrUnionGraphPattern = {
12706
- name: "groupOrUnionGraphPattern",
12707
- impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => {
12708
- const groups = [];
12709
- const group = SUBRULE1(groupGraphPattern, void 0);
12710
- groups.push(group);
12711
- MANY(() => {
12712
- CONSUME(union);
12713
- const group2 = SUBRULE2(groupGraphPattern, void 0);
12714
- groups.push(group2);
12715
- });
12716
- return ACTION(() => groups.length === 1 ? groups[0] : C.factory.patternUnion(
12717
- groups,
12718
- C.factory.sourceLocation(group, groups.at(-1))
12719
- ));
12720
- },
12721
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12722
- if (F2.isPatternUnion(ast)) {
12723
- const [head2, ...tail] = ast.patterns;
12724
- SUBRULE(groupGraphPattern, head2, void 0);
12725
- for (const pattern of tail) {
12726
- F2.printFilter(ast, () => PRINT_WORD("UNION"));
12727
- SUBRULE(groupGraphPattern, pattern, void 0);
12728
- }
12729
- } else {
12730
- SUBRULE(groupGraphPattern, ast, void 0);
12731
- }
12732
- }
12733
- };
12734
- var filter3 = {
12735
- name: "filter",
12736
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12737
- const filterToken = CONSUME(filter2);
12738
- const expression2 = SUBRULE(constraint, void 0);
12739
- return ACTION(() => C.factory.patternFilter(expression2, C.factory.sourceLocation(filterToken, expression2)));
12740
- },
12741
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12742
- F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
12743
- SUBRULE(expression, ast.expression, void 0);
12744
- F2.printFilter(ast, () => PRINT_WORD(")"));
12458
+ var pathNegatedPropertySet = {
12459
+ name: "pathNegatedPropertySet",
12460
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, OR, MANY }) => (C) => {
12461
+ const exclamation2 = CONSUME(symbols_exports.exclamation);
12462
+ return OR([
12463
+ { ALT: () => {
12464
+ const noAlternative = SUBRULE1(pathOneInPropertySet);
12465
+ return ACTION(() => C.factory.path("!", [noAlternative], C.factory.sourceLocation(exclamation2, noAlternative)));
12466
+ } },
12467
+ { ALT: () => {
12468
+ const open = CONSUME(symbols_exports.LParen);
12469
+ const head2 = SUBRULE2(pathOneInPropertySet);
12470
+ const tail = [];
12471
+ MANY(() => {
12472
+ CONSUME(symbols_exports.pipe);
12473
+ const item = SUBRULE3(pathOneInPropertySet);
12474
+ tail.push(item);
12475
+ });
12476
+ const close = CONSUME(symbols_exports.RParen);
12477
+ return ACTION(() => {
12478
+ const F2 = C.factory;
12479
+ if (tail.length === 0) {
12480
+ return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
12481
+ }
12482
+ return F2.path(
12483
+ "!",
12484
+ [F2.path("|", [head2, ...tail], F2.sourceLocation(open, close))],
12485
+ F2.sourceLocation(exclamation2, close)
12486
+ );
12487
+ });
12488
+ } }
12489
+ ]);
12745
12490
  }
12746
12491
  };
12747
- var constraint = {
12748
- name: "constraint",
12749
- impl: ({ SUBRULE, OR }) => () => OR([
12750
- { ALT: () => SUBRULE(brackettedExpression, void 0) },
12751
- { ALT: () => SUBRULE(builtInCall, void 0) },
12752
- { ALT: () => SUBRULE(functionCall, void 0) }
12492
+ var pathOneInPropertySet = {
12493
+ name: "pathOneInPropertySet",
12494
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
12495
+ { ALT: () => SUBRULE1(iri2) },
12496
+ { ALT: () => SUBRULE1(verbA) },
12497
+ { ALT: () => {
12498
+ const hat2 = CONSUME(symbols_exports.hat);
12499
+ const item = OR2([
12500
+ { ALT: () => SUBRULE2(iri2) },
12501
+ { ALT: () => SUBRULE2(verbA) }
12502
+ ]);
12503
+ return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12504
+ } }
12753
12505
  ])
12754
12506
  };
12755
- var functionCall = {
12756
- name: "functionCall",
12757
- impl: ({ ACTION, SUBRULE }) => (C) => {
12758
- const func = SUBRULE(iri2, void 0);
12759
- const args = SUBRULE(argList, void 0);
12760
- return ACTION(() => C.factory.expressionFunctionCall(
12761
- func,
12762
- args.val.args,
12763
- args.val.distinct,
12764
- C.factory.sourceLocation(func, args)
12765
- ));
12766
- }
12767
- };
12768
12507
 
12769
- // ../../packages/rules-sparql-1-1/lib/expressionHelpers.ts
12770
- function funcExpr1(func) {
12771
- return {
12772
- name: unCapitalize(func.name),
12773
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12774
- const operator = CONSUME(func);
12775
- CONSUME(symbols_exports.LParen);
12776
- const arg = SUBRULE(expression, void 0);
12777
- const close = CONSUME(symbols_exports.RParen);
12778
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12779
- }
12508
+ // ../../packages/rules-sparql-1-1/lib/grammar/tripleBlock.ts
12509
+ function triplesDotSeperated(triplesSameSubjectSubrule) {
12510
+ return ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME, OPTION }) => (C) => {
12511
+ const triples = [];
12512
+ let parsedDot = true;
12513
+ let dotToken;
12514
+ AT_LEAST_ONE({
12515
+ GATE: () => parsedDot,
12516
+ DEF: () => {
12517
+ parsedDot = false;
12518
+ const template = SUBRULE(triplesSameSubjectSubrule);
12519
+ ACTION(() => {
12520
+ triples.push(...template);
12521
+ });
12522
+ OPTION(() => {
12523
+ dotToken = CONSUME(symbols_exports.dot);
12524
+ parsedDot = true;
12525
+ });
12526
+ }
12527
+ });
12528
+ return ACTION(() => C.factory.patternBgp(triples, C.factory.sourceLocation(...triples, dotToken)));
12780
12529
  };
12781
12530
  }
12782
- function funcExpr2(func) {
12783
- return {
12784
- name: unCapitalize(func.name),
12785
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => {
12786
- const operator = CONSUME(func);
12787
- CONSUME(symbols_exports.LParen);
12788
- const arg1 = SUBRULE1(expression, void 0);
12789
- CONSUME(symbols_exports.comma);
12790
- const arg2 = SUBRULE2(expression, void 0);
12791
- const close = CONSUME(symbols_exports.RParen);
12792
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2], C.factory.sourceLocation(operator, close)));
12531
+ var triplesBlock = {
12532
+ name: "triplesBlock",
12533
+ impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
12534
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12535
+ for (const [index, triple] of ast.triples.entries()) {
12536
+ HANDLE_LOC(triple, () => {
12537
+ const nextTriple = ast.triples.at(index);
12538
+ if (F2.isTripleCollection(triple)) {
12539
+ SUBRULE(graphNodePath, triple);
12540
+ F2.printFilter(triple, () => PRINT_WORD("."));
12541
+ } else {
12542
+ SUBRULE(graphNodePath, triple.subject);
12543
+ if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12544
+ SUBRULE(varOrTerm, triple.predicate);
12545
+ } else {
12546
+ SUBRULE(pathGenerator, triple.predicate, void 0);
12547
+ }
12548
+ SUBRULE(graphNodePath, triple.object);
12549
+ if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12550
+ F2.printFilter(ast, () => PRINT_WORD("."));
12551
+ } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12552
+ F2.printFilter(ast, () => PRINT_WORD(","));
12553
+ } else {
12554
+ F2.printFilter(ast, () => PRINT_WORD(";"));
12555
+ }
12556
+ }
12557
+ });
12793
12558
  }
12794
- };
12795
- }
12796
- function funcExpr3(func) {
12559
+ }
12560
+ };
12561
+ function triplesSameSubjectImpl(name, allowPaths) {
12797
12562
  return {
12798
- name: unCapitalize(func.name),
12799
- impl: ({ ACTION, CONSUME, CONSUME1, CONSUME2, SUBRULE1, SUBRULE2, SUBRULE3 }) => (C) => {
12800
- const operator = CONSUME(func);
12801
- CONSUME(symbols_exports.LParen);
12802
- const arg1 = SUBRULE1(expression, void 0);
12803
- CONSUME1(symbols_exports.comma);
12804
- const arg2 = SUBRULE2(expression, void 0);
12805
- CONSUME2(symbols_exports.comma);
12806
- const arg3 = SUBRULE3(expression, void 0);
12807
- const close = CONSUME(symbols_exports.RParen);
12808
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
12809
- }
12563
+ name,
12564
+ impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
12565
+ { ALT: () => {
12566
+ const subject = SUBRULE(varOrTerm);
12567
+ const res = SUBRULE(
12568
+ allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty,
12569
+ ACTION(() => C.factory.dematerialized(subject))
12570
+ );
12571
+ return ACTION(() => {
12572
+ if (res.length > 0) {
12573
+ res[0].subject = subject;
12574
+ res[0].loc = C.factory.sourceLocation(subject, res[0]);
12575
+ }
12576
+ return res;
12577
+ });
12578
+ } },
12579
+ { ALT: () => {
12580
+ const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode);
12581
+ const restNode = SUBRULE(
12582
+ allowPaths ? propertyListPath : propertyList,
12583
+ ACTION(() => C.factory.graphNodeIdentifier(subjectNode))
12584
+ );
12585
+ return ACTION(() => {
12586
+ if (restNode.length === 0) {
12587
+ return [subjectNode];
12588
+ }
12589
+ restNode[0].subject = subjectNode;
12590
+ restNode[0].loc = C.factory.sourceLocation(subjectNode, restNode[0]);
12591
+ return restNode;
12592
+ });
12593
+ } }
12594
+ ])
12810
12595
  };
12811
12596
  }
12812
- function funcVar1(func) {
12597
+ var triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
12598
+ var triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
12599
+ var triplesTemplate = {
12600
+ name: "triplesTemplate",
12601
+ impl: triplesDotSeperated(triplesSameSubject)
12602
+ };
12603
+ function propertyListImpl(name, allowPaths) {
12813
12604
  return {
12814
- name: unCapitalize(func.name),
12815
- impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12816
- const operator = CONSUME(func);
12817
- CONSUME(symbols_exports.LParen);
12818
- const arg = SUBRULE(var_, void 0);
12819
- const close = CONSUME(symbols_exports.RParen);
12820
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12821
- }
12605
+ name,
12606
+ impl: ({ SUBRULE, OPTION }) => (_, subject) => OPTION(() => SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, subject)) ?? []
12822
12607
  };
12823
12608
  }
12824
- function funcExprOrNil1(func) {
12609
+ var propertyList = propertyListImpl("propertyList", false);
12610
+ var propertyListPath = propertyListImpl("propertyListPath", true);
12611
+ function propertyListNotEmptyImplementation(name, allowPaths) {
12825
12612
  return {
12826
- name: unCapitalize(func.name),
12827
- impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
12828
- const operator = CONSUME(func);
12829
- return OR([
12830
- { ALT: () => {
12831
- CONSUME(symbols_exports.LParen);
12832
- const arg = SUBRULE(expression, void 0);
12833
- const close = CONSUME(symbols_exports.RParen);
12834
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12835
- } },
12836
- { ALT: () => {
12837
- const nil2 = CONSUME(terminals_exports.nil);
12838
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12839
- } }
12840
- ]);
12613
+ name,
12614
+ impl: ({ ACTION, CONSUME, AT_LEAST_ONE, SUBRULE1, MANY2, OR1 }) => (_, subject) => {
12615
+ const result = [];
12616
+ let parsedSemi = true;
12617
+ AT_LEAST_ONE({
12618
+ GATE: () => parsedSemi,
12619
+ DEF: () => {
12620
+ parsedSemi = false;
12621
+ const predicate = allowPaths ? OR1([
12622
+ { ALT: () => SUBRULE1(verbPath) },
12623
+ { ALT: () => SUBRULE1(verbSimple) }
12624
+ ]) : SUBRULE1(verb);
12625
+ const triples = SUBRULE1(
12626
+ allowPaths ? objectListPath : objectList,
12627
+ subject,
12628
+ predicate
12629
+ );
12630
+ MANY2(() => {
12631
+ CONSUME(symbols_exports.semi);
12632
+ parsedSemi = true;
12633
+ });
12634
+ ACTION(() => {
12635
+ result.push(...triples);
12636
+ });
12637
+ }
12638
+ });
12639
+ return result;
12841
12640
  }
12842
12641
  };
12843
12642
  }
12844
- function funcNil1(func) {
12643
+ var propertyListNotEmpty = propertyListNotEmptyImplementation("propertyListNotEmpty", false);
12644
+ var propertyListPathNotEmpty = propertyListNotEmptyImplementation("propertyListPathNotEmpty", true);
12645
+ var verbPath = {
12646
+ name: "verbPath",
12647
+ impl: ({ SUBRULE }) => () => SUBRULE(path)
12648
+ };
12649
+ var verbSimple = {
12650
+ name: "verbSimple",
12651
+ impl: ({ SUBRULE }) => () => SUBRULE(var_)
12652
+ };
12653
+ function objectListImpl(name, allowPaths) {
12845
12654
  return {
12846
- name: unCapitalize(func.name),
12847
- impl: ({ ACTION, CONSUME }) => (C) => {
12848
- const operator = CONSUME(func);
12849
- const nil2 = CONSUME(terminals_exports.nil);
12850
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12655
+ name,
12656
+ impl: ({ ACTION, SUBRULE, AT_LEAST_ONE_SEP }) => (_, subj, pred) => {
12657
+ const objects = [];
12658
+ AT_LEAST_ONE_SEP({
12659
+ SEP: symbols_exports.comma,
12660
+ DEF: () => {
12661
+ const objectTriple = SUBRULE(allowPaths ? objectPath : object, subj, pred);
12662
+ ACTION(() => {
12663
+ objects.push(objectTriple);
12664
+ });
12665
+ }
12666
+ });
12667
+ return objects;
12851
12668
  }
12852
12669
  };
12853
12670
  }
12854
- function funcExprList1(func) {
12671
+ var objectList = objectListImpl("objectList", false);
12672
+ var objectListPath = objectListImpl("objectListPath", true);
12673
+ function objectImpl(name, allowPaths) {
12855
12674
  return {
12856
- name: unCapitalize(func.name),
12857
- impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
12858
- const operator = CONSUME(func);
12859
- const args = SUBRULE(expressionList, void 0);
12860
- return ACTION(() => C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));
12675
+ name,
12676
+ impl: ({ ACTION, SUBRULE }) => (C, subject, predicate) => {
12677
+ const node = SUBRULE(allowPaths ? graphNodePath : graphNode);
12678
+ return ACTION(() => C.factory.triple(subject, predicate, node));
12861
12679
  }
12862
12680
  };
12863
12681
  }
12864
- function funcExpr2or3(func) {
12682
+ var object = objectImpl("object", false);
12683
+ var objectPath = objectImpl("objectPath", true);
12684
+ function collectionImpl(name, allowPaths) {
12865
12685
  return {
12866
- name: unCapitalize(func.name),
12867
- impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, CONSUME1, OPTION, CONSUME2 }) => (C) => {
12868
- const operator = CONSUME(func);
12869
- CONSUME(symbols_exports.LParen);
12870
- const arg1 = SUBRULE1(expression, void 0);
12871
- CONSUME1(symbols_exports.comma);
12872
- const arg2 = SUBRULE2(expression, void 0);
12873
- const arg3 = OPTION(() => {
12874
- CONSUME2(symbols_exports.comma);
12875
- return SUBRULE3(expression, void 0);
12686
+ name,
12687
+ impl: ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME }) => (C) => {
12688
+ const terms = [];
12689
+ const startToken = CONSUME(symbols_exports.LParen);
12690
+ AT_LEAST_ONE(() => {
12691
+ terms.push(SUBRULE(allowPaths ? graphNodePath : graphNode));
12876
12692
  });
12877
- const close = CONSUME(symbols_exports.RParen);
12878
- return ACTION(() => C.factory.expressionOperation(
12879
- operator.image,
12880
- arg3 ? [arg1, arg2, arg3] : [arg1, arg2],
12881
- C.factory.sourceLocation(operator, close)
12882
- ));
12693
+ const endToken = CONSUME(symbols_exports.RParen);
12694
+ return ACTION(() => {
12695
+ const F2 = C.factory;
12696
+ const triples = [];
12697
+ const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#first" /* FIRST */, void 0);
12698
+ const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest" /* REST */, void 0);
12699
+ const predNil = F2.namedNode(F2.sourceLocationNoMaterialize(), "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil" /* NIL */, void 0);
12700
+ const listHead = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12701
+ let iterHead = listHead;
12702
+ for (const [index, term] of terms.entries()) {
12703
+ const lastInList = index === terms.length - 1;
12704
+ const headTriple = F2.triple(
12705
+ iterHead,
12706
+ predFirst,
12707
+ term
12708
+ );
12709
+ triples.push(headTriple);
12710
+ if (lastInList) {
12711
+ const nilTriple = F2.triple(iterHead, predRest, predNil);
12712
+ triples.push(nilTriple);
12713
+ } else {
12714
+ const tail = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12715
+ const linkTriple = F2.triple(iterHead, predRest, tail);
12716
+ triples.push(linkTriple);
12717
+ iterHead = tail;
12718
+ }
12719
+ }
12720
+ return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
12721
+ });
12722
+ },
12723
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12724
+ F2.printFilter(ast, () => PRINT_WORD("("));
12725
+ for (const [idx, triple] of ast.triples.entries()) {
12726
+ if (idx % 2 === 0) {
12727
+ SUBRULE(allowPaths ? graphNodePath : graphNode, triple.object);
12728
+ }
12729
+ }
12730
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12883
12731
  }
12884
12732
  };
12885
12733
  }
12886
- function funcExpr3or4(func) {
12734
+ var collection = collectionImpl("collection", false);
12735
+ var collectionPath = collectionImpl("collectionPath", true);
12736
+ function triplesNodeImpl(name, allowPaths) {
12887
12737
  return {
12888
- name: unCapitalize(func.name),
12889
- impl: ({
12890
- ACTION,
12891
- CONSUME,
12892
- SUBRULE1,
12893
- SUBRULE2,
12894
- SUBRULE3,
12895
- SUBRULE4,
12896
- CONSUME1,
12897
- OPTION,
12898
- CONSUME2,
12899
- CONSUME3
12900
- }) => (C) => {
12901
- const operator = CONSUME(func);
12902
- CONSUME(symbols_exports.LParen);
12903
- const arg1 = SUBRULE1(expression, void 0);
12904
- CONSUME1(symbols_exports.comma);
12905
- const arg2 = SUBRULE2(expression, void 0);
12906
- CONSUME2(symbols_exports.comma);
12907
- const arg3 = SUBRULE3(expression, void 0);
12908
- const arg4 = OPTION(() => {
12909
- CONSUME3(symbols_exports.comma);
12910
- return SUBRULE4(expression, void 0);
12911
- });
12912
- const close = CONSUME(symbols_exports.RParen);
12913
- return ACTION(() => C.factory.expressionOperation(
12914
- operator.image,
12915
- arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3],
12916
- C.factory.sourceLocation(operator, close)
12917
- ));
12918
- }
12738
+ name,
12739
+ impl: ({ SUBRULE, OR }) => () => OR([
12740
+ { ALT: () => SUBRULE(allowPaths ? collectionPath : collection) },
12741
+ { ALT: () => SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList) }
12742
+ ]),
12743
+ gImpl: ({ SUBRULE }) => (ast) => ast.subType === "list" ? SUBRULE(allowPaths ? collectionPath : collection, ast) : SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, ast)
12919
12744
  };
12920
12745
  }
12921
- function funcGroupGraphPattern(func) {
12746
+ var triplesNode = triplesNodeImpl("triplesNode", false);
12747
+ var triplesNodePath = triplesNodeImpl("triplesNodePath", true);
12748
+ function blankNodePropertyListImpl(name, allowPaths) {
12749
+ const propertyPathNotEmptyImpl = allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty;
12922
12750
  return {
12923
- name: unCapitalize(func.name),
12751
+ name,
12924
12752
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12925
- const operator = CONSUME(func);
12926
- const group = SUBRULE(groupGraphPattern, void 0);
12927
- return ACTION(() => C.factory.expressionPatternOperation(
12928
- operator.image,
12929
- group,
12930
- C.factory.sourceLocation(operator, group)
12753
+ const startToken = CONSUME(symbols_exports.LSquare);
12754
+ const blankNode2 = ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocationNoMaterialize()));
12755
+ const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
12756
+ const endToken = CONSUME(symbols_exports.RSquare);
12757
+ return ACTION(() => C.factory.tripleCollectionBlankNodeProperties(
12758
+ blankNode2,
12759
+ propList,
12760
+ C.factory.sourceLocation(startToken, endToken)
12931
12761
  ));
12762
+ },
12763
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12764
+ F2.printFilter(ast, () => PRINT("["));
12765
+ for (const triple of ast.triples) {
12766
+ HANDLE_LOC(triple, () => {
12767
+ if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12768
+ SUBRULE(varOrTerm, triple.predicate);
12769
+ } else {
12770
+ SUBRULE(pathGenerator, triple.predicate, void 0);
12771
+ }
12772
+ SUBRULE(graphNodePath, triple.object);
12773
+ F2.printFilter(ast, () => PRINT_WORD(";"));
12774
+ });
12775
+ }
12776
+ F2.printFilter(ast, () => PRINT("]"));
12932
12777
  }
12933
12778
  };
12934
12779
  }
12935
- function baseAggregateFunc(func) {
12780
+ var blankNodePropertyList = blankNodePropertyListImpl("blankNodePropertyList", false);
12781
+ var blankNodePropertyListPath = blankNodePropertyListImpl("blankNodePropertyListPath", true);
12782
+ function graphNodeImpl(name, allowPaths) {
12783
+ const triplesNodeRule = allowPaths ? triplesNodePath : triplesNode;
12936
12784
  return {
12937
- name: unCapitalize(func.name),
12938
- impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
12939
- const operator = CONSUME(func);
12940
- CONSUME(symbols_exports.LParen);
12941
- const distinct2 = OPTION(() => CONSUME(distinct));
12942
- const expr1 = SUBRULE(expression, void 0);
12943
- const close = CONSUME(symbols_exports.RParen);
12944
- return ACTION(() => C.factory.aggregate(
12945
- operator.image,
12946
- distinct2 !== void 0,
12947
- expr1,
12948
- void 0,
12949
- C.factory.sourceLocation(operator, close)
12950
- ));
12785
+ name,
12786
+ impl: ({ SUBRULE, OR }) => (C) => OR([
12787
+ { ALT: () => SUBRULE(varOrTerm) },
12788
+ {
12789
+ GATE: () => C.parseMode.has("canCreateBlankNodes"),
12790
+ ALT: () => SUBRULE(triplesNodeRule)
12791
+ }
12792
+ ]),
12793
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12794
+ if (F2.isTerm(ast)) {
12795
+ SUBRULE(varOrTerm, ast);
12796
+ } else {
12797
+ SUBRULE(triplesNodeRule, ast);
12798
+ }
12951
12799
  }
12952
12800
  };
12953
12801
  }
12802
+ var graphNode = graphNodeImpl("graphNode", false);
12803
+ var graphNodePath = graphNodeImpl("graphNodePath", true);
12954
12804
 
12955
- // ../../packages/rules-sparql-1-1/lib/grammar/builtIn.ts
12956
- var builtInStr = funcExpr1(BuildinCalls_exports.str);
12957
- var builtInLang = funcExpr1(BuildinCalls_exports.lang);
12958
- var builtInLangmatches = funcExpr2(BuildinCalls_exports.langmatches);
12959
- var builtInDatatype = funcExpr1(BuildinCalls_exports.datatype);
12960
- var builtInBound = funcVar1(BuildinCalls_exports.bound);
12961
- var builtInIri = funcExpr1(BuildinCalls_exports.iri);
12962
- var builtInUri = funcExpr1(BuildinCalls_exports.uri);
12963
- var builtInBnodeSparqlJs = funcExprOrNil1(BuildinCalls_exports.bnode);
12964
- var builtInRand = funcNil1(BuildinCalls_exports.rand);
12965
- var builtInAbs = funcExpr1(BuildinCalls_exports.abs);
12966
- var builtInCeil = funcExpr1(BuildinCalls_exports.ceil);
12967
- var builtInFloor = funcExpr1(BuildinCalls_exports.floor);
12968
- var builtInRound = funcExpr1(BuildinCalls_exports.round);
12969
- var builtInConcat = funcExprList1(BuildinCalls_exports.concat);
12970
- var builtInStrlen = funcExpr1(BuildinCalls_exports.strlen);
12971
- var builtInUcase = funcExpr1(BuildinCalls_exports.ucase);
12972
- var builtInLcase = funcExpr1(BuildinCalls_exports.lcase);
12973
- var builtInEncode_for_uri = funcExpr1(BuildinCalls_exports.encode_for_uri);
12974
- var builtInContains = funcExpr2(BuildinCalls_exports.contains);
12975
- var builtInStrstarts = funcExpr2(BuildinCalls_exports.strstarts);
12976
- var builtInStrends = funcExpr2(BuildinCalls_exports.strends);
12977
- var builtInStrbefore = funcExpr2(BuildinCalls_exports.strbefore);
12978
- var builtInStrafter = funcExpr2(BuildinCalls_exports.strafter);
12979
- var builtInYear = funcExpr1(BuildinCalls_exports.year);
12980
- var builtInMonth = funcExpr1(BuildinCalls_exports.month);
12981
- var builtInDay = funcExpr1(BuildinCalls_exports.day);
12982
- var builtInHours = funcExpr1(BuildinCalls_exports.hours);
12983
- var builtInMinutes = funcExpr1(BuildinCalls_exports.minutes);
12984
- var builtInSeconds = funcExpr1(BuildinCalls_exports.seconds);
12985
- var builtInTimezone = funcExpr1(BuildinCalls_exports.timezone);
12986
- var builtInTz = funcExpr1(BuildinCalls_exports.tz);
12987
- var builtInNow = funcNil1(BuildinCalls_exports.now);
12988
- var builtInUuid = funcNil1(BuildinCalls_exports.uuid);
12989
- var builtInStruuid = funcNil1(BuildinCalls_exports.struuid);
12990
- var builtInMd5 = funcExpr1(BuildinCalls_exports.md5);
12991
- var builtInSha1 = funcExpr1(BuildinCalls_exports.sha1);
12992
- var builtInSha256 = funcExpr1(BuildinCalls_exports.sha256);
12993
- var builtInSha384 = funcExpr1(BuildinCalls_exports.sha384);
12994
- var builtInSha512 = funcExpr1(BuildinCalls_exports.sha512);
12995
- var builtInCoalesce = funcExprList1(BuildinCalls_exports.coalesce);
12996
- var builtInIf = funcExpr3(BuildinCalls_exports.if_);
12997
- var builtInStrlang = funcExpr2(BuildinCalls_exports.strlang);
12998
- var builtInStrdt = funcExpr2(BuildinCalls_exports.strdt);
12999
- var builtInSameterm = funcExpr2(BuildinCalls_exports.sameterm);
13000
- var builtInIsiri = funcExpr1(BuildinCalls_exports.isiri);
13001
- var builtInIsuri = funcExpr1(BuildinCalls_exports.isuri);
13002
- var builtInIsblank = funcExpr1(BuildinCalls_exports.isblank);
13003
- var builtInIsliteral = funcExpr1(BuildinCalls_exports.isliteral);
13004
- var builtInIsnumeric = funcExpr1(BuildinCalls_exports.isnumeric);
13005
- function builtInCallList(SUBRULE) {
13006
- return [
13007
- { ALT: () => SUBRULE(aggregate, void 0) },
13008
- { ALT: () => SUBRULE(builtInStr, void 0) },
13009
- { ALT: () => SUBRULE(builtInLang, void 0) },
13010
- { ALT: () => SUBRULE(builtInLangmatches, void 0) },
13011
- { ALT: () => SUBRULE(builtInDatatype, void 0) },
13012
- { ALT: () => SUBRULE(builtInBound, void 0) },
13013
- { ALT: () => SUBRULE(builtInIri, void 0) },
13014
- { ALT: () => SUBRULE(builtInUri, void 0) },
13015
- { ALT: () => SUBRULE(builtInBnodeSparqlJs, void 0) },
13016
- { ALT: () => SUBRULE(builtInRand, void 0) },
13017
- { ALT: () => SUBRULE(builtInAbs, void 0) },
13018
- { ALT: () => SUBRULE(builtInCeil, void 0) },
13019
- { ALT: () => SUBRULE(builtInFloor, void 0) },
13020
- { ALT: () => SUBRULE(builtInRound, void 0) },
13021
- { ALT: () => SUBRULE(builtInConcat, void 0) },
13022
- { ALT: () => SUBRULE(substringExpression, void 0) },
13023
- { ALT: () => SUBRULE(builtInStrlen, void 0) },
13024
- { ALT: () => SUBRULE(strReplaceExpression, void 0) },
13025
- { ALT: () => SUBRULE(builtInUcase, void 0) },
13026
- { ALT: () => SUBRULE(builtInLcase, void 0) },
13027
- { ALT: () => SUBRULE(builtInEncode_for_uri, void 0) },
13028
- { ALT: () => SUBRULE(builtInContains, void 0) },
13029
- { ALT: () => SUBRULE(builtInStrstarts, void 0) },
13030
- { ALT: () => SUBRULE(builtInStrends, void 0) },
13031
- { ALT: () => SUBRULE(builtInStrbefore, void 0) },
13032
- { ALT: () => SUBRULE(builtInStrafter, void 0) },
13033
- { ALT: () => SUBRULE(builtInYear, void 0) },
13034
- { ALT: () => SUBRULE(builtInMonth, void 0) },
13035
- { ALT: () => SUBRULE(builtInDay, void 0) },
13036
- { ALT: () => SUBRULE(builtInHours, void 0) },
13037
- { ALT: () => SUBRULE(builtInMinutes, void 0) },
13038
- { ALT: () => SUBRULE(builtInSeconds, void 0) },
13039
- { ALT: () => SUBRULE(builtInTimezone, void 0) },
13040
- { ALT: () => SUBRULE(builtInTz, void 0) },
13041
- { ALT: () => SUBRULE(builtInNow, void 0) },
13042
- { ALT: () => SUBRULE(builtInUuid, void 0) },
13043
- { ALT: () => SUBRULE(builtInStruuid, void 0) },
13044
- { ALT: () => SUBRULE(builtInMd5, void 0) },
13045
- { ALT: () => SUBRULE(builtInSha1, void 0) },
13046
- { ALT: () => SUBRULE(builtInSha256, void 0) },
13047
- { ALT: () => SUBRULE(builtInSha384, void 0) },
13048
- { ALT: () => SUBRULE(builtInSha512, void 0) },
13049
- { ALT: () => SUBRULE(builtInCoalesce, void 0) },
13050
- { ALT: () => SUBRULE(builtInIf, void 0) },
13051
- { ALT: () => SUBRULE(builtInStrlang, void 0) },
13052
- { ALT: () => SUBRULE(builtInStrdt, void 0) },
13053
- { ALT: () => SUBRULE(builtInSameterm, void 0) },
13054
- { ALT: () => SUBRULE(builtInIsiri, void 0) },
13055
- { ALT: () => SUBRULE(builtInIsuri, void 0) },
13056
- { ALT: () => SUBRULE(builtInIsblank, void 0) },
13057
- { ALT: () => SUBRULE(builtInIsliteral, void 0) },
13058
- { ALT: () => SUBRULE(builtInIsnumeric, void 0) },
13059
- { ALT: () => SUBRULE(regexExpression, void 0) },
13060
- { ALT: () => SUBRULE(existsFunc, void 0) },
13061
- { ALT: () => SUBRULE(notExistsFunc, void 0) }
13062
- ];
13063
- }
13064
- var builtInCall = {
13065
- name: "builtInCall",
13066
- impl: ({ OR, SUBRULE, cache }) => () => {
13067
- const cached = cache.get(builtInCall);
13068
- if (cached) {
13069
- return OR(cached);
13070
- }
13071
- const builtIns = builtInCallList(SUBRULE);
13072
- cache.set(builtInCall, builtIns);
13073
- return OR(builtIns);
12805
+ // ../../packages/rules-sparql-1-1/lib/grammar/whereClause.ts
12806
+ var whereClause = {
12807
+ name: "whereClause",
12808
+ impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
12809
+ const where2 = OPTION(() => CONSUME(where));
12810
+ const group = SUBRULE(groupGraphPattern);
12811
+ return ACTION(() => C.factory.wrap(group, C.factory.sourceLocation(where2, group)));
12812
+ },
12813
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12814
+ F2.printFilter(ast, () => PRINT_WORD("WHERE"));
12815
+ SUBRULE(groupGraphPattern, ast.val);
13074
12816
  }
13075
12817
  };
13076
- var regexExpression = funcExpr2or3(BuildinCalls_exports.regex);
13077
- var substringExpression = funcExpr2or3(BuildinCalls_exports.substr);
13078
- var strReplaceExpression = funcExpr3or4(BuildinCalls_exports.replace);
13079
- var existsFunc = funcGroupGraphPattern(BuildinCalls_exports.exists);
13080
- var notExistsFunc = funcGroupGraphPattern(BuildinCalls_exports.notexists);
13081
- var aggregateCount = {
13082
- name: unCapitalize(BuildinCalls_exports.count.name),
13083
- impl: ({ ACTION, CONSUME, SUBRULE, OR, OPTION }) => (C) => {
13084
- const operatorToken = CONSUME(BuildinCalls_exports.count);
13085
- CONSUME(symbols_exports.LParen);
13086
- const distinctToken = OPTION(() => CONSUME(distinct));
13087
- const expressionVal = OR([
13088
- { ALT: () => {
13089
- const starToken = CONSUME(symbols_exports.star);
13090
- return ACTION(() => C.factory.wildcard(C.factory.sourceLocation(starToken)));
13091
- } },
13092
- { ALT: () => SUBRULE(expression, void 0) }
12818
+ var groupGraphPattern = {
12819
+ name: "groupGraphPattern",
12820
+ impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => {
12821
+ const open = CONSUME(symbols_exports.LCurly);
12822
+ const patterns = OR([
12823
+ { ALT: () => [SUBRULE(subSelect)] },
12824
+ { ALT: () => SUBRULE(groupGraphPatternSub) }
13093
12825
  ]);
13094
- const closeToken = CONSUME(symbols_exports.RParen);
13095
- return ACTION(() => {
13096
- const F2 = C.factory;
13097
- if (C.factory.isWildcard(expressionVal)) {
13098
- return F2.aggregate(
13099
- operatorToken.image,
13100
- Boolean(distinctToken),
13101
- expressionVal,
13102
- void 0,
13103
- C.factory.sourceLocation(operatorToken, closeToken)
13104
- );
12826
+ const close = CONSUME(symbols_exports.RCurly);
12827
+ return ACTION(() => C.factory.patternGroup(patterns, C.factory.sourceLocation(open, close)));
12828
+ },
12829
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12830
+ F2.printFilter(ast, () => PRINT_WORD("{"));
12831
+ for (const pattern of ast.patterns) {
12832
+ SUBRULE(generatePattern, pattern);
12833
+ }
12834
+ F2.printFilter(ast, () => PRINT_WORD("}"));
12835
+ }
12836
+ };
12837
+ var generatePattern = {
12838
+ name: "generatePattern",
12839
+ gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12840
+ if (ast.type === "query") {
12841
+ SUBRULE(query, F2.querySelect({
12842
+ context: [],
12843
+ datasets: F2.datasetClauses([], F2.sourceLocation()),
12844
+ where: ast.where,
12845
+ variables: ast.variables,
12846
+ solutionModifiers: ast.solutionModifiers,
12847
+ values: ast.values,
12848
+ distinct: ast.distinct,
12849
+ reduced: ast.reduced
12850
+ }, ast.loc));
12851
+ } else if (ast.subType === "group") {
12852
+ SUBRULE(groupGraphPattern, ast);
12853
+ } else if (ast.subType === "bgp") {
12854
+ SUBRULE(triplesBlock, ast);
12855
+ } else {
12856
+ SUBRULE(graphPatternNotTriples, ast);
12857
+ }
12858
+ }
12859
+ };
12860
+ var groupGraphPatternSub = {
12861
+ name: "groupGraphPatternSub",
12862
+ impl: ({ ACTION, SUBRULE, CONSUME, MANY, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OPTION3 }) => () => {
12863
+ const patterns = [];
12864
+ const bgpPattern = OPTION1(() => SUBRULE1(triplesBlock));
12865
+ if (bgpPattern) {
12866
+ patterns.push(bgpPattern);
12867
+ }
12868
+ MANY(() => {
12869
+ const notTriples = SUBRULE(graphPatternNotTriples);
12870
+ patterns.push(notTriples);
12871
+ OPTION2(() => CONSUME(symbols_exports.dot));
12872
+ const moreTriples = OPTION3(() => SUBRULE2(triplesBlock));
12873
+ if (moreTriples) {
12874
+ patterns.push(moreTriples);
12875
+ }
12876
+ });
12877
+ ACTION(() => checkNote13(patterns));
12878
+ return patterns;
12879
+ }
12880
+ };
12881
+ var graphPatternNotTriples = {
12882
+ name: "graphPatternNotTriples",
12883
+ impl: ({ SUBRULE, OR }) => () => OR([
12884
+ { ALT: () => SUBRULE(groupOrUnionGraphPattern) },
12885
+ { ALT: () => SUBRULE(optionalGraphPattern) },
12886
+ { ALT: () => SUBRULE(minusGraphPattern) },
12887
+ { ALT: () => SUBRULE(graphGraphPattern) },
12888
+ { ALT: () => SUBRULE(serviceGraphPattern) },
12889
+ { ALT: () => SUBRULE(filter3) },
12890
+ { ALT: () => SUBRULE(bind2) },
12891
+ { ALT: () => SUBRULE(inlineData) }
12892
+ ]),
12893
+ gImpl: ({ SUBRULE }) => (ast) => {
12894
+ switch (ast.subType) {
12895
+ case "group":
12896
+ case "union":
12897
+ SUBRULE(groupOrUnionGraphPattern, ast);
12898
+ break;
12899
+ case "optional":
12900
+ SUBRULE(optionalGraphPattern, ast);
12901
+ break;
12902
+ case "minus":
12903
+ SUBRULE(minusGraphPattern, ast);
12904
+ break;
12905
+ case "graph":
12906
+ SUBRULE(graphGraphPattern, ast);
12907
+ break;
12908
+ case "service":
12909
+ SUBRULE(serviceGraphPattern, ast);
12910
+ break;
12911
+ case "filter":
12912
+ SUBRULE(filter3, ast);
12913
+ break;
12914
+ case "bind":
12915
+ SUBRULE(bind2, ast);
12916
+ break;
12917
+ case "values":
12918
+ SUBRULE(inlineData, ast);
12919
+ break;
12920
+ }
12921
+ }
12922
+ };
12923
+ var optionalGraphPattern = {
12924
+ name: "optionalGraphPattern",
12925
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12926
+ const optional2 = CONSUME(optional);
12927
+ const group = SUBRULE(groupGraphPattern);
12928
+ return ACTION(() => C.factory.patternOptional(group.patterns, C.factory.sourceLocation(optional2, group)));
12929
+ },
12930
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12931
+ F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
12932
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12933
+ }
12934
+ };
12935
+ var graphGraphPattern = {
12936
+ name: "graphGraphPattern",
12937
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12938
+ const graph2 = CONSUME(graph_exports.graph);
12939
+ const name = SUBRULE(varOrIri);
12940
+ const group = SUBRULE(groupGraphPattern);
12941
+ return ACTION(() => C.factory.patternGraph(name, group.patterns, C.factory.sourceLocation(graph2, group)));
12942
+ },
12943
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12944
+ F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
12945
+ SUBRULE(varOrTerm, ast.name);
12946
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12947
+ }
12948
+ };
12949
+ var serviceGraphPattern = {
12950
+ name: "serviceGraphPattern",
12951
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
12952
+ const service2 = CONSUME(service);
12953
+ const silent2 = OPTION(() => {
12954
+ CONSUME(silent);
12955
+ return true;
12956
+ }) ?? false;
12957
+ const name = SUBRULE1(varOrIri);
12958
+ const group = SUBRULE1(groupGraphPattern);
12959
+ return ACTION(() => C.factory.patternService(name, group.patterns, silent2, C.factory.sourceLocation(service2, group)));
12960
+ },
12961
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12962
+ F2.printFilter(ast, () => {
12963
+ PRINT_WORD("SERVICE");
12964
+ if (ast.silent) {
12965
+ PRINT_WORD("SILENT");
13105
12966
  }
13106
- return F2.aggregate(
13107
- operatorToken.image,
13108
- Boolean(distinctToken),
13109
- expressionVal,
13110
- void 0,
13111
- C.factory.sourceLocation(operatorToken, closeToken)
13112
- );
13113
12967
  });
12968
+ SUBRULE(varOrTerm, ast.name);
12969
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
13114
12970
  }
13115
12971
  };
13116
- var aggregateSum = baseAggregateFunc(BuildinCalls_exports.sum);
13117
- var aggregateMin = baseAggregateFunc(BuildinCalls_exports.min);
13118
- var aggregateMax = baseAggregateFunc(BuildinCalls_exports.max);
13119
- var aggregateAvg = baseAggregateFunc(BuildinCalls_exports.avg);
13120
- var aggregateSample = baseAggregateFunc(BuildinCalls_exports.sample);
13121
- var aggregateGroup_concat = {
13122
- name: unCapitalize(BuildinCalls_exports.groupConcat.name),
13123
- impl: ({ ACTION, CONSUME, OPTION1, SUBRULE, OPTION2 }) => (C) => {
13124
- const operatorToken = CONSUME(BuildinCalls_exports.groupConcat);
12972
+ var bind2 = {
12973
+ name: "bind",
12974
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12975
+ const bind3 = CONSUME(bind);
13125
12976
  CONSUME(symbols_exports.LParen);
13126
- const distinctToken = OPTION1(() => CONSUME(distinct));
13127
- const expr = SUBRULE(expression, void 0);
13128
- const sep = OPTION2(() => {
13129
- CONSUME(symbols_exports.semi);
13130
- CONSUME(separator);
13131
- CONSUME(symbols_exports.equal);
13132
- return SUBRULE(string, void 0);
12977
+ const expressionVal = SUBRULE(expression);
12978
+ CONSUME(as);
12979
+ const variable = SUBRULE(var_);
12980
+ const close = CONSUME(symbols_exports.RParen);
12981
+ return ACTION(() => C.factory.patternBind(expressionVal, variable, C.factory.sourceLocation(bind3, close)));
12982
+ },
12983
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12984
+ F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12985
+ SUBRULE(expression, ast.expression);
12986
+ F2.printFilter(ast, () => PRINT_WORD("AS"));
12987
+ SUBRULE(var_, ast.variable);
12988
+ F2.printFilter(ast, () => PRINT_WORD(")"));
12989
+ }
12990
+ };
12991
+ var inlineData = {
12992
+ name: "inlineData",
12993
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12994
+ const values3 = CONSUME(values2);
12995
+ const datablock = SUBRULE(dataBlock);
12996
+ return ACTION(() => C.factory.patternValues(datablock.val, C.factory.sourceLocation(values3, datablock)));
12997
+ },
12998
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12999
+ const variables = Object.keys(ast.values[0]);
13000
+ F2.printFilter(ast, () => {
13001
+ PRINT_WORD("VALUES", "(");
13002
+ for (const variable of variables) {
13003
+ PRINT_WORD(`?${variable}`);
13004
+ }
13005
+ PRINT_WORD(")", "{");
13133
13006
  });
13134
- const closeToken = CONSUME(symbols_exports.RParen);
13135
- return ACTION(() => {
13136
- const F2 = C.factory;
13137
- return F2.aggregate(
13138
- operatorToken.image,
13139
- Boolean(distinctToken),
13140
- expr,
13141
- sep?.value ?? " ",
13142
- F2.sourceLocation(operatorToken, closeToken)
13143
- );
13007
+ for (const mapping of ast.values) {
13008
+ F2.printFilter(ast, () => PRINT_WORD("("));
13009
+ for (const variable of variables) {
13010
+ if (mapping[variable] === void 0) {
13011
+ F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
13012
+ } else {
13013
+ SUBRULE(graphNodePath, mapping[variable]);
13014
+ }
13015
+ }
13016
+ F2.printFilter(ast, () => PRINT_WORD(")"));
13017
+ }
13018
+ F2.printFilter(ast, () => PRINT_WORD("}"));
13019
+ }
13020
+ };
13021
+ var dataBlock = {
13022
+ name: "dataBlock",
13023
+ impl: ({ SUBRULE, OR }) => () => OR([
13024
+ { ALT: () => SUBRULE(inlineDataOneVar) },
13025
+ { ALT: () => SUBRULE(inlineDataFull) }
13026
+ ])
13027
+ };
13028
+ var inlineDataOneVar = {
13029
+ name: "inlineDataOneVar",
13030
+ impl: ({ ACTION, SUBRULE, CONSUME, MANY }) => (C) => {
13031
+ const res = [];
13032
+ const varVal = SUBRULE(var_);
13033
+ CONSUME(symbols_exports.LCurly);
13034
+ MANY(() => {
13035
+ const value = SUBRULE(dataBlockValue);
13036
+ ACTION(() => {
13037
+ res.push({ [varVal.value]: value });
13038
+ });
13144
13039
  });
13040
+ const close = CONSUME(symbols_exports.RCurly);
13041
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(varVal, close)));
13145
13042
  }
13146
13043
  };
13147
- var aggregate = {
13148
- name: "aggregate",
13149
- impl: ({ ACTION, SUBRULE, OR }) => (C) => {
13150
- const wasInAggregate = ACTION(() => C.parseMode.has("inAggregate"));
13151
- ACTION(() => C.parseMode.add("inAggregate"));
13152
- const result = OR([
13153
- { ALT: () => SUBRULE(aggregateCount, void 0) },
13154
- { ALT: () => SUBRULE(aggregateSum, void 0) },
13155
- { ALT: () => SUBRULE(aggregateMin, void 0) },
13156
- { ALT: () => SUBRULE(aggregateMax, void 0) },
13157
- { ALT: () => SUBRULE(aggregateAvg, void 0) },
13158
- { ALT: () => SUBRULE(aggregateSample, void 0) },
13159
- { ALT: () => SUBRULE(aggregateGroup_concat, void 0) }
13044
+ var inlineDataFull = {
13045
+ name: "inlineDataFull",
13046
+ impl: ({
13047
+ ACTION,
13048
+ OR,
13049
+ MANY1,
13050
+ MANY2,
13051
+ MANY3,
13052
+ MANY4,
13053
+ SUBRULE,
13054
+ CONSUME1,
13055
+ CONSUME2
13056
+ }) => (C) => {
13057
+ const res = [];
13058
+ const vars = [];
13059
+ return OR([
13060
+ { ALT: () => {
13061
+ const nil2 = CONSUME1(terminals_exports.nil);
13062
+ CONSUME1(symbols_exports.LCurly);
13063
+ MANY1(() => {
13064
+ CONSUME2(terminals_exports.nil);
13065
+ res.push({});
13066
+ });
13067
+ const close = CONSUME1(symbols_exports.RCurly);
13068
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(nil2, close)));
13069
+ } },
13070
+ { ALT: () => {
13071
+ const open = CONSUME1(symbols_exports.LParen);
13072
+ MANY2(() => {
13073
+ vars.push(SUBRULE(var_));
13074
+ });
13075
+ CONSUME1(symbols_exports.RParen);
13076
+ CONSUME2(symbols_exports.LCurly);
13077
+ MANY3(() => {
13078
+ let parsedValues = 0;
13079
+ const currentRow = {};
13080
+ CONSUME2(symbols_exports.LParen);
13081
+ MANY4(() => {
13082
+ if (parsedValues >= vars.length) {
13083
+ throw new Error("Number of dataBlockValues does not match number of variables. Too much values.");
13084
+ }
13085
+ const value = SUBRULE(dataBlockValue);
13086
+ ACTION(() => {
13087
+ currentRow[vars[parsedValues].value] = value;
13088
+ parsedValues++;
13089
+ });
13090
+ });
13091
+ CONSUME2(symbols_exports.RParen);
13092
+ ACTION(() => {
13093
+ res.push(currentRow);
13094
+ if (vars.length !== parsedValues) {
13095
+ throw new Error("Number of dataBlockValues does not match number of variables. Too few values.");
13096
+ }
13097
+ });
13098
+ });
13099
+ const close = CONSUME2(symbols_exports.RCurly);
13100
+ return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(open, close)));
13101
+ } }
13160
13102
  ]);
13161
- ACTION(() => !wasInAggregate && C.parseMode.delete("inAggregate"));
13162
- ACTION(() => {
13163
- if (!C.parseMode.has("canParseAggregate")) {
13164
- throw new Error("Aggregates are only allowed in SELECT, HAVING, and ORDER BY clauses.");
13165
- }
13166
- if (C.parseMode.has("inAggregate")) {
13167
- throw new Error("An aggregate function is not allowed within an aggregate function.");
13168
- }
13103
+ }
13104
+ };
13105
+ var dataBlockValue = {
13106
+ name: "dataBlockValue",
13107
+ impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
13108
+ { ALT: () => SUBRULE(iri2) },
13109
+ { ALT: () => SUBRULE(rdfLiteral) },
13110
+ { ALT: () => SUBRULE(numericLiteral) },
13111
+ { ALT: () => SUBRULE(booleanLiteral) },
13112
+ { ALT: () => {
13113
+ CONSUME(undef);
13114
+ return void 0;
13115
+ } }
13116
+ ])
13117
+ };
13118
+ var minusGraphPattern = {
13119
+ name: "minusGraphPattern",
13120
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13121
+ const minus2 = CONSUME(minus);
13122
+ const group = SUBRULE(groupGraphPattern);
13123
+ return ACTION(() => C.factory.patternMinus(group.patterns, C.factory.sourceLocation(minus2, group)));
13124
+ },
13125
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13126
+ F2.printFilter(ast, () => PRINT_WORD("MINUS"));
13127
+ SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
13128
+ }
13129
+ };
13130
+ var groupOrUnionGraphPattern = {
13131
+ name: "groupOrUnionGraphPattern",
13132
+ impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => {
13133
+ const groups = [];
13134
+ const group = SUBRULE1(groupGraphPattern);
13135
+ groups.push(group);
13136
+ MANY(() => {
13137
+ CONSUME(union);
13138
+ const group2 = SUBRULE2(groupGraphPattern);
13139
+ groups.push(group2);
13169
13140
  });
13170
- return result;
13141
+ return ACTION(() => groups.length === 1 ? groups[0] : C.factory.patternUnion(
13142
+ groups,
13143
+ C.factory.sourceLocation(group, groups.at(-1))
13144
+ ));
13171
13145
  },
13172
13146
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13173
- F2.printFilter(ast, () => {
13174
- PRINT_WORD(ast.aggregation, "(");
13175
- if (ast.distinct) {
13176
- PRINT_WORD("DISTINCT");
13147
+ if (F2.isPatternUnion(ast)) {
13148
+ const [head2, ...tail] = ast.patterns;
13149
+ SUBRULE(groupGraphPattern, head2);
13150
+ for (const pattern of tail) {
13151
+ F2.printFilter(ast, () => PRINT_WORD("UNION"));
13152
+ SUBRULE(groupGraphPattern, pattern);
13177
13153
  }
13178
- });
13179
- const arg = ast.expression[0];
13180
- if (F2.isWildcard(arg)) {
13181
- F2.printFilter(ast, () => PRINT_WORD("*"));
13182
13154
  } else {
13183
- SUBRULE(expression, arg, void 0);
13184
- }
13185
- if (F2.isExpressionAggregateSeparator(ast)) {
13186
- F2.printFilter(ast, () => PRINT_WORD(";", "SEPARATOR", "=", stringEscapedLexical(ast.separator)));
13155
+ SUBRULE(groupGraphPattern, ast);
13187
13156
  }
13157
+ }
13158
+ };
13159
+ var filter3 = {
13160
+ name: "filter",
13161
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13162
+ const filterToken = CONSUME(filter2);
13163
+ const expression2 = SUBRULE(constraint);
13164
+ return ACTION(() => C.factory.patternFilter(expression2, C.factory.sourceLocation(filterToken, expression2)));
13165
+ },
13166
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13167
+ F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
13168
+ SUBRULE(expression, ast.expression);
13188
13169
  F2.printFilter(ast, () => PRINT_WORD(")"));
13189
13170
  }
13190
13171
  };
13172
+ var constraint = {
13173
+ name: "constraint",
13174
+ impl: ({ SUBRULE, OR }) => () => OR([
13175
+ { ALT: () => SUBRULE(brackettedExpression) },
13176
+ { ALT: () => SUBRULE(builtInCall) },
13177
+ { ALT: () => SUBRULE(functionCall) }
13178
+ ])
13179
+ };
13180
+ var functionCall = {
13181
+ name: "functionCall",
13182
+ impl: ({ ACTION, SUBRULE }) => (C) => {
13183
+ const func = SUBRULE(iri2);
13184
+ const args = SUBRULE(argList);
13185
+ return ACTION(() => C.factory.expressionFunctionCall(
13186
+ func,
13187
+ args.val.args,
13188
+ args.val.distinct,
13189
+ C.factory.sourceLocation(func, args)
13190
+ ));
13191
+ }
13192
+ };
13191
13193
 
13192
13194
  // ../../packages/rules-sparql-1-1/lib/grammar/expression.ts
13193
13195
  var argList = {
@@ -13207,7 +13209,7 @@ var argList = {
13207
13209
  AT_LEAST_ONE_SEP({
13208
13210
  SEP: symbols_exports.comma,
13209
13211
  DEF: () => {
13210
- const arg = SUBRULE1(expression, void 0);
13212
+ const arg = SUBRULE1(expression);
13211
13213
  args.push(arg);
13212
13214
  }
13213
13215
  });
@@ -13224,11 +13226,11 @@ var argList = {
13224
13226
  });
13225
13227
  const [head2, ...tail] = ast.val.args;
13226
13228
  if (head2) {
13227
- SUBRULE(expression, head2, void 0);
13229
+ SUBRULE(expression, head2);
13228
13230
  }
13229
13231
  for (const expr of tail) {
13230
13232
  F2.printFilter(ast, () => PRINT_WORD(","));
13231
- SUBRULE(expression, expr, void 0);
13233
+ SUBRULE(expression, expr);
13232
13234
  }
13233
13235
  F2.printFilter(ast, () => PRINT_WORD(")"));
13234
13236
  }
@@ -13242,11 +13244,11 @@ var expressionList = {
13242
13244
  } },
13243
13245
  { ALT: () => {
13244
13246
  const open = CONSUME(symbols_exports.LParen);
13245
- const expr1 = SUBRULE1(expression, void 0);
13247
+ const expr1 = SUBRULE1(expression);
13246
13248
  const args = [expr1];
13247
13249
  MANY(() => {
13248
13250
  CONSUME(symbols_exports.comma);
13249
- const expr = SUBRULE2(expression, void 0);
13251
+ const expr = SUBRULE2(expression);
13250
13252
  args.push(expr);
13251
13253
  });
13252
13254
  const close = CONSUME(symbols_exports.RParen);
@@ -13258,15 +13260,15 @@ var infixOperators = /* @__PURE__ */ new Set(["in", "notin", "||", "&&", "=", "!
13258
13260
  var prefixOperator = /* @__PURE__ */ new Set(["!", "UPLUS", "UMINUS"]);
13259
13261
  var expression = {
13260
13262
  name: "expression",
13261
- impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression, void 0),
13263
+ impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression),
13262
13264
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13263
13265
  if (F2.isTerm(ast)) {
13264
- SUBRULE(varOrTerm, ast, void 0);
13266
+ SUBRULE(varOrTerm, ast);
13265
13267
  } else if (F2.isExpressionOperator(ast)) {
13266
13268
  if (infixOperators.has(ast.operator)) {
13267
13269
  const [left, ...right] = ast.args;
13268
13270
  F2.printFilter(ast, () => PRINT_WORD("("));
13269
- SUBRULE(expression, left, void 0);
13271
+ SUBRULE(expression, left);
13270
13272
  F2.printFilter(ast, () => {
13271
13273
  if (ast.operator === "notin") {
13272
13274
  PRINT_WORD("NOT IN");
@@ -13277,35 +13279,35 @@ var expression = {
13277
13279
  }
13278
13280
  });
13279
13281
  if (right.length === 1) {
13280
- SUBRULE(expression, right[0], void 0);
13282
+ SUBRULE(expression, right[0]);
13281
13283
  } else {
13282
- SUBRULE(argList, F2.wrap({ args: right, distinct: false }, ast.loc), void 0);
13284
+ SUBRULE(argList, F2.wrap({ args: right, distinct: false }, ast.loc));
13283
13285
  }
13284
13286
  F2.printFilter(ast, () => PRINT_WORD(")"));
13285
13287
  } else if (prefixOperator.has(ast.operator)) {
13286
13288
  const [expr] = ast.args;
13287
13289
  F2.printFilter(ast, () => PRINT_WORD(ast.operator));
13288
- SUBRULE(expression, expr, void 0);
13290
+ SUBRULE(expression, expr);
13289
13291
  } else {
13290
13292
  F2.printFilter(ast, () => PRINT_WORD(ast.operator, "("));
13291
13293
  const [head2, ...tail] = ast.args;
13292
13294
  if (head2) {
13293
- SUBRULE(expression, head2, void 0);
13295
+ SUBRULE(expression, head2);
13294
13296
  }
13295
13297
  for (const arg of tail) {
13296
13298
  F2.printFilter(ast, () => PRINT_WORD(","));
13297
- SUBRULE(expression, arg, void 0);
13299
+ SUBRULE(expression, arg);
13298
13300
  }
13299
13301
  F2.printFilter(ast, () => PRINT_WORD(")"));
13300
13302
  }
13301
13303
  } else if (F2.isExpressionPatternOperation(ast)) {
13302
13304
  const patterns = ast.args;
13303
13305
  F2.printFilter(ast, () => PRINT_WORD(ast.operator === "exists" ? "EXISTS" : "NOT EXISTS"));
13304
- SUBRULE(groupGraphPattern, patterns, void 0);
13306
+ SUBRULE(groupGraphPattern, patterns);
13305
13307
  } else if (F2.isExpressionFunctionCall(ast)) {
13306
- SUBRULE(iriOrFunction, ast, void 0);
13308
+ SUBRULE(iriOrFunction, ast);
13307
13309
  } else if (F2.isExpressionAggregate(ast)) {
13308
- SUBRULE(aggregate, ast, void 0);
13310
+ SUBRULE(aggregate, ast);
13309
13311
  }
13310
13312
  }
13311
13313
  };
@@ -13322,10 +13324,10 @@ function constructLeftDeep(startGenerator, restGenerator, ACTION, MANY) {
13322
13324
  var conditionalOrExpression = {
13323
13325
  name: "conditionalOrExpression",
13324
13326
  impl: ({ ACTION, MANY, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => constructLeftDeep(
13325
- () => SUBRULE1(conditionalAndExpression, void 0),
13327
+ () => SUBRULE1(conditionalAndExpression),
13326
13328
  () => {
13327
13329
  CONSUME(symbols_exports.logicOr);
13328
- const args = SUBRULE2(conditionalAndExpression, void 0);
13330
+ const args = SUBRULE2(conditionalAndExpression);
13329
13331
  return (left) => ACTION(() => C.factory.expressionOperation("||", [left, args], C.factory.sourceLocation(left, args)));
13330
13332
  },
13331
13333
  ACTION,
@@ -13335,10 +13337,10 @@ var conditionalOrExpression = {
13335
13337
  var conditionalAndExpression = {
13336
13338
  name: "conditionalAndExpression",
13337
13339
  impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => constructLeftDeep(
13338
- () => SUBRULE1(valueLogical, void 0),
13340
+ () => SUBRULE1(valueLogical),
13339
13341
  () => {
13340
13342
  CONSUME(symbols_exports.logicAnd);
13341
- const arg = SUBRULE2(valueLogical, void 0);
13343
+ const arg = SUBRULE2(valueLogical);
13342
13344
  return (left) => ACTION(() => C.factory.expressionOperation("&&", [left, arg], C.factory.sourceLocation(left, arg)));
13343
13345
  },
13344
13346
  ACTION,
@@ -13347,12 +13349,12 @@ var conditionalAndExpression = {
13347
13349
  };
13348
13350
  var valueLogical = {
13349
13351
  name: "valueLogical",
13350
- impl: ({ SUBRULE }) => () => SUBRULE(relationalExpression, void 0)
13352
+ impl: ({ SUBRULE }) => () => SUBRULE(relationalExpression)
13351
13353
  };
13352
13354
  var relationalExpression = {
13353
13355
  name: "relationalExpression",
13354
13356
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION, OR1, OR2, OR3 }) => (C) => {
13355
- const args1 = SUBRULE1(numericExpression, void 0);
13357
+ const args1 = SUBRULE1(numericExpression);
13356
13358
  const expression2 = OPTION(() => OR1([
13357
13359
  { ALT: () => {
13358
13360
  const operator = OR2([
@@ -13363,7 +13365,7 @@ var relationalExpression = {
13363
13365
  { ALT: () => CONSUME(symbols_exports.lessThanEqual) },
13364
13366
  { ALT: () => CONSUME(symbols_exports.greaterThanEqual) }
13365
13367
  ]);
13366
- const expr = SUBRULE2(numericExpression, void 0);
13368
+ const expr = SUBRULE2(numericExpression);
13367
13369
  return ACTION(() => C.factory.expressionOperation(
13368
13370
  operator.image,
13369
13371
  [args1, expr],
@@ -13375,7 +13377,7 @@ var relationalExpression = {
13375
13377
  { ALT: () => CONSUME(in_) },
13376
13378
  { ALT: () => CONSUME(notIn) }
13377
13379
  ]);
13378
- const args = SUBRULE1(expressionList, void 0);
13380
+ const args = SUBRULE1(expressionList);
13379
13381
  return ACTION(() => C.factory.expressionOperation(
13380
13382
  operator.image,
13381
13383
  [args1, ...args.val],
@@ -13388,25 +13390,25 @@ var relationalExpression = {
13388
13390
  };
13389
13391
  var numericExpression = {
13390
13392
  name: "numericExpression",
13391
- impl: ({ SUBRULE }) => () => SUBRULE(additiveExpression, void 0)
13393
+ impl: ({ SUBRULE }) => () => SUBRULE(additiveExpression)
13392
13394
  };
13393
13395
  var additiveExpression = {
13394
13396
  name: "additiveExpression",
13395
13397
  impl: ({ ACTION, SUBRULE, CONSUME, SUBRULE1, SUBRULE2, MANY1, MANY2, OR1, OR2, OR3, OR4 }) => (C) => constructLeftDeep(
13396
- () => SUBRULE1(multiplicativeExpression, void 0),
13398
+ () => SUBRULE1(multiplicativeExpression),
13397
13399
  () => OR1([
13398
13400
  { ALT: () => {
13399
13401
  const operator = OR2([
13400
13402
  { ALT: () => CONSUME(symbols_exports.opPlus) },
13401
13403
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13402
13404
  ]);
13403
- const arg = SUBRULE2(multiplicativeExpression, void 0);
13405
+ const arg = SUBRULE2(multiplicativeExpression);
13404
13406
  return ACTION(() => (left) => C.factory.expressionOperation(operator.image, [left, arg], C.factory.sourceLocation(left, arg)));
13405
13407
  } },
13406
13408
  { ALT: () => {
13407
13409
  const { operator, startInt } = OR3([
13408
13410
  { ALT: () => {
13409
- const integer2 = SUBRULE(numericLiteralPositive, void 0);
13411
+ const integer2 = SUBRULE(numericLiteralPositive);
13410
13412
  return ACTION(() => {
13411
13413
  integer2.value = integer2.value.replace(/^\+/u, "");
13412
13414
  return {
@@ -13416,7 +13418,7 @@ var additiveExpression = {
13416
13418
  });
13417
13419
  } },
13418
13420
  { ALT: () => {
13419
- const integer2 = SUBRULE(numericLiteralNegative, void 0);
13421
+ const integer2 = SUBRULE(numericLiteralNegative);
13420
13422
  return ACTION(() => {
13421
13423
  integer2.value = integer2.value.replace(/^-/u, "");
13422
13424
  return {
@@ -13433,7 +13435,7 @@ var additiveExpression = {
13433
13435
  { ALT: () => CONSUME(symbols_exports.star) },
13434
13436
  { ALT: () => CONSUME(symbols_exports.slash) }
13435
13437
  ]);
13436
- const innerExpr = SUBRULE1(unaryExpression, void 0);
13438
+ const innerExpr = SUBRULE1(unaryExpression);
13437
13439
  return ACTION(() => (leftInner) => C.factory.expressionOperation(
13438
13440
  innerOperator.image,
13439
13441
  [leftInner, innerExpr],
@@ -13457,13 +13459,13 @@ var additiveExpression = {
13457
13459
  var multiplicativeExpression = {
13458
13460
  name: "multiplicativeExpression",
13459
13461
  impl: ({ ACTION, CONSUME, MANY, SUBRULE1, SUBRULE2, OR }) => (C) => constructLeftDeep(
13460
- () => SUBRULE1(unaryExpression, void 0),
13462
+ () => SUBRULE1(unaryExpression),
13461
13463
  () => {
13462
13464
  const operator = OR([
13463
13465
  { ALT: () => CONSUME(symbols_exports.star) },
13464
13466
  { ALT: () => CONSUME(symbols_exports.slash) }
13465
13467
  ]);
13466
- const expr = SUBRULE2(unaryExpression, void 0);
13468
+ const expr = SUBRULE2(unaryExpression);
13467
13469
  return (left) => ({
13468
13470
  type: "expression",
13469
13471
  subType: "operation",
@@ -13479,14 +13481,14 @@ var multiplicativeExpression = {
13479
13481
  var unaryExpression = {
13480
13482
  name: "unaryExpression",
13481
13483
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
13482
- { ALT: () => SUBRULE1(primaryExpression, void 0) },
13484
+ { ALT: () => SUBRULE1(primaryExpression) },
13483
13485
  { ALT: () => {
13484
13486
  const operator = OR2([
13485
13487
  { ALT: () => CONSUME(symbols_exports.exclamation) },
13486
13488
  { ALT: () => CONSUME(symbols_exports.opPlus) },
13487
13489
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13488
13490
  ]);
13489
- const expr = SUBRULE2(primaryExpression, void 0);
13491
+ const expr = SUBRULE2(primaryExpression);
13490
13492
  return ACTION(() => ({
13491
13493
  type: "expression",
13492
13494
  subType: "operation",
@@ -13500,20 +13502,20 @@ var unaryExpression = {
13500
13502
  var primaryExpression = {
13501
13503
  name: "primaryExpression",
13502
13504
  impl: ({ SUBRULE, OR }) => () => OR([
13503
- { ALT: () => SUBRULE(brackettedExpression, void 0) },
13504
- { ALT: () => SUBRULE(builtInCall, void 0) },
13505
- { ALT: () => SUBRULE(iriOrFunction, void 0) },
13506
- { ALT: () => SUBRULE(rdfLiteral, void 0) },
13507
- { ALT: () => SUBRULE(numericLiteral, void 0) },
13508
- { ALT: () => SUBRULE(booleanLiteral, void 0) },
13509
- { ALT: () => SUBRULE(var_, void 0) }
13505
+ { ALT: () => SUBRULE(brackettedExpression) },
13506
+ { ALT: () => SUBRULE(builtInCall) },
13507
+ { ALT: () => SUBRULE(iriOrFunction) },
13508
+ { ALT: () => SUBRULE(rdfLiteral) },
13509
+ { ALT: () => SUBRULE(numericLiteral) },
13510
+ { ALT: () => SUBRULE(booleanLiteral) },
13511
+ { ALT: () => SUBRULE(var_) }
13510
13512
  ])
13511
13513
  };
13512
13514
  var brackettedExpression = {
13513
13515
  name: "brackettedExpression",
13514
13516
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13515
13517
  const open = CONSUME(symbols_exports.LParen);
13516
- const expr = SUBRULE(expression, void 0);
13518
+ const expr = SUBRULE(expression);
13517
13519
  const close = CONSUME(symbols_exports.RParen);
13518
13520
  return ACTION(() => {
13519
13521
  expr.loc = C.factory.sourceLocation(open, close);
@@ -13524,9 +13526,9 @@ var brackettedExpression = {
13524
13526
  var iriOrFunction = {
13525
13527
  name: "iriOrFunction",
13526
13528
  impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
13527
- const iriVal = SUBRULE(iri2, void 0);
13529
+ const iriVal = SUBRULE(iri2);
13528
13530
  const functionCall2 = OPTION(() => {
13529
- const args = SUBRULE(argList, void 0);
13531
+ const args = SUBRULE(argList);
13530
13532
  return ACTION(() => {
13531
13533
  const distinct2 = args.val.distinct;
13532
13534
  if (!C.parseMode.has("canParseAggregate") && distinct2) {
@@ -13546,10 +13548,10 @@ var iriOrFunction = {
13546
13548
  },
13547
13549
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13548
13550
  if (F2.isTermNamed(ast)) {
13549
- SUBRULE(iri2, ast, void 0);
13551
+ SUBRULE(iri2, ast);
13550
13552
  } else {
13551
- SUBRULE(iri2, ast.function, void 0);
13552
- SUBRULE(argList, F2.wrap({ args: ast.args, distinct: ast.distinct }, ast.loc), void 0);
13553
+ SUBRULE(iri2, ast.function);
13554
+ SUBRULE(argList, F2.wrap({ args: ast.args, distinct: ast.distinct }, ast.loc));
13553
13555
  }
13554
13556
  }
13555
13557
  };
@@ -13558,10 +13560,10 @@ var iriOrFunction = {
13558
13560
  var solutionModifier = {
13559
13561
  name: "solutionModifier",
13560
13562
  impl: ({ ACTION, SUBRULE, OPTION1, OPTION2, OPTION3, OPTION4 }) => () => {
13561
- const group = OPTION1(() => SUBRULE(groupClause, void 0));
13562
- const having2 = OPTION2(() => SUBRULE(havingClause, void 0));
13563
- const order2 = OPTION3(() => SUBRULE(orderClause, void 0));
13564
- const limitOffset = OPTION4(() => SUBRULE(limitOffsetClauses, void 0));
13563
+ const group = OPTION1(() => SUBRULE(groupClause));
13564
+ const having2 = OPTION2(() => SUBRULE(havingClause));
13565
+ const order2 = OPTION3(() => SUBRULE(orderClause));
13566
+ const limitOffset = OPTION4(() => SUBRULE(limitOffsetClauses));
13565
13567
  return ACTION(() => ({
13566
13568
  ...limitOffset && { limitOffset },
13567
13569
  ...group && { group },
@@ -13571,16 +13573,16 @@ var solutionModifier = {
13571
13573
  },
13572
13574
  gImpl: ({ SUBRULE }) => (ast) => {
13573
13575
  if (ast.group) {
13574
- SUBRULE(groupClause, ast.group, void 0);
13576
+ SUBRULE(groupClause, ast.group);
13575
13577
  }
13576
13578
  if (ast.having) {
13577
- SUBRULE(havingClause, ast.having, void 0);
13579
+ SUBRULE(havingClause, ast.having);
13578
13580
  }
13579
13581
  if (ast.order) {
13580
- SUBRULE(orderClause, ast.order, void 0);
13582
+ SUBRULE(orderClause, ast.order);
13581
13583
  }
13582
13584
  if (ast.limitOffset) {
13583
- SUBRULE(limitOffsetClauses, ast.limitOffset, void 0);
13585
+ SUBRULE(limitOffsetClauses, ast.limitOffset);
13584
13586
  }
13585
13587
  }
13586
13588
  };
@@ -13591,7 +13593,7 @@ var groupClause = {
13591
13593
  const start = CONSUME(groupByGroup);
13592
13594
  CONSUME(by);
13593
13595
  AT_LEAST_ONE(() => {
13594
- groupings.push(SUBRULE1(groupCondition, void 0));
13596
+ groupings.push(SUBRULE1(groupCondition));
13595
13597
  });
13596
13598
  return ACTION(() => ({
13597
13599
  type: "solutionModifier",
@@ -13604,12 +13606,12 @@ var groupClause = {
13604
13606
  F2.printFilter(ast, () => PRINT_WORDS("GROUP", "BY"));
13605
13607
  for (const grouping of ast.groupings) {
13606
13608
  if (F2.isExpression(grouping)) {
13607
- SUBRULE(expression, grouping, void 0);
13609
+ SUBRULE(expression, grouping);
13608
13610
  } else {
13609
13611
  F2.printFilter(ast, () => PRINT_WORDS("("));
13610
- SUBRULE(expression, grouping.value, void 0);
13612
+ SUBRULE(expression, grouping.value);
13611
13613
  F2.printFilter(ast, () => PRINT_WORDS("AS"));
13612
- SUBRULE(var_, grouping.variable, void 0);
13614
+ SUBRULE(var_, grouping.variable);
13613
13615
  F2.printFilter(ast, () => PRINT_WORDS(")"));
13614
13616
  }
13615
13617
  }
@@ -13618,16 +13620,16 @@ var groupClause = {
13618
13620
  var groupCondition = {
13619
13621
  name: "groupCondition",
13620
13622
  impl: ({ ACTION, SUBRULE, CONSUME, SUBRULE1, SUBRULE2, OPTION, OR }) => (C) => OR([
13621
- { ALT: () => SUBRULE(builtInCall, void 0) },
13622
- { ALT: () => SUBRULE(functionCall, void 0) },
13623
- { ALT: () => SUBRULE2(var_, void 0) },
13623
+ { ALT: () => SUBRULE(builtInCall) },
13624
+ { ALT: () => SUBRULE(functionCall) },
13625
+ { ALT: () => SUBRULE2(var_) },
13624
13626
  {
13625
13627
  ALT: () => {
13626
13628
  const open = CONSUME(symbols_exports.LParen);
13627
- const expressionValue = SUBRULE(expression, void 0);
13629
+ const expressionValue = SUBRULE(expression);
13628
13630
  const variable = OPTION(() => {
13629
13631
  CONSUME(as);
13630
- return SUBRULE1(var_, void 0);
13632
+ return SUBRULE1(var_);
13631
13633
  });
13632
13634
  const close = CONSUME(symbols_exports.RParen);
13633
13635
  return ACTION(() => {
@@ -13651,7 +13653,7 @@ var havingClause = {
13651
13653
  const expressions = [];
13652
13654
  const couldParseAgg = ACTION(() => C.parseMode.has("canParseAggregate") || !C.parseMode.add("canParseAggregate"));
13653
13655
  AT_LEAST_ONE(() => {
13654
- expressions.push(SUBRULE(havingCondition, void 0));
13656
+ expressions.push(SUBRULE(havingCondition));
13655
13657
  });
13656
13658
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13657
13659
  return ACTION(() => C.factory.solutionModifierHaving(expressions, C.factory.sourceLocation(having2, expressions.at(-1))));
@@ -13659,13 +13661,13 @@ var havingClause = {
13659
13661
  gImpl: ({ PRINT_WORD, SUBRULE }) => (ast, { factory: F2 }) => {
13660
13662
  F2.printFilter(ast, () => PRINT_WORD("HAVING"));
13661
13663
  for (const having2 of ast.having) {
13662
- SUBRULE(expression, having2, void 0);
13664
+ SUBRULE(expression, having2);
13663
13665
  }
13664
13666
  }
13665
13667
  };
13666
13668
  var havingCondition = {
13667
13669
  name: "havingCondition",
13668
- impl: ({ SUBRULE }) => () => SUBRULE(constraint, void 0)
13670
+ impl: ({ SUBRULE }) => () => SUBRULE(constraint)
13669
13671
  };
13670
13672
  var orderClause = {
13671
13673
  name: "orderClause",
@@ -13675,7 +13677,7 @@ var orderClause = {
13675
13677
  const orderings = [];
13676
13678
  const couldParseAgg = ACTION(() => C.parseMode.has("canParseAggregate") || !C.parseMode.add("canParseAggregate"));
13677
13679
  AT_LEAST_ONE(() => {
13678
- orderings.push(SUBRULE1(orderCondition, void 0));
13680
+ orderings.push(SUBRULE1(orderCondition));
13679
13681
  });
13680
13682
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13681
13683
  return ACTION(() => C.factory.solutionModifierOrder(orderings, C.factory.sourceLocation(order2, orderings.at(-1))));
@@ -13689,7 +13691,7 @@ var orderClause = {
13689
13691
  F2.printFilter(ast, () => PRINT_WORDS("ASC"));
13690
13692
  }
13691
13693
  F2.printFilter(ast, () => PRINT_WORDS("("));
13692
- SUBRULE(expression, ordering.expression, void 0);
13694
+ SUBRULE(expression, ordering.expression);
13693
13695
  F2.printFilter(ast, () => PRINT_WORDS(")"));
13694
13696
  }
13695
13697
  }
@@ -13708,7 +13710,7 @@ var orderCondition = {
13708
13710
  return [true, token];
13709
13711
  } }
13710
13712
  ]);
13711
- const expr = SUBRULE(brackettedExpression, void 0);
13713
+ const expr = SUBRULE(brackettedExpression);
13712
13714
  return ACTION(() => ({
13713
13715
  expression: expr,
13714
13716
  descending: descending[0],
@@ -13716,11 +13718,11 @@ var orderCondition = {
13716
13718
  }));
13717
13719
  } },
13718
13720
  { ALT: () => {
13719
- const expr = SUBRULE(constraint, void 0);
13721
+ const expr = SUBRULE(constraint);
13720
13722
  return ACTION(() => ({ expression: expr, descending: false, loc: expr.loc }));
13721
13723
  } },
13722
13724
  { ALT: () => {
13723
- const expr = SUBRULE(var_, void 0);
13725
+ const expr = SUBRULE(var_);
13724
13726
  return ACTION(() => ({ expression: expr, descending: false, loc: expr.loc }));
13725
13727
  } }
13726
13728
  ])
@@ -13729,8 +13731,8 @@ var limitOffsetClauses = {
13729
13731
  name: "limitOffsetClauses",
13730
13732
  impl: ({ ACTION, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => OR([
13731
13733
  { ALT: () => {
13732
- const limit2 = SUBRULE1(limitClause, void 0);
13733
- const offset2 = OPTION1(() => SUBRULE1(offsetClause, void 0));
13734
+ const limit2 = SUBRULE1(limitClause);
13735
+ const offset2 = OPTION1(() => SUBRULE1(offsetClause));
13734
13736
  return ACTION(() => C.factory.solutionModifierLimitOffset(
13735
13737
  limit2.val,
13736
13738
  offset2?.val,
@@ -13738,8 +13740,8 @@ var limitOffsetClauses = {
13738
13740
  ));
13739
13741
  } },
13740
13742
  { ALT: () => {
13741
- const offset2 = SUBRULE2(offsetClause, void 0);
13742
- const limit2 = OPTION2(() => SUBRULE2(limitClause, void 0));
13743
+ const offset2 = SUBRULE2(offsetClause);
13744
+ const limit2 = OPTION2(() => SUBRULE2(limitClause));
13743
13745
  return ACTION(() => C.factory.solutionModifierLimitOffset(
13744
13746
  limit2?.val,
13745
13747
  offset2.val,
@@ -13777,22 +13779,22 @@ var offsetClause = {
13777
13779
  }
13778
13780
  };
13779
13781
 
13780
- // ../../packages/rules-sparql-1-1/lib/grammar/queryUnit/queryUnit.ts
13782
+ // ../../packages/rules-sparql-1-1/lib/grammar/queryUnit.ts
13781
13783
  var queryUnit = {
13782
13784
  name: "queryUnit",
13783
- impl: ({ SUBRULE }) => () => SUBRULE(query, void 0)
13785
+ impl: ({ SUBRULE }) => () => SUBRULE(query)
13784
13786
  };
13785
13787
  var query = {
13786
13788
  name: "query",
13787
13789
  impl: ({ ACTION, SUBRULE, OR }) => (C) => {
13788
- const prologueValues = SUBRULE(prologue, void 0);
13790
+ const prologueValues = SUBRULE(prologue);
13789
13791
  const subType = OR([
13790
- { ALT: () => SUBRULE(selectQuery, void 0) },
13791
- { ALT: () => SUBRULE(constructQuery, void 0) },
13792
- { ALT: () => SUBRULE(describeQuery, void 0) },
13793
- { ALT: () => SUBRULE(askQuery, void 0) }
13792
+ { ALT: () => SUBRULE(selectQuery) },
13793
+ { ALT: () => SUBRULE(constructQuery) },
13794
+ { ALT: () => SUBRULE(describeQuery) },
13795
+ { ALT: () => SUBRULE(askQuery) }
13794
13796
  ]);
13795
- const values3 = SUBRULE(valuesClause, void 0);
13797
+ const values3 = SUBRULE(valuesClause);
13796
13798
  return ACTION(() => ({
13797
13799
  context: prologueValues,
13798
13800
  ...subType,
@@ -13806,28 +13808,28 @@ var query = {
13806
13808
  }));
13807
13809
  },
13808
13810
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13809
- SUBRULE(prologue, ast.context, void 0);
13811
+ SUBRULE(prologue, ast.context);
13810
13812
  if (F2.isQuerySelect(ast)) {
13811
- SUBRULE(selectQuery, ast, void 0);
13813
+ SUBRULE(selectQuery, ast);
13812
13814
  } else if (F2.isQueryConstruct(ast)) {
13813
- SUBRULE(constructQuery, ast, void 0);
13815
+ SUBRULE(constructQuery, ast);
13814
13816
  } else if (F2.isQueryDescribe(ast)) {
13815
- SUBRULE(describeQuery, ast, void 0);
13817
+ SUBRULE(describeQuery, ast);
13816
13818
  } else if (F2.isQueryAsk(ast)) {
13817
- SUBRULE(askQuery, ast, void 0);
13819
+ SUBRULE(askQuery, ast);
13818
13820
  }
13819
13821
  if (ast.values) {
13820
- SUBRULE(inlineData, ast.values, void 0);
13822
+ SUBRULE(inlineData, ast.values);
13821
13823
  }
13822
13824
  }
13823
13825
  };
13824
13826
  var selectQuery = {
13825
13827
  name: "selectQuery",
13826
13828
  impl: ({ ACTION, SUBRULE }) => (C) => {
13827
- const selectVal = SUBRULE(selectClause, void 0);
13828
- const from2 = SUBRULE(datasetClauseStar, void 0);
13829
- const where2 = SUBRULE(whereClause, void 0);
13830
- const modifiers = SUBRULE(solutionModifier, void 0);
13829
+ const selectVal = SUBRULE(selectClause);
13830
+ const from2 = SUBRULE(datasetClauseStar);
13831
+ const where2 = SUBRULE(whereClause);
13832
+ const modifiers = SUBRULE(solutionModifier);
13831
13833
  return ACTION(() => {
13832
13834
  const ret = {
13833
13835
  subType: "select",
@@ -13853,19 +13855,19 @@ var selectQuery = {
13853
13855
  variables: ast.variables,
13854
13856
  distinct: ast.distinct,
13855
13857
  reduced: ast.reduced
13856
- }, F2.sourceLocation(...ast.variables)), void 0);
13857
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
13858
- SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc), void 0);
13859
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
13858
+ }, F2.sourceLocation(...ast.variables)));
13859
+ SUBRULE(datasetClauseStar, ast.datasets);
13860
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc));
13861
+ SUBRULE(solutionModifier, ast.solutionModifiers);
13860
13862
  }
13861
13863
  };
13862
13864
  var subSelect = {
13863
13865
  name: "subSelect",
13864
13866
  impl: ({ ACTION, SUBRULE }) => (C) => {
13865
- const selectVal = SUBRULE(selectClause, void 0);
13866
- const where2 = SUBRULE(whereClause, void 0);
13867
- const modifiers = SUBRULE(solutionModifier, void 0);
13868
- const values3 = SUBRULE(valuesClause, void 0);
13867
+ const selectVal = SUBRULE(selectClause);
13868
+ const where2 = SUBRULE(whereClause);
13869
+ const modifiers = SUBRULE(solutionModifier);
13870
+ const values3 = SUBRULE(valuesClause);
13869
13871
  return ACTION(() => C.factory.querySelect({
13870
13872
  where: where2.val,
13871
13873
  datasets: C.factory.datasetClauses([], C.factory.sourceLocation()),
@@ -13930,7 +13932,7 @@ var selectClause = {
13930
13932
  const variables = [];
13931
13933
  AT_LEAST_ONE(() => OR3([
13932
13934
  { ALT: () => {
13933
- const raw = SUBRULE1(var_, void 0);
13935
+ const raw = SUBRULE1(var_);
13934
13936
  ACTION(() => {
13935
13937
  if (usedVars.some((v) => v.value === raw.value)) {
13936
13938
  throw new Error(`Variable ${raw.value} used more than once in SELECT clause`);
@@ -13942,9 +13944,9 @@ var selectClause = {
13942
13944
  } },
13943
13945
  { ALT: () => {
13944
13946
  const open = CONSUME(symbols_exports.LParen);
13945
- const expr = SUBRULE1(expression, void 0);
13947
+ const expr = SUBRULE1(expression);
13946
13948
  CONSUME(as);
13947
- const variable = SUBRULE2(var_, void 0);
13949
+ const variable = SUBRULE2(var_);
13948
13950
  const close = CONSUME(symbols_exports.RParen);
13949
13951
  ACTION(() => {
13950
13952
  last2 = close;
@@ -13975,12 +13977,12 @@ var selectClause = {
13975
13977
  if (F2.isWildcard(variable)) {
13976
13978
  F2.printFilter(ast, () => PRINT_WORD("*"));
13977
13979
  } else if (F2.isTerm(variable)) {
13978
- SUBRULE(var_, variable, void 0);
13980
+ SUBRULE(var_, variable);
13979
13981
  } else {
13980
13982
  F2.printFilter(ast, () => PRINT_WORD("("));
13981
- SUBRULE(expression, variable.expression, void 0);
13983
+ SUBRULE(expression, variable.expression);
13982
13984
  F2.printFilter(ast, () => PRINT_WORD("AS"));
13983
- SUBRULE(var_, variable.variable, void 0);
13985
+ SUBRULE(var_, variable.variable);
13984
13986
  F2.printFilter(ast, () => PRINT_WORD(")"));
13985
13987
  }
13986
13988
  }
@@ -13992,10 +13994,10 @@ var constructQuery = {
13992
13994
  const construct2 = CONSUME(construct);
13993
13995
  return OR([
13994
13996
  { ALT: () => {
13995
- const template = SUBRULE1(constructTemplate, void 0);
13996
- const from2 = SUBRULE1(datasetClauseStar, void 0);
13997
- const where2 = SUBRULE1(whereClause, void 0);
13998
- const modifiers = SUBRULE1(solutionModifier, void 0);
13997
+ const template = SUBRULE1(constructTemplate);
13998
+ const from2 = SUBRULE1(datasetClauseStar);
13999
+ const where2 = SUBRULE1(whereClause);
14000
+ const modifiers = SUBRULE1(solutionModifier);
13999
14001
  return ACTION(() => ({
14000
14002
  subType: "construct",
14001
14003
  template: template.val,
@@ -14013,10 +14015,10 @@ var constructQuery = {
14013
14015
  }));
14014
14016
  } },
14015
14017
  { ALT: () => {
14016
- const from2 = SUBRULE2(datasetClauseStar, void 0);
14018
+ const from2 = SUBRULE2(datasetClauseStar);
14017
14019
  CONSUME(where);
14018
- const template = SUBRULE2(constructTemplate, void 0);
14019
- const modifiers = SUBRULE2(solutionModifier, void 0);
14020
+ const template = SUBRULE2(constructTemplate);
14021
+ const modifiers = SUBRULE2(solutionModifier);
14020
14022
  return ACTION(() => ({
14021
14023
  subType: "construct",
14022
14024
  template: template.val,
@@ -14039,16 +14041,16 @@ var constructQuery = {
14039
14041
  F2.printFilter(ast, () => PRINT_WORD("CONSTRUCT"));
14040
14042
  if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
14041
14043
  F2.printFilter(ast, () => PRINT_WORD("{"));
14042
- SUBRULE(triplesBlock, ast.template, void 0);
14044
+ SUBRULE(triplesBlock, ast.template);
14043
14045
  F2.printFilter(ast, () => PRINT_WORD("}"));
14044
14046
  }
14045
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
14047
+ SUBRULE(datasetClauseStar, ast.datasets);
14046
14048
  if (F2.isSourceLocationNoMaterialize(ast.where.loc)) {
14047
- SUBRULE(whereClause, F2.wrap(F2.patternGroup([ast.template], ast.template.loc), ast.template.loc), void 0);
14049
+ SUBRULE(whereClause, F2.wrap(F2.patternGroup([ast.template], ast.template.loc), ast.template.loc));
14048
14050
  } else {
14049
- SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc), void 0);
14051
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.where.loc));
14050
14052
  }
14051
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
14053
+ SUBRULE(solutionModifier, ast.solutionModifiers);
14052
14054
  }
14053
14055
  };
14054
14056
  var describeQuery = {
@@ -14059,7 +14061,7 @@ var describeQuery = {
14059
14061
  { ALT: () => {
14060
14062
  const variables2 = [];
14061
14063
  AT_LEAST_ONE(() => {
14062
- variables2.push(SUBRULE1(varOrIri, void 0));
14064
+ variables2.push(SUBRULE1(varOrIri));
14063
14065
  });
14064
14066
  return variables2;
14065
14067
  } },
@@ -14068,9 +14070,9 @@ var describeQuery = {
14068
14070
  return [ACTION(() => C.factory.wildcard(C.factory.sourceLocation(star2)))];
14069
14071
  } }
14070
14072
  ]);
14071
- const from2 = SUBRULE1(datasetClauseStar, void 0);
14072
- const where2 = OPTION(() => SUBRULE1(whereClause, void 0));
14073
- const modifiers = SUBRULE1(solutionModifier, void 0);
14073
+ const from2 = SUBRULE1(datasetClauseStar);
14074
+ const where2 = OPTION(() => SUBRULE1(whereClause));
14075
+ const modifiers = SUBRULE1(solutionModifier);
14074
14076
  return ACTION(() => ({
14075
14077
  subType: "describe",
14076
14078
  variables,
@@ -14095,23 +14097,23 @@ var describeQuery = {
14095
14097
  F2.printFilter(ast, () => PRINT_WORD("*"));
14096
14098
  } else {
14097
14099
  for (const variable of ast.variables) {
14098
- SUBRULE(varOrTerm, variable, void 0);
14100
+ SUBRULE(varOrTerm, variable);
14099
14101
  }
14100
14102
  }
14101
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
14103
+ SUBRULE(datasetClauseStar, ast.datasets);
14102
14104
  if (ast.where) {
14103
- SUBRULE(whereClause, F2.wrap(ast.where, ast.loc), void 0);
14105
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
14104
14106
  }
14105
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
14107
+ SUBRULE(solutionModifier, ast.solutionModifiers);
14106
14108
  }
14107
14109
  };
14108
14110
  var askQuery = {
14109
14111
  name: "askQuery",
14110
14112
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14111
14113
  const ask2 = CONSUME(ask);
14112
- const from2 = SUBRULE(datasetClauseStar, void 0);
14113
- const where2 = SUBRULE(whereClause, void 0);
14114
- const modifiers = SUBRULE(solutionModifier, void 0);
14114
+ const from2 = SUBRULE(datasetClauseStar);
14115
+ const where2 = SUBRULE(whereClause);
14116
+ const modifiers = SUBRULE(solutionModifier);
14115
14117
  return ACTION(() => ({
14116
14118
  subType: "ask",
14117
14119
  datasets: from2,
@@ -14130,20 +14132,20 @@ var askQuery = {
14130
14132
  },
14131
14133
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14132
14134
  F2.printFilter(ast, () => PRINT_WORD("ASK"));
14133
- SUBRULE(datasetClauseStar, ast.datasets, void 0);
14134
- SUBRULE(whereClause, F2.wrap(ast.where, ast.loc), void 0);
14135
- SUBRULE(solutionModifier, ast.solutionModifiers, void 0);
14135
+ SUBRULE(datasetClauseStar, ast.datasets);
14136
+ SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
14137
+ SUBRULE(solutionModifier, ast.solutionModifiers);
14136
14138
  }
14137
14139
  };
14138
14140
  var valuesClause = {
14139
14141
  name: "valuesClause",
14140
- impl: ({ OPTION, SUBRULE }) => () => OPTION(() => SUBRULE(inlineData, void 0))
14142
+ impl: ({ OPTION, SUBRULE }) => () => OPTION(() => SUBRULE(inlineData))
14141
14143
  };
14142
14144
  var constructTemplate = {
14143
14145
  name: "constructTemplate",
14144
14146
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14145
14147
  const open = CONSUME(symbols_exports.LCurly);
14146
- const triples = OPTION(() => SUBRULE1(constructTriples, void 0));
14148
+ const triples = OPTION(() => SUBRULE1(constructTriples));
14147
14149
  const close = CONSUME(symbols_exports.RCurly);
14148
14150
  return ACTION(() => C.factory.wrap(
14149
14151
  triples ?? C.factory.patternBgp([], C.factory.sourceLocation()),
@@ -14156,27 +14158,27 @@ var constructTriples = {
14156
14158
  impl: triplesTemplate.impl
14157
14159
  };
14158
14160
 
14159
- // ../../packages/rules-sparql-1-1/lib/grammar/updateUnit/updateUnit.ts
14161
+ // ../../packages/rules-sparql-1-1/lib/grammar/updateUnit.ts
14160
14162
  var updateUnit = {
14161
14163
  name: "updateUnit",
14162
- impl: ({ SUBRULE }) => () => SUBRULE(update, void 0)
14164
+ impl: ({ SUBRULE }) => () => SUBRULE(update)
14163
14165
  };
14164
14166
  var update = {
14165
14167
  name: "update",
14166
14168
  impl: ({ ACTION, SUBRULE, SUBRULE1, SUBRULE2, CONSUME, OPTION1, MANY }) => (C) => {
14167
14169
  const updates = [];
14168
- const prologueValues = SUBRULE1(prologue, void 0);
14170
+ const prologueValues = SUBRULE1(prologue);
14169
14171
  updates.push({ context: prologueValues });
14170
14172
  let parsedSemi = true;
14171
14173
  MANY({
14172
14174
  GATE: () => parsedSemi,
14173
14175
  DEF: () => {
14174
14176
  parsedSemi = false;
14175
- updates.at(-1).operation = SUBRULE(update1, void 0);
14177
+ updates.at(-1).operation = SUBRULE(update1);
14176
14178
  OPTION1(() => {
14177
14179
  CONSUME(symbols_exports.semi);
14178
14180
  parsedSemi = true;
14179
- const innerPrologue = SUBRULE2(prologue, void 0);
14181
+ const innerPrologue = SUBRULE2(prologue);
14180
14182
  updates.push({ context: innerPrologue });
14181
14183
  });
14182
14184
  }
@@ -14198,9 +14200,9 @@ var update = {
14198
14200
  },
14199
14201
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14200
14202
  for (const update2 of ast.updates) {
14201
- SUBRULE(prologue, update2.context, void 0);
14203
+ SUBRULE(prologue, update2.context);
14202
14204
  if (update2.operation) {
14203
- SUBRULE(update1, update2.operation, void 0);
14205
+ SUBRULE(update1, update2.operation);
14204
14206
  F2.printFilter(ast, () => PRINT_WORD(" ;\n"));
14205
14207
  }
14206
14208
  }
@@ -14209,52 +14211,52 @@ var update = {
14209
14211
  var update1 = {
14210
14212
  name: "update1",
14211
14213
  impl: ({ SUBRULE, OR }) => () => OR([
14212
- { ALT: () => SUBRULE(load2, void 0) },
14213
- { ALT: () => SUBRULE(clear2, void 0) },
14214
- { ALT: () => SUBRULE(drop3, void 0) },
14215
- { ALT: () => SUBRULE(add2, void 0) },
14216
- { ALT: () => SUBRULE(move2, void 0) },
14217
- { ALT: () => SUBRULE(copy2, void 0) },
14218
- { ALT: () => SUBRULE(create2, void 0) },
14219
- { ALT: () => SUBRULE(insertData, void 0) },
14220
- { ALT: () => SUBRULE(deleteData, void 0) },
14221
- { ALT: () => SUBRULE(deleteWhere, void 0) },
14222
- { ALT: () => SUBRULE(modify, void 0) }
14214
+ { ALT: () => SUBRULE(load2) },
14215
+ { ALT: () => SUBRULE(clear2) },
14216
+ { ALT: () => SUBRULE(drop3) },
14217
+ { ALT: () => SUBRULE(add2) },
14218
+ { ALT: () => SUBRULE(move2) },
14219
+ { ALT: () => SUBRULE(copy2) },
14220
+ { ALT: () => SUBRULE(create2) },
14221
+ { ALT: () => SUBRULE(insertData) },
14222
+ { ALT: () => SUBRULE(deleteData) },
14223
+ { ALT: () => SUBRULE(deleteWhere) },
14224
+ { ALT: () => SUBRULE(modify) }
14223
14225
  ]),
14224
14226
  gImpl: ({ SUBRULE }) => (ast) => {
14225
14227
  switch (ast.subType) {
14226
14228
  case "load":
14227
- SUBRULE(load2, ast, void 0);
14229
+ SUBRULE(load2, ast);
14228
14230
  break;
14229
14231
  case "clear":
14230
- SUBRULE(clear2, ast, void 0);
14232
+ SUBRULE(clear2, ast);
14231
14233
  break;
14232
14234
  case "drop":
14233
- SUBRULE(drop3, ast, void 0);
14235
+ SUBRULE(drop3, ast);
14234
14236
  break;
14235
14237
  case "add":
14236
- SUBRULE(add2, ast, void 0);
14238
+ SUBRULE(add2, ast);
14237
14239
  break;
14238
14240
  case "move":
14239
- SUBRULE(move2, ast, void 0);
14241
+ SUBRULE(move2, ast);
14240
14242
  break;
14241
14243
  case "copy":
14242
- SUBRULE(copy2, ast, void 0);
14244
+ SUBRULE(copy2, ast);
14243
14245
  break;
14244
14246
  case "create":
14245
- SUBRULE(create2, ast, void 0);
14247
+ SUBRULE(create2, ast);
14246
14248
  break;
14247
14249
  case "insertdata":
14248
- SUBRULE(insertData, ast, void 0);
14250
+ SUBRULE(insertData, ast);
14249
14251
  break;
14250
14252
  case "deletedata":
14251
- SUBRULE(deleteData, ast, void 0);
14253
+ SUBRULE(deleteData, ast);
14252
14254
  break;
14253
14255
  case "deletewhere":
14254
- SUBRULE(deleteWhere, ast, void 0);
14256
+ SUBRULE(deleteWhere, ast);
14255
14257
  break;
14256
14258
  case "modify":
14257
- SUBRULE(modify, ast, void 0);
14259
+ SUBRULE(modify, ast);
14258
14260
  break;
14259
14261
  }
14260
14262
  }
@@ -14264,10 +14266,10 @@ var load2 = {
14264
14266
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION1, OPTION2 }) => (C) => {
14265
14267
  const loadToken = CONSUME(load);
14266
14268
  const silent2 = OPTION1(() => CONSUME(silent));
14267
- const source = SUBRULE1(iri2, void 0);
14269
+ const source = SUBRULE1(iri2);
14268
14270
  const destination = OPTION2(() => {
14269
14271
  CONSUME(loadInto);
14270
- return SUBRULE1(graphRef, void 0);
14272
+ return SUBRULE1(graphRef);
14271
14273
  });
14272
14274
  return ACTION(() => C.factory.updateOperationLoad(
14273
14275
  C.factory.sourceLocation(loadToken, source, destination),
@@ -14283,10 +14285,10 @@ var load2 = {
14283
14285
  PRINT_WORD("SILENT");
14284
14286
  }
14285
14287
  });
14286
- SUBRULE(iri2, ast.source, void 0);
14288
+ SUBRULE(iri2, ast.source);
14287
14289
  if (ast.destination) {
14288
14290
  F2.printFilter(ast, () => PRINT_WORD("INTO"));
14289
- SUBRULE(graphRefAll, ast.destination, void 0);
14291
+ SUBRULE(graphRefAll, ast.destination);
14290
14292
  }
14291
14293
  }
14292
14294
  };
@@ -14296,7 +14298,7 @@ function clearOrDrop(operation) {
14296
14298
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14297
14299
  const opToken = CONSUME(operation);
14298
14300
  const silent2 = OPTION(() => CONSUME(silent));
14299
- const destination = SUBRULE1(graphRefAll, void 0);
14301
+ const destination = SUBRULE1(graphRefAll);
14300
14302
  return ACTION(() => C.factory.updateOperationClearDrop(
14301
14303
  unCapitalize(operation.name),
14302
14304
  Boolean(silent2),
@@ -14311,7 +14313,7 @@ function clearOrDrop(operation) {
14311
14313
  PRINT_WORD("SILENT");
14312
14314
  }
14313
14315
  });
14314
- SUBRULE(graphRefAll, ast.destination, void 0);
14316
+ SUBRULE(graphRefAll, ast.destination);
14315
14317
  }
14316
14318
  };
14317
14319
  }
@@ -14322,7 +14324,7 @@ var create2 = {
14322
14324
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14323
14325
  const createToken3 = CONSUME(create);
14324
14326
  const silent2 = OPTION(() => CONSUME(silent));
14325
- const destination = SUBRULE1(graphRef, void 0);
14327
+ const destination = SUBRULE1(graphRef);
14326
14328
  return ACTION(() => C.factory.updateOperationCreate(
14327
14329
  destination,
14328
14330
  Boolean(silent2),
@@ -14336,7 +14338,7 @@ var create2 = {
14336
14338
  PRINT_WORD("SILENT");
14337
14339
  }
14338
14340
  });
14339
- SUBRULE(graphRefAll, ast.destination, void 0);
14341
+ SUBRULE(graphRefAll, ast.destination);
14340
14342
  }
14341
14343
  };
14342
14344
  function copyMoveAddOperation(operation) {
@@ -14345,9 +14347,9 @@ function copyMoveAddOperation(operation) {
14345
14347
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION }) => (C) => {
14346
14348
  const op = CONSUME(operation);
14347
14349
  const silent2 = OPTION(() => CONSUME(silent));
14348
- const source = SUBRULE1(graphOrDefault, void 0);
14350
+ const source = SUBRULE1(graphOrDefault);
14349
14351
  CONSUME(to);
14350
- const destination = SUBRULE2(graphOrDefault, void 0);
14352
+ const destination = SUBRULE2(graphOrDefault);
14351
14353
  return ACTION(() => C.factory.updateOperationAddMoveCopy(
14352
14354
  unCapitalize(operation.name),
14353
14355
  source,
@@ -14363,9 +14365,9 @@ function copyMoveAddOperation(operation) {
14363
14365
  PRINT_WORD("SILENT");
14364
14366
  }
14365
14367
  });
14366
- SUBRULE(graphRefAll, ast.source, void 0);
14368
+ SUBRULE(graphRefAll, ast.source);
14367
14369
  F2.printFilter(ast, () => PRINT_WORD("TO"));
14368
- SUBRULE(graphRefAll, ast.destination, void 0);
14370
+ SUBRULE(graphRefAll, ast.destination);
14369
14371
  }
14370
14372
  };
14371
14373
  }
@@ -14376,7 +14378,7 @@ var quadPattern = {
14376
14378
  name: "quadPattern",
14377
14379
  impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
14378
14380
  const open = CONSUME(symbols_exports.LCurly);
14379
- const val = SUBRULE1(quads, void 0);
14381
+ const val = SUBRULE1(quads);
14380
14382
  const close = CONSUME(symbols_exports.RCurly);
14381
14383
  return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
14382
14384
  }
@@ -14386,7 +14388,7 @@ var quadData = {
14386
14388
  impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
14387
14389
  const open = CONSUME(symbols_exports.LCurly);
14388
14390
  const couldParseVars = ACTION(() => C.parseMode.delete("canParseVars"));
14389
- const val = SUBRULE1(quads, void 0);
14391
+ const val = SUBRULE1(quads);
14390
14392
  ACTION(() => couldParseVars && C.parseMode.add("canParseVars"));
14391
14393
  const close = CONSUME(symbols_exports.RCurly);
14392
14394
  return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
@@ -14402,7 +14404,7 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14402
14404
  if (name !== "insertData") {
14403
14405
  couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
14404
14406
  }
14405
- const data = SUBRULE1(dataRule, void 0);
14407
+ const data = SUBRULE1(dataRule);
14406
14408
  if (name !== "insertData") {
14407
14409
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14408
14410
  }
@@ -14413,7 +14415,7 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14413
14415
  subType === "insertdata" ? "INSERT DATA" : subType === "deletedata" ? "DELETE DATA" : "DELETE WHERE",
14414
14416
  "{"
14415
14417
  ));
14416
- SUBRULE(quads, F2.wrap(ast.data, ast.loc), void 0);
14418
+ SUBRULE(quads, F2.wrap(ast.data, ast.loc));
14417
14419
  F2.printFilter(ast, () => PRINT_WORD("}"));
14418
14420
  }
14419
14421
  };
@@ -14426,23 +14428,23 @@ var modify = {
14426
14428
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => {
14427
14429
  const graph2 = OPTION1(() => {
14428
14430
  const withToken = CONSUME(modifyWith);
14429
- const graph3 = SUBRULE1(iri2, void 0);
14431
+ const graph3 = SUBRULE1(iri2);
14430
14432
  return { withToken, graph: graph3 };
14431
14433
  });
14432
14434
  const { insert, del } = OR([
14433
14435
  { ALT: () => {
14434
- const del2 = SUBRULE1(deleteClause2, void 0);
14435
- const insert2 = OPTION2(() => SUBRULE1(insertClause2, void 0));
14436
+ const del2 = SUBRULE1(deleteClause2);
14437
+ const insert2 = OPTION2(() => SUBRULE1(insertClause2));
14436
14438
  return { del: del2, insert: insert2 };
14437
14439
  } },
14438
14440
  { ALT: () => {
14439
- const insert2 = SUBRULE2(insertClause2, void 0);
14441
+ const insert2 = SUBRULE2(insertClause2);
14440
14442
  return { insert: insert2, del: void 0 };
14441
14443
  } }
14442
14444
  ]);
14443
- const using = SUBRULE1(usingClauseStar, void 0);
14445
+ const using = SUBRULE1(usingClauseStar);
14444
14446
  CONSUME(where);
14445
- const where2 = SUBRULE1(groupGraphPattern, void 0);
14447
+ const where2 = SUBRULE1(groupGraphPattern);
14446
14448
  return ACTION(() => C.factory.updateOperationModify(
14447
14449
  C.factory.sourceLocation(graph2?.withToken, del, insert, where2),
14448
14450
  insert?.val ?? [],
@@ -14455,21 +14457,21 @@ var modify = {
14455
14457
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14456
14458
  if (ast.graph) {
14457
14459
  F2.printFilter(ast, () => PRINT_WORD("WITH"));
14458
- SUBRULE(iri2, ast.graph, void 0);
14460
+ SUBRULE(iri2, ast.graph);
14459
14461
  }
14460
14462
  if (ast.delete.length > 0) {
14461
14463
  F2.printFilter(ast, () => PRINT_WORD("DELETE", "{"));
14462
- SUBRULE(quads, F2.wrap(ast.delete, ast.loc), void 0);
14464
+ SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
14463
14465
  F2.printFilter(ast, () => PRINT_WORD("}"));
14464
14466
  }
14465
14467
  if (ast.insert.length > 0) {
14466
14468
  F2.printFilter(ast, () => PRINT_WORD("INSERT", "{"));
14467
- SUBRULE(quads, F2.wrap(ast.insert, ast.loc), void 0);
14469
+ SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
14468
14470
  F2.printFilter(ast, () => PRINT_WORD("}"));
14469
14471
  }
14470
- SUBRULE(usingClauseStar, ast.from, void 0);
14472
+ SUBRULE(usingClauseStar, ast.from);
14471
14473
  F2.printFilter(ast, () => PRINT_WORD("WHERE"));
14472
- SUBRULE(groupGraphPattern, ast.where, void 0);
14474
+ SUBRULE(groupGraphPattern, ast.where);
14473
14475
  }
14474
14476
  };
14475
14477
  var deleteClause2 = {
@@ -14477,7 +14479,7 @@ var deleteClause2 = {
14477
14479
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14478
14480
  const delToken = CONSUME(deleteClause);
14479
14481
  const couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
14480
- const del = SUBRULE(quadPattern, void 0);
14482
+ const del = SUBRULE(quadPattern);
14481
14483
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14482
14484
  return ACTION(() => C.factory.wrap(del.val, C.factory.sourceLocation(delToken, del)));
14483
14485
  }
@@ -14486,7 +14488,7 @@ var insertClause2 = {
14486
14488
  name: "insertClause",
14487
14489
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14488
14490
  const insertToken = CONSUME(insertClause);
14489
- const insert = SUBRULE(quadPattern, void 0);
14491
+ const insert = SUBRULE(quadPattern);
14490
14492
  return ACTION(() => C.factory.wrap(insert.val, C.factory.sourceLocation(insertToken, insert)));
14491
14493
  }
14492
14494
  };
@@ -14499,7 +14501,7 @@ var graphOrDefault = {
14499
14501
  } },
14500
14502
  { ALT: () => {
14501
14503
  const graph2 = OPTION(() => CONSUME(graph_exports.graph));
14502
- const name = SUBRULE1(iri2, void 0);
14504
+ const name = SUBRULE1(iri2);
14503
14505
  return ACTION(() => C.factory.graphRefSpecific(name, C.factory.sourceLocation(graph2, name)));
14504
14506
  } }
14505
14507
  ])
@@ -14508,18 +14510,18 @@ var graphRef = {
14508
14510
  name: "graphRef",
14509
14511
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14510
14512
  const graph2 = CONSUME(graph_exports.graph);
14511
- const val = SUBRULE(iri2, void 0);
14513
+ const val = SUBRULE(iri2);
14512
14514
  return ACTION(() => C.factory.graphRefSpecific(val, C.factory.sourceLocation(graph2, val)));
14513
14515
  },
14514
14516
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14515
14517
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14516
- SUBRULE(iri2, ast.graph, void 0);
14518
+ SUBRULE(iri2, ast.graph);
14517
14519
  }
14518
14520
  };
14519
14521
  var graphRefAll = {
14520
14522
  name: "graphRefAll",
14521
14523
  impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => OR([
14522
- { ALT: () => SUBRULE(graphRef, void 0) },
14524
+ { ALT: () => SUBRULE(graphRef) },
14523
14525
  { ALT: () => {
14524
14526
  const def = CONSUME(graph_exports.default_);
14525
14527
  return ACTION(() => C.factory.graphRefDefault(C.factory.sourceLocation(def)));
@@ -14535,7 +14537,7 @@ var graphRefAll = {
14535
14537
  ]),
14536
14538
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14537
14539
  if (F2.isGraphRefSpecific(ast)) {
14538
- SUBRULE(graphRef, ast, void 0);
14540
+ SUBRULE(graphRef, ast);
14539
14541
  } else if (F2.isGraphRefDefault(ast)) {
14540
14542
  F2.printFilter(ast, () => PRINT_WORD("DEFAULT"));
14541
14543
  } else if (F2.isGraphRefNamed(ast)) {
@@ -14551,12 +14553,12 @@ var quads = {
14551
14553
  const quads2 = [];
14552
14554
  let last2;
14553
14555
  OPTION1(() => {
14554
- const triples = SUBRULE1(triplesTemplate, void 0);
14556
+ const triples = SUBRULE1(triplesTemplate);
14555
14557
  last2 = triples;
14556
14558
  ACTION(() => quads2.push(triples));
14557
14559
  });
14558
14560
  MANY(() => {
14559
- const notTriples = SUBRULE(quadsNotTriples, void 0);
14561
+ const notTriples = SUBRULE(quadsNotTriples);
14560
14562
  last2 = notTriples;
14561
14563
  quads2.push(notTriples);
14562
14564
  OPTION2(() => {
@@ -14565,7 +14567,7 @@ var quads = {
14565
14567
  return dotToken;
14566
14568
  });
14567
14569
  OPTION3(() => {
14568
- const triples = SUBRULE2(triplesTemplate, void 0);
14570
+ const triples = SUBRULE2(triplesTemplate);
14569
14571
  last2 = triples;
14570
14572
  ACTION(() => quads2.push(triples));
14571
14573
  });
@@ -14575,9 +14577,9 @@ var quads = {
14575
14577
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
14576
14578
  for (const quad of ast.val) {
14577
14579
  if (F2.isPattern(quad)) {
14578
- SUBRULE(triplesBlock, quad, void 0);
14580
+ SUBRULE(triplesBlock, quad);
14579
14581
  } else {
14580
- SUBRULE(quadsNotTriples, quad, void 0);
14582
+ SUBRULE(quadsNotTriples, quad);
14581
14583
  }
14582
14584
  }
14583
14585
  }
@@ -14586,9 +14588,9 @@ var quadsNotTriples = {
14586
14588
  name: "quadsNotTriples",
14587
14589
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
14588
14590
  const graph2 = CONSUME(graph_exports.graph);
14589
- const name = SUBRULE1(varOrIri, void 0);
14591
+ const name = SUBRULE1(varOrIri);
14590
14592
  CONSUME(symbols_exports.LCurly);
14591
- const triples = OPTION(() => SUBRULE1(triplesTemplate, void 0));
14593
+ const triples = OPTION(() => SUBRULE1(triplesTemplate));
14592
14594
  const close = CONSUME(symbols_exports.RCurly);
14593
14595
  return ACTION(() => C.factory.graphQuads(
14594
14596
  name,
@@ -14598,21 +14600,96 @@ var quadsNotTriples = {
14598
14600
  },
14599
14601
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14600
14602
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14601
- SUBRULE(varOrTerm, ast.graph, void 0);
14603
+ SUBRULE(varOrTerm, ast.graph);
14602
14604
  F2.printFilter(ast, () => PRINT_WORD("{"));
14603
- SUBRULE(triplesBlock, ast.triples, void 0);
14605
+ SUBRULE(triplesBlock, ast.triples);
14604
14606
  F2.printFilter(ast, () => PRINT_WORD("}"));
14605
14607
  }
14606
14608
  };
14607
14609
 
14608
- // lib/index.ts
14610
+ // ../../packages/rules-sparql-1-1/lib/grammar/index.ts
14609
14611
  var queryOrUpdate = {
14612
+ name: "queryOrUpdate",
14613
+ impl: ({ ACTION, SUBRULE, OR1, OR2, MANY, OPTION1, CONSUME, SUBRULE2 }) => (C) => {
14614
+ const prologueValues = SUBRULE(prologue);
14615
+ return OR1([
14616
+ { ALT: () => {
14617
+ const subType = OR2([
14618
+ { ALT: () => SUBRULE(selectQuery) },
14619
+ { ALT: () => SUBRULE(constructQuery) },
14620
+ { ALT: () => SUBRULE(describeQuery) },
14621
+ { ALT: () => SUBRULE(askQuery) }
14622
+ ]);
14623
+ const values3 = SUBRULE(valuesClause);
14624
+ return ACTION(() => ({
14625
+ context: prologueValues,
14626
+ ...subType,
14627
+ type: "query",
14628
+ ...values3 && { values: values3 },
14629
+ loc: C.factory.sourceLocation(
14630
+ prologueValues.at(0),
14631
+ subType,
14632
+ values3
14633
+ )
14634
+ }));
14635
+ } },
14636
+ { ALT: () => {
14637
+ const updates = [];
14638
+ updates.push({ context: prologueValues });
14639
+ let parsedSemi = true;
14640
+ MANY({
14641
+ GATE: () => parsedSemi,
14642
+ DEF: () => {
14643
+ parsedSemi = false;
14644
+ updates.at(-1).operation = SUBRULE(update1);
14645
+ OPTION1(() => {
14646
+ CONSUME(symbols_exports.semi);
14647
+ parsedSemi = true;
14648
+ const innerPrologue = SUBRULE2(prologue);
14649
+ updates.push({ context: innerPrologue });
14650
+ });
14651
+ }
14652
+ });
14653
+ return ACTION(() => {
14654
+ const update2 = {
14655
+ type: "update",
14656
+ updates,
14657
+ loc: C.factory.sourceLocation(
14658
+ ...updates[0].context,
14659
+ updates[0].operation,
14660
+ ...updates.at(-1).context,
14661
+ updates.at(-1)?.operation
14662
+ )
14663
+ };
14664
+ updateNoReuseBlankNodeLabels(update2);
14665
+ return update2;
14666
+ });
14667
+ } }
14668
+ ]);
14669
+ }
14670
+ };
14671
+
14672
+ // ../../packages/rules-sparql-1-1/lib/MinimalSparqlParser.ts
14673
+ function completeParseContext(context) {
14674
+ return {
14675
+ factory: context.factory ?? new Factory(),
14676
+ baseIRI: context.baseIRI,
14677
+ prefixes: { ...context.prefixes },
14678
+ origSource: context.origSource ?? "",
14679
+ offset: context.offset,
14680
+ parseMode: context.parseMode ? new Set(context.parseMode) : /* @__PURE__ */ new Set(["canParseVars", "canCreateBlankNodes"]),
14681
+ skipValidation: context.skipValidation ?? false
14682
+ };
14683
+ }
14684
+
14685
+ // lib/index.ts
14686
+ var queryOrUpdate2 = {
14610
14687
  name: "queryOrUpdate",
14611
14688
  gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
14612
14689
  if (F2.isQuery(ast)) {
14613
- SUBRULE(grammar_exports.query, ast, void 0);
14690
+ SUBRULE(grammar_exports.query, ast);
14614
14691
  } else {
14615
- SUBRULE(grammar_exports.update, ast, void 0);
14692
+ SUBRULE(grammar_exports.update, ast);
14616
14693
  }
14617
14694
  }
14618
14695
  };
@@ -14686,25 +14763,15 @@ var sparql11GeneratorBuilder = GeneratorBuilder.create([
14686
14763
  grammar_exports.minusGraphPattern,
14687
14764
  grammar_exports.groupOrUnionGraphPattern,
14688
14765
  grammar_exports.filter
14689
- ).addRule(queryOrUpdate);
14766
+ ).addRule(queryOrUpdate2);
14690
14767
  var Generator = class {
14691
- constructor() {
14692
- this.generator = sparql11GeneratorBuilder.build();
14693
- this.factory = new Factory();
14694
- }
14695
- generate(ast, origSource = "") {
14696
- return this.generator.queryOrUpdate(ast, {
14697
- factory: this.factory,
14698
- offset: 0,
14699
- origSource
14700
- }, void 0);
14701
- }
14702
- generatePath(ast, origSource = "") {
14703
- return this.generator.path(ast, {
14704
- factory: this.factory,
14705
- offset: 0,
14706
- origSource
14707
- }, void 0);
14768
+ generator = sparql11GeneratorBuilder.build();
14769
+ factory = new Factory();
14770
+ generate(ast, context = {}) {
14771
+ return this.generator.queryOrUpdate(ast, completeParseContext(context));
14772
+ }
14773
+ generatePath(ast, context = {}) {
14774
+ return this.generator.path(ast, completeParseContext(context), void 0);
14708
14775
  }
14709
14776
  };
14710
14777
  /*! Bundled license information: