@traqula/rules-sparql-1-2 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/AstFactory.js +1 -1
- package/lib/AstFactory.js.map +1 -1
- package/lib/grammar.d.ts +2 -2
- package/lib/grammar.js +33 -16
- package/lib/grammar.js.map +1 -1
- package/lib/index.cjs +436 -207
- package/lib/lexer.d.ts +1 -1
- package/lib/parserUtils.d.ts +2 -2
- package/lib/parserUtils.js +2 -2
- package/lib/parserUtils.js.map +1 -1
- package/lib/sparql12Types.d.ts +1 -0
- package/lib/sparql12Types.js.map +1 -1
- package/package.json +4 -4
package/lib/index.cjs
CHANGED
|
@@ -98,7 +98,7 @@ var AstCoreFactory = class {
|
|
|
98
98
|
if (filtered.length === 0) {
|
|
99
99
|
return this.gen();
|
|
100
100
|
}
|
|
101
|
-
const first2 = filtered
|
|
101
|
+
const first2 = filtered.at(0);
|
|
102
102
|
const last2 = filtered.at(-1);
|
|
103
103
|
return {
|
|
104
104
|
sourceLocationType: "source",
|
|
@@ -9525,21 +9525,31 @@ var LexerBuilder = class _LexerBuilder {
|
|
|
9525
9525
|
}
|
|
9526
9526
|
};
|
|
9527
9527
|
|
|
9528
|
-
// ../core/lib/
|
|
9529
|
-
var
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9528
|
+
// ../core/lib/TransformerObject.js
|
|
9529
|
+
var TransformerObject = class {
|
|
9530
|
+
defaultContext;
|
|
9531
|
+
maxStackSize = 1e6;
|
|
9532
|
+
/**
|
|
9533
|
+
* Creates stateless transformer.
|
|
9534
|
+
* @param defaultContext
|
|
9535
|
+
*/
|
|
9536
|
+
constructor(defaultContext = {}) {
|
|
9537
|
+
this.defaultContext = defaultContext;
|
|
9534
9538
|
}
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9539
|
+
/**
|
|
9540
|
+
* Function to shallow clone any type.
|
|
9541
|
+
* @param obj
|
|
9542
|
+
* @protected
|
|
9543
|
+
*/
|
|
9544
|
+
clone(obj) {
|
|
9545
|
+
if (obj === null || typeof obj !== "object") {
|
|
9546
|
+
return obj;
|
|
9541
9547
|
}
|
|
9542
|
-
|
|
9548
|
+
const proto = Object.getPrototypeOf(obj);
|
|
9549
|
+
if (proto === Object.prototype || proto === null) {
|
|
9550
|
+
return { ...obj };
|
|
9551
|
+
}
|
|
9552
|
+
return Object.assign(Object.create(proto), obj);
|
|
9543
9553
|
}
|
|
9544
9554
|
/**
|
|
9545
9555
|
* Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
|
|
@@ -9551,90 +9561,228 @@ var TransformerType = class {
|
|
|
9551
9561
|
* - Default false
|
|
9552
9562
|
*/
|
|
9553
9563
|
transformObject(startObject, mapper, preVisitor = () => ({})) {
|
|
9564
|
+
const defaults2 = this.defaultContext;
|
|
9565
|
+
const defaultCopyFlag = defaults2.copy ?? true;
|
|
9566
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9567
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9568
|
+
const defaultShallowKeys = defaults2.shallowKeys;
|
|
9569
|
+
const defaultDidShortCut = defaults2.shortcut ?? false;
|
|
9554
9570
|
let didShortCut = false;
|
|
9555
|
-
const
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9571
|
+
const resultWrap = { res: startObject };
|
|
9572
|
+
const stack = [startObject];
|
|
9573
|
+
const stackParent = [resultWrap];
|
|
9574
|
+
const stackParentKey = ["res"];
|
|
9575
|
+
const handleMapperOnLen = [];
|
|
9576
|
+
const mapperCopyStack = [];
|
|
9577
|
+
const mapperOrigStack = [];
|
|
9578
|
+
const mapperParent = [];
|
|
9579
|
+
const mapperParentKey = [];
|
|
9580
|
+
function handleMapper() {
|
|
9581
|
+
while (stack.length === handleMapperOnLen.at(-1)) {
|
|
9582
|
+
handleMapperOnLen.pop();
|
|
9583
|
+
const copyToMap = mapperCopyStack.pop();
|
|
9584
|
+
const origToMap = mapperOrigStack.pop();
|
|
9585
|
+
const parent = mapperParent.pop();
|
|
9586
|
+
const parentKey = mapperParentKey.pop();
|
|
9587
|
+
parent[parentKey] = mapper(copyToMap, origToMap);
|
|
9588
|
+
}
|
|
9589
|
+
}
|
|
9590
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9591
|
+
const curObject = stack.pop();
|
|
9592
|
+
const curParent = stackParent.pop();
|
|
9593
|
+
const curKey = stackParentKey.pop();
|
|
9594
|
+
if (!didShortCut) {
|
|
9595
|
+
if (Array.isArray(curObject)) {
|
|
9596
|
+
const newArr = [...curObject];
|
|
9597
|
+
handleMapperOnLen.push(stack.length);
|
|
9598
|
+
mapperCopyStack.push(newArr);
|
|
9599
|
+
mapperOrigStack.push(curObject);
|
|
9600
|
+
mapperParent.push(curParent);
|
|
9601
|
+
mapperParentKey.push(curKey);
|
|
9602
|
+
for (let index = curObject.length - 1; index >= 0; index--) {
|
|
9603
|
+
const val = curObject[index];
|
|
9604
|
+
if (val !== null && typeof val === "object") {
|
|
9605
|
+
stack.push(val);
|
|
9606
|
+
stackParent.push(newArr);
|
|
9607
|
+
stackParentKey.push(index.toString());
|
|
9608
|
+
}
|
|
9609
|
+
}
|
|
9610
|
+
handleMapper();
|
|
9611
|
+
continue;
|
|
9612
|
+
}
|
|
9613
|
+
const context = preVisitor(curObject);
|
|
9614
|
+
const copyFlag = context.copy ?? defaultCopyFlag;
|
|
9615
|
+
const continues = context.continue ?? defaultContinues;
|
|
9616
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9617
|
+
const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
|
|
9618
|
+
didShortCut = context.shortcut ?? defaultDidShortCut;
|
|
9619
|
+
const copy3 = copyFlag ? this.clone(curObject) : curObject;
|
|
9620
|
+
handleMapperOnLen.push(stack.length);
|
|
9621
|
+
mapperCopyStack.push(copy3);
|
|
9622
|
+
mapperOrigStack.push(curObject);
|
|
9623
|
+
mapperParent.push(curParent);
|
|
9624
|
+
mapperParentKey.push(curKey);
|
|
9625
|
+
if (continues && !didShortCut) {
|
|
9626
|
+
for (const key in copy3) {
|
|
9627
|
+
if (!Object.hasOwn(copy3, key)) {
|
|
9628
|
+
continue;
|
|
9629
|
+
}
|
|
9630
|
+
const val = copy3[key];
|
|
9631
|
+
const onlyShallow = shallowKeys && shallowKeys?.has(key);
|
|
9632
|
+
if (onlyShallow) {
|
|
9633
|
+
copy3[key] = this.clone(val);
|
|
9634
|
+
}
|
|
9635
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9636
|
+
continue;
|
|
9637
|
+
}
|
|
9638
|
+
if (!onlyShallow && val !== null && typeof val === "object") {
|
|
9639
|
+
stack.push(val);
|
|
9640
|
+
stackParentKey.push(key);
|
|
9641
|
+
stackParent.push(copy3);
|
|
9642
|
+
}
|
|
9564
9643
|
}
|
|
9565
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9566
9644
|
}
|
|
9567
9645
|
}
|
|
9568
|
-
|
|
9569
|
-
}
|
|
9570
|
-
|
|
9646
|
+
handleMapper();
|
|
9647
|
+
}
|
|
9648
|
+
if (stack.length >= this.maxStackSize) {
|
|
9649
|
+
throw new Error("Transform object stack overflowed");
|
|
9650
|
+
}
|
|
9651
|
+
handleMapper();
|
|
9652
|
+
return resultWrap.res;
|
|
9571
9653
|
}
|
|
9572
9654
|
/**
|
|
9573
9655
|
* Visitor that visits all objects. Visits deeper objects first.
|
|
9574
9656
|
*/
|
|
9575
9657
|
visitObject(startObject, visitor, preVisitor = () => ({})) {
|
|
9658
|
+
const defaults2 = this.defaultContext;
|
|
9659
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9660
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9661
|
+
const defaultShortcut = defaults2.shortcut ?? false;
|
|
9576
9662
|
let didShortCut = false;
|
|
9577
|
-
const
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9663
|
+
const stack = [startObject];
|
|
9664
|
+
const handleVisitorOnLen = [];
|
|
9665
|
+
const visitorStack = [];
|
|
9666
|
+
function handleVisitor() {
|
|
9667
|
+
while (stack.length === handleVisitorOnLen.at(-1)) {
|
|
9668
|
+
handleVisitorOnLen.pop();
|
|
9669
|
+
const toVisit = visitorStack.pop();
|
|
9670
|
+
visitor(toVisit);
|
|
9671
|
+
}
|
|
9672
|
+
}
|
|
9673
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9674
|
+
const curObject = stack.pop();
|
|
9675
|
+
if (!didShortCut) {
|
|
9676
|
+
if (Array.isArray(curObject)) {
|
|
9677
|
+
for (let i = curObject.length - 1; i >= 0; i--) {
|
|
9678
|
+
stack.push(curObject[i]);
|
|
9679
|
+
}
|
|
9680
|
+
handleVisitor();
|
|
9681
|
+
continue;
|
|
9682
|
+
}
|
|
9683
|
+
const context = preVisitor(curObject);
|
|
9684
|
+
didShortCut = context.shortcut ?? defaultShortcut;
|
|
9685
|
+
const continues = context.continue ?? defaultContinues;
|
|
9686
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9687
|
+
handleVisitorOnLen.push(stack.length);
|
|
9688
|
+
visitorStack.push(curObject);
|
|
9689
|
+
if (continues && !didShortCut) {
|
|
9690
|
+
for (const key in curObject) {
|
|
9691
|
+
if (!Object.hasOwn(curObject, key)) {
|
|
9692
|
+
continue;
|
|
9693
|
+
}
|
|
9694
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9695
|
+
continue;
|
|
9696
|
+
}
|
|
9697
|
+
const val = curObject[key];
|
|
9698
|
+
if (val && typeof val === "object") {
|
|
9699
|
+
stack.push(val);
|
|
9700
|
+
}
|
|
9585
9701
|
}
|
|
9586
|
-
this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9587
9702
|
}
|
|
9588
9703
|
}
|
|
9589
|
-
|
|
9590
|
-
}
|
|
9591
|
-
|
|
9704
|
+
handleVisitor();
|
|
9705
|
+
}
|
|
9706
|
+
if (stack.length >= this.maxStackSize) {
|
|
9707
|
+
throw new Error("Transform object stack overflowed");
|
|
9708
|
+
}
|
|
9709
|
+
handleVisitor();
|
|
9592
9710
|
}
|
|
9711
|
+
};
|
|
9712
|
+
|
|
9713
|
+
// ../core/lib/TransformerTyped.js
|
|
9714
|
+
var TransformerTyped = class extends TransformerObject {
|
|
9715
|
+
defaultNodePreVisitor;
|
|
9716
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9717
|
+
super(defaultContext);
|
|
9718
|
+
this.defaultNodePreVisitor = defaultNodePreVisitor;
|
|
9719
|
+
}
|
|
9720
|
+
/**
|
|
9721
|
+
* Transform a single node.
|
|
9722
|
+
* The transformation calls the preVisitor from starting from the startObject.
|
|
9723
|
+
* The preVisitor can dictate whether transformation should be stopped.
|
|
9724
|
+
* Note that stopping the transformation also prevets further copying.
|
|
9725
|
+
* The transformer itself transforms object starting with the deepest one that can be visited.
|
|
9726
|
+
* The transformer callback is performed on a copy of the original.
|
|
9727
|
+
* @param startObject
|
|
9728
|
+
* @param nodeCallBacks
|
|
9729
|
+
*/
|
|
9593
9730
|
transformNode(startObject, nodeCallBacks) {
|
|
9594
|
-
const transformWrapper = (
|
|
9595
|
-
|
|
9731
|
+
const transformWrapper = (copy3, orig) => {
|
|
9732
|
+
let ogTransform;
|
|
9733
|
+
const casted = copy3;
|
|
9596
9734
|
if (casted.type) {
|
|
9597
|
-
|
|
9598
|
-
if (ogFunc) {
|
|
9599
|
-
return ogFunc(casted);
|
|
9600
|
-
}
|
|
9735
|
+
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9601
9736
|
}
|
|
9602
|
-
return
|
|
9737
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9603
9738
|
};
|
|
9604
|
-
const
|
|
9739
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9740
|
+
const preVisitWrapper = (curObject) => {
|
|
9741
|
+
let ogPreVisit;
|
|
9742
|
+
let nodeContext = {};
|
|
9605
9743
|
const casted = curObject;
|
|
9606
9744
|
if (casted.type) {
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
return ogFunc(casted);
|
|
9610
|
-
}
|
|
9745
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9746
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9611
9747
|
}
|
|
9612
|
-
return {};
|
|
9748
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9613
9749
|
};
|
|
9614
|
-
return this.transformObject(startObject, transformWrapper,
|
|
9750
|
+
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9615
9751
|
}
|
|
9752
|
+
/**
|
|
9753
|
+
* Similar to {@link this.transformNode}, but without copying the startObject.
|
|
9754
|
+
* The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
|
|
9755
|
+
* @param startObject
|
|
9756
|
+
* @param nodeCallBacks
|
|
9757
|
+
*/
|
|
9616
9758
|
visitNode(startObject, nodeCallBacks) {
|
|
9617
|
-
const
|
|
9759
|
+
const visitorWrapper = (curObject) => {
|
|
9618
9760
|
const casted = curObject;
|
|
9619
9761
|
if (casted.type) {
|
|
9620
|
-
const
|
|
9621
|
-
if (
|
|
9622
|
-
|
|
9762
|
+
const ogTransform = nodeCallBacks[casted.type]?.visitor;
|
|
9763
|
+
if (ogTransform) {
|
|
9764
|
+
ogTransform(casted);
|
|
9623
9765
|
}
|
|
9624
9766
|
}
|
|
9625
9767
|
};
|
|
9768
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9626
9769
|
const preVisitWrapper = (curObject) => {
|
|
9770
|
+
let ogPreVisit;
|
|
9771
|
+
let nodeContext = {};
|
|
9627
9772
|
const casted = curObject;
|
|
9628
9773
|
if (casted.type) {
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
return ogFunc(casted);
|
|
9632
|
-
}
|
|
9774
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9775
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9633
9776
|
}
|
|
9634
|
-
return {};
|
|
9777
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9635
9778
|
};
|
|
9636
|
-
this.visitObject(startObject,
|
|
9779
|
+
return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
|
|
9637
9780
|
}
|
|
9781
|
+
/**
|
|
9782
|
+
* Traverses only selected nodes as returned by the function.
|
|
9783
|
+
* @param currentNode
|
|
9784
|
+
* @param traverse
|
|
9785
|
+
*/
|
|
9638
9786
|
traverseNodes(currentNode, traverse) {
|
|
9639
9787
|
let didShortCut = false;
|
|
9640
9788
|
const recurse = (curNode) => {
|
|
@@ -9655,11 +9803,24 @@ var TransformerType = class {
|
|
|
9655
9803
|
recurse(currentNode);
|
|
9656
9804
|
}
|
|
9657
9805
|
};
|
|
9658
|
-
|
|
9806
|
+
|
|
9807
|
+
// ../core/lib/TransformerSubTyped.js
|
|
9808
|
+
var TransformerSubTyped = class extends TransformerTyped {
|
|
9809
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9810
|
+
super(defaultContext, defaultNodePreVisitor);
|
|
9811
|
+
}
|
|
9812
|
+
/**
|
|
9813
|
+
* Shares the functionality and first two arguments with {@link this.transformNode}.
|
|
9814
|
+
* The third argument allows you to also transform based on the subType of objects.
|
|
9815
|
+
* Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
|
|
9816
|
+
* @param startObject
|
|
9817
|
+
* @param nodeCallBacks
|
|
9818
|
+
* @param nodeSpecificCallBacks
|
|
9819
|
+
*/
|
|
9659
9820
|
transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9660
|
-
const transformWrapper = (
|
|
9821
|
+
const transformWrapper = (copy3, orig) => {
|
|
9661
9822
|
let ogTransform;
|
|
9662
|
-
const casted =
|
|
9823
|
+
const casted = copy3;
|
|
9663
9824
|
if (casted.type && casted.subType) {
|
|
9664
9825
|
const specific = nodeSpecificCallBacks[casted.type];
|
|
9665
9826
|
if (specific) {
|
|
@@ -9669,7 +9830,7 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9669
9830
|
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9670
9831
|
}
|
|
9671
9832
|
}
|
|
9672
|
-
return ogTransform ? ogTransform(casted) :
|
|
9833
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9673
9834
|
};
|
|
9674
9835
|
const preVisitWrapper = (curObject) => {
|
|
9675
9836
|
let ogPreVisit;
|
|
@@ -9683,12 +9844,13 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9683
9844
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9684
9845
|
}
|
|
9685
9846
|
}
|
|
9686
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
9847
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9687
9848
|
};
|
|
9688
9849
|
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9689
9850
|
}
|
|
9690
9851
|
/**
|
|
9691
|
-
*
|
|
9852
|
+
* Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
|
|
9853
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
|
|
9692
9854
|
*/
|
|
9693
9855
|
visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9694
9856
|
const visitWrapper = (curObject) => {
|
|
@@ -9719,10 +9881,16 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9719
9881
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9720
9882
|
}
|
|
9721
9883
|
}
|
|
9722
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
9884
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9723
9885
|
};
|
|
9724
9886
|
this.visitObject(startObject, visitWrapper, preVisitWrapper);
|
|
9725
9887
|
}
|
|
9888
|
+
/**
|
|
9889
|
+
* Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
|
|
9890
|
+
* @param currentNode
|
|
9891
|
+
* @param traverseNode
|
|
9892
|
+
* @param traverseSubNode
|
|
9893
|
+
*/
|
|
9726
9894
|
traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
|
|
9727
9895
|
let didShortCut = false;
|
|
9728
9896
|
const recurse = (curNode) => {
|
|
@@ -10795,8 +10963,8 @@ function PatternFactoryMixin(Base) {
|
|
|
10795
10963
|
isPatternOptional(obj) {
|
|
10796
10964
|
return this.isOfSubType(obj, nodeType5, "optional");
|
|
10797
10965
|
}
|
|
10798
|
-
patternValues(values3, loc) {
|
|
10799
|
-
return { type: nodeType5, subType: "values", values: values3, loc };
|
|
10966
|
+
patternValues(variables, values3, loc) {
|
|
10967
|
+
return { type: nodeType5, subType: "values", variables, values: values3, loc };
|
|
10800
10968
|
}
|
|
10801
10969
|
isPatternValues(obj) {
|
|
10802
10970
|
return this.isOfSubType(obj, nodeType5, "values");
|
|
@@ -10971,7 +11139,7 @@ function TermFactoryMixin(Base) {
|
|
|
10971
11139
|
isTerm(x) {
|
|
10972
11140
|
return this.isOfType(x, "term");
|
|
10973
11141
|
}
|
|
10974
|
-
|
|
11142
|
+
termBlank(label, loc) {
|
|
10975
11143
|
const base = {
|
|
10976
11144
|
type: "term",
|
|
10977
11145
|
subType: "blankNode",
|
|
@@ -10985,7 +11153,7 @@ function TermFactoryMixin(Base) {
|
|
|
10985
11153
|
isTermBlank(obj) {
|
|
10986
11154
|
return this.isOfSubType(obj, nodeType8, "blankNode");
|
|
10987
11155
|
}
|
|
10988
|
-
|
|
11156
|
+
termLiteral(loc, value, langOrIri) {
|
|
10989
11157
|
return {
|
|
10990
11158
|
type: nodeType8,
|
|
10991
11159
|
subType: "literal",
|
|
@@ -11007,7 +11175,7 @@ function TermFactoryMixin(Base) {
|
|
|
11007
11175
|
const casted = obj;
|
|
11008
11176
|
return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
|
|
11009
11177
|
}
|
|
11010
|
-
|
|
11178
|
+
termVariable(value, loc) {
|
|
11011
11179
|
return {
|
|
11012
11180
|
type: nodeType8,
|
|
11013
11181
|
subType: "variable",
|
|
@@ -11018,7 +11186,7 @@ function TermFactoryMixin(Base) {
|
|
|
11018
11186
|
isTermVariable(obj) {
|
|
11019
11187
|
return this.isOfSubType(obj, nodeType8, "variable");
|
|
11020
11188
|
}
|
|
11021
|
-
|
|
11189
|
+
termNamed(loc, value, prefix) {
|
|
11022
11190
|
const base = {
|
|
11023
11191
|
type: nodeType8,
|
|
11024
11192
|
subType: "namedNode",
|
|
@@ -11263,7 +11431,7 @@ var CommonIRIs;
|
|
|
11263
11431
|
CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
11264
11432
|
CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
11265
11433
|
})(CommonIRIs || (CommonIRIs = {}));
|
|
11266
|
-
var AstTransformer = class extends
|
|
11434
|
+
var AstTransformer = class extends TransformerSubTyped {
|
|
11267
11435
|
};
|
|
11268
11436
|
|
|
11269
11437
|
// ../rules-sparql-1-1/lib/validation/validators.js
|
|
@@ -11479,17 +11647,20 @@ var rdfLiteral = {
|
|
|
11479
11647
|
return OPTION(() => OR([
|
|
11480
11648
|
{ ALT: () => {
|
|
11481
11649
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11482
|
-
return ACTION(() => C.astFactory.
|
|
11650
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11483
11651
|
} },
|
|
11484
11652
|
{ ALT: () => {
|
|
11485
11653
|
CONSUME(symbols_exports.hathat);
|
|
11486
11654
|
const iriVal = SUBRULE1(iri2);
|
|
11487
|
-
return ACTION(() => C.astFactory.
|
|
11655
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11488
11656
|
} }
|
|
11489
11657
|
])) ?? value;
|
|
11490
11658
|
},
|
|
11491
|
-
gImpl: ({ SUBRULE, PRINT,
|
|
11492
|
-
astFactory.printFilter(ast, () =>
|
|
11659
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11660
|
+
astFactory.printFilter(ast, () => {
|
|
11661
|
+
PRINT_WORD("");
|
|
11662
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
11663
|
+
});
|
|
11493
11664
|
if (ast.langOrIri) {
|
|
11494
11665
|
if (typeof ast.langOrIri === "string") {
|
|
11495
11666
|
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
@@ -11516,7 +11687,7 @@ var numericLiteralUnsigned = {
|
|
|
11516
11687
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11517
11688
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11518
11689
|
]);
|
|
11519
|
-
return ACTION(() => C.astFactory.
|
|
11690
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11520
11691
|
}
|
|
11521
11692
|
};
|
|
11522
11693
|
var numericLiteralPositive = {
|
|
@@ -11527,7 +11698,7 @@ var numericLiteralPositive = {
|
|
|
11527
11698
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11528
11699
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11529
11700
|
]);
|
|
11530
|
-
return ACTION(() => C.astFactory.
|
|
11701
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11531
11702
|
}
|
|
11532
11703
|
};
|
|
11533
11704
|
var numericLiteralNegative = {
|
|
@@ -11538,7 +11709,7 @@ var numericLiteralNegative = {
|
|
|
11538
11709
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11539
11710
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11540
11711
|
]);
|
|
11541
|
-
return ACTION(() => C.astFactory.
|
|
11712
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11542
11713
|
}
|
|
11543
11714
|
};
|
|
11544
11715
|
var booleanLiteral = {
|
|
@@ -11548,7 +11719,7 @@ var booleanLiteral = {
|
|
|
11548
11719
|
{ ALT: () => CONSUME(true_) },
|
|
11549
11720
|
{ ALT: () => CONSUME(false_) }
|
|
11550
11721
|
]);
|
|
11551
|
-
return ACTION(() => C.astFactory.
|
|
11722
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11552
11723
|
}
|
|
11553
11724
|
};
|
|
11554
11725
|
var string = {
|
|
@@ -11590,7 +11761,7 @@ var string = {
|
|
|
11590
11761
|
return char;
|
|
11591
11762
|
}
|
|
11592
11763
|
});
|
|
11593
|
-
return F3.
|
|
11764
|
+
return F3.termLiteral(F3.sourceLocation(x[0]), value);
|
|
11594
11765
|
});
|
|
11595
11766
|
}
|
|
11596
11767
|
};
|
|
@@ -11606,7 +11777,7 @@ var iriFull = {
|
|
|
11606
11777
|
name: "iriFull",
|
|
11607
11778
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11608
11779
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11609
|
-
return ACTION(() => C.astFactory.
|
|
11780
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11610
11781
|
},
|
|
11611
11782
|
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11612
11783
|
F3.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
@@ -11619,16 +11790,16 @@ var prefixedName = {
|
|
|
11619
11790
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11620
11791
|
return ACTION(() => {
|
|
11621
11792
|
const [prefix, localName] = longName.image.split(":");
|
|
11622
|
-
return C.astFactory.
|
|
11793
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11623
11794
|
});
|
|
11624
11795
|
} },
|
|
11625
11796
|
{ ALT: () => {
|
|
11626
11797
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11627
|
-
return ACTION(() => C.astFactory.
|
|
11798
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11628
11799
|
} }
|
|
11629
11800
|
]),
|
|
11630
|
-
gImpl: ({
|
|
11631
|
-
F3.printFilter(ast, () =>
|
|
11801
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11802
|
+
F3.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
11632
11803
|
}
|
|
11633
11804
|
};
|
|
11634
11805
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11638,11 +11809,11 @@ var blankNode = {
|
|
|
11638
11809
|
const result = OR([
|
|
11639
11810
|
{ ALT: () => {
|
|
11640
11811
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11641
|
-
return ACTION(() => C.astFactory.
|
|
11812
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11642
11813
|
} },
|
|
11643
11814
|
{ ALT: () => {
|
|
11644
11815
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11645
|
-
return ACTION(() => C.astFactory.
|
|
11816
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11646
11817
|
} }
|
|
11647
11818
|
]);
|
|
11648
11819
|
ACTION(() => {
|
|
@@ -11652,15 +11823,15 @@ var blankNode = {
|
|
|
11652
11823
|
});
|
|
11653
11824
|
return result;
|
|
11654
11825
|
},
|
|
11655
|
-
gImpl: ({
|
|
11656
|
-
astFactory.printFilter(ast, () =>
|
|
11826
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
11827
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
11657
11828
|
}
|
|
11658
11829
|
};
|
|
11659
11830
|
var verbA = {
|
|
11660
11831
|
name: "VerbA",
|
|
11661
11832
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11662
11833
|
const token = CONSUME(a);
|
|
11663
|
-
return ACTION(() => C.astFactory.
|
|
11834
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11664
11835
|
}
|
|
11665
11836
|
};
|
|
11666
11837
|
|
|
@@ -11694,10 +11865,10 @@ var baseDecl2 = {
|
|
|
11694
11865
|
const val = SUBRULE(iriFull);
|
|
11695
11866
|
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11696
11867
|
},
|
|
11697
|
-
gImpl: ({ SUBRULE,
|
|
11698
|
-
F3.printFilter(ast, () =>
|
|
11868
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
11869
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
|
|
11699
11870
|
SUBRULE(iri2, ast.value);
|
|
11700
|
-
F3.printFilter(ast, () =>
|
|
11871
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11701
11872
|
}
|
|
11702
11873
|
};
|
|
11703
11874
|
var prefixDecl2 = {
|
|
@@ -11708,12 +11879,12 @@ var prefixDecl2 = {
|
|
|
11708
11879
|
const value = SUBRULE(iriFull);
|
|
11709
11880
|
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11710
11881
|
},
|
|
11711
|
-
gImpl: ({ SUBRULE,
|
|
11882
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
11712
11883
|
F3.printFilter(ast, () => {
|
|
11713
|
-
|
|
11884
|
+
PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
|
|
11714
11885
|
});
|
|
11715
11886
|
SUBRULE(iri2, ast.value);
|
|
11716
|
-
F3.printFilter(ast, () =>
|
|
11887
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11717
11888
|
}
|
|
11718
11889
|
};
|
|
11719
11890
|
var verb = {
|
|
@@ -11750,10 +11921,10 @@ var var_ = {
|
|
|
11750
11921
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11751
11922
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11752
11923
|
]);
|
|
11753
|
-
return ACTION(() => C.astFactory.
|
|
11924
|
+
return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11754
11925
|
},
|
|
11755
|
-
gImpl: ({
|
|
11756
|
-
F3.printFilter(ast, () =>
|
|
11926
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11927
|
+
F3.printFilter(ast, () => PRINT(`?${ast.value}`));
|
|
11757
11928
|
}
|
|
11758
11929
|
};
|
|
11759
11930
|
var graphTerm = {
|
|
@@ -11766,7 +11937,7 @@ var graphTerm = {
|
|
|
11766
11937
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
11767
11938
|
{ ALT: () => {
|
|
11768
11939
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
11769
|
-
return ACTION(() => C.astFactory.
|
|
11940
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
11770
11941
|
} }
|
|
11771
11942
|
]),
|
|
11772
11943
|
gImpl: ({ SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
@@ -12396,13 +12567,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12396
12567
|
var triplesBlock = {
|
|
12397
12568
|
name: "triplesBlock",
|
|
12398
12569
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12399
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
12570
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12400
12571
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12401
12572
|
HANDLE_LOC(triple, () => {
|
|
12402
12573
|
const nextTriple = ast.triples.at(index);
|
|
12403
12574
|
if (F3.isTripleCollection(triple)) {
|
|
12404
12575
|
SUBRULE(graphNodePath, triple);
|
|
12405
|
-
F3.printFilter(triple, () =>
|
|
12576
|
+
F3.printFilter(triple, () => {
|
|
12577
|
+
PRINT_WORD(".");
|
|
12578
|
+
NEW_LINE();
|
|
12579
|
+
});
|
|
12406
12580
|
} else {
|
|
12407
12581
|
SUBRULE(graphNodePath, triple.subject);
|
|
12408
12582
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
@@ -12414,11 +12588,17 @@ var triplesBlock = {
|
|
|
12414
12588
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12415
12589
|
SUBRULE(graphNodePath, triple.object);
|
|
12416
12590
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12417
|
-
F3.printFilter(ast, () =>
|
|
12591
|
+
F3.printFilter(ast, () => {
|
|
12592
|
+
PRINT_WORD(".");
|
|
12593
|
+
NEW_LINE();
|
|
12594
|
+
});
|
|
12418
12595
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12419
12596
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
12420
12597
|
} else {
|
|
12421
|
-
F3.printFilter(ast, () =>
|
|
12598
|
+
F3.printFilter(ast, () => {
|
|
12599
|
+
PRINT_WORD(";");
|
|
12600
|
+
NEW_LINE();
|
|
12601
|
+
});
|
|
12422
12602
|
}
|
|
12423
12603
|
}
|
|
12424
12604
|
});
|
|
@@ -12551,10 +12731,10 @@ function collectionImpl(name, allowPaths) {
|
|
|
12551
12731
|
return ACTION(() => {
|
|
12552
12732
|
const F3 = C.astFactory;
|
|
12553
12733
|
const triples = [];
|
|
12554
|
-
const predFirst = F3.
|
|
12555
|
-
const predRest = F3.
|
|
12556
|
-
const predNil = F3.
|
|
12557
|
-
const listHead = F3.
|
|
12734
|
+
const predFirst = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12735
|
+
const predRest = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
12736
|
+
const predNil = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
|
|
12737
|
+
const listHead = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12558
12738
|
let iterHead = listHead;
|
|
12559
12739
|
for (const [index, term] of terms.entries()) {
|
|
12560
12740
|
const lastInList = index === terms.length - 1;
|
|
@@ -12564,7 +12744,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12564
12744
|
const nilTriple = F3.triple(iterHead, predRest, predNil);
|
|
12565
12745
|
triples.push(nilTriple);
|
|
12566
12746
|
} else {
|
|
12567
|
-
const tail = F3.
|
|
12747
|
+
const tail = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12568
12748
|
const linkTriple = F3.triple(iterHead, predRest, tail);
|
|
12569
12749
|
triples.push(linkTriple);
|
|
12570
12750
|
iterHead = tail;
|
|
@@ -12604,16 +12784,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12604
12784
|
name,
|
|
12605
12785
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12606
12786
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12607
|
-
const blankNode2 = ACTION(() => C.astFactory.
|
|
12787
|
+
const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12608
12788
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12609
12789
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12610
12790
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12611
12791
|
},
|
|
12612
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
12792
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
12613
12793
|
const { astFactory: F3, indentInc } = c;
|
|
12614
12794
|
F3.printFilter(ast, () => {
|
|
12615
12795
|
c[traqulaIndentation] += indentInc;
|
|
12616
|
-
PRINT("[
|
|
12796
|
+
PRINT("[");
|
|
12797
|
+
NEW_LINE();
|
|
12617
12798
|
});
|
|
12618
12799
|
for (const triple of ast.triples) {
|
|
12619
12800
|
HANDLE_LOC(triple, () => {
|
|
@@ -12624,7 +12805,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12624
12805
|
}
|
|
12625
12806
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12626
12807
|
SUBRULE(graphNodePath, triple.object);
|
|
12627
|
-
F3.printFilter(ast, () =>
|
|
12808
|
+
F3.printFilter(ast, () => {
|
|
12809
|
+
PRINT_WORD(";");
|
|
12810
|
+
NEW_LINE();
|
|
12811
|
+
});
|
|
12628
12812
|
});
|
|
12629
12813
|
}
|
|
12630
12814
|
F3.printFilter(ast, () => {
|
|
@@ -12683,18 +12867,19 @@ var groupGraphPattern = {
|
|
|
12683
12867
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12684
12868
|
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12685
12869
|
},
|
|
12686
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
12870
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12687
12871
|
const { astFactory: F3, indentInc } = C;
|
|
12688
12872
|
F3.printFilter(ast, () => {
|
|
12689
12873
|
C[traqulaIndentation] += indentInc;
|
|
12690
|
-
PRINT_WORD("{
|
|
12874
|
+
PRINT_WORD("{");
|
|
12875
|
+
NEW_LINE();
|
|
12691
12876
|
});
|
|
12692
12877
|
for (const pattern of ast.patterns) {
|
|
12693
12878
|
SUBRULE(generatePattern, pattern);
|
|
12694
12879
|
}
|
|
12695
12880
|
F3.printFilter(ast, () => {
|
|
12696
12881
|
C[traqulaIndentation] -= indentInc;
|
|
12697
|
-
|
|
12882
|
+
PRINT_ON_OWN_LINE("}");
|
|
12698
12883
|
});
|
|
12699
12884
|
}
|
|
12700
12885
|
};
|
|
@@ -12844,12 +13029,15 @@ var bind2 = {
|
|
|
12844
13029
|
const close = CONSUME(symbols_exports.RParen);
|
|
12845
13030
|
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
12846
13031
|
},
|
|
12847
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13032
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12848
13033
|
F3.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
12849
13034
|
SUBRULE(expression, ast.expression);
|
|
12850
13035
|
F3.printFilter(ast, () => PRINT_WORD("AS"));
|
|
12851
13036
|
SUBRULE(var_, ast.variable);
|
|
12852
|
-
F3.printFilter(ast, () =>
|
|
13037
|
+
F3.printFilter(ast, () => {
|
|
13038
|
+
PRINT_WORD(")");
|
|
13039
|
+
NEW_LINE();
|
|
13040
|
+
});
|
|
12853
13041
|
}
|
|
12854
13042
|
};
|
|
12855
13043
|
var inlineData = {
|
|
@@ -12857,34 +13045,46 @@ var inlineData = {
|
|
|
12857
13045
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12858
13046
|
const values3 = CONSUME(values2);
|
|
12859
13047
|
const datablock = SUBRULE(dataBlock);
|
|
12860
|
-
return ACTION(() =>
|
|
13048
|
+
return ACTION(() => {
|
|
13049
|
+
datablock.loc = C.astFactory.sourceLocation(values3, datablock);
|
|
13050
|
+
return datablock;
|
|
13051
|
+
});
|
|
12861
13052
|
},
|
|
12862
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13053
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12863
13054
|
const { astFactory: F3, indentInc } = C;
|
|
12864
|
-
const variables =
|
|
13055
|
+
const variables = ast.variables;
|
|
13056
|
+
const singleVar = variables.length === 1;
|
|
13057
|
+
F3.printFilter(ast, () => {
|
|
13058
|
+
PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
|
|
13059
|
+
});
|
|
13060
|
+
for (const variable of variables) {
|
|
13061
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13062
|
+
SUBRULE(varOrTerm, variable);
|
|
13063
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13064
|
+
}
|
|
12865
13065
|
F3.printFilter(ast, () => {
|
|
12866
|
-
PRINT_ON_EMPTY("");
|
|
12867
|
-
PRINT_WORD("VALUES", "(");
|
|
12868
|
-
for (const variable of variables) {
|
|
12869
|
-
PRINT_WORD(`?${variable}`);
|
|
12870
|
-
}
|
|
12871
13066
|
C[traqulaIndentation] += indentInc;
|
|
12872
|
-
PRINT_WORD(")", "{
|
|
13067
|
+
PRINT_WORD(singleVar ? "" : ")", "{");
|
|
13068
|
+
NEW_LINE();
|
|
12873
13069
|
});
|
|
12874
13070
|
for (const mapping of ast.values) {
|
|
12875
|
-
F3.printFilter(ast, () => PRINT_WORD("("));
|
|
13071
|
+
F3.printFilter(ast, () => !singleVar && PRINT_WORD("("));
|
|
12876
13072
|
for (const variable of variables) {
|
|
12877
|
-
|
|
13073
|
+
const var_2 = variable.value;
|
|
13074
|
+
if (mapping[var_2] === void 0) {
|
|
12878
13075
|
F3.printFilter(ast, () => PRINT_WORD("UNDEF"));
|
|
12879
13076
|
} else {
|
|
12880
|
-
SUBRULE(graphNodePath, mapping[
|
|
13077
|
+
SUBRULE(graphNodePath, mapping[var_2]);
|
|
12881
13078
|
}
|
|
12882
13079
|
}
|
|
12883
|
-
F3.printFilter(ast, () =>
|
|
13080
|
+
F3.printFilter(ast, () => {
|
|
13081
|
+
PRINT_WORD(singleVar ? "" : ")");
|
|
13082
|
+
NEW_LINE();
|
|
13083
|
+
});
|
|
12884
13084
|
}
|
|
12885
13085
|
F3.printFilter(ast, () => {
|
|
12886
13086
|
C[traqulaIndentation] -= indentInc;
|
|
12887
|
-
|
|
13087
|
+
PRINT_ON_OWN_LINE("}");
|
|
12888
13088
|
});
|
|
12889
13089
|
}
|
|
12890
13090
|
};
|
|
@@ -12908,7 +13108,7 @@ var inlineDataOneVar = {
|
|
|
12908
13108
|
});
|
|
12909
13109
|
});
|
|
12910
13110
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12911
|
-
return ACTION(() => C.astFactory.
|
|
13111
|
+
return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
|
|
12912
13112
|
}
|
|
12913
13113
|
};
|
|
12914
13114
|
var inlineDataFull = {
|
|
@@ -12925,7 +13125,7 @@ var inlineDataFull = {
|
|
|
12925
13125
|
res.push({});
|
|
12926
13126
|
});
|
|
12927
13127
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
12928
|
-
return ACTION(() => C.astFactory.
|
|
13128
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
|
|
12929
13129
|
} },
|
|
12930
13130
|
{ ALT: () => {
|
|
12931
13131
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -12957,7 +13157,7 @@ var inlineDataFull = {
|
|
|
12957
13157
|
});
|
|
12958
13158
|
});
|
|
12959
13159
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
12960
|
-
return ACTION(() => C.astFactory.
|
|
13160
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
|
|
12961
13161
|
} }
|
|
12962
13162
|
]);
|
|
12963
13163
|
}
|
|
@@ -13020,10 +13220,13 @@ var filter3 = {
|
|
|
13020
13220
|
const expression2 = SUBRULE(constraint);
|
|
13021
13221
|
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
13022
13222
|
},
|
|
13023
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13223
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13024
13224
|
F3.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
13025
13225
|
SUBRULE(expression, ast.expression);
|
|
13026
|
-
F3.printFilter(ast, () =>
|
|
13226
|
+
F3.printFilter(ast, () => {
|
|
13227
|
+
PRINT_WORD(")");
|
|
13228
|
+
NEW_LINE();
|
|
13229
|
+
});
|
|
13027
13230
|
}
|
|
13028
13231
|
};
|
|
13029
13232
|
var constraint = {
|
|
@@ -13409,8 +13612,7 @@ var groupClause = {
|
|
|
13409
13612
|
},
|
|
13410
13613
|
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13411
13614
|
F3.printFilter(ast, () => {
|
|
13412
|
-
PRINT_ON_EMPTY("");
|
|
13413
|
-
PRINT_WORDS("GROUP", "BY");
|
|
13615
|
+
PRINT_ON_EMPTY("GROUP BY ");
|
|
13414
13616
|
});
|
|
13415
13617
|
for (const grouping of ast.groupings) {
|
|
13416
13618
|
if (F3.isExpression(grouping)) {
|
|
@@ -13466,10 +13668,9 @@ var havingClause = {
|
|
|
13466
13668
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13467
13669
|
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13468
13670
|
},
|
|
13469
|
-
gImpl: ({
|
|
13671
|
+
gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13470
13672
|
F3.printFilter(ast, () => {
|
|
13471
|
-
PRINT_ON_EMPTY("");
|
|
13472
|
-
PRINT_WORD("HAVING");
|
|
13673
|
+
PRINT_ON_EMPTY("HAVING ");
|
|
13473
13674
|
});
|
|
13474
13675
|
for (const having2 of ast.having) {
|
|
13475
13676
|
SUBRULE(expression, having2);
|
|
@@ -13495,8 +13696,7 @@ var orderClause = {
|
|
|
13495
13696
|
},
|
|
13496
13697
|
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13497
13698
|
F3.printFilter(ast, () => {
|
|
13498
|
-
PRINT_ON_EMPTY("");
|
|
13499
|
-
PRINT_WORDS("ORDER", "BY");
|
|
13699
|
+
PRINT_ON_EMPTY("ORDER BY ");
|
|
13500
13700
|
});
|
|
13501
13701
|
for (const ordering of ast.orderDefs) {
|
|
13502
13702
|
if (ordering.descending) {
|
|
@@ -13555,9 +13755,9 @@ var limitOffsetClauses = {
|
|
|
13555
13755
|
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13556
13756
|
} }
|
|
13557
13757
|
]),
|
|
13558
|
-
gImpl: ({ PRINT_WORDS,
|
|
13758
|
+
gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13559
13759
|
F3.printFilter(ast, () => {
|
|
13560
|
-
|
|
13760
|
+
NEW_LINE();
|
|
13561
13761
|
if (ast.limit) {
|
|
13562
13762
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13563
13763
|
}
|
|
@@ -13742,9 +13942,9 @@ var selectClause = {
|
|
|
13742
13942
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13743
13943
|
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13744
13944
|
},
|
|
13745
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13945
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13746
13946
|
F3.printFilter(ast, () => {
|
|
13747
|
-
|
|
13947
|
+
PRINT_ON_EMPTY("SELECT ");
|
|
13748
13948
|
if (ast.val.distinct) {
|
|
13749
13949
|
PRINT_WORD("DISTINCT");
|
|
13750
13950
|
} else if (ast.val.reduced) {
|
|
@@ -13763,7 +13963,9 @@ var selectClause = {
|
|
|
13763
13963
|
SUBRULE(var_, variable.variable);
|
|
13764
13964
|
F3.printFilter(ast, () => PRINT_WORD(")"));
|
|
13765
13965
|
}
|
|
13966
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13766
13967
|
}
|
|
13968
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13767
13969
|
}
|
|
13768
13970
|
};
|
|
13769
13971
|
var constructQuery = {
|
|
@@ -13801,18 +14003,19 @@ var constructQuery = {
|
|
|
13801
14003
|
} }
|
|
13802
14004
|
]);
|
|
13803
14005
|
},
|
|
13804
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14006
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
13805
14007
|
const { astFactory: F3, indentInc } = C;
|
|
13806
|
-
F3.printFilter(ast, () =>
|
|
14008
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
|
|
13807
14009
|
if (!F3.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
13808
14010
|
F3.printFilter(ast, () => {
|
|
13809
14011
|
C[traqulaIndentation] += indentInc;
|
|
13810
|
-
PRINT_WORD("{
|
|
14012
|
+
PRINT_WORD("{");
|
|
14013
|
+
NEW_LINE();
|
|
13811
14014
|
});
|
|
13812
14015
|
SUBRULE(triplesBlock, ast.template);
|
|
13813
14016
|
F3.printFilter(ast, () => {
|
|
13814
14017
|
C[traqulaIndentation] -= indentInc;
|
|
13815
|
-
|
|
14018
|
+
PRINT_ON_OWN_LINE("}");
|
|
13816
14019
|
});
|
|
13817
14020
|
}
|
|
13818
14021
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
@@ -13853,8 +14056,8 @@ var describeQuery = {
|
|
|
13853
14056
|
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13854
14057
|
}));
|
|
13855
14058
|
},
|
|
13856
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13857
|
-
F3.printFilter(ast, () =>
|
|
14059
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14060
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
|
|
13858
14061
|
if (F3.isWildcard(ast.variables[0])) {
|
|
13859
14062
|
F3.printFilter(ast, () => PRINT_WORD("*"));
|
|
13860
14063
|
} else {
|
|
@@ -13884,8 +14087,8 @@ var askQuery = {
|
|
|
13884
14087
|
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13885
14088
|
}));
|
|
13886
14089
|
},
|
|
13887
|
-
gImpl: ({ SUBRULE,
|
|
13888
|
-
F3.printFilter(ast, () =>
|
|
14090
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14091
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
|
|
13889
14092
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
13890
14093
|
SUBRULE(whereClause, F3.wrap(ast.where, ast.loc));
|
|
13891
14094
|
SUBRULE(solutionModifier, ast.solutionModifiers);
|
|
@@ -13944,7 +14147,7 @@ var update = {
|
|
|
13944
14147
|
return update2;
|
|
13945
14148
|
});
|
|
13946
14149
|
},
|
|
13947
|
-
gImpl: ({ SUBRULE,
|
|
14150
|
+
gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13948
14151
|
const [head2, ...tail] = ast.updates;
|
|
13949
14152
|
if (head2) {
|
|
13950
14153
|
SUBRULE(prologue, head2.context);
|
|
@@ -13953,7 +14156,10 @@ var update = {
|
|
|
13953
14156
|
}
|
|
13954
14157
|
}
|
|
13955
14158
|
for (const update2 of tail) {
|
|
13956
|
-
F3.printFilter(ast, () =>
|
|
14159
|
+
F3.printFilter(ast, () => {
|
|
14160
|
+
PRINT(";");
|
|
14161
|
+
NEW_LINE();
|
|
14162
|
+
});
|
|
13957
14163
|
SUBRULE(prologue, update2.context);
|
|
13958
14164
|
if (update2.operation) {
|
|
13959
14165
|
SUBRULE(update1, update2.operation);
|
|
@@ -14026,9 +14232,9 @@ var load2 = {
|
|
|
14026
14232
|
});
|
|
14027
14233
|
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
14028
14234
|
},
|
|
14029
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14235
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14030
14236
|
F3.printFilter(ast, () => {
|
|
14031
|
-
|
|
14237
|
+
PRINT_ON_EMPTY("LOAD ");
|
|
14032
14238
|
if (ast.silent) {
|
|
14033
14239
|
PRINT_WORD("SILENT");
|
|
14034
14240
|
}
|
|
@@ -14049,9 +14255,9 @@ function clearOrDrop(operation) {
|
|
|
14049
14255
|
const destination = SUBRULE1(graphRefAll);
|
|
14050
14256
|
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
14051
14257
|
},
|
|
14052
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14258
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14053
14259
|
F3.printFilter(ast, () => {
|
|
14054
|
-
|
|
14260
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14055
14261
|
if (ast.silent) {
|
|
14056
14262
|
PRINT_WORD("SILENT");
|
|
14057
14263
|
}
|
|
@@ -14070,9 +14276,9 @@ var create2 = {
|
|
|
14070
14276
|
const destination = SUBRULE1(graphRef);
|
|
14071
14277
|
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
14072
14278
|
},
|
|
14073
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14279
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14074
14280
|
F3.printFilter(ast, () => {
|
|
14075
|
-
|
|
14281
|
+
PRINT_ON_EMPTY("CREATE ");
|
|
14076
14282
|
if (ast.silent) {
|
|
14077
14283
|
PRINT_WORD("SILENT");
|
|
14078
14284
|
}
|
|
@@ -14091,9 +14297,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14091
14297
|
const destination = SUBRULE2(graphOrDefault);
|
|
14092
14298
|
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14093
14299
|
},
|
|
14094
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14300
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14095
14301
|
F3.printFilter(ast, () => {
|
|
14096
|
-
|
|
14302
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14097
14303
|
if (ast.silent) {
|
|
14098
14304
|
PRINT_WORD("SILENT");
|
|
14099
14305
|
}
|
|
@@ -14142,23 +14348,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
|
|
|
14142
14348
|
}
|
|
14143
14349
|
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14144
14350
|
},
|
|
14145
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14351
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14146
14352
|
const { astFactory: F3, indentInc } = C;
|
|
14147
14353
|
F3.printFilter(ast, () => {
|
|
14148
|
-
C[traqulaIndentation] += indentInc;
|
|
14149
14354
|
if (subType === "insertdata") {
|
|
14150
|
-
|
|
14355
|
+
PRINT_ON_EMPTY("INSERT DATA ");
|
|
14151
14356
|
} else if (subType === "deletedata") {
|
|
14152
|
-
|
|
14357
|
+
PRINT_ON_EMPTY("DELETE DATA ");
|
|
14153
14358
|
} else if (subType === "deletewhere") {
|
|
14154
|
-
|
|
14359
|
+
PRINT_ON_EMPTY("DELETE WHERE ");
|
|
14155
14360
|
}
|
|
14156
|
-
|
|
14361
|
+
C[traqulaIndentation] += indentInc;
|
|
14362
|
+
PRINT_WORD("{");
|
|
14363
|
+
NEW_LINE();
|
|
14157
14364
|
});
|
|
14158
14365
|
SUBRULE(quads, F3.wrap(ast.data, ast.loc));
|
|
14159
14366
|
F3.printFilter(ast, () => {
|
|
14160
14367
|
C[traqulaIndentation] -= indentInc;
|
|
14161
|
-
|
|
14368
|
+
PRINT_ON_OWN_LINE("}");
|
|
14162
14369
|
});
|
|
14163
14370
|
}
|
|
14164
14371
|
};
|
|
@@ -14190,36 +14397,40 @@ var modify = {
|
|
|
14190
14397
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14191
14398
|
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14192
14399
|
},
|
|
14193
|
-
gImpl: ({ SUBRULE,
|
|
14400
|
+
gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
|
|
14194
14401
|
const { astFactory: F3, indentInc } = C;
|
|
14195
14402
|
if (ast.graph) {
|
|
14196
|
-
F3.printFilter(ast, () =>
|
|
14403
|
+
F3.printFilter(ast, () => PRINT_WORDS("WITH"));
|
|
14197
14404
|
SUBRULE(iri2, ast.graph);
|
|
14198
14405
|
}
|
|
14199
14406
|
if (ast.delete.length > 0) {
|
|
14200
14407
|
F3.printFilter(ast, () => {
|
|
14201
14408
|
C[traqulaIndentation] += indentInc;
|
|
14202
|
-
|
|
14409
|
+
PRINT_WORDS("DELETE", "{");
|
|
14410
|
+
NEW_LINE();
|
|
14203
14411
|
});
|
|
14204
14412
|
SUBRULE(quads, F3.wrap(ast.delete, ast.loc));
|
|
14205
14413
|
F3.printFilter(ast, () => {
|
|
14206
14414
|
C[traqulaIndentation] -= indentInc;
|
|
14207
|
-
PRINT_ON_EMPTY("}
|
|
14415
|
+
PRINT_ON_EMPTY("}");
|
|
14416
|
+
NEW_LINE();
|
|
14208
14417
|
});
|
|
14209
14418
|
}
|
|
14210
14419
|
if (ast.insert.length > 0) {
|
|
14211
14420
|
F3.printFilter(ast, () => {
|
|
14212
14421
|
C[traqulaIndentation] += indentInc;
|
|
14213
|
-
|
|
14422
|
+
PRINT_WORDS("INSERT", "{");
|
|
14423
|
+
NEW_LINE();
|
|
14214
14424
|
});
|
|
14215
14425
|
SUBRULE(quads, F3.wrap(ast.insert, ast.loc));
|
|
14216
14426
|
F3.printFilter(ast, () => {
|
|
14217
14427
|
C[traqulaIndentation] -= indentInc;
|
|
14218
|
-
PRINT_ON_EMPTY("}
|
|
14428
|
+
PRINT_ON_EMPTY("} ");
|
|
14429
|
+
NEW_LINE();
|
|
14219
14430
|
});
|
|
14220
14431
|
}
|
|
14221
14432
|
SUBRULE(usingClauseStar, ast.from);
|
|
14222
|
-
F3.printFilter(ast, () =>
|
|
14433
|
+
F3.printFilter(ast, () => PRINT_WORDS("WHERE"));
|
|
14223
14434
|
SUBRULE(groupGraphPattern, ast.where);
|
|
14224
14435
|
}
|
|
14225
14436
|
};
|
|
@@ -14343,18 +14554,19 @@ var quadsNotTriples = {
|
|
|
14343
14554
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14344
14555
|
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14345
14556
|
},
|
|
14346
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
14557
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14347
14558
|
const { astFactory: F3, indentInc } = C;
|
|
14348
14559
|
F3.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14349
14560
|
SUBRULE(varOrTerm, ast.graph);
|
|
14350
14561
|
F3.printFilter(ast, () => {
|
|
14351
14562
|
C[traqulaIndentation] += indentInc;
|
|
14352
|
-
PRINT_WORD("{
|
|
14563
|
+
PRINT_WORD("{");
|
|
14564
|
+
NEW_LINE();
|
|
14353
14565
|
});
|
|
14354
14566
|
SUBRULE(triplesBlock, ast.triples);
|
|
14355
14567
|
F3.printFilter(ast, () => {
|
|
14356
14568
|
C[traqulaIndentation] -= indentInc;
|
|
14357
|
-
|
|
14569
|
+
PRINT_ON_OWN_LINE("}");
|
|
14358
14570
|
});
|
|
14359
14571
|
}
|
|
14360
14572
|
};
|
|
@@ -14494,7 +14706,7 @@ var AstFactory2 = class extends AstFactory {
|
|
|
14494
14706
|
type: "tripleCollection",
|
|
14495
14707
|
subType: "reifiedTriple",
|
|
14496
14708
|
triples: [this.triple(subject, predicate, object3)],
|
|
14497
|
-
identifier: reifier2 ?? this.
|
|
14709
|
+
identifier: reifier2 ?? this.termBlank(void 0, this.sourceLocationNoMaterialize()),
|
|
14498
14710
|
loc
|
|
14499
14711
|
};
|
|
14500
14712
|
}
|
|
@@ -14640,9 +14852,9 @@ var versionDecl = {
|
|
|
14640
14852
|
const identifier = SUBRULE(versionSpecifier);
|
|
14641
14853
|
return ACTION(() => C.astFactory.contextDefinitionVersion(identifier.val, C.astFactory.sourceLocation(versionToken, identifier)));
|
|
14642
14854
|
},
|
|
14643
|
-
gImpl: ({
|
|
14855
|
+
gImpl: ({ PRINT_ON_OWN_LINE }) => (ast, { astFactory: F3 }) => {
|
|
14644
14856
|
F3.printFilter(ast, () => {
|
|
14645
|
-
|
|
14857
|
+
PRINT_ON_OWN_LINE("VERSION ", `${grammar_exports.stringEscapedLexical(ast.version)}`);
|
|
14646
14858
|
});
|
|
14647
14859
|
}
|
|
14648
14860
|
};
|
|
@@ -14709,7 +14921,7 @@ var reifier = {
|
|
|
14709
14921
|
if (reifier2 === void 0 && !C.parseMode.has("canCreateBlankNodes")) {
|
|
14710
14922
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
14711
14923
|
}
|
|
14712
|
-
return C.astFactory.wrap(reifier2 ?? C.astFactory.
|
|
14924
|
+
return C.astFactory.wrap(reifier2 ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation()), C.astFactory.sourceLocation(tildeToken, reifier2));
|
|
14713
14925
|
});
|
|
14714
14926
|
}
|
|
14715
14927
|
};
|
|
@@ -14768,7 +14980,7 @@ function annotationImpl(name, allowPaths) {
|
|
|
14768
14980
|
if (!currentReifier && !C.parseMode.has("canCreateBlankNodes")) {
|
|
14769
14981
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
14770
14982
|
}
|
|
14771
|
-
currentReifier = currentReifier ?? C.astFactory.
|
|
14983
|
+
currentReifier = currentReifier ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation());
|
|
14772
14984
|
});
|
|
14773
14985
|
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, currentReifier);
|
|
14774
14986
|
ACTION(() => {
|
|
@@ -14803,13 +15015,13 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
14803
15015
|
const close = CONSUME(annotationClose);
|
|
14804
15016
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(arg, res, C.astFactory.sourceLocation(open, close)));
|
|
14805
15017
|
},
|
|
14806
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC,
|
|
15018
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14807
15019
|
const { astFactory: F3, indentInc } = C;
|
|
14808
15020
|
F3.printFilter(ast, () => {
|
|
14809
15021
|
PRINT_WORD("{|");
|
|
14810
15022
|
if (ast.triples.length > 1) {
|
|
14811
15023
|
C[traqulaIndentation] += indentInc;
|
|
14812
|
-
|
|
15024
|
+
NEW_LINE();
|
|
14813
15025
|
}
|
|
14814
15026
|
});
|
|
14815
15027
|
function printTriple(triple) {
|
|
@@ -14819,18 +15031,22 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
14819
15031
|
} else {
|
|
14820
15032
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
14821
15033
|
}
|
|
15034
|
+
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
14822
15035
|
SUBRULE(graphNodePath2, triple.object);
|
|
14823
15036
|
});
|
|
14824
15037
|
}
|
|
14825
15038
|
const [head2, ...tail] = ast.triples;
|
|
14826
15039
|
printTriple(head2);
|
|
14827
15040
|
for (const triple of tail) {
|
|
14828
|
-
F3.printFilter(ast, () =>
|
|
15041
|
+
F3.printFilter(ast, () => {
|
|
15042
|
+
PRINT_WORD(";");
|
|
15043
|
+
NEW_LINE();
|
|
15044
|
+
});
|
|
14829
15045
|
printTriple(triple);
|
|
14830
15046
|
}
|
|
14831
15047
|
F3.printFilter(ast, () => {
|
|
14832
15048
|
if (ast.triples.length > 1) {
|
|
14833
|
-
|
|
15049
|
+
PRINT_ON_OWN_LINE("|}");
|
|
14834
15050
|
} else {
|
|
14835
15051
|
PRINT_WORD("|}");
|
|
14836
15052
|
}
|
|
@@ -14872,7 +15088,7 @@ var varOrTerm2 = {
|
|
|
14872
15088
|
{ ALT: () => SUBRULE(grammar_exports.blankNode) },
|
|
14873
15089
|
{ ALT: () => {
|
|
14874
15090
|
const token = CONSUME(lexer_exports.terminals.nil);
|
|
14875
|
-
return ACTION(() => C.astFactory.
|
|
15091
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.NIL));
|
|
14876
15092
|
} },
|
|
14877
15093
|
{ ALT: () => SUBRULE(tripleTerm) }
|
|
14878
15094
|
])
|
|
@@ -14898,11 +15114,13 @@ var reifiedTriple = {
|
|
|
14898
15114
|
F3.printFilter(ast, () => PRINT_WORD("<<"));
|
|
14899
15115
|
const triple = ast.triples[0];
|
|
14900
15116
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15117
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14901
15118
|
if (F3.isPathPure(triple.predicate)) {
|
|
14902
15119
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
14903
15120
|
} else {
|
|
14904
15121
|
SUBRULE(graphNodePath2, triple.predicate);
|
|
14905
15122
|
}
|
|
15123
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14906
15124
|
SUBRULE(graphNodePath2, triple.object);
|
|
14907
15125
|
SUBRULE(annotationPath, [F3.wrap(ast.identifier, ast.identifier.loc)]);
|
|
14908
15126
|
F3.printFilter(ast, () => PRINT_WORD(">>"));
|
|
@@ -14938,7 +15156,9 @@ var tripleTerm = {
|
|
|
14938
15156
|
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14939
15157
|
F3.printFilter(ast, () => PRINT_WORD("<<("));
|
|
14940
15158
|
SUBRULE(graphNodePath2, ast.subject);
|
|
15159
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14941
15160
|
SUBRULE(graphNodePath2, ast.predicate);
|
|
15161
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14942
15162
|
SUBRULE(graphNodePath2, ast.object);
|
|
14943
15163
|
F3.printFilter(ast, () => PRINT_WORD(")>>"));
|
|
14944
15164
|
}
|
|
@@ -14968,7 +15188,7 @@ var tripleTermData = {
|
|
|
14968
15188
|
{ ALT: () => SUBRULE(grammar_exports.iri) },
|
|
14969
15189
|
{ ALT: () => {
|
|
14970
15190
|
const token = CONSUME(lexer_exports.a);
|
|
14971
|
-
return ACTION(() => C.astFactory.
|
|
15191
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE));
|
|
14972
15192
|
} }
|
|
14973
15193
|
]);
|
|
14974
15194
|
const object3 = SUBRULE(tripleTermDataObject);
|
|
@@ -15055,7 +15275,7 @@ var rdfLiteral2 = {
|
|
|
15055
15275
|
{ ALT: () => {
|
|
15056
15276
|
const langTag2 = CONSUME(LANG_DIR);
|
|
15057
15277
|
return ACTION(() => {
|
|
15058
|
-
const literal = C.astFactory.
|
|
15278
|
+
const literal = C.astFactory.termLiteral(C.astFactory.sourceLocation(value, langTag2), value.value, langTag2.image.slice(1).toLowerCase());
|
|
15059
15279
|
langTagHasCorrectRange(literal);
|
|
15060
15280
|
return literal;
|
|
15061
15281
|
});
|
|
@@ -15063,7 +15283,7 @@ var rdfLiteral2 = {
|
|
|
15063
15283
|
{ ALT: () => {
|
|
15064
15284
|
CONSUME(lexer_exports.symbols.hathat);
|
|
15065
15285
|
const iriVal = SUBRULE(grammar_exports.iri);
|
|
15066
|
-
return ACTION(() => C.astFactory.
|
|
15286
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
15067
15287
|
} }
|
|
15068
15288
|
])) ?? value;
|
|
15069
15289
|
}
|
|
@@ -15089,13 +15309,16 @@ var unaryExpression2 = {
|
|
|
15089
15309
|
};
|
|
15090
15310
|
var generateTriplesBlock = {
|
|
15091
15311
|
name: "triplesBlock",
|
|
15092
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15312
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15093
15313
|
for (const [index, triple] of ast.triples.entries()) {
|
|
15094
15314
|
HANDLE_LOC(triple, () => {
|
|
15095
15315
|
const nextTriple = ast.triples.at(index);
|
|
15096
15316
|
if (F3.isTripleCollection(triple)) {
|
|
15097
15317
|
SUBRULE(graphNodePath2, triple);
|
|
15098
|
-
F3.printFilter(triple, () =>
|
|
15318
|
+
F3.printFilter(triple, () => {
|
|
15319
|
+
PRINT_WORD(".");
|
|
15320
|
+
NEW_LINE();
|
|
15321
|
+
});
|
|
15099
15322
|
} else {
|
|
15100
15323
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15101
15324
|
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
@@ -15108,11 +15331,17 @@ var generateTriplesBlock = {
|
|
|
15108
15331
|
SUBRULE(graphNodePath2, triple.object);
|
|
15109
15332
|
SUBRULE(annotationPath, triple.annotations ?? []);
|
|
15110
15333
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
15111
|
-
F3.printFilter(ast, () =>
|
|
15334
|
+
F3.printFilter(ast, () => {
|
|
15335
|
+
PRINT_WORD(".");
|
|
15336
|
+
NEW_LINE();
|
|
15337
|
+
});
|
|
15112
15338
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
15113
15339
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
15114
15340
|
} else {
|
|
15115
|
-
F3.printFilter(ast, () =>
|
|
15341
|
+
F3.printFilter(ast, () => {
|
|
15342
|
+
PRINT_WORD(";");
|
|
15343
|
+
NEW_LINE();
|
|
15344
|
+
});
|
|
15116
15345
|
}
|
|
15117
15346
|
}
|
|
15118
15347
|
});
|
|
@@ -15144,7 +15373,7 @@ function completeParseContext(context) {
|
|
|
15144
15373
|
[traqulaIndentation]: context[traqulaIndentation] ?? 0
|
|
15145
15374
|
};
|
|
15146
15375
|
}
|
|
15147
|
-
var AstTransformer2 = class extends
|
|
15376
|
+
var AstTransformer2 = class extends TransformerSubTyped {
|
|
15148
15377
|
};
|
|
15149
15378
|
/*! Bundled license information:
|
|
15150
15379
|
|