@traqula/generator-sparql-1-1 0.0.19 → 0.0.20
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 +494 -246
- package/lib/index.d.ts +30 -32
- 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,31 @@ 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 {
|
|
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
|
+
/**
|
|
9764
|
+
* Function to shallow clone any type.
|
|
9765
|
+
* @param obj
|
|
9766
|
+
* @protected
|
|
9767
|
+
*/
|
|
9768
|
+
clone(obj) {
|
|
9769
|
+
if (obj === null || typeof obj !== "object") {
|
|
9770
|
+
return obj;
|
|
9732
9771
|
}
|
|
9733
|
-
|
|
9772
|
+
const proto = Object.getPrototypeOf(obj);
|
|
9773
|
+
if (proto === Object.prototype || proto === null) {
|
|
9774
|
+
return { ...obj };
|
|
9775
|
+
}
|
|
9776
|
+
return Object.assign(Object.create(proto), obj);
|
|
9734
9777
|
}
|
|
9735
9778
|
/**
|
|
9736
9779
|
* Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
|
|
@@ -9742,90 +9785,228 @@ var TransformerType = class {
|
|
|
9742
9785
|
* - Default false
|
|
9743
9786
|
*/
|
|
9744
9787
|
transformObject(startObject, mapper, preVisitor = () => ({})) {
|
|
9788
|
+
const defaults2 = this.defaultContext;
|
|
9789
|
+
const defaultCopyFlag = defaults2.copy ?? true;
|
|
9790
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9791
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9792
|
+
const defaultShallowKeys = defaults2.shallowKeys;
|
|
9793
|
+
const defaultDidShortCut = defaults2.shortcut ?? false;
|
|
9745
9794
|
let didShortCut = false;
|
|
9746
|
-
const
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9795
|
+
const resultWrap = { res: startObject };
|
|
9796
|
+
const stack = [startObject];
|
|
9797
|
+
const stackParent = [resultWrap];
|
|
9798
|
+
const stackParentKey = ["res"];
|
|
9799
|
+
const handleMapperOnLen = [];
|
|
9800
|
+
const mapperCopyStack = [];
|
|
9801
|
+
const mapperOrigStack = [];
|
|
9802
|
+
const mapperParent = [];
|
|
9803
|
+
const mapperParentKey = [];
|
|
9804
|
+
function handleMapper() {
|
|
9805
|
+
while (stack.length === handleMapperOnLen.at(-1)) {
|
|
9806
|
+
handleMapperOnLen.pop();
|
|
9807
|
+
const copyToMap = mapperCopyStack.pop();
|
|
9808
|
+
const origToMap = mapperOrigStack.pop();
|
|
9809
|
+
const parent = mapperParent.pop();
|
|
9810
|
+
const parentKey = mapperParentKey.pop();
|
|
9811
|
+
parent[parentKey] = mapper(copyToMap, origToMap);
|
|
9812
|
+
}
|
|
9813
|
+
}
|
|
9814
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9815
|
+
const curObject = stack.pop();
|
|
9816
|
+
const curParent = stackParent.pop();
|
|
9817
|
+
const curKey = stackParentKey.pop();
|
|
9818
|
+
if (!didShortCut) {
|
|
9819
|
+
if (Array.isArray(curObject)) {
|
|
9820
|
+
const newArr = [...curObject];
|
|
9821
|
+
handleMapperOnLen.push(stack.length);
|
|
9822
|
+
mapperCopyStack.push(newArr);
|
|
9823
|
+
mapperOrigStack.push(curObject);
|
|
9824
|
+
mapperParent.push(curParent);
|
|
9825
|
+
mapperParentKey.push(curKey);
|
|
9826
|
+
for (let index = curObject.length - 1; index >= 0; index--) {
|
|
9827
|
+
const val = curObject[index];
|
|
9828
|
+
if (val !== null && typeof val === "object") {
|
|
9829
|
+
stack.push(val);
|
|
9830
|
+
stackParent.push(newArr);
|
|
9831
|
+
stackParentKey.push(index.toString());
|
|
9832
|
+
}
|
|
9833
|
+
}
|
|
9834
|
+
handleMapper();
|
|
9835
|
+
continue;
|
|
9836
|
+
}
|
|
9837
|
+
const context = preVisitor(curObject);
|
|
9838
|
+
const copyFlag = context.copy ?? defaultCopyFlag;
|
|
9839
|
+
const continues = context.continue ?? defaultContinues;
|
|
9840
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9841
|
+
const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
|
|
9842
|
+
didShortCut = context.shortcut ?? defaultDidShortCut;
|
|
9843
|
+
const copy3 = copyFlag ? this.clone(curObject) : curObject;
|
|
9844
|
+
handleMapperOnLen.push(stack.length);
|
|
9845
|
+
mapperCopyStack.push(copy3);
|
|
9846
|
+
mapperOrigStack.push(curObject);
|
|
9847
|
+
mapperParent.push(curParent);
|
|
9848
|
+
mapperParentKey.push(curKey);
|
|
9849
|
+
if (continues && !didShortCut) {
|
|
9850
|
+
for (const key in copy3) {
|
|
9851
|
+
if (!Object.hasOwn(copy3, key)) {
|
|
9852
|
+
continue;
|
|
9853
|
+
}
|
|
9854
|
+
const val = copy3[key];
|
|
9855
|
+
const onlyShallow = shallowKeys && shallowKeys?.has(key);
|
|
9856
|
+
if (onlyShallow) {
|
|
9857
|
+
copy3[key] = this.clone(val);
|
|
9858
|
+
}
|
|
9859
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9860
|
+
continue;
|
|
9861
|
+
}
|
|
9862
|
+
if (!onlyShallow && val !== null && typeof val === "object") {
|
|
9863
|
+
stack.push(val);
|
|
9864
|
+
stackParentKey.push(key);
|
|
9865
|
+
stackParent.push(copy3);
|
|
9866
|
+
}
|
|
9755
9867
|
}
|
|
9756
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9757
9868
|
}
|
|
9758
9869
|
}
|
|
9759
|
-
|
|
9760
|
-
}
|
|
9761
|
-
|
|
9870
|
+
handleMapper();
|
|
9871
|
+
}
|
|
9872
|
+
if (stack.length >= this.maxStackSize) {
|
|
9873
|
+
throw new Error("Transform object stack overflowed");
|
|
9874
|
+
}
|
|
9875
|
+
handleMapper();
|
|
9876
|
+
return resultWrap.res;
|
|
9762
9877
|
}
|
|
9763
9878
|
/**
|
|
9764
9879
|
* Visitor that visits all objects. Visits deeper objects first.
|
|
9765
9880
|
*/
|
|
9766
9881
|
visitObject(startObject, visitor, preVisitor = () => ({})) {
|
|
9882
|
+
const defaults2 = this.defaultContext;
|
|
9883
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9884
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9885
|
+
const defaultShortcut = defaults2.shortcut ?? false;
|
|
9767
9886
|
let didShortCut = false;
|
|
9768
|
-
const
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9887
|
+
const stack = [startObject];
|
|
9888
|
+
const handleVisitorOnLen = [];
|
|
9889
|
+
const visitorStack = [];
|
|
9890
|
+
function handleVisitor() {
|
|
9891
|
+
while (stack.length === handleVisitorOnLen.at(-1)) {
|
|
9892
|
+
handleVisitorOnLen.pop();
|
|
9893
|
+
const toVisit = visitorStack.pop();
|
|
9894
|
+
visitor(toVisit);
|
|
9895
|
+
}
|
|
9896
|
+
}
|
|
9897
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9898
|
+
const curObject = stack.pop();
|
|
9899
|
+
if (!didShortCut) {
|
|
9900
|
+
if (Array.isArray(curObject)) {
|
|
9901
|
+
for (let i = curObject.length - 1; i >= 0; i--) {
|
|
9902
|
+
stack.push(curObject[i]);
|
|
9903
|
+
}
|
|
9904
|
+
handleVisitor();
|
|
9905
|
+
continue;
|
|
9906
|
+
}
|
|
9907
|
+
const context = preVisitor(curObject);
|
|
9908
|
+
didShortCut = context.shortcut ?? defaultShortcut;
|
|
9909
|
+
const continues = context.continue ?? defaultContinues;
|
|
9910
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9911
|
+
handleVisitorOnLen.push(stack.length);
|
|
9912
|
+
visitorStack.push(curObject);
|
|
9913
|
+
if (continues && !didShortCut) {
|
|
9914
|
+
for (const key in curObject) {
|
|
9915
|
+
if (!Object.hasOwn(curObject, key)) {
|
|
9916
|
+
continue;
|
|
9917
|
+
}
|
|
9918
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9919
|
+
continue;
|
|
9920
|
+
}
|
|
9921
|
+
const val = curObject[key];
|
|
9922
|
+
if (val && typeof val === "object") {
|
|
9923
|
+
stack.push(val);
|
|
9924
|
+
}
|
|
9776
9925
|
}
|
|
9777
|
-
this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9778
9926
|
}
|
|
9779
9927
|
}
|
|
9780
|
-
|
|
9781
|
-
}
|
|
9782
|
-
|
|
9928
|
+
handleVisitor();
|
|
9929
|
+
}
|
|
9930
|
+
if (stack.length >= this.maxStackSize) {
|
|
9931
|
+
throw new Error("Transform object stack overflowed");
|
|
9932
|
+
}
|
|
9933
|
+
handleVisitor();
|
|
9783
9934
|
}
|
|
9935
|
+
};
|
|
9936
|
+
|
|
9937
|
+
// ../../packages/core/lib/TransformerTyped.js
|
|
9938
|
+
var TransformerTyped = class extends TransformerObject {
|
|
9939
|
+
defaultNodePreVisitor;
|
|
9940
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9941
|
+
super(defaultContext);
|
|
9942
|
+
this.defaultNodePreVisitor = defaultNodePreVisitor;
|
|
9943
|
+
}
|
|
9944
|
+
/**
|
|
9945
|
+
* Transform a single node.
|
|
9946
|
+
* The transformation calls the preVisitor from starting from the startObject.
|
|
9947
|
+
* The preVisitor can dictate whether transformation should be stopped.
|
|
9948
|
+
* Note that stopping the transformation also prevets further copying.
|
|
9949
|
+
* The transformer itself transforms object starting with the deepest one that can be visited.
|
|
9950
|
+
* The transformer callback is performed on a copy of the original.
|
|
9951
|
+
* @param startObject
|
|
9952
|
+
* @param nodeCallBacks
|
|
9953
|
+
*/
|
|
9784
9954
|
transformNode(startObject, nodeCallBacks) {
|
|
9785
|
-
const transformWrapper = (
|
|
9786
|
-
|
|
9955
|
+
const transformWrapper = (copy3, orig) => {
|
|
9956
|
+
let ogTransform;
|
|
9957
|
+
const casted = copy3;
|
|
9787
9958
|
if (casted.type) {
|
|
9788
|
-
|
|
9789
|
-
if (ogFunc) {
|
|
9790
|
-
return ogFunc(casted);
|
|
9791
|
-
}
|
|
9959
|
+
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9792
9960
|
}
|
|
9793
|
-
return
|
|
9961
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9794
9962
|
};
|
|
9795
|
-
const
|
|
9963
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9964
|
+
const preVisitWrapper = (curObject) => {
|
|
9965
|
+
let ogPreVisit;
|
|
9966
|
+
let nodeContext = {};
|
|
9796
9967
|
const casted = curObject;
|
|
9797
9968
|
if (casted.type) {
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
return ogFunc(casted);
|
|
9801
|
-
}
|
|
9969
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9970
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9802
9971
|
}
|
|
9803
|
-
return {};
|
|
9972
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9804
9973
|
};
|
|
9805
|
-
return this.transformObject(startObject, transformWrapper,
|
|
9974
|
+
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9806
9975
|
}
|
|
9976
|
+
/**
|
|
9977
|
+
* Similar to {@link this.transformNode}, but without copying the startObject.
|
|
9978
|
+
* The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
|
|
9979
|
+
* @param startObject
|
|
9980
|
+
* @param nodeCallBacks
|
|
9981
|
+
*/
|
|
9807
9982
|
visitNode(startObject, nodeCallBacks) {
|
|
9808
|
-
const
|
|
9983
|
+
const visitorWrapper = (curObject) => {
|
|
9809
9984
|
const casted = curObject;
|
|
9810
9985
|
if (casted.type) {
|
|
9811
|
-
const
|
|
9812
|
-
if (
|
|
9813
|
-
|
|
9986
|
+
const ogTransform = nodeCallBacks[casted.type]?.visitor;
|
|
9987
|
+
if (ogTransform) {
|
|
9988
|
+
ogTransform(casted);
|
|
9814
9989
|
}
|
|
9815
9990
|
}
|
|
9816
9991
|
};
|
|
9992
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9817
9993
|
const preVisitWrapper = (curObject) => {
|
|
9994
|
+
let ogPreVisit;
|
|
9995
|
+
let nodeContext = {};
|
|
9818
9996
|
const casted = curObject;
|
|
9819
9997
|
if (casted.type) {
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
return ogFunc(casted);
|
|
9823
|
-
}
|
|
9998
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9999
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9824
10000
|
}
|
|
9825
|
-
return {};
|
|
10001
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9826
10002
|
};
|
|
9827
|
-
this.visitObject(startObject,
|
|
10003
|
+
return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
|
|
9828
10004
|
}
|
|
10005
|
+
/**
|
|
10006
|
+
* Traverses only selected nodes as returned by the function.
|
|
10007
|
+
* @param currentNode
|
|
10008
|
+
* @param traverse
|
|
10009
|
+
*/
|
|
9829
10010
|
traverseNodes(currentNode, traverse) {
|
|
9830
10011
|
let didShortCut = false;
|
|
9831
10012
|
const recurse = (curNode) => {
|
|
@@ -9846,11 +10027,24 @@ var TransformerType = class {
|
|
|
9846
10027
|
recurse(currentNode);
|
|
9847
10028
|
}
|
|
9848
10029
|
};
|
|
9849
|
-
|
|
10030
|
+
|
|
10031
|
+
// ../../packages/core/lib/TransformerSubTyped.js
|
|
10032
|
+
var TransformerSubTyped = class extends TransformerTyped {
|
|
10033
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
10034
|
+
super(defaultContext, defaultNodePreVisitor);
|
|
10035
|
+
}
|
|
10036
|
+
/**
|
|
10037
|
+
* Shares the functionality and first two arguments with {@link this.transformNode}.
|
|
10038
|
+
* The third argument allows you to also transform based on the subType of objects.
|
|
10039
|
+
* Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
|
|
10040
|
+
* @param startObject
|
|
10041
|
+
* @param nodeCallBacks
|
|
10042
|
+
* @param nodeSpecificCallBacks
|
|
10043
|
+
*/
|
|
9850
10044
|
transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9851
|
-
const transformWrapper = (
|
|
10045
|
+
const transformWrapper = (copy3, orig) => {
|
|
9852
10046
|
let ogTransform;
|
|
9853
|
-
const casted =
|
|
10047
|
+
const casted = copy3;
|
|
9854
10048
|
if (casted.type && casted.subType) {
|
|
9855
10049
|
const specific = nodeSpecificCallBacks[casted.type];
|
|
9856
10050
|
if (specific) {
|
|
@@ -9860,7 +10054,7 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9860
10054
|
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9861
10055
|
}
|
|
9862
10056
|
}
|
|
9863
|
-
return ogTransform ? ogTransform(casted) :
|
|
10057
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9864
10058
|
};
|
|
9865
10059
|
const preVisitWrapper = (curObject) => {
|
|
9866
10060
|
let ogPreVisit;
|
|
@@ -9874,12 +10068,13 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9874
10068
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9875
10069
|
}
|
|
9876
10070
|
}
|
|
9877
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10071
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9878
10072
|
};
|
|
9879
10073
|
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9880
10074
|
}
|
|
9881
10075
|
/**
|
|
9882
|
-
*
|
|
10076
|
+
* Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
|
|
10077
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
|
|
9883
10078
|
*/
|
|
9884
10079
|
visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9885
10080
|
const visitWrapper = (curObject) => {
|
|
@@ -9910,10 +10105,16 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9910
10105
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9911
10106
|
}
|
|
9912
10107
|
}
|
|
9913
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10108
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9914
10109
|
};
|
|
9915
10110
|
this.visitObject(startObject, visitWrapper, preVisitWrapper);
|
|
9916
10111
|
}
|
|
10112
|
+
/**
|
|
10113
|
+
* Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
|
|
10114
|
+
* @param currentNode
|
|
10115
|
+
* @param traverseNode
|
|
10116
|
+
* @param traverseSubNode
|
|
10117
|
+
*/
|
|
9917
10118
|
traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
|
|
9918
10119
|
let didShortCut = false;
|
|
9919
10120
|
const recurse = (curNode) => {
|
|
@@ -10925,8 +11126,8 @@ function PatternFactoryMixin(Base) {
|
|
|
10925
11126
|
isPatternOptional(obj) {
|
|
10926
11127
|
return this.isOfSubType(obj, nodeType5, "optional");
|
|
10927
11128
|
}
|
|
10928
|
-
patternValues(values3, loc) {
|
|
10929
|
-
return { type: nodeType5, subType: "values", values: values3, loc };
|
|
11129
|
+
patternValues(variables, values3, loc) {
|
|
11130
|
+
return { type: nodeType5, subType: "values", variables, values: values3, loc };
|
|
10930
11131
|
}
|
|
10931
11132
|
isPatternValues(obj) {
|
|
10932
11133
|
return this.isOfSubType(obj, nodeType5, "values");
|
|
@@ -11101,7 +11302,7 @@ function TermFactoryMixin(Base) {
|
|
|
11101
11302
|
isTerm(x) {
|
|
11102
11303
|
return this.isOfType(x, "term");
|
|
11103
11304
|
}
|
|
11104
|
-
|
|
11305
|
+
termBlank(label, loc) {
|
|
11105
11306
|
const base = {
|
|
11106
11307
|
type: "term",
|
|
11107
11308
|
subType: "blankNode",
|
|
@@ -11115,7 +11316,7 @@ function TermFactoryMixin(Base) {
|
|
|
11115
11316
|
isTermBlank(obj) {
|
|
11116
11317
|
return this.isOfSubType(obj, nodeType8, "blankNode");
|
|
11117
11318
|
}
|
|
11118
|
-
|
|
11319
|
+
termLiteral(loc, value, langOrIri) {
|
|
11119
11320
|
return {
|
|
11120
11321
|
type: nodeType8,
|
|
11121
11322
|
subType: "literal",
|
|
@@ -11137,7 +11338,7 @@ function TermFactoryMixin(Base) {
|
|
|
11137
11338
|
const casted = obj;
|
|
11138
11339
|
return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
|
|
11139
11340
|
}
|
|
11140
|
-
|
|
11341
|
+
termVariable(value, loc) {
|
|
11141
11342
|
return {
|
|
11142
11343
|
type: nodeType8,
|
|
11143
11344
|
subType: "variable",
|
|
@@ -11148,7 +11349,7 @@ function TermFactoryMixin(Base) {
|
|
|
11148
11349
|
isTermVariable(obj) {
|
|
11149
11350
|
return this.isOfSubType(obj, nodeType8, "variable");
|
|
11150
11351
|
}
|
|
11151
|
-
|
|
11352
|
+
termNamed(loc, value, prefix) {
|
|
11152
11353
|
const base = {
|
|
11153
11354
|
type: nodeType8,
|
|
11154
11355
|
subType: "namedNode",
|
|
@@ -11393,7 +11594,7 @@ var CommonIRIs;
|
|
|
11393
11594
|
CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
11394
11595
|
CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
11395
11596
|
})(CommonIRIs || (CommonIRIs = {}));
|
|
11396
|
-
var AstTransformer = class extends
|
|
11597
|
+
var AstTransformer = class extends TransformerSubTyped {
|
|
11397
11598
|
};
|
|
11398
11599
|
|
|
11399
11600
|
// ../../packages/rules-sparql-1-1/lib/validation/validators.js
|
|
@@ -11609,17 +11810,20 @@ var rdfLiteral = {
|
|
|
11609
11810
|
return OPTION(() => OR([
|
|
11610
11811
|
{ ALT: () => {
|
|
11611
11812
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11612
|
-
return ACTION(() => C.astFactory.
|
|
11813
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11613
11814
|
} },
|
|
11614
11815
|
{ ALT: () => {
|
|
11615
11816
|
CONSUME(symbols_exports.hathat);
|
|
11616
11817
|
const iriVal = SUBRULE1(iri2);
|
|
11617
|
-
return ACTION(() => C.astFactory.
|
|
11818
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11618
11819
|
} }
|
|
11619
11820
|
])) ?? value;
|
|
11620
11821
|
},
|
|
11621
|
-
gImpl: ({ SUBRULE, PRINT,
|
|
11622
|
-
astFactory.printFilter(ast, () =>
|
|
11822
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11823
|
+
astFactory.printFilter(ast, () => {
|
|
11824
|
+
PRINT_WORD("");
|
|
11825
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
11826
|
+
});
|
|
11623
11827
|
if (ast.langOrIri) {
|
|
11624
11828
|
if (typeof ast.langOrIri === "string") {
|
|
11625
11829
|
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
@@ -11646,7 +11850,7 @@ var numericLiteralUnsigned = {
|
|
|
11646
11850
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11647
11851
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11648
11852
|
]);
|
|
11649
|
-
return ACTION(() => C.astFactory.
|
|
11853
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11650
11854
|
}
|
|
11651
11855
|
};
|
|
11652
11856
|
var numericLiteralPositive = {
|
|
@@ -11657,7 +11861,7 @@ var numericLiteralPositive = {
|
|
|
11657
11861
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11658
11862
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11659
11863
|
]);
|
|
11660
|
-
return ACTION(() => C.astFactory.
|
|
11864
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11661
11865
|
}
|
|
11662
11866
|
};
|
|
11663
11867
|
var numericLiteralNegative = {
|
|
@@ -11668,7 +11872,7 @@ var numericLiteralNegative = {
|
|
|
11668
11872
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11669
11873
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11670
11874
|
]);
|
|
11671
|
-
return ACTION(() => C.astFactory.
|
|
11875
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11672
11876
|
}
|
|
11673
11877
|
};
|
|
11674
11878
|
var booleanLiteral = {
|
|
@@ -11678,7 +11882,7 @@ var booleanLiteral = {
|
|
|
11678
11882
|
{ ALT: () => CONSUME(true_) },
|
|
11679
11883
|
{ ALT: () => CONSUME(false_) }
|
|
11680
11884
|
]);
|
|
11681
|
-
return ACTION(() => C.astFactory.
|
|
11885
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11682
11886
|
}
|
|
11683
11887
|
};
|
|
11684
11888
|
var string = {
|
|
@@ -11720,7 +11924,7 @@ var string = {
|
|
|
11720
11924
|
return char;
|
|
11721
11925
|
}
|
|
11722
11926
|
});
|
|
11723
|
-
return F2.
|
|
11927
|
+
return F2.termLiteral(F2.sourceLocation(x[0]), value);
|
|
11724
11928
|
});
|
|
11725
11929
|
}
|
|
11726
11930
|
};
|
|
@@ -11736,7 +11940,7 @@ var iriFull = {
|
|
|
11736
11940
|
name: "iriFull",
|
|
11737
11941
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11738
11942
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11739
|
-
return ACTION(() => C.astFactory.
|
|
11943
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11740
11944
|
},
|
|
11741
11945
|
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
11742
11946
|
F2.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
@@ -11749,16 +11953,16 @@ var prefixedName = {
|
|
|
11749
11953
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11750
11954
|
return ACTION(() => {
|
|
11751
11955
|
const [prefix, localName] = longName.image.split(":");
|
|
11752
|
-
return C.astFactory.
|
|
11956
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11753
11957
|
});
|
|
11754
11958
|
} },
|
|
11755
11959
|
{ ALT: () => {
|
|
11756
11960
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11757
|
-
return ACTION(() => C.astFactory.
|
|
11961
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11758
11962
|
} }
|
|
11759
11963
|
]),
|
|
11760
|
-
gImpl: ({
|
|
11761
|
-
F2.printFilter(ast, () =>
|
|
11964
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
11965
|
+
F2.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
11762
11966
|
}
|
|
11763
11967
|
};
|
|
11764
11968
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11768,11 +11972,11 @@ var blankNode = {
|
|
|
11768
11972
|
const result = OR([
|
|
11769
11973
|
{ ALT: () => {
|
|
11770
11974
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11771
|
-
return ACTION(() => C.astFactory.
|
|
11975
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11772
11976
|
} },
|
|
11773
11977
|
{ ALT: () => {
|
|
11774
11978
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11775
|
-
return ACTION(() => C.astFactory.
|
|
11979
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11776
11980
|
} }
|
|
11777
11981
|
]);
|
|
11778
11982
|
ACTION(() => {
|
|
@@ -11782,15 +11986,15 @@ var blankNode = {
|
|
|
11782
11986
|
});
|
|
11783
11987
|
return result;
|
|
11784
11988
|
},
|
|
11785
|
-
gImpl: ({
|
|
11786
|
-
astFactory.printFilter(ast, () =>
|
|
11989
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
11990
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
11787
11991
|
}
|
|
11788
11992
|
};
|
|
11789
11993
|
var verbA = {
|
|
11790
11994
|
name: "VerbA",
|
|
11791
11995
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11792
11996
|
const token = CONSUME(a);
|
|
11793
|
-
return ACTION(() => C.astFactory.
|
|
11997
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11794
11998
|
}
|
|
11795
11999
|
};
|
|
11796
12000
|
|
|
@@ -11824,10 +12028,10 @@ var baseDecl2 = {
|
|
|
11824
12028
|
const val = SUBRULE(iriFull);
|
|
11825
12029
|
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11826
12030
|
},
|
|
11827
|
-
gImpl: ({ SUBRULE,
|
|
11828
|
-
F2.printFilter(ast, () =>
|
|
12031
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12032
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
|
|
11829
12033
|
SUBRULE(iri2, ast.value);
|
|
11830
|
-
F2.printFilter(ast, () =>
|
|
12034
|
+
F2.printFilter(ast, () => NEW_LINE());
|
|
11831
12035
|
}
|
|
11832
12036
|
};
|
|
11833
12037
|
var prefixDecl2 = {
|
|
@@ -11838,12 +12042,12 @@ var prefixDecl2 = {
|
|
|
11838
12042
|
const value = SUBRULE(iriFull);
|
|
11839
12043
|
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11840
12044
|
},
|
|
11841
|
-
gImpl: ({ SUBRULE,
|
|
12045
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
11842
12046
|
F2.printFilter(ast, () => {
|
|
11843
|
-
|
|
12047
|
+
PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
|
|
11844
12048
|
});
|
|
11845
12049
|
SUBRULE(iri2, ast.value);
|
|
11846
|
-
F2.printFilter(ast, () =>
|
|
12050
|
+
F2.printFilter(ast, () => NEW_LINE());
|
|
11847
12051
|
}
|
|
11848
12052
|
};
|
|
11849
12053
|
var verb = {
|
|
@@ -11880,10 +12084,10 @@ var var_ = {
|
|
|
11880
12084
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11881
12085
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11882
12086
|
]);
|
|
11883
|
-
return ACTION(() => C.astFactory.
|
|
12087
|
+
return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11884
12088
|
},
|
|
11885
|
-
gImpl: ({
|
|
11886
|
-
F2.printFilter(ast, () =>
|
|
12089
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
12090
|
+
F2.printFilter(ast, () => PRINT(`?${ast.value}`));
|
|
11887
12091
|
}
|
|
11888
12092
|
};
|
|
11889
12093
|
var graphTerm = {
|
|
@@ -11896,7 +12100,7 @@ var graphTerm = {
|
|
|
11896
12100
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
11897
12101
|
{ ALT: () => {
|
|
11898
12102
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
11899
|
-
return ACTION(() => C.astFactory.
|
|
12103
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
11900
12104
|
} }
|
|
11901
12105
|
]),
|
|
11902
12106
|
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
@@ -12526,13 +12730,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12526
12730
|
var triplesBlock = {
|
|
12527
12731
|
name: "triplesBlock",
|
|
12528
12732
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12529
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F2 }) => {
|
|
12733
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12530
12734
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12531
12735
|
HANDLE_LOC(triple, () => {
|
|
12532
12736
|
const nextTriple = ast.triples.at(index);
|
|
12533
12737
|
if (F2.isTripleCollection(triple)) {
|
|
12534
12738
|
SUBRULE(graphNodePath, triple);
|
|
12535
|
-
F2.printFilter(triple, () =>
|
|
12739
|
+
F2.printFilter(triple, () => {
|
|
12740
|
+
PRINT_WORD(".");
|
|
12741
|
+
NEW_LINE();
|
|
12742
|
+
});
|
|
12536
12743
|
} else {
|
|
12537
12744
|
SUBRULE(graphNodePath, triple.subject);
|
|
12538
12745
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
@@ -12544,11 +12751,17 @@ var triplesBlock = {
|
|
|
12544
12751
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12545
12752
|
SUBRULE(graphNodePath, triple.object);
|
|
12546
12753
|
if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12547
|
-
F2.printFilter(ast, () =>
|
|
12754
|
+
F2.printFilter(ast, () => {
|
|
12755
|
+
PRINT_WORD(".");
|
|
12756
|
+
NEW_LINE();
|
|
12757
|
+
});
|
|
12548
12758
|
} else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12549
12759
|
F2.printFilter(ast, () => PRINT_WORD(","));
|
|
12550
12760
|
} else {
|
|
12551
|
-
F2.printFilter(ast, () =>
|
|
12761
|
+
F2.printFilter(ast, () => {
|
|
12762
|
+
PRINT_WORD(";");
|
|
12763
|
+
NEW_LINE();
|
|
12764
|
+
});
|
|
12552
12765
|
}
|
|
12553
12766
|
}
|
|
12554
12767
|
});
|
|
@@ -12681,10 +12894,10 @@ function collectionImpl(name, allowPaths) {
|
|
|
12681
12894
|
return ACTION(() => {
|
|
12682
12895
|
const F2 = C.astFactory;
|
|
12683
12896
|
const triples = [];
|
|
12684
|
-
const predFirst = F2.
|
|
12685
|
-
const predRest = F2.
|
|
12686
|
-
const predNil = F2.
|
|
12687
|
-
const listHead = F2.
|
|
12897
|
+
const predFirst = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12898
|
+
const predRest = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
12899
|
+
const predNil = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
|
|
12900
|
+
const listHead = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
|
|
12688
12901
|
let iterHead = listHead;
|
|
12689
12902
|
for (const [index, term] of terms.entries()) {
|
|
12690
12903
|
const lastInList = index === terms.length - 1;
|
|
@@ -12694,7 +12907,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12694
12907
|
const nilTriple = F2.triple(iterHead, predRest, predNil);
|
|
12695
12908
|
triples.push(nilTriple);
|
|
12696
12909
|
} else {
|
|
12697
|
-
const tail = F2.
|
|
12910
|
+
const tail = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
|
|
12698
12911
|
const linkTriple = F2.triple(iterHead, predRest, tail);
|
|
12699
12912
|
triples.push(linkTriple);
|
|
12700
12913
|
iterHead = tail;
|
|
@@ -12734,16 +12947,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12734
12947
|
name,
|
|
12735
12948
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12736
12949
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12737
|
-
const blankNode2 = ACTION(() => C.astFactory.
|
|
12950
|
+
const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12738
12951
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12739
12952
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12740
12953
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12741
12954
|
},
|
|
12742
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
12955
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
12743
12956
|
const { astFactory: F2, indentInc } = c;
|
|
12744
12957
|
F2.printFilter(ast, () => {
|
|
12745
12958
|
c[traqulaIndentation] += indentInc;
|
|
12746
|
-
PRINT("[
|
|
12959
|
+
PRINT("[");
|
|
12960
|
+
NEW_LINE();
|
|
12747
12961
|
});
|
|
12748
12962
|
for (const triple of ast.triples) {
|
|
12749
12963
|
HANDLE_LOC(triple, () => {
|
|
@@ -12754,7 +12968,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12754
12968
|
}
|
|
12755
12969
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12756
12970
|
SUBRULE(graphNodePath, triple.object);
|
|
12757
|
-
F2.printFilter(ast, () =>
|
|
12971
|
+
F2.printFilter(ast, () => {
|
|
12972
|
+
PRINT_WORD(";");
|
|
12973
|
+
NEW_LINE();
|
|
12974
|
+
});
|
|
12758
12975
|
});
|
|
12759
12976
|
}
|
|
12760
12977
|
F2.printFilter(ast, () => {
|
|
@@ -12813,18 +13030,19 @@ var groupGraphPattern = {
|
|
|
12813
13030
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12814
13031
|
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12815
13032
|
},
|
|
12816
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
13033
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12817
13034
|
const { astFactory: F2, indentInc } = C;
|
|
12818
13035
|
F2.printFilter(ast, () => {
|
|
12819
13036
|
C[traqulaIndentation] += indentInc;
|
|
12820
|
-
PRINT_WORD("{
|
|
13037
|
+
PRINT_WORD("{");
|
|
13038
|
+
NEW_LINE();
|
|
12821
13039
|
});
|
|
12822
13040
|
for (const pattern of ast.patterns) {
|
|
12823
13041
|
SUBRULE(generatePattern, pattern);
|
|
12824
13042
|
}
|
|
12825
13043
|
F2.printFilter(ast, () => {
|
|
12826
13044
|
C[traqulaIndentation] -= indentInc;
|
|
12827
|
-
|
|
13045
|
+
PRINT_ON_OWN_LINE("}");
|
|
12828
13046
|
});
|
|
12829
13047
|
}
|
|
12830
13048
|
};
|
|
@@ -12974,12 +13192,15 @@ var bind2 = {
|
|
|
12974
13192
|
const close = CONSUME(symbols_exports.RParen);
|
|
12975
13193
|
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
12976
13194
|
},
|
|
12977
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13195
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12978
13196
|
F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
12979
13197
|
SUBRULE(expression, ast.expression);
|
|
12980
13198
|
F2.printFilter(ast, () => PRINT_WORD("AS"));
|
|
12981
13199
|
SUBRULE(var_, ast.variable);
|
|
12982
|
-
F2.printFilter(ast, () =>
|
|
13200
|
+
F2.printFilter(ast, () => {
|
|
13201
|
+
PRINT_WORD(")");
|
|
13202
|
+
NEW_LINE();
|
|
13203
|
+
});
|
|
12983
13204
|
}
|
|
12984
13205
|
};
|
|
12985
13206
|
var inlineData = {
|
|
@@ -12987,34 +13208,46 @@ var inlineData = {
|
|
|
12987
13208
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12988
13209
|
const values3 = CONSUME(values2);
|
|
12989
13210
|
const datablock = SUBRULE(dataBlock);
|
|
12990
|
-
return ACTION(() =>
|
|
13211
|
+
return ACTION(() => {
|
|
13212
|
+
datablock.loc = C.astFactory.sourceLocation(values3, datablock);
|
|
13213
|
+
return datablock;
|
|
13214
|
+
});
|
|
12991
13215
|
},
|
|
12992
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13216
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12993
13217
|
const { astFactory: F2, indentInc } = C;
|
|
12994
|
-
const variables =
|
|
13218
|
+
const variables = ast.variables;
|
|
13219
|
+
const singleVar = variables.length === 1;
|
|
13220
|
+
F2.printFilter(ast, () => {
|
|
13221
|
+
PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
|
|
13222
|
+
});
|
|
13223
|
+
for (const variable of variables) {
|
|
13224
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13225
|
+
SUBRULE(varOrTerm, variable);
|
|
13226
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13227
|
+
}
|
|
12995
13228
|
F2.printFilter(ast, () => {
|
|
12996
|
-
PRINT_ON_EMPTY("");
|
|
12997
|
-
PRINT_WORD("VALUES", "(");
|
|
12998
|
-
for (const variable of variables) {
|
|
12999
|
-
PRINT_WORD(`?${variable}`);
|
|
13000
|
-
}
|
|
13001
13229
|
C[traqulaIndentation] += indentInc;
|
|
13002
|
-
PRINT_WORD(")", "{
|
|
13230
|
+
PRINT_WORD(singleVar ? "" : ")", "{");
|
|
13231
|
+
NEW_LINE();
|
|
13003
13232
|
});
|
|
13004
13233
|
for (const mapping of ast.values) {
|
|
13005
|
-
F2.printFilter(ast, () => PRINT_WORD("("));
|
|
13234
|
+
F2.printFilter(ast, () => !singleVar && PRINT_WORD("("));
|
|
13006
13235
|
for (const variable of variables) {
|
|
13007
|
-
|
|
13236
|
+
const var_2 = variable.value;
|
|
13237
|
+
if (mapping[var_2] === void 0) {
|
|
13008
13238
|
F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
|
|
13009
13239
|
} else {
|
|
13010
|
-
SUBRULE(graphNodePath, mapping[
|
|
13240
|
+
SUBRULE(graphNodePath, mapping[var_2]);
|
|
13011
13241
|
}
|
|
13012
13242
|
}
|
|
13013
|
-
F2.printFilter(ast, () =>
|
|
13243
|
+
F2.printFilter(ast, () => {
|
|
13244
|
+
PRINT_WORD(singleVar ? "" : ")");
|
|
13245
|
+
NEW_LINE();
|
|
13246
|
+
});
|
|
13014
13247
|
}
|
|
13015
13248
|
F2.printFilter(ast, () => {
|
|
13016
13249
|
C[traqulaIndentation] -= indentInc;
|
|
13017
|
-
|
|
13250
|
+
PRINT_ON_OWN_LINE("}");
|
|
13018
13251
|
});
|
|
13019
13252
|
}
|
|
13020
13253
|
};
|
|
@@ -13038,7 +13271,7 @@ var inlineDataOneVar = {
|
|
|
13038
13271
|
});
|
|
13039
13272
|
});
|
|
13040
13273
|
const close = CONSUME(symbols_exports.RCurly);
|
|
13041
|
-
return ACTION(() => C.astFactory.
|
|
13274
|
+
return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
|
|
13042
13275
|
}
|
|
13043
13276
|
};
|
|
13044
13277
|
var inlineDataFull = {
|
|
@@ -13055,7 +13288,7 @@ var inlineDataFull = {
|
|
|
13055
13288
|
res.push({});
|
|
13056
13289
|
});
|
|
13057
13290
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
13058
|
-
return ACTION(() => C.astFactory.
|
|
13291
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
|
|
13059
13292
|
} },
|
|
13060
13293
|
{ ALT: () => {
|
|
13061
13294
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -13087,7 +13320,7 @@ var inlineDataFull = {
|
|
|
13087
13320
|
});
|
|
13088
13321
|
});
|
|
13089
13322
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
13090
|
-
return ACTION(() => C.astFactory.
|
|
13323
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
|
|
13091
13324
|
} }
|
|
13092
13325
|
]);
|
|
13093
13326
|
}
|
|
@@ -13150,10 +13383,13 @@ var filter3 = {
|
|
|
13150
13383
|
const expression2 = SUBRULE(constraint);
|
|
13151
13384
|
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
13152
13385
|
},
|
|
13153
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13386
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
13154
13387
|
F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
13155
13388
|
SUBRULE(expression, ast.expression);
|
|
13156
|
-
F2.printFilter(ast, () =>
|
|
13389
|
+
F2.printFilter(ast, () => {
|
|
13390
|
+
PRINT_WORD(")");
|
|
13391
|
+
NEW_LINE();
|
|
13392
|
+
});
|
|
13157
13393
|
}
|
|
13158
13394
|
};
|
|
13159
13395
|
var constraint = {
|
|
@@ -13539,8 +13775,7 @@ var groupClause = {
|
|
|
13539
13775
|
},
|
|
13540
13776
|
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13541
13777
|
F2.printFilter(ast, () => {
|
|
13542
|
-
PRINT_ON_EMPTY("");
|
|
13543
|
-
PRINT_WORDS("GROUP", "BY");
|
|
13778
|
+
PRINT_ON_EMPTY("GROUP BY ");
|
|
13544
13779
|
});
|
|
13545
13780
|
for (const grouping of ast.groupings) {
|
|
13546
13781
|
if (F2.isExpression(grouping)) {
|
|
@@ -13596,10 +13831,9 @@ var havingClause = {
|
|
|
13596
13831
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13597
13832
|
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13598
13833
|
},
|
|
13599
|
-
gImpl: ({
|
|
13834
|
+
gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13600
13835
|
F2.printFilter(ast, () => {
|
|
13601
|
-
PRINT_ON_EMPTY("");
|
|
13602
|
-
PRINT_WORD("HAVING");
|
|
13836
|
+
PRINT_ON_EMPTY("HAVING ");
|
|
13603
13837
|
});
|
|
13604
13838
|
for (const having2 of ast.having) {
|
|
13605
13839
|
SUBRULE(expression, having2);
|
|
@@ -13625,8 +13859,7 @@ var orderClause = {
|
|
|
13625
13859
|
},
|
|
13626
13860
|
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13627
13861
|
F2.printFilter(ast, () => {
|
|
13628
|
-
PRINT_ON_EMPTY("");
|
|
13629
|
-
PRINT_WORDS("ORDER", "BY");
|
|
13862
|
+
PRINT_ON_EMPTY("ORDER BY ");
|
|
13630
13863
|
});
|
|
13631
13864
|
for (const ordering of ast.orderDefs) {
|
|
13632
13865
|
if (ordering.descending) {
|
|
@@ -13685,9 +13918,9 @@ var limitOffsetClauses = {
|
|
|
13685
13918
|
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13686
13919
|
} }
|
|
13687
13920
|
]),
|
|
13688
|
-
gImpl: ({ PRINT_WORDS,
|
|
13921
|
+
gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
13689
13922
|
F2.printFilter(ast, () => {
|
|
13690
|
-
|
|
13923
|
+
NEW_LINE();
|
|
13691
13924
|
if (ast.limit) {
|
|
13692
13925
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13693
13926
|
}
|
|
@@ -13872,9 +14105,9 @@ var selectClause = {
|
|
|
13872
14105
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13873
14106
|
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13874
14107
|
},
|
|
13875
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14108
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13876
14109
|
F2.printFilter(ast, () => {
|
|
13877
|
-
|
|
14110
|
+
PRINT_ON_EMPTY("SELECT ");
|
|
13878
14111
|
if (ast.val.distinct) {
|
|
13879
14112
|
PRINT_WORD("DISTINCT");
|
|
13880
14113
|
} else if (ast.val.reduced) {
|
|
@@ -13893,7 +14126,9 @@ var selectClause = {
|
|
|
13893
14126
|
SUBRULE(var_, variable.variable);
|
|
13894
14127
|
F2.printFilter(ast, () => PRINT_WORD(")"));
|
|
13895
14128
|
}
|
|
14129
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13896
14130
|
}
|
|
14131
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13897
14132
|
}
|
|
13898
14133
|
};
|
|
13899
14134
|
var constructQuery = {
|
|
@@ -13931,18 +14166,19 @@ var constructQuery = {
|
|
|
13931
14166
|
} }
|
|
13932
14167
|
]);
|
|
13933
14168
|
},
|
|
13934
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14169
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
13935
14170
|
const { astFactory: F2, indentInc } = C;
|
|
13936
|
-
F2.printFilter(ast, () =>
|
|
14171
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
|
|
13937
14172
|
if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
13938
14173
|
F2.printFilter(ast, () => {
|
|
13939
14174
|
C[traqulaIndentation] += indentInc;
|
|
13940
|
-
PRINT_WORD("{
|
|
14175
|
+
PRINT_WORD("{");
|
|
14176
|
+
NEW_LINE();
|
|
13941
14177
|
});
|
|
13942
14178
|
SUBRULE(triplesBlock, ast.template);
|
|
13943
14179
|
F2.printFilter(ast, () => {
|
|
13944
14180
|
C[traqulaIndentation] -= indentInc;
|
|
13945
|
-
|
|
14181
|
+
PRINT_ON_OWN_LINE("}");
|
|
13946
14182
|
});
|
|
13947
14183
|
}
|
|
13948
14184
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
@@ -13983,8 +14219,8 @@ var describeQuery = {
|
|
|
13983
14219
|
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13984
14220
|
}));
|
|
13985
14221
|
},
|
|
13986
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13987
|
-
F2.printFilter(ast, () =>
|
|
14222
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14223
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
|
|
13988
14224
|
if (F2.isWildcard(ast.variables[0])) {
|
|
13989
14225
|
F2.printFilter(ast, () => PRINT_WORD("*"));
|
|
13990
14226
|
} else {
|
|
@@ -14014,8 +14250,8 @@ var askQuery = {
|
|
|
14014
14250
|
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14015
14251
|
}));
|
|
14016
14252
|
},
|
|
14017
|
-
gImpl: ({ SUBRULE,
|
|
14018
|
-
F2.printFilter(ast, () =>
|
|
14253
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14254
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
|
|
14019
14255
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
14020
14256
|
SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
|
|
14021
14257
|
SUBRULE(solutionModifier, ast.solutionModifiers);
|
|
@@ -14074,7 +14310,7 @@ var update = {
|
|
|
14074
14310
|
return update2;
|
|
14075
14311
|
});
|
|
14076
14312
|
},
|
|
14077
|
-
gImpl: ({ SUBRULE,
|
|
14313
|
+
gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
14078
14314
|
const [head2, ...tail] = ast.updates;
|
|
14079
14315
|
if (head2) {
|
|
14080
14316
|
SUBRULE(prologue, head2.context);
|
|
@@ -14083,7 +14319,10 @@ var update = {
|
|
|
14083
14319
|
}
|
|
14084
14320
|
}
|
|
14085
14321
|
for (const update2 of tail) {
|
|
14086
|
-
F2.printFilter(ast, () =>
|
|
14322
|
+
F2.printFilter(ast, () => {
|
|
14323
|
+
PRINT(";");
|
|
14324
|
+
NEW_LINE();
|
|
14325
|
+
});
|
|
14087
14326
|
SUBRULE(prologue, update2.context);
|
|
14088
14327
|
if (update2.operation) {
|
|
14089
14328
|
SUBRULE(update1, update2.operation);
|
|
@@ -14156,9 +14395,9 @@ var load2 = {
|
|
|
14156
14395
|
});
|
|
14157
14396
|
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
14158
14397
|
},
|
|
14159
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14398
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14160
14399
|
F2.printFilter(ast, () => {
|
|
14161
|
-
|
|
14400
|
+
PRINT_ON_EMPTY("LOAD ");
|
|
14162
14401
|
if (ast.silent) {
|
|
14163
14402
|
PRINT_WORD("SILENT");
|
|
14164
14403
|
}
|
|
@@ -14179,9 +14418,9 @@ function clearOrDrop(operation) {
|
|
|
14179
14418
|
const destination = SUBRULE1(graphRefAll);
|
|
14180
14419
|
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
14181
14420
|
},
|
|
14182
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14421
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14183
14422
|
F2.printFilter(ast, () => {
|
|
14184
|
-
|
|
14423
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14185
14424
|
if (ast.silent) {
|
|
14186
14425
|
PRINT_WORD("SILENT");
|
|
14187
14426
|
}
|
|
@@ -14200,9 +14439,9 @@ var create2 = {
|
|
|
14200
14439
|
const destination = SUBRULE1(graphRef);
|
|
14201
14440
|
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
14202
14441
|
},
|
|
14203
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14442
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14204
14443
|
F2.printFilter(ast, () => {
|
|
14205
|
-
|
|
14444
|
+
PRINT_ON_EMPTY("CREATE ");
|
|
14206
14445
|
if (ast.silent) {
|
|
14207
14446
|
PRINT_WORD("SILENT");
|
|
14208
14447
|
}
|
|
@@ -14221,9 +14460,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14221
14460
|
const destination = SUBRULE2(graphOrDefault);
|
|
14222
14461
|
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14223
14462
|
},
|
|
14224
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14463
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14225
14464
|
F2.printFilter(ast, () => {
|
|
14226
|
-
|
|
14465
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14227
14466
|
if (ast.silent) {
|
|
14228
14467
|
PRINT_WORD("SILENT");
|
|
14229
14468
|
}
|
|
@@ -14272,23 +14511,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
|
|
|
14272
14511
|
}
|
|
14273
14512
|
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14274
14513
|
},
|
|
14275
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14514
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14276
14515
|
const { astFactory: F2, indentInc } = C;
|
|
14277
14516
|
F2.printFilter(ast, () => {
|
|
14278
|
-
C[traqulaIndentation] += indentInc;
|
|
14279
14517
|
if (subType === "insertdata") {
|
|
14280
|
-
|
|
14518
|
+
PRINT_ON_EMPTY("INSERT DATA ");
|
|
14281
14519
|
} else if (subType === "deletedata") {
|
|
14282
|
-
|
|
14520
|
+
PRINT_ON_EMPTY("DELETE DATA ");
|
|
14283
14521
|
} else if (subType === "deletewhere") {
|
|
14284
|
-
|
|
14522
|
+
PRINT_ON_EMPTY("DELETE WHERE ");
|
|
14285
14523
|
}
|
|
14286
|
-
|
|
14524
|
+
C[traqulaIndentation] += indentInc;
|
|
14525
|
+
PRINT_WORD("{");
|
|
14526
|
+
NEW_LINE();
|
|
14287
14527
|
});
|
|
14288
14528
|
SUBRULE(quads, F2.wrap(ast.data, ast.loc));
|
|
14289
14529
|
F2.printFilter(ast, () => {
|
|
14290
14530
|
C[traqulaIndentation] -= indentInc;
|
|
14291
|
-
|
|
14531
|
+
PRINT_ON_OWN_LINE("}");
|
|
14292
14532
|
});
|
|
14293
14533
|
}
|
|
14294
14534
|
};
|
|
@@ -14320,36 +14560,40 @@ var modify = {
|
|
|
14320
14560
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14321
14561
|
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14322
14562
|
},
|
|
14323
|
-
gImpl: ({ SUBRULE,
|
|
14563
|
+
gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
|
|
14324
14564
|
const { astFactory: F2, indentInc } = C;
|
|
14325
14565
|
if (ast.graph) {
|
|
14326
|
-
F2.printFilter(ast, () =>
|
|
14566
|
+
F2.printFilter(ast, () => PRINT_WORDS("WITH"));
|
|
14327
14567
|
SUBRULE(iri2, ast.graph);
|
|
14328
14568
|
}
|
|
14329
14569
|
if (ast.delete.length > 0) {
|
|
14330
14570
|
F2.printFilter(ast, () => {
|
|
14331
14571
|
C[traqulaIndentation] += indentInc;
|
|
14332
|
-
|
|
14572
|
+
PRINT_WORDS("DELETE", "{");
|
|
14573
|
+
NEW_LINE();
|
|
14333
14574
|
});
|
|
14334
14575
|
SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
|
|
14335
14576
|
F2.printFilter(ast, () => {
|
|
14336
14577
|
C[traqulaIndentation] -= indentInc;
|
|
14337
|
-
PRINT_ON_EMPTY("}
|
|
14578
|
+
PRINT_ON_EMPTY("}");
|
|
14579
|
+
NEW_LINE();
|
|
14338
14580
|
});
|
|
14339
14581
|
}
|
|
14340
14582
|
if (ast.insert.length > 0) {
|
|
14341
14583
|
F2.printFilter(ast, () => {
|
|
14342
14584
|
C[traqulaIndentation] += indentInc;
|
|
14343
|
-
|
|
14585
|
+
PRINT_WORDS("INSERT", "{");
|
|
14586
|
+
NEW_LINE();
|
|
14344
14587
|
});
|
|
14345
14588
|
SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
|
|
14346
14589
|
F2.printFilter(ast, () => {
|
|
14347
14590
|
C[traqulaIndentation] -= indentInc;
|
|
14348
|
-
PRINT_ON_EMPTY("}
|
|
14591
|
+
PRINT_ON_EMPTY("} ");
|
|
14592
|
+
NEW_LINE();
|
|
14349
14593
|
});
|
|
14350
14594
|
}
|
|
14351
14595
|
SUBRULE(usingClauseStar, ast.from);
|
|
14352
|
-
F2.printFilter(ast, () =>
|
|
14596
|
+
F2.printFilter(ast, () => PRINT_WORDS("WHERE"));
|
|
14353
14597
|
SUBRULE(groupGraphPattern, ast.where);
|
|
14354
14598
|
}
|
|
14355
14599
|
};
|
|
@@ -14473,18 +14717,19 @@ var quadsNotTriples = {
|
|
|
14473
14717
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14474
14718
|
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14475
14719
|
},
|
|
14476
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
14720
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14477
14721
|
const { astFactory: F2, indentInc } = C;
|
|
14478
14722
|
F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14479
14723
|
SUBRULE(varOrTerm, ast.graph);
|
|
14480
14724
|
F2.printFilter(ast, () => {
|
|
14481
14725
|
C[traqulaIndentation] += indentInc;
|
|
14482
|
-
PRINT_WORD("{
|
|
14726
|
+
PRINT_WORD("{");
|
|
14727
|
+
NEW_LINE();
|
|
14483
14728
|
});
|
|
14484
14729
|
SUBRULE(triplesBlock, ast.triples);
|
|
14485
14730
|
F2.printFilter(ast, () => {
|
|
14486
14731
|
C[traqulaIndentation] -= indentInc;
|
|
14487
|
-
|
|
14732
|
+
PRINT_ON_OWN_LINE("}");
|
|
14488
14733
|
});
|
|
14489
14734
|
}
|
|
14490
14735
|
};
|
|
@@ -14638,13 +14883,16 @@ var sparql11GeneratorBuilder = GeneratorBuilder.create([
|
|
|
14638
14883
|
grammar_exports.filter
|
|
14639
14884
|
);
|
|
14640
14885
|
var Generator = class {
|
|
14886
|
+
constructor(defaultContext = {}) {
|
|
14887
|
+
this.defaultContext = defaultContext;
|
|
14888
|
+
}
|
|
14641
14889
|
generator = sparql11GeneratorBuilder.build();
|
|
14642
14890
|
factory = new AstFactory();
|
|
14643
14891
|
generate(ast, context = {}) {
|
|
14644
|
-
return this.generator.queryOrUpdate(ast, completeParseContext(context));
|
|
14892
|
+
return this.generator.queryOrUpdate(ast, completeParseContext({ ...this.defaultContext, ...context })).trim();
|
|
14645
14893
|
}
|
|
14646
14894
|
generatePath(ast, context = {}) {
|
|
14647
|
-
return this.generator.path(ast, completeParseContext(context), void 0);
|
|
14895
|
+
return this.generator.path(ast, completeParseContext({ ...this.defaultContext, ...context }), void 0).trim();
|
|
14648
14896
|
}
|
|
14649
14897
|
};
|
|
14650
14898
|
/*! Bundled license information:
|