@traqula/generator-sparql-1-1 0.0.15 → 0.0.17

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
@@ -25,8 +25,8 @@ __export(index_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
27
 
28
- // ../../packages/core/lib/CoreFactory.js
29
- var CoreFactory = class {
28
+ // ../../packages/core/lib/AstCoreFactory.js
29
+ var AstCoreFactory = class {
30
30
  wrap(val, loc) {
31
31
  return { val, loc };
32
32
  }
@@ -152,214 +152,6 @@ var CoreFactory = class {
152
152
  }
153
153
  };
154
154
 
155
- // ../../packages/core/lib/generator-builder/dynamicGenerator.js
156
- var DynamicGenerator = class {
157
- rules;
158
- factory = new CoreFactory();
159
- __context = void 0;
160
- origSource = "";
161
- generatedUntil = 0;
162
- expectsSpace;
163
- stringBuilder = [];
164
- constructor(rules) {
165
- this.rules = rules;
166
- for (const rule of Object.values(rules)) {
167
- this[rule.name] = ((input, context, args) => {
168
- this.expectsSpace = false;
169
- this.stringBuilder.length = 0;
170
- this.origSource = context.origSource;
171
- this.generatedUntil = context?.offset ?? 0;
172
- this.setContext(context);
173
- this.subrule(rule, input, args);
174
- this.catchup(this.origSource.length);
175
- return this.stringBuilder.join("");
176
- });
177
- }
178
- }
179
- setContext(context) {
180
- this.__context = context;
181
- }
182
- getSafeContext() {
183
- return this.__context;
184
- }
185
- subrule = (cstDef, ast, ...arg) => {
186
- const def = this.rules[cstDef.name];
187
- if (!def) {
188
- throw new Error(`Rule ${cstDef.name} not found`);
189
- }
190
- const generate = () => def.gImpl({
191
- SUBRULE: this.subrule,
192
- PRINT: this.print,
193
- PRINT_SPACE_LEFT: this.printSpaceLeft,
194
- PRINT_WORD: this.printWord,
195
- PRINT_WORDS: this.printWords,
196
- CATCHUP: this.catchup,
197
- HANDLE_LOC: this.handleLoc
198
- })(ast, this.getSafeContext(), ...arg);
199
- if (this.factory.isLocalized(ast)) {
200
- this.handleLoc(ast, generate);
201
- } else {
202
- generate();
203
- }
204
- };
205
- handleLoc = (localized, handle) => {
206
- if (this.factory.isSourceLocationNoMaterialize(localized.loc)) {
207
- return;
208
- }
209
- if (this.factory.isSourceLocationStringReplace(localized.loc)) {
210
- this.catchup(localized.loc.start);
211
- this.print(localized.loc.newSource);
212
- this.generatedUntil = localized.loc.end;
213
- return;
214
- }
215
- if (this.factory.isSourceLocationNodeReplace(localized.loc)) {
216
- this.catchup(localized.loc.start);
217
- this.generatedUntil = localized.loc.end;
218
- }
219
- if (this.factory.isSourceLocationSource(localized.loc)) {
220
- this.catchup(localized.loc.start);
221
- }
222
- const ret = handle();
223
- if (this.factory.isSourceLocationSource(localized.loc)) {
224
- this.catchup(localized.loc.end);
225
- }
226
- return ret;
227
- };
228
- catchup = (until) => {
229
- const start = this.generatedUntil;
230
- if (start < until) {
231
- this.print(this.origSource.slice(start, until));
232
- }
233
- this.generatedUntil = Math.max(this.generatedUntil, until);
234
- };
235
- print = (...args) => {
236
- const pureArgs = args.filter((x) => x.length > 0);
237
- if (pureArgs.length > 0) {
238
- const [head2, ...tail] = pureArgs;
239
- if (this.expectsSpace) {
240
- this.expectsSpace = false;
241
- const blanks = /* @__PURE__ */ new Set(["\n", " ", " "]);
242
- if (this.stringBuilder.length > 0 && !(blanks.has(head2[0]) || blanks.has(this.stringBuilder.at(-1).at(-1)))) {
243
- this.stringBuilder.push(" ");
244
- }
245
- }
246
- this.stringBuilder.push(head2);
247
- this.stringBuilder.push(...tail);
248
- }
249
- };
250
- printWord = (...args) => {
251
- this.expectsSpace = true;
252
- this.print(...args);
253
- this.expectsSpace = true;
254
- };
255
- printSpaceLeft = (...args) => {
256
- this.expectsSpace = true;
257
- this.print(...args);
258
- };
259
- printWords = (...args) => {
260
- for (const arg of args) {
261
- this.printWord(arg);
262
- }
263
- };
264
- };
265
-
266
- // ../../packages/core/lib/generator-builder/generatorBuilder.js
267
- function listToRuleDefMap(rules) {
268
- const newRules = {};
269
- for (const rule of rules) {
270
- newRules[rule.name] = rule;
271
- }
272
- return newRules;
273
- }
274
- var GeneratorBuilder = class _GeneratorBuilder {
275
- static create(start) {
276
- if (start instanceof _GeneratorBuilder) {
277
- return new _GeneratorBuilder({ ...start.rules });
278
- }
279
- return new _GeneratorBuilder(listToRuleDefMap(start));
280
- }
281
- rules;
282
- constructor(startRules) {
283
- this.rules = startRules;
284
- }
285
- widenContext() {
286
- return this;
287
- }
288
- typePatch() {
289
- return this;
290
- }
291
- /**
292
- * Change the implementation of an existing generator rule.
293
- */
294
- patchRule(patch) {
295
- const self2 = this;
296
- self2.rules[patch.name] = patch;
297
- return self2;
298
- }
299
- /**
300
- * Add a rule to the grammar. If the rule already exists, but the implementation differs, an error will be thrown.
301
- */
302
- addRuleRedundant(rule) {
303
- const self2 = this;
304
- const rules = self2.rules;
305
- if (rules[rule.name] !== void 0 && rules[rule.name] !== rule) {
306
- throw new Error(`Rule ${rule.name} already exists in the GeneratorBuilder`);
307
- }
308
- rules[rule.name] = rule;
309
- return self2;
310
- }
311
- /**
312
- * Add a rule to the grammar. Will raise a typescript error if the rule already exists in the grammar.
313
- */
314
- addRule(rule) {
315
- return this.addRuleRedundant(rule);
316
- }
317
- addMany(...rules) {
318
- this.rules = { ...this.rules, ...listToRuleDefMap(rules) };
319
- return this;
320
- }
321
- /**
322
- * Delete a grammar rule by its name.
323
- */
324
- deleteRule(ruleName) {
325
- delete this.rules[ruleName];
326
- return this;
327
- }
328
- /**
329
- * Merge this grammar GeneratorBuilder with another.
330
- * It is best to merge the bigger grammar with the smaller one.
331
- * If the two builders both have a grammar rule with the same name,
332
- * no error will be thrown case they map to the same ruledef object.
333
- * If they map to a different object, an error will be thrown.
334
- * To fix this problem, the overridingRules array should contain a rule with the same conflicting name,
335
- * this rule implementation will be used.
336
- */
337
- merge(GeneratorBuilder2, overridingRules) {
338
- const otherRules = { ...GeneratorBuilder2.rules };
339
- const myRules = this.rules;
340
- for (const rule of Object.values(myRules)) {
341
- if (otherRules[rule.name] === void 0) {
342
- otherRules[rule.name] = rule;
343
- } else {
344
- const existingRule = otherRules[rule.name];
345
- if (existingRule !== rule) {
346
- const override = overridingRules.find((x) => x.name === rule.name);
347
- if (override) {
348
- otherRules[rule.name] = override;
349
- } else {
350
- throw new Error(`Rule with name "${rule.name}" already exists in the GeneratorBuilder, specify an override to resolve conflict`);
351
- }
352
- }
353
- }
354
- }
355
- this.rules = otherRules;
356
- return this;
357
- }
358
- build() {
359
- return new DynamicGenerator(this.rules);
360
- }
361
- };
362
-
363
155
  // ../../node_modules/lodash-es/_freeGlobal.js
364
156
  var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
365
157
  var freeGlobal_default = freeGlobal;
@@ -9571,28 +9363,284 @@ applyMixins(Parser, [
9571
9363
  PerformanceTracer
9572
9364
  ]);
9573
9365
 
9574
- // ../../packages/core/lib/lexer-builder/LexerBuilder.js
9575
- var LexerBuilder = class _LexerBuilder {
9576
- tokens;
9577
- static create(starter) {
9578
- return new _LexerBuilder(starter);
9366
+ // ../../packages/core/lib/utils.js
9367
+ function unCapitalize(str2) {
9368
+ return str2.charAt(0).toLowerCase() + str2.slice(1);
9369
+ }
9370
+ function createToken2(config) {
9371
+ return createToken(config);
9372
+ }
9373
+ var traqulaIndentation = "When you use this string, you expect traqula to handle indentation after every newline";
9374
+
9375
+ // ../../packages/core/lib/generator-builder/dynamicGenerator.js
9376
+ var DynamicGenerator = class {
9377
+ rules;
9378
+ factory = new AstCoreFactory();
9379
+ __context = void 0;
9380
+ origSource = "";
9381
+ generatedUntil = 0;
9382
+ expectsSpace;
9383
+ stringBuilder = [];
9384
+ constructor(rules) {
9385
+ this.rules = rules;
9386
+ for (const rule of Object.values(rules)) {
9387
+ this[rule.name] = ((input, context, args) => {
9388
+ this.expectsSpace = false;
9389
+ this.stringBuilder.length = 0;
9390
+ this.origSource = context.origSource;
9391
+ this.generatedUntil = context?.offset ?? 0;
9392
+ this.setContext(context);
9393
+ this.subrule(rule, input, args);
9394
+ this.catchup(this.origSource.length);
9395
+ return this.stringBuilder.join("");
9396
+ });
9397
+ }
9579
9398
  }
9580
- constructor(starter) {
9581
- this.tokens = starter?.tokens ? [...starter.tokens] : [];
9399
+ setContext(context) {
9400
+ this.__context = context;
9582
9401
  }
9583
- merge(merge, overwrite = []) {
9584
- const extraTokens = merge.tokens.filter((token) => {
9585
- const overwriteToken = overwrite.find((t) => t.name === token.name);
9586
- if (overwriteToken) {
9587
- return false;
9588
- }
9589
- const match = this.tokens.find((t) => t.name === token.name);
9590
- if (match) {
9591
- if (match !== token) {
9592
- throw new Error(`Token with name ${token.name} already exists. Implementation is different and no overwrite was provided.`);
9593
- }
9594
- return false;
9595
- }
9402
+ getSafeContext() {
9403
+ return this.__context;
9404
+ }
9405
+ subrule = (cstDef, ast, ...arg) => {
9406
+ const def = this.rules[cstDef.name];
9407
+ if (!def) {
9408
+ throw new Error(`Rule ${cstDef.name} not found`);
9409
+ }
9410
+ const generate = () => def.gImpl({
9411
+ SUBRULE: this.subrule,
9412
+ PRINT: this.print,
9413
+ PRINT_SPACE_LEFT: this.printSpaceLeft,
9414
+ PRINT_WORD: this.printWord,
9415
+ PRINT_WORDS: this.printWords,
9416
+ PRINT_ON_EMPTY: this.printOnEmpty,
9417
+ CATCHUP: this.catchup,
9418
+ HANDLE_LOC: this.handleLoc
9419
+ })(ast, this.getSafeContext(), ...arg);
9420
+ if (this.factory.isLocalized(ast)) {
9421
+ this.handleLoc(ast, generate);
9422
+ } else {
9423
+ generate();
9424
+ }
9425
+ };
9426
+ handleLoc = (localized, handle) => {
9427
+ if (this.factory.isSourceLocationNoMaterialize(localized.loc)) {
9428
+ return;
9429
+ }
9430
+ if (this.factory.isSourceLocationStringReplace(localized.loc)) {
9431
+ this.catchup(localized.loc.start);
9432
+ this.print(localized.loc.newSource);
9433
+ this.generatedUntil = localized.loc.end;
9434
+ return;
9435
+ }
9436
+ if (this.factory.isSourceLocationNodeReplace(localized.loc)) {
9437
+ this.catchup(localized.loc.start);
9438
+ this.generatedUntil = localized.loc.end;
9439
+ }
9440
+ if (this.factory.isSourceLocationSource(localized.loc)) {
9441
+ this.catchup(localized.loc.start);
9442
+ }
9443
+ const ret = handle();
9444
+ if (this.factory.isSourceLocationSource(localized.loc)) {
9445
+ this.catchup(localized.loc.end);
9446
+ }
9447
+ return ret;
9448
+ };
9449
+ catchup = (until) => {
9450
+ const start = this.generatedUntil;
9451
+ if (start < until) {
9452
+ this.print(this.origSource.slice(start, until));
9453
+ }
9454
+ this.generatedUntil = Math.max(this.generatedUntil, until);
9455
+ };
9456
+ print = (...args) => {
9457
+ const pureArgs = args.filter((x) => x.length > 0);
9458
+ if (pureArgs.length > 0) {
9459
+ const head2 = pureArgs[0];
9460
+ if (this.expectsSpace) {
9461
+ this.expectsSpace = false;
9462
+ const blanks = /* @__PURE__ */ new Set(["\n", " ", " "]);
9463
+ if (this.stringBuilder.length > 0 && !(blanks.has(head2[0]) || blanks.has(this.stringBuilder.at(-1).at(-1)))) {
9464
+ this.stringBuilder.push(" ");
9465
+ }
9466
+ }
9467
+ const context = this.getSafeContext();
9468
+ if (context[traqulaIndentation] && typeof context[traqulaIndentation] === "number") {
9469
+ const indent = context[traqulaIndentation];
9470
+ for (const str2 of pureArgs) {
9471
+ const [noNl, ...postNl] = str2.split("\n");
9472
+ this.stringBuilder.push(noNl);
9473
+ for (const subStr of postNl.map((line) => line.trimStart())) {
9474
+ this.stringBuilder.push("\n", " ".repeat(indent));
9475
+ if (subStr.length > 0) {
9476
+ this.stringBuilder.push(subStr);
9477
+ }
9478
+ }
9479
+ }
9480
+ } else {
9481
+ this.stringBuilder.push(...pureArgs);
9482
+ }
9483
+ }
9484
+ };
9485
+ printWord = (...args) => {
9486
+ this.expectsSpace = true;
9487
+ this.print(...args);
9488
+ this.expectsSpace = true;
9489
+ };
9490
+ printSpaceLeft = (...args) => {
9491
+ this.expectsSpace = true;
9492
+ this.print(...args);
9493
+ };
9494
+ printWords = (...args) => {
9495
+ for (const arg of args) {
9496
+ this.printWord(arg);
9497
+ }
9498
+ };
9499
+ printOnEmpty = (...args) => {
9500
+ let counter = this.stringBuilder.length - 1;
9501
+ let onEmpty = true;
9502
+ const isEmptyTest = /^[ \t\n]*$/u;
9503
+ while (counter >= 0 && onEmpty) {
9504
+ const cur = this.stringBuilder[counter];
9505
+ const indexOfNl = cur.lastIndexOf("\n");
9506
+ if (indexOfNl >= 0) {
9507
+ onEmpty = isEmptyTest.test(cur.slice(indexOfNl));
9508
+ if (onEmpty) {
9509
+ const newVal = cur.slice(0, indexOfNl);
9510
+ if (newVal) {
9511
+ this.stringBuilder[counter] = cur.slice(0, indexOfNl);
9512
+ } else {
9513
+ this.stringBuilder.splice(counter, 1);
9514
+ }
9515
+ }
9516
+ break;
9517
+ }
9518
+ onEmpty = isEmptyTest.test(cur);
9519
+ counter--;
9520
+ }
9521
+ this.print("\n", ...args);
9522
+ };
9523
+ };
9524
+
9525
+ // ../../packages/core/lib/generator-builder/generatorBuilder.js
9526
+ function listToRuleDefMap(rules) {
9527
+ const newRules = {};
9528
+ for (const rule of rules) {
9529
+ newRules[rule.name] = rule;
9530
+ }
9531
+ return newRules;
9532
+ }
9533
+ var GeneratorBuilder = class _GeneratorBuilder {
9534
+ static create(start) {
9535
+ if (start instanceof _GeneratorBuilder) {
9536
+ return new _GeneratorBuilder({ ...start.rules });
9537
+ }
9538
+ return new _GeneratorBuilder(listToRuleDefMap(start));
9539
+ }
9540
+ rules;
9541
+ constructor(startRules) {
9542
+ this.rules = startRules;
9543
+ }
9544
+ widenContext() {
9545
+ return this;
9546
+ }
9547
+ typePatch() {
9548
+ return this;
9549
+ }
9550
+ /**
9551
+ * Change the implementation of an existing generator rule.
9552
+ */
9553
+ patchRule(patch) {
9554
+ const self2 = this;
9555
+ self2.rules[patch.name] = patch;
9556
+ return self2;
9557
+ }
9558
+ /**
9559
+ * Add a rule to the grammar. If the rule already exists, but the implementation differs, an error will be thrown.
9560
+ */
9561
+ addRuleRedundant(rule) {
9562
+ const self2 = this;
9563
+ const rules = self2.rules;
9564
+ if (rules[rule.name] !== void 0 && rules[rule.name] !== rule) {
9565
+ throw new Error(`Rule ${rule.name} already exists in the GeneratorBuilder`);
9566
+ }
9567
+ rules[rule.name] = rule;
9568
+ return self2;
9569
+ }
9570
+ /**
9571
+ * Add a rule to the grammar. Will raise a typescript error if the rule already exists in the grammar.
9572
+ */
9573
+ addRule(rule) {
9574
+ return this.addRuleRedundant(rule);
9575
+ }
9576
+ addMany(...rules) {
9577
+ this.rules = { ...this.rules, ...listToRuleDefMap(rules) };
9578
+ return this;
9579
+ }
9580
+ /**
9581
+ * Delete a grammar rule by its name.
9582
+ */
9583
+ deleteRule(ruleName) {
9584
+ delete this.rules[ruleName];
9585
+ return this;
9586
+ }
9587
+ /**
9588
+ * Merge this grammar GeneratorBuilder with another.
9589
+ * It is best to merge the bigger grammar with the smaller one.
9590
+ * If the two builders both have a grammar rule with the same name,
9591
+ * no error will be thrown case they map to the same ruledef object.
9592
+ * If they map to a different object, an error will be thrown.
9593
+ * To fix this problem, the overridingRules array should contain a rule with the same conflicting name,
9594
+ * this rule implementation will be used.
9595
+ */
9596
+ merge(GeneratorBuilder2, overridingRules) {
9597
+ const otherRules = { ...GeneratorBuilder2.rules };
9598
+ const myRules = this.rules;
9599
+ for (const rule of Object.values(myRules)) {
9600
+ if (otherRules[rule.name] === void 0) {
9601
+ otherRules[rule.name] = rule;
9602
+ } else {
9603
+ const existingRule = otherRules[rule.name];
9604
+ if (existingRule !== rule) {
9605
+ const override = overridingRules.find((x) => x.name === rule.name);
9606
+ if (override) {
9607
+ otherRules[rule.name] = override;
9608
+ } else {
9609
+ throw new Error(`Rule with name "${rule.name}" already exists in the GeneratorBuilder, specify an override to resolve conflict`);
9610
+ }
9611
+ }
9612
+ }
9613
+ }
9614
+ this.rules = otherRules;
9615
+ return this;
9616
+ }
9617
+ build() {
9618
+ return new DynamicGenerator(this.rules);
9619
+ }
9620
+ };
9621
+
9622
+ // ../../packages/core/lib/lexer-builder/LexerBuilder.js
9623
+ var LexerBuilder = class _LexerBuilder {
9624
+ tokens;
9625
+ static create(starter) {
9626
+ return new _LexerBuilder(starter);
9627
+ }
9628
+ constructor(starter) {
9629
+ this.tokens = starter?.tokens ? [...starter.tokens] : [];
9630
+ }
9631
+ merge(merge, overwrite = []) {
9632
+ const extraTokens = merge.tokens.filter((token) => {
9633
+ const overwriteToken = overwrite.find((t) => t.name === token.name);
9634
+ if (overwriteToken) {
9635
+ return false;
9636
+ }
9637
+ const match = this.tokens.find((t) => t.name === token.name);
9638
+ if (match) {
9639
+ if (match !== token) {
9640
+ throw new Error(`Token with name ${token.name} already exists. Implementation is different and no overwrite was provided.`);
9641
+ }
9642
+ return false;
9643
+ }
9596
9644
  return true;
9597
9645
  });
9598
9646
  this.tokens.push(...extraTokens);
@@ -9668,16 +9716,13 @@ var LexerBuilder = class _LexerBuilder {
9668
9716
  }
9669
9717
  };
9670
9718
 
9671
- // ../../packages/core/lib/utils.js
9672
- function unCapitalize(str2) {
9673
- return str2.charAt(0).toLowerCase() + str2.slice(1);
9674
- }
9675
- function createToken2(config) {
9676
- return createToken(config);
9677
- }
9678
-
9679
9719
  // ../../packages/core/lib/Transformers.js
9680
9720
  var TransformerType = class {
9721
+ clone(obj) {
9722
+ const newObj = Object.create(Object.getPrototypeOf(obj));
9723
+ Object.defineProperties(newObj, Object.getOwnPropertyDescriptors(obj));
9724
+ return newObj;
9725
+ }
9681
9726
  safeObjectVisit(value, mapper) {
9682
9727
  if (value && typeof value === "object") {
9683
9728
  if (Array.isArray(value)) {
@@ -9687,104 +9732,213 @@ var TransformerType = class {
9687
9732
  }
9688
9733
  return value;
9689
9734
  }
9690
- transformNode(curObject, nodeCallBacks) {
9691
- let continueCheck;
9692
- let transformation;
9693
- const casted = curObject;
9694
- if (casted.type) {
9695
- continueCheck = nodeCallBacks[casted.type]?.continue;
9696
- transformation = nodeCallBacks[casted.type]?.transform;
9697
- }
9698
- let shouldContinue = true;
9699
- if (continueCheck) {
9700
- shouldContinue = continueCheck(curObject);
9701
- }
9702
- if (!shouldContinue) {
9703
- return curObject;
9704
- }
9705
- const copy3 = { ...curObject };
9706
- for (const [key, value] of Object.entries(copy3)) {
9707
- copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNode(obj, nodeCallBacks));
9708
- }
9709
- if (transformation) {
9710
- return transformation(copy3);
9711
- }
9712
- return copy3;
9735
+ /**
9736
+ * Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
9737
+ * @param startObject object to start iterating from
9738
+ * @param mapper mapper to transform the various objects - argument is a copy of the original
9739
+ * @param preVisitor callback that is evaluated before iterating deeper.
9740
+ * If continues is false, we do not iterate deeper, current object is still mapped. - default: true
9741
+ * If shortcut is true, we do not iterate deeper, nor do we branch out, this mapper will be the last one called.
9742
+ * - Default false
9743
+ */
9744
+ transformObject(startObject, mapper, preVisitor = () => ({})) {
9745
+ let didShortCut = false;
9746
+ const recurse = (curObject) => {
9747
+ const copy3 = this.clone(curObject);
9748
+ const context = preVisitor(copy3);
9749
+ didShortCut = context.shortcut ?? false;
9750
+ const continues = context.continue ?? true;
9751
+ if (continues && !didShortCut) {
9752
+ for (const [key, value] of Object.entries(copy3)) {
9753
+ if (didShortCut) {
9754
+ return copy3;
9755
+ }
9756
+ copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
9757
+ }
9758
+ }
9759
+ return mapper(copy3);
9760
+ };
9761
+ return recurse(startObject);
9713
9762
  }
9714
- visitNode(curObject, nodeCallBacks) {
9715
- let callback;
9716
- const casted = curObject;
9717
- if (casted.type) {
9718
- callback = nodeCallBacks[casted.type];
9719
- }
9720
- let shouldIterate = true;
9721
- if (callback) {
9722
- shouldIterate = callback(curObject);
9723
- }
9724
- if (shouldIterate) {
9725
- for (const value of Object.values(curObject)) {
9726
- this.safeObjectVisit(value, (obj) => this.visitNode(obj, nodeCallBacks));
9763
+ /**
9764
+ * Visitor that visits all objects. Visits deeper objects first.
9765
+ */
9766
+ visitObject(startObject, visitor, preVisitor = () => ({})) {
9767
+ let didShortCut = false;
9768
+ const recurse = (curObject) => {
9769
+ const context = preVisitor(curObject);
9770
+ didShortCut = context.shortcut ?? false;
9771
+ const continues = context.continue ?? true;
9772
+ if (continues && !didShortCut) {
9773
+ for (const value of Object.values(curObject)) {
9774
+ if (didShortCut) {
9775
+ return;
9776
+ }
9777
+ this.safeObjectVisit(value, (obj) => recurse(obj));
9778
+ }
9727
9779
  }
9728
- }
9780
+ visitor(curObject);
9781
+ };
9782
+ recurse(startObject);
9783
+ }
9784
+ transformNode(startObject, nodeCallBacks) {
9785
+ const transformWrapper = (curObject) => {
9786
+ const casted = curObject;
9787
+ if (casted.type) {
9788
+ const ogFunc = nodeCallBacks[casted.type]?.transform;
9789
+ if (ogFunc) {
9790
+ return ogFunc(casted);
9791
+ }
9792
+ }
9793
+ return curObject;
9794
+ };
9795
+ const preTransformWrapper = (curObject) => {
9796
+ const casted = curObject;
9797
+ if (casted.type) {
9798
+ const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9799
+ if (ogFunc) {
9800
+ return ogFunc(casted);
9801
+ }
9802
+ }
9803
+ return {};
9804
+ };
9805
+ return this.transformObject(startObject, transformWrapper, preTransformWrapper);
9806
+ }
9807
+ visitNode(startObject, nodeCallBacks) {
9808
+ const visitWrapper = (curObject) => {
9809
+ const casted = curObject;
9810
+ if (casted.type) {
9811
+ const ogFunc = nodeCallBacks[casted.type]?.visitor;
9812
+ if (ogFunc) {
9813
+ ogFunc(casted);
9814
+ }
9815
+ }
9816
+ };
9817
+ const preVisitWrapper = (curObject) => {
9818
+ const casted = curObject;
9819
+ if (casted.type) {
9820
+ const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9821
+ if (ogFunc) {
9822
+ return ogFunc(casted);
9823
+ }
9824
+ }
9825
+ return {};
9826
+ };
9827
+ this.visitObject(startObject, visitWrapper, preVisitWrapper);
9828
+ }
9829
+ traverseNodes(currentNode, traverse) {
9830
+ let didShortCut = false;
9831
+ const recurse = (curNode) => {
9832
+ const traverser = traverse[curNode.type];
9833
+ if (traverser) {
9834
+ const { next, shortcut } = traverser(curNode);
9835
+ didShortCut = shortcut ?? false;
9836
+ if (!didShortCut) {
9837
+ for (const node of next ?? []) {
9838
+ if (didShortCut) {
9839
+ return;
9840
+ }
9841
+ recurse(node);
9842
+ }
9843
+ }
9844
+ }
9845
+ };
9846
+ recurse(currentNode);
9729
9847
  }
9730
9848
  };
9731
9849
  var TransformerSubType = class extends TransformerType {
9732
- // Public visitObjects(curObject: object, visitor: (current: object) => void): void {
9733
- // for (const value of Object.values(curObject)) {
9734
- // this.safeObjectVisit(value, obj => this.visitObjects(obj, visitor));
9735
- // }
9736
- // }
9737
- transformNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
9738
- let continueCheck;
9739
- let transformation;
9740
- const casted = curObject;
9741
- if (casted.type && casted.subType) {
9742
- const specific = nodeSpecificCallBacks[casted.type];
9743
- if (specific) {
9744
- continueCheck = specific[casted.subType]?.continue;
9745
- transformation = specific[casted.subType]?.transform;
9746
- }
9747
- }
9748
- let shouldContinue = true;
9749
- if (continueCheck) {
9750
- shouldContinue = continueCheck(curObject);
9751
- }
9752
- if (!shouldContinue) {
9753
- return curObject;
9754
- }
9755
- const copy3 = { ...curObject };
9756
- for (const [key, value] of Object.entries(copy3)) {
9757
- copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
9758
- }
9759
- if (transformation) {
9760
- return transformation(copy3);
9761
- }
9762
- return copy3;
9850
+ transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
9851
+ const transformWrapper = (curObject) => {
9852
+ let ogTransform;
9853
+ const casted = curObject;
9854
+ if (casted.type && casted.subType) {
9855
+ const specific = nodeSpecificCallBacks[casted.type];
9856
+ if (specific) {
9857
+ ogTransform = specific[casted.subType]?.transform;
9858
+ }
9859
+ if (!ogTransform) {
9860
+ ogTransform = nodeCallBacks[casted.type]?.transform;
9861
+ }
9862
+ }
9863
+ return ogTransform ? ogTransform(casted) : curObject;
9864
+ };
9865
+ const preVisitWrapper = (curObject) => {
9866
+ let ogPreVisit;
9867
+ const casted = curObject;
9868
+ if (casted.type && casted.subType) {
9869
+ const specific = nodeSpecificCallBacks[casted.type];
9870
+ if (specific) {
9871
+ ogPreVisit = specific[casted.subType]?.preVisitor;
9872
+ }
9873
+ if (!ogPreVisit) {
9874
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
9875
+ }
9876
+ }
9877
+ return ogPreVisit ? ogPreVisit(casted) : curObject;
9878
+ };
9879
+ return this.transformObject(startObject, transformWrapper, preVisitWrapper);
9763
9880
  }
9764
9881
  /**
9765
9882
  * When both nodeCallBack and NodeSpecific callBack are matched, will only look at nodeSpecifCallback
9766
9883
  */
9767
- visitNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
9768
- let callback;
9769
- const casted = curObject;
9770
- if (casted.type && casted.subType) {
9771
- const specific = nodeSpecificCallBacks[casted.type];
9772
- if (specific) {
9773
- callback = specific[casted.subType];
9884
+ visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
9885
+ const visitWrapper = (curObject) => {
9886
+ let ogTransform;
9887
+ const casted = curObject;
9888
+ if (casted.type && casted.subType) {
9889
+ const specific = nodeSpecificCallBacks[casted.type];
9890
+ if (specific) {
9891
+ ogTransform = specific[casted.subType]?.visitor;
9892
+ }
9893
+ if (!ogTransform) {
9894
+ ogTransform = nodeCallBacks[casted.type]?.visitor;
9895
+ }
9774
9896
  }
9775
- }
9776
- if (!callback && casted.type) {
9777
- callback = nodeCallBacks[curObject.type];
9778
- }
9779
- let shouldIterate = true;
9780
- if (callback) {
9781
- shouldIterate = callback(curObject) ?? true;
9782
- }
9783
- if (shouldIterate) {
9784
- for (const value of Object.values(curObject)) {
9785
- this.safeObjectVisit(value, (obj) => this.visitNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
9897
+ if (ogTransform) {
9898
+ ogTransform(casted);
9786
9899
  }
9787
- }
9900
+ };
9901
+ const preVisitWrapper = (curObject) => {
9902
+ let ogPreVisit;
9903
+ const casted = curObject;
9904
+ if (casted.type && casted.subType) {
9905
+ const specific = nodeSpecificCallBacks[casted.type];
9906
+ if (specific) {
9907
+ ogPreVisit = specific[casted.subType]?.preVisitor;
9908
+ }
9909
+ if (!ogPreVisit) {
9910
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
9911
+ }
9912
+ }
9913
+ return ogPreVisit ? ogPreVisit(casted) : curObject;
9914
+ };
9915
+ this.visitObject(startObject, visitWrapper, preVisitWrapper);
9916
+ }
9917
+ traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
9918
+ let didShortCut = false;
9919
+ const recurse = (curNode) => {
9920
+ let traverser;
9921
+ const subObj = traverseSubNode[curNode.type];
9922
+ if (subObj) {
9923
+ traverser = subObj[curNode.subType];
9924
+ }
9925
+ if (!traverser) {
9926
+ traverser = traverseNode[curNode.type];
9927
+ }
9928
+ if (traverser) {
9929
+ const { next, shortcut } = traverser(curNode);
9930
+ didShortCut = shortcut ?? false;
9931
+ if (!didShortCut) {
9932
+ for (const node of next ?? []) {
9933
+ if (didShortCut) {
9934
+ return;
9935
+ }
9936
+ recurse(node);
9937
+ }
9938
+ }
9939
+ }
9940
+ };
9941
+ recurse(currentNode);
9788
9942
  }
9789
9943
  };
9790
9944
 
@@ -11123,8 +11277,8 @@ function UpdateOperationFactoryMixin(Base) {
11123
11277
  };
11124
11278
  }
11125
11279
 
11126
- // ../../packages/rules-sparql-1-1/lib/factory.js
11127
- var Factory = class extends asArg(CoreFactory).call(ContextFactoryMixin).call(ExpressionFactoryMixin).call(GraphRefFactoryMixin).call(PathFactoryMixin).call(PatternFactoryMixin).call(QueryFactoryMixin).call(SolutionModifiersFactoryMixin).call(TermFactoryMixin).call(UpdateOperationFactoryMixin).returns() {
11280
+ // ../../packages/rules-sparql-1-1/lib/astFactory.js
11281
+ var AstFactory = class extends asArg(AstCoreFactory).call(ContextFactoryMixin).call(ExpressionFactoryMixin).call(GraphRefFactoryMixin).call(PathFactoryMixin).call(PatternFactoryMixin).call(QueryFactoryMixin).call(SolutionModifiersFactoryMixin).call(TermFactoryMixin).call(UpdateOperationFactoryMixin).returns() {
11128
11282
  alwaysSparql11(obj) {
11129
11283
  return true;
11130
11284
  }
@@ -11221,12 +11375,12 @@ var CommonIRIs;
11221
11375
  CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
11222
11376
  CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
11223
11377
  })(CommonIRIs || (CommonIRIs = {}));
11224
- var TransformerSparql11 = class extends TransformerSubType {
11378
+ var AstTransformer = class extends TransformerSubType {
11225
11379
  };
11226
11380
 
11227
11381
  // ../../packages/rules-sparql-1-1/lib/validation/validators.js
11228
- var F = new Factory();
11229
- var transformer = new TransformerSparql11();
11382
+ var F = new AstFactory();
11383
+ var transformer = new AstTransformer();
11230
11384
  function getAggregatesOfExpression(expression2) {
11231
11385
  if (F.isExpressionAggregate(expression2)) {
11232
11386
  return [expression2];
@@ -11305,77 +11459,69 @@ function queryIsGood(query2) {
11305
11459
  }
11306
11460
  }
11307
11461
  }
11462
+ function notUndefined(some2) {
11463
+ return some2 !== void 0;
11464
+ }
11308
11465
  function findPatternBoundedVars(iter, boundedVars) {
11309
- if (F.isQuery(iter) || F.isUpdate(iter)) {
11310
- if (F.isQuerySelect(iter) || F.isQueryDescribe(iter)) {
11311
- if (iter.where && iter.variables.some((x) => F.isWildcard(x))) {
11312
- findPatternBoundedVars(iter.where, boundedVars);
11313
- } else {
11314
- for (const v of iter.variables) {
11315
- findPatternBoundedVars(v, boundedVars);
11316
- }
11317
- }
11318
- if (iter.solutionModifiers.group) {
11319
- const grouping = iter.solutionModifiers.group;
11320
- for (const g of grouping.groupings) {
11321
- if ("variable" in g) {
11322
- findPatternBoundedVars(g.variable, boundedVars);
11323
- }
11324
- }
11325
- }
11326
- if (iter.values?.values && iter.values.values.length > 0) {
11327
- const values3 = iter.values.values;
11328
- for (const v of Object.keys(values3[0])) {
11466
+ transformer.traverseSubNodes(iter, {
11467
+ query: (op) => ({ next: [
11468
+ op.solutionModifiers.group
11469
+ ].filter(notUndefined) }),
11470
+ triple: (op) => ({ next: [op.subject, op.predicate, op.object] }),
11471
+ path: (op) => ({ next: op.items }),
11472
+ tripleCollection: (op) => ({ next: [op.identifier, ...op.triples] })
11473
+ }, {
11474
+ query: {
11475
+ select: (op) => ({ next: [
11476
+ ...op.variables.some((x) => F.isWildcard(x)) ? [op.where] : op.variables,
11477
+ op.solutionModifiers.group,
11478
+ op.values
11479
+ ].filter(notUndefined) }),
11480
+ describe: (op) => ({ next: [
11481
+ ...op.variables.some((x) => F.isWildcard(x)) ? [op.where] : op.variables,
11482
+ op.solutionModifiers.group,
11483
+ op.values
11484
+ ].filter(notUndefined) })
11485
+ },
11486
+ solutionModifier: {
11487
+ group: (op) => ({
11488
+ next: op.groupings.filter((g) => "variable" in g).map((x) => x.variable)
11489
+ }),
11490
+ having: (op) => ({ next: op.having }),
11491
+ order: (op) => ({ next: op.orderDefs.map((x) => x.expression) })
11492
+ },
11493
+ pattern: {
11494
+ values: (op) => {
11495
+ for (const v of Object.keys(op.values.at(0) ?? {})) {
11329
11496
  boundedVars.add(v);
11330
11497
  }
11498
+ return {};
11499
+ },
11500
+ bgp: (op) => ({ next: op.triples }),
11501
+ group: (op) => ({ next: op.patterns }),
11502
+ union: (op) => ({ next: op.patterns }),
11503
+ optional: (op) => ({ next: op.patterns }),
11504
+ service: (op) => ({ next: [op.name, ...op.patterns] }),
11505
+ bind: (op) => ({ next: [op.variable] }),
11506
+ graph: (op) => ({ next: [op.name, ...op.patterns] }),
11507
+ minus: (op) => ({ next: op.patterns.slice(0, 1) })
11508
+ },
11509
+ term: {
11510
+ variable: (op) => {
11511
+ boundedVars.add(op.value);
11512
+ return {};
11331
11513
  }
11332
11514
  }
11333
- } else if (F.isTerm(iter)) {
11334
- if (F.isTermVariable(iter)) {
11335
- boundedVars.add(iter.value);
11336
- }
11337
- } else if (F.isTriple(iter)) {
11338
- findPatternBoundedVars(iter.subject, boundedVars);
11339
- findPatternBoundedVars(iter.predicate, boundedVars);
11340
- findPatternBoundedVars(iter.object, boundedVars);
11341
- } else if (F.isPath(iter)) {
11342
- if (!F.isTerm(iter)) {
11343
- for (const item of iter.items) {
11344
- findPatternBoundedVars(item, boundedVars);
11345
- }
11346
- }
11347
- } else if (F.isTripleCollection(iter) || F.isPatternBgp(iter)) {
11348
- for (const triple of iter.triples) {
11349
- findPatternBoundedVars(triple, boundedVars);
11350
- }
11351
- } else if (F.isPatternGroup(iter) || F.isPatternUnion(iter) || F.isPatternOptional(iter) || F.isPatternService(iter)) {
11352
- for (const pattern of iter.patterns) {
11353
- findPatternBoundedVars(pattern, boundedVars);
11354
- }
11355
- if (F.isPatternService(iter)) {
11356
- findPatternBoundedVars(iter.name, boundedVars);
11357
- }
11358
- } else if (F.isPatternBind(iter)) {
11359
- findPatternBoundedVars(iter.variable, boundedVars);
11360
- } else if (F.isPatternValues(iter)) {
11361
- for (const variable of Object.keys(iter.values.at(0) ?? {})) {
11362
- boundedVars.add(variable);
11363
- }
11364
- } else if (F.isPatternGraph(iter)) {
11365
- findPatternBoundedVars(iter.name, boundedVars);
11366
- for (const pattern of iter.patterns) {
11367
- findPatternBoundedVars(pattern, boundedVars);
11368
- }
11369
- }
11515
+ });
11370
11516
  }
11371
11517
  function checkNote13(patterns) {
11372
11518
  for (const [index, pattern] of patterns.entries()) {
11373
11519
  if (F.isPatternBind(pattern) && index > 0 && F.isPatternBgp(patterns[index - 1])) {
11374
11520
  const bgp = patterns[index - 1];
11375
11521
  const variables = [];
11376
- transformer.visitNodeSpecific(bgp, {}, { term: { variable: (var_2) => {
11522
+ transformer.visitNodeSpecific(bgp, {}, { term: { variable: { visitor: (var_2) => {
11377
11523
  variables.push(var_2);
11378
- } } });
11524
+ } } } });
11379
11525
  if (variables.some((var_2) => var_2.value === pattern.variable.value)) {
11380
11526
  throw new Error(`Variable used to bind is already bound (?${pattern.variable.value})`);
11381
11527
  }
@@ -11401,12 +11547,12 @@ function updateNoReuseBlankNodeLabels(updateQuery) {
11401
11547
  const operation = update2.operation;
11402
11548
  if (operation.subType === "insertdata") {
11403
11549
  const blankNodesHere = /* @__PURE__ */ new Set();
11404
- transformer.visitNodeSpecific(operation, {}, { term: { blankNode: (blankNode2) => {
11550
+ transformer.visitNodeSpecific(operation, {}, { term: { blankNode: { visitor: (blankNode2) => {
11405
11551
  blankNodesHere.add(blankNode2.label);
11406
11552
  if (blankLabelsUsedInInsertData.has(blankNode2.label)) {
11407
11553
  throw new Error("Detected reuse blank node across different INSERT DATA clauses");
11408
11554
  }
11409
- } } });
11555
+ } } } });
11410
11556
  for (const blankNode2 of blankNodesHere) {
11411
11557
  blankLabelsUsedInInsertData.add(blankNode2);
11412
11558
  }
@@ -11445,22 +11591,22 @@ var rdfLiteral = {
11445
11591
  return OPTION(() => OR([
11446
11592
  { ALT: () => {
11447
11593
  const lang2 = CONSUME(terminals_exports.langTag);
11448
- return ACTION(() => C.factory.literalTerm(C.factory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
11594
+ return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
11449
11595
  } },
11450
11596
  { ALT: () => {
11451
11597
  CONSUME(symbols_exports.hathat);
11452
11598
  const iriVal = SUBRULE1(iri2);
11453
- return ACTION(() => C.factory.literalTerm(C.factory.sourceLocation(value, iriVal), value.value, iriVal));
11599
+ return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
11454
11600
  } }
11455
11601
  ])) ?? value;
11456
11602
  },
11457
- gImpl: ({ SUBRULE, PRINT, PRINT_SPACE_LEFT }) => (ast, { factory }) => {
11458
- factory.printFilter(ast, () => PRINT_SPACE_LEFT(stringEscapedLexical(ast.value)));
11603
+ gImpl: ({ SUBRULE, PRINT, PRINT_SPACE_LEFT }) => (ast, { astFactory }) => {
11604
+ astFactory.printFilter(ast, () => PRINT_SPACE_LEFT(stringEscapedLexical(ast.value)));
11459
11605
  if (ast.langOrIri) {
11460
11606
  if (typeof ast.langOrIri === "string") {
11461
- factory.printFilter(ast, () => PRINT("@", ast.langOrIri));
11607
+ astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
11462
11608
  } else {
11463
- factory.printFilter(ast, () => PRINT("^^"));
11609
+ astFactory.printFilter(ast, () => PRINT("^^"));
11464
11610
  SUBRULE(iri2, ast.langOrIri);
11465
11611
  }
11466
11612
  }
@@ -11482,7 +11628,7 @@ var numericLiteralUnsigned = {
11482
11628
  { ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
11483
11629
  { ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
11484
11630
  ]);
11485
- return ACTION(() => C.factory.literalTerm(C.factory.sourceLocation(parsed[0]), parsed[0].image, C.factory.namedNode(C.factory.sourceLocationNoMaterialize(), parsed[1])));
11631
+ return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11486
11632
  }
11487
11633
  };
11488
11634
  var numericLiteralPositive = {
@@ -11493,7 +11639,7 @@ var numericLiteralPositive = {
11493
11639
  { ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
11494
11640
  { ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
11495
11641
  ]);
11496
- return ACTION(() => C.factory.literalTerm(C.factory.sourceLocation(parsed[0]), parsed[0].image, C.factory.namedNode(C.factory.sourceLocationNoMaterialize(), parsed[1])));
11642
+ return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11497
11643
  }
11498
11644
  };
11499
11645
  var numericLiteralNegative = {
@@ -11504,7 +11650,7 @@ var numericLiteralNegative = {
11504
11650
  { ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
11505
11651
  { ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
11506
11652
  ]);
11507
- return ACTION(() => C.factory.literalTerm(C.factory.sourceLocation(parsed[0]), parsed[0].image, C.factory.namedNode(C.factory.sourceLocationNoMaterialize(), parsed[1])));
11653
+ return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11508
11654
  }
11509
11655
  };
11510
11656
  var booleanLiteral = {
@@ -11514,7 +11660,7 @@ var booleanLiteral = {
11514
11660
  { ALT: () => CONSUME(true_) },
11515
11661
  { ALT: () => CONSUME(false_) }
11516
11662
  ]);
11517
- return ACTION(() => C.factory.literalTerm(C.factory.sourceLocation(token), token.image.toLowerCase(), C.factory.namedNode(C.factory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
11663
+ return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
11518
11664
  }
11519
11665
  };
11520
11666
  var string = {
@@ -11539,7 +11685,7 @@ var string = {
11539
11685
  } }
11540
11686
  ]);
11541
11687
  return ACTION(() => {
11542
- const F2 = C.factory;
11688
+ const F2 = C.astFactory;
11543
11689
  const value = x[1].replaceAll(/\\([tnrbf"'\\])/gu, (_, char) => {
11544
11690
  switch (char) {
11545
11691
  case "t":
@@ -11566,16 +11712,16 @@ var iri2 = {
11566
11712
  { ALT: () => SUBRULE(iriFull) },
11567
11713
  { ALT: () => SUBRULE(prefixedName) }
11568
11714
  ]),
11569
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast) : SUBRULE(iriFull, ast)
11715
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast) : SUBRULE(iriFull, ast)
11570
11716
  };
11571
11717
  var iriFull = {
11572
11718
  name: "iriFull",
11573
11719
  impl: ({ ACTION, CONSUME }) => (C) => {
11574
11720
  const iriToken = CONSUME(terminals_exports.iriRef);
11575
- return ACTION(() => C.factory.namedNode(C.factory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
11721
+ return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
11576
11722
  },
11577
- gImpl: ({ PRINT }) => (ast, { factory }) => {
11578
- factory.printFilter(ast, () => PRINT("<", ast.value, ">"));
11723
+ gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
11724
+ F2.printFilter(ast, () => PRINT("<", ast.value, ">"));
11579
11725
  }
11580
11726
  };
11581
11727
  var prefixedName = {
@@ -11585,16 +11731,16 @@ var prefixedName = {
11585
11731
  const longName = CONSUME(terminals_exports.pNameLn);
11586
11732
  return ACTION(() => {
11587
11733
  const [prefix, localName] = longName.image.split(":");
11588
- return C.factory.namedNode(C.factory.sourceLocation(longName), localName, prefix);
11734
+ return C.astFactory.namedNode(C.astFactory.sourceLocation(longName), localName, prefix);
11589
11735
  });
11590
11736
  } },
11591
11737
  { ALT: () => {
11592
11738
  const shortName = CONSUME(terminals_exports.pNameNs);
11593
- return ACTION(() => C.factory.namedNode(C.factory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
11739
+ return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
11594
11740
  } }
11595
11741
  ]),
11596
- gImpl: ({ PRINT_WORD }) => (ast, { factory }) => {
11597
- factory.printFilter(ast, () => PRINT_WORD(ast.prefix, ":", ast.value));
11742
+ gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F2 }) => {
11743
+ F2.printFilter(ast, () => PRINT_WORD(ast.prefix, ":", ast.value));
11598
11744
  }
11599
11745
  };
11600
11746
  var canCreateBlankNodes = Symbol("canCreateBlankNodes");
@@ -11604,11 +11750,11 @@ var blankNode = {
11604
11750
  const result = OR([
11605
11751
  { ALT: () => {
11606
11752
  const labelToken = CONSUME(terminals_exports.blankNodeLabel);
11607
- return ACTION(() => C.factory.blankNode(labelToken.image.slice(2), C.factory.sourceLocation(labelToken)));
11753
+ return ACTION(() => C.astFactory.blankNode(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
11608
11754
  } },
11609
11755
  { ALT: () => {
11610
11756
  const anonToken = CONSUME(terminals_exports.anon);
11611
- return ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocation(anonToken)));
11757
+ return ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocation(anonToken)));
11612
11758
  } }
11613
11759
  ]);
11614
11760
  ACTION(() => {
@@ -11618,15 +11764,15 @@ var blankNode = {
11618
11764
  });
11619
11765
  return result;
11620
11766
  },
11621
- gImpl: ({ PRINT_WORD }) => (ast, { factory }) => {
11622
- factory.printFilter(ast, () => PRINT_WORD("_:", ast.label.replace(/^e_/u, "")));
11767
+ gImpl: ({ PRINT_WORD }) => (ast, { astFactory }) => {
11768
+ astFactory.printFilter(ast, () => PRINT_WORD("_:", ast.label.replace(/^e_/u, "")));
11623
11769
  }
11624
11770
  };
11625
11771
  var verbA = {
11626
11772
  name: "VerbA",
11627
11773
  impl: ({ ACTION, CONSUME }) => (C) => {
11628
11774
  const token = CONSUME(a);
11629
- return ACTION(() => C.factory.namedNode(C.factory.sourceLocation(token), CommonIRIs.TYPE, void 0));
11775
+ return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
11630
11776
  }
11631
11777
  };
11632
11778
 
@@ -11643,7 +11789,7 @@ var prologue = {
11643
11789
  ]));
11644
11790
  return result;
11645
11791
  },
11646
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11792
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
11647
11793
  for (const context of ast) {
11648
11794
  if (F2.isContextDefinitionBase(context)) {
11649
11795
  SUBRULE(baseDecl2, context);
@@ -11658,11 +11804,12 @@ var baseDecl2 = {
11658
11804
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11659
11805
  const base = CONSUME(baseDecl);
11660
11806
  const val = SUBRULE(iriFull);
11661
- return ACTION(() => C.factory.contextDefinitionBase(C.factory.sourceLocation(base, val), val));
11807
+ return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
11662
11808
  },
11663
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11809
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
11664
11810
  F2.printFilter(ast, () => PRINT_WORD("BASE"));
11665
11811
  SUBRULE(iri2, ast.value);
11812
+ F2.printFilter(ast, () => PRINT_WORD("\n"));
11666
11813
  }
11667
11814
  };
11668
11815
  var prefixDecl2 = {
@@ -11671,13 +11818,14 @@ var prefixDecl2 = {
11671
11818
  const prefix = CONSUME(prefixDecl);
11672
11819
  const name = CONSUME(terminals_exports.pNameNs).image.slice(0, -1);
11673
11820
  const value = SUBRULE(iriFull);
11674
- return ACTION(() => C.factory.contextDefinitionPrefix(C.factory.sourceLocation(prefix, value), name, value));
11821
+ return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
11675
11822
  },
11676
- gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { factory: F2 }) => {
11823
+ gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { astFactory: F2 }) => {
11677
11824
  F2.printFilter(ast, () => {
11678
11825
  PRINT_WORDS("PREFIX", `${ast.key}:`);
11679
11826
  });
11680
11827
  SUBRULE(iri2, ast.value);
11828
+ F2.printFilter(ast, () => PRINT_WORDS("\n"));
11681
11829
  }
11682
11830
  };
11683
11831
  var verb = {
@@ -11693,7 +11841,7 @@ var varOrTerm = {
11693
11841
  { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
11694
11842
  { ALT: () => SUBRULE(graphTerm) }
11695
11843
  ]),
11696
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11844
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
11697
11845
  if (F2.isTermVariable(ast)) {
11698
11846
  return SUBRULE(var_, ast);
11699
11847
  }
@@ -11714,9 +11862,9 @@ var var_ = {
11714
11862
  { ALT: () => CONSUME(terminals_exports.var1) },
11715
11863
  { ALT: () => CONSUME(terminals_exports.var2) }
11716
11864
  ]);
11717
- return ACTION(() => C.factory.variable(varToken.image.slice(1), C.factory.sourceLocation(varToken)));
11865
+ return ACTION(() => C.astFactory.variable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
11718
11866
  },
11719
- gImpl: ({ PRINT_WORD }) => (ast, { factory: F2 }) => {
11867
+ gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F2 }) => {
11720
11868
  F2.printFilter(ast, () => PRINT_WORD(`?${ast.value}`));
11721
11869
  }
11722
11870
  };
@@ -11730,10 +11878,10 @@ var graphTerm = {
11730
11878
  { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
11731
11879
  { ALT: () => {
11732
11880
  const tokenNil = CONSUME(terminals_exports.nil);
11733
- return ACTION(() => C.factory.namedNode(C.factory.sourceLocation(tokenNil), CommonIRIs.NIL));
11881
+ return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
11734
11882
  } }
11735
11883
  ]),
11736
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
11884
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
11737
11885
  if (F2.isTermNamed(ast)) {
11738
11886
  SUBRULE(iri2, ast);
11739
11887
  } else if (F2.isTermLiteral(ast)) {
@@ -11753,14 +11901,14 @@ function datasetClauseUsing(name, token) {
11753
11901
  return OR([
11754
11902
  { ALT: () => {
11755
11903
  const iri3 = SUBRULE(defaultGraphClause);
11756
- return ACTION(() => C.factory.wrap({ clauseType: "default", value: iri3 }, C.factory.sourceLocation(start, iri3)));
11904
+ return ACTION(() => C.astFactory.wrap({ clauseType: "default", value: iri3 }, C.astFactory.sourceLocation(start, iri3)));
11757
11905
  } },
11758
11906
  { ALT: () => {
11759
11907
  const namedClause = SUBRULE(namedGraphClause);
11760
- return ACTION(() => C.factory.wrap({
11908
+ return ACTION(() => C.astFactory.wrap({
11761
11909
  clauseType: "named",
11762
11910
  value: namedClause.val
11763
- }, C.factory.sourceLocation(start, namedClause)));
11911
+ }, C.astFactory.sourceLocation(start, namedClause)));
11764
11912
  } }
11765
11913
  ]);
11766
11914
  }
@@ -11781,9 +11929,9 @@ function datasetClauseUsingStar(name, subRule, fromUsing) {
11781
11929
  const clause = SUBRULE(subRule);
11782
11930
  clauses.push(clause);
11783
11931
  });
11784
- return ACTION(() => C.factory.datasetClauses(clauses.map((clause) => clause.val), C.factory.sourceLocation(...clauses)));
11932
+ return ACTION(() => C.astFactory.datasetClauses(clauses.map((clause) => clause.val), C.astFactory.sourceLocation(...clauses)));
11785
11933
  },
11786
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
11934
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
11787
11935
  for (const clause of ast.clauses) {
11788
11936
  F2.printFilter(ast, () => PRINT_WORD(fromUsing));
11789
11937
  if (clause.clauseType === "named") {
@@ -11801,7 +11949,7 @@ var namedGraphClause = {
11801
11949
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11802
11950
  const named2 = CONSUME(graph_exports.named);
11803
11951
  const iri3 = SUBRULE(sourceSelector);
11804
- return ACTION(() => C.factory.wrap(iri3, C.factory.sourceLocation(named2, iri3)));
11952
+ return ACTION(() => C.astFactory.wrap(iri3, C.astFactory.sourceLocation(named2, iri3)));
11805
11953
  }
11806
11954
  };
11807
11955
  var sourceSelector = {
@@ -11818,7 +11966,7 @@ function funcExpr1(func) {
11818
11966
  CONSUME(symbols_exports.LParen);
11819
11967
  const arg = SUBRULE(expression);
11820
11968
  const close = CONSUME(symbols_exports.RParen);
11821
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
11969
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
11822
11970
  }
11823
11971
  };
11824
11972
  }
@@ -11832,7 +11980,7 @@ function funcExpr2(func) {
11832
11980
  CONSUME(symbols_exports.comma);
11833
11981
  const arg2 = SUBRULE2(expression);
11834
11982
  const close = CONSUME(symbols_exports.RParen);
11835
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2], C.factory.sourceLocation(operator, close)));
11983
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg1, arg2], C.astFactory.sourceLocation(operator, close)));
11836
11984
  }
11837
11985
  };
11838
11986
  }
@@ -11848,7 +11996,7 @@ function funcExpr3(func) {
11848
11996
  CONSUME2(symbols_exports.comma);
11849
11997
  const arg3 = SUBRULE3(expression);
11850
11998
  const close = CONSUME(symbols_exports.RParen);
11851
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
11999
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg1, arg2, arg3], C.astFactory.sourceLocation(operator, close)));
11852
12000
  }
11853
12001
  };
11854
12002
  }
@@ -11860,7 +12008,7 @@ function funcVar1(func) {
11860
12008
  CONSUME(symbols_exports.LParen);
11861
12009
  const arg = SUBRULE(var_);
11862
12010
  const close = CONSUME(symbols_exports.RParen);
11863
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12011
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
11864
12012
  }
11865
12013
  };
11866
12014
  }
@@ -11874,11 +12022,11 @@ function funcExprOrNil1(func) {
11874
12022
  CONSUME(symbols_exports.LParen);
11875
12023
  const arg = SUBRULE(expression);
11876
12024
  const close = CONSUME(symbols_exports.RParen);
11877
- return ACTION(() => C.factory.expressionOperation(operator.image, [arg], C.factory.sourceLocation(operator, close)));
12025
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
11878
12026
  } },
11879
12027
  { ALT: () => {
11880
12028
  const nil2 = CONSUME(terminals_exports.nil);
11881
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12029
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil2)));
11882
12030
  } }
