@traqula/rules-sparql-1-2 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AstFactory.js +1 -1
- package/lib/AstFactory.js.map +1 -1
- package/lib/grammar.js +33 -16
- package/lib/grammar.js.map +1 -1
- package/lib/index.cjs +446 -209
- 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,34 @@ 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 _TransformerObject {
|
|
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
|
+
clone(newDefaultContext = {}) {
|
|
9540
|
+
return new _TransformerObject({ ...this.defaultContext, ...newDefaultContext });
|
|
9541
|
+
}
|
|
9542
|
+
/**
|
|
9543
|
+
* Function to shallow clone any type.
|
|
9544
|
+
* @param obj
|
|
9545
|
+
* @protected
|
|
9546
|
+
*/
|
|
9547
|
+
cloneObj(obj) {
|
|
9548
|
+
if (obj === null || typeof obj !== "object") {
|
|
9549
|
+
return obj;
|
|
9541
9550
|
}
|
|
9542
|
-
|
|
9551
|
+
const proto = Object.getPrototypeOf(obj);
|
|
9552
|
+
if (proto === Object.prototype || proto === null) {
|
|
9553
|
+
return { ...obj };
|
|
9554
|
+
}
|
|
9555
|
+
return Object.assign(Object.create(proto), obj);
|
|
9543
9556
|
}
|
|
9544
9557
|
/**
|
|
9545
9558
|
* Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
|
|
@@ -9551,90 +9564,231 @@ var TransformerType = class {
|
|
|
9551
9564
|
* - Default false
|
|
9552
9565
|
*/
|
|
9553
9566
|
transformObject(startObject, mapper, preVisitor = () => ({})) {
|
|
9567
|
+
const defaults2 = this.defaultContext;
|
|
9568
|
+
const defaultCopyFlag = defaults2.copy ?? true;
|
|
9569
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9570
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9571
|
+
const defaultShallowKeys = defaults2.shallowKeys;
|
|
9572
|
+
const defaultDidShortCut = defaults2.shortcut ?? false;
|
|
9554
9573
|
let didShortCut = false;
|
|
9555
|
-
const
|
|
9556
|
-
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9561
|
-
|
|
9562
|
-
|
|
9563
|
-
|
|
9574
|
+
const resultWrap = { res: startObject };
|
|
9575
|
+
const stack = [startObject];
|
|
9576
|
+
const stackParent = [resultWrap];
|
|
9577
|
+
const stackParentKey = ["res"];
|
|
9578
|
+
const handleMapperOnLen = [];
|
|
9579
|
+
const mapperCopyStack = [];
|
|
9580
|
+
const mapperOrigStack = [];
|
|
9581
|
+
const mapperParent = [];
|
|
9582
|
+
const mapperParentKey = [];
|
|
9583
|
+
function handleMapper() {
|
|
9584
|
+
while (stack.length === handleMapperOnLen.at(-1)) {
|
|
9585
|
+
handleMapperOnLen.pop();
|
|
9586
|
+
const copyToMap = mapperCopyStack.pop();
|
|
9587
|
+
const origToMap = mapperOrigStack.pop();
|
|
9588
|
+
const parent = mapperParent.pop();
|
|
9589
|
+
const parentKey = mapperParentKey.pop();
|
|
9590
|
+
parent[parentKey] = mapper(copyToMap, origToMap);
|
|
9591
|
+
}
|
|
9592
|
+
}
|
|
9593
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9594
|
+
const curObject = stack.pop();
|
|
9595
|
+
const curParent = stackParent.pop();
|
|
9596
|
+
const curKey = stackParentKey.pop();
|
|
9597
|
+
if (!didShortCut) {
|
|
9598
|
+
if (Array.isArray(curObject)) {
|
|
9599
|
+
const newArr = [...curObject];
|
|
9600
|
+
handleMapperOnLen.push(stack.length);
|
|
9601
|
+
mapperCopyStack.push(newArr);
|
|
9602
|
+
mapperOrigStack.push(curObject);
|
|
9603
|
+
mapperParent.push(curParent);
|
|
9604
|
+
mapperParentKey.push(curKey);
|
|
9605
|
+
for (let index = curObject.length - 1; index >= 0; index--) {
|
|
9606
|
+
const val = curObject[index];
|
|
9607
|
+
if (val !== null && typeof val === "object") {
|
|
9608
|
+
stack.push(val);
|
|
9609
|
+
stackParent.push(newArr);
|
|
9610
|
+
stackParentKey.push(index.toString());
|
|
9611
|
+
}
|
|
9612
|
+
}
|
|
9613
|
+
handleMapper();
|
|
9614
|
+
continue;
|
|
9615
|
+
}
|
|
9616
|
+
const context = preVisitor(curObject);
|
|
9617
|
+
const copyFlag = context.copy ?? defaultCopyFlag;
|
|
9618
|
+
const continues = context.continue ?? defaultContinues;
|
|
9619
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9620
|
+
const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
|
|
9621
|
+
didShortCut = context.shortcut ?? defaultDidShortCut;
|
|
9622
|
+
const copy3 = copyFlag ? this.cloneObj(curObject) : curObject;
|
|
9623
|
+
handleMapperOnLen.push(stack.length);
|
|
9624
|
+
mapperCopyStack.push(copy3);
|
|
9625
|
+
mapperOrigStack.push(curObject);
|
|
9626
|
+
mapperParent.push(curParent);
|
|
9627
|
+
mapperParentKey.push(curKey);
|
|
9628
|
+
if (continues && !didShortCut) {
|
|
9629
|
+
for (const key in copy3) {
|
|
9630
|
+
if (!Object.hasOwn(copy3, key)) {
|
|
9631
|
+
continue;
|
|
9632
|
+
}
|
|
9633
|
+
const val = copy3[key];
|
|
9634
|
+
const onlyShallow = shallowKeys && shallowKeys?.has(key);
|
|
9635
|
+
if (onlyShallow) {
|
|
9636
|
+
copy3[key] = this.cloneObj(val);
|
|
9637
|
+
}
|
|
9638
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9639
|
+
continue;
|
|
9640
|
+
}
|
|
9641
|
+
if (!onlyShallow && val !== null && typeof val === "object") {
|
|
9642
|
+
stack.push(val);
|
|
9643
|
+
stackParentKey.push(key);
|
|
9644
|
+
stackParent.push(copy3);
|
|
9645
|
+
}
|
|
9564
9646
|
}
|
|
9565
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9566
9647
|
}
|
|
9567
9648
|
}
|
|
9568
|
-
|
|
9569
|
-
}
|
|
9570
|
-
|
|
9649
|
+
handleMapper();
|
|
9650
|
+
}
|
|
9651
|
+
if (stack.length >= this.maxStackSize) {
|
|
9652
|
+
throw new Error("Transform object stack overflowed");
|
|
9653
|
+
}
|
|
9654
|
+
handleMapper();
|
|
9655
|
+
return resultWrap.res;
|
|
9571
9656
|
}
|
|
9572
9657
|
/**
|
|
9573
9658
|
* Visitor that visits all objects. Visits deeper objects first.
|
|
9574
9659
|
*/
|
|
9575
9660
|
visitObject(startObject, visitor, preVisitor = () => ({})) {
|
|
9661
|
+
const defaults2 = this.defaultContext;
|
|
9662
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9663
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9664
|
+
const defaultShortcut = defaults2.shortcut ?? false;
|
|
9576
9665
|
let didShortCut = false;
|
|
9577
|
-
const
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9666
|
+
const stack = [startObject];
|
|
9667
|
+
const handleVisitorOnLen = [];
|
|
9668
|
+
const visitorStack = [];
|
|
9669
|
+
function handleVisitor() {
|
|
9670
|
+
while (stack.length === handleVisitorOnLen.at(-1)) {
|
|
9671
|
+
handleVisitorOnLen.pop();
|
|
9672
|
+
const toVisit = visitorStack.pop();
|
|
9673
|
+
visitor(toVisit);
|
|
9674
|
+
}
|
|
9675
|
+
}
|
|
9676
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9677
|
+
const curObject = stack.pop();
|
|
9678
|
+
if (!didShortCut) {
|
|
9679
|
+
if (Array.isArray(curObject)) {
|
|
9680
|
+
for (let i = curObject.length - 1; i >= 0; i--) {
|
|
9681
|
+
stack.push(curObject[i]);
|
|
9682
|
+
}
|
|
9683
|
+
handleVisitor();
|
|
9684
|
+
continue;
|
|
9685
|
+
}
|
|
9686
|
+
const context = preVisitor(curObject);
|
|
9687
|
+
didShortCut = context.shortcut ?? defaultShortcut;
|
|
9688
|
+
const continues = context.continue ?? defaultContinues;
|
|
9689
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9690
|
+
handleVisitorOnLen.push(stack.length);
|
|
9691
|
+
visitorStack.push(curObject);
|
|
9692
|
+
if (continues && !didShortCut) {
|
|
9693
|
+
for (const key in curObject) {
|
|
9694
|
+
if (!Object.hasOwn(curObject, key)) {
|
|
9695
|
+
continue;
|
|
9696
|
+
}
|
|
9697
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9698
|
+
continue;
|
|
9699
|
+
}
|
|
9700
|
+
const val = curObject[key];
|
|
9701
|
+
if (val && typeof val === "object") {
|
|
9702
|
+
stack.push(val);
|
|
9703
|
+
}
|
|
9585
9704
|
}
|
|
9586
|
-
this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9587
9705
|
}
|
|
9588
9706
|
}
|
|
9589
|
-
|
|
9590
|
-
}
|
|
9591
|
-
|
|
9707
|
+
handleVisitor();
|
|
9708
|
+
}
|
|
9709
|
+
if (stack.length >= this.maxStackSize) {
|
|
9710
|
+
throw new Error("Transform object stack overflowed");
|
|
9711
|
+
}
|
|
9712
|
+
handleVisitor();
|
|
9713
|
+
}
|
|
9714
|
+
};
|
|
9715
|
+
|
|
9716
|
+
// ../core/lib/TransformerTyped.js
|
|
9717
|
+
var TransformerTyped = class _TransformerTyped extends TransformerObject {
|
|
9718
|
+
defaultNodePreVisitor;
|
|
9719
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9720
|
+
super(defaultContext);
|
|
9721
|
+
this.defaultNodePreVisitor = defaultNodePreVisitor;
|
|
9592
9722
|
}
|
|
9723
|
+
clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
|
|
9724
|
+
return new _TransformerTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
|
|
9725
|
+
}
|
|
9726
|
+
/**
|
|
9727
|
+
* Transform a single node.
|
|
9728
|
+
* The transformation calls the preVisitor from starting from the startObject.
|
|
9729
|
+
* The preVisitor can dictate whether transformation should be stopped.
|
|
9730
|
+
* Note that stopping the transformation also prevets further copying.
|
|
9731
|
+
* The transformer itself transforms object starting with the deepest one that can be visited.
|
|
9732
|
+
* The transformer callback is performed on a copy of the original.
|
|
9733
|
+
* @param startObject
|
|
9734
|
+
* @param nodeCallBacks
|
|
9735
|
+
*/
|
|
9593
9736
|
transformNode(startObject, nodeCallBacks) {
|
|
9594
|
-
const transformWrapper = (
|
|
9595
|
-
|
|
9737
|
+
const transformWrapper = (copy3, orig) => {
|
|
9738
|
+
let ogTransform;
|
|
9739
|
+
const casted = copy3;
|
|
9596
9740
|
if (casted.type) {
|
|
9597
|
-
|
|
9598
|
-
if (ogFunc) {
|
|
9599
|
-
return ogFunc(casted);
|
|
9600
|
-
}
|
|
9741
|
+
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9601
9742
|
}
|
|
9602
|
-
return
|
|
9743
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9603
9744
|
};
|
|
9604
|
-
const
|
|
9745
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9746
|
+
const preVisitWrapper = (curObject) => {
|
|
9747
|
+
let ogPreVisit;
|
|
9748
|
+
let nodeContext = {};
|
|
9605
9749
|
const casted = curObject;
|
|
9606
9750
|
if (casted.type) {
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
return ogFunc(casted);
|
|
9610
|
-
}
|
|
9751
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9752
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9611
9753
|
}
|
|
9612
|
-
return {};
|
|
9754
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9613
9755
|
};
|
|
9614
|
-
return this.transformObject(startObject, transformWrapper,
|
|
9756
|
+
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9615
9757
|
}
|
|
9758
|
+
/**
|
|
9759
|
+
* Similar to {@link this.transformNode}, but without copying the startObject.
|
|
9760
|
+
* The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
|
|
9761
|
+
* @param startObject
|
|
9762
|
+
* @param nodeCallBacks
|
|
9763
|
+
*/
|
|
9616
9764
|
visitNode(startObject, nodeCallBacks) {
|
|
9617
|
-
const
|
|
9765
|
+
const visitorWrapper = (curObject) => {
|
|
9618
9766
|
const casted = curObject;
|
|
9619
9767
|
if (casted.type) {
|
|
9620
|
-
const
|
|
9621
|
-
if (
|
|
9622
|
-
|
|
9768
|
+
const ogTransform = nodeCallBacks[casted.type]?.visitor;
|
|
9769
|
+
if (ogTransform) {
|
|
9770
|
+
ogTransform(casted);
|
|
9623
9771
|
}
|
|
9624
9772
|
}
|
|
9625
9773
|
};
|
|
9774
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9626
9775
|
const preVisitWrapper = (curObject) => {
|
|
9776
|
+
let ogPreVisit;
|
|
9777
|
+
let nodeContext = {};
|
|
9627
9778
|
const casted = curObject;
|
|
9628
9779
|
if (casted.type) {
|
|
9629
|
-
|
|
9630
|
-
|
|
9631
|
-
return ogFunc(casted);
|
|
9632
|
-
}
|
|
9780
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9781
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9633
9782
|
}
|
|
9634
|
-
return {};
|
|
9783
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9635
9784
|
};
|
|
9636
|
-
this.visitObject(startObject,
|
|
9785
|
+
return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
|
|
9637
9786
|
}
|
|
9787
|
+
/**
|
|
9788
|
+
* Traverses only selected nodes as returned by the function.
|
|
9789
|
+
* @param currentNode
|
|
9790
|
+
* @param traverse
|
|
9791
|
+
*/
|
|
9638
9792
|
traverseNodes(currentNode, traverse) {
|
|
9639
9793
|
let didShortCut = false;
|
|
9640
9794
|
const recurse = (curNode) => {
|
|
@@ -9655,11 +9809,27 @@ var TransformerType = class {
|
|
|
9655
9809
|
recurse(currentNode);
|
|
9656
9810
|
}
|
|
9657
9811
|
};
|
|
9658
|
-
|
|
9812
|
+
|
|
9813
|
+
// ../core/lib/TransformerSubTyped.js
|
|
9814
|
+
var TransformerSubTyped = class _TransformerSubTyped extends TransformerTyped {
|
|
9815
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9816
|
+
super(defaultContext, defaultNodePreVisitor);
|
|
9817
|
+
}
|
|
9818
|
+
clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
|
|
9819
|
+
return new _TransformerSubTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
|
|
9820
|
+
}
|
|
9821
|
+
/**
|
|
9822
|
+
* Shares the functionality and first two arguments with {@link this.transformNode}.
|
|
9823
|
+
* The third argument allows you to also transform based on the subType of objects.
|
|
9824
|
+
* Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
|
|
9825
|
+
* @param startObject
|
|
9826
|
+
* @param nodeCallBacks
|
|
9827
|
+
* @param nodeSpecificCallBacks
|
|
9828
|
+
*/
|
|
9659
9829
|
transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9660
|
-
const transformWrapper = (
|
|
9830
|
+
const transformWrapper = (copy3, orig) => {
|
|
9661
9831
|
let ogTransform;
|
|
9662
|
-
const casted =
|
|
9832
|
+
const casted = copy3;
|
|
9663
9833
|
if (casted.type && casted.subType) {
|
|
9664
9834
|
const specific = nodeSpecificCallBacks[casted.type];
|
|
9665
9835
|
if (specific) {
|
|
@@ -9669,7 +9839,7 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9669
9839
|
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9670
9840
|
}
|
|
9671
9841
|
}
|
|
9672
|
-
return ogTransform ? ogTransform(casted) :
|
|
9842
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9673
9843
|
};
|
|
9674
9844
|
const preVisitWrapper = (curObject) => {
|
|
9675
9845
|
let ogPreVisit;
|
|
@@ -9683,12 +9853,13 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9683
9853
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9684
9854
|
}
|
|
9685
9855
|
}
|
|
9686
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
9856
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9687
9857
|
};
|
|
9688
9858
|
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9689
9859
|
}
|
|
9690
9860
|
/**
|
|
9691
|
-
*
|
|
9861
|
+
* Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
|
|
9862
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
|
|
9692
9863
|
*/
|
|
9693
9864
|
visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9694
9865
|
const visitWrapper = (curObject) => {
|
|
@@ -9719,10 +9890,16 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9719
9890
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9720
9891
|
}
|
|
9721
9892
|
}
|
|
9722
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
9893
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9723
9894
|
};
|
|
9724
9895
|
this.visitObject(startObject, visitWrapper, preVisitWrapper);
|
|
9725
9896
|
}
|
|
9897
|
+
/**
|
|
9898
|
+
* Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
|
|
9899
|
+
* @param currentNode
|
|
9900
|
+
* @param traverseNode
|
|
9901
|
+
* @param traverseSubNode
|
|
9902
|
+
*/
|
|
9726
9903
|
traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
|
|
9727
9904
|
let didShortCut = false;
|
|
9728
9905
|
const recurse = (curNode) => {
|
|
@@ -10795,8 +10972,8 @@ function PatternFactoryMixin(Base) {
|
|
|
10795
10972
|
isPatternOptional(obj) {
|
|
10796
10973
|
return this.isOfSubType(obj, nodeType5, "optional");
|
|
10797
10974
|
}
|
|
10798
|
-
patternValues(values3, loc) {
|
|
10799
|
-
return { type: nodeType5, subType: "values", values: values3, loc };
|
|
10975
|
+
patternValues(variables, values3, loc) {
|
|
10976
|
+
return { type: nodeType5, subType: "values", variables, values: values3, loc };
|
|
10800
10977
|
}
|
|
10801
10978
|
isPatternValues(obj) {
|
|
10802
10979
|
return this.isOfSubType(obj, nodeType5, "values");
|
|
@@ -10971,7 +11148,7 @@ function TermFactoryMixin(Base) {
|
|
|
10971
11148
|
isTerm(x) {
|
|
10972
11149
|
return this.isOfType(x, "term");
|
|
10973
11150
|
}
|
|
10974
|
-
|
|
11151
|
+
termBlank(label, loc) {
|
|
10975
11152
|
const base = {
|
|
10976
11153
|
type: "term",
|
|
10977
11154
|
subType: "blankNode",
|
|
@@ -10985,7 +11162,7 @@ function TermFactoryMixin(Base) {
|
|
|
10985
11162
|
isTermBlank(obj) {
|
|
10986
11163
|
return this.isOfSubType(obj, nodeType8, "blankNode");
|
|
10987
11164
|
}
|
|
10988
|
-
|
|
11165
|
+
termLiteral(loc, value, langOrIri) {
|
|
10989
11166
|
return {
|
|
10990
11167
|
type: nodeType8,
|
|
10991
11168
|
subType: "literal",
|
|
@@ -11007,7 +11184,7 @@ function TermFactoryMixin(Base) {
|
|
|
11007
11184
|
const casted = obj;
|
|
11008
11185
|
return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
|
|
11009
11186
|
}
|
|
11010
|
-
|
|
11187
|
+
termVariable(value, loc) {
|
|
11011
11188
|
return {
|
|
11012
11189
|
type: nodeType8,
|
|
11013
11190
|
subType: "variable",
|
|
@@ -11018,7 +11195,7 @@ function TermFactoryMixin(Base) {
|
|
|
11018
11195
|
isTermVariable(obj) {
|
|
11019
11196
|
return this.isOfSubType(obj, nodeType8, "variable");
|
|
11020
11197
|
}
|
|
11021
|
-
|
|
11198
|
+
termNamed(loc, value, prefix) {
|
|
11022
11199
|
const base = {
|
|
11023
11200
|
type: nodeType8,
|
|
11024
11201
|
subType: "namedNode",
|
|
@@ -11263,7 +11440,7 @@ var CommonIRIs;
|
|
|
11263
11440
|
CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
11264
11441
|
CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
11265
11442
|
})(CommonIRIs || (CommonIRIs = {}));
|
|
11266
|
-
var AstTransformer = class extends
|
|
11443
|
+
var AstTransformer = class extends TransformerSubTyped {
|
|
11267
11444
|
};
|
|
11268
11445
|
|
|
11269
11446
|
// ../rules-sparql-1-1/lib/validation/validators.js
|
|
@@ -11391,8 +11568,7 @@ function findPatternBoundedVars(iter, boundedVars) {
|
|
|
11391
11568
|
optional: (op) => ({ next: op.patterns }),
|
|
11392
11569
|
service: (op) => ({ next: [op.name, ...op.patterns] }),
|
|
11393
11570
|
bind: (op) => ({ next: [op.variable] }),
|
|
11394
|
-
graph: (op) => ({ next: [op.name, ...op.patterns] })
|
|
11395
|
-
minus: (op) => ({ next: op.patterns.slice(0, 1) })
|
|
11571
|
+
graph: (op) => ({ next: [op.name, ...op.patterns] })
|
|
11396
11572
|
},
|
|
11397
11573
|
term: {
|
|
11398
11574
|
variable: (op) => {
|
|
@@ -11479,17 +11655,20 @@ var rdfLiteral = {
|
|
|
11479
11655
|
return OPTION(() => OR([
|
|
11480
11656
|
{ ALT: () => {
|
|
11481
11657
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11482
|
-
return ACTION(() => C.astFactory.
|
|
11658
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11483
11659
|
} },
|
|
11484
11660
|
{ ALT: () => {
|
|
11485
11661
|
CONSUME(symbols_exports.hathat);
|
|
11486
11662
|
const iriVal = SUBRULE1(iri2);
|
|
11487
|
-
return ACTION(() => C.astFactory.
|
|
11663
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11488
11664
|
} }
|
|
11489
11665
|
])) ?? value;
|
|
11490
11666
|
},
|
|
11491
|
-
gImpl: ({ SUBRULE, PRINT,
|
|
11492
|
-
astFactory.printFilter(ast, () =>
|
|
11667
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11668
|
+
astFactory.printFilter(ast, () => {
|
|
11669
|
+
PRINT_WORD("");
|
|
11670
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
11671
|
+
});
|
|
11493
11672
|
if (ast.langOrIri) {
|
|
11494
11673
|
if (typeof ast.langOrIri === "string") {
|
|
11495
11674
|
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
@@ -11516,7 +11695,7 @@ var numericLiteralUnsigned = {
|
|
|
11516
11695
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11517
11696
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11518
11697
|
]);
|
|
11519
|
-
return ACTION(() => C.astFactory.
|
|
11698
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11520
11699
|
}
|
|
11521
11700
|
};
|
|
11522
11701
|
var numericLiteralPositive = {
|
|
@@ -11527,7 +11706,7 @@ var numericLiteralPositive = {
|
|
|
11527
11706
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11528
11707
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11529
11708
|
]);
|
|
11530
|
-
return ACTION(() => C.astFactory.
|
|
11709
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11531
11710
|
}
|
|
11532
11711
|
};
|
|
11533
11712
|
var numericLiteralNegative = {
|
|
@@ -11538,7 +11717,7 @@ var numericLiteralNegative = {
|
|
|
11538
11717
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11539
11718
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11540
11719
|
]);
|
|
11541
|
-
return ACTION(() => C.astFactory.
|
|
11720
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11542
11721
|
}
|
|
11543
11722
|
};
|
|
11544
11723
|
var booleanLiteral = {
|
|
@@ -11548,7 +11727,7 @@ var booleanLiteral = {
|
|
|
11548
11727
|
{ ALT: () => CONSUME(true_) },
|
|
11549
11728
|
{ ALT: () => CONSUME(false_) }
|
|
11550
11729
|
]);
|
|
11551
|
-
return ACTION(() => C.astFactory.
|
|
11730
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11552
11731
|
}
|
|
11553
11732
|
};
|
|
11554
11733
|
var string = {
|
|
@@ -11590,7 +11769,7 @@ var string = {
|
|
|
11590
11769
|
return char;
|
|
11591
11770
|
}
|
|
11592
11771
|
});
|
|
11593
|
-
return F3.
|
|
11772
|
+
return F3.termLiteral(F3.sourceLocation(x[0]), value);
|
|
11594
11773
|
});
|
|
11595
11774
|
}
|
|
11596
11775
|
};
|
|
@@ -11606,7 +11785,7 @@ var iriFull = {
|
|
|
11606
11785
|
name: "iriFull",
|
|
11607
11786
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11608
11787
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11609
|
-
return ACTION(() => C.astFactory.
|
|
11788
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11610
11789
|
},
|
|
11611
11790
|
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11612
11791
|
F3.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
@@ -11619,16 +11798,16 @@ var prefixedName = {
|
|
|
11619
11798
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11620
11799
|
return ACTION(() => {
|
|
11621
11800
|
const [prefix, localName] = longName.image.split(":");
|
|
11622
|
-
return C.astFactory.
|
|
11801
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11623
11802
|
});
|
|
11624
11803
|
} },
|
|
11625
11804
|
{ ALT: () => {
|
|
11626
11805
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11627
|
-
return ACTION(() => C.astFactory.
|
|
11806
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11628
11807
|
} }
|
|
11629
11808
|
]),
|
|
11630
|
-
gImpl: ({
|
|
11631
|
-
F3.printFilter(ast, () =>
|
|
11809
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11810
|
+
F3.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
11632
11811
|
}
|
|
11633
11812
|
};
|
|
11634
11813
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11638,11 +11817,11 @@ var blankNode = {
|
|
|
11638
11817
|
const result = OR([
|
|
11639
11818
|
{ ALT: () => {
|
|
11640
11819
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11641
|
-
return ACTION(() => C.astFactory.
|
|
11820
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11642
11821
|
} },
|
|
11643
11822
|
{ ALT: () => {
|
|
11644
11823
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11645
|
-
return ACTION(() => C.astFactory.
|
|
11824
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11646
11825
|
} }
|
|
11647
11826
|
]);
|
|
11648
11827
|
ACTION(() => {
|
|
@@ -11652,15 +11831,15 @@ var blankNode = {
|
|
|
11652
11831
|
});
|
|
11653
11832
|
return result;
|
|
11654
11833
|
},
|
|
11655
|
-
gImpl: ({
|
|
11656
|
-
astFactory.printFilter(ast, () =>
|
|
11834
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
11835
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
11657
11836
|
}
|
|
11658
11837
|
};
|
|
11659
11838
|
var verbA = {
|
|
11660
11839
|
name: "VerbA",
|
|
11661
11840
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11662
11841
|
const token = CONSUME(a);
|
|
11663
|
-
return ACTION(() => C.astFactory.
|
|
11842
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11664
11843
|
}
|
|
11665
11844
|
};
|
|
11666
11845
|
|
|
@@ -11694,10 +11873,10 @@ var baseDecl2 = {
|
|
|
11694
11873
|
const val = SUBRULE(iriFull);
|
|
11695
11874
|
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11696
11875
|
},
|
|
11697
|
-
gImpl: ({ SUBRULE,
|
|
11698
|
-
F3.printFilter(ast, () =>
|
|
11876
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
11877
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
|
|
11699
11878
|
SUBRULE(iri2, ast.value);
|
|
11700
|
-
F3.printFilter(ast, () =>
|
|
11879
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11701
11880
|
}
|
|
11702
11881
|
};
|
|
11703
11882
|
var prefixDecl2 = {
|
|
@@ -11708,12 +11887,12 @@ var prefixDecl2 = {
|
|
|
11708
11887
|
const value = SUBRULE(iriFull);
|
|
11709
11888
|
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11710
11889
|
},
|
|
11711
|
-
gImpl: ({ SUBRULE,
|
|
11890
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
11712
11891
|
F3.printFilter(ast, () => {
|
|
11713
|
-
|
|
11892
|
+
PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
|
|
11714
11893
|
});
|
|
11715
11894
|
SUBRULE(iri2, ast.value);
|
|
11716
|
-
F3.printFilter(ast, () =>
|
|
11895
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11717
11896
|
}
|
|
11718
11897
|
};
|
|
11719
11898
|
var verb = {
|
|
@@ -11750,10 +11929,10 @@ var var_ = {
|
|
|
11750
11929
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11751
11930
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11752
11931
|
]);
|
|
11753
|
-
return ACTION(() => C.astFactory.
|
|
11932
|
+
return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11754
11933
|
},
|
|
11755
|
-
gImpl: ({
|
|
11756
|
-
F3.printFilter(ast, () =>
|
|
11934
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11935
|
+
F3.printFilter(ast, () => PRINT(`?${ast.value}`));
|
|
11757
11936
|
}
|
|
11758
11937
|
};
|
|
11759
11938
|
var graphTerm = {
|
|
@@ -11766,7 +11945,7 @@ var graphTerm = {
|
|
|
11766
11945
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
11767
11946
|
{ ALT: () => {
|
|
11768
11947
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
11769
|
-
return ACTION(() => C.astFactory.
|
|
11948
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
11770
11949
|
} }
|
|
11771
11950
|
]),
|
|
11772
11951
|
gImpl: ({ SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
@@ -12396,13 +12575,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12396
12575
|
var triplesBlock = {
|
|
12397
12576
|
name: "triplesBlock",
|
|
12398
12577
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12399
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
12578
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12400
12579
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12401
12580
|
HANDLE_LOC(triple, () => {
|
|
12402
12581
|
const nextTriple = ast.triples.at(index);
|
|
12403
12582
|
if (F3.isTripleCollection(triple)) {
|
|
12404
12583
|
SUBRULE(graphNodePath, triple);
|
|
12405
|
-
F3.printFilter(triple, () =>
|
|
12584
|
+
F3.printFilter(triple, () => {
|
|
12585
|
+
PRINT_WORD(".");
|
|
12586
|
+
NEW_LINE();
|
|
12587
|
+
});
|
|
12406
12588
|
} else {
|
|
12407
12589
|
SUBRULE(graphNodePath, triple.subject);
|
|
12408
12590
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
@@ -12414,11 +12596,17 @@ var triplesBlock = {
|
|
|
12414
12596
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12415
12597
|
SUBRULE(graphNodePath, triple.object);
|
|
12416
12598
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12417
|
-
F3.printFilter(ast, () =>
|
|
12599
|
+
F3.printFilter(ast, () => {
|
|
12600
|
+
PRINT_WORD(".");
|
|
12601
|
+
NEW_LINE();
|
|
12602
|
+
});
|
|
12418
12603
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12419
12604
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
12420
12605
|
} else {
|
|
12421
|
-
F3.printFilter(ast, () =>
|
|
12606
|
+
F3.printFilter(ast, () => {
|
|
12607
|
+
PRINT_WORD(";");
|
|
12608
|
+
NEW_LINE();
|
|
12609
|
+
});
|
|
12422
12610
|
}
|
|
12423
12611
|
}
|
|
12424
12612
|
});
|
|
@@ -12551,10 +12739,10 @@ function collectionImpl(name, allowPaths) {
|
|
|
12551
12739
|
return ACTION(() => {
|
|
12552
12740
|
const F3 = C.astFactory;
|
|
12553
12741
|
const triples = [];
|
|
12554
|
-
const predFirst = F3.
|
|
12555
|
-
const predRest = F3.
|
|
12556
|
-
const predNil = F3.
|
|
12557
|
-
const listHead = F3.
|
|
12742
|
+
const predFirst = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12743
|
+
const predRest = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
12744
|
+
const predNil = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
|
|
12745
|
+
const listHead = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12558
12746
|
let iterHead = listHead;
|
|
12559
12747
|
for (const [index, term] of terms.entries()) {
|
|
12560
12748
|
const lastInList = index === terms.length - 1;
|
|
@@ -12564,7 +12752,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12564
12752
|
const nilTriple = F3.triple(iterHead, predRest, predNil);
|
|
12565
12753
|
triples.push(nilTriple);
|
|
12566
12754
|
} else {
|
|
12567
|
-
const tail = F3.
|
|
12755
|
+
const tail = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12568
12756
|
const linkTriple = F3.triple(iterHead, predRest, tail);
|
|
12569
12757
|
triples.push(linkTriple);
|
|
12570
12758
|
iterHead = tail;
|
|
@@ -12604,16 +12792,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12604
12792
|
name,
|
|
12605
12793
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12606
12794
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12607
|
-
const blankNode2 = ACTION(() => C.astFactory.
|
|
12795
|
+
const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12608
12796
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12609
12797
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12610
12798
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12611
12799
|
},
|
|
12612
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
12800
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
12613
12801
|
const { astFactory: F3, indentInc } = c;
|
|
12614
12802
|
F3.printFilter(ast, () => {
|
|
12615
12803
|
c[traqulaIndentation] += indentInc;
|
|
12616
|
-
PRINT("[
|
|
12804
|
+
PRINT("[");
|
|
12805
|
+
NEW_LINE();
|
|
12617
12806
|
});
|
|
12618
12807
|
for (const triple of ast.triples) {
|
|
12619
12808
|
HANDLE_LOC(triple, () => {
|
|
@@ -12624,7 +12813,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12624
12813
|
}
|
|
12625
12814
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12626
12815
|
SUBRULE(graphNodePath, triple.object);
|
|
12627
|
-
F3.printFilter(ast, () =>
|
|
12816
|
+
F3.printFilter(ast, () => {
|
|
12817
|
+
PRINT_WORD(";");
|
|
12818
|
+
NEW_LINE();
|
|
12819
|
+
});
|
|
12628
12820
|
});
|
|
12629
12821
|
}
|
|
12630
12822
|
F3.printFilter(ast, () => {
|
|
@@ -12683,18 +12875,19 @@ var groupGraphPattern = {
|
|
|
12683
12875
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12684
12876
|
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12685
12877
|
},
|
|
12686
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
12878
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12687
12879
|
const { astFactory: F3, indentInc } = C;
|
|
12688
12880
|
F3.printFilter(ast, () => {
|
|
12689
12881
|
C[traqulaIndentation] += indentInc;
|
|
12690
|
-
PRINT_WORD("{
|
|
12882
|
+
PRINT_WORD("{");
|
|
12883
|
+
NEW_LINE();
|
|
12691
12884
|
});
|
|
12692
12885
|
for (const pattern of ast.patterns) {
|
|
12693
12886
|
SUBRULE(generatePattern, pattern);
|
|
12694
12887
|
}
|
|
12695
12888
|
F3.printFilter(ast, () => {
|
|
12696
12889
|
C[traqulaIndentation] -= indentInc;
|
|
12697
|
-
|
|
12890
|
+
PRINT_ON_OWN_LINE("}");
|
|
12698
12891
|
});
|
|
12699
12892
|
}
|
|
12700
12893
|
};
|
|
@@ -12844,12 +13037,15 @@ var bind2 = {
|
|
|
12844
13037
|
const close = CONSUME(symbols_exports.RParen);
|
|
12845
13038
|
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
12846
13039
|
},
|
|
12847
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13040
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12848
13041
|
F3.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
12849
13042
|
SUBRULE(expression, ast.expression);
|
|
12850
13043
|
F3.printFilter(ast, () => PRINT_WORD("AS"));
|
|
12851
13044
|
SUBRULE(var_, ast.variable);
|
|
12852
|
-
F3.printFilter(ast, () =>
|
|
13045
|
+
F3.printFilter(ast, () => {
|
|
13046
|
+
PRINT_WORD(")");
|
|
13047
|
+
NEW_LINE();
|
|
13048
|
+
});
|
|
12853
13049
|
}
|
|
12854
13050
|
};
|
|
12855
13051
|
var inlineData = {
|
|
@@ -12857,34 +13053,46 @@ var inlineData = {
|
|
|
12857
13053
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12858
13054
|
const values3 = CONSUME(values2);
|
|
12859
13055
|
const datablock = SUBRULE(dataBlock);
|
|
12860
|
-
return ACTION(() =>
|
|
13056
|
+
return ACTION(() => {
|
|
13057
|
+
datablock.loc = C.astFactory.sourceLocation(values3, datablock);
|
|
13058
|
+
return datablock;
|
|
13059
|
+
});
|
|
12861
13060
|
},
|
|
12862
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13061
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12863
13062
|
const { astFactory: F3, indentInc } = C;
|
|
12864
|
-
const variables =
|
|
13063
|
+
const variables = ast.variables;
|
|
13064
|
+
const singleVar = variables.length === 1;
|
|
13065
|
+
F3.printFilter(ast, () => {
|
|
13066
|
+
PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
|
|
13067
|
+
});
|
|
13068
|
+
for (const variable of variables) {
|
|
13069
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13070
|
+
SUBRULE(varOrTerm, variable);
|
|
13071
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13072
|
+
}
|
|
12865
13073
|
F3.printFilter(ast, () => {
|
|
12866
|
-
PRINT_ON_EMPTY("");
|
|
12867
|
-
PRINT_WORD("VALUES", "(");
|
|
12868
|
-
for (const variable of variables) {
|
|
12869
|
-
PRINT_WORD(`?${variable}`);
|
|
12870
|
-
}
|
|
12871
13074
|
C[traqulaIndentation] += indentInc;
|
|
12872
|
-
PRINT_WORD(")", "{
|
|
13075
|
+
PRINT_WORD(singleVar ? "" : ")", "{");
|
|
13076
|
+
NEW_LINE();
|
|
12873
13077
|
});
|
|
12874
13078
|
for (const mapping of ast.values) {
|
|
12875
|
-
F3.printFilter(ast, () => PRINT_WORD("("));
|
|
13079
|
+
F3.printFilter(ast, () => !singleVar && PRINT_WORD("("));
|
|
12876
13080
|
for (const variable of variables) {
|
|
12877
|
-
|
|
13081
|
+
const var_2 = variable.value;
|
|
13082
|
+
if (mapping[var_2] === void 0) {
|
|
12878
13083
|
F3.printFilter(ast, () => PRINT_WORD("UNDEF"));
|
|
12879
13084
|
} else {
|
|
12880
|
-
SUBRULE(graphNodePath, mapping[
|
|
13085
|
+
SUBRULE(graphNodePath, mapping[var_2]);
|
|
12881
13086
|
}
|
|
12882
13087
|
}
|
|
12883
|
-
F3.printFilter(ast, () =>
|
|
13088
|
+
F3.printFilter(ast, () => {
|
|
13089
|
+
PRINT_WORD(singleVar ? "" : ")");
|
|
13090
|
+
NEW_LINE();
|
|
13091
|
+
});
|
|
12884
13092
|
}
|
|
12885
13093
|
F3.printFilter(ast, () => {
|
|
12886
13094
|
C[traqulaIndentation] -= indentInc;
|
|
12887
|
-
|
|
13095
|
+
PRINT_ON_OWN_LINE("}");
|
|
12888
13096
|
});
|
|
12889
13097
|
}
|
|
12890
13098
|
};
|
|
@@ -12908,7 +13116,7 @@ var inlineDataOneVar = {
|
|
|
12908
13116
|
});
|
|
12909
13117
|
});
|
|
12910
13118
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12911
|
-
return ACTION(() => C.astFactory.
|
|
13119
|
+
return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
|
|
12912
13120
|
}
|
|
12913
13121
|
};
|
|
12914
13122
|
var inlineDataFull = {
|
|
@@ -12925,7 +13133,7 @@ var inlineDataFull = {
|
|
|
12925
13133
|
res.push({});
|
|
12926
13134
|
});
|
|
12927
13135
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
12928
|
-
return ACTION(() => C.astFactory.
|
|
13136
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
|
|
12929
13137
|
} },
|
|
12930
13138
|
{ ALT: () => {
|
|
12931
13139
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -12957,7 +13165,7 @@ var inlineDataFull = {
|
|
|
12957
13165
|
});
|
|
12958
13166
|
});
|
|
12959
13167
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
12960
|
-
return ACTION(() => C.astFactory.
|
|
13168
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
|
|
12961
13169
|
} }
|
|
12962
13170
|
]);
|
|
12963
13171
|
}
|
|
@@ -13020,10 +13228,13 @@ var filter3 = {
|
|
|
13020
13228
|
const expression2 = SUBRULE(constraint);
|
|
13021
13229
|
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
13022
13230
|
},
|
|
13023
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13231
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13024
13232
|
F3.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
13025
13233
|
SUBRULE(expression, ast.expression);
|
|
13026
|
-
F3.printFilter(ast, () =>
|
|
13234
|
+
F3.printFilter(ast, () => {
|
|
13235
|
+
PRINT_WORD(")");
|
|
13236
|
+
NEW_LINE();
|
|
13237
|
+
});
|
|
13027
13238
|
}
|
|
13028
13239
|
};
|
|
13029
13240
|
var constraint = {
|
|
@@ -13409,8 +13620,7 @@ var groupClause = {
|
|
|
13409
13620
|
},
|
|
13410
13621
|
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13411
13622
|
F3.printFilter(ast, () => {
|
|
13412
|
-
PRINT_ON_EMPTY("");
|
|
13413
|
-
PRINT_WORDS("GROUP", "BY");
|
|
13623
|
+
PRINT_ON_EMPTY("GROUP BY ");
|
|
13414
13624
|
});
|
|
13415
13625
|
for (const grouping of ast.groupings) {
|
|
13416
13626
|
if (F3.isExpression(grouping)) {
|
|
@@ -13466,10 +13676,9 @@ var havingClause = {
|
|
|
13466
13676
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13467
13677
|
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13468
13678
|
},
|
|
13469
|
-
gImpl: ({
|
|
13679
|
+
gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13470
13680
|
F3.printFilter(ast, () => {
|
|
13471
|
-
PRINT_ON_EMPTY("");
|
|
13472
|
-
PRINT_WORD("HAVING");
|
|
13681
|
+
PRINT_ON_EMPTY("HAVING ");
|
|
13473
13682
|
});
|
|
13474
13683
|
for (const having2 of ast.having) {
|
|
13475
13684
|
SUBRULE(expression, having2);
|
|
@@ -13495,8 +13704,7 @@ var orderClause = {
|
|
|
13495
13704
|
},
|
|
13496
13705
|
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13497
13706
|
F3.printFilter(ast, () => {
|
|
13498
|
-
PRINT_ON_EMPTY("");
|
|
13499
|
-
PRINT_WORDS("ORDER", "BY");
|
|
13707
|
+
PRINT_ON_EMPTY("ORDER BY ");
|
|
13500
13708
|
});
|
|
13501
13709
|
for (const ordering of ast.orderDefs) {
|
|
13502
13710
|
if (ordering.descending) {
|
|
@@ -13555,9 +13763,9 @@ var limitOffsetClauses = {
|
|
|
13555
13763
|
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13556
13764
|
} }
|
|
13557
13765
|
]),
|
|
13558
|
-
gImpl: ({ PRINT_WORDS,
|
|
13766
|
+
gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13559
13767
|
F3.printFilter(ast, () => {
|
|
13560
|
-
|
|
13768
|
+
NEW_LINE();
|
|
13561
13769
|
if (ast.limit) {
|
|
13562
13770
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13563
13771
|
}
|
|
@@ -13742,9 +13950,9 @@ var selectClause = {
|
|
|
13742
13950
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13743
13951
|
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13744
13952
|
},
|
|
13745
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13953
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13746
13954
|
F3.printFilter(ast, () => {
|
|
13747
|
-
|
|
13955
|
+
PRINT_ON_EMPTY("SELECT ");
|
|
13748
13956
|
if (ast.val.distinct) {
|
|
13749
13957
|
PRINT_WORD("DISTINCT");
|
|
13750
13958
|
} else if (ast.val.reduced) {
|
|
@@ -13763,7 +13971,9 @@ var selectClause = {
|
|
|
13763
13971
|
SUBRULE(var_, variable.variable);
|
|
13764
13972
|
F3.printFilter(ast, () => PRINT_WORD(")"));
|
|
13765
13973
|
}
|
|
13974
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13766
13975
|
}
|
|
13976
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13767
13977
|
}
|
|
13768
13978
|
};
|
|
13769
13979
|
var constructQuery = {
|
|
@@ -13801,18 +14011,19 @@ var constructQuery = {
|
|
|
13801
14011
|
} }
|
|
13802
14012
|
]);
|
|
13803
14013
|
},
|
|
13804
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14014
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
13805
14015
|
const { astFactory: F3, indentInc } = C;
|
|
13806
|
-
F3.printFilter(ast, () =>
|
|
14016
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
|
|
13807
14017
|
if (!F3.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
13808
14018
|
F3.printFilter(ast, () => {
|
|
13809
14019
|
C[traqulaIndentation] += indentInc;
|
|
13810
|
-
PRINT_WORD("{
|
|
14020
|
+
PRINT_WORD("{");
|
|
14021
|
+
NEW_LINE();
|
|
13811
14022
|
});
|
|
13812
14023
|
SUBRULE(triplesBlock, ast.template);
|
|
13813
14024
|
F3.printFilter(ast, () => {
|
|
13814
14025
|
C[traqulaIndentation] -= indentInc;
|
|
13815
|
-
|
|
14026
|
+
PRINT_ON_OWN_LINE("}");
|
|
13816
14027
|
});
|
|
13817
14028
|
}
|
|
13818
14029
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
@@ -13853,8 +14064,8 @@ var describeQuery = {
|
|
|
13853
14064
|
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13854
14065
|
}));
|
|
13855
14066
|
},
|
|
13856
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13857
|
-
F3.printFilter(ast, () =>
|
|
14067
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14068
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
|
|
13858
14069
|
if (F3.isWildcard(ast.variables[0])) {
|
|
13859
14070
|
F3.printFilter(ast, () => PRINT_WORD("*"));
|
|
13860
14071
|
} else {
|
|
@@ -13884,8 +14095,8 @@ var askQuery = {
|
|
|
13884
14095
|
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
13885
14096
|
}));
|
|
13886
14097
|
},
|
|
13887
|
-
gImpl: ({ SUBRULE,
|
|
13888
|
-
F3.printFilter(ast, () =>
|
|
14098
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14099
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
|
|
13889
14100
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
13890
14101
|
SUBRULE(whereClause, F3.wrap(ast.where, ast.loc));
|
|
13891
14102
|
SUBRULE(solutionModifier, ast.solutionModifiers);
|
|
@@ -13944,7 +14155,7 @@ var update = {
|
|
|
13944
14155
|
return update2;
|
|
13945
14156
|
});
|
|
13946
14157
|
},
|
|
13947
|
-
gImpl: ({ SUBRULE,
|
|
14158
|
+
gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13948
14159
|
const [head2, ...tail] = ast.updates;
|
|
13949
14160
|
if (head2) {
|
|
13950
14161
|
SUBRULE(prologue, head2.context);
|
|
@@ -13953,7 +14164,10 @@ var update = {
|
|
|
13953
14164
|
}
|
|
13954
14165
|
}
|
|
13955
14166
|
for (const update2 of tail) {
|
|
13956
|
-
F3.printFilter(ast, () =>
|
|
14167
|
+
F3.printFilter(ast, () => {
|
|
14168
|
+
PRINT(";");
|
|
14169
|
+
NEW_LINE();
|
|
14170
|
+
});
|
|
13957
14171
|
SUBRULE(prologue, update2.context);
|
|
13958
14172
|
if (update2.operation) {
|
|
13959
14173
|
SUBRULE(update1, update2.operation);
|
|
@@ -14026,9 +14240,9 @@ var load2 = {
|
|
|
14026
14240
|
});
|
|
14027
14241
|
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
14028
14242
|
},
|
|
14029
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14243
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14030
14244
|
F3.printFilter(ast, () => {
|
|
14031
|
-
|
|
14245
|
+
PRINT_ON_EMPTY("LOAD ");
|
|
14032
14246
|
if (ast.silent) {
|
|
14033
14247
|
PRINT_WORD("SILENT");
|
|
14034
14248
|
}
|
|
@@ -14049,9 +14263,9 @@ function clearOrDrop(operation) {
|
|
|
14049
14263
|
const destination = SUBRULE1(graphRefAll);
|
|
14050
14264
|
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
14051
14265
|
},
|
|
14052
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14266
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14053
14267
|
F3.printFilter(ast, () => {
|
|
14054
|
-
|
|
14268
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14055
14269
|
if (ast.silent) {
|
|
14056
14270
|
PRINT_WORD("SILENT");
|
|
14057
14271
|
}
|
|
@@ -14070,9 +14284,9 @@ var create2 = {
|
|
|
14070
14284
|
const destination = SUBRULE1(graphRef);
|
|
14071
14285
|
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
14072
14286
|
},
|
|
14073
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14287
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14074
14288
|
F3.printFilter(ast, () => {
|
|
14075
|
-
|
|
14289
|
+
PRINT_ON_EMPTY("CREATE ");
|
|
14076
14290
|
if (ast.silent) {
|
|
14077
14291
|
PRINT_WORD("SILENT");
|
|
14078
14292
|
}
|
|
@@ -14091,9 +14305,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14091
14305
|
const destination = SUBRULE2(graphOrDefault);
|
|
14092
14306
|
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14093
14307
|
},
|
|
14094
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14308
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14095
14309
|
F3.printFilter(ast, () => {
|
|
14096
|
-
|
|
14310
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14097
14311
|
if (ast.silent) {
|
|
14098
14312
|
PRINT_WORD("SILENT");
|
|
14099
14313
|
}
|
|
@@ -14142,23 +14356,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
|
|
|
14142
14356
|
}
|
|
14143
14357
|
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14144
14358
|
},
|
|
14145
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14359
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14146
14360
|
const { astFactory: F3, indentInc } = C;
|
|
14147
14361
|
F3.printFilter(ast, () => {
|
|
14148
|
-
C[traqulaIndentation] += indentInc;
|
|
14149
14362
|
if (subType === "insertdata") {
|
|
14150
|
-
|
|
14363
|
+
PRINT_ON_EMPTY("INSERT DATA ");
|
|
14151
14364
|
} else if (subType === "deletedata") {
|
|
14152
|
-
|
|
14365
|
+
PRINT_ON_EMPTY("DELETE DATA ");
|
|
14153
14366
|
} else if (subType === "deletewhere") {
|
|
14154
|
-
|
|
14367
|
+
PRINT_ON_EMPTY("DELETE WHERE ");
|
|
14155
14368
|
}
|
|
14156
|
-
|
|
14369
|
+
C[traqulaIndentation] += indentInc;
|
|
14370
|
+
PRINT_WORD("{");
|
|
14371
|
+
NEW_LINE();
|
|
14157
14372
|
});
|
|
14158
14373
|
SUBRULE(quads, F3.wrap(ast.data, ast.loc));
|
|
14159
14374
|
F3.printFilter(ast, () => {
|
|
14160
14375
|
C[traqulaIndentation] -= indentInc;
|
|
14161
|
-
|
|
14376
|
+
PRINT_ON_OWN_LINE("}");
|
|
14162
14377
|
});
|
|
14163
14378
|
}
|
|
14164
14379
|
};
|
|
@@ -14190,36 +14405,40 @@ var modify = {
|
|
|
14190
14405
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14191
14406
|
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14192
14407
|
},
|
|
14193
|
-
gImpl: ({ SUBRULE,
|
|
14408
|
+
gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
|
|
14194
14409
|
const { astFactory: F3, indentInc } = C;
|
|
14195
14410
|
if (ast.graph) {
|
|
14196
|
-
F3.printFilter(ast, () =>
|
|
14411
|
+
F3.printFilter(ast, () => PRINT_WORDS("WITH"));
|
|
14197
14412
|
SUBRULE(iri2, ast.graph);
|
|
14198
14413
|
}
|
|
14199
14414
|
if (ast.delete.length > 0) {
|
|
14200
14415
|
F3.printFilter(ast, () => {
|
|
14201
14416
|
C[traqulaIndentation] += indentInc;
|
|
14202
|
-
|
|
14417
|
+
PRINT_WORDS("DELETE", "{");
|
|
14418
|
+
NEW_LINE();
|
|
14203
14419
|
});
|
|
14204
14420
|
SUBRULE(quads, F3.wrap(ast.delete, ast.loc));
|
|
14205
14421
|
F3.printFilter(ast, () => {
|
|
14206
14422
|
C[traqulaIndentation] -= indentInc;
|
|
14207
|
-
PRINT_ON_EMPTY("}
|
|
14423
|
+
PRINT_ON_EMPTY("}");
|
|
14424
|
+
NEW_LINE();
|
|
14208
14425
|
});
|
|
14209
14426
|
}
|
|
14210
14427
|
if (ast.insert.length > 0) {
|
|
14211
14428
|
F3.printFilter(ast, () => {
|
|
14212
14429
|
C[traqulaIndentation] += indentInc;
|
|
14213
|
-
|
|
14430
|
+
PRINT_WORDS("INSERT", "{");
|
|
14431
|
+
NEW_LINE();
|
|
14214
14432
|
});
|
|
14215
14433
|
SUBRULE(quads, F3.wrap(ast.insert, ast.loc));
|
|
14216
14434
|
F3.printFilter(ast, () => {
|
|
14217
14435
|
C[traqulaIndentation] -= indentInc;
|
|
14218
|
-
PRINT_ON_EMPTY("}
|
|
14436
|
+
PRINT_ON_EMPTY("} ");
|
|
14437
|
+
NEW_LINE();
|
|
14219
14438
|
});
|
|
14220
14439
|
}
|
|
14221
14440
|
SUBRULE(usingClauseStar, ast.from);
|
|
14222
|
-
F3.printFilter(ast, () =>
|
|
14441
|
+
F3.printFilter(ast, () => PRINT_WORDS("WHERE"));
|
|
14223
14442
|
SUBRULE(groupGraphPattern, ast.where);
|
|
14224
14443
|
}
|
|
14225
14444
|
};
|
|
@@ -14343,18 +14562,19 @@ var quadsNotTriples = {
|
|
|
14343
14562
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14344
14563
|
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14345
14564
|
},
|
|
14346
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
14565
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14347
14566
|
const { astFactory: F3, indentInc } = C;
|
|
14348
14567
|
F3.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14349
14568
|
SUBRULE(varOrTerm, ast.graph);
|
|
14350
14569
|
F3.printFilter(ast, () => {
|
|
14351
14570
|
C[traqulaIndentation] += indentInc;
|
|
14352
|
-
PRINT_WORD("{
|
|
14571
|
+
PRINT_WORD("{");
|
|
14572
|
+
NEW_LINE();
|
|
14353
14573
|
});
|
|
14354
14574
|
SUBRULE(triplesBlock, ast.triples);
|
|
14355
14575
|
F3.printFilter(ast, () => {
|
|
14356
14576
|
C[traqulaIndentation] -= indentInc;
|
|
14357
|
-
|
|
14577
|
+
PRINT_ON_OWN_LINE("}");
|
|
14358
14578
|
});
|
|
14359
14579
|
}
|
|
14360
14580
|
};
|
|
@@ -14494,7 +14714,7 @@ var AstFactory2 = class extends AstFactory {
|
|
|
14494
14714
|
type: "tripleCollection",
|
|
14495
14715
|
subType: "reifiedTriple",
|
|
14496
14716
|
triples: [this.triple(subject, predicate, object3)],
|
|
14497
|
-
identifier: reifier2 ?? this.
|
|
14717
|
+
identifier: reifier2 ?? this.termBlank(void 0, this.sourceLocationNoMaterialize()),
|
|
14498
14718
|
loc
|
|
14499
14719
|
};
|
|
14500
14720
|
}
|
|
@@ -14640,9 +14860,9 @@ var versionDecl = {
|
|
|
14640
14860
|
const identifier = SUBRULE(versionSpecifier);
|
|
14641
14861
|
return ACTION(() => C.astFactory.contextDefinitionVersion(identifier.val, C.astFactory.sourceLocation(versionToken, identifier)));
|
|
14642
14862
|
},
|
|
14643
|
-
gImpl: ({
|
|
14863
|
+
gImpl: ({ PRINT_ON_OWN_LINE }) => (ast, { astFactory: F3 }) => {
|
|
14644
14864
|
F3.printFilter(ast, () => {
|
|
14645
|
-
|
|
14865
|
+
PRINT_ON_OWN_LINE("VERSION ", `${grammar_exports.stringEscapedLexical(ast.version)}`);
|
|
14646
14866
|
});
|
|
14647
14867
|
}
|
|
14648
14868
|
};
|
|
@@ -14709,7 +14929,7 @@ var reifier = {
|
|
|
14709
14929
|
if (reifier2 === void 0 && !C.parseMode.has("canCreateBlankNodes")) {
|
|
14710
14930
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
14711
14931
|
}
|
|
14712
|
-
return C.astFactory.wrap(reifier2 ?? C.astFactory.
|
|
14932
|
+
return C.astFactory.wrap(reifier2 ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation()), C.astFactory.sourceLocation(tildeToken, reifier2));
|
|
14713
14933
|
});
|
|
14714
14934
|
}
|
|
14715
14935
|
};
|
|
@@ -14768,7 +14988,7 @@ function annotationImpl(name, allowPaths) {
|
|
|
14768
14988
|
if (!currentReifier && !C.parseMode.has("canCreateBlankNodes")) {
|
|
14769
14989
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
14770
14990
|
}
|
|
14771
|
-
currentReifier = currentReifier ?? C.astFactory.
|
|
14991
|
+
currentReifier = currentReifier ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation());
|
|
14772
14992
|
});
|
|
14773
14993
|
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, currentReifier);
|
|
14774
14994
|
ACTION(() => {
|
|
@@ -14803,13 +15023,13 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
14803
15023
|
const close = CONSUME(annotationClose);
|
|
14804
15024
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(arg, res, C.astFactory.sourceLocation(open, close)));
|
|
14805
15025
|
},
|
|
14806
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC,
|
|
15026
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14807
15027
|
const { astFactory: F3, indentInc } = C;
|
|
14808
15028
|
F3.printFilter(ast, () => {
|
|
14809
15029
|
PRINT_WORD("{|");
|
|
14810
15030
|
if (ast.triples.length > 1) {
|
|
14811
15031
|
C[traqulaIndentation] += indentInc;
|
|
14812
|
-
|
|
15032
|
+
NEW_LINE();
|
|
14813
15033
|
}
|
|
14814
15034
|
});
|
|
14815
15035
|
function printTriple(triple) {
|
|
@@ -14819,18 +15039,22 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
14819
15039
|
} else {
|
|
14820
15040
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
14821
15041
|
}
|
|
15042
|
+
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
14822
15043
|
SUBRULE(graphNodePath2, triple.object);
|
|
14823
15044
|
});
|
|
14824
15045
|
}
|
|
14825
15046
|
const [head2, ...tail] = ast.triples;
|
|
14826
15047
|
printTriple(head2);
|
|
14827
15048
|
for (const triple of tail) {
|
|
14828
|
-
F3.printFilter(ast, () =>
|
|
15049
|
+
F3.printFilter(ast, () => {
|
|
15050
|
+
PRINT_WORD(";");
|
|
15051
|
+
NEW_LINE();
|
|
15052
|
+
});
|
|
14829
15053
|
printTriple(triple);
|
|
14830
15054
|
}
|
|
14831
15055
|
F3.printFilter(ast, () => {
|
|
14832
15056
|
if (ast.triples.length > 1) {
|
|
14833
|
-
|
|
15057
|
+
PRINT_ON_OWN_LINE("|}");
|
|
14834
15058
|
} else {
|
|
14835
15059
|
PRINT_WORD("|}");
|
|
14836
15060
|
}
|
|
@@ -14872,7 +15096,7 @@ var varOrTerm2 = {
|
|
|
14872
15096
|
{ ALT: () => SUBRULE(grammar_exports.blankNode) },
|
|
14873
15097
|
{ ALT: () => {
|
|
14874
15098
|
const token = CONSUME(lexer_exports.terminals.nil);
|
|
14875
|
-
return ACTION(() => C.astFactory.
|
|
15099
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.NIL));
|
|
14876
15100
|
} },
|
|
14877
15101
|
{ ALT: () => SUBRULE(tripleTerm) }
|
|
14878
15102
|
])
|
|
@@ -14898,11 +15122,13 @@ var reifiedTriple = {
|
|
|
14898
15122
|
F3.printFilter(ast, () => PRINT_WORD("<<"));
|
|
14899
15123
|
const triple = ast.triples[0];
|
|
14900
15124
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15125
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14901
15126
|
if (F3.isPathPure(triple.predicate)) {
|
|
14902
15127
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
14903
15128
|
} else {
|
|
14904
15129
|
SUBRULE(graphNodePath2, triple.predicate);
|
|
14905
15130
|
}
|
|
15131
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14906
15132
|
SUBRULE(graphNodePath2, triple.object);
|
|
14907
15133
|
SUBRULE(annotationPath, [F3.wrap(ast.identifier, ast.identifier.loc)]);
|
|
14908
15134
|
F3.printFilter(ast, () => PRINT_WORD(">>"));
|
|
@@ -14938,7 +15164,9 @@ var tripleTerm = {
|
|
|
14938
15164
|
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14939
15165
|
F3.printFilter(ast, () => PRINT_WORD("<<("));
|
|
14940
15166
|
SUBRULE(graphNodePath2, ast.subject);
|
|
15167
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14941
15168
|
SUBRULE(graphNodePath2, ast.predicate);
|
|
15169
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14942
15170
|
SUBRULE(graphNodePath2, ast.object);
|
|
14943
15171
|
F3.printFilter(ast, () => PRINT_WORD(")>>"));
|
|
14944
15172
|
}
|
|
@@ -14968,7 +15196,7 @@ var tripleTermData = {
|
|
|
14968
15196
|
{ ALT: () => SUBRULE(grammar_exports.iri) },
|
|
14969
15197
|
{ ALT: () => {
|
|
14970
15198
|
const token = CONSUME(lexer_exports.a);
|
|
14971
|
-
return ACTION(() => C.astFactory.
|
|
15199
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE));
|
|
14972
15200
|
} }
|
|
14973
15201
|
]);
|
|
14974
15202
|
const object3 = SUBRULE(tripleTermDataObject);
|
|
@@ -15055,7 +15283,7 @@ var rdfLiteral2 = {
|
|
|
15055
15283
|
{ ALT: () => {
|
|
15056
15284
|
const langTag2 = CONSUME(LANG_DIR);
|
|
15057
15285
|
return ACTION(() => {
|
|
15058
|
-
const literal = C.astFactory.
|
|
15286
|
+
const literal = C.astFactory.termLiteral(C.astFactory.sourceLocation(value, langTag2), value.value, langTag2.image.slice(1).toLowerCase());
|
|
15059
15287
|
langTagHasCorrectRange(literal);
|
|
15060
15288
|
return literal;
|
|
15061
15289
|
});
|
|
@@ -15063,7 +15291,7 @@ var rdfLiteral2 = {
|
|
|
15063
15291
|
{ ALT: () => {
|
|
15064
15292
|
CONSUME(lexer_exports.symbols.hathat);
|
|
15065
15293
|
const iriVal = SUBRULE(grammar_exports.iri);
|
|
15066
|
-
return ACTION(() => C.astFactory.
|
|
15294
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
15067
15295
|
} }
|
|
15068
15296
|
])) ?? value;
|
|
15069
15297
|
}
|
|
@@ -15089,13 +15317,16 @@ var unaryExpression2 = {
|
|
|
15089
15317
|
};
|
|
15090
15318
|
var generateTriplesBlock = {
|
|
15091
15319
|
name: "triplesBlock",
|
|
15092
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15320
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15093
15321
|
for (const [index, triple] of ast.triples.entries()) {
|
|
15094
15322
|
HANDLE_LOC(triple, () => {
|
|
15095
15323
|
const nextTriple = ast.triples.at(index);
|
|
15096
15324
|
if (F3.isTripleCollection(triple)) {
|
|
15097
15325
|
SUBRULE(graphNodePath2, triple);
|
|
15098
|
-
F3.printFilter(triple, () =>
|
|
15326
|
+
F3.printFilter(triple, () => {
|
|
15327
|
+
PRINT_WORD(".");
|
|
15328
|
+
NEW_LINE();
|
|
15329
|
+
});
|
|
15099
15330
|
} else {
|
|
15100
15331
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15101
15332
|
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
@@ -15108,11 +15339,17 @@ var generateTriplesBlock = {
|
|
|
15108
15339
|
SUBRULE(graphNodePath2, triple.object);
|
|
15109
15340
|
SUBRULE(annotationPath, triple.annotations ?? []);
|
|
15110
15341
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
15111
|
-
F3.printFilter(ast, () =>
|
|
15342
|
+
F3.printFilter(ast, () => {
|
|
15343
|
+
PRINT_WORD(".");
|
|
15344
|
+
NEW_LINE();
|
|
15345
|
+
});
|
|
15112
15346
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
15113
15347
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
15114
15348
|
} else {
|
|
15115
|
-
F3.printFilter(ast, () =>
|
|
15349
|
+
F3.printFilter(ast, () => {
|
|
15350
|
+
PRINT_WORD(";");
|
|
15351
|
+
NEW_LINE();
|
|
15352
|
+
});
|
|
15116
15353
|
}
|
|
15117
15354
|
}
|
|
15118
15355
|
});
|
|
@@ -15144,7 +15381,7 @@ function completeParseContext(context) {
|
|
|
15144
15381
|
[traqulaIndentation]: context[traqulaIndentation] ?? 0
|
|
15145
15382
|
};
|
|
15146
15383
|
}
|
|
15147
|
-
var AstTransformer2 = class extends
|
|
15384
|
+
var AstTransformer2 = class extends TransformerSubTyped {
|
|
15148
15385
|
};
|
|
15149
15386
|
/*! Bundled license information:
|
|
15150
15387
|
|