@traqula/generator-sparql-1-2 0.0.18 → 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 +531 -266
- package/lib/index.d.ts +105 -73
- package/lib/index.js +6 -2
- package/lib/index.js.map +1 -1
- package/package.json +8 -8
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
|
|
|
@@ -9532,10 +9562,10 @@ function listToRuleDefMap(rules) {
|
|
|
9532
9562
|
}
|
|
9533
9563
|
var GeneratorBuilder = class _GeneratorBuilder {
|
|
9534
9564
|
static create(start) {
|
|
9535
|
-
if (start
|
|
9536
|
-
return new _GeneratorBuilder(
|
|
9565
|
+
if (Array.isArray(start)) {
|
|
9566
|
+
return new _GeneratorBuilder(listToRuleDefMap(start));
|
|
9537
9567
|
}
|
|
9538
|
-
return new _GeneratorBuilder(
|
|
9568
|
+
return new _GeneratorBuilder({ ...start.rules });
|
|
9539
9569
|
}
|
|
9540
9570
|
rules;
|
|
9541
9571
|
constructor(startRules) {
|
|
@@ -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();
|
|
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;
|
|
9783
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) => {
|
|
@@ -10986,8 +11187,8 @@ function PatternFactoryMixin(Base) {
|
|
|
10986
11187
|
isPatternOptional(obj) {
|
|
10987
11188
|
return this.isOfSubType(obj, nodeType5, "optional");
|
|
10988
11189
|
}
|
|
10989
|
-
patternValues(values3, loc) {
|
|
10990
|
-
return { type: nodeType5, subType: "values", values: values3, loc };
|
|
11190
|
+
patternValues(variables, values3, loc) {
|
|
11191
|
+
return { type: nodeType5, subType: "values", variables, values: values3, loc };
|
|
10991
11192
|
}
|
|
10992
11193
|
isPatternValues(obj) {
|
|
10993
11194
|
return this.isOfSubType(obj, nodeType5, "values");
|
|
@@ -11162,7 +11363,7 @@ function TermFactoryMixin(Base) {
|
|
|
11162
11363
|
isTerm(x) {
|
|
11163
11364
|
return this.isOfType(x, "term");
|
|
11164
11365
|
}
|
|
11165
|
-
|
|
11366
|
+
termBlank(label, loc) {
|
|
11166
11367
|
const base = {
|
|
11167
11368
|
type: "term",
|
|
11168
11369
|
subType: "blankNode",
|
|
@@ -11176,7 +11377,7 @@ function TermFactoryMixin(Base) {
|
|
|
11176
11377
|
isTermBlank(obj) {
|
|
11177
11378
|
return this.isOfSubType(obj, nodeType8, "blankNode");
|
|
11178
11379
|
}
|
|
11179
|
-
|
|
11380
|
+
termLiteral(loc, value, langOrIri) {
|
|
11180
11381
|
return {
|
|
11181
11382
|
type: nodeType8,
|
|
11182
11383
|
subType: "literal",
|
|
@@ -11198,7 +11399,7 @@ function TermFactoryMixin(Base) {
|
|
|
11198
11399
|
const casted = obj;
|
|
11199
11400
|
return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
|
|
11200
11401
|
}
|
|
11201
|
-
|
|
11402
|
+
termVariable(value, loc) {
|
|
11202
11403
|
return {
|
|
11203
11404
|
type: nodeType8,
|
|
11204
11405
|
subType: "variable",
|
|
@@ -11209,7 +11410,7 @@ function TermFactoryMixin(Base) {
|
|
|
11209
11410
|
isTermVariable(obj) {
|
|
11210
11411
|
return this.isOfSubType(obj, nodeType8, "variable");
|
|
11211
11412
|
}
|
|
11212
|
-
|
|
11413
|
+
termNamed(loc, value, prefix) {
|
|
11213
11414
|
const base = {
|
|
11214
11415
|
type: nodeType8,
|
|
11215
11416
|
subType: "namedNode",
|
|
@@ -11454,7 +11655,7 @@ var CommonIRIs;
|
|
|
11454
11655
|
CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
11455
11656
|
CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
11456
11657
|
})(CommonIRIs || (CommonIRIs = {}));
|
|
11457
|
-
var AstTransformer = class extends
|
|
11658
|
+
var AstTransformer = class extends TransformerSubTyped {
|
|
11458
11659
|
};
|
|
11459
11660
|
|
|
11460
11661
|
// ../../packages/rules-sparql-1-1/lib/validation/validators.js
|
|
@@ -11670,17 +11871,20 @@ var rdfLiteral = {
|
|
|
11670
11871
|
return OPTION(() => OR([
|
|
11671
11872
|
{ ALT: () => {
|
|
11672
11873
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11673
|
-
return ACTION(() => C.astFactory.
|
|
11874
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11674
11875
|
} },
|
|
11675
11876
|
{ ALT: () => {
|
|
11676
11877
|
CONSUME(symbols_exports.hathat);
|
|
11677
11878
|
const iriVal = SUBRULE1(iri2);
|
|
11678
|
-
return ACTION(() => C.astFactory.
|
|
11879
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11679
11880
|
} }
|
|
11680
11881
|
])) ?? value;
|
|
11681
11882
|
},
|
|
11682
|
-
gImpl: ({ SUBRULE, PRINT,
|
|
11683
|
-
astFactory.printFilter(ast, () =>
|
|
11883
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11884
|
+
astFactory.printFilter(ast, () => {
|
|
11885
|
+
PRINT_WORD("");
|
|
11886
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
11887
|
+
});
|
|
11684
11888
|
if (ast.langOrIri) {
|
|
11685
11889
|
if (typeof ast.langOrIri === "string") {
|
|
11686
11890
|
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
@@ -11707,7 +11911,7 @@ var numericLiteralUnsigned = {
|
|
|
11707
11911
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11708
11912
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11709
11913
|
]);
|
|
11710
|
-
return ACTION(() => C.astFactory.
|
|
11914
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11711
11915
|
}
|
|
11712
11916
|
};
|
|
11713
11917
|
var numericLiteralPositive = {
|
|
@@ -11718,7 +11922,7 @@ var numericLiteralPositive = {
|
|
|
11718
11922
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11719
11923
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11720
11924
|
]);
|
|
11721
|
-
return ACTION(() => C.astFactory.
|
|
11925
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11722
11926
|
}
|
|
11723
11927
|
};
|
|
11724
11928
|
var numericLiteralNegative = {
|
|
@@ -11729,7 +11933,7 @@ var numericLiteralNegative = {
|
|
|
11729
11933
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11730
11934
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11731
11935
|
]);
|
|
11732
|
-
return ACTION(() => C.astFactory.
|
|
11936
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11733
11937
|
}
|
|
11734
11938
|
};
|
|
11735
11939
|
var booleanLiteral = {
|
|
@@ -11739,7 +11943,7 @@ var booleanLiteral = {
|
|
|
11739
11943
|
{ ALT: () => CONSUME(true_) },
|
|
11740
11944
|
{ ALT: () => CONSUME(false_) }
|
|
11741
11945
|
]);
|
|
11742
|
-
return ACTION(() => C.astFactory.
|
|
11946
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11743
11947
|
}
|
|
11744
11948
|
};
|
|
11745
11949
|
var string = {
|
|
@@ -11781,7 +11985,7 @@ var string = {
|
|
|
11781
11985
|
return char;
|
|
11782
11986
|
}
|
|
11783
11987
|
});
|
|
11784
|
-
return F3.
|
|
11988
|
+
return F3.termLiteral(F3.sourceLocation(x[0]), value);
|
|
11785
11989
|
});
|
|
11786
11990
|
}
|
|
11787
11991
|
};
|
|
@@ -11797,7 +12001,7 @@ var iriFull = {
|
|
|
11797
12001
|
name: "iriFull",
|
|
11798
12002
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11799
12003
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11800
|
-
return ACTION(() => C.astFactory.
|
|
12004
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11801
12005
|
},
|
|
11802
12006
|
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11803
12007
|
F3.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
@@ -11810,16 +12014,16 @@ var prefixedName = {
|
|
|
11810
12014
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11811
12015
|
return ACTION(() => {
|
|
11812
12016
|
const [prefix, localName] = longName.image.split(":");
|
|
11813
|
-
return C.astFactory.
|
|
12017
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11814
12018
|
});
|
|
11815
12019
|
} },
|
|
11816
12020
|
{ ALT: () => {
|
|
11817
12021
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11818
|
-
return ACTION(() => C.astFactory.
|
|
12022
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11819
12023
|
} }
|
|
11820
12024
|
]),
|
|
11821
|
-
gImpl: ({
|
|
11822
|
-
F3.printFilter(ast, () =>
|
|
12025
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
12026
|
+
F3.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
11823
12027
|
}
|
|
11824
12028
|
};
|
|
11825
12029
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11829,11 +12033,11 @@ var blankNode = {
|
|
|
11829
12033
|
const result = OR([
|
|
11830
12034
|
{ ALT: () => {
|
|
11831
12035
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11832
|
-
return ACTION(() => C.astFactory.
|
|
12036
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11833
12037
|
} },
|
|
11834
12038
|
{ ALT: () => {
|
|
11835
12039
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11836
|
-
return ACTION(() => C.astFactory.
|
|
12040
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11837
12041
|
} }
|
|
11838
12042
|
]);
|
|
11839
12043
|
ACTION(() => {
|
|
@@ -11843,15 +12047,15 @@ var blankNode = {
|
|
|
11843
12047
|
});
|
|
11844
12048
|
return result;
|
|
11845
12049
|
},
|
|
11846
|
-
gImpl: ({
|
|
11847
|
-
astFactory.printFilter(ast, () =>
|
|
12050
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
12051
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
11848
12052
|
}
|
|
11849
12053
|
};
|
|
11850
12054
|
var verbA = {
|
|
11851
12055
|
name: "VerbA",
|
|
11852
12056
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11853
12057
|
const token = CONSUME(a);
|
|
11854
|
-
return ACTION(() => C.astFactory.
|
|
12058
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11855
12059
|
}
|
|
11856
12060
|
};
|
|
11857
12061
|
|
|
@@ -11885,10 +12089,10 @@ var baseDecl2 = {
|
|
|
11885
12089
|
const val = SUBRULE(iriFull);
|
|
11886
12090
|
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11887
12091
|
},
|
|
11888
|
-
gImpl: ({ SUBRULE,
|
|
11889
|
-
F3.printFilter(ast, () =>
|
|
12092
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12093
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
|
|
11890
12094
|
SUBRULE(iri2, ast.value);
|
|
11891
|
-
F3.printFilter(ast, () =>
|
|
12095
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11892
12096
|
}
|
|
11893
12097
|
};
|
|
11894
12098
|
var prefixDecl2 = {
|
|
@@ -11899,12 +12103,12 @@ var prefixDecl2 = {
|
|
|
11899
12103
|
const value = SUBRULE(iriFull);
|
|
11900
12104
|
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11901
12105
|
},
|
|
11902
|
-
gImpl: ({ SUBRULE,
|
|
12106
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
11903
12107
|
F3.printFilter(ast, () => {
|
|
11904
|
-
|
|
12108
|
+
PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
|
|
11905
12109
|
});
|
|
11906
12110
|
SUBRULE(iri2, ast.value);
|
|
11907
|
-
F3.printFilter(ast, () =>
|
|
12111
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11908
12112
|
}
|
|
11909
12113
|
};
|
|
11910
12114
|
var verb = {
|
|
@@ -11941,10 +12145,10 @@ var var_ = {
|
|
|
11941
12145
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11942
12146
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11943
12147
|
]);
|
|
11944
|
-
return ACTION(() => C.astFactory.
|
|
12148
|
+
return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11945
12149
|
},
|
|
11946
|
-
gImpl: ({
|
|
11947
|
-
F3.printFilter(ast, () =>
|
|
12150
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
12151
|
+
F3.printFilter(ast, () => PRINT(`?${ast.value}`));
|
|
11948
12152
|
}
|
|
11949
12153
|
};
|
|
11950
12154
|
var graphTerm = {
|
|
@@ -11957,7 +12161,7 @@ var graphTerm = {
|
|
|
11957
12161
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
11958
12162
|
{ ALT: () => {
|
|
11959
12163
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
11960
|
-
return ACTION(() => C.astFactory.
|
|
12164
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
11961
12165
|
} }
|
|
11962
12166
|
]),
|
|
11963
12167
|
gImpl: ({ SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
@@ -12587,13 +12791,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12587
12791
|
var triplesBlock = {
|
|
12588
12792
|
name: "triplesBlock",
|
|
12589
12793
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12590
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
12794
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12591
12795
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12592
12796
|
HANDLE_LOC(triple, () => {
|
|
12593
12797
|
const nextTriple = ast.triples.at(index);
|
|
12594
12798
|
if (F3.isTripleCollection(triple)) {
|
|
12595
12799
|
SUBRULE(graphNodePath, triple);
|
|
12596
|
-
F3.printFilter(triple, () =>
|
|
12800
|
+
F3.printFilter(triple, () => {
|
|
12801
|
+
PRINT_WORD(".");
|
|
12802
|
+
NEW_LINE();
|
|
12803
|
+
});
|
|
12597
12804
|
} else {
|
|
12598
12805
|
SUBRULE(graphNodePath, triple.subject);
|
|
12599
12806
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
@@ -12605,11 +12812,17 @@ var triplesBlock = {
|
|
|
12605
12812
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12606
12813
|
SUBRULE(graphNodePath, triple.object);
|
|
12607
12814
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12608
|
-
F3.printFilter(ast, () =>
|
|
12815
|
+
F3.printFilter(ast, () => {
|
|
12816
|
+
PRINT_WORD(".");
|
|
12817
|
+
NEW_LINE();
|
|
12818
|
+
});
|
|
12609
12819
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12610
12820
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
12611
12821
|
} else {
|
|
12612
|
-
F3.printFilter(ast, () =>
|
|
12822
|
+
F3.printFilter(ast, () => {
|
|
12823
|
+
PRINT_WORD(";");
|
|
12824
|
+
NEW_LINE();
|
|
12825
|
+
});
|
|
12613
12826
|
}
|
|
12614
12827
|
}
|
|
12615
12828
|
});
|
|
@@ -12742,10 +12955,10 @@ function collectionImpl(name, allowPaths) {
|
|
|
12742
12955
|
return ACTION(() => {
|
|
12743
12956
|
const F3 = C.astFactory;
|
|
12744
12957
|
const triples = [];
|
|
12745
|
-
const predFirst = F3.
|
|
12746
|
-
const predRest = F3.
|
|
12747
|
-
const predNil = F3.
|
|
12748
|
-
const listHead = F3.
|
|
12958
|
+
const predFirst = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12959
|
+
const predRest = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
12960
|
+
const predNil = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
|
|
12961
|
+
const listHead = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12749
12962
|
let iterHead = listHead;
|
|
12750
12963
|
for (const [index, term] of terms.entries()) {
|
|
12751
12964
|
const lastInList = index === terms.length - 1;
|
|
@@ -12755,7 +12968,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12755
12968
|
const nilTriple = F3.triple(iterHead, predRest, predNil);
|
|
12756
12969
|
triples.push(nilTriple);
|
|
12757
12970
|
} else {
|
|
12758
|
-
const tail = F3.
|
|
12971
|
+
const tail = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12759
12972
|
const linkTriple = F3.triple(iterHead, predRest, tail);
|
|
12760
12973
|
triples.push(linkTriple);
|
|
12761
12974
|
iterHead = tail;
|
|
@@ -12795,16 +13008,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12795
13008
|
name,
|
|
12796
13009
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12797
13010
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12798
|
-
const blankNode2 = ACTION(() => C.astFactory.
|
|
13011
|
+
const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12799
13012
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12800
13013
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12801
13014
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12802
13015
|
},
|
|
12803
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
13016
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
12804
13017
|
const { astFactory: F3, indentInc } = c;
|
|
12805
13018
|
F3.printFilter(ast, () => {
|
|
12806
13019
|
c[traqulaIndentation] += indentInc;
|
|
12807
|
-
PRINT("[
|
|
13020
|
+
PRINT("[");
|
|
13021
|
+
NEW_LINE();
|
|
12808
13022
|
});
|
|
12809
13023
|
for (const triple of ast.triples) {
|
|
12810
13024
|
HANDLE_LOC(triple, () => {
|
|
@@ -12815,7 +13029,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12815
13029
|
}
|
|
12816
13030
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12817
13031
|
SUBRULE(graphNodePath, triple.object);
|
|
12818
|
-
F3.printFilter(ast, () =>
|
|
13032
|
+
F3.printFilter(ast, () => {
|
|
13033
|
+
PRINT_WORD(";");
|
|
13034
|
+
NEW_LINE();
|
|
13035
|
+
});
|
|
12819
13036
|
});
|
|
12820
13037
|
}
|
|
12821
13038
|
F3.printFilter(ast, () => {
|
|
@@ -12874,18 +13091,19 @@ var groupGraphPattern = {
|
|
|
12874
13091
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12875
13092
|
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12876
13093
|
},
|
|
12877
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
13094
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12878
13095
|
const { astFactory: F3, indentInc } = C;
|
|
12879
13096
|
F3.printFilter(ast, () => {
|
|
12880
13097
|
C[traqulaIndentation] += indentInc;
|
|
12881
|
-
PRINT_WORD("{
|
|
13098
|
+
PRINT_WORD("{");
|
|
13099
|
+
NEW_LINE();
|
|
12882
13100
|
});
|
|
12883
13101
|
for (const pattern of ast.patterns) {
|
|
12884
13102
|
SUBRULE(generatePattern, pattern);
|
|
12885
13103
|
}
|
|
12886
13104
|
F3.printFilter(ast, () => {
|
|
12887
13105
|
C[traqulaIndentation] -= indentInc;
|
|
12888
|
-
|
|
13106
|
+
PRINT_ON_OWN_LINE("}");
|
|
12889
13107
|
});
|
|
12890
13108
|
}
|
|
12891
13109
|
};
|
|
@@ -13035,12 +13253,15 @@ var bind2 = {
|
|
|
13035
13253
|
const close = CONSUME(symbols_exports.RParen);
|
|
13036
13254
|
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
13037
13255
|
},
|
|
13038
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13256
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13039
13257
|
F3.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
13040
13258
|
SUBRULE(expression, ast.expression);
|
|
13041
13259
|
F3.printFilter(ast, () => PRINT_WORD("AS"));
|
|
13042
13260
|
SUBRULE(var_, ast.variable);
|
|
13043
|
-
F3.printFilter(ast, () =>
|
|
13261
|
+
F3.printFilter(ast, () => {
|
|
13262
|
+
PRINT_WORD(")");
|
|
13263
|
+
NEW_LINE();
|
|
13264
|
+
});
|
|
13044
13265
|
}
|
|
13045
13266
|
};
|
|
13046
13267
|
var inlineData = {
|
|
@@ -13048,34 +13269,46 @@ var inlineData = {
|
|
|
13048
13269
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
13049
13270
|
const values3 = CONSUME(values2);
|
|
13050
13271
|
const datablock = SUBRULE(dataBlock);
|
|
13051
|
-
return ACTION(() =>
|
|
13272
|
+
return ACTION(() => {
|
|
13273
|
+
datablock.loc = C.astFactory.sourceLocation(values3, datablock);
|
|
13274
|
+
return datablock;
|
|
13275
|
+
});
|
|
13052
13276
|
},
|
|
13053
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13277
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
13054
13278
|
const { astFactory: F3, indentInc } = C;
|
|
13055
|
-
const variables =
|
|
13279
|
+
const variables = ast.variables;
|
|
13280
|
+
const singleVar = variables.length === 1;
|
|
13281
|
+
F3.printFilter(ast, () => {
|
|
13282
|
+
PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
|
|
13283
|
+
});
|
|
13284
|
+
for (const variable of variables) {
|
|
13285
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13286
|
+
SUBRULE(varOrTerm, variable);
|
|
13287
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13288
|
+
}
|
|
13056
13289
|
F3.printFilter(ast, () => {
|
|
13057
|
-
PRINT_ON_EMPTY("");
|
|
13058
|
-
PRINT_WORD("VALUES", "(");
|
|
13059
|
-
for (const variable of variables) {
|
|
13060
|
-
PRINT_WORD(`?${variable}`);
|
|
13061
|
-
}
|
|
13062
13290
|
C[traqulaIndentation] += indentInc;
|
|
13063
|
-
PRINT_WORD(")", "{
|
|
13291
|
+
PRINT_WORD(singleVar ? "" : ")", "{");
|
|
13292
|
+
NEW_LINE();
|
|
13064
13293
|
});
|
|
13065
13294
|
for (const mapping of ast.values) {
|
|
13066
|
-
F3.printFilter(ast, () => PRINT_WORD("("));
|
|
13295
|
+
F3.printFilter(ast, () => !singleVar && PRINT_WORD("("));
|
|
13067
13296
|
for (const variable of variables) {
|
|
13068
|
-
|
|
13297
|
+
const var_2 = variable.value;
|
|
13298
|
+
if (mapping[var_2] === void 0) {
|
|
13069
13299
|
F3.printFilter(ast, () => PRINT_WORD("UNDEF"));
|
|
13070
13300
|
} else {
|
|
13071
|
-
SUBRULE(graphNodePath, mapping[
|
|
13301
|
+
SUBRULE(graphNodePath, mapping[var_2]);
|
|
13072
13302
|
}
|
|
13073
13303
|
}
|
|
13074
|
-
F3.printFilter(ast, () =>
|
|
13304
|
+
F3.printFilter(ast, () => {
|
|
13305
|
+
PRINT_WORD(singleVar ? "" : ")");
|
|
13306
|
+
NEW_LINE();
|
|
13307
|
+
});
|
|
13075
13308
|
}
|
|
13076
13309
|
F3.printFilter(ast, () => {
|
|
13077
13310
|
C[traqulaIndentation] -= indentInc;
|
|
13078
|
-
|
|
13311
|
+
PRINT_ON_OWN_LINE("}");
|
|
13079
13312
|
});
|
|
13080
13313
|
}
|
|
13081
13314
|
};
|
|
@@ -13099,7 +13332,7 @@ var inlineDataOneVar = {
|
|
|
13099
13332
|
});
|
|
13100
13333
|
});
|
|
13101
13334
|
const close = CONSUME(symbols_exports.RCurly);
|
|
13102
|
-
return ACTION(() => C.astFactory.
|
|
13335
|
+
return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
|
|
13103
13336
|
}
|
|
13104
13337
|
};
|
|
13105
13338
|
var inlineDataFull = {
|
|
@@ -13116,7 +13349,7 @@ var inlineDataFull = {
|
|
|
13116
13349
|
res.push({});
|
|
13117
13350
|
});
|
|
13118
13351
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
13119
|
-
return ACTION(() => C.astFactory.
|
|
13352
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
|
|
13120
13353
|
} },
|
|
13121
13354
|
{ ALT: () => {
|
|
13122
13355
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -13148,7 +13381,7 @@ var inlineDataFull = {
|
|
|
13148
13381
|
});
|
|
13149
13382
|
});
|
|
13150
13383
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
13151
|
-
return ACTION(() => C.astFactory.
|
|
13384
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
|
|
13152
13385
|
} }
|
|
13153
13386
|
]);
|
|
13154
13387
|
}
|
|
@@ -13211,10 +13444,13 @@ var filter3 = {
|
|
|
13211
13444
|
const expression2 = SUBRULE(constraint);
|
|
13212
13445
|
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
13213
13446
|
},
|
|
13214
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13447
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13215
13448
|
F3.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
13216
13449
|
SUBRULE(expression, ast.expression);
|
|
13217
|
-
F3.printFilter(ast, () =>
|
|
13450
|
+
F3.printFilter(ast, () => {
|
|
13451
|
+
PRINT_WORD(")");
|
|
13452
|
+
NEW_LINE();
|
|
13453
|
+
});
|
|
13218
13454
|
}
|
|
13219
13455
|
};
|
|
13220
13456
|
var constraint = {
|
|
@@ -13600,8 +13836,7 @@ var groupClause = {
|
|
|
13600
13836
|
},
|
|
13601
13837
|
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13602
13838
|
F3.printFilter(ast, () => {
|
|
13603
|
-
PRINT_ON_EMPTY("");
|
|
13604
|
-
PRINT_WORDS("GROUP", "BY");
|
|
13839
|
+
PRINT_ON_EMPTY("GROUP BY ");
|
|
13605
13840
|
});
|
|
13606
13841
|
for (const grouping of ast.groupings) {
|
|
13607
13842
|
if (F3.isExpression(grouping)) {
|
|
@@ -13657,10 +13892,9 @@ var havingClause = {
|
|
|
13657
13892
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13658
13893
|
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13659
13894
|
},
|
|
13660
|
-
gImpl: ({
|
|
13895
|
+
gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13661
13896
|
F3.printFilter(ast, () => {
|
|
13662
|
-
PRINT_ON_EMPTY("");
|
|
13663
|
-
PRINT_WORD("HAVING");
|
|
13897
|
+
PRINT_ON_EMPTY("HAVING ");
|
|
13664
13898
|
});
|
|
13665
13899
|
for (const having2 of ast.having) {
|
|
13666
13900
|
SUBRULE(expression, having2);
|
|
@@ -13686,8 +13920,7 @@ var orderClause = {
|
|
|
13686
13920
|
},
|
|
13687
13921
|
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13688
13922
|
F3.printFilter(ast, () => {
|
|
13689
|
-
PRINT_ON_EMPTY("");
|
|
13690
|
-
PRINT_WORDS("ORDER", "BY");
|
|
13923
|
+
PRINT_ON_EMPTY("ORDER BY ");
|
|
13691
13924
|
});
|
|
13692
13925
|
for (const ordering of ast.orderDefs) {
|
|
13693
13926
|
if (ordering.descending) {
|
|
@@ -13746,9 +13979,9 @@ var limitOffsetClauses = {
|
|
|
13746
13979
|
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13747
13980
|
} }
|
|
13748
13981
|
]),
|
|
13749
|
-
gImpl: ({ PRINT_WORDS,
|
|
13982
|
+
gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13750
13983
|
F3.printFilter(ast, () => {
|
|
13751
|
-
|
|
13984
|
+
NEW_LINE();
|
|
13752
13985
|
if (ast.limit) {
|
|
13753
13986
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13754
13987
|
}
|
|
@@ -13933,9 +14166,9 @@ var selectClause = {
|
|
|
13933
14166
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13934
14167
|
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13935
14168
|
},
|
|
13936
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14169
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13937
14170
|
F3.printFilter(ast, () => {
|
|
13938
|
-
|
|
14171
|
+
PRINT_ON_EMPTY("SELECT ");
|
|
13939
14172
|
if (ast.val.distinct) {
|
|
13940
14173
|
PRINT_WORD("DISTINCT");
|
|
13941
14174
|
} else if (ast.val.reduced) {
|
|
@@ -13954,7 +14187,9 @@ var selectClause = {
|
|
|
13954
14187
|
SUBRULE(var_, variable.variable);
|
|
13955
14188
|
F3.printFilter(ast, () => PRINT_WORD(")"));
|
|
13956
14189
|
}
|
|
14190
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13957
14191
|
}
|
|
14192
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13958
14193
|
}
|
|
13959
14194
|
};
|
|
13960
14195
|
var constructQuery = {
|
|
@@ -13992,18 +14227,19 @@ var constructQuery = {
|
|
|
13992
14227
|
} }
|
|
13993
14228
|
]);
|
|
13994
14229
|
},
|
|
13995
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14230
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
13996
14231
|
const { astFactory: F3, indentInc } = C;
|
|
13997
|
-
F3.printFilter(ast, () =>
|
|
14232
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
|
|
13998
14233
|
if (!F3.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
13999
14234
|
F3.printFilter(ast, () => {
|
|
14000
14235
|
C[traqulaIndentation] += indentInc;
|
|
14001
|
-
PRINT_WORD("{
|
|
14236
|
+
PRINT_WORD("{");
|
|
14237
|
+
NEW_LINE();
|
|
14002
14238
|
});
|
|
14003
14239
|
SUBRULE(triplesBlock, ast.template);
|
|
14004
14240
|
F3.printFilter(ast, () => {
|
|
14005
14241
|
C[traqulaIndentation] -= indentInc;
|
|
14006
|
-
|
|
14242
|
+
PRINT_ON_OWN_LINE("}");
|
|
14007
14243
|
});
|
|
14008
14244
|
}
|
|
14009
14245
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
@@ -14044,8 +14280,8 @@ var describeQuery = {
|
|
|
14044
14280
|
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14045
14281
|
}));
|
|
14046
14282
|
},
|
|
14047
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14048
|
-
F3.printFilter(ast, () =>
|
|
14283
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14284
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
|
|
14049
14285
|
if (F3.isWildcard(ast.variables[0])) {
|
|
14050
14286
|
F3.printFilter(ast, () => PRINT_WORD("*"));
|
|
14051
14287
|
} else {
|
|
@@ -14075,8 +14311,8 @@ var askQuery = {
|
|
|
14075
14311
|
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14076
14312
|
}));
|
|
14077
14313
|
},
|
|
14078
|
-
gImpl: ({ SUBRULE,
|
|
14079
|
-
F3.printFilter(ast, () =>
|
|
14314
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14315
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
|
|
14080
14316
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
14081
14317
|
SUBRULE(whereClause, F3.wrap(ast.where, ast.loc));
|
|
14082
14318
|
SUBRULE(solutionModifier, ast.solutionModifiers);
|
|
@@ -14135,7 +14371,7 @@ var update = {
|
|
|
14135
14371
|
return update2;
|
|
14136
14372
|
});
|
|
14137
14373
|
},
|
|
14138
|
-
gImpl: ({ SUBRULE,
|
|
14374
|
+
gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
14139
14375
|
const [head2, ...tail] = ast.updates;
|
|
14140
14376
|
if (head2) {
|
|
14141
14377
|
SUBRULE(prologue, head2.context);
|
|
@@ -14144,7 +14380,10 @@ var update = {
|
|
|
14144
14380
|
}
|
|
14145
14381
|
}
|
|
14146
14382
|
for (const update2 of tail) {
|
|
14147
|
-
F3.printFilter(ast, () =>
|
|
14383
|
+
F3.printFilter(ast, () => {
|
|
14384
|
+
PRINT(";");
|
|
14385
|
+
NEW_LINE();
|
|
14386
|
+
});
|
|
14148
14387
|
SUBRULE(prologue, update2.context);
|
|
14149
14388
|
if (update2.operation) {
|
|
14150
14389
|
SUBRULE(update1, update2.operation);
|
|
@@ -14217,9 +14456,9 @@ var load2 = {
|
|
|
14217
14456
|
});
|
|
14218
14457
|
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
14219
14458
|
},
|
|
14220
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14459
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14221
14460
|
F3.printFilter(ast, () => {
|
|
14222
|
-
|
|
14461
|
+
PRINT_ON_EMPTY("LOAD ");
|
|
14223
14462
|
if (ast.silent) {
|
|
14224
14463
|
PRINT_WORD("SILENT");
|
|
14225
14464
|
}
|
|
@@ -14240,9 +14479,9 @@ function clearOrDrop(operation) {
|
|
|
14240
14479
|
const destination = SUBRULE1(graphRefAll);
|
|
14241
14480
|
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
14242
14481
|
},
|
|
14243
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14482
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14244
14483
|
F3.printFilter(ast, () => {
|
|
14245
|
-
|
|
14484
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14246
14485
|
if (ast.silent) {
|
|
14247
14486
|
PRINT_WORD("SILENT");
|
|
14248
14487
|
}
|
|
@@ -14261,9 +14500,9 @@ var create2 = {
|
|
|
14261
14500
|
const destination = SUBRULE1(graphRef);
|
|
14262
14501
|
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
14263
14502
|
},
|
|
14264
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14503
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14265
14504
|
F3.printFilter(ast, () => {
|
|
14266
|
-
|
|
14505
|
+
PRINT_ON_EMPTY("CREATE ");
|
|
14267
14506
|
if (ast.silent) {
|
|
14268
14507
|
PRINT_WORD("SILENT");
|
|
14269
14508
|
}
|
|
@@ -14282,9 +14521,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14282
14521
|
const destination = SUBRULE2(graphOrDefault);
|
|
14283
14522
|
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14284
14523
|
},
|
|
14285
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14524
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14286
14525
|
F3.printFilter(ast, () => {
|
|
14287
|
-
|
|
14526
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14288
14527
|
if (ast.silent) {
|
|
14289
14528
|
PRINT_WORD("SILENT");
|
|
14290
14529
|
}
|
|
@@ -14333,23 +14572,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
|
|
|
14333
14572
|
}
|
|
14334
14573
|
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14335
14574
|
},
|
|
14336
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14575
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14337
14576
|
const { astFactory: F3, indentInc } = C;
|
|
14338
14577
|
F3.printFilter(ast, () => {
|
|
14339
|
-
C[traqulaIndentation] += indentInc;
|
|
14340
14578
|
if (subType === "insertdata") {
|
|
14341
|
-
|
|
14579
|
+
PRINT_ON_EMPTY("INSERT DATA ");
|
|
14342
14580
|
} else if (subType === "deletedata") {
|
|
14343
|
-
|
|
14581
|
+
PRINT_ON_EMPTY("DELETE DATA ");
|
|
14344
14582
|
} else if (subType === "deletewhere") {
|
|
14345
|
-
|
|
14583
|
+
PRINT_ON_EMPTY("DELETE WHERE ");
|
|
14346
14584
|
}
|
|
14347
|
-
|
|
14585
|
+
C[traqulaIndentation] += indentInc;
|
|
14586
|
+
PRINT_WORD("{");
|
|
14587
|
+
NEW_LINE();
|
|
14348
14588
|
});
|
|
14349
14589
|
SUBRULE(quads, F3.wrap(ast.data, ast.loc));
|
|
14350
14590
|
F3.printFilter(ast, () => {
|
|
14351
14591
|
C[traqulaIndentation] -= indentInc;
|
|
14352
|
-
|
|
14592
|
+
PRINT_ON_OWN_LINE("}");
|
|
14353
14593
|
});
|
|
14354
14594
|
}
|
|
14355
14595
|
};
|
|
@@ -14381,36 +14621,40 @@ var modify = {
|
|
|
14381
14621
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14382
14622
|
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14383
14623
|
},
|
|
14384
|
-
gImpl: ({ SUBRULE,
|
|
14624
|
+
gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
|
|
14385
14625
|
const { astFactory: F3, indentInc } = C;
|
|
14386
14626
|
if (ast.graph) {
|
|
14387
|
-
F3.printFilter(ast, () =>
|
|
14627
|
+
F3.printFilter(ast, () => PRINT_WORDS("WITH"));
|
|
14388
14628
|
SUBRULE(iri2, ast.graph);
|
|
14389
14629
|
}
|
|
14390
14630
|
if (ast.delete.length > 0) {
|
|
14391
14631
|
F3.printFilter(ast, () => {
|
|
14392
14632
|
C[traqulaIndentation] += indentInc;
|
|
14393
|
-
|
|
14633
|
+
PRINT_WORDS("DELETE", "{");
|
|
14634
|
+
NEW_LINE();
|
|
14394
14635
|
});
|
|
14395
14636
|
SUBRULE(quads, F3.wrap(ast.delete, ast.loc));
|
|
14396
14637
|
F3.printFilter(ast, () => {
|
|
14397
14638
|
C[traqulaIndentation] -= indentInc;
|
|
14398
|
-
PRINT_ON_EMPTY("}
|
|
14639
|
+
PRINT_ON_EMPTY("}");
|
|
14640
|
+
NEW_LINE();
|
|
14399
14641
|
});
|
|
14400
14642
|
}
|
|
14401
14643
|
if (ast.insert.length > 0) {
|
|
14402
14644
|
F3.printFilter(ast, () => {
|
|
14403
14645
|
C[traqulaIndentation] += indentInc;
|
|
14404
|
-
|
|
14646
|
+
PRINT_WORDS("INSERT", "{");
|
|
14647
|
+
NEW_LINE();
|
|
14405
14648
|
});
|
|
14406
14649
|
SUBRULE(quads, F3.wrap(ast.insert, ast.loc));
|
|
14407
14650
|
F3.printFilter(ast, () => {
|
|
14408
14651
|
C[traqulaIndentation] -= indentInc;
|
|
14409
|
-
PRINT_ON_EMPTY("}
|
|
14652
|
+
PRINT_ON_EMPTY("} ");
|
|
14653
|
+
NEW_LINE();
|
|
14410
14654
|
});
|
|
14411
14655
|
}
|
|
14412
14656
|
SUBRULE(usingClauseStar, ast.from);
|
|
14413
|
-
F3.printFilter(ast, () =>
|
|
14657
|
+
F3.printFilter(ast, () => PRINT_WORDS("WHERE"));
|
|
14414
14658
|
SUBRULE(groupGraphPattern, ast.where);
|
|
14415
14659
|
}
|
|
14416
14660
|
};
|
|
@@ -14534,18 +14778,19 @@ var quadsNotTriples = {
|
|
|
14534
14778
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14535
14779
|
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14536
14780
|
},
|
|
14537
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
14781
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14538
14782
|
const { astFactory: F3, indentInc } = C;
|
|
14539
14783
|
F3.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14540
14784
|
SUBRULE(varOrTerm, ast.graph);
|
|
14541
14785
|
F3.printFilter(ast, () => {
|
|
14542
14786
|
C[traqulaIndentation] += indentInc;
|
|
14543
|
-
PRINT_WORD("{
|
|
14787
|
+
PRINT_WORD("{");
|
|
14788
|
+
NEW_LINE();
|
|
14544
14789
|
});
|
|
14545
14790
|
SUBRULE(triplesBlock, ast.triples);
|
|
14546
14791
|
F3.printFilter(ast, () => {
|
|
14547
14792
|
C[traqulaIndentation] -= indentInc;
|
|
14548
|
-
|
|
14793
|
+
PRINT_ON_OWN_LINE("}");
|
|
14549
14794
|
});
|
|
14550
14795
|
}
|
|
14551
14796
|
};
|
|
@@ -14725,7 +14970,7 @@ var AstFactory2 = class extends AstFactory {
|
|
|
14725
14970
|
type: "tripleCollection",
|
|
14726
14971
|
subType: "reifiedTriple",
|
|
14727
14972
|
triples: [this.triple(subject, predicate, object3)],
|
|
14728
|
-
identifier: reifier2 ?? this.
|
|
14973
|
+
identifier: reifier2 ?? this.termBlank(void 0, this.sourceLocationNoMaterialize()),
|
|
14729
14974
|
loc
|
|
14730
14975
|
};
|
|
14731
14976
|
}
|
|
@@ -14800,9 +15045,9 @@ var versionDecl = {
|
|
|
14800
15045
|
const identifier = SUBRULE(versionSpecifier);
|
|
14801
15046
|
return ACTION(() => C.astFactory.contextDefinitionVersion(identifier.val, C.astFactory.sourceLocation(versionToken, identifier)));
|
|
14802
15047
|
},
|
|
14803
|
-
gImpl: ({
|
|
15048
|
+
gImpl: ({ PRINT_ON_OWN_LINE }) => (ast, { astFactory: F3 }) => {
|
|
14804
15049
|
F3.printFilter(ast, () => {
|
|
14805
|
-
|
|
15050
|
+
PRINT_ON_OWN_LINE("VERSION ", `${grammar_exports.stringEscapedLexical(ast.version)}`);
|
|
14806
15051
|
});
|
|
14807
15052
|
}
|
|
14808
15053
|
};
|
|
@@ -14869,7 +15114,7 @@ var reifier = {
|
|
|
14869
15114
|
if (reifier2 === void 0 && !C.parseMode.has("canCreateBlankNodes")) {
|
|
14870
15115
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
14871
15116
|
}
|
|
14872
|
-
return C.astFactory.wrap(reifier2 ?? C.astFactory.
|
|
15117
|
+
return C.astFactory.wrap(reifier2 ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation()), C.astFactory.sourceLocation(tildeToken, reifier2));
|
|
14873
15118
|
});
|
|
14874
15119
|
}
|
|
14875
15120
|
};
|
|
@@ -14928,7 +15173,7 @@ function annotationImpl(name, allowPaths) {
|
|
|
14928
15173
|
if (!currentReifier && !C.parseMode.has("canCreateBlankNodes")) {
|
|
14929
15174
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
14930
15175
|
}
|
|
14931
|
-
currentReifier = currentReifier ?? C.astFactory.
|
|
15176
|
+
currentReifier = currentReifier ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation());
|
|
14932
15177
|
});
|
|
14933
15178
|
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, currentReifier);
|
|
14934
15179
|
ACTION(() => {
|
|
@@ -14963,13 +15208,13 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
14963
15208
|
const close = CONSUME(annotationClose);
|
|
14964
15209
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(arg, res, C.astFactory.sourceLocation(open, close)));
|
|
14965
15210
|
},
|
|
14966
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC,
|
|
15211
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14967
15212
|
const { astFactory: F3, indentInc } = C;
|
|
14968
15213
|
F3.printFilter(ast, () => {
|
|
14969
15214
|
PRINT_WORD("{|");
|
|
14970
15215
|
if (ast.triples.length > 1) {
|
|
14971
15216
|
C[traqulaIndentation] += indentInc;
|
|
14972
|
-
|
|
15217
|
+
NEW_LINE();
|
|
14973
15218
|
}
|
|
14974
15219
|
});
|
|
14975
15220
|
function printTriple(triple) {
|
|
@@ -14979,18 +15224,22 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
14979
15224
|
} else {
|
|
14980
15225
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
14981
15226
|
}
|
|
15227
|
+
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
14982
15228
|
SUBRULE(graphNodePath2, triple.object);
|
|
14983
15229
|
});
|
|
14984
15230
|
}
|
|
14985
15231
|
const [head2, ...tail] = ast.triples;
|
|
14986
15232
|
printTriple(head2);
|
|
14987
15233
|
for (const triple of tail) {
|
|
14988
|
-
F3.printFilter(ast, () =>
|
|
15234
|
+
F3.printFilter(ast, () => {
|
|
15235
|
+
PRINT_WORD(";");
|
|
15236
|
+
NEW_LINE();
|
|
15237
|
+
});
|
|
14989
15238
|
printTriple(triple);
|
|
14990
15239
|
}
|
|
14991
15240
|
F3.printFilter(ast, () => {
|
|
14992
15241
|
if (ast.triples.length > 1) {
|
|
14993
|
-
|
|
15242
|
+
PRINT_ON_OWN_LINE("|}");
|
|
14994
15243
|
} else {
|
|
14995
15244
|
PRINT_WORD("|}");
|
|
14996
15245
|
}
|
|
@@ -15032,7 +15281,7 @@ var varOrTerm2 = {
|
|
|
15032
15281
|
{ ALT: () => SUBRULE(grammar_exports.blankNode) },
|
|
15033
15282
|
{ ALT: () => {
|
|
15034
15283
|
const token = CONSUME(lexer_exports.terminals.nil);
|
|
15035
|
-
return ACTION(() => C.astFactory.
|
|
15284
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.NIL));
|
|
15036
15285
|
} },
|
|
15037
15286
|
{ ALT: () => SUBRULE(tripleTerm) }
|
|
15038
15287
|
])
|
|
@@ -15058,11 +15307,13 @@ var reifiedTriple = {
|
|
|
15058
15307
|
F3.printFilter(ast, () => PRINT_WORD("<<"));
|
|
15059
15308
|
const triple = ast.triples[0];
|
|
15060
15309
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15310
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15061
15311
|
if (F3.isPathPure(triple.predicate)) {
|
|
15062
15312
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
15063
15313
|
} else {
|
|
15064
15314
|
SUBRULE(graphNodePath2, triple.predicate);
|
|
15065
15315
|
}
|
|
15316
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15066
15317
|
SUBRULE(graphNodePath2, triple.object);
|
|
15067
15318
|
SUBRULE(annotationPath, [F3.wrap(ast.identifier, ast.identifier.loc)]);
|
|
15068
15319
|
F3.printFilter(ast, () => PRINT_WORD(">>"));
|
|
@@ -15098,7 +15349,9 @@ var tripleTerm = {
|
|
|
15098
15349
|
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
15099
15350
|
F3.printFilter(ast, () => PRINT_WORD("<<("));
|
|
15100
15351
|
SUBRULE(graphNodePath2, ast.subject);
|
|
15352
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15101
15353
|
SUBRULE(graphNodePath2, ast.predicate);
|
|
15354
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15102
15355
|
SUBRULE(graphNodePath2, ast.object);
|
|
15103
15356
|
F3.printFilter(ast, () => PRINT_WORD(")>>"));
|
|
15104
15357
|
}
|
|
@@ -15128,7 +15381,7 @@ var tripleTermData = {
|
|
|
15128
15381
|
{ ALT: () => SUBRULE(grammar_exports.iri) },
|
|
15129
15382
|
{ ALT: () => {
|
|
15130
15383
|
const token = CONSUME(lexer_exports.a);
|
|
15131
|
-
return ACTION(() => C.astFactory.
|
|
15384
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE));
|
|
15132
15385
|
} }
|
|
15133
15386
|
]);
|
|
15134
15387
|
const object3 = SUBRULE(tripleTermDataObject);
|
|
@@ -15215,7 +15468,7 @@ var rdfLiteral2 = {
|
|
|
15215
15468
|
{ ALT: () => {
|
|
15216
15469
|
const langTag2 = CONSUME(LANG_DIR);
|
|
15217
15470
|
return ACTION(() => {
|
|
15218
|
-
const literal = C.astFactory.
|
|
15471
|
+
const literal = C.astFactory.termLiteral(C.astFactory.sourceLocation(value, langTag2), value.value, langTag2.image.slice(1).toLowerCase());
|
|
15219
15472
|
langTagHasCorrectRange(literal);
|
|
15220
15473
|
return literal;
|
|
15221
15474
|
});
|
|
@@ -15223,7 +15476,7 @@ var rdfLiteral2 = {
|
|
|
15223
15476
|
{ ALT: () => {
|
|
15224
15477
|
CONSUME(lexer_exports.symbols.hathat);
|
|
15225
15478
|
const iriVal = SUBRULE(grammar_exports.iri);
|
|
15226
|
-
return ACTION(() => C.astFactory.
|
|
15479
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
15227
15480
|
} }
|
|
15228
15481
|
])) ?? value;
|
|
15229
15482
|
}
|
|
@@ -15249,13 +15502,16 @@ var unaryExpression2 = {
|
|
|
15249
15502
|
};
|
|
15250
15503
|
var generateTriplesBlock = {
|
|
15251
15504
|
name: "triplesBlock",
|
|
15252
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15505
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15253
15506
|
for (const [index, triple] of ast.triples.entries()) {
|
|
15254
15507
|
HANDLE_LOC(triple, () => {
|
|
15255
15508
|
const nextTriple = ast.triples.at(index);
|
|
15256
15509
|
if (F3.isTripleCollection(triple)) {
|
|
15257
15510
|
SUBRULE(graphNodePath2, triple);
|
|
15258
|
-
F3.printFilter(triple, () =>
|
|
15511
|
+
F3.printFilter(triple, () => {
|
|
15512
|
+
PRINT_WORD(".");
|
|
15513
|
+
NEW_LINE();
|
|
15514
|
+
});
|
|
15259
15515
|
} else {
|
|
15260
15516
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15261
15517
|
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
@@ -15268,11 +15524,17 @@ var generateTriplesBlock = {
|
|
|
15268
15524
|
SUBRULE(graphNodePath2, triple.object);
|
|
15269
15525
|
SUBRULE(annotationPath, triple.annotations ?? []);
|
|
15270
15526
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
15271
|
-
F3.printFilter(ast, () =>
|
|
15527
|
+
F3.printFilter(ast, () => {
|
|
15528
|
+
PRINT_WORD(".");
|
|
15529
|
+
NEW_LINE();
|
|
15530
|
+
});
|
|
15272
15531
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
15273
15532
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
15274
15533
|
} else {
|
|
15275
|
-
F3.printFilter(ast, () =>
|
|
15534
|
+
F3.printFilter(ast, () => {
|
|
15535
|
+
PRINT_WORD(";");
|
|
15536
|
+
NEW_LINE();
|
|
15537
|
+
});
|
|
15276
15538
|
}
|
|
15277
15539
|
}
|
|
15278
15540
|
});
|
|
@@ -15308,13 +15570,16 @@ function completeParseContext2(context) {
|
|
|
15308
15570
|
// lib/index.ts
|
|
15309
15571
|
var sparql12GeneratorBuilder = GeneratorBuilder.create(sparql11GeneratorBuilder).widenContext().typePatch().addRule(grammar_exports2.tripleTerm).addRule(grammar_exports2.reifiedTriple).patchRule(grammar_exports2.graphNodePath).addRule(grammar_exports2.annotationBlockPath).addRule(grammar_exports2.annotationPath).addRule(grammar_exports2.versionDecl).patchRule(grammar_exports2.prologue).patchRule(grammar_exports2.generateTriplesBlock).patchRule(grammar_exports2.generateGraphTerm);
|
|
15310
15572
|
var Generator = class {
|
|
15573
|
+
constructor(defaultContext = {}) {
|
|
15574
|
+
this.defaultContext = defaultContext;
|
|
15575
|
+
}
|
|
15311
15576
|
generator = sparql12GeneratorBuilder.build();
|
|
15312
15577
|
F = new AstFactory2();
|
|
15313
15578
|
generate(ast, context = {}) {
|
|
15314
|
-
return this.generator.queryOrUpdate(ast, completeParseContext2(context));
|
|
15579
|
+
return this.generator.queryOrUpdate(ast, completeParseContext2({ ...this.defaultContext, ...context })).trim();
|
|
15315
15580
|
}
|
|
15316
15581
|
generatePath(ast, context = {}) {
|
|
15317
|
-
return this.generator.path(ast, completeParseContext2(context), void 0);
|
|
15582
|
+
return this.generator.path(ast, completeParseContext2({ ...this.defaultContext, ...context }), void 0).trim();
|
|
15318
15583
|
}
|
|
15319
15584
|
};
|
|
15320
15585
|
/*! Bundled license information:
|