11883
12031
  ]);
11884
12032
  }
@@ -11890,7 +12038,7 @@ function funcNil1(func) {
11890
12038
  impl: ({ ACTION, CONSUME }) => (C) => {
11891
12039
  const operator = CONSUME(func);
11892
12040
  const nil2 = CONSUME(terminals_exports.nil);
11893
- return ACTION(() => C.factory.expressionOperation(operator.image, [], C.factory.sourceLocation(operator, nil2)));
12041
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil2)));
11894
12042
  }
11895
12043
  };
11896
12044
  }
@@ -11900,7 +12048,7 @@ function funcExprList1(func) {
11900
12048
  impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
11901
12049
  const operator = CONSUME(func);
11902
12050
  const args = SUBRULE(expressionList);
11903
- return ACTION(() => C.factory.expressionOperation(operator.image, args.val, C.factory.sourceLocation(operator, args)));
12051
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, args.val, C.astFactory.sourceLocation(operator, args)));
11904
12052
  }
11905
12053
  };
11906
12054
  }
@@ -11918,7 +12066,7 @@ function funcExpr2or3(func) {
11918
12066
  return SUBRULE3(expression);
11919
12067
  });
11920
12068
  const close = CONSUME(symbols_exports.RParen);
11921
- return ACTION(() => C.factory.expressionOperation(operator.image, arg3 ? [arg1, arg2, arg3] : [arg1, arg2], C.factory.sourceLocation(operator, close)));
12069
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, arg3 ? [arg1, arg2, arg3] : [arg1, arg2], C.astFactory.sourceLocation(operator, close)));
11922
12070
  }
