@traqula/generator-sparql-1-1 0.0.19 → 0.0.21
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 +504 -248
- package/lib/index.d.ts +4 -6
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/package.json +6 -6
package/lib/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var AstCoreFactory = class {
|
|
|
42
42
|
if (filtered.length === 0) {
|
|
43
43
|
return this.gen();
|
|
44
44
|
}
|
|
45
|
-
const first2 = filtered
|
|
45
|
+
const first2 = filtered.at(0);
|
|
46
46
|
const last2 = filtered.at(-1);
|
|
47
47
|
return {
|
|
48
48
|
sourceLocationType: "source",
|
|
@@ -9379,13 +9379,16 @@ var DynamicGenerator = class {
|
|
|
9379
9379
|
__context = void 0;
|
|
9380
9380
|
origSource = "";
|
|
9381
9381
|
generatedUntil = 0;
|
|
9382
|
-
|
|
9382
|
+
toEnsure = [];
|
|
9383
|
+
/**
|
|
9384
|
+
* Should not contain empty strings
|
|
9385
|
+
* @protected
|
|
9386
|
+
*/
|
|
9383
9387
|
stringBuilder = [];
|
|
9384
9388
|
constructor(rules) {
|
|
9385
9389
|
this.rules = rules;
|
|
9386
9390
|
for (const rule of Object.values(rules)) {
|
|
9387
9391
|
this[rule.name] = ((input, context, args) => {
|
|
9388
|
-
this.expectsSpace = false;
|
|
9389
9392
|
this.stringBuilder.length = 0;
|
|
9390
9393
|
this.origSource = context.origSource;
|
|
9391
9394
|
this.generatedUntil = context?.offset ?? 0;
|
|
@@ -9410,12 +9413,15 @@ var DynamicGenerator = class {
|
|
|
9410
9413
|
const generate = () => def.gImpl({
|
|
9411
9414
|
SUBRULE: this.subrule,
|
|
9412
9415
|
PRINT: this.print,
|
|
9413
|
-
|
|
9416
|
+
ENSURE: this.ensure,
|
|
9417
|
+
ENSURE_EITHER: this.ensureEither,
|
|
9418
|
+
NEW_LINE: this.newLine,
|
|
9419
|
+
HANDLE_LOC: this.handleLoc,
|
|
9420
|
+
CATCHUP: this.catchup,
|
|
9414
9421
|
PRINT_WORD: this.printWord,
|
|
9415
9422
|
PRINT_WORDS: this.printWords,
|
|
9416
9423
|
PRINT_ON_EMPTY: this.printOnEmpty,
|
|
9417
|
-
|
|
9418
|
-
HANDLE_LOC: this.handleLoc
|
|
9424
|
+
PRINT_ON_OWN_LINE: this.printOnOwnLine
|
|
9419
9425
|
})(ast, this.getSafeContext(), ...arg);
|
|
9420
9426
|
if (this.factory.isLocalized(ast)) {
|
|
9421
9427
|
this.handleLoc(ast, generate);
|
|
@@ -9453,43 +9459,82 @@ var DynamicGenerator = class {
|
|
|
9453
9459
|
}
|
|
9454
9460
|
this.generatedUntil = Math.max(this.generatedUntil, until);
|
|
9455
9461
|
};
|
|
9462
|
+
handeEnsured(toPrint) {
|
|
9463
|
+
for (const callBack of this.toEnsure) {
|
|
9464
|
+
callBack(toPrint);
|
|
9465
|
+
}
|
|
9466
|
+
this.toEnsure.length = 0;
|
|
9467
|
+
}
|
|
9456
9468
|
print = (...args) => {
|
|
9457
|
-
const
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9469
|
+
const joined = args.join("");
|
|
9470
|
+
this.handeEnsured(joined);
|
|
9471
|
+
this.stringBuilder.push(joined);
|
|
9472
|
+
};
|
|
9473
|
+
doesEndWith(subsStr) {
|
|
9474
|
+
const len = subsStr.length;
|
|
9475
|
+
let temp = "";
|
|
9476
|
+
while (temp.length < len && this.stringBuilder.length > 0) {
|
|
9477
|
+
temp = this.stringBuilder.pop() + temp;
|
|
9478
|
+
}
|
|
9479
|
+
this.stringBuilder.push(temp);
|
|
9480
|
+
return temp.endsWith(subsStr);
|
|
9481
|
+
}
|
|
9482
|
+
ensure = (...args) => {
|
|
9483
|
+
const toEnsure = args.join("");
|
|
9484
|
+
if (!this.doesEndWith(toEnsure)) {
|
|
9485
|
+
this.toEnsure.push((willPrint) => {
|
|
9486
|
+
if (!willPrint.startsWith(toEnsure) && !this.doesEndWith(toEnsure)) {
|
|
9487
|
+
this.stringBuilder.push(toEnsure);
|
|
9465
9488
|
}
|
|
9466
|
-
}
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
}
|
|
9478
|
-
}
|
|
9489
|
+
});
|
|
9490
|
+
}
|
|
9491
|
+
};
|
|
9492
|
+
ensureEither = (...args) => {
|
|
9493
|
+
if (args.length === 1) {
|
|
9494
|
+
this.ensure(...args);
|
|
9495
|
+
} else if (args.length > 1 && // Not already matched?
|
|
9496
|
+
!args.some((subStr) => this.doesEndWith(subStr))) {
|
|
9497
|
+
this.toEnsure.push((willPrint) => {
|
|
9498
|
+
if (!args.some((subStr) => willPrint.startsWith(subStr)) && !args.some((subStr) => this.doesEndWith(subStr))) {
|
|
9499
|
+
this.stringBuilder.push(args[0]);
|
|
9479
9500
|
}
|
|
9501
|
+
});
|
|
9502
|
+
}
|
|
9503
|
+
};
|
|
9504
|
+
pruneEndingBlanks() {
|
|
9505
|
+
let temp = "";
|
|
9506
|
+
while (/^[ \t]*$/u.test(temp) && this.stringBuilder.length > 0) {
|
|
9507
|
+
temp = this.stringBuilder.pop() + temp;
|
|
9508
|
+
}
|
|
9509
|
+
this.print(temp.trimEnd());
|
|
9510
|
+
}
|
|
9511
|
+
newLine = (arg) => {
|
|
9512
|
+
const indentation = this.getSafeContext()[traqulaIndentation] ?? 0;
|
|
9513
|
+
if (indentation === -1) {
|
|
9514
|
+
return;
|
|
9515
|
+
}
|
|
9516
|
+
const force = arg?.force ?? false;
|
|
9517
|
+
this.pruneEndingBlanks();
|
|
9518
|
+
if (force) {
|
|
9519
|
+
this.print("\n", " ".repeat(indentation));
|
|
9520
|
+
} else {
|
|
9521
|
+
let temp = "";
|
|
9522
|
+
while (!temp.includes("\n") && this.stringBuilder.length > 0) {
|
|
9523
|
+
temp = this.stringBuilder.pop() + temp;
|
|
9524
|
+
}
|
|
9525
|
+
if (/\n[ \t]*$/u.test(temp)) {
|
|
9526
|
+
temp = temp.replace(/\n[ \t]*$/u, `
|
|
9527
|
+
${" ".repeat(indentation)}`);
|
|
9528
|
+
this.print(temp);
|
|
9480
9529
|
} else {
|
|
9481
|
-
this.
|
|
9530
|
+
this.print(temp, "\n", " ".repeat(indentation));
|
|
9482
9531
|
}
|
|
9483
9532
|
}
|
|
9484
9533
|
};
|
|
9485
9534
|
printWord = (...args) => {
|
|
9486
|
-
this.
|
|
9487
|
-
this.print(...args);
|
|
9488
|
-
this.expectsSpace = true;
|
|
9489
|
-
};
|
|
9490
|
-
printSpaceLeft = (...args) => {
|
|
9491
|
-
this.expectsSpace = true;
|
|
9535
|
+
this.ensureEither(" ", "\n");
|
|
9492
9536
|
this.print(...args);
|
|
9537
|
+
this.ensureEither(" ", "\n");
|
|
9493
9538
|
};
|
|
9494
9539
|
printWords = (...args) => {
|
|
9495
9540
|
for (const arg of args) {
|
|
@@ -9497,28 +9542,13 @@ var DynamicGenerator = class {
|
|
|
9497
9542
|
}
|
|
9498
9543
|
};
|
|
9499
9544
|
printOnEmpty = (...args) => {
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
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);
|
|
9545
|
+
this.newLine();
|
|
9546
|
+
this.print(...args);
|
|
9547
|
+
};
|
|
9548
|
+
printOnOwnLine = (...args) => {
|
|
9549
|
+
this.newLine();
|
|
9550
|
+
this.print(...args);
|
|
9551
|
+
this.newLine();
|
|
9522
9552
|
};
|
|
9523
9553
|
};
|
|
9524
9554
|
|
|
@@ -9584,6 +9614,9 @@ var GeneratorBuilder = class _GeneratorBuilder {
|
|
|
9584
9614
|
delete this.rules[ruleName];
|
|
9585
9615
|
return this;
|
|
9586
9616
|
}
|
|
9617
|
+
getRule(ruleName) {
|
|
9618
|
+
return this.rules[ruleName];
|
|
9619
|
+
}
|
|
9587
9620
|
/**
|
|
9588
9621
|
* Merge this grammar GeneratorBuilder with another.
|
|
9589
9622
|
* It is best to merge the bigger grammar with the smaller one.
|
|
@@ -9716,21 +9749,34 @@ var LexerBuilder = class _LexerBuilder {
|
|
|
9716
9749
|
}
|
|
9717
9750
|
};
|
|
9718
9751
|
|
|
9719
|
-
// ../../packages/core/lib/
|
|
9720
|
-
var
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9752
|
+
// ../../packages/core/lib/TransformerObject.js
|
|
9753
|
+
var TransformerObject = class _TransformerObject {
|
|
9754
|
+
defaultContext;
|
|
9755
|
+
maxStackSize = 1e6;
|
|
9756
|
+
/**
|
|
9757
|
+
* Creates stateless transformer.
|
|
9758
|
+
* @param defaultContext
|
|
9759
|
+
*/
|
|
9760
|
+
constructor(defaultContext = {}) {
|
|
9761
|
+
this.defaultContext = defaultContext;
|
|
9725
9762
|
}
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9763
|
+
clone(newDefaultContext = {}) {
|
|
9764
|
+
return new _TransformerObject({ ...this.defaultContext, ...newDefaultContext });
|
|
9765
|
+
}
|
|
9766
|
+
/**
|
|
9767
|
+
* Function to shallow clone any type.
|
|
9768
|
+
* @param obj
|
|
9769
|
+
* @protected
|
|
9770
|
+
*/
|
|
9771
|
+
cloneObj(obj) {
|
|
9772
|
+
if (obj === null || typeof obj !== "object") {
|
|
9773
|
+
return obj;
|
|
9732
9774
|
}
|
|
9733
|
-
|
|
9775
|
+
const proto = Object.getPrototypeOf(obj);
|
|
9776
|
+
if (proto === Object.prototype || proto === null) {
|
|
9777
|
+
return { ...obj };
|
|
9778
|
+
}
|
|
9779
|
+
return Object.assign(Object.create(proto), obj);
|
|
9734
9780
|
}
|
|
9735
9781
|
/**
|
|
9736
9782
|
* Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
|
|
@@ -9742,90 +9788,231 @@ var TransformerType = class {
|
|
|
9742
9788
|
* - Default false
|
|
9743
9789
|
*/
|
|
9744
9790
|
transformObject(startObject, mapper, preVisitor = () => ({})) {
|
|
9791
|
+
const defaults2 = this.defaultContext;
|
|
9792
|
+
const defaultCopyFlag = defaults2.copy ?? true;
|
|
9793
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9794
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9795
|
+
const defaultShallowKeys = defaults2.shallowKeys;
|
|
9796
|
+
const defaultDidShortCut = defaults2.shortcut ?? false;
|
|
9745
9797
|
let didShortCut = false;
|
|
9746
|
-
const
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9798
|
+
const resultWrap = { res: startObject };
|
|
9799
|
+
const stack = [startObject];
|
|
9800
|
+
const stackParent = [resultWrap];
|
|
9801
|
+
const stackParentKey = ["res"];
|
|
9802
|
+
const handleMapperOnLen = [];
|
|
9803
|
+
const mapperCopyStack = [];
|
|
9804
|
+
const mapperOrigStack = [];
|
|
9805
|
+
const mapperParent = [];
|
|
9806
|
+
const mapperParentKey = [];
|
|
9807
|
+
function handleMapper() {
|
|
9808
|
+
while (stack.length === handleMapperOnLen.at(-1)) {
|
|
9809
|
+
handleMapperOnLen.pop();
|
|
9810
|
+
const copyToMap = mapperCopyStack.pop();
|
|
9811
|
+
const origToMap = mapperOrigStack.pop();
|
|
9812
|
+
const parent = mapperParent.pop();
|
|
9813
|
+
const parentKey = mapperParentKey.pop();
|
|
9814
|
+
parent[parentKey] = mapper(copyToMap, origToMap);
|
|
9815
|
+
}
|
|
9816
|
+
}
|
|
9817
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9818
|
+
const curObject = stack.pop();
|
|
9819
|
+
const curParent = stackParent.pop();
|
|
9820
|
+
const curKey = stackParentKey.pop();
|
|
9821
|
+
if (!didShortCut) {
|
|
9822
|
+
if (Array.isArray(curObject)) {
|
|
9823
|
+
const newArr = [...curObject];
|
|
9824
|
+
handleMapperOnLen.push(stack.length);
|
|
9825
|
+
mapperCopyStack.push(newArr);
|
|
9826
|
+
mapperOrigStack.push(curObject);
|
|
9827
|
+
mapperParent.push(curParent);
|
|
9828
|
+
mapperParentKey.push(curKey);
|
|
9829
|
+
for (let index = curObject.length - 1; index >= 0; index--) {
|
|
9830
|
+
const val = curObject[index];
|
|
9831
|
+
if (val !== null && typeof val === "object") {
|
|
9832
|
+
stack.push(val);
|
|
9833
|
+
stackParent.push(newArr);
|
|
9834
|
+
stackParentKey.push(index.toString());
|
|
9835
|
+
}
|
|
9836
|
+
}
|
|
9837
|
+
handleMapper();
|
|
9838
|
+
continue;
|
|
9839
|
+
}
|
|
9840
|
+
const context = preVisitor(curObject);
|
|
9841
|
+
const copyFlag = context.copy ?? defaultCopyFlag;
|
|
9842
|
+
const continues = context.continue ?? defaultContinues;
|
|
9843
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9844
|
+
const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
|
|
9845
|
+
didShortCut = context.shortcut ?? defaultDidShortCut;
|
|
9846
|
+
const copy3 = copyFlag ? this.cloneObj(curObject) : curObject;
|
|
9847
|
+
handleMapperOnLen.push(stack.length);
|
|
9848
|
+
mapperCopyStack.push(copy3);
|
|
9849
|
+
mapperOrigStack.push(curObject);
|
|
9850
|
+
mapperParent.push(curParent);
|
|
9851
|
+
mapperParentKey.push(curKey);
|
|
9852
|
+
if (continues && !didShortCut) {
|
|
9853
|
+
for (const key in copy3) {
|
|
9854
|
+
if (!Object.hasOwn(copy3, key)) {
|
|
9855
|
+
continue;
|
|
9856
|
+
}
|
|
9857
|
+
const val = copy3[key];
|
|
9858
|
+
const onlyShallow = shallowKeys && shallowKeys?.has(key);
|
|
9859
|
+
if (onlyShallow) {
|
|
9860
|
+
copy3[key] = this.cloneObj(val);
|
|
9861
|
+
}
|
|
9862
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9863
|
+
continue;
|
|
9864
|
+
}
|
|
9865
|
+
if (!onlyShallow && val !== null && typeof val === "object") {
|
|
9866
|
+
stack.push(val);
|
|
9867
|
+
stackParentKey.push(key);
|
|
9868
|
+
stackParent.push(copy3);
|
|
9869
|
+
}
|
|
9755
9870
|
}
|
|
9756
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9757
9871
|
}
|
|
9758
9872
|
}
|
|
9759
|
-
|
|
9760
|
-
}
|
|
9761
|
-
|
|
9873
|
+
handleMapper();
|
|
9874
|
+
}
|
|
9875
|
+
if (stack.length >= this.maxStackSize) {
|
|
9876
|
+
throw new Error("Transform object stack overflowed");
|
|
9877
|
+
}
|
|
9878
|
+
handleMapper();
|
|
9879
|
+
return resultWrap.res;
|
|
9762
9880
|
}
|
|
9763
9881
|
/**
|
|
9764
9882
|
* Visitor that visits all objects. Visits deeper objects first.
|
|
9765
9883
|
*/
|
|
9766
9884
|
visitObject(startObject, visitor, preVisitor = () => ({})) {
|
|
9885
|
+
const defaults2 = this.defaultContext;
|
|
9886
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9887
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9888
|
+
const defaultShortcut = defaults2.shortcut ?? false;
|
|
9767
9889
|
let didShortCut = false;
|
|
9768
|
-
const
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9890
|
+
const stack = [startObject];
|
|
9891
|
+
const handleVisitorOnLen = [];
|
|
9892
|
+
const visitorStack = [];
|
|
9893
|
+
function handleVisitor() {
|
|
9894
|
+
while (stack.length === handleVisitorOnLen.at(-1)) {
|
|
9895
|
+
handleVisitorOnLen.pop();
|
|
9896
|
+
const toVisit = visitorStack.pop();
|
|
9897
|
+
visitor(toVisit);
|
|
9898
|
+
}
|
|
9899
|
+
}
|
|
9900
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9901
|
+
const curObject = stack.pop();
|
|
9902
|
+
if (!didShortCut) {
|
|
9903
|
+
if (Array.isArray(curObject)) {
|
|
9904
|
+
for (let i = curObject.length - 1; i >= 0; i--) {
|
|
9905
|
+
stack.push(curObject[i]);
|
|
9906
|
+
}
|
|
9907
|
+
handleVisitor();
|
|
9908
|
+
continue;
|
|
9909
|
+
}
|
|
9910
|
+
const context = preVisitor(curObject);
|
|
9911
|
+
didShortCut = context.shortcut ?? defaultShortcut;
|
|
9912
|
+
const continues = context.continue ?? defaultContinues;
|
|
9913
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9914
|
+
handleVisitorOnLen.push(stack.length);
|
|
9915
|
+
visitorStack.push(curObject);
|
|
9916
|
+
if (continues && !didShortCut) {
|
|
9917
|
+
for (const key in curObject) {
|
|
9918
|
+
if (!Object.hasOwn(curObject, key)) {
|
|
9919
|
+
continue;
|
|
9920
|
+
}
|
|
9921
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9922
|
+
continue;
|
|
9923
|
+
}
|
|
9924
|
+
const val = curObject[key];
|
|
9925
|
+
if (val && typeof val === "object") {
|
|
9926
|
+
stack.push(val);
|
|
9927
|
+
}
|
|
9776
9928
|
}
|
|
9777
|
-
this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9778
9929
|
}
|
|
9779
9930
|
}
|
|
9780
|
-
|
|
9781
|
-
}
|
|
9782
|
-
|
|
9931
|
+
handleVisitor();
|
|
9932
|
+
}
|
|
9933
|
+
if (stack.length >= this.maxStackSize) {
|
|
9934
|
+
throw new Error("Transform object stack overflowed");
|
|
9935
|
+
}
|
|
9936
|
+
handleVisitor();
|
|
9937
|
+
}
|
|
9938
|
+
};
|
|
9939
|
+
|
|
9940
|
+
// ../../packages/core/lib/TransformerTyped.js
|
|
9941
|
+
var TransformerTyped = class _TransformerTyped extends TransformerObject {
|
|
9942
|
+
defaultNodePreVisitor;
|
|
9943
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9944
|
+
super(defaultContext);
|
|
9945
|
+
this.defaultNodePreVisitor = defaultNodePreVisitor;
|
|
9783
9946
|
}
|
|
9947
|
+
clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
|
|
9948
|
+
return new _TransformerTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
|
|
9949
|
+
}
|
|
9950
|
+
/**
|
|
9951
|
+
* Transform a single node.
|
|
9952
|
+
* The transformation calls the preVisitor from starting from the startObject.
|
|
9953
|
+
* The preVisitor can dictate whether transformation should be stopped.
|
|
9954
|
+
* Note that stopping the transformation also prevets further copying.
|
|
9955
|
+
* The transformer itself transforms object starting with the deepest one that can be visited.
|
|
9956
|
+
* The transformer callback is performed on a copy of the original.
|
|
9957
|
+
* @param startObject
|
|
9958
|
+
* @param nodeCallBacks
|
|
9959
|
+
*/
|
|
9784
9960
|
transformNode(startObject, nodeCallBacks) {
|
|
9785
|
-
const transformWrapper = (
|
|
9786
|
-
|
|
9961
|
+
const transformWrapper = (copy3, orig) => {
|
|
9962
|
+
let ogTransform;
|
|
9963
|
+
const casted = copy3;
|
|
9787
9964
|
if (casted.type) {
|
|
9788
|
-
|
|
9789
|
-
if (ogFunc) {
|
|
9790
|
-
return ogFunc(casted);
|
|
9791
|
-
}
|
|
9965
|
+
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9792
9966
|
}
|
|
9793
|
-
return
|
|
9967
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9794
9968
|
};
|
|
9795
|
-
const
|
|
9969
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9970
|
+
const preVisitWrapper = (curObject) => {
|
|
9971
|
+
let ogPreVisit;
|
|
9972
|
+
let nodeContext = {};
|
|
9796
9973
|
const casted = curObject;
|
|
9797
9974
|
if (casted.type) {
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
return ogFunc(casted);
|
|
9801
|
-
}
|
|
9975
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9976
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9802
9977
|
}
|
|
9803
|
-
return {};
|
|
9978
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9804
9979
|
};
|
|
9805
|
-
return this.transformObject(startObject, transformWrapper,
|
|
9980
|
+
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9806
9981
|
}
|
|
9982
|
+
/**
|
|
9983
|
+
* Similar to {@link this.transformNode}, but without copying the startObject.
|
|
9984
|
+
* The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
|
|
9985
|
+
* @param startObject
|
|
9986
|
+
* @param nodeCallBacks
|
|
9987
|
+
*/
|
|
9807
9988
|
visitNode(startObject, nodeCallBacks) {
|
|
9808
|
-
const
|
|
9989
|
+
const visitorWrapper = (curObject) => {
|
|
9809
9990
|
const casted = curObject;
|
|
9810
9991
|
if (casted.type) {
|
|
9811
|
-
const
|
|
9812
|
-
if (
|
|
9813
|
-
|
|
9992
|
+
const ogTransform = nodeCallBacks[casted.type]?.visitor;
|
|
9993
|
+
if (ogTransform) {
|
|
9994
|
+
ogTransform(casted);
|
|
9814
9995
|
}
|
|
9815
9996
|
}
|
|
9816
9997
|
};
|
|
9998
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9817
9999
|
const preVisitWrapper = (curObject) => {
|
|
10000
|
+
let ogPreVisit;
|
|
10001
|
+
let nodeContext = {};
|
|
9818
10002
|
const casted = curObject;
|
|
9819
10003
|
if (casted.type) {
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
return ogFunc(casted);
|
|
9823
|
-
}
|
|
10004
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
10005
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9824
10006
|
}
|
|
9825
|
-
return {};
|
|
10007
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9826
10008
|
};
|
|
9827
|
-
this.visitObject(startObject,
|
|
10009
|
+
return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
|
|
9828
10010
|
}
|
|
10011
|
+
/**
|
|
10012
|
+
* Traverses only selected nodes as returned by the function.
|
|
10013
|
+
* @param currentNode
|
|
10014
|
+
* @param traverse
|
|
10015
|
+
*/
|
|
9829
10016
|
traverseNodes(currentNode, traverse) {
|
|
9830
10017
|
let didShortCut = false;
|
|
9831
10018
|
const recurse = (curNode) => {
|
|
@@ -9846,11 +10033,27 @@ var TransformerType = class {
|
|
|
9846
10033
|
recurse(currentNode);
|
|
9847
10034
|
}
|
|
9848
10035
|
};
|
|
9849
|
-
|
|
10036
|
+
|
|
10037
|
+
// ../../packages/core/lib/TransformerSubTyped.js
|
|
10038
|
+
var TransformerSubTyped = class _TransformerSubTyped extends TransformerTyped {
|
|
10039
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
10040
|
+
super(defaultContext, defaultNodePreVisitor);
|
|
10041
|
+
}
|
|
10042
|
+
clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
|
|
10043
|
+
return new _TransformerSubTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
|
|
10044
|
+
}
|
|
10045
|
+
/**
|
|
10046
|
+
* Shares the functionality and first two arguments with {@link this.transformNode}.
|
|
10047
|
+
* The third argument allows you to also transform based on the subType of objects.
|
|
10048
|
+
* Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
|
|
10049
|
+
* @param startObject
|
|
10050
|
+
* @param nodeCallBacks
|
|
10051
|
+
* @param nodeSpecificCallBacks
|
|
10052
|
+
*/
|
|
9850
10053
|
transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9851
|
-
const transformWrapper = (
|
|
10054
|
+
const transformWrapper = (copy3, orig) => {
|
|
9852
10055
|
let ogTransform;
|
|
9853
|
-
const casted =
|
|
10056
|
+
const casted = copy3;
|
|
9854
10057
|
if (casted.type && casted.subType) {
|
|
9855
10058
|
const specific = nodeSpecificCallBacks[casted.type];
|
|
9856
10059
|
if (specific) {
|
|
@@ -9860,7 +10063,7 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9860
10063
|
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9861
10064
|
}
|
|
9862
10065
|
}
|
|
9863
|
-
return ogTransform ? ogTransform(casted) :
|
|
10066
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9864
10067
|
};
|
|
9865
10068
|
const preVisitWrapper = (curObject) => {
|
|
9866
10069
|
let ogPreVisit;
|
|
@@ -9874,12 +10077,13 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9874
10077
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9875
10078
|
}
|
|
9876
10079
|
}
|
|
9877
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10080
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9878
10081
|
};
|
|
9879
10082
|
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9880
10083
|
}
|
|
9881
10084
|
/**
|
|
9882
|
-
*
|
|
10085
|
+
* Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
|
|
10086
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
|
|
9883
10087
|
*/
|
|
9884
10088
|
visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9885
10089
|
const visitWrapper = (curObject) => {
|
|
@@ -9910,10 +10114,16 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9910
10114
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9911
10115
|
}
|
|
9912
10116
|
}
|
|
9913
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10117
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9914
10118
|
};
|
|
9915
10119
|
this.visitObject(startObject, visitWrapper, preVisitWrapper);
|
|
9916
10120
|
}
|
|
10121
|
+
/**
|
|
10122
|
+
* Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
|
|
10123
|
+
* @param currentNode
|
|
10124
|
+
* @param traverseNode
|
|
10125
|
+
* @param traverseSubNode
|
|
10126
|
+
*/
|
|
9917
10127
|
traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
|
|
9918
10128
|
let didShortCut = false;
|
|
9919
10129
|
const recurse = (curNode) => {
|
|
@@ -10925,8 +11135,8 @@ function PatternFactoryMixin(Base) {
|
|
|
10925
11135
|
isPatternOptional(obj) {
|
|
10926
11136
|
return this.isOfSubType(obj, nodeType5, "optional");
|
|
10927
11137
|
}
|
|
10928
|
-
patternValues(values3, loc) {
|
|
10929
|
-
return { type: nodeType5, subType: "values", values: values3, loc };
|
|
11138
|
+
patternValues(variables, values3, loc) {
|
|
11139
|
+
return { type: nodeType5, subType: "values", variables, values: values3, loc };
|
|
10930
11140
|
}
|
|
10931
11141
|
isPatternValues(obj) {
|
|
10932
11142
|
return this.isOfSubType(obj, nodeType5, "values");
|
|
@@ -11101,7 +11311,7 @@ function TermFactoryMixin(Base) {
|
|
|
11101
11311
|
isTerm(x) {
|
|
11102
11312
|
return this.isOfType(x, "term");
|
|
11103
11313
|
}
|
|
11104
|
-
|
|
11314
|
+
termBlank(label, loc) {
|
|
11105
11315
|
const base = {
|
|
11106
11316
|
type: "term",
|
|
11107
11317
|
subType: "blankNode",
|
|
@@ -11115,7 +11325,7 @@ function TermFactoryMixin(Base) {
|
|
|
11115
11325
|
isTermBlank(obj) {
|
|
11116
11326
|
return this.isOfSubType(obj, nodeType8, "blankNode");
|
|
11117
11327
|
}
|
|
11118
|
-
|
|
11328
|
+
termLiteral(loc, value, langOrIri) {
|
|
11119
11329
|
return {
|
|
11120
11330
|
type: nodeType8,
|
|
11121
11331
|
subType: "literal",
|
|
@@ -11137,7 +11347,7 @@ function TermFactoryMixin(Base) {
|
|
|
11137
11347
|
const casted = obj;
|
|
11138
11348
|
return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
|
|
11139
11349
|
}
|
|
11140
|
-
|
|
11350
|
+
termVariable(value, loc) {
|
|
11141
11351
|
return {
|
|
11142
11352
|
type: nodeType8,
|
|
11143
11353
|
subType: "variable",
|
|
@@ -11148,7 +11358,7 @@ function TermFactoryMixin(Base) {
|
|
|
11148
11358
|
isTermVariable(obj) {
|
|
11149
11359
|
return this.isOfSubType(obj, nodeType8, "variable");
|
|
11150
11360
|
}
|
|
11151
|
-
|
|
11361
|
+
termNamed(loc, value, prefix) {
|
|
11152
11362
|
const base = {
|
|
11153
11363
|
type: nodeType8,
|
|
11154
11364
|
subType: "namedNode",
|
|
@@ -11393,7 +11603,7 @@ var CommonIRIs;
|
|
|
11393
11603
|
CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
11394
11604
|
CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
11395
11605
|
})(CommonIRIs || (CommonIRIs = {}));
|
|
11396
|
-
var AstTransformer = class extends
|
|
11606
|
+
var AstTransformer = class extends TransformerSubTyped {
|
|
11397
11607
|
};
|
|
11398
11608
|
|
|
11399
11609
|
// ../../packages/rules-sparql-1-1/lib/validation/validators.js
|
|
@@ -11521,8 +11731,7 @@ function findPatternBoundedVars(iter, boundedVars) {
|
|
|
11521
11731
|
optional: (op) => ({ next: op.patterns }),
|
|
11522
11732
|
service: (op) => ({ next: [op.name, ...op.patterns] }),
|
|
11523
11733
|
bind: (op) => ({ next: [op.variable] }),
|
|
11524
|
-
graph: (op) => ({ next: [op.name, ...op.patterns] })
|
|
11525
|
-
minus: (op) => ({ next: op.patterns.slice(0, 1) })
|
|
11734
|
+
graph: (op) => ({ next: [op.name, ...op.patterns] })
|
|
11526
11735
|
},
|
|
11527
11736
|
term: {
|
|
11528
11737
|
variable: (op) => {
|
|
@@ -11609,17 +11818,20 @@ var rdfLiteral = {
|
|
|
11609
11818
|
return OPTION(() => OR([
|
|
11610
11819
|
{ ALT: () => {
|
|
11611
11820
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11612
|
-
return ACTION(() => C.astFactory.
|
|
11821
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11613
11822
|
} },
|
|
11614
11823
|
{ ALT: () => {
|
|
11615
11824
|
CONSUME(symbols_exports.hathat);
|
|
11616
11825
|
const iriVal = SUBRULE1(iri2);
|
|
11617
|
-
return ACTION(() => C.astFactory.
|
|
11826
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11618
11827
|
} }
|
|
11619
11828
|
])) ?? value;
|
|
11620
11829
|
},
|
|
11621
|
-
gImpl: ({ SUBRULE, PRINT,
|
|
11622
|
-
astFactory.printFilter(ast, () =>
|
|
11830
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11831
|
+
astFactory.printFilter(ast, () => {
|
|
11832
|
+
PRINT_WORD("");
|
|
11833
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
11834
|
+
});
|
|
11623
11835
|
if (ast.langOrIri) {
|
|
11624
11836
|
if (typeof ast.langOrIri === "string") {
|
|
11625
11837
|
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
@@ -11646,7 +11858,7 @@ var numericLiteralUnsigned = {
|
|
|
11646
11858
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11647
11859
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11648
11860
|
]);
|
|
11649
|
-
return ACTION(() => C.astFactory.
|
|
11861
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11650
11862
|
}
|
|
11651
11863
|
};
|
|
11652
11864
|
var numericLiteralPositive = {
|
|
@@ -11657,7 +11869,7 @@ var numericLiteralPositive = {
|
|
|
11657
11869
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11658
11870
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11659
11871
|
]);
|
|
11660
|
-
return ACTION(() => C.astFactory.
|
|
11872
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11661
11873
|
}
|
|
11662
11874
|
};
|
|
11663
11875
|
var numericLiteralNegative = {
|
|
@@ -11668,7 +11880,7 @@ var numericLiteralNegative = {
|
|
|
11668
11880
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11669
11881
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11670
11882
|
]);
|
|
11671
|
-
return ACTION(() => C.astFactory.
|
|
11883
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11672
11884
|
}
|
|
11673
11885
|
};
|
|
11674
11886
|
var booleanLiteral = {
|
|
@@ -11678,7 +11890,7 @@ var booleanLiteral = {
|
|
|
11678
11890
|
{ ALT: () => CONSUME(true_) },
|
|
11679
11891
|
{ ALT: () => CONSUME(false_) }
|
|
11680
11892
|
]);
|
|
11681
|
-
return ACTION(() => C.astFactory.
|
|
11893
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11682
11894
|
}
|
|
11683
11895
|
};
|
|
11684
11896
|
var string = {
|
|
@@ -11720,7 +11932,7 @@ var string = {
|
|
|
11720
11932
|
return char;
|
|
11721
11933
|
}
|
|
11722
11934
|
});
|
|
11723
|
-
return F2.
|
|
11935
|
+
return F2.termLiteral(F2.sourceLocation(x[0]), value);
|
|
11724
11936
|
});
|
|
11725
11937
|
}
|
|
11726
11938
|
};
|
|
@@ -11736,7 +11948,7 @@ var iriFull = {
|
|
|
11736
11948
|
name: "iriFull",
|
|
11737
11949
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11738
11950
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11739
|
-
return ACTION(() => C.astFactory.
|
|
11951
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11740
11952
|
},
|
|
11741
11953
|
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
11742
11954
|
F2.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
@@ -11749,16 +11961,16 @@ var prefixedName = {
|
|
|
11749
11961
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11750
11962
|
return ACTION(() => {
|
|
11751
11963
|
const [prefix, localName] = longName.image.split(":");
|
|
11752
|
-
return C.astFactory.
|
|
11964
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11753
11965
|
});
|
|
11754
11966
|
} },
|
|
11755
11967
|
{ ALT: () => {
|
|
11756
11968
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11757
|
-
return ACTION(() => C.astFactory.
|
|
11969
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11758
11970
|
} }
|
|
11759
11971
|
]),
|
|
11760
|
-
gImpl: ({
|
|
11761
|
-
F2.printFilter(ast, () =>
|
|
11972
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
11973
|
+
F2.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
11762
11974
|
}
|
|
11763
11975
|
};
|
|
11764
11976
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11768,11 +11980,11 @@ var blankNode = {
|
|
|
11768
11980
|
const result = OR([
|
|
11769
11981
|
{ ALT: () => {
|
|
11770
11982
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11771
|
-
return ACTION(() => C.astFactory.
|
|
11983
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11772
11984
|
} },
|
|
11773
11985
|
{ ALT: () => {
|
|
11774
11986
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11775
|
-
return ACTION(() => C.astFactory.
|
|
11987
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11776
11988
|
} }
|
|
11777
11989
|
]);
|
|
11778
11990
|
ACTION(() => {
|
|
@@ -11782,15 +11994,15 @@ var blankNode = {
|
|
|
11782
11994
|
});
|
|
11783
11995
|
return result;
|
|
11784
11996
|
},
|
|
11785
|
-
gImpl: ({
|
|
11786
|
-
astFactory.printFilter(ast, () =>
|
|
11997
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
11998
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
11787
11999
|
}
|
|
11788
12000
|
};
|
|
11789
12001
|
var verbA = {
|
|
11790
12002
|
name: "VerbA",
|
|
11791
12003
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11792
12004
|
const token = CONSUME(a);
|
|
11793
|
-
return ACTION(() => C.astFactory.
|
|
12005
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11794
12006
|
}
|
|
11795
12007
|
};
|
|
11796
12008
|
|
|
@@ -11824,10 +12036,10 @@ var baseDecl2 = {
|
|
|
11824
12036
|
const val = SUBRULE(iriFull);
|
|
11825
12037
|
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11826
12038
|
},
|
|
11827
|
-
gImpl: ({ SUBRULE,
|
|
11828
|
-
F2.printFilter(ast, () =>
|
|
12039
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12040
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
|
|
11829
12041
|
SUBRULE(iri2, ast.value);
|
|
11830
|
-
F2.printFilter(ast, () =>
|
|
12042
|
+
F2.printFilter(ast, () => NEW_LINE());
|
|
11831
12043
|
}
|
|
11832
12044
|
};
|
|
11833
12045
|
var prefixDecl2 = {
|
|
@@ -11838,12 +12050,12 @@ var prefixDecl2 = {
|
|
|
11838
12050
|
const value = SUBRULE(iriFull);
|
|
11839
12051
|
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11840
12052
|
},
|
|
11841
|
-
gImpl: ({ SUBRULE,
|
|
12053
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
11842
12054
|
F2.printFilter(ast, () => {
|
|
11843
|
-
|
|
12055
|
+
PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
|
|
11844
12056
|
});
|
|
11845
12057
|
SUBRULE(iri2, ast.value);
|
|
11846
|
-
F2.printFilter(ast, () =>
|
|
12058
|
+
F2.printFilter(ast, () => NEW_LINE());
|
|
11847
12059
|
}
|
|
11848
12060
|
};
|
|
11849
12061
|
var verb = {
|
|
@@ -11880,10 +12092,10 @@ var var_ = {
|
|
|
11880
12092
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11881
12093
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11882
12094
|
]);
|
|
11883
|
-
return ACTION(() => C.astFactory.
|
|
12095
|
+
return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11884
12096
|
},
|
|
11885
|
-
gImpl: ({
|
|
11886
|
-
F2.printFilter(ast, () =>
|
|
12097
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
12098
|
+
F2.printFilter(ast, () => PRINT(`?${ast.value}`));
|
|
11887
12099
|
}
|
|
11888
12100
|
};
|
|
11889
12101
|
var graphTerm = {
|
|
@@ -11896,7 +12108,7 @@ var graphTerm = {
|
|
|
11896
12108
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
11897
12109
|
{ ALT: () => {
|
|
11898
12110
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
11899
|
-
return ACTION(() => C.astFactory.
|
|
12111
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
11900
12112
|
} }
|
|
11901
12113
|
]),
|
|
11902
12114
|
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
@@ -12526,13 +12738,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12526
12738
|
var triplesBlock = {
|
|
12527
12739
|
name: "triplesBlock",
|
|
12528
12740
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12529
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F2 }) => {
|
|
12741
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12530
12742
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12531
12743
|
HANDLE_LOC(triple, () => {
|
|
12532
12744
|
const nextTriple = ast.triples.at(index);
|
|
12533
12745
|
if (F2.isTripleCollection(triple)) {
|
|
12534
12746
|
SUBRULE(graphNodePath, triple);
|
|
12535
|
-
F2.printFilter(triple, () =>
|
|
12747
|
+
F2.printFilter(triple, () => {
|
|
12748
|
+
PRINT_WORD(".");
|
|
12749
|
+
NEW_LINE();
|
|
12750
|
+
});
|
|
12536
12751
|
} else {
|
|
12537
12752
|
SUBRULE(graphNodePath, triple.subject);
|
|
12538
12753
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
@@ -12544,11 +12759,17 @@ var triplesBlock = {
|
|
|
12544
12759
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12545
12760
|
SUBRULE(graphNodePath, triple.object);
|
|
12546
12761
|
if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12547
|
-
F2.printFilter(ast, () =>
|
|
12762
|
+
F2.printFilter(ast, () => {
|
|
12763
|
+
PRINT_WORD(".");
|
|
12764
|
+
NEW_LINE();
|
|
12765
|
+
});
|
|
12548
12766
|
} else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12549
12767
|
F2.printFilter(ast, () => PRINT_WORD(","));
|
|
12550
12768
|
} else {
|
|
12551
|
-
F2.printFilter(ast, () =>
|
|
12769
|
+
F2.printFilter(ast, () => {
|
|
12770
|
+
PRINT_WORD(";");
|
|
12771
|
+
NEW_LINE();
|
|
12772
|
+
});
|
|
12552
12773
|
}
|
|
12553
12774
|
}
|
|
12554
12775
|
});
|
|
@@ -12681,10 +12902,10 @@ function collectionImpl(name, allowPaths) {
|
|
|
12681
12902
|
return ACTION(() => {
|
|
12682
12903
|
const F2 = C.astFactory;
|
|
12683
12904
|
const triples = [];
|
|
12684
|
-
const predFirst = F2.
|
|
12685
|
-
const predRest = F2.
|
|
12686
|
-
const predNil = F2.
|
|
12687
|
-
const listHead = F2.
|
|
12905
|
+
const predFirst = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12906
|
+
const predRest = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
12907
|
+
const predNil = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
|
|
12908
|
+
const listHead = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
|
|
12688
12909
|
let iterHead = listHead;
|
|
12689
12910
|
for (const [index, term] of terms.entries()) {
|
|
12690
12911
|
const lastInList = index === terms.length - 1;
|
|
@@ -12694,7 +12915,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12694
12915
|
const nilTriple = F2.triple(iterHead, predRest, predNil);
|
|
12695
12916
|
triples.push(nilTriple);
|
|
12696
12917
|
} else {
|
|
12697
|
-
const tail = F2.
|
|
12918
|
+
const tail = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
|
|
12698
12919
|
const linkTriple = F2.triple(iterHead, predRest, tail);
|
|
12699
12920
|
triples.push(linkTriple);
|
|
12700
12921
|
iterHead = tail;
|
|
@@ -12734,16 +12955,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12734
12955
|
name,
|
|
12735
12956
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12736
12957
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12737
|
-
const blankNode2 = ACTION(() => C.astFactory.
|
|
12958
|
+
const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12738
12959
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12739
12960
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12740
12961
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12741
12962
|
},
|
|
12742
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
12963
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
12743
12964
|
const { astFactory: F2, indentInc } = c;
|
|
12744
12965
|
F2.printFilter(ast, () => {
|
|
12745
12966
|
c[traqulaIndentation] += indentInc;
|
|
12746
|
-
PRINT("[
|
|
12967
|
+
PRINT("[");
|
|
12968
|
+
NEW_LINE();
|
|
12747
12969
|
});
|
|
12748
12970
|
for (const triple of ast.triples) {
|
|
12749
12971
|
HANDLE_LOC(triple, () => {
|
|
@@ -12754,7 +12976,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12754
12976
|
}
|
|
12755
12977
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12756
12978
|
SUBRULE(graphNodePath, triple.object);
|
|
12757
|
-
F2.printFilter(ast, () =>
|
|
12979
|
+
F2.printFilter(ast, () => {
|
|
12980
|
+
PRINT_WORD(";");
|
|
12981
|
+
NEW_LINE();
|
|
12982
|
+
});
|
|
12758
12983
|
});
|
|
12759
12984
|
}
|
|
12760
12985
|
F2.printFilter(ast, () => {
|
|
@@ -12813,18 +13038,19 @@ var groupGraphPattern = {
|
|
|
12813
13038
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12814
13039
|
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12815
13040
|
},
|
|
12816
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
13041
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12817
13042
|
const { astFactory: F2, indentInc } = C;
|
|
12818
13043
|
F2.printFilter(ast, () => {
|
|
12819
13044
|
C[traqulaIndentation] += indentInc;
|
|
12820
|
-
PRINT_WORD("{
|
|
13045
|
+
PRINT_WORD("{");
|
|
13046
|
+
NEW_LINE();
|
|
12821
13047
|
});
|
|
12822
13048
|
for (const pattern of ast.patterns) {
|
|
12823
13049
|
SUBRULE(generatePattern, pattern);
|
|
12824
13050
|
}
|
|
12825
13051
|
F2.printFilter(ast, () => {
|
|
12826
13052
|
C[traqulaIndentation] -= indentInc;
|
|
12827
|
-
|
|
13053
|
+
PRINT_ON_OWN_LINE("}");
|
|
12828
13054
|
});
|
|
12829
13055
|
}
|
|
12830
13056
|
};
|
|
@@ -12974,12 +13200,15 @@ var bind2 = {
|
|
|
12974
13200
|
const close = CONSUME(symbols_exports.RParen);
|
|
12975
13201
|
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
12976
13202
|
},
|
|
12977
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13203
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12978
13204
|
F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
12979
13205
|
SUBRULE(expression, ast.expression);
|
|
12980
13206
|
F2.printFilter(ast, () => PRINT_WORD("AS"));
|
|
12981
13207
|
SUBRULE(var_, ast.variable);
|
|
12982
|
-
F2.printFilter(ast, () =>
|
|
13208
|
+
F2.printFilter(ast, () => {
|
|
13209
|
+
PRINT_WORD(")");
|
|
13210
|
+
NEW_LINE();
|
|
13211
|
+
});
|
|
12983
13212
|
}
|
|
12984
13213
|
};
|
|
12985
13214
|
var inlineData = {
|
|
@@ -12987,34 +13216,46 @@ var inlineData = {
|
|
|
12987
13216
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12988
13217
|
const values3 = CONSUME(values2);
|
|
12989
13218
|
const datablock = SUBRULE(dataBlock);
|
|
12990
|
-
return ACTION(() =>
|
|
13219
|
+
return ACTION(() => {
|
|
13220
|
+
datablock.loc = C.astFactory.sourceLocation(values3, datablock);
|
|
13221
|
+
return datablock;
|
|
13222
|
+
});
|
|
12991
13223
|
},
|
|
12992
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13224
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12993
13225
|
const { astFactory: F2, indentInc } = C;
|
|
12994
|
-
const variables =
|
|
13226
|
+
const variables = ast.variables;
|
|
13227
|
+
const singleVar = variables.length === 1;
|
|
13228
|
+
F2.printFilter(ast, () => {
|
|
13229
|
+
PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
|
|
13230
|
+
});
|
|
13231
|
+
for (const variable of variables) {
|
|
13232
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13233
|
+
SUBRULE(varOrTerm, variable);
|
|
13234
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13235
|
+
}
|
|
12995
13236
|
F2.printFilter(ast, () => {
|
|
12996
|
-
PRINT_ON_EMPTY("");
|
|
12997
|
-
PRINT_WORD("VALUES", "(");
|
|
12998
|
-
for (const variable of variables) {
|
|
12999
|
-
PRINT_WORD(`?${variable}`);
|
|
13000
|
-
}
|
|
13001
13237
|
C[traqulaIndentation] += indentInc;
|
|
13002
|
-
PRINT_WORD(")", "{
|
|
13238
|
+
PRINT_WORD(singleVar ? "" : ")", "{");
|
|
13239
|
+
NEW_LINE();
|
|
13003
13240
|
});
|
|
13004
13241
|
for (const mapping of ast.values) {
|
|
13005
|
-
F2.printFilter(ast, () => PRINT_WORD("("));
|
|
13242
|
+
F2.printFilter(ast, () => !singleVar && PRINT_WORD("("));
|
|
13006
13243
|
for (const variable of variables) {
|
|
13007
|
-
|
|
13244
|
+
const var_2 = variable.value;
|
|
13245
|
+
if (mapping[var_2] === void 0) {
|
|
13008
13246
|
F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
|
|
13009
13247
|
} else {
|
|
13010
|
-
SUBRULE(graphNodePath, mapping[
|
|
13248
|
+
SUBRULE(graphNodePath, mapping[var_2]);
|
|
13011
13249
|
}
|
|
13012
13250
|
}
|
|
13013
|
-
F2.printFilter(ast, () =>
|
|
13251
|
+
F2.printFilter(ast, () => {
|
|
13252
|
+
PRINT_WORD(singleVar ? "" : ")");
|
|
13253
|
+
NEW_LINE();
|
|
13254
|
+
});
|
|
13014
13255
|
}
|
|
13015
13256
|
F2.printFilter(ast, () => {
|
|
13016
13257
|
C[traqulaIndentation] -= indentInc;
|
|
13017
|
-
|
|
13258
|
+
PRINT_ON_OWN_LINE("}");
|
|
13018
13259
|
});
|
|
13019
13260
|
}
|
|
13020
13261
|
};
|
|
@@ -13038,7 +13279,7 @@ var inlineDataOneVar = {
|
|
|
13038
13279
|
});
|
|
13039
13280
|
});
|
|
13040
13281
|
const close = CONSUME(symbols_exports.RCurly);
|
|
13041
|
-
return ACTION(() => C.astFactory.
|
|
13282
|
+
return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
|
|
13042
13283
|
}
|
|
13043
13284
|
};
|
|
13044
13285
|
var inlineDataFull = {
|
|
@@ -13055,7 +13296,7 @@ var inlineDataFull = {
|
|
|
13055
13296
|
res.push({});
|
|
13056
13297
|
});
|
|
13057
13298
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
13058
|
-
return ACTION(() => C.astFactory.
|
|
13299
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
|
|
13059
13300
|
} },
|
|
13060
13301
|
{ ALT: () => {
|
|
13061
13302
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -13087,7 +13328,7 @@ var inlineDataFull = {
|
|
|
13087
13328
|
});
|
|
13088
13329
|
});
|
|
13089
13330
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
13090
|
-
return ACTION(() => C.astFactory.
|
|
13331
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
|
|
13091
13332
|
} }
|
|
13092
13333
|
]);
|
|
13093
13334
|
}
|
|
@@ -13150,10 +13391,13 @@ var filter3 = {
|
|
|
13150
13391
|
const expression2 = SUBRULE(constraint);
|
|
13151
13392
|
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
13152
13393
|
},
|
|
13153
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13394
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
13154
13395
|
F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
13155
13396
|
SUBRULE(expression, ast.expression);
|
|
13156
|
-
F2.printFilter(ast, () =>
|
|
13397
|
+
F2.printFilter(ast, () => {
|
|
13398
|
+
PRINT_WORD(")");
|
|
13399
|
+
NEW_LINE();
|
|
13400
|
+
});
|
|
13157
13401
|
}
|
|
13158
13402
|
};
|
|
13159
13403
|
var constraint = {
|
|
@@ -13539,8 +13783,7 @@ var groupClause = {
|
|
|
13539
13783
|
},
|
|
13540
13784
|
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13541
13785
|
F2.printFilter(ast, () => {
|
|
13542
|
-
PRINT_ON_EMPTY("");
|
|
13543
|
-
PRINT_WORDS("GROUP", "BY");
|
|
13786
|
+
PRINT_ON_EMPTY("GROUP BY ");
|
|
13544
13787
|
});
|
|
13545
13788
|
for (const grouping of ast.groupings) {
|
|
13546
13789
|
if (F2.isExpression(grouping)) {
|
|
@@ -13596,10 +13839,9 @@ var havingClause = {
|
|
|
13596
13839
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13597
13840
|
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13598
13841
|
},
|
|
13599
|
-
gImpl: ({
|
|
13842
|
+
gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13600
13843
|
F2.printFilter(ast, () => {
|
|
13601
|
-
PRINT_ON_EMPTY("");
|
|
13602
|
-
PRINT_WORD("HAVING");
|
|
13844
|
+
PRINT_ON_EMPTY("HAVING ");
|
|
13603
13845
|
});
|
|
13604
13846
|
for (const having2 of ast.having) {
|
|
13605
13847
|
SUBRULE(expression, having2);
|
|
@@ -13625,8 +13867,7 @@ var orderClause = {
|
|
|
13625
13867
|
},
|
|
13626
13868
|
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13627
13869
|
F2.printFilter(ast, () => {
|
|
13628
|
-
PRINT_ON_EMPTY("");
|
|
13629
|
-
PRINT_WORDS("ORDER", "BY");
|
|
13870
|
+
PRINT_ON_EMPTY("ORDER BY ");
|
|
13630
13871
|
});
|
|
13631
13872
|
for (const ordering of ast.orderDefs) {
|
|
13632
13873
|
if (ordering.descending) {
|
|
@@ -13685,9 +13926,9 @@ var limitOffsetClauses = {
|
|
|
13685
13926
|
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13686
13927
|
} }
|
|
13687
13928
|
]),
|
|
13688
|
-
gImpl: ({ PRINT_WORDS,
|
|
13929
|
+
gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
13689
13930
|
F2.printFilter(ast, () => {
|
|
13690
|
-
|
|
13931
|
+
NEW_LINE();
|
|
13691
13932
|
if (ast.limit) {
|
|
13692
13933
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13693
13934
|
}
|
|
@@ -13872,9 +14113,9 @@ var selectClause = {
|
|
|
13872
14113
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13873
14114
|
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13874
14115
|
},
|
|
13875
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14116
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13876
14117
|
F2.printFilter(ast, () => {
|
|
13877
|
-
|
|
14118
|
+
PRINT_ON_EMPTY("SELECT ");
|
|
13878
14119
|
if (ast.val.distinct) {
|
|
13879
14120
|
PRINT_WORD("DISTINCT");
|
|
13880
14121
|
} else if (ast.val.reduced) {
|
|
@@ -13893,7 +14134,9 @@ var selectClause = {
|
|
|
13893
14134
|
SUBRULE(var_, variable.variable);
|
|
13894
14135
|
F2.printFilter(ast, () => PRINT_WORD(")"));
|
|
13895
14136
|
}
|
|
14137
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13896
14138
|
}
|
|
14139
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13897
14140
|
}
|
|
13898
14141
|
};
|
|
13899
14142
|
var constructQuery = {
|
|
@@ -13931,18 +14174,19 @@ var constructQuery = {
|
|
|
13931
14174
|
} }
|
|
13932
14175
|
]);
|
|
13933
14176
|
},
|
|
13934
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14177
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
13935
14178
|
const { astFactory: F2, indentInc } = C;
|
|
13936
|
-
F2.printFilter(ast, () =>
|
|
14179
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
|
|
13937
14180
|
if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
13938
14181
|
F2.printFilter(ast, () => {
|
|
13939
14182
|
C[traqulaIndentation] += indentInc;
|
|
13940
|
-
PRINT_WORD("{
|
|
14183
|
+
PRINT_WORD("{");
|
|
14184
|
+
NEW_LINE();
|
|
13941
14185
|
});
|
|
13942
14186
|
SUBRULE(triplesBlock, ast.template);
|
|
13943
14187
|
F2.printFilter(ast, () => {
|
|
13944
14188
|
C[traqulaIndentation] -= indentInc;
|
|
13945
|
-
|
|
14189
|
+
PRINT_ON_OWN_LINE("}");
|
|
13946
14190
|
});
|
|
13947
14191
|
}
|
|
13948
14192
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
@@ -13983,8 +14227,8 @@ var describeQuery = {
|
|
|
13983
14227
|
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13984
14228
|
}));
|
|
13985
14229
|
},
|
|
13986
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13987
|
-
F2.printFilter(ast, () =>
|
|
14230
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14231
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
|
|
13988
14232
|
if (F2.isWildcard(ast.variables[0])) {
|
|
13989
14233
|
F2.printFilter(ast, () => PRINT_WORD("*"));
|
|
13990
14234
|
} else {
|
|
@@ -14014,8 +14258,8 @@ var askQuery = {
|
|
|
14014
14258
|
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14015
14259
|
}));
|
|
14016
14260
|
},
|
|
14017
|
-
gImpl: ({ SUBRULE,
|
|
14018
|
-
F2.printFilter(ast, () =>
|
|
14261
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14262
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
|
|
14019
14263
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
14020
14264
|
SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
|
|
14021
14265
|
SUBRULE(solutionModifier, ast.solutionModifiers);
|
|
@@ -14074,7 +14318,7 @@ var update = {
|
|
|
14074
14318
|
return update2;
|
|
14075
14319
|
});
|
|
14076
14320
|
},
|
|
14077
|
-
gImpl: ({ SUBRULE,
|
|
14321
|
+
gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
14078
14322
|
const [head2, ...tail] = ast.updates;
|
|
14079
14323
|
if (head2) {
|
|
14080
14324
|
SUBRULE(prologue, head2.context);
|
|
@@ -14083,7 +14327,10 @@ var update = {
|
|
|
14083
14327
|
}
|
|
14084
14328
|
}
|
|
14085
14329
|
for (const update2 of tail) {
|
|
14086
|
-
F2.printFilter(ast, () =>
|
|
14330
|
+
F2.printFilter(ast, () => {
|
|
14331
|
+
PRINT(";");
|
|
14332
|
+
NEW_LINE();
|
|
14333
|
+
});
|
|
14087
14334
|
SUBRULE(prologue, update2.context);
|
|
14088
14335
|
if (update2.operation) {
|
|
14089
14336
|
SUBRULE(update1, update2.operation);
|
|
@@ -14156,9 +14403,9 @@ var load2 = {
|
|
|
14156
14403
|
});
|
|
14157
14404
|
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
14158
14405
|
},
|
|
14159
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14406
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14160
14407
|
F2.printFilter(ast, () => {
|
|
14161
|
-
|
|
14408
|
+
PRINT_ON_EMPTY("LOAD ");
|
|
14162
14409
|
if (ast.silent) {
|
|
14163
14410
|
PRINT_WORD("SILENT");
|
|
14164
14411
|
}
|
|
@@ -14179,9 +14426,9 @@ function clearOrDrop(operation) {
|
|
|
14179
14426
|
const destination = SUBRULE1(graphRefAll);
|
|
14180
14427
|
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
14181
14428
|
},
|
|
14182
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14429
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14183
14430
|
F2.printFilter(ast, () => {
|
|
14184
|
-
|
|
14431
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14185
14432
|
if (ast.silent) {
|
|
14186
14433
|
PRINT_WORD("SILENT");
|
|
14187
14434
|
}
|
|
@@ -14200,9 +14447,9 @@ var create2 = {
|
|
|
14200
14447
|
const destination = SUBRULE1(graphRef);
|
|
14201
14448
|
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
14202
14449
|
},
|
|
14203
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14450
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14204
14451
|
F2.printFilter(ast, () => {
|
|
14205
|
-
|
|
14452
|
+
PRINT_ON_EMPTY("CREATE ");
|
|
14206
14453
|
if (ast.silent) {
|
|
14207
14454
|
PRINT_WORD("SILENT");
|
|
14208
14455
|
}
|
|
@@ -14221,9 +14468,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14221
14468
|
const destination = SUBRULE2(graphOrDefault);
|
|
14222
14469
|
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14223
14470
|
},
|
|
14224
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14471
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14225
14472
|
F2.printFilter(ast, () => {
|
|
14226
|
-
|
|
14473
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14227
14474
|
if (ast.silent) {
|
|
14228
14475
|
PRINT_WORD("SILENT");
|
|
14229
14476
|
}
|
|
@@ -14272,23 +14519,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
|
|
|
14272
14519
|
}
|
|
14273
14520
|
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14274
14521
|
},
|
|
14275
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14522
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14276
14523
|
const { astFactory: F2, indentInc } = C;
|
|
14277
14524
|
F2.printFilter(ast, () => {
|
|
14278
|
-
C[traqulaIndentation] += indentInc;
|
|
14279
14525
|
if (subType === "insertdata") {
|
|
14280
|
-
|
|
14526
|
+
PRINT_ON_EMPTY("INSERT DATA ");
|
|
14281
14527
|
} else if (subType === "deletedata") {
|
|
14282
|
-
|
|
14528
|
+
PRINT_ON_EMPTY("DELETE DATA ");
|
|
14283
14529
|
} else if (subType === "deletewhere") {
|
|
14284
|
-
|
|
14530
|
+
PRINT_ON_EMPTY("DELETE WHERE ");
|
|
14285
14531
|
}
|
|
14286
|
-
|
|
14532
|
+
C[traqulaIndentation] += indentInc;
|
|
14533
|
+
PRINT_WORD("{");
|
|
14534
|
+
NEW_LINE();
|
|
14287
14535
|
});
|
|
14288
14536
|
SUBRULE(quads, F2.wrap(ast.data, ast.loc));
|
|
14289
14537
|
F2.printFilter(ast, () => {
|
|
14290
14538
|
C[traqulaIndentation] -= indentInc;
|
|
14291
|
-
|
|
14539
|
+
PRINT_ON_OWN_LINE("}");
|
|
14292
14540
|
});
|
|
14293
14541
|
}
|
|
14294
14542
|
};
|
|
@@ -14320,36 +14568,40 @@ var modify = {
|
|
|
14320
14568
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14321
14569
|
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14322
14570
|
},
|
|
14323
|
-
gImpl: ({ SUBRULE,
|
|
14571
|
+
gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
|
|
14324
14572
|
const { astFactory: F2, indentInc } = C;
|
|
14325
14573
|
if (ast.graph) {
|
|
14326
|
-
F2.printFilter(ast, () =>
|
|
14574
|
+
F2.printFilter(ast, () => PRINT_WORDS("WITH"));
|
|
14327
14575
|
SUBRULE(iri2, ast.graph);
|
|
14328
14576
|
}
|
|
14329
14577
|
if (ast.delete.length > 0) {
|
|
14330
14578
|
F2.printFilter(ast, () => {
|
|
14331
14579
|
C[traqulaIndentation] += indentInc;
|
|
14332
|
-
|
|
14580
|
+
PRINT_WORDS("DELETE", "{");
|
|
14581
|
+
NEW_LINE();
|
|
14333
14582
|
});
|
|
14334
14583
|
SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
|
|
14335
14584
|
F2.printFilter(ast, () => {
|
|
14336
14585
|
C[traqulaIndentation] -= indentInc;
|
|
14337
|
-
PRINT_ON_EMPTY("}
|
|
14586
|
+
PRINT_ON_EMPTY("}");
|
|
14587
|
+
NEW_LINE();
|
|
14338
14588
|
});
|
|
14339
14589
|
}
|
|
14340
14590
|
if (ast.insert.length > 0) {
|
|
14341
14591
|
F2.printFilter(ast, () => {
|
|
14342
14592
|
C[traqulaIndentation] += indentInc;
|
|
14343
|
-
|
|
14593
|
+
PRINT_WORDS("INSERT", "{");
|
|
14594
|
+
NEW_LINE();
|
|
14344
14595
|
});
|
|
14345
14596
|
SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
|
|
14346
14597
|
F2.printFilter(ast, () => {
|
|
14347
14598
|
C[traqulaIndentation] -= indentInc;
|
|
14348
|
-
PRINT_ON_EMPTY("}
|
|
14599
|
+
PRINT_ON_EMPTY("} ");
|
|
14600
|
+
NEW_LINE();
|
|
14349
14601
|
});
|
|
14350
14602
|
}
|
|
14351
14603
|
SUBRULE(usingClauseStar, ast.from);
|
|
14352
|
-
F2.printFilter(ast, () =>
|
|
14604
|
+
F2.printFilter(ast, () => PRINT_WORDS("WHERE"));
|
|
14353
14605
|
SUBRULE(groupGraphPattern, ast.where);
|
|
14354
14606
|
}
|
|
14355
14607
|
};
|
|
@@ -14473,18 +14725,19 @@ var quadsNotTriples = {
|
|
|
14473
14725
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14474
14726
|
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14475
14727
|
},
|
|
14476
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
14728
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14477
14729
|
const { astFactory: F2, indentInc } = C;
|
|
14478
14730
|
F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14479
14731
|
SUBRULE(varOrTerm, ast.graph);
|
|
14480
14732
|
F2.printFilter(ast, () => {
|
|
14481
14733
|
C[traqulaIndentation] += indentInc;
|
|
14482
|
-
PRINT_WORD("{
|
|
14734
|
+
PRINT_WORD("{");
|
|
14735
|
+
NEW_LINE();
|
|
14483
14736
|
});
|
|
14484
14737
|
SUBRULE(triplesBlock, ast.triples);
|
|
14485
14738
|
F2.printFilter(ast, () => {
|
|
14486
14739
|
C[traqulaIndentation] -= indentInc;
|
|
14487
|
-
|
|
14740
|
+
PRINT_ON_OWN_LINE("}");
|
|
14488
14741
|
});
|
|
14489
14742
|
}
|
|
14490
14743
|
};
|
|
@@ -14638,13 +14891,16 @@ var sparql11GeneratorBuilder = GeneratorBuilder.create([
|
|
|
14638
14891
|
grammar_exports.filter
|
|
14639
14892
|
);
|
|
14640
14893
|
var Generator = class {
|
|
14894
|
+
constructor(defaultContext = {}) {
|
|
14895
|
+
this.defaultContext = defaultContext;
|
|
14896
|
+
}
|
|
14641
14897
|
generator = sparql11GeneratorBuilder.build();
|
|
14642
14898
|
factory = new AstFactory();
|
|
14643
14899
|
generate(ast, context = {}) {
|
|
14644
|
-
return this.generator.queryOrUpdate(ast, completeParseContext(context));
|
|
14900
|
+
return this.generator.queryOrUpdate(ast, completeParseContext({ ...this.defaultContext, ...context })).trim();
|
|
14645
14901
|
}
|
|
14646
14902
|
generatePath(ast, context = {}) {
|
|
14647
|
-
return this.generator.path(ast, completeParseContext(context), void 0);
|
|
14903
|
+
return this.generator.path(ast, completeParseContext({ ...this.defaultContext, ...context }), void 0).trim();
|
|
14648
14904
|
}
|
|
14649
14905
|
};
|
|
14650
14906
|
/*! Bundled license information:
|