@traqula/generator-sparql-1-1 0.0.15 → 0.0.16
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 +557 -439
- package/lib/index.d.ts +14 -21
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
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/
|
|
29
|
-
var
|
|
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,6 +9363,262 @@ applyMixins(Parser, [
|
|
|
9571
9363
|
PerformanceTracer
|
|
9572
9364
|
]);
|
|
9573
9365
|
|
|
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
|
+
}
|
|
9398
|
+
}
|
|
9399
|
+
setContext(context) {
|
|
9400
|
+
this.__context = context;
|
|
9401
|
+
}
|
|
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
|
+
|
|
9574
9622
|
// ../../packages/core/lib/lexer-builder/LexerBuilder.js
|
|
9575
9623
|
var LexerBuilder = class _LexerBuilder {
|
|
9576
9624
|
tokens;
|
|
@@ -9668,14 +9716,6 @@ 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 {
|
|
9681
9721
|
safeObjectVisit(value, mapper) {
|
|
@@ -11123,8 +11163,8 @@ function UpdateOperationFactoryMixin(Base) {
|
|
|
11123
11163
|
};
|
|
11124
11164
|
}
|
|
11125
11165
|
|
|
11126
|
-
// ../../packages/rules-sparql-1-1/lib/
|
|
11127
|
-
var
|
|
11166
|
+
// ../../packages/rules-sparql-1-1/lib/astFactory.js
|
|
11167
|
+
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
11168
|
alwaysSparql11(obj) {
|
|
11129
11169
|
return true;
|
|
11130
11170
|
}
|
|
@@ -11225,7 +11265,7 @@ var TransformerSparql11 = class extends TransformerSubType {
|
|
|
11225
11265
|
};
|
|
11226
11266
|
|
|
11227
11267
|
// ../../packages/rules-sparql-1-1/lib/validation/validators.js
|
|
11228
|
-
var F = new
|
|
11268
|
+
var F = new AstFactory();
|
|
11229
11269
|
var transformer = new TransformerSparql11();
|
|
11230
11270
|
function getAggregatesOfExpression(expression2) {
|
|
11231
11271
|
if (F.isExpressionAggregate(expression2)) {
|
|
@@ -11445,22 +11485,22 @@ var rdfLiteral = {
|
|
|
11445
11485
|
return OPTION(() => OR([
|
|
11446
11486
|
{ ALT: () => {
|
|
11447
11487
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11448
|
-
return ACTION(() => C.
|
|
11488
|
+
return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11449
11489
|
} },
|
|
11450
11490
|
{ ALT: () => {
|
|
11451
11491
|
CONSUME(symbols_exports.hathat);
|
|
11452
11492
|
const iriVal = SUBRULE1(iri2);
|
|
11453
|
-
return ACTION(() => C.
|
|
11493
|
+
return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11454
11494
|
} }
|
|
11455
11495
|
])) ?? value;
|
|
11456
11496
|
},
|
|
11457
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_SPACE_LEFT }) => (ast, {
|
|
11458
|
-
|
|
11497
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_SPACE_LEFT }) => (ast, { astFactory }) => {
|
|
11498
|
+
astFactory.printFilter(ast, () => PRINT_SPACE_LEFT(stringEscapedLexical(ast.value)));
|
|
11459
11499
|
if (ast.langOrIri) {
|
|
11460
11500
|
if (typeof ast.langOrIri === "string") {
|
|
11461
|
-
|
|
11501
|
+
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
11462
11502
|
} else {
|
|
11463
|
-
|
|
11503
|
+
astFactory.printFilter(ast, () => PRINT("^^"));
|
|
11464
11504
|
SUBRULE(iri2, ast.langOrIri);
|
|
11465
11505
|
}
|
|
11466
11506
|
}
|
|
@@ -11482,7 +11522,7 @@ var numericLiteralUnsigned = {
|
|
|
11482
11522
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11483
11523
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11484
11524
|
]);
|
|
11485
|
-
return ACTION(() => C.
|
|
11525
|
+
return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11486
11526
|
}
|
|
11487
11527
|
};
|
|
11488
11528
|
var numericLiteralPositive = {
|
|
@@ -11493,7 +11533,7 @@ var numericLiteralPositive = {
|
|
|
11493
11533
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11494
11534
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11495
11535
|
]);
|
|
11496
|
-
return ACTION(() => C.
|
|
11536
|
+
return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11497
11537
|
}
|
|
11498
11538
|
};
|
|
11499
11539
|
var numericLiteralNegative = {
|
|
@@ -11504,7 +11544,7 @@ var numericLiteralNegative = {
|
|
|
11504
11544
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11505
11545
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11506
11546
|
]);
|
|
11507
|
-
return ACTION(() => C.
|
|
11547
|
+
return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11508
11548
|
}
|
|
11509
11549
|
};
|
|
11510
11550
|
var booleanLiteral = {
|
|
@@ -11514,7 +11554,7 @@ var booleanLiteral = {
|
|
|
11514
11554
|
{ ALT: () => CONSUME(true_) },
|
|
11515
11555
|
{ ALT: () => CONSUME(false_) }
|
|
11516
11556
|
]);
|
|
11517
|
-
return ACTION(() => C.
|
|
11557
|
+
return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11518
11558
|
}
|
|
11519
11559
|
};
|
|
11520
11560
|
var string = {
|
|
@@ -11539,7 +11579,7 @@ var string = {
|
|
|
11539
11579
|
} }
|
|
11540
11580
|
]);
|
|
11541
11581
|
return ACTION(() => {
|
|
11542
|
-
const F2 = C.
|
|
11582
|
+
const F2 = C.astFactory;
|
|
11543
11583
|
const value = x[1].replaceAll(/\\([tnrbf"'\\])/gu, (_, char) => {
|
|
11544
11584
|
switch (char) {
|
|
11545
11585
|
case "t":
|
|
@@ -11566,16 +11606,16 @@ var iri2 = {
|
|
|
11566
11606
|
{ ALT: () => SUBRULE(iriFull) },
|
|
11567
11607
|
{ ALT: () => SUBRULE(prefixedName) }
|
|
11568
11608
|
]),
|
|
11569
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
11609
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => F2.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast) : SUBRULE(iriFull, ast)
|
|
11570
11610
|
};
|
|
11571
11611
|
var iriFull = {
|
|
11572
11612
|
name: "iriFull",
|
|
11573
11613
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11574
11614
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11575
|
-
return ACTION(() => C.
|
|
11615
|
+
return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11576
11616
|
},
|
|
11577
|
-
gImpl: ({ PRINT }) => (ast, {
|
|
11578
|
-
|
|
11617
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
11618
|
+
F2.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
11579
11619
|
}
|
|
11580
11620
|
};
|
|
11581
11621
|
var prefixedName = {
|
|
@@ -11585,16 +11625,16 @@ var prefixedName = {
|
|
|
11585
11625
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11586
11626
|
return ACTION(() => {
|
|
11587
11627
|
const [prefix, localName] = longName.image.split(":");
|
|
11588
|
-
return C.
|
|
11628
|
+
return C.astFactory.namedNode(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11589
11629
|
});
|
|
11590
11630
|
} },
|
|
11591
11631
|
{ ALT: () => {
|
|
11592
11632
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11593
|
-
return ACTION(() => C.
|
|
11633
|
+
return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11594
11634
|
} }
|
|
11595
11635
|
]),
|
|
11596
|
-
gImpl: ({ PRINT_WORD }) => (ast, {
|
|
11597
|
-
|
|
11636
|
+
gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
11637
|
+
F2.printFilter(ast, () => PRINT_WORD(ast.prefix, ":", ast.value));
|
|
11598
11638
|
}
|
|
11599
11639
|
};
|
|
11600
11640
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11604,11 +11644,11 @@ var blankNode = {
|
|
|
11604
11644
|
const result = OR([
|
|
11605
11645
|
{ ALT: () => {
|
|
11606
11646
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11607
|
-
return ACTION(() => C.
|
|
11647
|
+
return ACTION(() => C.astFactory.blankNode(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11608
11648
|
} },
|
|
11609
11649
|
{ ALT: () => {
|
|
11610
11650
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11611
|
-
return ACTION(() => C.
|
|
11651
|
+
return ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11612
11652
|
} }
|
|
11613
11653
|
]);
|
|
11614
11654
|
ACTION(() => {
|
|
@@ -11618,15 +11658,15 @@ var blankNode = {
|
|
|
11618
11658
|
});
|
|
11619
11659
|
return result;
|
|
11620
11660
|
},
|
|
11621
|
-
gImpl: ({ PRINT_WORD }) => (ast, {
|
|
11622
|
-
|
|
11661
|
+
gImpl: ({ PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11662
|
+
astFactory.printFilter(ast, () => PRINT_WORD("_:", ast.label.replace(/^e_/u, "")));
|
|
11623
11663
|
}
|
|
11624
11664
|
};
|
|
11625
11665
|
var verbA = {
|
|
11626
11666
|
name: "VerbA",
|
|
11627
11667
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11628
11668
|
const token = CONSUME(a);
|
|
11629
|
-
return ACTION(() => C.
|
|
11669
|
+
return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11630
11670
|
}
|
|
11631
11671
|
};
|
|
11632
11672
|
|
|
@@ -11643,7 +11683,7 @@ var prologue = {
|
|
|
11643
11683
|
]));
|
|
11644
11684
|
return result;
|
|
11645
11685
|
},
|
|
11646
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
11686
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
11647
11687
|
for (const context of ast) {
|
|
11648
11688
|
if (F2.isContextDefinitionBase(context)) {
|
|
11649
11689
|
SUBRULE(baseDecl2, context);
|
|
@@ -11658,11 +11698,12 @@ var baseDecl2 = {
|
|
|
11658
11698
|
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
11659
11699
|
const base = CONSUME(baseDecl);
|
|
11660
11700
|
const val = SUBRULE(iriFull);
|
|
11661
|
-
return ACTION(() => C.
|
|
11701
|
+
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11662
11702
|
},
|
|
11663
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
11703
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
11664
11704
|
F2.printFilter(ast, () => PRINT_WORD("BASE"));
|
|
11665
11705
|
SUBRULE(iri2, ast.value);
|
|
11706
|
+
F2.printFilter(ast, () => PRINT_WORD("\n"));
|
|
11666
11707
|
}
|
|
11667
11708
|
};
|
|
11668
11709
|
var prefixDecl2 = {
|
|
@@ -11671,13 +11712,14 @@ var prefixDecl2 = {
|
|
|
11671
11712
|
const prefix = CONSUME(prefixDecl);
|
|
11672
11713
|
const name = CONSUME(terminals_exports.pNameNs).image.slice(0, -1);
|
|
11673
11714
|
const value = SUBRULE(iriFull);
|
|
11674
|
-
return ACTION(() => C.
|
|
11715
|
+
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11675
11716
|
},
|
|
11676
|
-
gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, {
|
|
11717
|
+
gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { astFactory: F2 }) => {
|
|
11677
11718
|
F2.printFilter(ast, () => {
|
|
11678
11719
|
PRINT_WORDS("PREFIX", `${ast.key}:`);
|
|
11679
11720
|
});
|
|
11680
11721
|
SUBRULE(iri2, ast.value);
|
|
11722
|
+
F2.printFilter(ast, () => PRINT_WORDS("\n"));
|
|
11681
11723
|
}
|
|
11682
11724
|
};
|
|
11683
11725
|
var verb = {
|
|
@@ -11693,7 +11735,7 @@ var varOrTerm = {
|
|
|
11693
11735
|
{ GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(var_) },
|
|
11694
11736
|
{ ALT: () => SUBRULE(graphTerm) }
|
|
11695
11737
|
]),
|
|
11696
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
11738
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
11697
11739
|
if (F2.isTermVariable(ast)) {
|
|
11698
11740
|
return SUBRULE(var_, ast);
|
|
11699
11741
|
}
|
|
@@ -11714,9 +11756,9 @@ var var_ = {
|
|
|
11714
11756
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11715
11757
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11716
11758
|
]);
|
|
11717
|
-
return ACTION(() => C.
|
|
11759
|
+
return ACTION(() => C.astFactory.variable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11718
11760
|
},
|
|
11719
|
-
gImpl: ({ PRINT_WORD }) => (ast, {
|
|
11761
|
+
gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
11720
11762
|
F2.printFilter(ast, () => PRINT_WORD(`?${ast.value}`));
|
|
11721
11763
|
}
|
|
11722
11764
|
};
|
|
@@ -11730,10 +11772,10 @@ var graphTerm = {
|
|
|
11730
11772
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
11731
11773
|
{ ALT: () => {
|
|
11732
11774
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
11733
|
-
return ACTION(() => C.
|
|
11775
|
+
return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
11734
11776
|
} }
|
|
11735
11777
|
]),
|
|
11736
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
11778
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
11737
11779
|
if (F2.isTermNamed(ast)) {
|
|
11738
11780
|
SUBRULE(iri2, ast);
|
|
11739
11781
|
} else if (F2.isTermLiteral(ast)) {
|
|
@@ -11753,14 +11795,14 @@ function datasetClauseUsing(name, token) {
|
|
|
11753
11795
|
return OR([
|
|
11754
11796
|
{ ALT: () => {
|
|
11755
11797
|
const iri3 = SUBRULE(defaultGraphClause);
|
|
11756
|
-
return ACTION(() => C.
|
|
11798
|
+
return ACTION(() => C.astFactory.wrap({ clauseType: "default", value: iri3 }, C.astFactory.sourceLocation(start, iri3)));
|
|
11757
11799
|
} },
|
|
11758
11800
|
{ ALT: () => {
|
|
11759
11801
|
const namedClause = SUBRULE(namedGraphClause);
|
|
11760
|
-
return ACTION(() => C.
|
|
11802
|
+
return ACTION(() => C.astFactory.wrap({
|
|
11761
11803
|
clauseType: "named",
|
|
11762
11804
|
value: namedClause.val
|
|
11763
|
-
}, C.
|
|
11805
|
+
}, C.astFactory.sourceLocation(start, namedClause)));
|
|
11764
11806
|
} }
|
|
11765
11807
|
]);
|
|
11766
11808
|
}
|
|
@@ -11781,9 +11823,9 @@ function datasetClauseUsingStar(name, subRule, fromUsing) {
|
|
|
11781
11823
|
const clause = SUBRULE(subRule);
|
|
11782
11824
|
clauses.push(clause);
|
|
11783
11825
|
});
|
|
11784
|
-
return ACTION(() => C.
|
|
11826
|
+
return ACTION(() => C.astFactory.datasetClauses(clauses.map((clause) => clause.val), C.astFactory.sourceLocation(...clauses)));
|
|
11785
11827
|
},
|
|
11786
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
11828
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
11787
11829
|
for (const clause of ast.clauses) {
|
|
11788
11830
|
F2.printFilter(ast, () => PRINT_WORD(fromUsing));
|
|
11789
11831
|
if (clause.clauseType === "named") {
|
|
@@ -11801,7 +11843,7 @@ var namedGraphClause = {
|
|
|
11801
11843
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
11802
11844
|
const named2 = CONSUME(graph_exports.named);
|
|
11803
11845
|
const iri3 = SUBRULE(sourceSelector);
|
|
11804
|
-
return ACTION(() => C.
|
|
11846
|
+
return ACTION(() => C.astFactory.wrap(iri3, C.astFactory.sourceLocation(named2, iri3)));
|
|
11805
11847
|
}
|
|
11806
11848
|
};
|
|
11807
11849
|
var sourceSelector = {
|
|
@@ -11818,7 +11860,7 @@ function funcExpr1(func) {
|
|
|
11818
11860
|
CONSUME(symbols_exports.LParen);
|
|
11819
11861
|
const arg = SUBRULE(expression);
|
|
11820
11862
|
const close = CONSUME(symbols_exports.RParen);
|
|
11821
|
-
return ACTION(() => C.
|
|
11863
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
|
|
11822
11864
|
}
|
|
11823
11865
|
};
|
|
11824
11866
|
}
|
|
@@ -11832,7 +11874,7 @@ function funcExpr2(func) {
|
|
|
11832
11874
|
CONSUME(symbols_exports.comma);
|
|
11833
11875
|
const arg2 = SUBRULE2(expression);
|
|
11834
11876
|
const close = CONSUME(symbols_exports.RParen);
|
|
11835
|
-
return ACTION(() => C.
|
|
11877
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg1, arg2], C.astFactory.sourceLocation(operator, close)));
|
|
11836
11878
|
}
|
|
11837
11879
|
};
|
|
11838
11880
|
}
|
|
@@ -11848,7 +11890,7 @@ function funcExpr3(func) {
|
|
|
11848
11890
|
CONSUME2(symbols_exports.comma);
|
|
11849
11891
|
const arg3 = SUBRULE3(expression);
|
|
11850
11892
|
const close = CONSUME(symbols_exports.RParen);
|
|
11851
|
-
return ACTION(() => C.
|
|
11893
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg1, arg2, arg3], C.astFactory.sourceLocation(operator, close)));
|
|
11852
11894
|
}
|
|
11853
11895
|
};
|
|
11854
11896
|
}
|
|
@@ -11860,7 +11902,7 @@ function funcVar1(func) {
|
|
|
11860
11902
|
CONSUME(symbols_exports.LParen);
|
|
11861
11903
|
const arg = SUBRULE(var_);
|
|
11862
11904
|
const close = CONSUME(symbols_exports.RParen);
|
|
11863
|
-
return ACTION(() => C.
|
|
11905
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
|
|
11864
11906
|
}
|
|
11865
11907
|
};
|
|
11866
11908
|
}
|
|
@@ -11874,11 +11916,11 @@ function funcExprOrNil1(func) {
|
|
|
11874
11916
|
CONSUME(symbols_exports.LParen);
|
|
11875
11917
|
const arg = SUBRULE(expression);
|
|
11876
11918
|
const close = CONSUME(symbols_exports.RParen);
|
|
11877
|
-
return ACTION(() => C.
|
|
11919
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [arg], C.astFactory.sourceLocation(operator, close)));
|
|
11878
11920
|
} },
|
|
11879
11921
|
{ ALT: () => {
|
|
11880
11922
|
const nil2 = CONSUME(terminals_exports.nil);
|
|
11881
|
-
return ACTION(() => C.
|
|
11923
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil2)));
|
|
11882
11924
|
} }
|
|
11883
11925
|
]);
|
|
11884
11926
|
}
|
|
@@ -11890,7 +11932,7 @@ function funcNil1(func) {
|
|
|
11890
11932
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11891
11933
|
const operator = CONSUME(func);
|
|
11892
11934
|
const nil2 = CONSUME(terminals_exports.nil);
|
|
11893
|
-
return ACTION(() => C.
|
|
11935
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [], C.astFactory.sourceLocation(operator, nil2)));
|
|
11894
11936
|
}
|
|
11895
11937
|
};
|
|
11896
11938
|
}
|
|
@@ -11900,7 +11942,7 @@ function funcExprList1(func) {
|
|
|
11900
11942
|
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
11901
11943
|
const operator = CONSUME(func);
|
|
11902
11944
|
const args = SUBRULE(expressionList);
|
|
11903
|
-
return ACTION(() => C.
|
|
11945
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, args.val, C.astFactory.sourceLocation(operator, args)));
|
|
11904
11946
|
}
|
|
11905
11947
|
};
|
|
11906
11948
|
}
|
|
@@ -11918,7 +11960,7 @@ function funcExpr2or3(func) {
|
|
|
11918
11960
|
return SUBRULE3(expression);
|
|
11919
11961
|
});
|
|
11920
11962
|
const close = CONSUME(symbols_exports.RParen);
|
|
11921
|
-
return ACTION(() => C.
|
|
11963
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, arg3 ? [arg1, arg2, arg3] : [arg1, arg2], C.astFactory.sourceLocation(operator, close)));
|
|
11922
11964
|
}
|
|
11923
11965
|
};
|
|
11924
11966
|
}
|
|
@@ -11938,7 +11980,7 @@ function funcExpr3or4(func) {
|
|
|
11938
11980
|
return SUBRULE4(expression);
|
|
11939
11981
|
});
|
|
11940
11982
|
const close = CONSUME(symbols_exports.RParen);
|
|
11941
|
-
return ACTION(() => C.
|
|
11983
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, arg4 ? [arg1, arg2, arg3, arg4] : [arg1, arg2, arg3], C.astFactory.sourceLocation(operator, close)));
|
|
11942
11984
|
}
|
|
11943
11985
|
};
|
|
11944
11986
|
}
|
|
@@ -11948,7 +11990,7 @@ function funcGroupGraphPattern(func) {
|
|
|
11948
11990
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
11949
11991
|
const operator = CONSUME(func);
|
|
11950
11992
|
const group = SUBRULE(groupGraphPattern);
|
|
11951
|
-
return ACTION(() => C.
|
|
11993
|
+
return ACTION(() => C.astFactory.expressionPatternOperation(operator.image, group, C.astFactory.sourceLocation(operator, group)));
|
|
11952
11994
|
}
|
|
11953
11995
|
};
|
|
11954
11996
|
}
|
|
@@ -11961,7 +12003,7 @@ function baseAggregateFunc(func) {
|
|
|
11961
12003
|
const distinct2 = OPTION(() => CONSUME(distinct));
|
|
11962
12004
|
const expr1 = SUBRULE(expression);
|
|
11963
12005
|
const close = CONSUME(symbols_exports.RParen);
|
|
11964
|
-
return ACTION(() => C.
|
|
12006
|
+
return ACTION(() => C.astFactory.aggregate(operator.image, distinct2 !== void 0, expr1, void 0, C.astFactory.sourceLocation(operator, close)));
|
|
11965
12007
|
}
|
|
11966
12008
|
};
|
|
11967
12009
|
}
|
|
@@ -12101,17 +12143,17 @@ var aggregateCount = {
|
|
|
12101
12143
|
const expressionVal = OR([
|
|
12102
12144
|
{ ALT: () => {
|
|
12103
12145
|
const starToken = CONSUME(symbols_exports.star);
|
|
12104
|
-
return ACTION(() => C.
|
|
12146
|
+
return ACTION(() => C.astFactory.wildcard(C.astFactory.sourceLocation(starToken)));
|
|
12105
12147
|
} },
|
|
12106
12148
|
{ ALT: () => SUBRULE(expression) }
|
|
12107
12149
|
]);
|
|
12108
12150
|
const closeToken = CONSUME(symbols_exports.RParen);
|
|
12109
12151
|
return ACTION(() => {
|
|
12110
|
-
const F2 = C.
|
|
12111
|
-
if (C.
|
|
12112
|
-
return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.
|
|
12152
|
+
const F2 = C.astFactory;
|
|
12153
|
+
if (C.astFactory.isWildcard(expressionVal)) {
|
|
12154
|
+
return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.astFactory.sourceLocation(operatorToken, closeToken));
|
|
12113
12155
|
}
|
|
12114
|
-
return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.
|
|
12156
|
+
return F2.aggregate(operatorToken.image, Boolean(distinctToken), expressionVal, void 0, C.astFactory.sourceLocation(operatorToken, closeToken));
|
|
12115
12157
|
});
|
|
12116
12158
|
}
|
|
12117
12159
|
};
|
|
@@ -12135,7 +12177,7 @@ var aggregateGroup_concat = {
|
|
|
12135
12177
|
});
|
|
12136
12178
|
const closeToken = CONSUME(symbols_exports.RParen);
|
|
12137
12179
|
return ACTION(() => {
|
|
12138
|
-
const F2 = C.
|
|
12180
|
+
const F2 = C.astFactory;
|
|
12139
12181
|
return F2.aggregate(operatorToken.image, Boolean(distinctToken), expr, sep?.value ?? " ", F2.sourceLocation(operatorToken, closeToken));
|
|
12140
12182
|
});
|
|
12141
12183
|
}
|
|
@@ -12165,7 +12207,7 @@ var aggregate = {
|
|
|
12165
12207
|
});
|
|
12166
12208
|
return result;
|
|
12167
12209
|
},
|
|
12168
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12210
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12169
12211
|
F2.printFilter(ast, () => {
|
|
12170
12212
|
PRINT_WORD(ast.aggregation.toUpperCase(), "(");
|
|
12171
12213
|
if (ast.distinct) {
|
|
@@ -12192,7 +12234,7 @@ var path = {
|
|
|
12192
12234
|
};
|
|
12193
12235
|
var pathGenerator = {
|
|
12194
12236
|
name: "path",
|
|
12195
|
-
gImpl: ({ PRINT, SUBRULE }) => (ast, {
|
|
12237
|
+
gImpl: ({ PRINT, SUBRULE }) => (ast, { astFactory: F2 }, braces = true) => {
|
|
12196
12238
|
if (F2.isTerm(ast) && F2.isTermNamed(ast)) {
|
|
12197
12239
|
SUBRULE(iri2, ast);
|
|
12198
12240
|
} else {
|
|
@@ -12241,7 +12283,7 @@ function pathChainHelper(name, SEP, subType, subRule) {
|
|
|
12241
12283
|
tailEnd = SUBRULE2(subRule);
|
|
12242
12284
|
tail.push(tailEnd);
|
|
12243
12285
|
});
|
|
12244
|
-
return ACTION(() => tail.length === 0 ? head2 : C.
|
|
12286
|
+
return ACTION(() => tail.length === 0 ? head2 : C.astFactory.path(subType, [head2, ...tail], C.astFactory.sourceLocation(head2, tailEnd)));
|
|
12245
12287
|
}
|
|
12246
12288
|
};
|
|
12247
12289
|
}
|
|
@@ -12252,7 +12294,7 @@ var pathEltOrInverse = {
|
|
|
12252
12294
|
{ ALT: () => {
|
|
12253
12295
|
const hat2 = CONSUME(symbols_exports.hat);
|
|
12254
12296
|
const item = SUBRULE2(pathElt);
|
|
12255
|
-
return ACTION(() => C.
|
|
12297
|
+
return ACTION(() => C.astFactory.path("^", [item], C.astFactory.sourceLocation(hat2, item)));
|
|
12256
12298
|
} }
|
|
12257
12299
|
])
|
|
12258
12300
|
};
|
|
@@ -12263,7 +12305,7 @@ var pathElt = {
|
|
|
12263
12305
|
impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
|
|
12264
12306
|
const item = SUBRULE(pathPrimary);
|
|
12265
12307
|
const modification = OPTION(() => SUBRULE(pathMod));
|
|
12266
|
-
return ACTION(() => modification === void 0 ? item : C.
|
|
12308
|
+
return ACTION(() => modification === void 0 ? item : C.astFactory.path(modification.image, [item], C.astFactory.sourceLocation(item, modification)));
|
|
12267
12309
|
}
|
|
12268
12310
|
};
|
|
12269
12311
|
var pathMod = {
|
|
@@ -12295,7 +12337,7 @@ var pathNegatedPropertySet = {
|
|
|
12295
12337
|
return OR([
|
|
12296
12338
|
{ ALT: () => {
|
|
12297
12339
|
const noAlternative = SUBRULE1(pathOneInPropertySet);
|
|
12298
|
-
return ACTION(() => C.
|
|
12340
|
+
return ACTION(() => C.astFactory.path("!", [noAlternative], C.astFactory.sourceLocation(exclamation2, noAlternative)));
|
|
12299
12341
|
} },
|
|
12300
12342
|
{ ALT: () => {
|
|
12301
12343
|
const open = CONSUME(symbols_exports.LParen);
|
|
@@ -12308,7 +12350,7 @@ var pathNegatedPropertySet = {
|
|
|
12308
12350
|
});
|
|
12309
12351
|
const close = CONSUME(symbols_exports.RParen);
|
|
12310
12352
|
return ACTION(() => {
|
|
12311
|
-
const F2 = C.
|
|
12353
|
+
const F2 = C.astFactory;
|
|
12312
12354
|
if (tail.length === 0) {
|
|
12313
12355
|
return F2.path("!", [head2], F2.sourceLocation(exclamation2, close));
|
|
12314
12356
|
}
|
|
@@ -12329,7 +12371,7 @@ var pathOneInPropertySet = {
|
|
|
12329
12371
|
{ ALT: () => SUBRULE2(iri2) },
|
|
12330
12372
|
{ ALT: () => SUBRULE2(verbA) }
|
|
12331
12373
|
]);
|
|
12332
|
-
return ACTION(() => C.
|
|
12374
|
+
return ACTION(() => C.astFactory.path("^", [item], C.astFactory.sourceLocation(hat2, item)));
|
|
12333
12375
|
} }
|
|
12334
12376
|
])
|
|
12335
12377
|
};
|
|
@@ -12354,33 +12396,35 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12354
12396
|
});
|
|
12355
12397
|
}
|
|
12356
12398
|
});
|
|
12357
|
-
return ACTION(() => C.
|
|
12399
|
+
return ACTION(() => C.astFactory.patternBgp(triples, C.astFactory.sourceLocation(...triples, dotToken)));
|
|
12358
12400
|
};
|
|
12359
12401
|
}
|
|
12360
12402
|
var triplesBlock = {
|
|
12361
12403
|
name: "triplesBlock",
|
|
12362
12404
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12363
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, {
|
|
12405
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F2 }) => {
|
|
12364
12406
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12365
12407
|
HANDLE_LOC(triple, () => {
|
|
12366
12408
|
const nextTriple = ast.triples.at(index);
|
|
12367
12409
|
if (F2.isTripleCollection(triple)) {
|
|
12368
12410
|
SUBRULE(graphNodePath, triple);
|
|
12369
|
-
F2.printFilter(triple, () => PRINT_WORD("
|
|
12411
|
+
F2.printFilter(triple, () => PRINT_WORD(".\n"));
|
|
12370
12412
|
} else {
|
|
12371
12413
|
SUBRULE(graphNodePath, triple.subject);
|
|
12414
|
+
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12372
12415
|
if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
|
|
12373
12416
|
SUBRULE(varOrTerm, triple.predicate);
|
|
12374
12417
|
} else {
|
|
12375
12418
|
SUBRULE(pathGenerator, triple.predicate, void 0);
|
|
12376
12419
|
}
|
|
12420
|
+
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12377
12421
|
SUBRULE(graphNodePath, triple.object);
|
|
12378
12422
|
if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12379
|
-
F2.printFilter(ast, () => PRINT_WORD("
|
|
12423
|
+
F2.printFilter(ast, () => PRINT_WORD(".\n"));
|
|
12380
12424
|
} else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12381
12425
|
F2.printFilter(ast, () => PRINT_WORD(","));
|
|
12382
12426
|
} else {
|
|
12383
|
-
F2.printFilter(ast, () => PRINT_WORD("
|
|
12427
|
+
F2.printFilter(ast, () => PRINT_WORD(";\n"));
|
|
12384
12428
|
}
|
|
12385
12429
|
}
|
|
12386
12430
|
});
|
|
@@ -12393,24 +12437,24 @@ function triplesSameSubjectImpl(name, allowPaths) {
|
|
|
12393
12437
|
impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
|
|
12394
12438
|
{ ALT: () => {
|
|
12395
12439
|
const subject = SUBRULE(varOrTerm);
|
|
12396
|
-
const res = SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, ACTION(() => C.
|
|
12440
|
+
const res = SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, ACTION(() => C.astFactory.dematerialized(subject)));
|
|
12397
12441
|
return ACTION(() => {
|
|
12398
12442
|
if (res.length > 0) {
|
|
12399
12443
|
res[0].subject = subject;
|
|
12400
|
-
res[0].loc = C.
|
|
12444
|
+
res[0].loc = C.astFactory.sourceLocation(subject, res[0]);
|
|
12401
12445
|
}
|
|
12402
12446
|
return res;
|
|
12403
12447
|
});
|
|
12404
12448
|
} },
|
|
12405
12449
|
{ ALT: () => {
|
|
12406
12450
|
const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode);
|
|
12407
|
-
const restNode = SUBRULE(allowPaths ? propertyListPath : propertyList, ACTION(() => C.
|
|
12451
|
+
const restNode = SUBRULE(allowPaths ? propertyListPath : propertyList, ACTION(() => C.astFactory.graphNodeIdentifier(subjectNode)));
|
|
12408
12452
|
return ACTION(() => {
|
|
12409
12453
|
if (restNode.length === 0) {
|
|
12410
12454
|
return [subjectNode];
|
|
12411
12455
|
}
|
|
12412
12456
|
restNode[0].subject = subjectNode;
|
|
12413
|
-
restNode[0].loc = C.
|
|
12457
|
+
restNode[0].loc = C.astFactory.sourceLocation(subjectNode, restNode[0]);
|
|
12414
12458
|
return restNode;
|
|
12415
12459
|
});
|
|
12416
12460
|
} }
|
|
@@ -12494,7 +12538,7 @@ function objectImpl(name, allowPaths) {
|
|
|
12494
12538
|
name,
|
|
12495
12539
|
impl: ({ ACTION, SUBRULE }) => (C, subject, predicate) => {
|
|
12496
12540
|
const node = SUBRULE(allowPaths ? graphNodePath : graphNode);
|
|
12497
|
-
return ACTION(() => C.
|
|
12541
|
+
return ACTION(() => C.astFactory.triple(subject, predicate, node));
|
|
12498
12542
|
}
|
|
12499
12543
|
};
|
|
12500
12544
|
}
|
|
@@ -12511,7 +12555,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12511
12555
|
});
|
|
12512
12556
|
const endToken = CONSUME(symbols_exports.RParen);
|
|
12513
12557
|
return ACTION(() => {
|
|
12514
|
-
const F2 = C.
|
|
12558
|
+
const F2 = C.astFactory;
|
|
12515
12559
|
const triples = [];
|
|
12516
12560
|
const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12517
12561
|
const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
@@ -12535,7 +12579,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12535
12579
|
return F2.tripleCollectionList(listHead, triples, F2.sourceLocation(startToken, endToken));
|
|
12536
12580
|
});
|
|
12537
12581
|
},
|
|
12538
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12582
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12539
12583
|
F2.printFilter(ast, () => PRINT_WORD("("));
|
|
12540
12584
|
for (const [idx, triple] of ast.triples.entries()) {
|
|
12541
12585
|
if (idx % 2 === 0) {
|
|
@@ -12566,13 +12610,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12566
12610
|
name,
|
|
12567
12611
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12568
12612
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12569
|
-
const blankNode2 = ACTION(() => C.
|
|
12613
|
+
const blankNode2 = ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12570
12614
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12571
12615
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12572
|
-
return ACTION(() => C.
|
|
12616
|
+
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12573
12617
|
},
|
|
12574
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC }) => (ast,
|
|
12575
|
-
F2
|
|
12618
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
12619
|
+
const { astFactory: F2, indentInc } = c;
|
|
12620
|
+
F2.printFilter(ast, () => {
|
|
12621
|
+
c[traqulaIndentation] += indentInc;
|
|
12622
|
+
PRINT("[\n");
|
|
12623
|
+
});
|
|
12576
12624
|
for (const triple of ast.triples) {
|
|
12577
12625
|
HANDLE_LOC(triple, () => {
|
|
12578
12626
|
if (F2.isTerm(triple.predicate) && F2.isTermVariable(triple.predicate)) {
|
|
@@ -12580,11 +12628,15 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12580
12628
|
} else {
|
|
12581
12629
|
SUBRULE(pathGenerator, triple.predicate, void 0);
|
|
12582
12630
|
}
|
|
12631
|
+
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12583
12632
|
SUBRULE(graphNodePath, triple.object);
|
|
12584
|
-
F2.printFilter(ast, () => PRINT_WORD("
|
|
12633
|
+
F2.printFilter(ast, () => PRINT_WORD(";\n"));
|
|
12585
12634
|
});
|
|
12586
12635
|
}
|
|
12587
|
-
F2.printFilter(ast, () =>
|
|
12636
|
+
F2.printFilter(ast, () => {
|
|
12637
|
+
c[traqulaIndentation] -= indentInc;
|
|
12638
|
+
PRINT_ON_EMPTY("]");
|
|
12639
|
+
});
|
|
12588
12640
|
}
|
|
12589
12641
|
};
|
|
12590
12642
|
}
|
|
@@ -12601,7 +12653,7 @@ function graphNodeImpl(name, allowPaths) {
|
|
|
12601
12653
|
ALT: () => SUBRULE(triplesNodeRule)
|
|
12602
12654
|
}
|
|
12603
12655
|
]),
|
|
12604
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
12656
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
12605
12657
|
if (F2.isTerm(ast)) {
|
|
12606
12658
|
SUBRULE(varOrTerm, ast);
|
|
12607
12659
|
} else {
|
|
@@ -12619,9 +12671,9 @@ var whereClause = {
|
|
|
12619
12671
|
impl: ({ ACTION, SUBRULE, CONSUME, OPTION }) => (C) => {
|
|
12620
12672
|
const where2 = OPTION(() => CONSUME(where));
|
|
12621
12673
|
const group = SUBRULE(groupGraphPattern);
|
|
12622
|
-
return ACTION(() => C.
|
|
12674
|
+
return ACTION(() => C.astFactory.wrap(group, C.astFactory.sourceLocation(where2, group)));
|
|
12623
12675
|
},
|
|
12624
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12676
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12625
12677
|
F2.printFilter(ast, () => PRINT_WORD("WHERE"));
|
|
12626
12678
|
SUBRULE(groupGraphPattern, ast.val);
|
|
12627
12679
|
}
|
|
@@ -12635,19 +12687,26 @@ var groupGraphPattern = {
|
|
|
12635
12687
|
{ ALT: () => SUBRULE(groupGraphPatternSub) }
|
|
12636
12688
|
]);
|
|
12637
12689
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12638
|
-
return ACTION(() => C.
|
|
12690
|
+
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12639
12691
|
},
|
|
12640
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast,
|
|
12641
|
-
F2
|
|
12692
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
12693
|
+
const { astFactory: F2, indentInc } = C;
|
|
12694
|
+
F2.printFilter(ast, () => {
|
|
12695
|
+
C[traqulaIndentation] += indentInc;
|
|
12696
|
+
PRINT_WORD("{\n");
|
|
12697
|
+
});
|
|
12642
12698
|
for (const pattern of ast.patterns) {
|
|
12643
12699
|
SUBRULE(generatePattern, pattern);
|
|
12644
12700
|
}
|
|
12645
|
-
F2.printFilter(ast, () =>
|
|
12701
|
+
F2.printFilter(ast, () => {
|
|
12702
|
+
C[traqulaIndentation] -= indentInc;
|
|
12703
|
+
PRINT_ON_EMPTY("}\n");
|
|
12704
|
+
});
|
|
12646
12705
|
}
|
|
12647
12706
|
};
|
|
12648
12707
|
var generatePattern = {
|
|
12649
12708
|
name: "generatePattern",
|
|
12650
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
12709
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
12651
12710
|
if (ast.type === "query") {
|
|
12652
12711
|
SUBRULE(query, F2.querySelect({
|
|
12653
12712
|
context: [],
|
|
@@ -12736,9 +12795,9 @@ var optionalGraphPattern = {
|
|
|
12736
12795
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12737
12796
|
const optional2 = CONSUME(optional);
|
|
12738
12797
|
const group = SUBRULE(groupGraphPattern);
|
|
12739
|
-
return ACTION(() => C.
|
|
12798
|
+
return ACTION(() => C.astFactory.patternOptional(group.patterns, C.astFactory.sourceLocation(optional2, group)));
|
|
12740
12799
|
},
|
|
12741
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12800
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12742
12801
|
F2.printFilter(ast, () => PRINT_WORD("OPTIONAL"));
|
|
12743
12802
|
SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
|
|
12744
12803
|
}
|
|
@@ -12749,9 +12808,9 @@ var graphGraphPattern = {
|
|
|
12749
12808
|
const graph2 = CONSUME(graph_exports.graph);
|
|
12750
12809
|
const name = SUBRULE(varOrIri);
|
|
12751
12810
|
const group = SUBRULE(groupGraphPattern);
|
|
12752
|
-
return ACTION(() => C.
|
|
12811
|
+
return ACTION(() => C.astFactory.patternGraph(name, group.patterns, C.astFactory.sourceLocation(graph2, group)));
|
|
12753
12812
|
},
|
|
12754
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12813
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12755
12814
|
F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
12756
12815
|
SUBRULE(varOrTerm, ast.name);
|
|
12757
12816
|
SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
|
|
@@ -12767,9 +12826,9 @@ var serviceGraphPattern = {
|
|
|
12767
12826
|
}) ?? false;
|
|
12768
12827
|
const name = SUBRULE1(varOrIri);
|
|
12769
12828
|
const group = SUBRULE1(groupGraphPattern);
|
|
12770
|
-
return ACTION(() => C.
|
|
12829
|
+
return ACTION(() => C.astFactory.patternService(name, group.patterns, silent2, C.astFactory.sourceLocation(service2, group)));
|
|
12771
12830
|
},
|
|
12772
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12831
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12773
12832
|
F2.printFilter(ast, () => {
|
|
12774
12833
|
PRINT_WORD("SERVICE");
|
|
12775
12834
|
if (ast.silent) {
|
|
@@ -12789,14 +12848,14 @@ var bind2 = {
|
|
|
12789
12848
|
CONSUME(as);
|
|
12790
12849
|
const variable = SUBRULE(var_);
|
|
12791
12850
|
const close = CONSUME(symbols_exports.RParen);
|
|
12792
|
-
return ACTION(() => C.
|
|
12851
|
+
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
12793
12852
|
},
|
|
12794
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12853
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12795
12854
|
F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
12796
12855
|
SUBRULE(expression, ast.expression);
|
|
12797
12856
|
F2.printFilter(ast, () => PRINT_WORD("AS"));
|
|
12798
12857
|
SUBRULE(var_, ast.variable);
|
|
12799
|
-
F2.printFilter(ast, () => PRINT_WORD(")"));
|
|
12858
|
+
F2.printFilter(ast, () => PRINT_WORD(")\n"));
|
|
12800
12859
|
}
|
|
12801
12860
|
};
|
|
12802
12861
|
var inlineData = {
|
|
@@ -12804,16 +12863,19 @@ var inlineData = {
|
|
|
12804
12863
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12805
12864
|
const values3 = CONSUME(values2);
|
|
12806
12865
|
const datablock = SUBRULE(dataBlock);
|
|
12807
|
-
return ACTION(() => C.
|
|
12866
|
+
return ACTION(() => C.astFactory.patternValues(datablock.val, C.astFactory.sourceLocation(values3, datablock)));
|
|
12808
12867
|
},
|
|
12809
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast,
|
|
12868
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
12869
|
+
const { astFactory: F2, indentInc } = C;
|
|
12810
12870
|
const variables = Object.keys(ast.values.at(0) ?? {});
|
|
12811
12871
|
F2.printFilter(ast, () => {
|
|
12872
|
+
PRINT_ON_EMPTY("");
|
|
12812
12873
|
PRINT_WORD("VALUES", "(");
|
|
12813
12874
|
for (const variable of variables) {
|
|
12814
12875
|
PRINT_WORD(`?${variable}`);
|
|
12815
12876
|
}
|
|
12816
|
-
|
|
12877
|
+
C[traqulaIndentation] += indentInc;
|
|
12878
|
+
PRINT_WORD(")", "{\n");
|
|
12817
12879
|
});
|
|
12818
12880
|
for (const mapping of ast.values) {
|
|
12819
12881
|
F2.printFilter(ast, () => PRINT_WORD("("));
|
|
@@ -12824,9 +12886,12 @@ var inlineData = {
|
|
|
12824
12886
|
SUBRULE(graphNodePath, mapping[variable]);
|
|
12825
12887
|
}
|
|
12826
12888
|
}
|
|
12827
|
-
F2.printFilter(ast, () => PRINT_WORD(")"));
|
|
12889
|
+
F2.printFilter(ast, () => PRINT_WORD(")\n"));
|
|
12828
12890
|
}
|
|
12829
|
-
F2.printFilter(ast, () =>
|
|
12891
|
+
F2.printFilter(ast, () => {
|
|
12892
|
+
C[traqulaIndentation] -= indentInc;
|
|
12893
|
+
PRINT_ON_EMPTY("}\n");
|
|
12894
|
+
});
|
|
12830
12895
|
}
|
|
12831
12896
|
};
|
|
12832
12897
|
var dataBlock = {
|
|
@@ -12849,7 +12914,7 @@ var inlineDataOneVar = {
|
|
|
12849
12914
|
});
|
|
12850
12915
|
});
|
|
12851
12916
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12852
|
-
return ACTION(() => C.
|
|
12917
|
+
return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(varVal, close)));
|
|
12853
12918
|
}
|
|
12854
12919
|
};
|
|
12855
12920
|
var inlineDataFull = {
|
|
@@ -12866,7 +12931,7 @@ var inlineDataFull = {
|
|
|
12866
12931
|
res.push({});
|
|
12867
12932
|
});
|
|
12868
12933
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
12869
|
-
return ACTION(() => C.
|
|
12934
|
+
return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(nil2, close)));
|
|
12870
12935
|
} },
|
|
12871
12936
|
{ ALT: () => {
|
|
12872
12937
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -12898,7 +12963,7 @@ var inlineDataFull = {
|
|
|
12898
12963
|
});
|
|
12899
12964
|
});
|
|
12900
12965
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
12901
|
-
return ACTION(() => C.
|
|
12966
|
+
return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(open, close)));
|
|
12902
12967
|
} }
|
|
12903
12968
|
]);
|
|
12904
12969
|
}
|
|
@@ -12921,9 +12986,9 @@ var minusGraphPattern = {
|
|
|
12921
12986
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12922
12987
|
const minus2 = CONSUME(minus);
|
|
12923
12988
|
const group = SUBRULE(groupGraphPattern);
|
|
12924
|
-
return ACTION(() => C.
|
|
12989
|
+
return ACTION(() => C.astFactory.patternMinus(group.patterns, C.astFactory.sourceLocation(minus2, group)));
|
|
12925
12990
|
},
|
|
12926
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
12991
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12927
12992
|
F2.printFilter(ast, () => PRINT_WORD("MINUS"));
|
|
12928
12993
|
SUBRULE(groupGraphPattern, F2.patternGroup(ast.patterns, ast.loc));
|
|
12929
12994
|
}
|
|
@@ -12939,9 +13004,9 @@ var groupOrUnionGraphPattern = {
|
|
|
12939
13004
|
const group2 = SUBRULE2(groupGraphPattern);
|
|
12940
13005
|
groups.push(group2);
|
|
12941
13006
|
});
|
|
12942
|
-
return ACTION(() => groups.length === 1 ? groups[0] : C.
|
|
13007
|
+
return ACTION(() => groups.length === 1 ? groups[0] : C.astFactory.patternUnion(groups, C.astFactory.sourceLocation(group, groups.at(-1))));
|
|
12943
13008
|
},
|
|
12944
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13009
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12945
13010
|
if (F2.isPatternUnion(ast)) {
|
|
12946
13011
|
const [head2, ...tail] = ast.patterns;
|
|
12947
13012
|
SUBRULE(groupGraphPattern, head2);
|
|
@@ -12959,12 +13024,12 @@ var filter3 = {
|
|
|
12959
13024
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12960
13025
|
const filterToken = CONSUME(filter2);
|
|
12961
13026
|
const expression2 = SUBRULE(constraint);
|
|
12962
|
-
return ACTION(() => C.
|
|
13027
|
+
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
12963
13028
|
},
|
|
12964
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13029
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
12965
13030
|
F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
12966
13031
|
SUBRULE(expression, ast.expression);
|
|
12967
|
-
F2.printFilter(ast, () => PRINT_WORD(")"));
|
|
13032
|
+
F2.printFilter(ast, () => PRINT_WORD(")\n"));
|
|
12968
13033
|
}
|
|
12969
13034
|
};
|
|
12970
13035
|
var constraint = {
|
|
@@ -12980,7 +13045,7 @@ var functionCall = {
|
|
|
12980
13045
|
impl: ({ ACTION, SUBRULE }) => (C) => {
|
|
12981
13046
|
const func = SUBRULE(iri2);
|
|
12982
13047
|
const args = SUBRULE(argList);
|
|
12983
|
-
return ACTION(() => C.
|
|
13048
|
+
return ACTION(() => C.astFactory.expressionFunctionCall(func, args.val.args, args.val.distinct, C.astFactory.sourceLocation(func, args)));
|
|
12984
13049
|
}
|
|
12985
13050
|
};
|
|
12986
13051
|
|
|
@@ -12990,7 +13055,7 @@ var argList = {
|
|
|
12990
13055
|
impl: ({ ACTION, CONSUME, SUBRULE1, OPTION, OR, AT_LEAST_ONE_SEP }) => (C) => OR([
|
|
12991
13056
|
{ ALT: () => {
|
|
12992
13057
|
const nil2 = CONSUME(terminals_exports.nil);
|
|
12993
|
-
return ACTION(() => C.
|
|
13058
|
+
return ACTION(() => C.astFactory.wrap({ args: [], distinct: false }, C.astFactory.sourceLocation(nil2)));
|
|
12994
13059
|
} },
|
|
12995
13060
|
{ ALT: () => {
|
|
12996
13061
|
const args = [];
|
|
@@ -13007,10 +13072,10 @@ var argList = {
|
|
|
13007
13072
|
}
|
|
13008
13073
|
});
|
|
13009
13074
|
const close = CONSUME(symbols_exports.RParen);
|
|
13010
|
-
return ACTION(() => C.
|
|
13075
|
+
return ACTION(() => C.astFactory.wrap({ args, distinct: distinct2 }, C.astFactory.sourceLocation(open, close)));
|
|
13011
13076
|
} }
|
|
13012
13077
|
]),
|
|
13013
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13078
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13014
13079
|
F2.printFilter(ast, () => {
|
|
13015
13080
|
PRINT_WORD("(");
|
|
13016
13081
|
if (ast.val.distinct) {
|
|
@@ -13033,7 +13098,7 @@ var expressionList = {
|
|
|
13033
13098
|
impl: ({ ACTION, CONSUME, MANY, OR, SUBRULE1, SUBRULE2 }) => (C) => OR([
|
|
13034
13099
|
{ ALT: () => {
|
|
13035
13100
|
const nil2 = CONSUME(terminals_exports.nil);
|
|
13036
|
-
return ACTION(() => C.
|
|
13101
|
+
return ACTION(() => C.astFactory.wrap([], C.astFactory.sourceLocation(nil2)));
|
|
13037
13102
|
} },
|
|
13038
13103
|
{ ALT: () => {
|
|
13039
13104
|
const open = CONSUME(symbols_exports.LParen);
|
|
@@ -13045,7 +13110,7 @@ var expressionList = {
|
|
|
13045
13110
|
args.push(expr);
|
|
13046
13111
|
});
|
|
13047
13112
|
const close = CONSUME(symbols_exports.RParen);
|
|
13048
|
-
return ACTION(() => C.
|
|
13113
|
+
return ACTION(() => C.astFactory.wrap(args, C.astFactory.sourceLocation(open, close)));
|
|
13049
13114
|
} }
|
|
13050
13115
|
])
|
|
13051
13116
|
};
|
|
@@ -13054,7 +13119,7 @@ var prefixOperator = /* @__PURE__ */ new Set(["!", "UPLUS", "UMINUS"]);
|
|
|
13054
13119
|
var expression = {
|
|
13055
13120
|
name: "expression",
|
|
13056
13121
|
impl: ({ SUBRULE }) => () => SUBRULE(conditionalOrExpression),
|
|
13057
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13122
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13058
13123
|
if (F2.isTerm(ast)) {
|
|
13059
13124
|
SUBRULE(varOrTerm, ast);
|
|
13060
13125
|
} else if (F2.isExpressionOperator(ast)) {
|
|
@@ -13119,7 +13184,7 @@ var conditionalOrExpression = {
|
|
|
13119
13184
|
impl: ({ ACTION, MANY, CONSUME, SUBRULE1, SUBRULE2 }) => (C) => constructLeftDeep(() => SUBRULE1(conditionalAndExpression), () => {
|
|
13120
13185
|
CONSUME(symbols_exports.logicOr);
|
|
13121
13186
|
const args = SUBRULE2(conditionalAndExpression);
|
|
13122
|
-
return (left) => ACTION(() => C.
|
|
13187
|
+
return (left) => ACTION(() => C.astFactory.expressionOperation("||", [left, args], C.astFactory.sourceLocation(left, args)));
|
|
13123
13188
|
}, ACTION, MANY)
|
|
13124
13189
|
};
|
|
13125
13190
|
var conditionalAndExpression = {
|
|
@@ -13127,7 +13192,7 @@ var conditionalAndExpression = {
|
|
|
13127
13192
|
impl: ({ ACTION, MANY, SUBRULE1, SUBRULE2, CONSUME }) => (C) => constructLeftDeep(() => SUBRULE1(valueLogical), () => {
|
|
13128
13193
|
CONSUME(symbols_exports.logicAnd);
|
|
13129
13194
|
const arg = SUBRULE2(valueLogical);
|
|
13130
|
-
return (left) => ACTION(() => C.
|
|
13195
|
+
return (left) => ACTION(() => C.astFactory.expressionOperation("&&", [left, arg], C.astFactory.sourceLocation(left, arg)));
|
|
13131
13196
|
}, ACTION, MANY)
|
|
13132
13197
|
};
|
|
13133
13198
|
var valueLogical = {
|
|
@@ -13149,7 +13214,7 @@ var relationalExpression = {
|
|
|
13149
13214
|
{ ALT: () => CONSUME(symbols_exports.greaterThanEqual) }
|
|
13150
13215
|
]);
|
|
13151
13216
|
const expr = SUBRULE2(numericExpression);
|
|
13152
|
-
return ACTION(() => C.
|
|
13217
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [args1, expr], C.astFactory.sourceLocation(args1, expr)));
|
|
13153
13218
|
} },
|
|
13154
13219
|
{ ALT: () => {
|
|
13155
13220
|
const operator = OR3([
|
|
@@ -13157,7 +13222,7 @@ var relationalExpression = {
|
|
|
13157
13222
|
{ ALT: () => CONSUME(notIn) }
|
|
13158
13223
|
]);
|
|
13159
13224
|
const args = SUBRULE1(expressionList);
|
|
13160
|
-
return ACTION(() => C.
|
|
13225
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image, [args1, ...args.val], C.astFactory.sourceLocation(args1, args)));
|
|
13161
13226
|
} }
|
|
13162
13227
|
]));
|
|
13163
13228
|
return expression2 ?? args1;
|
|
@@ -13176,7 +13241,7 @@ var additiveExpression = {
|
|
|
13176
13241
|
{ ALT: () => CONSUME(symbols_exports.opMinus) }
|
|
13177
13242
|
]);
|
|
13178
13243
|
const arg = SUBRULE2(multiplicativeExpression);
|
|
13179
|
-
return ACTION(() => (left) => C.
|
|
13244
|
+
return ACTION(() => (left) => C.astFactory.expressionOperation(operator.image, [left, arg], C.astFactory.sourceLocation(left, arg)));
|
|
13180
13245
|
} },
|
|
13181
13246
|
{ ALT: () => {
|
|
13182
13247
|
const { operator, startInt } = OR3([
|
|
@@ -13207,9 +13272,9 @@ var additiveExpression = {
|
|
|
13207
13272
|
{ ALT: () => CONSUME(symbols_exports.slash) }
|
|
13208
13273
|
]);
|
|
13209
13274
|
const innerExpr = SUBRULE1(unaryExpression);
|
|
13210
|
-
return ACTION(() => (leftInner) => C.
|
|
13275
|
+
return ACTION(() => (leftInner) => C.astFactory.expressionOperation(innerOperator.image, [leftInner, innerExpr], C.astFactory.sourceLocation(leftInner, innerExpr)));
|
|
13211
13276
|
}, ACTION, MANY2);
|
|
13212
|
-
return (left) => C.
|
|
13277
|
+
return (left) => C.astFactory.expressionOperation(operator, [left, multiplicativeExpr], C.astFactory.sourceLocation(left, multiplicativeExpr));
|
|
13213
13278
|
} }
|
|
13214
13279
|
]), ACTION, MANY1)
|
|
13215
13280
|
};
|
|
@@ -13226,7 +13291,7 @@ var multiplicativeExpression = {
|
|
|
13226
13291
|
subType: "operation",
|
|
13227
13292
|
operator: operator.image,
|
|
13228
13293
|
args: [left, expr],
|
|
13229
|
-
loc: C.
|
|
13294
|
+
loc: C.astFactory.sourceLocation(left, expr)
|
|
13230
13295
|
});
|
|
13231
13296
|
}, ACTION, MANY)
|
|
13232
13297
|
};
|
|
@@ -13241,7 +13306,7 @@ var unaryExpression = {
|
|
|
13241
13306
|
{ ALT: () => CONSUME(symbols_exports.opMinus) }
|
|
13242
13307
|
]);
|
|
13243
13308
|
const expr = SUBRULE2(primaryExpression);
|
|
13244
|
-
return ACTION(() => C.
|
|
13309
|
+
return ACTION(() => C.astFactory.expressionOperation(operator.image === "!" ? "!" : operator.image === "+" ? "UPLUS" : "UMINUS", [expr], C.astFactory.sourceLocation(operator, expr)));
|
|
13245
13310
|
} }
|
|
13246
13311
|
])
|
|
13247
13312
|
};
|
|
@@ -13264,7 +13329,7 @@ var brackettedExpression = {
|
|
|
13264
13329
|
const expr = SUBRULE(expression);
|
|
13265
13330
|
const close = CONSUME(symbols_exports.RParen);
|
|
13266
13331
|
return ACTION(() => {
|
|
13267
|
-
expr.loc = C.
|
|
13332
|
+
expr.loc = C.astFactory.sourceLocation(open, close);
|
|
13268
13333
|
return expr;
|
|
13269
13334
|
});
|
|
13270
13335
|
}
|
|
@@ -13286,13 +13351,13 @@ var iriOrFunction = {
|
|
|
13286
13351
|
function: iriVal,
|
|
13287
13352
|
args: args.val.args,
|
|
13288
13353
|
distinct: distinct2,
|
|
13289
|
-
loc: C.
|
|
13354
|
+
loc: C.astFactory.sourceLocation(iriVal, args)
|
|
13290
13355
|
};
|
|
13291
13356
|
});
|
|
13292
13357
|
});
|
|
13293
13358
|
return functionCall2 ?? iriVal;
|
|
13294
13359
|
},
|
|
13295
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
13360
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13296
13361
|
if (F2.isTermNamed(ast)) {
|
|
13297
13362
|
SUBRULE(iri2, ast);
|
|
13298
13363
|
} else {
|
|
@@ -13345,11 +13410,14 @@ var groupClause = {
|
|
|
13345
13410
|
type: "solutionModifier",
|
|
13346
13411
|
subType: "group",
|
|
13347
13412
|
groupings,
|
|
13348
|
-
loc: C.
|
|
13413
|
+
loc: C.astFactory.sourceLocation(start, groupings.at(-1))
|
|
13349
13414
|
}));
|
|
13350
13415
|
},
|
|
13351
|
-
gImpl: ({ PRINT_WORDS, SUBRULE }) => (ast, {
|
|
13352
|
-
F2.printFilter(ast, () =>
|
|
13416
|
+
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13417
|
+
F2.printFilter(ast, () => {
|
|
13418
|
+
PRINT_ON_EMPTY("");
|
|
13419
|
+
PRINT_WORDS("GROUP", "BY");
|
|
13420
|
+
});
|
|
13353
13421
|
for (const grouping of ast.groupings) {
|
|
13354
13422
|
if (F2.isExpression(grouping)) {
|
|
13355
13423
|
SUBRULE(expression, grouping);
|
|
@@ -13383,7 +13451,7 @@ var groupCondition = {
|
|
|
13383
13451
|
return {
|
|
13384
13452
|
variable,
|
|
13385
13453
|
value: expressionValue,
|
|
13386
|
-
loc: C.
|
|
13454
|
+
loc: C.astFactory.sourceLocation(open, close)
|
|
13387
13455
|
};
|
|
13388
13456
|
}
|
|
13389
13457
|
return expressionValue;
|
|
@@ -13402,10 +13470,13 @@ var havingClause = {
|
|
|
13402
13470
|
expressions.push(SUBRULE(havingCondition));
|
|
13403
13471
|
});
|
|
13404
13472
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13405
|
-
return ACTION(() => C.
|
|
13473
|
+
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13406
13474
|
},
|
|
13407
|
-
gImpl: ({ PRINT_WORD, SUBRULE }) => (ast, {
|
|
13408
|
-
F2.printFilter(ast, () =>
|
|
13475
|
+
gImpl: ({ PRINT_WORD, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13476
|
+
F2.printFilter(ast, () => {
|
|
13477
|
+
PRINT_ON_EMPTY("");
|
|
13478
|
+
PRINT_WORD("HAVING");
|
|
13479
|
+
});
|
|
13409
13480
|
for (const having2 of ast.having) {
|
|
13410
13481
|
SUBRULE(expression, having2);
|
|
13411
13482
|
}
|
|
@@ -13426,10 +13497,13 @@ var orderClause = {
|
|
|
13426
13497
|
orderings.push(SUBRULE1(orderCondition));
|
|
13427
13498
|
});
|
|
13428
13499
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13429
|
-
return ACTION(() => C.
|
|
13500
|
+
return ACTION(() => C.astFactory.solutionModifierOrder(orderings, C.astFactory.sourceLocation(order2, orderings.at(-1))));
|
|
13430
13501
|
},
|
|
13431
|
-
gImpl: ({ PRINT_WORDS, SUBRULE }) => (ast, {
|
|
13432
|
-
F2.printFilter(ast, () =>
|
|
13502
|
+
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13503
|
+
F2.printFilter(ast, () => {
|
|
13504
|
+
PRINT_ON_EMPTY("");
|
|
13505
|
+
PRINT_WORDS("ORDER", "BY");
|
|
13506
|
+
});
|
|
13433
13507
|
for (const ordering of ast.orderDefs) {
|
|
13434
13508
|
if (ordering.descending) {
|
|
13435
13509
|
F2.printFilter(ast, () => PRINT_WORDS("DESC"));
|
|
@@ -13460,7 +13534,7 @@ var orderCondition = {
|
|
|
13460
13534
|
return ACTION(() => ({
|
|
13461
13535
|
expression: expr,
|
|
13462
13536
|
descending: descending[0],
|
|
13463
|
-
loc: C.
|
|
13537
|
+
loc: C.astFactory.sourceLocation(descending[1], expr)
|
|
13464
13538
|
}));
|
|
13465
13539
|
} },
|
|
13466
13540
|
{ ALT: () => {
|
|
@@ -13479,16 +13553,17 @@ var limitOffsetClauses = {
|
|
|
13479
13553
|
{ ALT: () => {
|
|
13480
13554
|
const limit2 = SUBRULE1(limitClause);
|
|
13481
13555
|
const offset2 = OPTION1(() => SUBRULE1(offsetClause));
|
|
13482
|
-
return ACTION(() => C.
|
|
13556
|
+
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2.val, offset2?.val, C.astFactory.sourceLocation(limit2, ...offset2 ? [offset2] : [])));
|
|
13483
13557
|
} },
|
|
13484
13558
|
{ ALT: () => {
|
|
13485
13559
|
const offset2 = SUBRULE2(offsetClause);
|
|
13486
13560
|
const limit2 = OPTION2(() => SUBRULE2(limitClause));
|
|
13487
|
-
return ACTION(() => C.
|
|
13561
|
+
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13488
13562
|
} }
|
|
13489
13563
|
]),
|
|
13490
|
-
gImpl: ({ PRINT_WORDS }) => (ast, {
|
|
13564
|
+
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13491
13565
|
F2.printFilter(ast, () => {
|
|
13566
|
+
PRINT_ON_EMPTY("");
|
|
13492
13567
|
if (ast.limit) {
|
|
13493
13568
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13494
13569
|
}
|
|
@@ -13504,7 +13579,7 @@ var limitClause = {
|
|
|
13504
13579
|
const offset2 = CONSUME(limit);
|
|
13505
13580
|
const value = CONSUME(terminals_exports.integer);
|
|
13506
13581
|
const val = Number.parseInt(value.image, 10);
|
|
13507
|
-
return ACTION(() => C.
|
|
13582
|
+
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(offset2, value)));
|
|
13508
13583
|
}
|
|
13509
13584
|
};
|
|
13510
13585
|
var offsetClause = {
|
|
@@ -13513,7 +13588,7 @@ var offsetClause = {
|
|
|
13513
13588
|
const offset2 = CONSUME(offset);
|
|
13514
13589
|
const value = CONSUME(terminals_exports.integer);
|
|
13515
13590
|
const val = Number.parseInt(value.image, 10);
|
|
13516
|
-
return ACTION(() => C.
|
|
13591
|
+
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(offset2, value)));
|
|
13517
13592
|
}
|
|
13518
13593
|
};
|
|
13519
13594
|
|
|
@@ -13538,10 +13613,10 @@ var query = {
|
|
|
13538
13613
|
...subType,
|
|
13539
13614
|
type: "query",
|
|
13540
13615
|
...values3 && { values: values3 },
|
|
13541
|
-
loc: C.
|
|
13616
|
+
loc: C.astFactory.sourceLocation(prologueValues.at(0), subType, values3)
|
|
13542
13617
|
}));
|
|
13543
13618
|
},
|
|
13544
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
13619
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13545
13620
|
SUBRULE(prologue, ast.context);
|
|
13546
13621
|
if (F2.isQuerySelect(ast)) {
|
|
13547
13622
|
SUBRULE(selectQuery, ast);
|
|
@@ -13571,13 +13646,13 @@ var selectQuery = {
|
|
|
13571
13646
|
solutionModifiers: modifiers,
|
|
13572
13647
|
datasets: from2,
|
|
13573
13648
|
...selectVal.val,
|
|
13574
|
-
loc: C.
|
|
13649
|
+
loc: C.astFactory.sourceLocation(selectVal, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13575
13650
|
};
|
|
13576
13651
|
queryIsGood(ret);
|
|
13577
13652
|
return ret;
|
|
13578
13653
|
});
|
|
13579
13654
|
},
|
|
13580
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
13655
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13581
13656
|
SUBRULE(selectClause, F2.wrap({
|
|
13582
13657
|
variables: ast.variables,
|
|
13583
13658
|
distinct: ast.distinct,
|
|
@@ -13595,14 +13670,14 @@ var subSelect = {
|
|
|
13595
13670
|
const where2 = SUBRULE(whereClause);
|
|
13596
13671
|
const modifiers = SUBRULE(solutionModifier);
|
|
13597
13672
|
const values3 = SUBRULE(valuesClause);
|
|
13598
|
-
return ACTION(() => C.
|
|
13673
|
+
return ACTION(() => C.astFactory.querySelect({
|
|
13599
13674
|
where: where2.val,
|
|
13600
|
-
datasets: C.
|
|
13675
|
+
datasets: C.astFactory.datasetClauses([], C.astFactory.sourceLocation()),
|
|
13601
13676
|
context: [],
|
|
13602
13677
|
solutionModifiers: modifiers,
|
|
13603
13678
|
...selectVal.val,
|
|
13604
13679
|
...values3 && { values: values3 }
|
|
13605
|
-
}, C.
|
|
13680
|
+
}, C.astFactory.sourceLocation(selectVal, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset, values3)));
|
|
13606
13681
|
}
|
|
13607
13682
|
};
|
|
13608
13683
|
var selectClause = {
|
|
@@ -13633,7 +13708,7 @@ var selectClause = {
|
|
|
13633
13708
|
const star2 = CONSUME(symbols_exports.star);
|
|
13634
13709
|
return ACTION(() => {
|
|
13635
13710
|
last2 = star2;
|
|
13636
|
-
return { variables: [C.
|
|
13711
|
+
return { variables: [C.astFactory.wildcard(C.astFactory.sourceLocation(star2))], ...distRed };
|
|
13637
13712
|
});
|
|
13638
13713
|
} },
|
|
13639
13714
|
{ ALT: () => {
|
|
@@ -13663,7 +13738,7 @@ var selectClause = {
|
|
|
13663
13738
|
throw new Error(`Variable ${variable.value} used more than once in SELECT clause`);
|
|
13664
13739
|
}
|
|
13665
13740
|
usedVars.push(variable);
|
|
13666
|
-
variables.push(C.
|
|
13741
|
+
variables.push(C.astFactory.patternBind(expr, variable, C.astFactory.sourceLocation(open, last2)));
|
|
13667
13742
|
});
|
|
13668
13743
|
} }
|
|
13669
13744
|
]));
|
|
@@ -13671,9 +13746,9 @@ var selectClause = {
|
|
|
13671
13746
|
} }
|
|
13672
13747
|
]);
|
|
13673
13748
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13674
|
-
return ACTION(() => C.
|
|
13749
|
+
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13675
13750
|
},
|
|
13676
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13751
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13677
13752
|
F2.printFilter(ast, () => {
|
|
13678
13753
|
PRINT_WORD("SELECT");
|
|
13679
13754
|
if (ast.val.distinct) {
|
|
@@ -13713,7 +13788,7 @@ var constructQuery = {
|
|
|
13713
13788
|
datasets: from2,
|
|
13714
13789
|
where: where2.val,
|
|
13715
13790
|
solutionModifiers: modifiers,
|
|
13716
|
-
loc: C.
|
|
13791
|
+
loc: C.astFactory.sourceLocation(construct2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13717
13792
|
}));
|
|
13718
13793
|
} },
|
|
13719
13794
|
{ ALT: () => {
|
|
@@ -13725,19 +13800,26 @@ var constructQuery = {
|
|
|
13725
13800
|
subType: "construct",
|
|
13726
13801
|
template: template.val,
|
|
13727
13802
|
datasets: from2,
|
|
13728
|
-
where: C.
|
|
13803
|
+
where: C.astFactory.patternGroup([template.val], C.astFactory.sourceLocation()),
|
|
13729
13804
|
solutionModifiers: modifiers,
|
|
13730
|
-
loc: C.
|
|
13805
|
+
loc: C.astFactory.sourceLocation(construct2, template, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13731
13806
|
}));
|
|
13732
13807
|
} }
|
|
13733
13808
|
]);
|
|
13734
13809
|
},
|
|
13735
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast,
|
|
13810
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13811
|
+
const { astFactory: F2, indentInc } = C;
|
|
13736
13812
|
F2.printFilter(ast, () => PRINT_WORD("CONSTRUCT"));
|
|
13737
13813
|
if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
13738
|
-
F2.printFilter(ast, () =>
|
|
13814
|
+
F2.printFilter(ast, () => {
|
|
13815
|
+
C[traqulaIndentation] += indentInc;
|
|
13816
|
+
PRINT_WORD("{\n");
|
|
13817
|
+
});
|
|
13739
13818
|
SUBRULE(triplesBlock, ast.template);
|
|
13740
|
-
F2.printFilter(ast, () =>
|
|
13819
|
+
F2.printFilter(ast, () => {
|
|
13820
|
+
C[traqulaIndentation] -= indentInc;
|
|
13821
|
+
PRINT_ON_EMPTY("}\n");
|
|
13822
|
+
});
|
|
13741
13823
|
}
|
|
13742
13824
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
13743
13825
|
if (F2.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
@@ -13762,7 +13844,7 @@ var describeQuery = {
|
|
|
13762
13844
|
} },
|
|
13763
13845
|
{ ALT: () => {
|
|
13764
13846
|
const star2 = CONSUME(symbols_exports.star);
|
|
13765
|
-
return [ACTION(() => C.
|
|
13847
|
+
return [ACTION(() => C.astFactory.wildcard(C.astFactory.sourceLocation(star2)))];
|
|
13766
13848
|
} }
|
|
13767
13849
|
]);
|
|
13768
13850
|
const from2 = SUBRULE1(datasetClauseStar);
|
|
@@ -13774,10 +13856,10 @@ var describeQuery = {
|
|
|
13774
13856
|
datasets: from2,
|
|
13775
13857
|
...where2 && { where: where2.val },
|
|
13776
13858
|
solutionModifiers: modifiers,
|
|
13777
|
-
loc: C.
|
|
13859
|
+
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13778
13860
|
}));
|
|
13779
13861
|
},
|
|
13780
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13862
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13781
13863
|
F2.printFilter(ast, () => PRINT_WORD("DESCRIBE"));
|
|
13782
13864
|
if (F2.isWildcard(ast.variables[0])) {
|
|
13783
13865
|
F2.printFilter(ast, () => PRINT_WORD("*"));
|
|
@@ -13805,10 +13887,10 @@ var askQuery = {
|
|
|
13805
13887
|
datasets: from2,
|
|
13806
13888
|
where: where2.val,
|
|
13807
13889
|
solutionModifiers: modifiers,
|
|
13808
|
-
loc: C.
|
|
13890
|
+
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13809
13891
|
}));
|
|
13810
13892
|
},
|
|
13811
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13893
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13812
13894
|
F2.printFilter(ast, () => PRINT_WORD("ASK"));
|
|
13813
13895
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
13814
13896
|
SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
|
|
@@ -13825,7 +13907,7 @@ var constructTemplate = {
|
|
|
13825
13907
|
const open = CONSUME(symbols_exports.LCurly);
|
|
13826
13908
|
const triples = OPTION(() => SUBRULE1(constructTriples));
|
|
13827
13909
|
const close = CONSUME(symbols_exports.RCurly);
|
|
13828
|
-
return ACTION(() => C.
|
|
13910
|
+
return ACTION(() => C.astFactory.wrap(triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocation()), C.astFactory.sourceLocation(open, close)));
|
|
13829
13911
|
}
|
|
13830
13912
|
};
|
|
13831
13913
|
var constructTriples = {
|
|
@@ -13862,13 +13944,13 @@ var update = {
|
|
|
13862
13944
|
const update2 = {
|
|
13863
13945
|
type: "update",
|
|
13864
13946
|
updates,
|
|
13865
|
-
loc: C.
|
|
13947
|
+
loc: C.astFactory.sourceLocation(...updates[0].context, updates[0].operation, ...updates.at(-1).context, updates.at(-1)?.operation)
|
|
13866
13948
|
};
|
|
13867
13949
|
updateNoReuseBlankNodeLabels(update2);
|
|
13868
13950
|
return update2;
|
|
13869
13951
|
});
|
|
13870
13952
|
},
|
|
13871
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
13953
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13872
13954
|
const [head2, ...tail] = ast.updates;
|
|
13873
13955
|
if (head2) {
|
|
13874
13956
|
SUBRULE(prologue, head2.context);
|
|
@@ -13948,9 +14030,9 @@ var load2 = {
|
|
|
13948
14030
|
CONSUME(loadInto);
|
|
13949
14031
|
return SUBRULE1(graphRef);
|
|
13950
14032
|
});
|
|
13951
|
-
return ACTION(() => C.
|
|
14033
|
+
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
13952
14034
|
},
|
|
13953
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
14035
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13954
14036
|
F2.printFilter(ast, () => {
|
|
13955
14037
|
PRINT_WORD("LOAD");
|
|
13956
14038
|
if (ast.silent) {
|
|
@@ -13971,9 +14053,9 @@ function clearOrDrop(operation) {
|
|
|
13971
14053
|
const opToken = CONSUME(operation);
|
|
13972
14054
|
const silent2 = OPTION(() => CONSUME(silent));
|
|
13973
14055
|
const destination = SUBRULE1(graphRefAll);
|
|
13974
|
-
return ACTION(() => C.
|
|
14056
|
+
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
13975
14057
|
},
|
|
13976
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
14058
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13977
14059
|
F2.printFilter(ast, () => {
|
|
13978
14060
|
PRINT_WORD(operation.name.toUpperCase());
|
|
13979
14061
|
if (ast.silent) {
|
|
@@ -13992,9 +14074,9 @@ var create2 = {
|
|
|
13992
14074
|
const createToken3 = CONSUME(create);
|
|
13993
14075
|
const silent2 = OPTION(() => CONSUME(silent));
|
|
13994
14076
|
const destination = SUBRULE1(graphRef);
|
|
13995
|
-
return ACTION(() => C.
|
|
14077
|
+
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
13996
14078
|
},
|
|
13997
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
14079
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13998
14080
|
F2.printFilter(ast, () => {
|
|
13999
14081
|
PRINT_WORD("CREATE");
|
|
14000
14082
|
if (ast.silent) {
|
|
@@ -14013,9 +14095,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14013
14095
|
const source = SUBRULE1(graphOrDefault);
|
|
14014
14096
|
CONSUME(to);
|
|
14015
14097
|
const destination = SUBRULE2(graphOrDefault);
|
|
14016
|
-
return ACTION(() => C.
|
|
14098
|
+
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14017
14099
|
},
|
|
14018
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
14100
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14019
14101
|
F2.printFilter(ast, () => {
|
|
14020
14102
|
PRINT_WORD(operation.name.toUpperCase());
|
|
14021
14103
|
if (ast.silent) {
|
|
@@ -14037,7 +14119,7 @@ var quadPattern = {
|
|
|
14037
14119
|
const open = CONSUME(symbols_exports.LCurly);
|
|
14038
14120
|
const val = SUBRULE1(quads);
|
|
14039
14121
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14040
|
-
return ACTION(() => C.
|
|
14122
|
+
return ACTION(() => C.astFactory.wrap(val.val, C.astFactory.sourceLocation(open, close)));
|
|
14041
14123
|
}
|
|
14042
14124
|
};
|
|
14043
14125
|
var quadData = {
|
|
@@ -14048,7 +14130,7 @@ var quadData = {
|
|
|
14048
14130
|
const val = SUBRULE1(quads);
|
|
14049
14131
|
ACTION(() => couldParseVars && C.parseMode.add("canParseVars"));
|
|
14050
14132
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14051
|
-
return ACTION(() => C.
|
|
14133
|
+
return ACTION(() => C.astFactory.wrap(val.val, C.astFactory.sourceLocation(open, close)));
|
|
14052
14134
|
}
|
|
14053
14135
|
};
|
|
14054
14136
|
function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
|
|
@@ -14065,12 +14147,26 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
|
|
|
14065
14147
|
if (name !== "insertData") {
|
|
14066
14148
|
ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
|
|
14067
14149
|
}
|
|
14068
|
-
return ACTION(() => C.
|
|
14150
|
+
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14069
14151
|
},
|
|
14070
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast,
|
|
14071
|
-
|
|
14152
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14153
|
+
const { astFactory: F2, indentInc } = C;
|
|
14154
|
+
F2.printFilter(ast, () => {
|
|
14155
|
+
C[traqulaIndentation] += indentInc;
|
|
14156
|
+
if (subType === "insertdata") {
|
|
14157
|
+
PRINT_WORD("INSERT DATA");
|
|
14158
|
+
} else if (subType === "deletedata") {
|
|
14159
|
+
PRINT_WORD("DELETE DATA");
|
|
14160
|
+
} else if (subType === "deletewhere") {
|
|
14161
|
+
PRINT_WORD("DELETE WHERE");
|
|
14162
|
+
}
|
|
14163
|
+
PRINT_WORD("{\n");
|
|
14164
|
+
});
|
|
14072
14165
|
SUBRULE(quads, F2.wrap(ast.data, ast.loc));
|
|
14073
|
-
F2.printFilter(ast, () =>
|
|
14166
|
+
F2.printFilter(ast, () => {
|
|
14167
|
+
C[traqulaIndentation] -= indentInc;
|
|
14168
|
+
PRINT_ON_EMPTY("}\n");
|
|
14169
|
+
});
|
|
14074
14170
|
}
|
|
14075
14171
|
};
|
|
14076
14172
|
}
|
|
@@ -14099,22 +14195,35 @@ var modify = {
|
|
|
14099
14195
|
const using = SUBRULE1(usingClauseStar);
|
|
14100
14196
|
CONSUME(where);
|
|
14101
14197
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14102
|
-
return ACTION(() => C.
|
|
14198
|
+
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14103
14199
|
},
|
|
14104
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast,
|
|
14200
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14201
|
+
const { astFactory: F2, indentInc } = C;
|
|
14105
14202
|
if (ast.graph) {
|
|
14106
14203
|
F2.printFilter(ast, () => PRINT_WORD("WITH"));
|
|
14107
14204
|
SUBRULE(iri2, ast.graph);
|
|
14108
14205
|
}
|
|
14109
14206
|
if (ast.delete.length > 0) {
|
|
14110
|
-
F2.printFilter(ast, () =>
|
|
14207
|
+
F2.printFilter(ast, () => {
|
|
14208
|
+
C[traqulaIndentation] += indentInc;
|
|
14209
|
+
PRINT_WORD("DELETE", "{\n");
|
|
14210
|
+
});
|
|
14111
14211
|
SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
|
|
14112
|
-
F2.printFilter(ast, () =>
|
|
14212
|
+
F2.printFilter(ast, () => {
|
|
14213
|
+
C[traqulaIndentation] -= indentInc;
|
|
14214
|
+
PRINT_ON_EMPTY("}\n");
|
|
14215
|
+
});
|
|
14113
14216
|
}
|
|
14114
14217
|
if (ast.insert.length > 0) {
|
|
14115
|
-
F2.printFilter(ast, () =>
|
|
14218
|
+
F2.printFilter(ast, () => {
|
|
14219
|
+
C[traqulaIndentation] += indentInc;
|
|
14220
|
+
PRINT_WORD("INSERT", "{\n");
|
|
14221
|
+
});
|
|
14116
14222
|
SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
|
|
14117
|
-
F2.printFilter(ast, () =>
|
|
14223
|
+
F2.printFilter(ast, () => {
|
|
14224
|
+
C[traqulaIndentation] -= indentInc;
|
|
14225
|
+
PRINT_ON_EMPTY("}\n");
|
|
14226
|
+
});
|
|
14118
14227
|
}
|
|
14119
14228
|
SUBRULE(usingClauseStar, ast.from);
|
|
14120
14229
|
F2.printFilter(ast, () => PRINT_WORD("WHERE"));
|
|
@@ -14128,7 +14237,7 @@ var deleteClause2 = {
|
|
|
14128
14237
|
const couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
|
|
14129
14238
|
const del = SUBRULE(quadPattern);
|
|
14130
14239
|
ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
|
|
14131
|
-
return ACTION(() => C.
|
|
14240
|
+
return ACTION(() => C.astFactory.wrap(del.val, C.astFactory.sourceLocation(delToken, del)));
|
|
14132
14241
|
}
|
|
14133
14242
|
};
|
|
14134
14243
|
var insertClause2 = {
|
|
@@ -14136,7 +14245,7 @@ var insertClause2 = {
|
|
|
14136
14245
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
14137
14246
|
const insertToken = CONSUME(insertClause);
|
|
14138
14247
|
const insert = SUBRULE(quadPattern);
|
|
14139
|
-
return ACTION(() => C.
|
|
14248
|
+
return ACTION(() => C.astFactory.wrap(insert.val, C.astFactory.sourceLocation(insertToken, insert)));
|
|
14140
14249
|
}
|
|
14141
14250
|
};
|
|
14142
14251
|
var graphOrDefault = {
|
|
@@ -14144,12 +14253,12 @@ var graphOrDefault = {
|
|
|
14144
14253
|
impl: ({ ACTION, SUBRULE1, CONSUME, OPTION, OR }) => (C) => OR([
|
|
14145
14254
|
{ ALT: () => {
|
|
14146
14255
|
const def = CONSUME(graph_exports.default_);
|
|
14147
|
-
return ACTION(() => C.
|
|
14256
|
+
return ACTION(() => C.astFactory.graphRefDefault(C.astFactory.sourceLocation(def)));
|
|
14148
14257
|
} },
|
|
14149
14258
|
{ ALT: () => {
|
|
14150
14259
|
const graph2 = OPTION(() => CONSUME(graph_exports.graph));
|
|
14151
14260
|
const name = SUBRULE1(iri2);
|
|
14152
|
-
return ACTION(() => C.
|
|
14261
|
+
return ACTION(() => C.astFactory.graphRefSpecific(name, C.astFactory.sourceLocation(graph2, name)));
|
|
14153
14262
|
} }
|
|
14154
14263
|
])
|
|
14155
14264
|
};
|
|
@@ -14158,9 +14267,9 @@ var graphRef = {
|
|
|
14158
14267
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
14159
14268
|
const graph2 = CONSUME(graph_exports.graph);
|
|
14160
14269
|
const val = SUBRULE(iri2);
|
|
14161
|
-
return ACTION(() => C.
|
|
14270
|
+
return ACTION(() => C.astFactory.graphRefSpecific(val, C.astFactory.sourceLocation(graph2, val)));
|
|
14162
14271
|
},
|
|
14163
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
14272
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14164
14273
|
F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14165
14274
|
SUBRULE(iri2, ast.graph);
|
|
14166
14275
|
}
|
|
@@ -14171,18 +14280,18 @@ var graphRefAll = {
|
|
|
14171
14280
|
{ ALT: () => SUBRULE(graphRef) },
|
|
14172
14281
|
{ ALT: () => {
|
|
14173
14282
|
const def = CONSUME(graph_exports.default_);
|
|
14174
|
-
return ACTION(() => C.
|
|
14283
|
+
return ACTION(() => C.astFactory.graphRefDefault(C.astFactory.sourceLocation(def)));
|
|
14175
14284
|
} },
|
|
14176
14285
|
{ ALT: () => {
|
|
14177
14286
|
const named2 = CONSUME(graph_exports.named);
|
|
14178
|
-
return ACTION(() => C.
|
|
14287
|
+
return ACTION(() => C.astFactory.graphRefNamed(C.astFactory.sourceLocation(named2)));
|
|
14179
14288
|
} },
|
|
14180
14289
|
{ ALT: () => {
|
|
14181
14290
|
const graphAll2 = CONSUME(graph_exports.graphAll);
|
|
14182
|
-
return ACTION(() => C.
|
|
14291
|
+
return ACTION(() => C.astFactory.graphRefAll(C.astFactory.sourceLocation(graphAll2)));
|
|
14183
14292
|
} }
|
|
14184
14293
|
]),
|
|
14185
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, {
|
|
14294
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14186
14295
|
if (F2.isGraphRefSpecific(ast)) {
|
|
14187
14296
|
SUBRULE(graphRef, ast);
|
|
14188
14297
|
} else if (F2.isGraphRefDefault(ast)) {
|
|
@@ -14219,9 +14328,9 @@ var quads = {
|
|
|
14219
14328
|
ACTION(() => quads2.push(triples));
|
|
14220
14329
|
});
|
|
14221
14330
|
});
|
|
14222
|
-
return ACTION(() => C.
|
|
14331
|
+
return ACTION(() => C.astFactory.wrap(quads2, C.astFactory.sourceLocation(quads2.at(0), last2)));
|
|
14223
14332
|
},
|
|
14224
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
14333
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
14225
14334
|
for (const quad of ast.val) {
|
|
14226
14335
|
if (F2.isPattern(quad)) {
|
|
14227
14336
|
SUBRULE(triplesBlock, quad);
|
|
@@ -14239,14 +14348,21 @@ var quadsNotTriples = {
|
|
|
14239
14348
|
CONSUME(symbols_exports.LCurly);
|
|
14240
14349
|
const triples = OPTION(() => SUBRULE1(triplesTemplate));
|
|
14241
14350
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14242
|
-
return ACTION(() => C.
|
|
14351
|
+
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14243
14352
|
},
|
|
14244
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast,
|
|
14353
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14354
|
+
const { astFactory: F2, indentInc } = C;
|
|
14245
14355
|
F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14246
14356
|
SUBRULE(varOrTerm, ast.graph);
|
|
14247
|
-
F2.printFilter(ast, () =>
|
|
14357
|
+
F2.printFilter(ast, () => {
|
|
14358
|
+
C[traqulaIndentation] += indentInc;
|
|
14359
|
+
PRINT_WORD("{\n");
|
|
14360
|
+
});
|
|
14248
14361
|
SUBRULE(triplesBlock, ast.triples);
|
|
14249
|
-
F2.printFilter(ast, () =>
|
|
14362
|
+
F2.printFilter(ast, () => {
|
|
14363
|
+
C[traqulaIndentation] -= indentInc;
|
|
14364
|
+
PRINT_ON_EMPTY("}\n");
|
|
14365
|
+
});
|
|
14250
14366
|
}
|
|
14251
14367
|
};
|
|
14252
14368
|
|
|
@@ -14269,7 +14385,7 @@ var queryOrUpdate = {
|
|
|
14269
14385
|
...subType,
|
|
14270
14386
|
type: "query",
|
|
14271
14387
|
...values3 && { values: values3 },
|
|
14272
|
-
loc: C.
|
|
14388
|
+
loc: C.astFactory.sourceLocation(prologueValues.at(0), subType, values3)
|
|
14273
14389
|
}));
|
|
14274
14390
|
} },
|
|
14275
14391
|
{ ALT: () => {
|
|
@@ -14293,7 +14409,7 @@ var queryOrUpdate = {
|
|
|
14293
14409
|
const update2 = {
|
|
14294
14410
|
type: "update",
|
|
14295
14411
|
updates,
|
|
14296
|
-
loc: C.
|
|
14412
|
+
loc: C.astFactory.sourceLocation(...updates[0].context, updates[0].operation, ...updates.at(-1).context, updates.at(-1)?.operation)
|
|
14297
14413
|
};
|
|
14298
14414
|
updateNoReuseBlankNodeLabels(update2);
|
|
14299
14415
|
return update2;
|
|
@@ -14301,7 +14417,7 @@ var queryOrUpdate = {
|
|
|
14301
14417
|
} }
|
|
14302
14418
|
]);
|
|
14303
14419
|
},
|
|
14304
|
-
gImpl: ({ SUBRULE }) => (ast, {
|
|
14420
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
14305
14421
|
if (F2.isQuery(ast)) {
|
|
14306
14422
|
SUBRULE(query, ast);
|
|
14307
14423
|
} else {
|
|
@@ -14313,13 +14429,15 @@ var queryOrUpdate = {
|
|
|
14313
14429
|
// ../../packages/rules-sparql-1-1/lib/MinimalSparqlParser.js
|
|
14314
14430
|
function completeParseContext(context) {
|
|
14315
14431
|
return {
|
|
14316
|
-
|
|
14432
|
+
astFactory: context.astFactory ?? new AstFactory(),
|
|
14317
14433
|
baseIRI: context.baseIRI,
|
|
14318
14434
|
prefixes: { ...context.prefixes },
|
|
14319
14435
|
origSource: context.origSource ?? "",
|
|
14320
14436
|
offset: context.offset,
|
|
14321
14437
|
parseMode: context.parseMode ? new Set(context.parseMode) : /* @__PURE__ */ new Set(["canParseVars", "canCreateBlankNodes"]),
|
|
14322
|
-
skipValidation: context.skipValidation ?? false
|
|
14438
|
+
skipValidation: context.skipValidation ?? false,
|
|
14439
|
+
[traqulaIndentation]: context[traqulaIndentation] ?? 0,
|
|
14440
|
+
indentInc: context.indentInc ?? 2
|
|
14323
14441
|
};
|
|
14324
14442
|
}
|
|
14325
14443
|
|
|
@@ -14398,7 +14516,7 @@ var sparql11GeneratorBuilder = GeneratorBuilder.create([
|
|
|
14398
14516
|
);
|
|
14399
14517
|
var Generator = class {
|
|
14400
14518
|
generator = sparql11GeneratorBuilder.build();
|
|
14401
|
-
factory = new
|
|
14519
|
+
factory = new AstFactory();
|
|
14402
14520
|
generate(ast, context = {}) {
|
|
14403
14521
|
return this.generator.queryOrUpdate(ast, completeParseContext(context));
|
|
14404
14522
|
}
|