11923
12071
  };
11924
12072
  }
@@ -11938,7 +12086,7 @@ function funcExpr3or4(func) {
11938
12086
  return SUBRULE4(expression);
11939
12087
  });
11940
12088
  const close = CONSUME(symbols_exports.RParen);
11941
- return ACTION(() => C.factory.expressionOperation(operator.image, arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3], C.factory.sourceLocation(operator, close)));
12089
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3], C.astFactory.sourceLocation(operator, close)));
11942
12090
  }
11943
12091
  };
11944
12092
  }
@@ -11948,7 +12096,7 @@ function funcGroupGraphPattern(func) {
11948
12096
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
11949
12097
  const operator = CONSUME(func);
11950
12098
  const group = SUBRULE(groupGraphPattern);
11951
- return ACTION(() => C.factory.expressionPatternOperation(operator.image, group, C.factory.sourceLocation(operator, group)));
12099
+ return ACTION(() => C.astFactory.expressionPatternOperation(operator.image, group, C.astFactory.sourceLocation(operator, group)));
11952
12100
  }
11953
12101
  };
11954
12102
  }
@@ -11961,7 +12109,7 @@ function baseAggregateFunc(func) {
11961
12109
  const distinct2 = OPTION(() => CONSUME(distinct));
11962
12110
  const expr1 = SUBRULE(expression);
11963
12111
  const close = CONSUME(symbols_exports.RParen);
11964
- return ACTION(() => C.factory.aggregate(operator.image, distinct2 !== void 0, expr1, void 0, C.factory.sourceLocation(operator, close)));
12112
+ return ACTION(() => C.astFactory.aggregate(operator.image, distinct2 !== void 0, expr1, void 0, C.astFactory.sourceLocation(operator, close)));
11965
12113
  }
