@traqula/parser-sparql-1-1 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/Parser.d.ts +5 -4
- package/lib/Parser.js +2 -1
- package/lib/Parser.js.map +1 -1
- package/lib/index.cjs +416 -192
- package/lib/queryUnitParser.d.ts +3 -3
- package/lib/subSelectParser.d.ts +3 -3
- package/lib/updateUnitParser.d.ts +3 -3
- package/package.json +5 -5
package/lib/index.cjs
CHANGED
|
@@ -50,7 +50,7 @@ var AstCoreFactory = class {
|
|
|
50
50
|
if (filtered.length === 0) {
|
|
51
51
|
return this.gen();
|
|
52
52
|
}
|
|
53
|
-
const first2 = filtered
|
|
53
|
+
const first2 = filtered.at(0);
|
|
54
54
|
const last2 = filtered.at(-1);
|
|
55
55
|
return {
|
|
56
56
|
sourceLocationType: "source",
|
|
@@ -9663,6 +9663,9 @@ var ParserBuilder = class _ParserBuilder {
|
|
|
9663
9663
|
delete this.rules[ruleName];
|
|
9664
9664
|
return this;
|
|
9665
9665
|
}
|
|
9666
|
+
getRule(ruleName) {
|
|
9667
|
+
return this.rules[ruleName];
|
|
9668
|
+
}
|
|
9666
9669
|
/**
|
|
9667
9670
|
* Merge this grammar builder with another.
|
|
9668
9671
|
* It is best to merge the bigger grammar with the smaller one.
|
|
@@ -9749,21 +9752,34 @@ ${firstError.message}`);
|
|
|
9749
9752
|
}
|
|
9750
9753
|
};
|
|
9751
9754
|
|
|
9752
|
-
// ../../packages/core/lib/
|
|
9753
|
-
var
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9755
|
+
// ../../packages/core/lib/TransformerObject.js
|
|
9756
|
+
var TransformerObject = class _TransformerObject {
|
|
9757
|
+
defaultContext;
|
|
9758
|
+
maxStackSize = 1e6;
|
|
9759
|
+
/**
|
|
9760
|
+
* Creates stateless transformer.
|
|
9761
|
+
* @param defaultContext
|
|
9762
|
+
*/
|
|
9763
|
+
constructor(defaultContext = {}) {
|
|
9764
|
+
this.defaultContext = defaultContext;
|
|
9758
9765
|
}
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9766
|
+
clone(newDefaultContext = {}) {
|
|
9767
|
+
return new _TransformerObject({ ...this.defaultContext, ...newDefaultContext });
|
|
9768
|
+
}
|
|
9769
|
+
/**
|
|
9770
|
+
* Function to shallow clone any type.
|
|
9771
|
+
* @param obj
|
|
9772
|
+
* @protected
|
|
9773
|
+
*/
|
|
9774
|
+
cloneObj(obj) {
|
|
9775
|
+
if (obj === null || typeof obj !== "object") {
|
|
9776
|
+
return obj;
|
|
9765
9777
|
}
|
|
9766
|
-
|
|
9778
|
+
const proto = Object.getPrototypeOf(obj);
|
|
9779
|
+
if (proto === Object.prototype || proto === null) {
|
|
9780
|
+
return { ...obj };
|
|
9781
|
+
}
|
|
9782
|
+
return Object.assign(Object.create(proto), obj);
|
|
9767
9783
|
}
|
|
9768
9784
|
/**
|
|
9769
9785
|
* Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
|
|
@@ -9775,90 +9791,231 @@ var TransformerType = class {
|
|
|
9775
9791
|
* - Default false
|
|
9776
9792
|
*/
|
|
9777
9793
|
transformObject(startObject, mapper, preVisitor = () => ({})) {
|
|
9794
|
+
const defaults2 = this.defaultContext;
|
|
9795
|
+
const defaultCopyFlag = defaults2.copy ?? true;
|
|
9796
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9797
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9798
|
+
const defaultShallowKeys = defaults2.shallowKeys;
|
|
9799
|
+
const defaultDidShortCut = defaults2.shortcut ?? false;
|
|
9778
9800
|
let didShortCut = false;
|
|
9779
|
-
const
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9801
|
+
const resultWrap = { res: startObject };
|
|
9802
|
+
const stack = [startObject];
|
|
9803
|
+
const stackParent = [resultWrap];
|
|
9804
|
+
const stackParentKey = ["res"];
|
|
9805
|
+
const handleMapperOnLen = [];
|
|
9806
|
+
const mapperCopyStack = [];
|
|
9807
|
+
const mapperOrigStack = [];
|
|
9808
|
+
const mapperParent = [];
|
|
9809
|
+
const mapperParentKey = [];
|
|
9810
|
+
function handleMapper() {
|
|
9811
|
+
while (stack.length === handleMapperOnLen.at(-1)) {
|
|
9812
|
+
handleMapperOnLen.pop();
|
|
9813
|
+
const copyToMap = mapperCopyStack.pop();
|
|
9814
|
+
const origToMap = mapperOrigStack.pop();
|
|
9815
|
+
const parent = mapperParent.pop();
|
|
9816
|
+
const parentKey = mapperParentKey.pop();
|
|
9817
|
+
parent[parentKey] = mapper(copyToMap, origToMap);
|
|
9818
|
+
}
|
|
9819
|
+
}
|
|
9820
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9821
|
+
const curObject = stack.pop();
|
|
9822
|
+
const curParent = stackParent.pop();
|
|
9823
|
+
const curKey = stackParentKey.pop();
|
|
9824
|
+
if (!didShortCut) {
|
|
9825
|
+
if (Array.isArray(curObject)) {
|
|
9826
|
+
const newArr = [...curObject];
|
|
9827
|
+
handleMapperOnLen.push(stack.length);
|
|
9828
|
+
mapperCopyStack.push(newArr);
|
|
9829
|
+
mapperOrigStack.push(curObject);
|
|
9830
|
+
mapperParent.push(curParent);
|
|
9831
|
+
mapperParentKey.push(curKey);
|
|
9832
|
+
for (let index = curObject.length - 1; index >= 0; index--) {
|
|
9833
|
+
const val = curObject[index];
|
|
9834
|
+
if (val !== null && typeof val === "object") {
|
|
9835
|
+
stack.push(val);
|
|
9836
|
+
stackParent.push(newArr);
|
|
9837
|
+
stackParentKey.push(index.toString());
|
|
9838
|
+
}
|
|
9839
|
+
}
|
|
9840
|
+
handleMapper();
|
|
9841
|
+
continue;
|
|
9842
|
+
}
|
|
9843
|
+
const context = preVisitor(curObject);
|
|
9844
|
+
const copyFlag = context.copy ?? defaultCopyFlag;
|
|
9845
|
+
const continues = context.continue ?? defaultContinues;
|
|
9846
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9847
|
+
const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
|
|
9848
|
+
didShortCut = context.shortcut ?? defaultDidShortCut;
|
|
9849
|
+
const copy3 = copyFlag ? this.cloneObj(curObject) : curObject;
|
|
9850
|
+
handleMapperOnLen.push(stack.length);
|
|
9851
|
+
mapperCopyStack.push(copy3);
|
|
9852
|
+
mapperOrigStack.push(curObject);
|
|
9853
|
+
mapperParent.push(curParent);
|
|
9854
|
+
mapperParentKey.push(curKey);
|
|
9855
|
+
if (continues && !didShortCut) {
|
|
9856
|
+
for (const key in copy3) {
|
|
9857
|
+
if (!Object.hasOwn(copy3, key)) {
|
|
9858
|
+
continue;
|
|
9859
|
+
}
|
|
9860
|
+
const val = copy3[key];
|
|
9861
|
+
const onlyShallow = shallowKeys && shallowKeys?.has(key);
|
|
9862
|
+
if (onlyShallow) {
|
|
9863
|
+
copy3[key] = this.cloneObj(val);
|
|
9864
|
+
}
|
|
9865
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9866
|
+
continue;
|
|
9867
|
+
}
|
|
9868
|
+
if (!onlyShallow && val !== null && typeof val === "object") {
|
|
9869
|
+
stack.push(val);
|
|
9870
|
+
stackParentKey.push(key);
|
|
9871
|
+
stackParent.push(copy3);
|
|
9872
|
+
}
|
|
9788
9873
|
}
|
|
9789
|
-
copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9790
9874
|
}
|
|
9791
9875
|
}
|
|
9792
|
-
|
|
9793
|
-
}
|
|
9794
|
-
|
|
9876
|
+
handleMapper();
|
|
9877
|
+
}
|
|
9878
|
+
if (stack.length >= this.maxStackSize) {
|
|
9879
|
+
throw new Error("Transform object stack overflowed");
|
|
9880
|
+
}
|
|
9881
|
+
handleMapper();
|
|
9882
|
+
return resultWrap.res;
|
|
9795
9883
|
}
|
|
9796
9884
|
/**
|
|
9797
9885
|
* Visitor that visits all objects. Visits deeper objects first.
|
|
9798
9886
|
*/
|
|
9799
9887
|
visitObject(startObject, visitor, preVisitor = () => ({})) {
|
|
9888
|
+
const defaults2 = this.defaultContext;
|
|
9889
|
+
const defaultContinues = defaults2.continue ?? true;
|
|
9890
|
+
const defaultIgnoreKeys = defaults2.ignoreKeys;
|
|
9891
|
+
const defaultShortcut = defaults2.shortcut ?? false;
|
|
9800
9892
|
let didShortCut = false;
|
|
9801
|
-
const
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9893
|
+
const stack = [startObject];
|
|
9894
|
+
const handleVisitorOnLen = [];
|
|
9895
|
+
const visitorStack = [];
|
|
9896
|
+
function handleVisitor() {
|
|
9897
|
+
while (stack.length === handleVisitorOnLen.at(-1)) {
|
|
9898
|
+
handleVisitorOnLen.pop();
|
|
9899
|
+
const toVisit = visitorStack.pop();
|
|
9900
|
+
visitor(toVisit);
|
|
9901
|
+
}
|
|
9902
|
+
}
|
|
9903
|
+
while (stack.length > 0 && stack.length < this.maxStackSize) {
|
|
9904
|
+
const curObject = stack.pop();
|
|
9905
|
+
if (!didShortCut) {
|
|
9906
|
+
if (Array.isArray(curObject)) {
|
|
9907
|
+
for (let i = curObject.length - 1; i >= 0; i--) {
|
|
9908
|
+
stack.push(curObject[i]);
|
|
9909
|
+
}
|
|
9910
|
+
handleVisitor();
|
|
9911
|
+
continue;
|
|
9912
|
+
}
|
|
9913
|
+
const context = preVisitor(curObject);
|
|
9914
|
+
didShortCut = context.shortcut ?? defaultShortcut;
|
|
9915
|
+
const continues = context.continue ?? defaultContinues;
|
|
9916
|
+
const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
|
|
9917
|
+
handleVisitorOnLen.push(stack.length);
|
|
9918
|
+
visitorStack.push(curObject);
|
|
9919
|
+
if (continues && !didShortCut) {
|
|
9920
|
+
for (const key in curObject) {
|
|
9921
|
+
if (!Object.hasOwn(curObject, key)) {
|
|
9922
|
+
continue;
|
|
9923
|
+
}
|
|
9924
|
+
if (ignoreKeys && ignoreKeys.has(key)) {
|
|
9925
|
+
continue;
|
|
9926
|
+
}
|
|
9927
|
+
const val = curObject[key];
|
|
9928
|
+
if (val && typeof val === "object") {
|
|
9929
|
+
stack.push(val);
|
|
9930
|
+
}
|
|
9809
9931
|
}
|
|
9810
|
-
this.safeObjectVisit(value, (obj) => recurse(obj));
|
|
9811
9932
|
}
|
|
9812
9933
|
}
|
|
9813
|
-
|
|
9814
|
-
}
|
|
9815
|
-
|
|
9934
|
+
handleVisitor();
|
|
9935
|
+
}
|
|
9936
|
+
if (stack.length >= this.maxStackSize) {
|
|
9937
|
+
throw new Error("Transform object stack overflowed");
|
|
9938
|
+
}
|
|
9939
|
+
handleVisitor();
|
|
9816
9940
|
}
|
|
9941
|
+
};
|
|
9942
|
+
|
|
9943
|
+
// ../../packages/core/lib/TransformerTyped.js
|
|
9944
|
+
var TransformerTyped = class _TransformerTyped extends TransformerObject {
|
|
9945
|
+
defaultNodePreVisitor;
|
|
9946
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
9947
|
+
super(defaultContext);
|
|
9948
|
+
this.defaultNodePreVisitor = defaultNodePreVisitor;
|
|
9949
|
+
}
|
|
9950
|
+
clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
|
|
9951
|
+
return new _TransformerTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
|
|
9952
|
+
}
|
|
9953
|
+
/**
|
|
9954
|
+
* Transform a single node.
|
|
9955
|
+
* The transformation calls the preVisitor from starting from the startObject.
|
|
9956
|
+
* The preVisitor can dictate whether transformation should be stopped.
|
|
9957
|
+
* Note that stopping the transformation also prevets further copying.
|
|
9958
|
+
* The transformer itself transforms object starting with the deepest one that can be visited.
|
|
9959
|
+
* The transformer callback is performed on a copy of the original.
|
|
9960
|
+
* @param startObject
|
|
9961
|
+
* @param nodeCallBacks
|
|
9962
|
+
*/
|
|
9817
9963
|
transformNode(startObject, nodeCallBacks) {
|
|
9818
|
-
const transformWrapper = (
|
|
9819
|
-
|
|
9964
|
+
const transformWrapper = (copy3, orig) => {
|
|
9965
|
+
let ogTransform;
|
|
9966
|
+
const casted = copy3;
|
|
9820
9967
|
if (casted.type) {
|
|
9821
|
-
|
|
9822
|
-
if (ogFunc) {
|
|
9823
|
-
return ogFunc(casted);
|
|
9824
|
-
}
|
|
9968
|
+
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9825
9969
|
}
|
|
9826
|
-
return
|
|
9970
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9827
9971
|
};
|
|
9828
|
-
const
|
|
9972
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9973
|
+
const preVisitWrapper = (curObject) => {
|
|
9974
|
+
let ogPreVisit;
|
|
9975
|
+
let nodeContext = {};
|
|
9829
9976
|
const casted = curObject;
|
|
9830
9977
|
if (casted.type) {
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
return ogFunc(casted);
|
|
9834
|
-
}
|
|
9978
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9979
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9835
9980
|
}
|
|
9836
|
-
return {};
|
|
9981
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9837
9982
|
};
|
|
9838
|
-
return this.transformObject(startObject, transformWrapper,
|
|
9983
|
+
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9839
9984
|
}
|
|
9985
|
+
/**
|
|
9986
|
+
* Similar to {@link this.transformNode}, but without copying the startObject.
|
|
9987
|
+
* The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
|
|
9988
|
+
* @param startObject
|
|
9989
|
+
* @param nodeCallBacks
|
|
9990
|
+
*/
|
|
9840
9991
|
visitNode(startObject, nodeCallBacks) {
|
|
9841
|
-
const
|
|
9992
|
+
const visitorWrapper = (curObject) => {
|
|
9842
9993
|
const casted = curObject;
|
|
9843
9994
|
if (casted.type) {
|
|
9844
|
-
const
|
|
9845
|
-
if (
|
|
9846
|
-
|
|
9995
|
+
const ogTransform = nodeCallBacks[casted.type]?.visitor;
|
|
9996
|
+
if (ogTransform) {
|
|
9997
|
+
ogTransform(casted);
|
|
9847
9998
|
}
|
|
9848
9999
|
}
|
|
9849
10000
|
};
|
|
10001
|
+
const nodeDefaults = this.defaultNodePreVisitor;
|
|
9850
10002
|
const preVisitWrapper = (curObject) => {
|
|
10003
|
+
let ogPreVisit;
|
|
10004
|
+
let nodeContext = {};
|
|
9851
10005
|
const casted = curObject;
|
|
9852
10006
|
if (casted.type) {
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
return ogFunc(casted);
|
|
9856
|
-
}
|
|
10007
|
+
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
10008
|
+
nodeContext = nodeDefaults[casted.type] ?? nodeContext;
|
|
9857
10009
|
}
|
|
9858
|
-
return {};
|
|
10010
|
+
return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
|
|
9859
10011
|
};
|
|
9860
|
-
this.visitObject(startObject,
|
|
10012
|
+
return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
|
|
9861
10013
|
}
|
|
10014
|
+
/**
|
|
10015
|
+
* Traverses only selected nodes as returned by the function.
|
|
10016
|
+
* @param currentNode
|
|
10017
|
+
* @param traverse
|
|
10018
|
+
*/
|
|
9862
10019
|
traverseNodes(currentNode, traverse) {
|
|
9863
10020
|
let didShortCut = false;
|
|
9864
10021
|
const recurse = (curNode) => {
|
|
@@ -9879,11 +10036,27 @@ var TransformerType = class {
|
|
|
9879
10036
|
recurse(currentNode);
|
|
9880
10037
|
}
|
|
9881
10038
|
};
|
|
9882
|
-
|
|
10039
|
+
|
|
10040
|
+
// ../../packages/core/lib/TransformerSubTyped.js
|
|
10041
|
+
var TransformerSubTyped = class _TransformerSubTyped extends TransformerTyped {
|
|
10042
|
+
constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
|
|
10043
|
+
super(defaultContext, defaultNodePreVisitor);
|
|
10044
|
+
}
|
|
10045
|
+
clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
|
|
10046
|
+
return new _TransformerSubTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
|
|
10047
|
+
}
|
|
10048
|
+
/**
|
|
10049
|
+
* Shares the functionality and first two arguments with {@link this.transformNode}.
|
|
10050
|
+
* The third argument allows you to also transform based on the subType of objects.
|
|
10051
|
+
* Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
|
|
10052
|
+
* @param startObject
|
|
10053
|
+
* @param nodeCallBacks
|
|
10054
|
+
* @param nodeSpecificCallBacks
|
|
10055
|
+
*/
|
|
9883
10056
|
transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9884
|
-
const transformWrapper = (
|
|
10057
|
+
const transformWrapper = (copy3, orig) => {
|
|
9885
10058
|
let ogTransform;
|
|
9886
|
-
const casted =
|
|
10059
|
+
const casted = copy3;
|
|
9887
10060
|
if (casted.type && casted.subType) {
|
|
9888
10061
|
const specific = nodeSpecificCallBacks[casted.type];
|
|
9889
10062
|
if (specific) {
|
|
@@ -9893,7 +10066,7 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9893
10066
|
ogTransform = nodeCallBacks[casted.type]?.transform;
|
|
9894
10067
|
}
|
|
9895
10068
|
}
|
|
9896
|
-
return ogTransform ? ogTransform(casted) :
|
|
10069
|
+
return ogTransform ? ogTransform(casted, orig) : copy3;
|
|
9897
10070
|
};
|
|
9898
10071
|
const preVisitWrapper = (curObject) => {
|
|
9899
10072
|
let ogPreVisit;
|
|
@@ -9907,12 +10080,13 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9907
10080
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9908
10081
|
}
|
|
9909
10082
|
}
|
|
9910
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10083
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9911
10084
|
};
|
|
9912
10085
|
return this.transformObject(startObject, transformWrapper, preVisitWrapper);
|
|
9913
10086
|
}
|
|
9914
10087
|
/**
|
|
9915
|
-
*
|
|
10088
|
+
* Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
|
|
10089
|
+
* When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
|
|
9916
10090
|
*/
|
|
9917
10091
|
visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
|
|
9918
10092
|
const visitWrapper = (curObject) => {
|
|
@@ -9943,10 +10117,16 @@ var TransformerSubType = class extends TransformerType {
|
|
|
9943
10117
|
ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
|
|
9944
10118
|
}
|
|
9945
10119
|
}
|
|
9946
|
-
return ogPreVisit ? ogPreVisit(casted) :
|
|
10120
|
+
return ogPreVisit ? ogPreVisit(casted) : {};
|
|
9947
10121
|
};
|
|
9948
10122
|
this.visitObject(startObject, visitWrapper, preVisitWrapper);
|
|
9949
10123
|
}
|
|
10124
|
+
/**
|
|
10125
|
+
* Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
|
|
10126
|
+
* @param currentNode
|
|
10127
|
+
* @param traverseNode
|
|
10128
|
+
* @param traverseSubNode
|
|
10129
|
+
*/
|
|
9950
10130
|
traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
|
|
9951
10131
|
let didShortCut = false;
|
|
9952
10132
|
const recurse = (curNode) => {
|
|
@@ -11019,8 +11199,8 @@ function PatternFactoryMixin(Base) {
|
|
|
11019
11199
|
isPatternOptional(obj) {
|
|
11020
11200
|
return this.isOfSubType(obj, nodeType5, "optional");
|
|
11021
11201
|
}
|
|
11022
|
-
patternValues(values3, loc) {
|
|
11023
|
-
return { type: nodeType5, subType: "values", values: values3, loc };
|
|
11202
|
+
patternValues(variables, values3, loc) {
|
|
11203
|
+
return { type: nodeType5, subType: "values", variables, values: values3, loc };
|
|
11024
11204
|
}
|
|
11025
11205
|
isPatternValues(obj) {
|
|
11026
11206
|
return this.isOfSubType(obj, nodeType5, "values");
|
|
@@ -11195,7 +11375,7 @@ function TermFactoryMixin(Base) {
|
|
|
11195
11375
|
isTerm(x) {
|
|
11196
11376
|
return this.isOfType(x, "term");
|
|
11197
11377
|
}
|
|
11198
|
-
|
|
11378
|
+
termBlank(label, loc) {
|
|
11199
11379
|
const base = {
|
|
11200
11380
|
type: "term",
|
|
11201
11381
|
subType: "blankNode",
|
|
@@ -11209,7 +11389,7 @@ function TermFactoryMixin(Base) {
|
|
|
11209
11389
|
isTermBlank(obj) {
|
|
11210
11390
|
return this.isOfSubType(obj, nodeType8, "blankNode");
|
|
11211
11391
|
}
|
|
11212
|
-
|
|
11392
|
+
termLiteral(loc, value, langOrIri) {
|
|
11213
11393
|
return {
|
|
11214
11394
|
type: nodeType8,
|
|
11215
11395
|
subType: "literal",
|
|
@@ -11231,7 +11411,7 @@ function TermFactoryMixin(Base) {
|
|
|
11231
11411
|
const casted = obj;
|
|
11232
11412
|
return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
|
|
11233
11413
|
}
|
|
11234
|
-
|
|
11414
|
+
termVariable(value, loc) {
|
|
11235
11415
|
return {
|
|
11236
11416
|
type: nodeType8,
|
|
11237
11417
|
subType: "variable",
|
|
@@ -11242,7 +11422,7 @@ function TermFactoryMixin(Base) {
|
|
|
11242
11422
|
isTermVariable(obj) {
|
|
11243
11423
|
return this.isOfSubType(obj, nodeType8, "variable");
|
|
11244
11424
|
}
|
|
11245
|
-
|
|
11425
|
+
termNamed(loc, value, prefix) {
|
|
11246
11426
|
const base = {
|
|
11247
11427
|
type: nodeType8,
|
|
11248
11428
|
subType: "namedNode",
|
|
@@ -11505,7 +11685,7 @@ var CommonIRIs;
|
|
|
11505
11685
|
CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
11506
11686
|
CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
11507
11687
|
})(CommonIRIs || (CommonIRIs = {}));
|
|
11508
|
-
var AstTransformer = class extends
|
|
11688
|
+
var AstTransformer = class extends TransformerSubTyped {
|
|
11509
11689
|
};
|
|
11510
11690
|
|
|
11511
11691
|
// ../../packages/rules-sparql-1-1/lib/validation/validators.js
|
|
@@ -11633,8 +11813,7 @@ function findPatternBoundedVars(iter, boundedVars) {
|
|
|
11633
11813
|
optional: (op) => ({ next: op.patterns }),
|
|
11634
11814
|
service: (op) => ({ next: [op.name, ...op.patterns] }),
|
|
11635
11815
|
bind: (op) => ({ next: [op.variable] }),
|
|
11636
|
-
graph: (op) => ({ next: [op.name, ...op.patterns] })
|
|
11637
|
-
minus: (op) => ({ next: op.patterns.slice(0, 1) })
|
|
11816
|
+
graph: (op) => ({ next: [op.name, ...op.patterns] })
|
|
11638
11817
|
},
|
|
11639
11818
|
term: {
|
|
11640
11819
|
variable: (op) => {
|
|
@@ -11721,17 +11900,20 @@ var rdfLiteral = {
|
|
|
11721
11900
|
return OPTION(() => OR([
|
|
11722
11901
|
{ ALT: () => {
|
|
11723
11902
|
const lang2 = CONSUME(terminals_exports.langTag);
|
|
11724
|
-
return ACTION(() => C.astFactory.
|
|
11903
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
|
|
11725
11904
|
} },
|
|
11726
11905
|
{ ALT: () => {
|
|
11727
11906
|
CONSUME(symbols_exports.hathat);
|
|
11728
11907
|
const iriVal = SUBRULE1(iri2);
|
|
11729
|
-
return ACTION(() => C.astFactory.
|
|
11908
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
11730
11909
|
} }
|
|
11731
11910
|
])) ?? value;
|
|
11732
11911
|
},
|
|
11733
|
-
gImpl: ({ SUBRULE, PRINT,
|
|
11734
|
-
astFactory.printFilter(ast, () =>
|
|
11912
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
11913
|
+
astFactory.printFilter(ast, () => {
|
|
11914
|
+
PRINT_WORD("");
|
|
11915
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
11916
|
+
});
|
|
11735
11917
|
if (ast.langOrIri) {
|
|
11736
11918
|
if (typeof ast.langOrIri === "string") {
|
|
11737
11919
|
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
@@ -11758,7 +11940,7 @@ var numericLiteralUnsigned = {
|
|
|
11758
11940
|
{ ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
|
|
11759
11941
|
{ ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
|
|
11760
11942
|
]);
|
|
11761
|
-
return ACTION(() => C.astFactory.
|
|
11943
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11762
11944
|
}
|
|
11763
11945
|
};
|
|
11764
11946
|
var numericLiteralPositive = {
|
|
@@ -11769,7 +11951,7 @@ var numericLiteralPositive = {
|
|
|
11769
11951
|
{ ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
|
|
11770
11952
|
{ ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
|
|
11771
11953
|
]);
|
|
11772
|
-
return ACTION(() => C.astFactory.
|
|
11954
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11773
11955
|
}
|
|
11774
11956
|
};
|
|
11775
11957
|
var numericLiteralNegative = {
|
|
@@ -11780,7 +11962,7 @@ var numericLiteralNegative = {
|
|
|
11780
11962
|
{ ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
|
|
11781
11963
|
{ ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
|
|
11782
11964
|
]);
|
|
11783
|
-
return ACTION(() => C.astFactory.
|
|
11965
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
11784
11966
|
}
|
|
11785
11967
|
};
|
|
11786
11968
|
var booleanLiteral = {
|
|
@@ -11790,7 +11972,7 @@ var booleanLiteral = {
|
|
|
11790
11972
|
{ ALT: () => CONSUME(true_) },
|
|
11791
11973
|
{ ALT: () => CONSUME(false_) }
|
|
11792
11974
|
]);
|
|
11793
|
-
return ACTION(() => C.astFactory.
|
|
11975
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
|
|
11794
11976
|
}
|
|
11795
11977
|
};
|
|
11796
11978
|
var string = {
|
|
@@ -11832,7 +12014,7 @@ var string = {
|
|
|
11832
12014
|
return char;
|
|
11833
12015
|
}
|
|
11834
12016
|
});
|
|
11835
|
-
return F2.
|
|
12017
|
+
return F2.termLiteral(F2.sourceLocation(x[0]), value);
|
|
11836
12018
|
});
|
|
11837
12019
|
}
|
|
11838
12020
|
};
|
|
@@ -11848,7 +12030,7 @@ var iriFull = {
|
|
|
11848
12030
|
name: "iriFull",
|
|
11849
12031
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11850
12032
|
const iriToken = CONSUME(terminals_exports.iriRef);
|
|
11851
|
-
return ACTION(() => C.astFactory.
|
|
12033
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
11852
12034
|
},
|
|
11853
12035
|
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
11854
12036
|
F2.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
@@ -11861,16 +12043,16 @@ var prefixedName = {
|
|
|
11861
12043
|
const longName = CONSUME(terminals_exports.pNameLn);
|
|
11862
12044
|
return ACTION(() => {
|
|
11863
12045
|
const [prefix, localName] = longName.image.split(":");
|
|
11864
|
-
return C.astFactory.
|
|
12046
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
11865
12047
|
});
|
|
11866
12048
|
} },
|
|
11867
12049
|
{ ALT: () => {
|
|
11868
12050
|
const shortName = CONSUME(terminals_exports.pNameNs);
|
|
11869
|
-
return ACTION(() => C.astFactory.
|
|
12051
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
11870
12052
|
} }
|
|
11871
12053
|
]),
|
|
11872
|
-
gImpl: ({
|
|
11873
|
-
F2.printFilter(ast, () =>
|
|
12054
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
12055
|
+
F2.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
11874
12056
|
}
|
|
11875
12057
|
};
|
|
11876
12058
|
var canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
@@ -11880,11 +12062,11 @@ var blankNode = {
|
|
|
11880
12062
|
const result = OR([
|
|
11881
12063
|
{ ALT: () => {
|
|
11882
12064
|
const labelToken = CONSUME(terminals_exports.blankNodeLabel);
|
|
11883
|
-
return ACTION(() => C.astFactory.
|
|
12065
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
11884
12066
|
} },
|
|
11885
12067
|
{ ALT: () => {
|
|
11886
12068
|
const anonToken = CONSUME(terminals_exports.anon);
|
|
11887
|
-
return ACTION(() => C.astFactory.
|
|
12069
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
11888
12070
|
} }
|
|
11889
12071
|
]);
|
|
11890
12072
|
ACTION(() => {
|
|
@@ -11894,15 +12076,15 @@ var blankNode = {
|
|
|
11894
12076
|
});
|
|
11895
12077
|
return result;
|
|
11896
12078
|
},
|
|
11897
|
-
gImpl: ({
|
|
11898
|
-
astFactory.printFilter(ast, () =>
|
|
12079
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
12080
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
11899
12081
|
}
|
|
11900
12082
|
};
|
|
11901
12083
|
var verbA = {
|
|
11902
12084
|
name: "VerbA",
|
|
11903
12085
|
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
11904
12086
|
const token = CONSUME(a);
|
|
11905
|
-
return ACTION(() => C.astFactory.
|
|
12087
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
|
|
11906
12088
|
}
|
|
11907
12089
|
};
|
|
11908
12090
|
|
|
@@ -11936,10 +12118,10 @@ var baseDecl2 = {
|
|
|
11936
12118
|
const val = SUBRULE(iriFull);
|
|
11937
12119
|
return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
|
|
11938
12120
|
},
|
|
11939
|
-
gImpl: ({ SUBRULE,
|
|
11940
|
-
F2.printFilter(ast, () =>
|
|
12121
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12122
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
|
|
11941
12123
|
SUBRULE(iri2, ast.value);
|
|
11942
|
-
F2.printFilter(ast, () =>
|
|
12124
|
+
F2.printFilter(ast, () => NEW_LINE());
|
|
11943
12125
|
}
|
|
11944
12126
|
};
|
|
11945
12127
|
var prefixDecl2 = {
|
|
@@ -11950,12 +12132,12 @@ var prefixDecl2 = {
|
|
|
11950
12132
|
const value = SUBRULE(iriFull);
|
|
11951
12133
|
return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
|
|
11952
12134
|
},
|
|
11953
|
-
gImpl: ({ SUBRULE,
|
|
12135
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
11954
12136
|
F2.printFilter(ast, () => {
|
|
11955
|
-
|
|
12137
|
+
PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
|
|
11956
12138
|
});
|
|
11957
12139
|
SUBRULE(iri2, ast.value);
|
|
11958
|
-
F2.printFilter(ast, () =>
|
|
12140
|
+
F2.printFilter(ast, () => NEW_LINE());
|
|
11959
12141
|
}
|
|
11960
12142
|
};
|
|
11961
12143
|
var verb = {
|
|
@@ -11992,10 +12174,10 @@ var var_ = {
|
|
|
11992
12174
|
{ ALT: () => CONSUME(terminals_exports.var1) },
|
|
11993
12175
|
{ ALT: () => CONSUME(terminals_exports.var2) }
|
|
11994
12176
|
]);
|
|
11995
|
-
return ACTION(() => C.astFactory.
|
|
12177
|
+
return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
|
|
11996
12178
|
},
|
|
11997
|
-
gImpl: ({
|
|
11998
|
-
F2.printFilter(ast, () =>
|
|
12179
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
|
|
12180
|
+
F2.printFilter(ast, () => PRINT(`?${ast.value}`));
|
|
11999
12181
|
}
|
|
12000
12182
|
};
|
|
12001
12183
|
var graphTerm = {
|
|
@@ -12008,7 +12190,7 @@ var graphTerm = {
|
|
|
12008
12190
|
{ GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
|
|
12009
12191
|
{ ALT: () => {
|
|
12010
12192
|
const tokenNil = CONSUME(terminals_exports.nil);
|
|
12011
|
-
return ACTION(() => C.astFactory.
|
|
12193
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
|
|
12012
12194
|
} }
|
|
12013
12195
|
]),
|
|
12014
12196
|
gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
@@ -12638,13 +12820,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
|
12638
12820
|
var triplesBlock = {
|
|
12639
12821
|
name: "triplesBlock",
|
|
12640
12822
|
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
12641
|
-
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F2 }) => {
|
|
12823
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
12642
12824
|
for (const [index, triple] of ast.triples.entries()) {
|
|
12643
12825
|
HANDLE_LOC(triple, () => {
|
|
12644
12826
|
const nextTriple = ast.triples.at(index);
|
|
12645
12827
|
if (F2.isTripleCollection(triple)) {
|
|
12646
12828
|
SUBRULE(graphNodePath, triple);
|
|
12647
|
-
F2.printFilter(triple, () =>
|
|
12829
|
+
F2.printFilter(triple, () => {
|
|
12830
|
+
PRINT_WORD(".");
|
|
12831
|
+
NEW_LINE();
|
|
12832
|
+
});
|
|
12648
12833
|
} else {
|
|
12649
12834
|
SUBRULE(graphNodePath, triple.subject);
|
|
12650
12835
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
@@ -12656,11 +12841,17 @@ var triplesBlock = {
|
|
|
12656
12841
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12657
12842
|
SUBRULE(graphNodePath, triple.object);
|
|
12658
12843
|
if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
12659
|
-
F2.printFilter(ast, () =>
|
|
12844
|
+
F2.printFilter(ast, () => {
|
|
12845
|
+
PRINT_WORD(".");
|
|
12846
|
+
NEW_LINE();
|
|
12847
|
+
});
|
|
12660
12848
|
} else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
12661
12849
|
F2.printFilter(ast, () => PRINT_WORD(","));
|
|
12662
12850
|
} else {
|
|
12663
|
-
F2.printFilter(ast, () =>
|
|
12851
|
+
F2.printFilter(ast, () => {
|
|
12852
|
+
PRINT_WORD(";");
|
|
12853
|
+
NEW_LINE();
|
|
12854
|
+
});
|
|
12664
12855
|
}
|
|
12665
12856
|
}
|
|
12666
12857
|
});
|
|
@@ -12793,10 +12984,10 @@ function collectionImpl(name, allowPaths) {
|
|
|
12793
12984
|
return ACTION(() => {
|
|
12794
12985
|
const F2 = C.astFactory;
|
|
12795
12986
|
const triples = [];
|
|
12796
|
-
const predFirst = F2.
|
|
12797
|
-
const predRest = F2.
|
|
12798
|
-
const predNil = F2.
|
|
12799
|
-
const listHead = F2.
|
|
12987
|
+
const predFirst = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
|
|
12988
|
+
const predRest = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
|
|
12989
|
+
const predNil = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
|
|
12990
|
+
const listHead = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
|
|
12800
12991
|
let iterHead = listHead;
|
|
12801
12992
|
for (const [index, term] of terms.entries()) {
|
|
12802
12993
|
const lastInList = index === terms.length - 1;
|
|
@@ -12806,7 +12997,7 @@ function collectionImpl(name, allowPaths) {
|
|
|
12806
12997
|
const nilTriple = F2.triple(iterHead, predRest, predNil);
|
|
12807
12998
|
triples.push(nilTriple);
|
|
12808
12999
|
} else {
|
|
12809
|
-
const tail = F2.
|
|
13000
|
+
const tail = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
|
|
12810
13001
|
const linkTriple = F2.triple(iterHead, predRest, tail);
|
|
12811
13002
|
triples.push(linkTriple);
|
|
12812
13003
|
iterHead = tail;
|
|
@@ -12846,16 +13037,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12846
13037
|
name,
|
|
12847
13038
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
12848
13039
|
const startToken = CONSUME(symbols_exports.LSquare);
|
|
12849
|
-
const blankNode2 = ACTION(() => C.astFactory.
|
|
13040
|
+
const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
12850
13041
|
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
|
|
12851
13042
|
const endToken = CONSUME(symbols_exports.RSquare);
|
|
12852
13043
|
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
12853
13044
|
},
|
|
12854
|
-
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
|
|
13045
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
12855
13046
|
const { astFactory: F2, indentInc } = c;
|
|
12856
13047
|
F2.printFilter(ast, () => {
|
|
12857
13048
|
c[traqulaIndentation] += indentInc;
|
|
12858
|
-
PRINT("[
|
|
13049
|
+
PRINT("[");
|
|
13050
|
+
NEW_LINE();
|
|
12859
13051
|
});
|
|
12860
13052
|
for (const triple of ast.triples) {
|
|
12861
13053
|
HANDLE_LOC(triple, () => {
|
|
@@ -12866,7 +13058,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
|
|
|
12866
13058
|
}
|
|
12867
13059
|
F2.printFilter(triple, () => PRINT_WORD(""));
|
|
12868
13060
|
SUBRULE(graphNodePath, triple.object);
|
|
12869
|
-
F2.printFilter(ast, () =>
|
|
13061
|
+
F2.printFilter(ast, () => {
|
|
13062
|
+
PRINT_WORD(";");
|
|
13063
|
+
NEW_LINE();
|
|
13064
|
+
});
|
|
12870
13065
|
});
|
|
12871
13066
|
}
|
|
12872
13067
|
F2.printFilter(ast, () => {
|
|
@@ -12925,18 +13120,19 @@ var groupGraphPattern = {
|
|
|
12925
13120
|
const close = CONSUME(symbols_exports.RCurly);
|
|
12926
13121
|
return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
|
|
12927
13122
|
},
|
|
12928
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
13123
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
12929
13124
|
const { astFactory: F2, indentInc } = C;
|
|
12930
13125
|
F2.printFilter(ast, () => {
|
|
12931
13126
|
C[traqulaIndentation] += indentInc;
|
|
12932
|
-
PRINT_WORD("{
|
|
13127
|
+
PRINT_WORD("{");
|
|
13128
|
+
NEW_LINE();
|
|
12933
13129
|
});
|
|
12934
13130
|
for (const pattern of ast.patterns) {
|
|
12935
13131
|
SUBRULE(generatePattern, pattern);
|
|
12936
13132
|
}
|
|
12937
13133
|
F2.printFilter(ast, () => {
|
|
12938
13134
|
C[traqulaIndentation] -= indentInc;
|
|
12939
|
-
|
|
13135
|
+
PRINT_ON_OWN_LINE("}");
|
|
12940
13136
|
});
|
|
12941
13137
|
}
|
|
12942
13138
|
};
|
|
@@ -13086,12 +13282,15 @@ var bind2 = {
|
|
|
13086
13282
|
const close = CONSUME(symbols_exports.RParen);
|
|
13087
13283
|
return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
|
|
13088
13284
|
},
|
|
13089
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13285
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
13090
13286
|
F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
|
|
13091
13287
|
SUBRULE(expression, ast.expression);
|
|
13092
13288
|
F2.printFilter(ast, () => PRINT_WORD("AS"));
|
|
13093
13289
|
SUBRULE(var_, ast.variable);
|
|
13094
|
-
F2.printFilter(ast, () =>
|
|
13290
|
+
F2.printFilter(ast, () => {
|
|
13291
|
+
PRINT_WORD(")");
|
|
13292
|
+
NEW_LINE();
|
|
13293
|
+
});
|
|
13095
13294
|
}
|
|
13096
13295
|
};
|
|
13097
13296
|
var inlineData = {
|
|
@@ -13099,34 +13298,46 @@ var inlineData = {
|
|
|
13099
13298
|
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
13100
13299
|
const values3 = CONSUME(values2);
|
|
13101
13300
|
const datablock = SUBRULE(dataBlock);
|
|
13102
|
-
return ACTION(() =>
|
|
13301
|
+
return ACTION(() => {
|
|
13302
|
+
datablock.loc = C.astFactory.sourceLocation(values3, datablock);
|
|
13303
|
+
return datablock;
|
|
13304
|
+
});
|
|
13103
13305
|
},
|
|
13104
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
13306
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
13105
13307
|
const { astFactory: F2, indentInc } = C;
|
|
13106
|
-
const variables =
|
|
13308
|
+
const variables = ast.variables;
|
|
13309
|
+
const singleVar = variables.length === 1;
|
|
13310
|
+
F2.printFilter(ast, () => {
|
|
13311
|
+
PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
|
|
13312
|
+
});
|
|
13313
|
+
for (const variable of variables) {
|
|
13314
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13315
|
+
SUBRULE(varOrTerm, variable);
|
|
13316
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
13317
|
+
}
|
|
13107
13318
|
F2.printFilter(ast, () => {
|
|
13108
|
-
PRINT_ON_EMPTY("");
|
|
13109
|
-
PRINT_WORD("VALUES", "(");
|
|
13110
|
-
for (const variable of variables) {
|
|
13111
|
-
PRINT_WORD(`?${variable}`);
|
|
13112
|
-
}
|
|
13113
13319
|
C[traqulaIndentation] += indentInc;
|
|
13114
|
-
PRINT_WORD(")", "{
|
|
13320
|
+
PRINT_WORD(singleVar ? "" : ")", "{");
|
|
13321
|
+
NEW_LINE();
|
|
13115
13322
|
});
|
|
13116
13323
|
for (const mapping of ast.values) {
|
|
13117
|
-
F2.printFilter(ast, () => PRINT_WORD("("));
|
|
13324
|
+
F2.printFilter(ast, () => !singleVar && PRINT_WORD("("));
|
|
13118
13325
|
for (const variable of variables) {
|
|
13119
|
-
|
|
13326
|
+
const var_2 = variable.value;
|
|
13327
|
+
if (mapping[var_2] === void 0) {
|
|
13120
13328
|
F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
|
|
13121
13329
|
} else {
|
|
13122
|
-
SUBRULE(graphNodePath, mapping[
|
|
13330
|
+
SUBRULE(graphNodePath, mapping[var_2]);
|
|
13123
13331
|
}
|
|
13124
13332
|
}
|
|
13125
|
-
F2.printFilter(ast, () =>
|
|
13333
|
+
F2.printFilter(ast, () => {
|
|
13334
|
+
PRINT_WORD(singleVar ? "" : ")");
|
|
13335
|
+
NEW_LINE();
|
|
13336
|
+
});
|
|
13126
13337
|
}
|
|
13127
13338
|
F2.printFilter(ast, () => {
|
|
13128
13339
|
C[traqulaIndentation] -= indentInc;
|
|
13129
|
-
|
|
13340
|
+
PRINT_ON_OWN_LINE("}");
|
|
13130
13341
|
});
|
|
13131
13342
|
}
|
|
13132
13343
|
};
|
|
@@ -13150,7 +13361,7 @@ var inlineDataOneVar = {
|
|
|
13150
13361
|
});
|
|
13151
13362
|
});
|
|
13152
13363
|
const close = CONSUME(symbols_exports.RCurly);
|
|
13153
|
-
return ACTION(() => C.astFactory.
|
|
13364
|
+
return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
|
|
13154
13365
|
}
|
|
13155
13366
|
};
|
|
13156
13367
|
var inlineDataFull = {
|
|
@@ -13167,7 +13378,7 @@ var inlineDataFull = {
|
|
|
13167
13378
|
res.push({});
|
|
13168
13379
|
});
|
|
13169
13380
|
const close = CONSUME1(symbols_exports.RCurly);
|
|
13170
|
-
return ACTION(() => C.astFactory.
|
|
13381
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
|
|
13171
13382
|
} },
|
|
13172
13383
|
{ ALT: () => {
|
|
13173
13384
|
const open = CONSUME1(symbols_exports.LParen);
|
|
@@ -13199,7 +13410,7 @@ var inlineDataFull = {
|
|
|
13199
13410
|
});
|
|
13200
13411
|
});
|
|
13201
13412
|
const close = CONSUME2(symbols_exports.RCurly);
|
|
13202
|
-
return ACTION(() => C.astFactory.
|
|
13413
|
+
return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
|
|
13203
13414
|
} }
|
|
13204
13415
|
]);
|
|
13205
13416
|
}
|
|
@@ -13262,10 +13473,13 @@ var filter3 = {
|
|
|
13262
13473
|
const expression2 = SUBRULE(constraint);
|
|
13263
13474
|
return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
|
|
13264
13475
|
},
|
|
13265
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
13476
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
13266
13477
|
F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
|
|
13267
13478
|
SUBRULE(expression, ast.expression);
|
|
13268
|
-
F2.printFilter(ast, () =>
|
|
13479
|
+
F2.printFilter(ast, () => {
|
|
13480
|
+
PRINT_WORD(")");
|
|
13481
|
+
NEW_LINE();
|
|
13482
|
+
});
|
|
13269
13483
|
}
|
|
13270
13484
|
};
|
|
13271
13485
|
var constraint = {
|
|
@@ -13651,8 +13865,7 @@ var groupClause = {
|
|
|
13651
13865
|
},
|
|
13652
13866
|
gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13653
13867
|
F2.printFilter(ast, () => {
|
|
13654
|
-
PRINT_ON_EMPTY("");
|
|
13655
|
-
PRINT_WORDS("GROUP", "BY");
|
|
13868
|
+
PRINT_ON_EMPTY("GROUP BY ");
|
|
13656
13869
|
});
|
|
13657
13870
|
for (const grouping of ast.groupings) {
|
|
13658
13871
|
if (F2.isExpression(grouping)) {
|
|
@@ -13708,10 +13921,9 @@ var havingClause = {
|
|
|
13708
13921
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13709
13922
|
return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
|
|
13710
13923
|
},
|
|
13711
|
-
gImpl: ({
|
|
13924
|
+
gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13712
13925
|
F2.printFilter(ast, () => {
|
|
13713
|
-
PRINT_ON_EMPTY("");
|
|
13714
|
-
PRINT_WORD("HAVING");
|
|
13926
|
+
PRINT_ON_EMPTY("HAVING ");
|
|
13715
13927
|
});
|
|
13716
13928
|
for (const having2 of ast.having) {
|
|
13717
13929
|
SUBRULE(expression, having2);
|
|
@@ -13737,8 +13949,7 @@ var orderClause = {
|
|
|
13737
13949
|
},
|
|
13738
13950
|
gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
|
|
13739
13951
|
F2.printFilter(ast, () => {
|
|
13740
|
-
PRINT_ON_EMPTY("");
|
|
13741
|
-
PRINT_WORDS("ORDER", "BY");
|
|
13952
|
+
PRINT_ON_EMPTY("ORDER BY ");
|
|
13742
13953
|
});
|
|
13743
13954
|
for (const ordering of ast.orderDefs) {
|
|
13744
13955
|
if (ordering.descending) {
|
|
@@ -13797,9 +14008,9 @@ var limitOffsetClauses = {
|
|
|
13797
14008
|
return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
|
|
13798
14009
|
} }
|
|
13799
14010
|
]),
|
|
13800
|
-
gImpl: ({ PRINT_WORDS,
|
|
14011
|
+
gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
13801
14012
|
F2.printFilter(ast, () => {
|
|
13802
|
-
|
|
14013
|
+
NEW_LINE();
|
|
13803
14014
|
if (ast.limit) {
|
|
13804
14015
|
PRINT_WORDS("LIMIT", String(ast.limit));
|
|
13805
14016
|
}
|
|
@@ -13984,9 +14195,9 @@ var selectClause = {
|
|
|
13984
14195
|
ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
|
|
13985
14196
|
return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
|
|
13986
14197
|
},
|
|
13987
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14198
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
13988
14199
|
F2.printFilter(ast, () => {
|
|
13989
|
-
|
|
14200
|
+
PRINT_ON_EMPTY("SELECT ");
|
|
13990
14201
|
if (ast.val.distinct) {
|
|
13991
14202
|
PRINT_WORD("DISTINCT");
|
|
13992
14203
|
} else if (ast.val.reduced) {
|
|
@@ -14005,7 +14216,9 @@ var selectClause = {
|
|
|
14005
14216
|
SUBRULE(var_, variable.variable);
|
|
14006
14217
|
F2.printFilter(ast, () => PRINT_WORD(")"));
|
|
14007
14218
|
}
|
|
14219
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
14008
14220
|
}
|
|
14221
|
+
F2.printFilter(ast, () => PRINT_WORD(""));
|
|
14009
14222
|
}
|
|
14010
14223
|
};
|
|
14011
14224
|
var constructQuery = {
|
|
@@ -14043,18 +14256,19 @@ var constructQuery = {
|
|
|
14043
14256
|
} }
|
|
14044
14257
|
]);
|
|
14045
14258
|
},
|
|
14046
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14259
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14047
14260
|
const { astFactory: F2, indentInc } = C;
|
|
14048
|
-
F2.printFilter(ast, () =>
|
|
14261
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
|
|
14049
14262
|
if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
|
|
14050
14263
|
F2.printFilter(ast, () => {
|
|
14051
14264
|
C[traqulaIndentation] += indentInc;
|
|
14052
|
-
PRINT_WORD("{
|
|
14265
|
+
PRINT_WORD("{");
|
|
14266
|
+
NEW_LINE();
|
|
14053
14267
|
});
|
|
14054
14268
|
SUBRULE(triplesBlock, ast.template);
|
|
14055
14269
|
F2.printFilter(ast, () => {
|
|
14056
14270
|
C[traqulaIndentation] -= indentInc;
|
|
14057
|
-
|
|
14271
|
+
PRINT_ON_OWN_LINE("}");
|
|
14058
14272
|
});
|
|
14059
14273
|
}
|
|
14060
14274
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
@@ -14095,8 +14309,8 @@ var describeQuery = {
|
|
|
14095
14309
|
loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14096
14310
|
}));
|
|
14097
14311
|
},
|
|
14098
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14099
|
-
F2.printFilter(ast, () =>
|
|
14312
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14313
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
|
|
14100
14314
|
if (F2.isWildcard(ast.variables[0])) {
|
|
14101
14315
|
F2.printFilter(ast, () => PRINT_WORD("*"));
|
|
14102
14316
|
} else {
|
|
@@ -14126,8 +14340,8 @@ var askQuery = {
|
|
|
14126
14340
|
loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
|
|
14127
14341
|
}));
|
|
14128
14342
|
},
|
|
14129
|
-
gImpl: ({ SUBRULE,
|
|
14130
|
-
F2.printFilter(ast, () =>
|
|
14343
|
+
gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14344
|
+
F2.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
|
|
14131
14345
|
SUBRULE(datasetClauseStar, ast.datasets);
|
|
14132
14346
|
SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
|
|
14133
14347
|
SUBRULE(solutionModifier, ast.solutionModifiers);
|
|
@@ -14186,7 +14400,7 @@ var update = {
|
|
|
14186
14400
|
return update2;
|
|
14187
14401
|
});
|
|
14188
14402
|
},
|
|
14189
|
-
gImpl: ({ SUBRULE,
|
|
14403
|
+
gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F2 }) => {
|
|
14190
14404
|
const [head2, ...tail] = ast.updates;
|
|
14191
14405
|
if (head2) {
|
|
14192
14406
|
SUBRULE(prologue, head2.context);
|
|
@@ -14195,7 +14409,10 @@ var update = {
|
|
|
14195
14409
|
}
|
|
14196
14410
|
}
|
|
14197
14411
|
for (const update2 of tail) {
|
|
14198
|
-
F2.printFilter(ast, () =>
|
|
14412
|
+
F2.printFilter(ast, () => {
|
|
14413
|
+
PRINT(";");
|
|
14414
|
+
NEW_LINE();
|
|
14415
|
+
});
|
|
14199
14416
|
SUBRULE(prologue, update2.context);
|
|
14200
14417
|
if (update2.operation) {
|
|
14201
14418
|
SUBRULE(update1, update2.operation);
|
|
@@ -14268,9 +14485,9 @@ var load2 = {
|
|
|
14268
14485
|
});
|
|
14269
14486
|
return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
|
|
14270
14487
|
},
|
|
14271
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14488
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14272
14489
|
F2.printFilter(ast, () => {
|
|
14273
|
-
|
|
14490
|
+
PRINT_ON_EMPTY("LOAD ");
|
|
14274
14491
|
if (ast.silent) {
|
|
14275
14492
|
PRINT_WORD("SILENT");
|
|
14276
14493
|
}
|
|
@@ -14291,9 +14508,9 @@ function clearOrDrop(operation) {
|
|
|
14291
14508
|
const destination = SUBRULE1(graphRefAll);
|
|
14292
14509
|
return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
|
|
14293
14510
|
},
|
|
14294
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14511
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14295
14512
|
F2.printFilter(ast, () => {
|
|
14296
|
-
|
|
14513
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14297
14514
|
if (ast.silent) {
|
|
14298
14515
|
PRINT_WORD("SILENT");
|
|
14299
14516
|
}
|
|
@@ -14312,9 +14529,9 @@ var create2 = {
|
|
|
14312
14529
|
const destination = SUBRULE1(graphRef);
|
|
14313
14530
|
return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
|
|
14314
14531
|
},
|
|
14315
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14532
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14316
14533
|
F2.printFilter(ast, () => {
|
|
14317
|
-
|
|
14534
|
+
PRINT_ON_EMPTY("CREATE ");
|
|
14318
14535
|
if (ast.silent) {
|
|
14319
14536
|
PRINT_WORD("SILENT");
|
|
14320
14537
|
}
|
|
@@ -14333,9 +14550,9 @@ function copyMoveAddOperation(operation) {
|
|
|
14333
14550
|
const destination = SUBRULE2(graphOrDefault);
|
|
14334
14551
|
return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
|
|
14335
14552
|
},
|
|
14336
|
-
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
|
|
14553
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
|
|
14337
14554
|
F2.printFilter(ast, () => {
|
|
14338
|
-
|
|
14555
|
+
PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
|
|
14339
14556
|
if (ast.silent) {
|
|
14340
14557
|
PRINT_WORD("SILENT");
|
|
14341
14558
|
}
|
|
@@ -14384,23 +14601,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
|
|
|
14384
14601
|
}
|
|
14385
14602
|
return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
|
|
14386
14603
|
},
|
|
14387
|
-
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
|
|
14604
|
+
gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
|
|
14388
14605
|
const { astFactory: F2, indentInc } = C;
|
|
14389
14606
|
F2.printFilter(ast, () => {
|
|
14390
|
-
C[traqulaIndentation] += indentInc;
|
|
14391
14607
|
if (subType === "insertdata") {
|
|
14392
|
-
|
|
14608
|
+
PRINT_ON_EMPTY("INSERT DATA ");
|
|
14393
14609
|
} else if (subType === "deletedata") {
|
|
14394
|
-
|
|
14610
|
+
PRINT_ON_EMPTY("DELETE DATA ");
|
|
14395
14611
|
} else if (subType === "deletewhere") {
|
|
14396
|
-
|
|
14612
|
+
PRINT_ON_EMPTY("DELETE WHERE ");
|
|
14397
14613
|
}
|
|
14398
|
-
|
|
14614
|
+
C[traqulaIndentation] += indentInc;
|
|
14615
|
+
PRINT_WORD("{");
|
|
14616
|
+
NEW_LINE();
|
|
14399
14617
|
});
|
|
14400
14618
|
SUBRULE(quads, F2.wrap(ast.data, ast.loc));
|
|
14401
14619
|
F2.printFilter(ast, () => {
|
|
14402
14620
|
C[traqulaIndentation] -= indentInc;
|
|
14403
|
-
|
|
14621
|
+
PRINT_ON_OWN_LINE("}");
|
|
14404
14622
|
});
|
|
14405
14623
|
}
|
|
14406
14624
|
};
|
|
@@ -14432,36 +14650,40 @@ var modify = {
|
|
|
14432
14650
|
const where2 = SUBRULE1(groupGraphPattern);
|
|
14433
14651
|
return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
|
|
14434
14652
|
},
|
|
14435
|
-
gImpl: ({ SUBRULE,
|
|
14653
|
+
gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
|
|
14436
14654
|
const { astFactory: F2, indentInc } = C;
|
|
14437
14655
|
if (ast.graph) {
|
|
14438
|
-
F2.printFilter(ast, () =>
|
|
14656
|
+
F2.printFilter(ast, () => PRINT_WORDS("WITH"));
|
|
14439
14657
|
SUBRULE(iri2, ast.graph);
|
|
14440
14658
|
}
|
|
14441
14659
|
if (ast.delete.length > 0) {
|
|
14442
14660
|
F2.printFilter(ast, () => {
|
|
14443
14661
|
C[traqulaIndentation] += indentInc;
|
|
14444
|
-
|
|
14662
|
+
PRINT_WORDS("DELETE", "{");
|
|
14663
|
+
NEW_LINE();
|
|
14445
14664
|
});
|
|
14446
14665
|
SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
|
|
14447
14666
|
F2.printFilter(ast, () => {
|
|
14448
14667
|
C[traqulaIndentation] -= indentInc;
|
|
14449
|
-
PRINT_ON_EMPTY("}
|
|
14668
|
+
PRINT_ON_EMPTY("}");
|
|
14669
|
+
NEW_LINE();
|
|
14450
14670
|
});
|
|
14451
14671
|
}
|
|
14452
14672
|
if (ast.insert.length > 0) {
|
|
14453
14673
|
F2.printFilter(ast, () => {
|
|
14454
14674
|
C[traqulaIndentation] += indentInc;
|
|
14455
|
-
|
|
14675
|
+
PRINT_WORDS("INSERT", "{");
|
|
14676
|
+
NEW_LINE();
|
|
14456
14677
|
});
|
|
14457
14678
|
SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
|
|
14458
14679
|
F2.printFilter(ast, () => {
|
|
14459
14680
|
C[traqulaIndentation] -= indentInc;
|
|
14460
|
-
PRINT_ON_EMPTY("}
|
|
14681
|
+
PRINT_ON_EMPTY("} ");
|
|
14682
|
+
NEW_LINE();
|
|
14461
14683
|
});
|
|
14462
14684
|
}
|
|
14463
14685
|
SUBRULE(usingClauseStar, ast.from);
|
|
14464
|
-
F2.printFilter(ast, () =>
|
|
14686
|
+
F2.printFilter(ast, () => PRINT_WORDS("WHERE"));
|
|
14465
14687
|
SUBRULE(groupGraphPattern, ast.where);
|
|
14466
14688
|
}
|
|
14467
14689
|
};
|
|
@@ -14585,18 +14807,19 @@ var quadsNotTriples = {
|
|
|
14585
14807
|
const close = CONSUME(symbols_exports.RCurly);
|
|
14586
14808
|
return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
|
|
14587
14809
|
},
|
|
14588
|
-
gImpl: ({ SUBRULE, PRINT_WORD,
|
|
14810
|
+
gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
|
|
14589
14811
|
const { astFactory: F2, indentInc } = C;
|
|
14590
14812
|
F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
|
|
14591
14813
|
SUBRULE(varOrTerm, ast.graph);
|
|
14592
14814
|
F2.printFilter(ast, () => {
|
|
14593
14815
|
C[traqulaIndentation] += indentInc;
|
|
14594
|
-
PRINT_WORD("{
|
|
14816
|
+
PRINT_WORD("{");
|
|
14817
|
+
NEW_LINE();
|
|
14595
14818
|
});
|
|
14596
14819
|
SUBRULE(triplesBlock, ast.triples);
|
|
14597
14820
|
F2.printFilter(ast, () => {
|
|
14598
14821
|
C[traqulaIndentation] -= indentInc;
|
|
14599
|
-
|
|
14822
|
+
PRINT_ON_OWN_LINE("}");
|
|
14600
14823
|
});
|
|
14601
14824
|
}
|
|
14602
14825
|
};
|
|
@@ -14936,8 +15159,9 @@ var updateParserBuilder = ParserBuilder.create(updateNoModifyParserBuilder).patc
|
|
|
14936
15159
|
// lib/Parser.js
|
|
14937
15160
|
var sparql11ParserBuilder = ParserBuilder.create(queryUnitParserBuilder).merge(updateParserBuilder, []).addRule(grammar_exports.queryOrUpdate);
|
|
14938
15161
|
var Parser2 = class extends MinimalSparqlParser {
|
|
14939
|
-
constructor() {
|
|
15162
|
+
constructor(args = {}) {
|
|
14940
15163
|
const parser = sparql11ParserBuilder.build({
|
|
15164
|
+
...args,
|
|
14941
15165
|
tokenVocabulary: lexer_exports.sparql11LexerBuilder.tokenVocabulary,
|
|
14942
15166
|
queryPreProcessor: sparqlCodepointEscape
|
|
14943
15167
|
});
|