@traqula/parser-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/Parser.d.ts +143 -143
- package/lib/Parser.js +2 -1
- package/lib/Parser.js.map +1 -1
- package/lib/index.cjs +440 -207
- package/package.json +10 -9
package/lib/index.cjs
CHANGED
|
@@ -42,7 +42,7 @@ var AstCoreFactory = class {
|
|
|
42
42
|
if (filtered.length === 0) {
|
|
43
43
|
return this.gen();
|
|
44
44
|
}
|
|
45
|
-
const first2 = filtered
|
|
45
|
+
const first2 = filtered.at(0);
|
|
46
46
|
const last2 = filtered.at(-1);
|
|
47
47
|
return {
|
|
48
48
|
sourceLocationType: "source",
|
|
@@ -9655,6 +9655,9 @@ var ParserBuilder = class _ParserBuilder {
|
|
|
9655
9655
|
delete this.rules[ruleName];
|
|
9656
9656
|
return this;
|
|
9657
9657
|
}
|
|
9658
|
+
getRule(ruleName) {
|
|
9659
|
+
return this.rules[ruleName];
|
|
9660
|
+
}
|
|
9658
9661
|
/**
|
|
9659
9662
|
* Merge this grammar builder with another.
|
|
9660
9663
|
* It is best to merge the bigger grammar with the smaller one.
|
|
@@ -9741,21 +9744,31 @@ ${firstError.message}`);
|
|
|
9741
9744
|
}
|
|
9742
9745
|
};
|
|
9743
9746
|
|
|
9744
|
-
// ../../packages/core/lib/
|
|
9745
|
-
var
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9747
|
+
// ../../packages/core/lib/TransformerObject.js
|
|
9748
|
+
var TransformerObject = class {
|
|
9749
|
+
defaultContext;
|
|
9750
|
+
maxStackSize = 1e6;
|
|
9751
|
+
/**
|
|
9752
|
+
* Creates stateless transformer.
|
|
9753
|
+
* @param defaultContext
|
|
9754
|
+
*/
|
|
9755
|
+
constructor(defaultContext = {}) {
|
|
9756
|
+
this.defaultContext = defaultContext;
|
|
9750
9757
|
}
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9758
|
+
/**
|
|
9759
|
+
* Function to shallow clone any type.
|
|
9760
|
+
* @param obj
|
|
9761
|
+
* @protected
|
|
9762
|
+
*/
|
|
9763
|
+
clone(obj) {
|
|
9764
|
+
if (obj === null || typeof obj !== "object") {
|
|
9765
|
+
return obj;
|
|
9757
9766
|
}
|
|
9758
|
-
|
|
9767
|
+
const proto = Object.getPrototypeOf(obj);
|
|
9768
|
+
if (proto === Object.prototype || proto === null) {
|
|
9769
|
+
return { ...obj };
|
|
9770
|
+
}
|
|
9771
|
+
return Object.assign(Object.create(proto), obj);
|
|
9759
9772
|
}
|
|
9760
9773
|
/**
|
|
9761
9774
|
* Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
|
|
@@ -9767,90 +9780,228 @@ var TransformerType = class {
|
|
|
9767
9780
|
* - Default false
|
|
9768
9781
|
*/
|
|
9769
9782
|
transformObject(startObject, mapper, preVisitor = () => ({})) {
|
|
9783
|
+
const defaults2 = this.defaultContext;
|
|
9784
|
+
const defaultCopyFlag = defaults2.copy ?? true;
|
|
9785
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9786
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9787
|
+
const defaultShallowKeys = defaults2.shallowKeys;
|
|
9788
|
+
const defaultDidShortCut = defaults2.shortcut ?? false;
|
|
9770
9789
|
let didShortCut = false;
|
|
9771
|
-
const
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9790
|
+
const resultWrap = { res: startObject };
|
|
9791
|
+
const stack = [startObject];
|
|
9792
|
+
const stackParent = [resultWrap];
|
|
9793
|
+
const stackParentKey = ["res"];
|
|
9794
|
+
const handleMapperOnLen = [];
|
|
9795
|
+
const mapperCopyStack = [];
|
|
9796
|
+
const mapperOrigStack = [];
|
|
9797
|
+
const mapperParent = [];
|
|
9798
|
+
const mapperParentKey = [];
|
|
9799
|
+
function handleMapper() {
|
|
9800
|
+
while (stack.length === handleMapperOnLen.at(-1)) {
|
|
9801
|
+
handleMapperOnLen.pop();
|
|
9802
|
+
const copyToMap = mapperCopyStack.pop();
|
|
9803
|
+
const origToMap = mapperOrigStack.pop();
|
|
9804
|
+
const parent = mapperParent.pop();
|
|
9805
|
+
const parentKey = mapperParentKey.pop();
|
|
9806
|
+
parent[parentKey] = mapper(copyToMap, origToMap);
|
|
9807
|
+
}
|
|
9808
|
+
}
|
|
9809
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9810
|
+
const curObject = stack.pop();
|
|
9811
|
+
const curParent = stackParent.pop();
|
|
9812
|
+
const curKey = stackParentKey.pop();
|
|
9813
|
+
if (!didShortCut) {
|
|
9814
|
+
if (Array.isArray(curObject)) {
|
|
9815
|
+
const newArr = [...curObject];
|
|
9816
|
+
handleMapperOnLen.push(stack.length);
|
|
9817
|
+
mapperCopyStack.push(newArr);
|
|
9818
|
+
mapperOrigStack.push(curObject);
|
|
9819
|
+
mapperParent.push(curParent);
|
|
9820
|
+
mapperParentKey.push(curKey);
|
|
9821
|
+
for (let index = curObject.length - 1; index >= 0; index--) {
|
|
9822
|
+
const val = curObject[index];
|
|
9823
|
+
if (val !== null && typeof val === "object") {
|
|
9824
|
+
stack.push(val);
|
|
9825
|
+
stackParent.push(newArr);
|
|
9826
|
+
stackParentKey.push(index.toString());
|
|
9827
|
+
}
|
|
9828
|
+
}
|
|
9829
|
+
handleMapper();
|
|
9830
|
+
continue;
|
|
9831
|
+
}
|
|
9832
|
+
const context = preVisitor(curObject);
|
|
9833
|
+
const copyFlag = context.copy ?? defaultCopyFlag;
|
|
9834
|
+
const continues = context.continue ?? defaultContinues;
|
|
9835
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9836
|
+
const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
|
|
9837
|
+
didShortCut = context.shortcut ?? defaultDidShortCut;
|
|
9838
|
+
const copy3 = copyFlag ? this.clone(curObject) : curObject;
|
|
9839
|
+
handleMapperOnLen.push(stack.length);
|
|
9840
|
+
mapperCopyStack.push(copy3);
|
|
9841
|
+
mapperOrigStack.push(curObject);
|
|
9842
|
+
mapperParent.push(curParent);
|
|
9843
|
+
mapperParentKey.push(curKey);
|
|
9844
|
+
if (continues && !didShortCut) {
|
|
9845
|
+
for (const key in copy3) {
|
|
9846
|
+
if (!Object.hasOwn(copy3, key)) {
|
|
9847
|
+
continue;
|
|
9848
|
+
}
|
|
9849
|
+
const val = copy3[key];
|
|
9850
|
+
const onlyShallow = shallowKeys && shallowKeys?.has(key);
|
|
9851
|
+
if (onlyShallow) {
|
|
9852
|
+
copy3[key] = this.clone(val);
|
|
9853
|
+
}
|
|
9854
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9855
|
+
continue;
|
|
9856
|
+
}
|
|
9857
|
+
if (!onlyShallow && val !== null && typeof val === "object") {
|
|
9858
|
+
stack.push(val);
|
|
9859
|
+
stackParentKey.push(key);
|
|
9860
|
+
stackParent.push(copy3);
|
|
9861
|
+
}
|
|
9780
9862
|
}
|
|
9781
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9782
9863
|
}
|
|
9783
9864
|
}
|
|
9784
|
-
|
|
9785
|
-
}
|
|
9786
|
-
|
|
9865
|
+
handleMapper();
|
|
9866
|
+
}
|
|
9867
|
+
if (stack.length >= this.maxStackSize) {
|
|
9868
|
+
throw new Error("Transform object stack overflowed");
|
|
9869
|
+
}
|
|
9870
|
+
handleMapper();
|
|
9871
|
+
return resultWrap.res;
|
|
9787
9872
|
}
|
|
9788
9873
|
/**
|
|
9789
9874
|
* Visitor that visits all objects. Visits deeper objects first.
|
|
9790
9875
|
*/
|
|
9791
9876
|
visitObject(startObject, visitor, preVisitor = () => ({})) {
|
|
9877
|
+
const defaults2 = this.defaultContext;
|
|
9878
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9879
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9880
|
+
const defaultShortcut = defaults2.shortcut ?? false;
|
|
9792
9881
|
let didShortCut = false;
|
|
9793
|
-
const
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9882
|
+
const stack = [startObject];
|
|
9883
|
+
const handleVisitorOnLen = [];
|
|
9884
|
+
const visitorStack = [];
|
|
9885
|
+
function handleVisitor() {
|
|
9886
|
+
while (stack.length === handleVisitorOnLen.at(-1)) {
|
|
9887
|
+
handleVisitorOnLen.pop();
|
|
9888
|
+
const toVisit = visitorStack.pop();
|
|
9889
|
+
visitor(toVisit);
|
|
9890
|
+
}
|
|
9891
|
+
}
|
|
9892
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9893
|
+
const curObject = stack.pop();
|
|
9894
|
+
if (!didShortCut) {
|
|
9895
|
+
if (Array.isArray(curObject)) {
|
|
9896
|
+
for (let i = curObject.length - 1; i >= 0; i--) {
|
|
9897
|
+
stack.push(curObject[i]);
|
|
9898
|
+
}
|
|
9899
|
+
handleVisitor();
|
|
9900
|
+
continue;
|
|
9901
|
+
}
|
|
9902
|
+
const context = preVisitor(curObject);
|
|
9903
|
+
didShortCut = context.shortcut ?? defaultShortcut;
|
|
9904
|
+
const continues = context.continue ?? defaultContinues;
|
|
9905
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9906
|
+
handleVisitorOnLen.push(stack.length);
|
|
9907
|
+
visitorStack.push(curObject);
|
|
9908
|
+
if (continues && !didShortCut) {
|
|
9909
|
+
for (const key in curObject) {
|
|
9910
|
+
if (!Object.hasOwn(curObject, key)) {
|
|
9911
|
+
continue;
|
|
9912
|
+
}
|
|
9913
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9914
|
+
continue;
|
|
9915
|
+
}
|
|
9916
|
+
const val = curObject[key];
|
|
9917
|
+
if (val && typeof val === "object") {
|
|
9918
|
+
stack.push(val);
|
|
9919
|
+
}
|
|
9801
9920
|
}
|
|
9802
|
-
this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9803
9921
|
}
|
|
9804
9922
|
}
|
|
9805
|
-
|
|
9806
|
-
}
|
|
9807
|
-
|
|
9923
|
+
handleVisitor();
|
|
9924
|
+
}
|
|
9925
|
+
if (stack.length >= this.maxStackSize) {
|
|
9926
|
+
throw new Error("Transform object stack overflowed");
|
|
9927
|
+
}
|
|
9928
|
+
handleVisitor();
|
|
9929
|
+
}
|
|
9930
|
+
};
|
|
9931
|
+
|
|
9932
|
+
// ../../packages/core/lib/TransformerTyped.js
|
|
9933
|
+
var TransformerTyped = class extends TransformerObject {
|
|
9934
|
+
defaultNodePreVisitor;
|
|
9935
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9936
|
+
super(defaultContext);
|
|
9937
|
+
this.defaultNodePreVisitor = defaultNodePreVisitor;
|
|
9808
9938
|
}
|
|
9939
|
+
/**
|
|
9940
|
+
* Transform a single node.
|
|
9941
|
+
* The transformation calls the preVisitor from starting from the startObject.
|
|
9942
|
+
* The preVisitor can dictate whether transformation should be stopped.
|
|
9943
|
+
* Note that stopping the transformation also prevets further copying.
|
|
9944
|
+
* The transformer itself transforms object starting with the deepest one that can be visited.
|
|
9945
|
+
* The transformer callback is performed on a copy of the original.
|
|
9946
|
+
* @param startObject
|
|
9947
|
+
* @param nodeCallBacks
|
|
9948
|
+
*/
|
|
9809
9949
|
transformNode(startObject, nodeCallBacks) {
|
|
9810
|
-
const transformWrapper = (
|
|
9811
|
-
|
|
9950
|
+
const transformWrapper = (copy3, orig) => {
|
|
9951
|
+
let ogTransform;
|
|
9952
|
+
const casted = copy3;
|
|
9812
9953
|
if (casted.type) {
|
|
9813
|
-
|
|
9814
|
-
if (ogFunc) {
|
|
9815
|
-
return ogFunc(casted);
|
|
9816
|
-
}
|
|
9954
|
+
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9817
9955
|
}
|
|
9818
|
-
return
|
|
9956
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9819
9957
|
};
|
|
9820
|
-
const
|
|
9958
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9959
|
+
const preVisitWrapper = (curObject) => {
|
|
9960
|
+
let ogPreVisit;
|
|
9961
|
+
let nodeContext = {};
|
|
9821
9962
|
const casted = curObject;
|
|
9822
9963
|
if (casted.type) {
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
return ogFunc(casted);
|
|
9826
|
-
}
|
|
9964
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9965
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9827
9966
|
}
|
|
9828
|
-
return {};
|
|
9967
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9829
9968
|
};
|
|
9830
|
-
return this.transformObject(startObject, transformWrapper,
|
|
9969
|
+
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9831
9970
|
}
|
|
9971
|
+
/**
|
|
9972
|
+
* Similar to {@link this.transformNode}, but without copying the startObject.
|
|
9973
|
+
* The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
|
|
9974
|
+
* @param startObject
|
|
9975
|
+
* @param nodeCallBacks
|
|
9976
|
+
*/
|
|
9832
9977
|
visitNode(startObject, nodeCallBacks) {
|
|
9833
|
-
const
|
|
9978
|
+
const visitorWrapper = (curObject) => {
|
|
9834
9979
|
const casted = curObject;
|
|
9835
9980
|
if (casted.type) {
|
|
9836
|
-
const
|
|
9837
|
-
if (
|
|
9838
|
-
|
|
9981
|
+
const ogTransform = nodeCallBacks[casted.type]?.visitor;
|
|
9982
|
+
if (ogTransform) {
|
|
9983
|
+
ogTransform(casted);
|
|
9839
9984
|
}
|
|
9840
9985
|
}
|
|
9841
9986
|
};
|
|
9987
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9842
9988
|
const preVisitWrapper = (curObject) => {
|
|
9989
|
+
let ogPreVisit;
|
|
9990
|
+
let nodeContext = {};
|
|
9843
9991
|
const casted = curObject;
|
|
9844
9992
|
if (casted.type) {
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
return ogFunc(casted);
|
|
9848
|
-
}
|
|
9993
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9994
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9849
9995
|
}
|
|
9850
|
-
return {};
|
|
9996
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9851
9997
|
};
|
|
9852
|
-
this.visitObject(startObject,
|
|
9998
|
+
return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
|
|
9853
9999
|
}
|
|
10000
|
+
/**
|
|
10001
|
+
* Traverses only selected nodes as returned by the function.
|
|
10002
|
+
* @param currentNode
|
|
10003
|
+
* @param traverse
|
|
10004
|
+
*/
|
|
9854
10005
|
traverseNodes(currentNode, traverse) {
|
|
9855
10006
|
let didShortCut = false;
|
|
9856
10007
|
const recurse = (curNode) => {
|
|
@@ -9871,11 +10022,24 @@ var TransformerType = class {
|
|
|
9871
10022
|
recurse(currentNode);
|
|
9872
10023
|
}
|
|
9873
10024
|
};
|
|
9874
|
-
|
|
10025
|
+
|
|
10026
|
+
// ../../packages/core/lib/TransformerSubTyped.js
|
|
10027
|
+
var TransformerSubTyped = class extends TransformerTyped {
|
|
10028
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
10029
|
+
super(defaultContext, defaultNodePreVisitor);
|
|
10030
|
+
}
|
|
10031
|
+
/**
|
|
10032
|
+
* Shares the functionality and first two arguments with {@link this.transformNode}.
|
|
10033
|
+
* The third argument allows you to also transform based on the subType of objects.
|
|
10034
|
+
* Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
|
|
10035
|
+
* @param startObject
|
|
10036
|
+
* @param nodeCallBacks
|
|
10037
|
+
* @param nodeSpecificCallBacks
|
|
10038
|
+
*/
|
|
9875
10039
|
transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9876
|
-
const transformWrapper = (
|
|
10040
|
+
const transformWrapper = (copy3, orig) => {
|
|
9877
10041
|
let ogTransform;
|
|
9878
|
-
const casted =
|
|
10042
|
+
const casted = copy3;
|
|
9879
10043
|
if (casted.type && casted.subType) {
|
|
9880
10044
|
const specific = nodeSpecificCallBacks[casted.type];
|
|
9881
10045
|
if (specific) {
|
|
@@ -9885,7 +10049,7 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9885
10049
|
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9886
10050
|
}
|
|
9887
10051
|
}
|
|
9888
|
-
return ogTransform ? ogTransform(casted) :
|
|
10052
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9889
10053
|
};
|
|
9890
10054
|
const preVisitWrapper = (curObject) => {
|
|
9891
10055
|
let ogPreVisit;
|
|
@@ -9899,12 +10063,13 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9899
10063
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9900
10064
|
}
|
|
9901
10065
|
}
|
|
9902
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10066
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9903
10067
|
};
|
|
9904
10068
|
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9905
10069
|
}
|
|
9906
10070
|
/**
|
|
9907
|
-
*
|
|
10071
|
+
* Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
|
|
10072
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
|
|
9908
10073
|
*/
|
|
9909
10074
|
visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9910
10075
|
const visitWrapper = (curObject) => {
|
|
@@ -9935,10 +10100,16 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9935
10100
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9936
10101
|
}
|
|
9937
10102
|
}
|
|
9938
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10103
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9939
10104
|
};
|
|
9940
10105
|
this.visitObject(startObject, visitWrapper, preVisitWrapper);
|
|
9941
10106
|
}
|
|
10107
|
+
/**
|
|
10108
|
+
* Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
|
|
10109
|
+
* @param currentNode
|
|
10110
|
+
* @param traverseNode
|
|
10111
|
+
* @param traverseSubNode
|
|
10112
|
+
*/
|
|
9942
10113
|
traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
|
|
9943
10114
|
let didShortCut = false;
|
|
9944
10115
|
const recurse = (curNode) => {
|
|
@@ -11011,8 +11182,8 @@ function PatternFactoryMixin(Base) {
|
|
|
11011
11182
|
isPatternOptional(obj) {
|
|
11012
11183
|
return this.isOfSubType(obj, nodeType5, "optional");
|
|
11013
11184
|
}
|
|
11014
|
-
patternValues(values3, loc) {
|
|
11015
|
-
return { type: nodeType5, subType: "values", values: values3, loc };
|
|
11185
|
+
patternValues(variables, values3, loc) {
|
|
11186
|
+
return { type: nodeType5, subType: "values", variables, values: values3, loc };
|
|
11016
11187
|
}
|
|
11017
11188
|
isPatternValues(obj) {
|
|
11018
11189
|
return this.isOfSubType(obj, nodeType5, "values");
|
|
@@ -11187,7 +11358,7 @@ function TermFactoryMixin(Base) {
|
|
|
11187
11358
|
isTerm(x) {
|
|
11188
11359
|
return this.isOfType(x, "term");
|
|
11189
11360
|
}
|
|
11190
|
-
|
|
11361
|
+
termBlank(label, loc) {
|
|
11191
11362
|
const base = {
|
|
11192
11363
|
type: "term",
|
|
11193
11364
|
subType: "blankNode",
|
|
@@ -11201,7 +11372,7 @@ function TermFactoryMixin(Base) {
|
|
|
11201
11372
|
isTermBlank(obj) {
|
|
11202
11373
|
return this.isOfSubType(obj, nodeType8, "blankNode");
|
|
11203
11374
|
}
|
|
11204
|
-
|
|
11375
|
+
termLiteral(loc, value, langOrIri) {
|
|
11205
11376
|
return {
|
|
11206
11377
|
type: nodeType8,
|
|
11207
11378
|
subType: "literal",
|
|
@@ -11223,7 +11394,7 @@ function TermFactoryMixin(Base) {
|
|
|
11223
11394
|
const casted = obj;
|
|
11224
11395
|
return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
|
|
11225
11396
|
}
|
|
11226
|
-
|
|
11397
|
+
termVariable(value, loc) {
|
|
11227
11398
|
return {
|
|
11228
11399
|
type: nodeType8,
|
|
11229
11400
|
subType: "variable",
|
|
@@ -11234,7 +11405,7 @@ function TermFactoryMixin(Base) {
|
|
|
11234
11405
|
isTermVariable(obj) {
|
|
11235
11406
|
return this.isOfSubType(obj, nodeType8, "variable");
|
|
11236
11407
|
}
|
|
11237
|
-
|
|
11408
|
+
termNamed(loc, value, prefix) {
|
|
11238
11409
|
const base = {
|
|
11239
11410
|
type: nodeType8,
|
|
11240
11411
|
subType: "namedNode",
|
|
@@ -11497,7 +11668,7 @@ var CommonIRIs;
|
|
|
11497
11668
|
CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
11498
11669
|
CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
11499
11670
|
})(CommonIRIs || (CommonIRIs = {}));
|
|
11500
|
-
var AstTransformer = class extends
|
|
11671
|
+
var AstTransformer = class extends TransformerSubTyped {
|
|
11501
11672
|
};
|
|
11502
11673
|
|
|
11503
11674
|
// ../../packages/rules-sparql-1-1/lib/validation/validators.js
|
|
@@ -11713,17 +11884,20 @@ var rdfLiteral = {
|
|
|
11713
11884
|
return OPTION(() => OR([
|
|
11714
11885
|
{ ALT: () => {
|
|
11715
11886
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11716
|
-
return ACTION(() => C.astFactory.
|
|
11887
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11717
11888
|
} },
|
|
11718
11889
|
{ ALT: () => {
|
|
11719
11890
|
CONSUME(symbols_exports.hathat);
|
|
11720
11891
|
const iriVal = SUBRULE1(iri2);
|
|
11721
|
-
return ACTION(() => C.astFactory.
|
|
11892
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11722
11893
|
} }
|
|
11723
11894
|
])) ?? value;
|
|
11724
11895
|
},
|
|
11725
|
-
gImpl: ({ SUBRULE, PRINT,
|
|
11726
|
-
astFactory.printFilter(ast, () =>
|
|
11896
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11897
|
+
astFactory.printFilter(ast, () => {
|
|
11898
|
+
PRINT_WORD("");
|
|
11899
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
11900
|
+
});
|
|
11727
11901
|
if (ast.langOrIri) {
|
|
11728
11902
|
if (typeof ast.langOrIri === "string") {
|
|
11729
11903
|
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
@@ -11750,7 +11924,7 @@ var numericLiteralUnsigned = {
|
|
|
11750
11924
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11751
11925
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11752
11926
|
]);
|
|
11753
|
-
return ACTION(() => C.astFactory.
|
|
11927
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11754
11928
|
}
|
|
11755
11929
|
};
|
|
11756
11930
|
var numericLiteralPositive = {
|
|
@@ -11761,7 +11935,7 @@ var numericLiteralPositive = {
|
|
|
11761
11935
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11762
11936
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11763
11937
|
]);
|
|
11764
|
-
return ACTION(() => C.astFactory.
|
|
11938
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11765
11939
|
}
|
|
11766
11940
|
};
|
|
11767
11941
|
var numericLiteralNegative = {
|
|
@@ -11772,7 +11946,7 @@ var numericLiteralNegative = {
|
|
|
11772
11946
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11773
11947
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11774
11948
|
]);
|
|
11775
|
-
return ACTION(() => C.astFactory.
|
|
11949
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11776
11950
|
}
|
|
11777
11951
|
};
|
|
11778
11952
|
var booleanLiteral = {
|
|
@@ -11782,7 +11956,7 @@ var booleanLiteral = {
|
|
|
11782
11956
|
{ ALT: () => CONSUME(true_) },
|
|
11783
11957
|
{ ALT: () => CONSUME(false_) }
|
|
11784
11958
|
]);
|
|
11785
|
-
return ACTION(() => C.astFactory.
|
|
11959
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11786
11960
|
}
|
|
11787
11961
|
};
|
|
11788
11962
|
var string = {
|
|
@@ -11824,7 +11998,7 @@ var string = {
|
|
|
11824
11998
|
return char;
|
|
11825
11999
|
}
|
|
11826
12000
|
});
|
|
11827
|
-
return F3.
|
|
12001
|
+
return F3.termLiteral(F3.sourceLocation(x[0]), value);
|
|
11828
12002
|
});
|
|
11829
12003
|
}
|
|
11830
12004
|
};
|
|
@@ -11840,7 +12014,7 @@ var iriFull = {
|
|
|
11840
12014
|
name: "iriFull",
|
|
11841
12015
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11842
12016
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11843
|
-
return ACTION(() => C.astFactory.
|
|
12017
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11844
12018
|
},
|
|
11845
12019
|
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
11846
12020
|
F3.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
@@ -11853,16 +12027,16 @@ var prefixedName = {
|
|
|
11853
12027
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11854
12028
|
return ACTION(() => {
|
|
11855
12029
|
const [prefix, localName] = longName.image.split(":");
|
|
11856
|
-
return C.astFactory.
|
|
12030
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11857
12031
|
});
|
|
11858
12032
|
} },
|
|
11859
12033
|
{ ALT: () => {
|
|
11860
12034
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11861
|
-
return ACTION(() => C.astFactory.
|
|
12035
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11862
12036
|
} }
|
|
11863
12037
|
]),
|
|
11864
|
-
gImpl: ({
|
|
11865
|
-
F3.printFilter(ast, () =>
|
|
12038
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
12039
|
+
F3.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
11866
12040
|
}
|
|
11867
12041
|
};
|
|
11868
12042
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11872,11 +12046,11 @@ var blankNode = {
|
|
|
11872
12046
|
const result = OR([
|
|
11873
12047
|
{ ALT: () => {
|
|
11874
12048
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11875
|
-
return ACTION(() => C.astFactory.
|
|
12049
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11876
12050
|
} },
|
|
11877
12051
|
{ ALT: () => {
|
|
11878
12052
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11879
|
-
return ACTION(() => C.astFactory.
|
|
12053
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11880
12054
|
} }
|
|
11881
12055
|
]);
|
|
11882
12056
|
ACTION(() => {
|
|
@@ -11886,15 +12060,15 @@ var blankNode = {
|
|
|
11886
12060
|
});
|
|
11887
12061
|
return result;
|
|
11888
12062
|
},
|
|
11889
|
-
gImpl: ({
|
|
11890
|
-
astFactory.printFilter(ast, () =>
|
|
12063
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
12064
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
11891
12065
|
}
|
|
11892
12066
|
};
|
|
11893
12067
|
var verbA = {
|
|
11894
12068
|
name: "VerbA",
|
|
11895
12069
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11896
12070
|
const token = CONSUME(a);
|
|
11897
|
-
return ACTION(() => C.astFactory.
|
|
12071
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11898
12072
|
}
|
|
11899
12073
|
};
|
|
11900
12074
|
|
|
@@ -11928,10 +12102,10 @@ var baseDecl2 = {
|
|
|
11928
12102
|
const val = SUBRULE(iriFull);
|
|
11929
12103
|
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11930
12104
|
},
|
|
11931
|
-
gImpl: ({ SUBRULE,
|
|
11932
|
-
F3.printFilter(ast, () =>
|
|
12105
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12106
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
|
|
11933
12107
|
SUBRULE(iri2, ast.value);
|
|
11934
|
-
F3.printFilter(ast, () =>
|
|
12108
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11935
12109
|
}
|
|
11936
12110
|
};
|
|
11937
12111
|
var prefixDecl2 = {
|
|
@@ -11942,12 +12116,12 @@ var prefixDecl2 = {
|
|
|
11942
12116
|
const value = SUBRULE(iriFull);
|
|
11943
12117
|
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11944
12118
|
},
|
|
11945
|
-
gImpl: ({ SUBRULE,
|
|
12119
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
11946
12120
|
F3.printFilter(ast, () => {
|
|
11947
|
-
|
|
12121
|
+
PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
|
|
11948
12122
|
});
|
|
11949
12123
|
SUBRULE(iri2, ast.value);
|
|
11950
|
-
F3.printFilter(ast, () =>
|
|
12124
|
+
F3.printFilter(ast, () => NEW_LINE());
|
|
11951
12125
|
}
|
|
11952
12126
|
};
|
|
11953
12127
|
var verb = {
|
|
@@ -11984,10 +12158,10 @@ var var_ = {
|
|
|
11984
12158
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11985
12159
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11986
12160
|
]);
|
|
11987
|
-
return ACTION(() => C.astFactory.
|
|
12161
|
+
return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11988
12162
|
},
|
|
11989
|
-
gImpl: ({
|
|
11990
|
-
F3.printFilter(ast, () =>
|
|
12163
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
|
|
12164
|
+
F3.printFilter(ast, () => PRINT(`?${ast.value}`));
|
|
11991
12165
|
}
|
|
11992
12166
|
};
|
|
11993
12167
|
var graphTerm = {
|
|
@@ -12000,7 +12174,7 @@ var graphTerm = {
|
|
|
12000
12174
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
12001
12175
|
{ ALT: () => {
|
|
12002
12176
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
12003
|
-
return ACTION(() => C.astFactory.
|
|
12177
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
12004
12178
|
} }
|
|
12005
12179
|
]),
|
|
12006
12180
|
gImpl: ({ SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
@@ -12630,13 +12804,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12630
12804
|
var triplesBlock = {
|
|
12631
12805
|
name: "triplesBlock",
|
|
12632
12806
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12633
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
12807
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
12634
12808
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12635
12809
|
HANDLE_LOC(triple, () => {
|
|
12636
12810
|
const nextTriple = ast.triples.at(index);
|
|
12637
12811
|
if (F3.isTripleCollection(triple)) {
|
|
12638
12812
|
SUBRULE(graphNodePath, triple);
|
|
12639
|
-
F3.printFilter(triple, () =>
|
|
12813
|
+
F3.printFilter(triple, () => {
|
|
12814
|
+
PRINT_WORD(".");
|
|
12815
|
+
NEW_LINE();
|
|
12816
|
+
});
|
|
12640
12817
|
} else {
|
|
12641
12818
|
SUBRULE(graphNodePath, triple.subject);
|
|
12642
12819
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
@@ -12648,11 +12825,17 @@ var triplesBlock = {
|
|
|
12648
12825
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12649
12826
|
SUBRULE(graphNodePath, triple.object);
|
|
12650
12827
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12651
|
-
F3.printFilter(ast, () =>
|
|
12828
|
+
F3.printFilter(ast, () => {
|
|
12829
|
+
PRINT_WORD(".");
|
|
12830
|
+
NEW_LINE();
|
|
12831
|
+
});
|
|
12652
12832
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12653
12833
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
12654
12834
|
} else {
|
|
12655
|
-
F3.printFilter(ast, () =>
|
|
12835
|
+
F3.printFilter(ast, () => {
|
|
12836
|
+
PRINT_WORD(";");
|
|
12837
|
+
NEW_LINE();
|
|
12838
|
+
});
|
|
12656
12839
|
}
|
|
12657
12840
|
}
|
|
12658
12841
|
});
|
|
@@ -12785,10 +12968,10 @@ function collectionImpl(name, allowPaths) {
|
|
|
12785
12968
|
return ACTION(() => {
|
|
12786
12969
|
const F3 = C.astFactory;
|
|
12787
12970
|
const triples = [];
|
|
12788
|
-
const predFirst = F3.
|
|
12789
|
-
const predRest = F3.
|
|
12790
|
-
const predNil = F3.
|
|
12791
|
-
const listHead = F3.
|
|
12971
|
+
const predFirst = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12972
|
+
const predRest = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
12973
|
+
const predNil = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
|
|
12974
|
+
const listHead = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12792
12975
|
let iterHead = listHead;
|
|
12793
12976
|
for (const [index, term] of terms.entries()) {
|
|
12794
12977
|
const lastInList = index === terms.length - 1;
|
|
@@ -12798,7 +12981,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12798
12981
|
const nilTriple = F3.triple(iterHead, predRest, predNil);
|
|
12799
12982
|
triples.push(nilTriple);
|
|
12800
12983
|
} else {
|
|
12801
|
-
const tail = F3.
|
|
12984
|
+
const tail = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
|
|
12802
12985
|
const linkTriple = F3.triple(iterHead, predRest, tail);
|
|
12803
12986
|
triples.push(linkTriple);
|
|
12804
12987
|
iterHead = tail;
|
|
@@ -12838,16 +13021,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12838
13021
|
name,
|
|
12839
13022
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12840
13023
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12841
|
-
const blankNode2 = ACTION(() => C.astFactory.
|
|
13024
|
+
const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12842
13025
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12843
13026
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12844
13027
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12845
13028
|
},
|
|
12846
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
13029
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
12847
13030
|
const { astFactory: F3, indentInc } = c;
|
|
12848
13031
|
F3.printFilter(ast, () => {
|
|
12849
13032
|
c[traqulaIndentation] += indentInc;
|
|
12850
|
-
PRINT("[
|
|
13033
|
+
PRINT("[");
|
|
13034
|
+
NEW_LINE();
|
|
12851
13035
|
});
|
|
12852
13036
|
for (const triple of ast.triples) {
|
|
12853
13037
|
HANDLE_LOC(triple, () => {
|
|
@@ -12858,7 +13042,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12858
13042
|
}
|
|
12859
13043
|
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
12860
13044
|
SUBRULE(graphNodePath, triple.object);
|
|
12861
|
-
F3.printFilter(ast, () =>
|
|
13045
|
+
F3.printFilter(ast, () => {
|
|
13046
|
+
PRINT_WORD(";");
|
|
13047
|
+
NEW_LINE();
|
|
13048
|
+
});
|
|
12862
13049
|
});
|
|
12863
13050
|
}
|
|
12864
13051
|
F3.printFilter(ast, () => {
|
|
@@ -12917,18 +13104,19 @@ var groupGraphPattern = {
|
|
|
12917
13104
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12918
13105
|
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12919
13106
|
},
|
|
12920
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
13107
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12921
13108
|
const { astFactory: F3, indentInc } = C;
|
|
12922
13109
|
F3.printFilter(ast, () => {
|
|
12923
13110
|
C[traqulaIndentation] += indentInc;
|
|
12924
|
-
PRINT_WORD("{
|
|
13111
|
+
PRINT_WORD("{");
|
|
13112
|
+
NEW_LINE();
|
|
12925
13113
|
});
|
|
12926
13114
|
for (const pattern of ast.patterns) {
|
|
12927
13115
|
SUBRULE(generatePattern, pattern);
|
|
12928
13116
|
}
|
|
12929
13117
|
F3.printFilter(ast, () => {
|
|
12930
13118
|
C[traqulaIndentation] -= indentInc;
|
|
12931
|
-
|
|
13119
|
+
PRINT_ON_OWN_LINE("}");
|
|
12932
13120
|
});
|
|
12933
13121
|
}
|
|
12934
13122
|
};
|
|
@@ -13078,12 +13266,15 @@ var bind2 = {
|
|
|
13078
13266
|
const close = CONSUME(symbols_exports.RParen);
|
|
13079
13267
|
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
13080
13268
|
},
|
|
13081
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13269
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13082
13270
|
F3.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
13083
13271
|
SUBRULE(expression, ast.expression);
|
|
13084
13272
|
F3.printFilter(ast, () => PRINT_WORD("AS"));
|
|
13085
13273
|
SUBRULE(var_, ast.variable);
|
|
13086
|
-
F3.printFilter(ast, () =>
|
|
13274
|
+
F3.printFilter(ast, () => {
|
|
13275
|
+
PRINT_WORD(")");
|
|
13276
|
+
NEW_LINE();
|
|
13277
|
+
});
|
|
13087
13278
|
}
|
|
13088
13279
|
};
|
|
13089
13280
|
var inlineData = {
|
|
@@ -13091,34 +13282,46 @@ var inlineData = {
|
|
|
13091
13282
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
13092
13283
|
const values3 = CONSUME(values2);
|
|
13093
13284
|
const datablock = SUBRULE(dataBlock);
|
|
13094
|
-
return ACTION(() =>
|
|
13285
|
+
return ACTION(() => {
|
|
13286
|
+
datablock.loc = C.astFactory.sourceLocation(values3, datablock);
|
|
13287
|
+
return datablock;
|
|
13288
|
+
});
|
|
13095
13289
|
},
|
|
13096
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13290
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
13097
13291
|
const { astFactory: F3, indentInc } = C;
|
|
13098
|
-
const variables =
|
|
13292
|
+
const variables = ast.variables;
|
|
13293
|
+
const singleVar = variables.length === 1;
|
|
13294
|
+
F3.printFilter(ast, () => {
|
|
13295
|
+
PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
|
|
13296
|
+
});
|
|
13297
|
+
for (const variable of variables) {
|
|
13298
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13299
|
+
SUBRULE(varOrTerm, variable);
|
|
13300
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
13301
|
+
}
|
|
13099
13302
|
F3.printFilter(ast, () => {
|
|
13100
|
-
PRINT_ON_EMPTY("");
|
|
13101
|
-
PRINT_WORD("VALUES", "(");
|
|
13102
|
-
for (const variable of variables) {
|
|
13103
|
-
PRINT_WORD(`?${variable}`);
|
|
13104
|
-
}
|
|
13105
13303
|
C[traqulaIndentation] += indentInc;
|
|
13106
|
-
PRINT_WORD(")", "{
|
|
13304
|
+
PRINT_WORD(singleVar ? "" : ")", "{");
|
|
13305
|
+
NEW_LINE();
|
|
13107
13306
|
});
|
|
13108
13307
|
for (const mapping of ast.values) {
|
|
13109
|
-
F3.printFilter(ast, () => PRINT_WORD("("));
|
|
13308
|
+
F3.printFilter(ast, () => !singleVar && PRINT_WORD("("));
|
|
13110
13309
|
for (const variable of variables) {
|
|
13111
|
-
|
|
13310
|
+
const var_2 = variable.value;
|
|
13311
|
+
if (mapping[var_2] === void 0) {
|
|
13112
13312
|
F3.printFilter(ast, () => PRINT_WORD("UNDEF"));
|
|
13113
13313
|
} else {
|
|
13114
|
-
SUBRULE(graphNodePath, mapping[
|
|
13314
|
+
SUBRULE(graphNodePath, mapping[var_2]);
|
|
13115
13315
|
}
|
|
13116
13316
|
}
|
|
13117
|
-
F3.printFilter(ast, () =>
|
|
13317
|
+
F3.printFilter(ast, () => {
|
|
13318
|
+
PRINT_WORD(singleVar ? "" : ")");
|
|
13319
|
+
NEW_LINE();
|
|
13320
|
+
});
|
|
13118
13321
|
}
|
|
13119
13322
|
F3.printFilter(ast, () => {
|
|
13120
13323
|
C[traqulaIndentation] -= indentInc;
|
|
13121
|
-
|
|
13324
|
+
PRINT_ON_OWN_LINE("}");
|
|
13122
13325
|
});
|
|
13123
13326
|
}
|
|
13124
13327
|
};
|
|
@@ -13142,7 +13345,7 @@ var inlineDataOneVar = {
|
|
|
13142
13345
|
});
|
|
13143
13346
|
});
|
|
13144
13347
|
const close = CONSUME(symbols_exports.RCurly);
|
|
13145
|
-
return ACTION(() => C.astFactory.
|
|
13348
|
+
return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
|
|
13146
13349
|
}
|
|
13147
13350
|
};
|
|
13148
13351
|
var inlineDataFull = {
|
|
@@ -13159,7 +13362,7 @@ var inlineDataFull = {
|
|
|
13159
13362
|
res.push({});
|
|
13160
13363
|
});
|
|
13161
13364
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
13162
|
-
return ACTION(() => C.astFactory.
|
|
13365
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
|
|
13163
13366
|
} },
|
|
13164
13367
|
{ ALT: () => {
|
|
13165
13368
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -13191,7 +13394,7 @@ var inlineDataFull = {
|
|
|
13191
13394
|
});
|
|
13192
13395
|
});
|
|
13193
13396
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
13194
|
-
return ACTION(() => C.astFactory.
|
|
13397
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
|
|
13195
13398
|
} }
|
|
13196
13399
|
]);
|
|
13197
13400
|
}
|
|
@@ -13254,10 +13457,13 @@ var filter3 = {
|
|
|
13254
13457
|
const expression2 = SUBRULE(constraint);
|
|
13255
13458
|
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
13256
13459
|
},
|
|
13257
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
13460
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13258
13461
|
F3.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
13259
13462
|
SUBRULE(expression, ast.expression);
|
|
13260
|
-
F3.printFilter(ast, () =>
|
|
13463
|
+
F3.printFilter(ast, () => {
|
|
13464
|
+
PRINT_WORD(")");
|
|
13465
|
+
NEW_LINE();
|
|
13466
|
+
});
|
|
13261
13467
|
}
|
|
13262
13468
|
};
|
|
13263
13469
|
var constraint = {
|
|
@@ -13643,8 +13849,7 @@ var groupClause = {
|
|
|
13643
13849
|
},
|
|
13644
13850
|
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13645
13851
|
F3.printFilter(ast, () => {
|
|
13646
|
-
PRINT_ON_EMPTY("");
|
|
13647
|
-
PRINT_WORDS("GROUP", "BY");
|
|
13852
|
+
PRINT_ON_EMPTY("GROUP BY ");
|
|
13648
13853
|
});
|
|
13649
13854
|
for (const grouping of ast.groupings) {
|
|
13650
13855
|
if (F3.isExpression(grouping)) {
|
|
@@ -13700,10 +13905,9 @@ var havingClause = {
|
|
|
13700
13905
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13701
13906
|
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13702
13907
|
},
|
|
13703
|
-
gImpl: ({
|
|
13908
|
+
gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13704
13909
|
F3.printFilter(ast, () => {
|
|
13705
|
-
PRINT_ON_EMPTY("");
|
|
13706
|
-
PRINT_WORD("HAVING");
|
|
13910
|
+
PRINT_ON_EMPTY("HAVING ");
|
|
13707
13911
|
});
|
|
13708
13912
|
for (const having2 of ast.having) {
|
|
13709
13913
|
SUBRULE(expression, having2);
|
|
@@ -13729,8 +13933,7 @@ var orderClause = {
|
|
|
13729
13933
|
},
|
|
13730
13934
|
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
|
|
13731
13935
|
F3.printFilter(ast, () => {
|
|
13732
|
-
PRINT_ON_EMPTY("");
|
|
13733
|
-
PRINT_WORDS("ORDER", "BY");
|
|
13936
|
+
PRINT_ON_EMPTY("ORDER BY ");
|
|
13734
13937
|
});
|
|
13735
13938
|
for (const ordering of ast.orderDefs) {
|
|
13736
13939
|
if (ordering.descending) {
|
|
@@ -13789,9 +13992,9 @@ var limitOffsetClauses = {
|
|
|
13789
13992
|
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13790
13993
|
} }
|
|
13791
13994
|
]),
|
|
13792
|
-
gImpl: ({ PRINT_WORDS,
|
|
13995
|
+
gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
13793
13996
|
F3.printFilter(ast, () => {
|
|
13794
|
-
|
|
13997
|
+
NEW_LINE();
|
|
13795
13998
|
if (ast.limit) {
|
|
13796
13999
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13797
14000
|
}
|
|
@@ -13976,9 +14179,9 @@ var selectClause = {
|
|
|
13976
14179
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13977
14180
|
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13978
14181
|
},
|
|
13979
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14182
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
13980
14183
|
F3.printFilter(ast, () => {
|
|
13981
|
-
|
|
14184
|
+
PRINT_ON_EMPTY("SELECT ");
|
|
13982
14185
|
if (ast.val.distinct) {
|
|
13983
14186
|
PRINT_WORD("DISTINCT");
|
|
13984
14187
|
} else if (ast.val.reduced) {
|
|
@@ -13997,7 +14200,9 @@ var selectClause = {
|
|
|
13997
14200
|
SUBRULE(var_, variable.variable);
|
|
13998
14201
|
F3.printFilter(ast, () => PRINT_WORD(")"));
|
|
13999
14202
|
}
|
|
14203
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14000
14204
|
}
|
|
14205
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
14001
14206
|
}
|
|
14002
14207
|
};
|
|
14003
14208
|
var constructQuery = {
|
|
@@ -14035,18 +14240,19 @@ var constructQuery = {
|
|
|
14035
14240
|
} }
|
|
14036
14241
|
]);
|
|
14037
14242
|
},
|
|
14038
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14243
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14039
14244
|
const { astFactory: F3, indentInc } = C;
|
|
14040
|
-
F3.printFilter(ast, () =>
|
|
14245
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
|
|
14041
14246
|
if (!F3.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
14042
14247
|
F3.printFilter(ast, () => {
|
|
14043
14248
|
C[traqulaIndentation] += indentInc;
|
|
14044
|
-
PRINT_WORD("{
|
|
14249
|
+
PRINT_WORD("{");
|
|
14250
|
+
NEW_LINE();
|
|
14045
14251
|
});
|
|
14046
14252
|
SUBRULE(triplesBlock, ast.template);
|
|
14047
14253
|
F3.printFilter(ast, () => {
|
|
14048
14254
|
C[traqulaIndentation] -= indentInc;
|
|
14049
|
-
|
|
14255
|
+
PRINT_ON_OWN_LINE("}");
|
|
14050
14256
|
});
|
|
14051
14257
|
}
|
|
14052
14258
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
@@ -14087,8 +14293,8 @@ var describeQuery = {
|
|
|
14087
14293
|
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14088
14294
|
}));
|
|
14089
14295
|
},
|
|
14090
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14091
|
-
F3.printFilter(ast, () =>
|
|
14296
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14297
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
|
|
14092
14298
|
if (F3.isWildcard(ast.variables[0])) {
|
|
14093
14299
|
F3.printFilter(ast, () => PRINT_WORD("*"));
|
|
14094
14300
|
} else {
|
|
@@ -14118,8 +14324,8 @@ var askQuery = {
|
|
|
14118
14324
|
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14119
14325
|
}));
|
|
14120
14326
|
},
|
|
14121
|
-
gImpl: ({ SUBRULE,
|
|
14122
|
-
F3.printFilter(ast, () =>
|
|
14327
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14328
|
+
F3.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
|
|
14123
14329
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
14124
14330
|
SUBRULE(whereClause, F3.wrap(ast.where, ast.loc));
|
|
14125
14331
|
SUBRULE(solutionModifier, ast.solutionModifiers);
|
|
@@ -14178,7 +14384,7 @@ var update = {
|
|
|
14178
14384
|
return update2;
|
|
14179
14385
|
});
|
|
14180
14386
|
},
|
|
14181
|
-
gImpl: ({ SUBRULE,
|
|
14387
|
+
gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F3 }) => {
|
|
14182
14388
|
const [head2, ...tail] = ast.updates;
|
|
14183
14389
|
if (head2) {
|
|
14184
14390
|
SUBRULE(prologue, head2.context);
|
|
@@ -14187,7 +14393,10 @@ var update = {
|
|
|
14187
14393
|
}
|
|
14188
14394
|
}
|
|
14189
14395
|
for (const update2 of tail) {
|
|
14190
|
-
F3.printFilter(ast, () =>
|
|
14396
|
+
F3.printFilter(ast, () => {
|
|
14397
|
+
PRINT(";");
|
|
14398
|
+
NEW_LINE();
|
|
14399
|
+
});
|
|
14191
14400
|
SUBRULE(prologue, update2.context);
|
|
14192
14401
|
if (update2.operation) {
|
|
14193
14402
|
SUBRULE(update1, update2.operation);
|
|
@@ -14260,9 +14469,9 @@ var load2 = {
|
|
|
14260
14469
|
});
|
|
14261
14470
|
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
14262
14471
|
},
|
|
14263
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14472
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14264
14473
|
F3.printFilter(ast, () => {
|
|
14265
|
-
|
|
14474
|
+
PRINT_ON_EMPTY("LOAD ");
|
|
14266
14475
|
if (ast.silent) {
|
|
14267
14476
|
PRINT_WORD("SILENT");
|
|
14268
14477
|
}
|
|
@@ -14283,9 +14492,9 @@ function clearOrDrop(operation) {
|
|
|
14283
14492
|
const destination = SUBRULE1(graphRefAll);
|
|
14284
14493
|
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
14285
14494
|
},
|
|
14286
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14495
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14287
14496
|
F3.printFilter(ast, () => {
|
|
14288
|
-
|
|
14497
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14289
14498
|
if (ast.silent) {
|
|
14290
14499
|
PRINT_WORD("SILENT");
|
|
14291
14500
|
}
|
|
@@ -14304,9 +14513,9 @@ var create2 = {
|
|
|
14304
14513
|
const destination = SUBRULE1(graphRef);
|
|
14305
14514
|
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
14306
14515
|
},
|
|
14307
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14516
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14308
14517
|
F3.printFilter(ast, () => {
|
|
14309
|
-
|
|
14518
|
+
PRINT_ON_EMPTY("CREATE ");
|
|
14310
14519
|
if (ast.silent) {
|
|
14311
14520
|
PRINT_WORD("SILENT");
|
|
14312
14521
|
}
|
|
@@ -14325,9 +14534,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14325
14534
|
const destination = SUBRULE2(graphOrDefault);
|
|
14326
14535
|
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14327
14536
|
},
|
|
14328
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
14537
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
|
|
14329
14538
|
F3.printFilter(ast, () => {
|
|
14330
|
-
|
|
14539
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14331
14540
|
if (ast.silent) {
|
|
14332
14541
|
PRINT_WORD("SILENT");
|
|
14333
14542
|
}
|
|
@@ -14376,23 +14585,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
|
|
|
14376
14585
|
}
|
|
14377
14586
|
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14378
14587
|
},
|
|
14379
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14588
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14380
14589
|
const { astFactory: F3, indentInc } = C;
|
|
14381
14590
|
F3.printFilter(ast, () => {
|
|
14382
|
-
C[traqulaIndentation] += indentInc;
|
|
14383
14591
|
if (subType === "insertdata") {
|
|
14384
|
-
|
|
14592
|
+
PRINT_ON_EMPTY("INSERT DATA ");
|
|
14385
14593
|
} else if (subType === "deletedata") {
|
|
14386
|
-
|
|
14594
|
+
PRINT_ON_EMPTY("DELETE DATA ");
|
|
14387
14595
|
} else if (subType === "deletewhere") {
|
|
14388
|
-
|
|
14596
|
+
PRINT_ON_EMPTY("DELETE WHERE ");
|
|
14389
14597
|
}
|
|
14390
|
-
|
|
14598
|
+
C[traqulaIndentation] += indentInc;
|
|
14599
|
+
PRINT_WORD("{");
|
|
14600
|
+
NEW_LINE();
|
|
14391
14601
|
});
|
|
14392
14602
|
SUBRULE(quads, F3.wrap(ast.data, ast.loc));
|
|
14393
14603
|
F3.printFilter(ast, () => {
|
|
14394
14604
|
C[traqulaIndentation] -= indentInc;
|
|
14395
|
-
|
|
14605
|
+
PRINT_ON_OWN_LINE("}");
|
|
14396
14606
|
});
|
|
14397
14607
|
}
|
|
14398
14608
|
};
|
|
@@ -14424,36 +14634,40 @@ var modify = {
|
|
|
14424
14634
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14425
14635
|
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14426
14636
|
},
|
|
14427
|
-
gImpl: ({ SUBRULE,
|
|
14637
|
+
gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
|
|
14428
14638
|
const { astFactory: F3, indentInc } = C;
|
|
14429
14639
|
if (ast.graph) {
|
|
14430
|
-
F3.printFilter(ast, () =>
|
|
14640
|
+
F3.printFilter(ast, () => PRINT_WORDS("WITH"));
|
|
14431
14641
|
SUBRULE(iri2, ast.graph);
|
|
14432
14642
|
}
|
|
14433
14643
|
if (ast.delete.length > 0) {
|
|
14434
14644
|
F3.printFilter(ast, () => {
|
|
14435
14645
|
C[traqulaIndentation] += indentInc;
|
|
14436
|
-
|
|
14646
|
+
PRINT_WORDS("DELETE", "{");
|
|
14647
|
+
NEW_LINE();
|
|
14437
14648
|
});
|
|
14438
14649
|
SUBRULE(quads, F3.wrap(ast.delete, ast.loc));
|
|
14439
14650
|
F3.printFilter(ast, () => {
|
|
14440
14651
|
C[traqulaIndentation] -= indentInc;
|
|
14441
|
-
PRINT_ON_EMPTY("}
|
|
14652
|
+
PRINT_ON_EMPTY("}");
|
|
14653
|
+
NEW_LINE();
|
|
14442
14654
|
});
|
|
14443
14655
|
}
|
|
14444
14656
|
if (ast.insert.length > 0) {
|
|
14445
14657
|
F3.printFilter(ast, () => {
|
|
14446
14658
|
C[traqulaIndentation] += indentInc;
|
|
14447
|
-
|
|
14659
|
+
PRINT_WORDS("INSERT", "{");
|
|
14660
|
+
NEW_LINE();
|
|
14448
14661
|
});
|
|
14449
14662
|
SUBRULE(quads, F3.wrap(ast.insert, ast.loc));
|
|
14450
14663
|
F3.printFilter(ast, () => {
|
|
14451
14664
|
C[traqulaIndentation] -= indentInc;
|
|
14452
|
-
PRINT_ON_EMPTY("}
|
|
14665
|
+
PRINT_ON_EMPTY("} ");
|
|
14666
|
+
NEW_LINE();
|
|
14453
14667
|
});
|
|
14454
14668
|
}
|
|
14455
14669
|
SUBRULE(usingClauseStar, ast.from);
|
|
14456
|
-
F3.printFilter(ast, () =>
|
|
14670
|
+
F3.printFilter(ast, () => PRINT_WORDS("WHERE"));
|
|
14457
14671
|
SUBRULE(groupGraphPattern, ast.where);
|
|
14458
14672
|
}
|
|
14459
14673
|
};
|
|
@@ -14577,18 +14791,19 @@ var quadsNotTriples = {
|
|
|
14577
14791
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14578
14792
|
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14579
14793
|
},
|
|
14580
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
14794
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14581
14795
|
const { astFactory: F3, indentInc } = C;
|
|
14582
14796
|
F3.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14583
14797
|
SUBRULE(varOrTerm, ast.graph);
|
|
14584
14798
|
F3.printFilter(ast, () => {
|
|
14585
14799
|
C[traqulaIndentation] += indentInc;
|
|
14586
|
-
PRINT_WORD("{
|
|
14800
|
+
PRINT_WORD("{");
|
|
14801
|
+
NEW_LINE();
|
|
14587
14802
|
});
|
|
14588
14803
|
SUBRULE(triplesBlock, ast.triples);
|
|
14589
14804
|
F3.printFilter(ast, () => {
|
|
14590
14805
|
C[traqulaIndentation] -= indentInc;
|
|
14591
|
-
|
|
14806
|
+
PRINT_ON_OWN_LINE("}");
|
|
14592
14807
|
});
|
|
14593
14808
|
}
|
|
14594
14809
|
};
|
|
@@ -15019,7 +15234,7 @@ var AstFactory2 = class extends AstFactory {
|
|
|
15019
15234
|
type: "tripleCollection",
|
|
15020
15235
|
subType: "reifiedTriple",
|
|
15021
15236
|
triples: [this.triple(subject, predicate, object3)],
|
|
15022
|
-
identifier: reifier2 ?? this.
|
|
15237
|
+
identifier: reifier2 ?? this.termBlank(void 0, this.sourceLocationNoMaterialize()),
|
|
15023
15238
|
loc
|
|
15024
15239
|
};
|
|
15025
15240
|
}
|
|
@@ -15094,9 +15309,9 @@ var versionDecl = {
|
|
|
15094
15309
|
const identifier = SUBRULE(versionSpecifier);
|
|
15095
15310
|
return ACTION(() => C.astFactory.contextDefinitionVersion(identifier.val, C.astFactory.sourceLocation(versionToken, identifier)));
|
|
15096
15311
|
},
|
|
15097
|
-
gImpl: ({
|
|
15312
|
+
gImpl: ({ PRINT_ON_OWN_LINE }) => (ast, { astFactory: F3 }) => {
|
|
15098
15313
|
F3.printFilter(ast, () => {
|
|
15099
|
-
|
|
15314
|
+
PRINT_ON_OWN_LINE("VERSION ", `${grammar_exports.stringEscapedLexical(ast.version)}`);
|
|
15100
15315
|
});
|
|
15101
15316
|
}
|
|
15102
15317
|
};
|
|
@@ -15163,7 +15378,7 @@ var reifier = {
|
|
|
15163
15378
|
if (reifier2 === void 0 && !C.parseMode.has("canCreateBlankNodes")) {
|
|
15164
15379
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
15165
15380
|
}
|
|
15166
|
-
return C.astFactory.wrap(reifier2 ?? C.astFactory.
|
|
15381
|
+
return C.astFactory.wrap(reifier2 ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation()), C.astFactory.sourceLocation(tildeToken, reifier2));
|
|
15167
15382
|
});
|
|
15168
15383
|
}
|
|
15169
15384
|
};
|
|
@@ -15222,7 +15437,7 @@ function annotationImpl(name, allowPaths) {
|
|
|
15222
15437
|
if (!currentReifier && !C.parseMode.has("canCreateBlankNodes")) {
|
|
15223
15438
|
throw new Error("Cannot create blanknodes in current parse mode");
|
|
15224
15439
|
}
|
|
15225
|
-
currentReifier = currentReifier ?? C.astFactory.
|
|
15440
|
+
currentReifier = currentReifier ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation());
|
|
15226
15441
|
});
|
|
15227
15442
|
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, currentReifier);
|
|
15228
15443
|
ACTION(() => {
|
|
@@ -15257,13 +15472,13 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
15257
15472
|
const close = CONSUME(annotationClose);
|
|
15258
15473
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(arg, res, C.astFactory.sourceLocation(open, close)));
|
|
15259
15474
|
},
|
|
15260
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC,
|
|
15475
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
15261
15476
|
const { astFactory: F3, indentInc } = C;
|
|
15262
15477
|
F3.printFilter(ast, () => {
|
|
15263
15478
|
PRINT_WORD("{|");
|
|
15264
15479
|
if (ast.triples.length > 1) {
|
|
15265
15480
|
C[traqulaIndentation] += indentInc;
|
|
15266
|
-
|
|
15481
|
+
NEW_LINE();
|
|
15267
15482
|
}
|
|
15268
15483
|
});
|
|
15269
15484
|
function printTriple(triple) {
|
|
@@ -15273,18 +15488,22 @@ function annotationBlockImpl(name, allowPaths) {
|
|
|
15273
15488
|
} else {
|
|
15274
15489
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
15275
15490
|
}
|
|
15491
|
+
F3.printFilter(triple, () => PRINT_WORD(""));
|
|
15276
15492
|
SUBRULE(graphNodePath2, triple.object);
|
|
15277
15493
|
});
|
|
15278
15494
|
}
|
|
15279
15495
|
const [head2, ...tail] = ast.triples;
|
|
15280
15496
|
printTriple(head2);
|
|
15281
15497
|
for (const triple of tail) {
|
|
15282
|
-
F3.printFilter(ast, () =>
|
|
15498
|
+
F3.printFilter(ast, () => {
|
|
15499
|
+
PRINT_WORD(";");
|
|
15500
|
+
NEW_LINE();
|
|
15501
|
+
});
|
|
15283
15502
|
printTriple(triple);
|
|
15284
15503
|
}
|
|
15285
15504
|
F3.printFilter(ast, () => {
|
|
15286
15505
|
if (ast.triples.length > 1) {
|
|
15287
|
-
|
|
15506
|
+
PRINT_ON_OWN_LINE("|}");
|
|
15288
15507
|
} else {
|
|
15289
15508
|
PRINT_WORD("|}");
|
|
15290
15509
|
}
|
|
@@ -15326,7 +15545,7 @@ var varOrTerm2 = {
|
|
|
15326
15545
|
{ ALT: () => SUBRULE(grammar_exports.blankNode) },
|
|
15327
15546
|
{ ALT: () => {
|
|
15328
15547
|
const token = CONSUME(lexer_exports.terminals.nil);
|
|
15329
|
-
return ACTION(() => C.astFactory.
|
|
15548
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.NIL));
|
|
15330
15549
|
} },
|
|
15331
15550
|
{ ALT: () => SUBRULE(tripleTerm) }
|
|
15332
15551
|
])
|
|
@@ -15352,11 +15571,13 @@ var reifiedTriple = {
|
|
|
15352
15571
|
F3.printFilter(ast, () => PRINT_WORD("<<"));
|
|
15353
15572
|
const triple = ast.triples[0];
|
|
15354
15573
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15574
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15355
15575
|
if (F3.isPathPure(triple.predicate)) {
|
|
15356
15576
|
SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
|
|
15357
15577
|
} else {
|
|
15358
15578
|
SUBRULE(graphNodePath2, triple.predicate);
|
|
15359
15579
|
}
|
|
15580
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15360
15581
|
SUBRULE(graphNodePath2, triple.object);
|
|
15361
15582
|
SUBRULE(annotationPath, [F3.wrap(ast.identifier, ast.identifier.loc)]);
|
|
15362
15583
|
F3.printFilter(ast, () => PRINT_WORD(">>"));
|
|
@@ -15392,7 +15613,9 @@ var tripleTerm = {
|
|
|
15392
15613
|
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
|
|
15393
15614
|
F3.printFilter(ast, () => PRINT_WORD("<<("));
|
|
15394
15615
|
SUBRULE(graphNodePath2, ast.subject);
|
|
15616
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15395
15617
|
SUBRULE(graphNodePath2, ast.predicate);
|
|
15618
|
+
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
15396
15619
|
SUBRULE(graphNodePath2, ast.object);
|
|
15397
15620
|
F3.printFilter(ast, () => PRINT_WORD(")>>"));
|
|
15398
15621
|
}
|
|
@@ -15422,7 +15645,7 @@ var tripleTermData = {
|
|
|
15422
15645
|
{ ALT: () => SUBRULE(grammar_exports.iri) },
|
|
15423
15646
|
{ ALT: () => {
|
|
15424
15647
|
const token = CONSUME(lexer_exports.a);
|
|
15425
|
-
return ACTION(() => C.astFactory.
|
|
15648
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE));
|
|
15426
15649
|
} }
|
|
15427
15650
|
]);
|
|
15428
15651
|
const object3 = SUBRULE(tripleTermDataObject);
|
|
@@ -15509,7 +15732,7 @@ var rdfLiteral2 = {
|
|
|
15509
15732
|
{ ALT: () => {
|
|
15510
15733
|
const langTag2 = CONSUME(LANG_DIR);
|
|
15511
15734
|
return ACTION(() => {
|
|
15512
|
-
const literal = C.astFactory.
|
|
15735
|
+
const literal = C.astFactory.termLiteral(C.astFactory.sourceLocation(value, langTag2), value.value, langTag2.image.slice(1).toLowerCase());
|
|
15513
15736
|
langTagHasCorrectRange(literal);
|
|
15514
15737
|
return literal;
|
|
15515
15738
|
});
|
|
@@ -15517,7 +15740,7 @@ var rdfLiteral2 = {
|
|
|
15517
15740
|
{ ALT: () => {
|
|
15518
15741
|
CONSUME(lexer_exports.symbols.hathat);
|
|
15519
15742
|
const iriVal = SUBRULE(grammar_exports.iri);
|
|
15520
|
-
return ACTION(() => C.astFactory.
|
|
15743
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
15521
15744
|
} }
|
|
15522
15745
|
])) ?? value;
|
|
15523
15746
|
}
|
|
@@ -15543,13 +15766,16 @@ var unaryExpression2 = {
|
|
|
15543
15766
|
};
|
|
15544
15767
|
var generateTriplesBlock = {
|
|
15545
15768
|
name: "triplesBlock",
|
|
15546
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15769
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
|
|
15547
15770
|
for (const [index, triple] of ast.triples.entries()) {
|
|
15548
15771
|
HANDLE_LOC(triple, () => {
|
|
15549
15772
|
const nextTriple = ast.triples.at(index);
|
|
15550
15773
|
if (F3.isTripleCollection(triple)) {
|
|
15551
15774
|
SUBRULE(graphNodePath2, triple);
|
|
15552
|
-
F3.printFilter(triple, () =>
|
|
15775
|
+
F3.printFilter(triple, () => {
|
|
15776
|
+
PRINT_WORD(".");
|
|
15777
|
+
NEW_LINE();
|
|
15778
|
+
});
|
|
15553
15779
|
} else {
|
|
15554
15780
|
SUBRULE(graphNodePath2, triple.subject);
|
|
15555
15781
|
F3.printFilter(ast, () => PRINT_WORD(""));
|
|
@@ -15562,11 +15788,17 @@ var generateTriplesBlock = {
|
|
|
15562
15788
|
SUBRULE(graphNodePath2, triple.object);
|
|
15563
15789
|
SUBRULE(annotationPath, triple.annotations ?? []);
|
|
15564
15790
|
if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
15565
|
-
F3.printFilter(ast, () =>
|
|
15791
|
+
F3.printFilter(ast, () => {
|
|
15792
|
+
PRINT_WORD(".");
|
|
15793
|
+
NEW_LINE();
|
|
15794
|
+
});
|
|
15566
15795
|
} else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
15567
15796
|
F3.printFilter(ast, () => PRINT_WORD(","));
|
|
15568
15797
|
} else {
|
|
15569
|
-
F3.printFilter(ast, () =>
|
|
15798
|
+
F3.printFilter(ast, () => {
|
|
15799
|
+
PRINT_WORD(";");
|
|
15800
|
+
NEW_LINE();
|
|
15801
|
+
});
|
|
15570
15802
|
}
|
|
15571
15803
|
}
|
|
15572
15804
|
});
|
|
@@ -15604,8 +15836,9 @@ var sparql12ParserBuilder = ParserBuilder.create(sparql11ParserBuilder).widenCon
|
|
|
15604
15836
|
var Parser2 = class {
|
|
15605
15837
|
parser;
|
|
15606
15838
|
F = new AstFactory2();
|
|
15607
|
-
constructor() {
|
|
15839
|
+
constructor(args = {}) {
|
|
15608
15840
|
this.parser = sparql12ParserBuilder.build({
|
|
15841
|
+
...args,
|
|
15609
15842
|
queryPreProcessor: sparqlCodepointEscape,
|
|
15610
15843
|
tokenVocabulary: lexer_exports2.sparql12LexerBuilder.tokenVocabulary
|
|
15611
15844
|
});
|