11966
12114
  };
11967
12115
  }
@@ -12101,17 +12249,17 @@ var aggregateCount = {
12101
12249
  const expressionVal = OR([
12102
12250
  { ALT: () => {
12103
12251
  const starToken = CONSUME(symbols_exports.star);
12104
- return ACTION(() => C.factory.wildcard(C.factory.sourceLocation(starToken)));
12252
+ return ACTION(() => C.astFactory.wildcard(C.astFactory.sourceLocation(starToken)));
12105
12253
  } },
12106
12254
  { ALT: () => SUBRULE(expression) }
12107
12255
  ]);
12108
12256
  const closeToken = CONSUME(symbols_exports.RParen);
12109
12257
  return ACTION(() => {
12110
- const F2 = C.factory;
12111
- if (C.factory.isWildcard(expressionVal)) {
12112
- return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.factory.sourceLocation(operatorToken, closeToken));
12258
+ const F2 = C.astFactory;
12259
+ if (C.astFactory.isWildcard(expressionVal)) {
12260
+ return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.astFactory.sourceLocation(operatorToken, closeToken));
12113
12261
  }
12114
- return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.factory.sourceLocation(operatorToken, closeToken));
12262
+ return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.astFactory.sourceLocation(operatorToken, closeToken));
12115
12263
  });
12116
12264
  }
12117
12265
  };
@@ -12135,7 +12283,7 @@ var aggregateGroup_concat = {
12135
12283
  });
12136
12284
  const closeToken = CONSUME(symbols_exports.RParen);
12137
12285
  return ACTION(() => {
12138
- const F2 = C.factory;
12286
+ const F2 = C.astFactory;
12139
12287
  return F2.aggregate(operatorToken.image, Boolean(distinctToken), expr, sep?.value ?? " ", F2.sourceLocation(operatorToken, closeToken));
12140
12288
  });
12141
12289
  }
@@ -12165,7 +12313,7 @@ var aggregate = {
12165
12313
  });
12166
12314
  return result;
12167
12315
  },
12168
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12316
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12169
12317
  F2.printFilter(ast, () => {
12170
12318
  PRINT_WORD(ast.aggregation.toUpperCase(), "(");
12171
12319
  if (ast.distinct) {
@@ -12192,7 +12340,7 @@ var path = {
12192
12340
  };
12193
12341
  var pathGenerator = {
12194
12342
  name: "path",
12195
- gImpl: ({ PRINT, SUBRULE }) => (ast, { factory: F2 }, braces = true) => {
12343
+ gImpl: ({ PRINT, SUBRULE }) => (ast, { astFactory: F2 }, braces = true) => {
12196
12344
  if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
12197
12345
  SUBRULE(iri2, ast);
12198
12346
  } else {
@@ -12241,7 +12389,7 @@ function pathChainHelper(name, SEP, subType, subRule) {
12241
12389
  tailEnd = SUBRULE2(subRule);
12242
12390
  tail.push(tailEnd);
12243
12391
  });
12244
- return ACTION(() => tail.length === 0 ? head2 : C.factory.path(subType, [head2, ...tail], C.factory.sourceLocation(head2, tailEnd)));
12392
+ return ACTION(() => tail.length === 0 ? head2 : C.astFactory.path(subType, [head2, ...tail], C.astFactory.sourceLocation(head2, tailEnd)));
12245
12393
  }
12246
12394
  };
12247
12395
  }
@@ -12252,7 +12400,7 @@ var pathEltOrInverse = {
12252
12400
  { ALT: () => {
12253
12401
  const hat2 = CONSUME(symbols_exports.hat);
12254
12402
  const item = SUBRULE2(pathElt);
12255
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12403
+ return ACTION(() => C.astFactory.path("^", [item], C.astFactory.sourceLocation(hat2, item)));
12256
12404
  } }
12257
12405
  ])
12258
12406
  };
@@ -12263,7 +12411,7 @@ var pathElt = {
12263
12411
  impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
12264
12412
  const item = SUBRULE(pathPrimary);
12265
12413
  const modification = OPTION(() => SUBRULE(pathMod));
12266
- return ACTION(() => modification === void 0 ? item : C.factory.path(modification.image, [item], C.factory.sourceLocation(item, modification)));
12414
+ return ACTION(() => modification === void 0 ? item : C.astFactory.path(modification.image, [item], C.astFactory.sourceLocation(item, modification)));
12267
12415
  }
12268
12416
  };
12269
12417
  var pathMod = {
@@ -12295,7 +12443,7 @@ var pathNegatedPropertySet = {
12295
12443
  return OR([
12296
12444
  { ALT: () => {
12297
12445
  const noAlternative = SUBRULE1(pathOneInPropertySet);
12298
- return ACTION(() => C.factory.path("!", [noAlternative], C.factory.sourceLocation(exclamation2, noAlternative)));
12446
+ return ACTION(() => C.astFactory.path("!", [noAlternative], C.astFactory.sourceLocation(exclamation2, noAlternative)));
12299
12447
  } },
12300
12448
  { ALT: () => {
12301
12449
  const open = CONSUME(symbols_exports.LParen);
@@ -12308,7 +12456,7 @@ var pathNegatedPropertySet = {
12308
12456
  });
12309
12457
  const close = CONSUME(symbols_exports.RParen);
12310
12458
  return ACTION(() => {
12311
- const F2 = C.factory;
12459
+ const F2 = C.astFactory;
12312
12460
  if (tail.length === 0) {
12313
12461
  return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
12314
12462
  }
@@ -12329,7 +12477,7 @@ var pathOneInPropertySet = {
12329
12477
  { ALT: () => SUBRULE2(iri2) },
12330
12478
  { ALT: () => SUBRULE2(verbA) }
12331
12479
  ]);
12332
- return ACTION(() => C.factory.path("^", [item], C.factory.sourceLocation(hat2, item)));
12480
+ return ACTION(() => C.astFactory.path("^", [item], C.astFactory.sourceLocation(hat2, item)));
12333
12481
  } }
12334
12482
  ])
12335
12483
  };
@@ -12354,33 +12502,35 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
12354
12502
  });
12355
12503
  }
12356
12504
  });
12357
- return ACTION(() => C.factory.patternBgp(triples, C.factory.sourceLocation(...triples, dotToken)));
12505
+ return ACTION(() => C.astFactory.patternBgp(triples, C.astFactory.sourceLocation(...triples, dotToken)));
12358
12506
  };
12359
12507
  }
12360
12508
  var triplesBlock = {
12361
12509
  name: "triplesBlock",
12362
12510
  impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
12363
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12511
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F2 }) => {
12364
12512
  for (const [index, triple] of ast.triples.entries()) {
12365
12513
  HANDLE_LOC(triple, () => {
12366
12514
  const nextTriple = ast.triples.at(index);
12367
12515
  if (F2.isTripleCollection(triple)) {
12368
12516
  SUBRULE(graphNodePath, triple);
12369
- F2.printFilter(triple, () => PRINT_WORD("."));
12517
+ F2.printFilter(triple, () => PRINT_WORD(".\n"));
12370
12518
  } else {
12371
12519
  SUBRULE(graphNodePath, triple.subject);
12520
+ F2.printFilter(triple, () => PRINT_WORD(""));
12372
12521
  if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
12373
12522
  SUBRULE(varOrTerm, triple.predicate);
12374
12523
  } else {
12375
12524
  SUBRULE(pathGenerator, triple.predicate, void 0);
12376
12525
  }
12526
+ F2.printFilter(triple, () => PRINT_WORD(""));
12377
12527
  SUBRULE(graphNodePath, triple.object);
12378
12528
  if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12379
- F2.printFilter(ast, () => PRINT_WORD("."));
12529
+ F2.printFilter(ast, () => PRINT_WORD(".\n"));
12380
12530
  } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12381
12531
  F2.printFilter(ast, () => PRINT_WORD(","));
12382
12532
  } else {
12383
- F2.printFilter(ast, () => PRINT_WORD(";"));
12533
+ F2.printFilter(ast, () => PRINT_WORD(";\n"));
12384
12534
  }
12385
12535
  }
12386
12536
  });
@@ -12393,24 +12543,24 @@ function triplesSameSubjectImpl(name, allowPaths) {
12393
12543
  impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
12394
12544
  { ALT: () => {
12395
12545
  const subject = SUBRULE(varOrTerm);
12396
- const res = SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, ACTION(() => C.factory.dematerialized(subject)));
12546
+ const res = SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, ACTION(() => C.astFactory.dematerialized(subject)));
12397
12547
  return ACTION(() => {
12398
12548
  if (res.length > 0) {
12399
12549
  res[0].subject = subject;
12400
- res[0].loc = C.factory.sourceLocation(subject, res[0]);
12550
+ res[0].loc = C.astFactory.sourceLocation(subject, res[0]);
12401
12551
  }
12402
12552
  return res;
12403
12553
  });
12404
12554
  } },
12405
12555
  { ALT: () => {
12406
12556
  const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode);
12407
- const restNode = SUBRULE(allowPaths ? propertyListPath : propertyList, ACTION(() => C.factory.graphNodeIdentifier(subjectNode)));
12557
+ const restNode = SUBRULE(allowPaths ? propertyListPath : propertyList, ACTION(() => C.astFactory.graphNodeIdentifier(subjectNode)));
12408
12558
  return ACTION(() => {
12409
12559
  if (restNode.length === 0) {
12410
12560
  return [subjectNode];
12411
12561
  }
12412
12562
  restNode[0].subject = subjectNode;
12413
- restNode[0].loc = C.factory.sourceLocation(subjectNode, restNode[0]);
12563
+ restNode[0].loc = C.astFactory.sourceLocation(subjectNode, restNode[0]);
12414
12564
  return restNode;
12415
12565
  });
12416
12566
  } }
@@ -12494,7 +12644,7 @@ function objectImpl(name, allowPaths) {
12494
12644
  name,
12495
12645
  impl: ({ ACTION, SUBRULE }) => (C, subject, predicate) => {
12496
12646
  const node = SUBRULE(allowPaths ? graphNodePath : graphNode);
12497
- return ACTION(() => C.factory.triple(subject, predicate, node));
12647
+ return ACTION(() => C.astFactory.triple(subject, predicate, node));
12498
12648
  }
12499
12649
  };
12500
12650
  }
@@ -12511,7 +12661,7 @@ function collectionImpl(name, allowPaths) {
12511
12661
  });
12512
12662
  const endToken = CONSUME(symbols_exports.RParen);
12513
12663
  return ACTION(() => {
12514
- const F2 = C.factory;
12664
+ const F2 = C.astFactory;
12515
12665
  const triples = [];
12516
12666
  const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
12517
12667
  const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
@@ -12535,7 +12685,7 @@ function collectionImpl(name, allowPaths) {
12535
12685
  return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
12536
12686
  });
12537
12687
  },
12538
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12688
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12539
12689
  F2.printFilter(ast, () => PRINT_WORD("("));
12540
12690
  for (const [idx, triple] of ast.triples.entries()) {
12541
12691
  if (idx % 2 === 0) {
@@ -12566,13 +12716,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
12566
12716
  name,
12567
12717
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12568
12718
  const startToken = CONSUME(symbols_exports.LSquare);
12569
- const blankNode2 = ACTION(() => C.factory.blankNode(void 0, C.factory.sourceLocationNoMaterialize()));
12719
+ const blankNode2 = ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocationNoMaterialize()));
12570
12720
  const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
12571
12721
  const endToken = CONSUME(symbols_exports.RSquare);
12572
- return ACTION(() => C.factory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.factory.sourceLocation(startToken, endToken)));
12722
+ return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
12573
12723
  },
12574
- gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast, { factory: F2 }) => {
12575
- F2.printFilter(ast, () => PRINT("["));
12724
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
12725
+ const { astFactory: F2, indentInc } = c;
12726
+ F2.printFilter(ast, () => {
12727
+ c[traqulaIndentation] += indentInc;
12728
+ PRINT("[\n");
12729
+ });
12576
12730
  for (const triple of ast.triples) {
12577
12731
  HANDLE_LOC(triple, () => {
12578
12732
  if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
@@ -12580,11 +12734,15 @@ function blankNodePropertyListImpl(name, allowPaths) {
12580
12734
  } else {
12581
12735
  SUBRULE(pathGenerator, triple.predicate, void 0);
12582
12736
  }
12737
+ F2.printFilter(triple, () => PRINT_WORD(""));
12583
12738
  SUBRULE(graphNodePath, triple.object);
12584
- F2.printFilter(ast, () => PRINT_WORD(";"));
12739
+ F2.printFilter(ast, () => PRINT_WORD(";\n"));
12585
12740
  });
12586
12741
  }
12587
- F2.printFilter(ast, () => PRINT("]"));
12742
+ F2.printFilter(ast, () => {
12743
+ c[traqulaIndentation] -= indentInc;
12744
+ PRINT_ON_EMPTY("]");
12745
+ });
12588
12746
  }
12589
12747
  };
12590
12748
  }
@@ -12601,7 +12759,7 @@ function graphNodeImpl(name, allowPaths) {
12601
12759
  ALT: () => SUBRULE(triplesNodeRule)
12602
12760
  }
12603
12761
  ]),
12604
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12762
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
12605
12763
  if (F2.isTerm(ast)) {
12606
12764
  SUBRULE(varOrTerm, ast);
12607
12765
  } else {
@@ -12619,9 +12777,9 @@ var whereClause = {
12619
12777
  impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
12620
12778
  const where2 = OPTION(() => CONSUME(where));
12621
12779
  const group = SUBRULE(groupGraphPattern);
12622
- return ACTION(() => C.factory.wrap(group, C.factory.sourceLocation(where2, group)));
12780
+ return ACTION(() => C.astFactory.wrap(group, C.astFactory.sourceLocation(where2, group)));
12623
12781
  },
12624
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12782
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12625
12783
  F2.printFilter(ast, () => PRINT_WORD("WHERE"));
12626
12784
  SUBRULE(groupGraphPattern, ast.val);
12627
12785
  }
@@ -12635,19 +12793,26 @@ var groupGraphPattern = {
12635
12793
  { ALT: () => SUBRULE(groupGraphPatternSub) }
12636
12794
  ]);
12637
12795
  const close = CONSUME(symbols_exports.RCurly);
12638
- return ACTION(() => C.factory.patternGroup(patterns, C.factory.sourceLocation(open, close)));
12796
+ return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
12639
12797
  },
12640
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12641
- F2.printFilter(ast, () => PRINT_WORD("{"));
12798
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
12799
+ const { astFactory: F2, indentInc } = C;
12800
+ F2.printFilter(ast, () => {
12801
+ C[traqulaIndentation] += indentInc;
12802
+ PRINT_WORD("{\n");
12803
+ });
12642
12804
  for (const pattern of ast.patterns) {
12643
12805
  SUBRULE(generatePattern, pattern);
12644
12806
  }
12645
- F2.printFilter(ast, () => PRINT_WORD("}"));
12807
+ F2.printFilter(ast, () => {
12808
+ C[traqulaIndentation] -= indentInc;
12809
+ PRINT_ON_EMPTY("}\n");
12810
+ });
12646
12811
  }
12647
12812
  };
12648
12813
  var generatePattern = {
12649
12814
  name: "generatePattern",
12650
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
12815
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
12651
12816
  if (ast.type === "query") {
12652
12817
  SUBRULE(query, F2.querySelect({
12653
12818
  context: [],
@@ -12736,9 +12901,9 @@ var optionalGraphPattern = {
12736
12901
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12737
12902
  const optional2 = CONSUME(optional);
12738
12903
  const group = SUBRULE(groupGraphPattern);
12739
- return ACTION(() => C.factory.patternOptional(group.patterns, C.factory.sourceLocation(optional2, group)));
12904
+ return ACTION(() => C.astFactory.patternOptional(group.patterns, C.astFactory.sourceLocation(optional2, group)));
12740
12905
  },
12741
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12906
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12742
12907
  F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
12743
12908
  SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12744
12909
  }
@@ -12749,9 +12914,9 @@ var graphGraphPattern = {
12749
12914
  const graph2 = CONSUME(graph_exports.graph);
12750
12915
  const name = SUBRULE(varOrIri);
12751
12916
  const group = SUBRULE(groupGraphPattern);
12752
- return ACTION(() => C.factory.patternGraph(name, group.patterns, C.factory.sourceLocation(graph2, group)));
12917
+ return ACTION(() => C.astFactory.patternGraph(name, group.patterns, C.astFactory.sourceLocation(graph2, group)));
12753
12918
  },
12754
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12919
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12755
12920
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
12756
12921
  SUBRULE(varOrTerm, ast.name);
12757
12922
  SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
@@ -12767,9 +12932,9 @@ var serviceGraphPattern = {
12767
12932
  }) ?? false;
12768
12933
  const name = SUBRULE1(varOrIri);
12769
12934
  const group = SUBRULE1(groupGraphPattern);
12770
- return ACTION(() => C.factory.patternService(name, group.patterns, silent2, C.factory.sourceLocation(service2, group)));
12935
+ return ACTION(() => C.astFactory.patternService(name, group.patterns, silent2, C.astFactory.sourceLocation(service2, group)));
12771
12936
  },
12772
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12937
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12773
12938
  F2.printFilter(ast, () => {
12774
12939
  PRINT_WORD("SERVICE");
12775
12940
  if (ast.silent) {
@@ -12789,14 +12954,14 @@ var bind2 = {
12789
12954
  CONSUME(as);
12790
12955
  const variable = SUBRULE(var_);
12791
12956
  const close = CONSUME(symbols_exports.RParen);
12792
- return ACTION(() => C.factory.patternBind(expressionVal, variable, C.factory.sourceLocation(bind3, close)));
12957
+ return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
12793
12958
  },
12794
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12959
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12795
12960
  F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12796
12961
  SUBRULE(expression, ast.expression);
12797
12962
  F2.printFilter(ast, () => PRINT_WORD("AS"));
12798
12963
  SUBRULE(var_, ast.variable);
12799
- F2.printFilter(ast, () => PRINT_WORD(")"));
12964
+ F2.printFilter(ast, () => PRINT_WORD(")\n"));
12800
12965
  }
12801
12966
  };
12802
12967
  var inlineData = {
@@ -12804,16 +12969,19 @@ var inlineData = {
12804
12969
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12805
12970
  const values3 = CONSUME(values2);
12806
12971
  const datablock = SUBRULE(dataBlock);
12807
- return ACTION(() => C.factory.patternValues(datablock.val, C.factory.sourceLocation(values3, datablock)));
12972
+ return ACTION(() => C.astFactory.patternValues(datablock.val, C.astFactory.sourceLocation(values3, datablock)));
12808
12973
  },
12809
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
12974
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
12975
+ const { astFactory: F2, indentInc } = C;
12810
12976
  const variables = Object.keys(ast.values.at(0) ?? {});
12811
12977
  F2.printFilter(ast, () => {
12978
+ PRINT_ON_EMPTY("");
12812
12979
  PRINT_WORD("VALUES", "(");
12813
12980
  for (const variable of variables) {
12814
12981
  PRINT_WORD(`?${variable}`);
12815
12982
  }
12816
- PRINT_WORD(")", "{");
12983
+ C[traqulaIndentation] += indentInc;
12984
+ PRINT_WORD(")", "{\n");
12817
12985
  });
12818
12986
  for (const mapping of ast.values) {
12819
12987
  F2.printFilter(ast, () => PRINT_WORD("("));
@@ -12824,9 +12992,12 @@ var inlineData = {
12824
12992
  SUBRULE(graphNodePath, mapping[variable]);
12825
12993
  }
12826
12994
  }
12827
- F2.printFilter(ast, () => PRINT_WORD(")"));
12995
+ F2.printFilter(ast, () => PRINT_WORD(")\n"));
12828
12996
  }
12829
- F2.printFilter(ast, () => PRINT_WORD("}"));
12997
+ F2.printFilter(ast, () => {
12998
+ C[traqulaIndentation] -= indentInc;
12999
+ PRINT_ON_EMPTY("}\n");
13000
+ });
12830
13001
  }
12831
13002
  };
12832
13003
  var dataBlock = {
@@ -12849,7 +13020,7 @@ var inlineDataOneVar = {
12849
13020
  });
12850
13021
  });
12851
13022
  const close = CONSUME(symbols_exports.RCurly);
12852
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(varVal, close)));
13023
+ return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(varVal, close)));
12853
13024
  }
12854
13025
  };
12855
13026
  var inlineDataFull = {
@@ -12866,7 +13037,7 @@ var inlineDataFull = {
12866
13037
  res.push({});
12867
13038
  });
12868
13039
  const close = CONSUME1(symbols_exports.RCurly);
12869
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(nil2, close)));
13040
+ return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(nil2, close)));
12870
13041
  } },
12871
13042
  { ALT: () => {
12872
13043
  const open = CONSUME1(symbols_exports.LParen);
@@ -12898,7 +13069,7 @@ var inlineDataFull = {
12898
13069
  });
12899
13070
  });
12900
13071
  const close = CONSUME2(symbols_exports.RCurly);
12901
- return ACTION(() => C.factory.wrap(res, C.factory.sourceLocation(open, close)));
13072
+ return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(open, close)));
12902
13073
  } }
12903
13074
  ]);
12904
13075
  }
@@ -12921,9 +13092,9 @@ var minusGraphPattern = {
12921
13092
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12922
13093
  const minus2 = CONSUME(minus);
12923
13094
  const group = SUBRULE(groupGraphPattern);
12924
- return ACTION(() => C.factory.patternMinus(group.patterns, C.factory.sourceLocation(minus2, group)));
13095
+ return ACTION(() => C.astFactory.patternMinus(group.patterns, C.astFactory.sourceLocation(minus2, group)));
12925
13096
  },
12926
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13097
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12927
13098
  F2.printFilter(ast, () => PRINT_WORD("MINUS"));
12928
13099
  SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
12929
13100
  }
@@ -12939,9 +13110,9 @@ var groupOrUnionGraphPattern = {
12939
13110
  const group2 = SUBRULE2(groupGraphPattern);
12940
13111
  groups.push(group2);
12941
13112
  });
12942
- return ACTION(() => groups.length === 1 ? groups[0] : C.factory.patternUnion(groups, C.factory.sourceLocation(group, groups.at(-1))));
13113
+ return ACTION(() => groups.length === 1 ? groups[0] : C.astFactory.patternUnion(groups, C.astFactory.sourceLocation(group, groups.at(-1))));
12943
13114
  },
12944
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13115
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12945
13116
  if (F2.isPatternUnion(ast)) {
12946
13117
  const [head2, ...tail] = ast.patterns;
12947
13118
  SUBRULE(groupGraphPattern, head2);
@@ -12959,12 +13130,12 @@ var filter3 = {
12959
13130
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12960
13131
  const filterToken = CONSUME(filter2);
12961
13132
  const expression2 = SUBRULE(constraint);
12962
- return ACTION(() => C.factory.patternFilter(expression2, C.factory.sourceLocation(filterToken, expression2)));
13133
+ return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
12963
13134
  },
12964
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13135
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
12965
13136
  F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
12966
13137
  SUBRULE(expression, ast.expression);
12967
- F2.printFilter(ast, () => PRINT_WORD(")"));
13138
+ F2.printFilter(ast, () => PRINT_WORD(")\n"));
12968
13139
  }
12969
13140
  };
12970
13141
  var constraint = {
@@ -12980,7 +13151,7 @@ var functionCall = {
12980
13151
  impl: ({ ACTION, SUBRULE }) => (C) => {
12981
13152
  const func = SUBRULE(iri2);
12982
13153
  const args = SUBRULE(argList);
12983
- return ACTION(() => C.factory.expressionFunctionCall(func, args.val.args, args.val.distinct, C.factory.sourceLocation(func, args)));
13154
+ return ACTION(() => C.astFactory.expressionFunctionCall(func, args.val.args, args.val.distinct, C.astFactory.sourceLocation(func, args)));
12984
13155
  }
12985
13156
  };
12986
13157
 
@@ -12990,7 +13161,7 @@ var argList = {
12990
13161
  impl: ({ ACTION, CONSUME, SUBRULE1, OPTION, OR, AT_LEAST_ONE_SEP }) => (C) => OR([
12991
13162
  { ALT: () => {
12992
13163
  const nil2 = CONSUME(terminals_exports.nil);
12993
- return ACTION(() => C.factory.wrap({ args: [], distinct: false }, C.factory.sourceLocation(nil2)));
13164
+ return ACTION(() => C.astFactory.wrap({ args: [], distinct: false }, C.astFactory.sourceLocation(nil2)));
12994
13165
  } },
12995
13166
  { ALT: () => {
12996
13167
  const args = [];
@@ -13007,10 +13178,10 @@ var argList = {
13007
13178
  }
13008
13179
  });
13009
13180
  const close = CONSUME(symbols_exports.RParen);
13010
- return ACTION(() => C.factory.wrap({ args, distinct: distinct2 }, C.factory.sourceLocation(open, close)));
13181
+ return ACTION(() => C.astFactory.wrap({ args, distinct: distinct2 }, C.astFactory.sourceLocation(open, close)));
13011
13182
  } }
13012
13183
  ]),
13013
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13184
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13014
13185
  F2.printFilter(ast, () => {
13015
13186
  PRINT_WORD("(");
13016
13187
  if (ast.val.distinct) {
@@ -13033,7 +13204,7 @@ var expressionList = {
13033
13204
  impl: ({ ACTION, CONSUME, MANY, OR, SUBRULE1, SUBRULE2 }) => (C) => OR([
13034
13205
  { ALT: () => {
13035
13206
  const nil2 = CONSUME(terminals_exports.nil);
13036
- return ACTION(() => C.factory.wrap([], C.factory.sourceLocation(nil2)));
13207
+ return ACTION(() => C.astFactory.wrap([], C.astFactory.sourceLocation(nil2)));
13037
13208
  } },
13038
13209
  { ALT: () => {
13039
13210
  const open = CONSUME(symbols_exports.LParen);
@@ -13045,7 +13216,7 @@ var expressionList = {
13045
13216
  args.push(expr);
13046
13217
  });
13047
13218
  const close = CONSUME(symbols_exports.RParen);
13048
- return ACTION(() => C.factory.wrap(args, C.factory.sourceLocation(open, close)));
13219
+ return ACTION(() => C.astFactory.wrap(args, C.astFactory.sourceLocation(open, close)));
13049
13220
  } }
13050
13221
  ])
13051
13222
  };
@@ -13054,7 +13225,7 @@ var prefixOperator = /* @__PURE__ */ new Set(["!", "UPLUS", "UMINUS"]);
13054
13225
  var expression = {
13055
13226
  name: "expression",
13056
13227
  impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression),
13057
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13228
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13058
13229
  if (F2.isTerm(ast)) {
13059
13230
  SUBRULE(varOrTerm, ast);
13060
13231
  } else if (F2.isExpressionOperator(ast)) {
@@ -13119,7 +13290,7 @@ var conditionalOrExpression = {
13119
13290
  impl: ({ ACTION, MANY, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => constructLeftDeep(() => SUBRULE1(conditionalAndExpression), () => {
13120
13291
  CONSUME(symbols_exports.logicOr);
13121
13292
  const args = SUBRULE2(conditionalAndExpression);
13122
- return (left) => ACTION(() => C.factory.expressionOperation("||", [left, args], C.factory.sourceLocation(left, args)));
13293
+ return (left) => ACTION(() => C.astFactory.expressionOperation("||", [left, args], C.astFactory.sourceLocation(left, args)));
13123
13294
  }, ACTION, MANY)
13124
13295
  };
13125
13296
  var conditionalAndExpression = {
@@ -13127,7 +13298,7 @@ var conditionalAndExpression = {
13127
13298
  impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => constructLeftDeep(() => SUBRULE1(valueLogical), () => {
13128
13299
  CONSUME(symbols_exports.logicAnd);
13129
13300
  const arg = SUBRULE2(valueLogical);
13130
- return (left) => ACTION(() => C.factory.expressionOperation("&&", [left, arg], C.factory.sourceLocation(left, arg)));
13301
+ return (left) => ACTION(() => C.astFactory.expressionOperation("&&", [left, arg], C.astFactory.sourceLocation(left, arg)));
13131
13302
  }, ACTION, MANY)
13132
13303
  };
13133
13304
  var valueLogical = {
@@ -13149,7 +13320,7 @@ var relationalExpression = {
13149
13320
  { ALT: () => CONSUME(symbols_exports.greaterThanEqual) }
13150
13321
  ]);
13151
13322
  const expr = SUBRULE2(numericExpression);
13152
- return ACTION(() => C.factory.expressionOperation(operator.image, [args1, expr], C.factory.sourceLocation(args1, expr)));
13323
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [args1, expr], C.astFactory.sourceLocation(args1, expr)));
13153
13324
  } },
13154
13325
  { ALT: () => {
13155
13326
  const operator = OR3([
@@ -13157,7 +13328,7 @@ var relationalExpression = {
13157
13328
  { ALT: () => CONSUME(notIn) }
13158
13329
  ]);
13159
13330
  const args = SUBRULE1(expressionList);
13160
- return ACTION(() => C.factory.expressionOperation(operator.image, [args1, ...args.val], C.factory.sourceLocation(args1, args)));
13331
+ return ACTION(() => C.astFactory.expressionOperation(operator.image, [args1, ...args.val], C.astFactory.sourceLocation(args1, args)));
13161
13332
  } }
13162
13333
  ]));
13163
13334
  return expression2 ?? args1;
@@ -13176,7 +13347,7 @@ var additiveExpression = {
13176
13347
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13177
13348
  ]);
13178
13349
  const arg = SUBRULE2(multiplicativeExpression);
13179
- return ACTION(() => (left) => C.factory.expressionOperation(operator.image, [left, arg], C.factory.sourceLocation(left, arg)));
13350
+ return ACTION(() => (left) => C.astFactory.expressionOperation(operator.image, [left, arg], C.astFactory.sourceLocation(left, arg)));
13180
13351
  } },
13181
13352
  { ALT: () => {
13182
13353
  const { operator, startInt } = OR3([
@@ -13207,9 +13378,9 @@ var additiveExpression = {
13207
13378
  { ALT: () => CONSUME(symbols_exports.slash) }
13208
13379
  ]);
13209
13380
  const innerExpr = SUBRULE1(unaryExpression);
13210
- return ACTION(() => (leftInner) => C.factory.expressionOperation(innerOperator.image, [leftInner, innerExpr], C.factory.sourceLocation(leftInner, innerExpr)));
13381
+ return ACTION(() => (leftInner) => C.astFactory.expressionOperation(innerOperator.image, [leftInner, innerExpr], C.astFactory.sourceLocation(leftInner, innerExpr)));
13211
13382
  }, ACTION, MANY2);
13212
- return (left) => C.factory.expressionOperation(operator, [left, multiplicativeExpr], C.factory.sourceLocation(left, multiplicativeExpr));
13383
+ return (left) => C.astFactory.expressionOperation(operator, [left, multiplicativeExpr], C.astFactory.sourceLocation(left, multiplicativeExpr));
13213
13384
  } }
13214
13385
  ]), ACTION, MANY1)
13215
13386
  };
@@ -13226,7 +13397,7 @@ var multiplicativeExpression = {
13226
13397
  subType: "operation",
13227
13398
  operator: operator.image,
13228
13399
  args: [left, expr],
13229
- loc: C.factory.sourceLocation(left, expr)
13400
+ loc: C.astFactory.sourceLocation(left, expr)
13230
13401
  });
13231
13402
  }, ACTION, MANY)
13232
13403
  };
@@ -13241,7 +13412,7 @@ var unaryExpression = {
13241
13412
  { ALT: () => CONSUME(symbols_exports.opMinus) }
13242
13413
  ]);
13243
13414
  const expr = SUBRULE2(primaryExpression);
13244
- return ACTION(() => C.factory.expressionOperation(operator.image === "!" ? "!" : operator.image === "+" ? "UPLUS" : "UMINUS", [expr], C.factory.sourceLocation(operator, expr)));
13415
+ return ACTION(() => C.astFactory.expressionOperation(operator.image === "!" ? "!" : operator.image === "+" ? "UPLUS" : "UMINUS", [expr], C.astFactory.sourceLocation(operator, expr)));
13245
13416
  } }
13246
13417
  ])
13247
13418
  };
@@ -13264,7 +13435,7 @@ var brackettedExpression = {
13264
13435
  const expr = SUBRULE(expression);
13265
13436
  const close = CONSUME(symbols_exports.RParen);
13266
13437
  return ACTION(() => {
13267
- expr.loc = C.factory.sourceLocation(open, close);
13438
+ expr.loc = C.astFactory.sourceLocation(open, close);
13268
13439
  return expr;
13269
13440
  });
13270
13441
  }
@@ -13286,13 +13457,13 @@ var iriOrFunction = {
13286
13457
  function: iriVal,
13287
13458
  args: args.val.args,
13288
13459
  distinct: distinct2,
13289
- loc: C.factory.sourceLocation(iriVal, args)
13460
+ loc: C.astFactory.sourceLocation(iriVal, args)
13290
13461
  };
13291
13462
  });
13292
13463
  });
13293
13464
  return functionCall2 ?? iriVal;
13294
13465
  },
13295
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13466
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
13296
13467
  if (F2.isTermNamed(ast)) {
13297
13468
  SUBRULE(iri2, ast);
13298
13469
  } else {
@@ -13345,11 +13516,14 @@ var groupClause = {
13345
13516
  type: "solutionModifier",
13346
13517
  subType: "group",
13347
13518
  groupings,
13348
- loc: C.factory.sourceLocation(start, groupings.at(-1))
13519
+ loc: C.astFactory.sourceLocation(start, groupings.at(-1))
13349
13520
  }));
13350
13521
  },
13351
- gImpl: ({ PRINT_WORDS, SUBRULE }) => (ast, { factory: F2 }) => {
13352
- F2.printFilter(ast, () => PRINT_WORDS("GROUP", "BY"));
13522
+ gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
13523
+ F2.printFilter(ast, () => {
13524
+ PRINT_ON_EMPTY("");
13525
+ PRINT_WORDS("GROUP", "BY");
13526
+ });
13353
13527
  for (const grouping of ast.groupings) {
13354
13528
  if (F2.isExpression(grouping)) {
13355
13529
  SUBRULE(expression, grouping);
@@ -13383,7 +13557,7 @@ var groupCondition = {
13383
13557
  return {
13384
13558
  variable,
13385
13559
  value: expressionValue,
13386
- loc: C.factory.sourceLocation(open, close)
13560
+ loc: C.astFactory.sourceLocation(open, close)
13387
13561
  };
13388
13562
  }
13389
13563
  return expressionValue;
@@ -13402,10 +13576,13 @@ var havingClause = {
13402
13576
  expressions.push(SUBRULE(havingCondition));
13403
13577
  });
13404
13578
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13405
- return ACTION(() => C.factory.solutionModifierHaving(expressions, C.factory.sourceLocation(having2, expressions.at(-1))));
13579
+ return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
13406
13580
  },
13407
- gImpl: ({ PRINT_WORD, SUBRULE }) => (ast, { factory: F2 }) => {
13408
- F2.printFilter(ast, () => PRINT_WORD("HAVING"));
13581
+ gImpl: ({ PRINT_WORD, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
13582
+ F2.printFilter(ast, () => {
13583
+ PRINT_ON_EMPTY("");
13584
+ PRINT_WORD("HAVING");
13585
+ });
13409
13586
  for (const having2 of ast.having) {
13410
13587
  SUBRULE(expression, having2);
13411
13588
  }
@@ -13426,10 +13603,13 @@ var orderClause = {
13426
13603
  orderings.push(SUBRULE1(orderCondition));
13427
13604
  });
13428
13605
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13429
- return ACTION(() => C.factory.solutionModifierOrder(orderings, C.factory.sourceLocation(order2, orderings.at(-1))));
13606
+ return ACTION(() => C.astFactory.solutionModifierOrder(orderings, C.astFactory.sourceLocation(order2, orderings.at(-1))));
13430
13607
  },
13431
- gImpl: ({ PRINT_WORDS, SUBRULE }) => (ast, { factory: F2 }) => {
13432
- F2.printFilter(ast, () => PRINT_WORDS("ORDER", "BY"));
13608
+ gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
13609
+ F2.printFilter(ast, () => {
13610
+ PRINT_ON_EMPTY("");
13611
+ PRINT_WORDS("ORDER", "BY");
13612
+ });
13433
13613
  for (const ordering of ast.orderDefs) {
13434
13614
  if (ordering.descending) {
13435
13615
  F2.printFilter(ast, () => PRINT_WORDS("DESC"));
@@ -13460,7 +13640,7 @@ var orderCondition = {
13460
13640
  return ACTION(() => ({
13461
13641
  expression: expr,
13462
13642
  descending: descending[0],
13463
- loc: C.factory.sourceLocation(descending[1], expr)
13643
+ loc: C.astFactory.sourceLocation(descending[1], expr)
13464
13644
  }));
13465
13645
  } },
13466
13646
  { ALT: () => {
@@ -13479,16 +13659,17 @@ var limitOffsetClauses = {
13479
13659
  { ALT: () => {
13480
13660
  const limit2 = SUBRULE1(limitClause);
13481
13661
  const offset2 = OPTION1(() => SUBRULE1(offsetClause));
13482
- return ACTION(() => C.factory.solutionModifierLimitOffset(limit2.val, offset2?.val, C.factory.sourceLocation(limit2, ...offset2 ? [offset2] : [])));
13662
+ return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2.val, offset2?.val, C.astFactory.sourceLocation(limit2, ...offset2 ? [offset2] : [])));
13483
13663
  } },
13484
13664
  { ALT: () => {
13485
13665
  const offset2 = SUBRULE2(offsetClause);
13486
13666
  const limit2 = OPTION2(() => SUBRULE2(limitClause));
13487
- return ACTION(() => C.factory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.factory.sourceLocation(offset2, limit2)));
13667
+ return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
13488
13668
  } }
13489
13669
  ]),
13490
- gImpl: ({ PRINT_WORDS }) => (ast, { factory: F2 }) => {
13670
+ gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
13491
13671
  F2.printFilter(ast, () => {
13672
+ PRINT_ON_EMPTY("");
13492
13673
  if (ast.limit) {
13493
13674
  PRINT_WORDS("LIMIT", String(ast.limit));
13494
13675
  }
@@ -13504,7 +13685,7 @@ var limitClause = {
13504
13685
  const offset2 = CONSUME(limit);
13505
13686
  const value = CONSUME(terminals_exports.integer);
13506
13687
  const val = Number.parseInt(value.image, 10);
13507
- return ACTION(() => C.factory.wrap(val, C.factory.sourceLocation(offset2, value)));
13688
+ return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(offset2, value)));
13508
13689
  }
13509
13690
  };
13510
13691
  var offsetClause = {
@@ -13513,7 +13694,7 @@ var offsetClause = {
13513
13694
  const offset2 = CONSUME(offset);
13514
13695
  const value = CONSUME(terminals_exports.integer);
13515
13696
  const val = Number.parseInt(value.image, 10);
13516
- return ACTION(() => C.factory.wrap(val, C.factory.sourceLocation(offset2, value)));
13697
+ return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(offset2, value)));
13517
13698
  }
13518
13699
  };
13519
13700
 
@@ -13538,10 +13719,10 @@ var query = {
13538
13719
  ...subType,
13539
13720
  type: "query",
13540
13721
  ...values3 && { values: values3 },
13541
- loc: C.factory.sourceLocation(prologueValues.at(0), subType, values3)
13722
+ loc: C.astFactory.sourceLocation(prologueValues.at(0), subType, values3)
13542
13723
  }));
13543
13724
  },
13544
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13725
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
13545
13726
  SUBRULE(prologue, ast.context);
13546
13727
  if (F2.isQuerySelect(ast)) {
13547
13728
  SUBRULE(selectQuery, ast);
@@ -13571,13 +13752,13 @@ var selectQuery = {
13571
13752
  solutionModifiers: modifiers,
13572
13753
  datasets: from2,
13573
13754
  ...selectVal.val,
13574
- loc: C.factory.sourceLocation(selectVal, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13755
+ loc: C.astFactory.sourceLocation(selectVal, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13575
13756
  };
13576
13757
  queryIsGood(ret);
13577
13758
  return ret;
13578
13759
  });
13579
13760
  },
13580
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
13761
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
13581
13762
  SUBRULE(selectClause, F2.wrap({
13582
13763
  variables: ast.variables,
13583
13764
  distinct: ast.distinct,
@@ -13595,14 +13776,14 @@ var subSelect = {
13595
13776
  const where2 = SUBRULE(whereClause);
13596
13777
  const modifiers = SUBRULE(solutionModifier);
13597
13778
  const values3 = SUBRULE(valuesClause);
13598
- return ACTION(() => C.factory.querySelect({
13779
+ return ACTION(() => C.astFactory.querySelect({
13599
13780
  where: where2.val,
13600
- datasets: C.factory.datasetClauses([], C.factory.sourceLocation()),
13781
+ datasets: C.astFactory.datasetClauses([], C.astFactory.sourceLocation()),
13601
13782
  context: [],
13602
13783
  solutionModifiers: modifiers,
13603
13784
  ...selectVal.val,
13604
13785
  ...values3 && { values: values3 }
13605
- }, C.factory.sourceLocation(selectVal, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset, values3)));
13786
+ }, C.astFactory.sourceLocation(selectVal, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset, values3)));
13606
13787
  }
13607
13788
  };
13608
13789
  var selectClause = {
@@ -13633,7 +13814,7 @@ var selectClause = {
13633
13814
  const star2 = CONSUME(symbols_exports.star);
13634
13815
  return ACTION(() => {
13635
13816
  last2 = star2;
13636
- return { variables: [C.factory.wildcard(C.factory.sourceLocation(star2))], ...distRed };
13817
+ return { variables: [C.astFactory.wildcard(C.astFactory.sourceLocation(star2))], ...distRed };
13637
13818
  });
13638
13819
  } },
13639
13820
  { ALT: () => {
@@ -13663,7 +13844,7 @@ var selectClause = {
13663
13844
  throw new Error(`Variable ${variable.value} used more than once in SELECT clause`);
13664
13845
  }
13665
13846
  usedVars.push(variable);
13666
- variables.push(C.factory.patternBind(expr, variable, C.factory.sourceLocation(open, last2)));
13847
+ variables.push(C.astFactory.patternBind(expr, variable, C.astFactory.sourceLocation(open, last2)));
13667
13848
  });
13668
13849
  } }
13669
13850
  ]));
@@ -13671,9 +13852,9 @@ var selectClause = {
13671
13852
  } }
13672
13853
  ]);
13673
13854
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13674
- return ACTION(() => C.factory.wrap(val, C.factory.sourceLocation(select2, last2)));
13855
+ return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
13675
13856
  },
13676
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13857
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13677
13858
  F2.printFilter(ast, () => {
13678
13859
  PRINT_WORD("SELECT");
13679
13860
  if (ast.val.distinct) {
@@ -13713,7 +13894,7 @@ var constructQuery = {
13713
13894
  datasets: from2,
13714
13895
  where: where2.val,
13715
13896
  solutionModifiers: modifiers,
13716
- loc: C.factory.sourceLocation(construct2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13897
+ loc: C.astFactory.sourceLocation(construct2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13717
13898
  }));
13718
13899
  } },
13719
13900
  { ALT: () => {
@@ -13725,19 +13906,26 @@ var constructQuery = {
13725
13906
  subType: "construct",
13726
13907
  template: template.val,
13727
13908
  datasets: from2,
13728
- where: C.factory.patternGroup([template.val], C.factory.sourceLocation()),
13909
+ where: C.astFactory.patternGroup([template.val], C.astFactory.sourceLocation()),
13729
13910
  solutionModifiers: modifiers,
13730
- loc: C.factory.sourceLocation(construct2, template, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13911
+ loc: C.astFactory.sourceLocation(construct2, template, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13731
13912
  }));
13732
13913
  } }
13733
13914
  ]);
13734
13915
  },
13735
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13916
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
13917
+ const { astFactory: F2, indentInc } = C;
13736
13918
  F2.printFilter(ast, () => PRINT_WORD("CONSTRUCT"));
13737
13919
  if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
13738
- F2.printFilter(ast, () => PRINT_WORD("{"));
13920
+ F2.printFilter(ast, () => {
13921
+ C[traqulaIndentation] += indentInc;
13922
+ PRINT_WORD("{\n");
13923
+ });
13739
13924
  SUBRULE(triplesBlock, ast.template);
13740
- F2.printFilter(ast, () => PRINT_WORD("}"));
13925
+ F2.printFilter(ast, () => {
13926
+ C[traqulaIndentation] -= indentInc;
13927
+ PRINT_ON_EMPTY("}\n");
13928
+ });
13741
13929
  }
13742
13930
  SUBRULE(datasetClauseStar, ast.datasets);
13743
13931
  if (F2.isSourceLocationNoMaterialize(ast.where.loc)) {
@@ -13762,7 +13950,7 @@ var describeQuery = {
13762
13950
  } },
13763
13951
  { ALT: () => {
13764
13952
  const star2 = CONSUME(symbols_exports.star);
13765
- return [ACTION(() => C.factory.wildcard(C.factory.sourceLocation(star2)))];
13953
+ return [ACTION(() => C.astFactory.wildcard(C.astFactory.sourceLocation(star2)))];
13766
13954
  } }
13767
13955
  ]);
13768
13956
  const from2 = SUBRULE1(datasetClauseStar);
@@ -13774,10 +13962,10 @@ var describeQuery = {
13774
13962
  datasets: from2,
13775
13963
  ...where2 && { where: where2.val },
13776
13964
  solutionModifiers: modifiers,
13777
- loc: C.factory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13965
+ loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13778
13966
  }));
13779
13967
  },
13780
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13968
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13781
13969
  F2.printFilter(ast, () => PRINT_WORD("DESCRIBE"));
13782
13970
  if (F2.isWildcard(ast.variables[0])) {
13783
13971
  F2.printFilter(ast, () => PRINT_WORD("*"));
@@ -13805,10 +13993,10 @@ var askQuery = {
13805
13993
  datasets: from2,
13806
13994
  where: where2.val,
13807
13995
  solutionModifiers: modifiers,
13808
- loc: C.factory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13996
+ loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13809
13997
  }));
13810
13998
  },
13811
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
13999
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13812
14000
  F2.printFilter(ast, () => PRINT_WORD("ASK"));
13813
14001
  SUBRULE(datasetClauseStar, ast.datasets);
13814
14002
  SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
@@ -13825,7 +14013,7 @@ var constructTemplate = {
13825
14013
  const open = CONSUME(symbols_exports.LCurly);
13826
14014
  const triples = OPTION(() => SUBRULE1(constructTriples));
13827
14015
  const close = CONSUME(symbols_exports.RCurly);
13828
- return ACTION(() => C.factory.wrap(triples ?? C.factory.patternBgp([], C.factory.sourceLocation()), C.factory.sourceLocation(open, close)));
14016
+ return ACTION(() => C.astFactory.wrap(triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocation()), C.astFactory.sourceLocation(open, close)));
13829
14017
  }
13830
14018
  };
13831
14019
  var constructTriples = {
@@ -13862,13 +14050,13 @@ var update = {
13862
14050
  const update2 = {
13863
14051
  type: "update",
13864
14052
  updates,
13865
- loc: C.factory.sourceLocation(...updates[0].context, updates[0].operation, ...updates.at(-1).context, updates.at(-1)?.operation)
14053
+ loc: C.astFactory.sourceLocation(...updates[0].context, updates[0].operation, ...updates.at(-1).context, updates.at(-1)?.operation)
13866
14054
  };
13867
14055
  updateNoReuseBlankNodeLabels(update2);
13868
14056
  return update2;
13869
14057
  });
13870
14058
  },
13871
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14059
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13872
14060
  const [head2, ...tail] = ast.updates;
13873
14061
  if (head2) {
13874
14062
  SUBRULE(prologue, head2.context);
@@ -13948,9 +14136,9 @@ var load2 = {
13948
14136
  CONSUME(loadInto);
13949
14137
  return SUBRULE1(graphRef);
13950
14138
  });
13951
- return ACTION(() => C.factory.updateOperationLoad(C.factory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
14139
+ return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
13952
14140
  },
13953
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14141
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13954
14142
  F2.printFilter(ast, () => {
13955
14143
  PRINT_WORD("LOAD");
13956
14144
  if (ast.silent) {
@@ -13971,9 +14159,9 @@ function clearOrDrop(operation) {
13971
14159
  const opToken = CONSUME(operation);
13972
14160
  const silent2 = OPTION(() => CONSUME(silent));
13973
14161
  const destination = SUBRULE1(graphRefAll);
13974
- return ACTION(() => C.factory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.factory.sourceLocation(opToken, destination)));
14162
+ return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
13975
14163
  },
13976
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14164
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13977
14165
  F2.printFilter(ast, () => {
13978
14166
  PRINT_WORD(operation.name.toUpperCase());
13979
14167
  if (ast.silent) {
@@ -13992,9 +14180,9 @@ var create2 = {
13992
14180
  const createToken3 = CONSUME(create);
13993
14181
  const silent2 = OPTION(() => CONSUME(silent));
13994
14182
  const destination = SUBRULE1(graphRef);
13995
- return ACTION(() => C.factory.updateOperationCreate(destination, Boolean(silent2), C.factory.sourceLocation(createToken3, destination)));
14183
+ return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
13996
14184
  },
13997
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14185
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13998
14186
  F2.printFilter(ast, () => {
13999
14187
  PRINT_WORD("CREATE");
14000
14188
  if (ast.silent) {
@@ -14013,9 +14201,9 @@ function copyMoveAddOperation(operation) {
14013
14201
  const source = SUBRULE1(graphOrDefault);
14014
14202
  CONSUME(to);
14015
14203
  const destination = SUBRULE2(graphOrDefault);
14016
- return ACTION(() => C.factory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.factory.sourceLocation(op, destination)));
14204
+ return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
14017
14205
  },
14018
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14206
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14019
14207
  F2.printFilter(ast, () => {
14020
14208
  PRINT_WORD(operation.name.toUpperCase());
14021
14209
  if (ast.silent) {
@@ -14037,7 +14225,7 @@ var quadPattern = {
14037
14225
  const open = CONSUME(symbols_exports.LCurly);
14038
14226
  const val = SUBRULE1(quads);
14039
14227
  const close = CONSUME(symbols_exports.RCurly);
14040
- return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
14228
+ return ACTION(() => C.astFactory.wrap(val.val, C.astFactory.sourceLocation(open, close)));
14041
14229
  }
14042
14230
  };
14043
14231
  var quadData = {
@@ -14048,7 +14236,7 @@ var quadData = {
14048
14236
  const val = SUBRULE1(quads);
14049
14237
  ACTION(() => couldParseVars && C.parseMode.add("canParseVars"));
14050
14238
  const close = CONSUME(symbols_exports.RCurly);
14051
- return ACTION(() => C.factory.wrap(val.val, C.factory.sourceLocation(open, close)));
14239
+ return ACTION(() => C.astFactory.wrap(val.val, C.astFactory.sourceLocation(open, close)));
14052
14240
  }
14053
14241
  };
14054
14242
  function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
@@ -14065,12 +14253,26 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14065
14253
  if (name !== "insertData") {
14066
14254
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14067
14255
  }
14068
- return ACTION(() => C.factory.updateOperationInsDelDataWhere(subType, data.val, C.factory.sourceLocation(insDelToken, data)));
14256
+ return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
14069
14257
  },
14070
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14071
- F2.printFilter(ast, () => PRINT_WORD(subType === "insertdata" ? "INSERT DATA" : subType === "deletedata" ? "DELETE DATA" : "DELETE WHERE", "{"));
14258
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14259
+ const { astFactory: F2, indentInc } = C;
14260
+ F2.printFilter(ast, () => {
14261
+ C[traqulaIndentation] += indentInc;
14262
+ if (subType === "insertdata") {
14263
+ PRINT_WORD("INSERT DATA");
14264
+ } else if (subType === "deletedata") {
14265
+ PRINT_WORD("DELETE DATA");
14266
+ } else if (subType === "deletewhere") {
14267
+ PRINT_WORD("DELETE WHERE");
14268
+ }
14269
+ PRINT_WORD("{\n");
14270
+ });
14072
14271
  SUBRULE(quads, F2.wrap(ast.data, ast.loc));
14073
- F2.printFilter(ast, () => PRINT_WORD("}"));
14272
+ F2.printFilter(ast, () => {
14273
+ C[traqulaIndentation] -= indentInc;
14274
+ PRINT_ON_EMPTY("}\n");
14275
+ });
14074
14276
  }
14075
14277
  };
14076
14278
  }
@@ -14099,22 +14301,35 @@ var modify = {
14099
14301
  const using = SUBRULE1(usingClauseStar);
14100
14302
  CONSUME(where);
14101
14303
  const where2 = SUBRULE1(groupGraphPattern);
14102
- return ACTION(() => C.factory.updateOperationModify(C.factory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
14304
+ return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
14103
14305
  },
14104
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14306
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14307
+ const { astFactory: F2, indentInc } = C;
14105
14308
  if (ast.graph) {
14106
14309
  F2.printFilter(ast, () => PRINT_WORD("WITH"));
14107
14310
  SUBRULE(iri2, ast.graph);
14108
14311
  }
14109
14312
  if (ast.delete.length > 0) {
14110
- F2.printFilter(ast, () => PRINT_WORD("DELETE", "{"));
14313
+ F2.printFilter(ast, () => {
14314
+ C[traqulaIndentation] += indentInc;
14315
+ PRINT_WORD("DELETE", "{\n");
14316
+ });
14111
14317
  SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
14112
- F2.printFilter(ast, () => PRINT_WORD("}"));
14318
+ F2.printFilter(ast, () => {
14319
+ C[traqulaIndentation] -= indentInc;
14320
+ PRINT_ON_EMPTY("}\n");
14321
+ });
14113
14322
  }
14114
14323
  if (ast.insert.length > 0) {
14115
- F2.printFilter(ast, () => PRINT_WORD("INSERT", "{"));
14324
+ F2.printFilter(ast, () => {
14325
+ C[traqulaIndentation] += indentInc;
14326
+ PRINT_WORD("INSERT", "{\n");
14327
+ });
14116
14328
  SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
14117
- F2.printFilter(ast, () => PRINT_WORD("}"));
14329
+ F2.printFilter(ast, () => {
14330
+ C[traqulaIndentation] -= indentInc;
14331
+ PRINT_ON_EMPTY("}\n");
14332
+ });
14118
14333
  }
14119
14334
  SUBRULE(usingClauseStar, ast.from);
14120
14335
  F2.printFilter(ast, () => PRINT_WORD("WHERE"));
@@ -14128,7 +14343,7 @@ var deleteClause2 = {
14128
14343
  const couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
14129
14344
  const del = SUBRULE(quadPattern);
14130
14345
  ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
14131
- return ACTION(() => C.factory.wrap(del.val, C.factory.sourceLocation(delToken, del)));
14346
+ return ACTION(() => C.astFactory.wrap(del.val, C.astFactory.sourceLocation(delToken, del)));
14132
14347
  }
14133
14348
  };
14134
14349
  var insertClause2 = {
@@ -14136,7 +14351,7 @@ var insertClause2 = {
14136
14351
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14137
14352
  const insertToken = CONSUME(insertClause);
14138
14353
  const insert = SUBRULE(quadPattern);
14139
- return ACTION(() => C.factory.wrap(insert.val, C.factory.sourceLocation(insertToken, insert)));
14354
+ return ACTION(() => C.astFactory.wrap(insert.val, C.astFactory.sourceLocation(insertToken, insert)));
14140
14355
  }
14141
14356
  };
14142
14357
  var graphOrDefault = {
@@ -14144,12 +14359,12 @@ var graphOrDefault = {
14144
14359
  impl: ({ ACTION, SUBRULE1, CONSUME, OPTION, OR }) => (C) => OR([
14145
14360
  { ALT: () => {
14146
14361
  const def = CONSUME(graph_exports.default_);
14147
- return ACTION(() => C.factory.graphRefDefault(C.factory.sourceLocation(def)));
14362
+ return ACTION(() => C.astFactory.graphRefDefault(C.astFactory.sourceLocation(def)));
14148
14363
  } },
14149
14364
  { ALT: () => {
14150
14365
  const graph2 = OPTION(() => CONSUME(graph_exports.graph));
14151
14366
  const name = SUBRULE1(iri2);
14152
- return ACTION(() => C.factory.graphRefSpecific(name, C.factory.sourceLocation(graph2, name)));
14367
+ return ACTION(() => C.astFactory.graphRefSpecific(name, C.astFactory.sourceLocation(graph2, name)));
14153
14368
  } }
14154
14369
  ])
14155
14370
  };
@@ -14158,9 +14373,9 @@ var graphRef = {
14158
14373
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
14159
14374
  const graph2 = CONSUME(graph_exports.graph);
14160
14375
  const val = SUBRULE(iri2);
14161
- return ACTION(() => C.factory.graphRefSpecific(val, C.factory.sourceLocation(graph2, val)));
14376
+ return ACTION(() => C.astFactory.graphRefSpecific(val, C.astFactory.sourceLocation(graph2, val)));
14162
14377
  },
14163
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14378
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14164
14379
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14165
14380
  SUBRULE(iri2, ast.graph);
14166
14381
  }
@@ -14171,18 +14386,18 @@ var graphRefAll = {
14171
14386
  { ALT: () => SUBRULE(graphRef) },
14172
14387
  { ALT: () => {
14173
14388
  const def = CONSUME(graph_exports.default_);
14174
- return ACTION(() => C.factory.graphRefDefault(C.factory.sourceLocation(def)));
14389
+ return ACTION(() => C.astFactory.graphRefDefault(C.astFactory.sourceLocation(def)));
14175
14390
  } },
14176
14391
  { ALT: () => {
14177
14392
  const named2 = CONSUME(graph_exports.named);
14178
- return ACTION(() => C.factory.graphRefNamed(C.factory.sourceLocation(named2)));
14393
+ return ACTION(() => C.astFactory.graphRefNamed(C.astFactory.sourceLocation(named2)));
14179
14394
  } },
14180
14395
  { ALT: () => {
14181
14396
  const graphAll2 = CONSUME(graph_exports.graphAll);
14182
- return ACTION(() => C.factory.graphRefAll(C.factory.sourceLocation(graphAll2)));
14397
+ return ACTION(() => C.astFactory.graphRefAll(C.astFactory.sourceLocation(graphAll2)));
14183
14398
  } }
14184
14399
  ]),
14185
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14400
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14186
14401
  if (F2.isGraphRefSpecific(ast)) {
14187
14402
  SUBRULE(graphRef, ast);
14188
14403
  } else if (F2.isGraphRefDefault(ast)) {
@@ -14219,9 +14434,9 @@ var quads = {
14219
14434
  ACTION(() => quads2.push(triples));
14220
14435
  });
14221
14436
  });
14222
- return ACTION(() => C.factory.wrap(quads2, C.factory.sourceLocation(quads2.at(0), last2)));
14437
+ return ACTION(() => C.astFactory.wrap(quads2, C.astFactory.sourceLocation(quads2.at(0), last2)));
14223
14438
  },
14224
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
14439
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
14225
14440
  for (const quad of ast.val) {
14226
14441
  if (F2.isPattern(quad)) {
14227
14442
  SUBRULE(triplesBlock, quad);
@@ -14239,14 +14454,21 @@ var quadsNotTriples = {
14239
14454
  CONSUME(symbols_exports.LCurly);
14240
14455
  const triples = OPTION(() => SUBRULE1(triplesTemplate));
14241
14456
  const close = CONSUME(symbols_exports.RCurly);
14242
- return ACTION(() => C.factory.graphQuads(name, triples ?? C.factory.patternBgp([], C.factory.sourceLocationNoMaterialize()), C.factory.sourceLocation(graph2, close)));
14457
+ return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
14243
14458
  },
14244
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { factory: F2 }) => {
14459
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14460
+ const { astFactory: F2, indentInc } = C;
14245
14461
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14246
14462
  SUBRULE(varOrTerm, ast.graph);
14247
- F2.printFilter(ast, () => PRINT_WORD("{"));
14463
+ F2.printFilter(ast, () => {
14464
+ C[traqulaIndentation] += indentInc;
14465
+ PRINT_WORD("{\n");
14466
+ });
14248
14467
  SUBRULE(triplesBlock, ast.triples);
14249
- F2.printFilter(ast, () => PRINT_WORD("}"));
14468
+ F2.printFilter(ast, () => {
14469
+ C[traqulaIndentation] -= indentInc;
14470
+ PRINT_ON_EMPTY("}\n");
14471
+ });
14250
14472
  }
14251
14473
  };
14252
14474
 
@@ -14269,7 +14491,7 @@ var queryOrUpdate = {
14269
14491
  ...subType,
14270
14492
  type: "query",
14271
14493
  ...values3 && { values: values3 },
14272
- loc: C.factory.sourceLocation(prologueValues.at(0), subType, values3)
14494
+ loc: C.astFactory.sourceLocation(prologueValues.at(0), subType, values3)
14273
14495
  }));
14274
14496
  } },
14275
14497
  { ALT: () => {
@@ -14293,7 +14515,7 @@ var queryOrUpdate = {
14293
14515
  const update2 = {
14294
14516
  type: "update",
14295
14517
  updates,
14296
- loc: C.factory.sourceLocation(...updates[0].context, updates[0].operation, ...updates.at(-1).context, updates.at(-1)?.operation)
14518
+ loc: C.astFactory.sourceLocation(...updates[0].context, updates[0].operation, ...updates.at(-1).context, updates.at(-1)?.operation)
14297
14519
  };
14298
14520
  updateNoReuseBlankNodeLabels(update2);
14299
14521
  return update2;
@@ -14301,7 +14523,7 @@ var queryOrUpdate = {
14301
14523
  } }
14302
14524
  ]);
14303
14525
  },
14304
- gImpl: ({ SUBRULE }) => (ast, { factory: F2 }) => {
14526
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
14305
14527
  if (F2.isQuery(ast)) {
14306
14528
  SUBRULE(query, ast);
14307
14529
  } else {
@@ -14313,13 +14535,15 @@ var queryOrUpdate = {
14313
14535
  // ../../packages/rules-sparql-1-1/lib/MinimalSparqlParser.js
14314
14536
  function completeParseContext(context) {
14315
14537
  return {
14316
- factory: context.factory ?? new Factory(),
14538
+ astFactory: context.astFactory ?? new AstFactory(),
14317
14539
  baseIRI: context.baseIRI,
14318
14540
  prefixes: { ...context.prefixes },
14319
14541
  origSource: context.origSource ?? "",
14320
14542
  offset: context.offset,
14321
14543
  parseMode: context.parseMode ? new Set(context.parseMode) : /* @__PURE__ */ new Set(["canParseVars", "canCreateBlankNodes"]),
14322
- skipValidation: context.skipValidation ?? false
14544
+ skipValidation: context.skipValidation ?? false,
14545
+ [traqulaIndentation]: context[traqulaIndentation] ?? 0,
14546
+ indentInc: context.indentInc ?? 2
14323
14547
  };
14324
14548
  }
14325
14549
 
@@ -14398,7 +14622,7 @@ var sparql11GeneratorBuilder = GeneratorBuilder.create([
14398
14622
  );
14399
14623
  var Generator = class {
14400
14624
  generator = sparql11GeneratorBuilder.build();
14401
- factory = new Factory();
14625
+ factory = new AstFactory();
14402
14626
  generate(ast, context = {}) {
14403
14627
  return this.generator.queryOrUpdate(ast, completeParseContext(context));
14404
14628
  }