@traqula/rules-sparql-1-1 0.0.18 → 0.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/Sparql11types.d.ts +1 -0
  2. package/lib/Sparql11types.js.map +1 -1
  3. package/lib/astFactory.d.ts +9 -9
  4. package/lib/factoryMixins/Patternfactory.d.ts +1 -1
  5. package/lib/factoryMixins/Patternfactory.js +2 -2
  6. package/lib/factoryMixins/Patternfactory.js.map +1 -1
  7. package/lib/factoryMixins/TermFactory.d.ts +8 -8
  8. package/lib/factoryMixins/TermFactory.js +4 -4
  9. package/lib/factoryMixins/TermFactory.js.map +1 -1
  10. package/lib/grammar/general.js +10 -10
  11. package/lib/grammar/general.js.map +1 -1
  12. package/lib/grammar/literals.js +22 -19
  13. package/lib/grammar/literals.js.map +1 -1
  14. package/lib/grammar/propertyPaths.d.ts +2 -2
  15. package/lib/grammar/queryUnit.js +13 -10
  16. package/lib/grammar/queryUnit.js.map +1 -1
  17. package/lib/grammar/solutionModifier.js +6 -9
  18. package/lib/grammar/solutionModifier.js.map +1 -1
  19. package/lib/grammar/tripleBlock.d.ts +4 -4
  20. package/lib/grammar/tripleBlock.js +26 -13
  21. package/lib/grammar/tripleBlock.js.map +1 -1
  22. package/lib/grammar/updateUnit.js +36 -27
  23. package/lib/grammar/updateUnit.js.map +1 -1
  24. package/lib/grammar/whereClause.d.ts +4 -4
  25. package/lib/grammar/whereClause.js +43 -24
  26. package/lib/grammar/whereClause.js.map +1 -1
  27. package/lib/index.cjs +401 -189
  28. package/lib/lexer/BuiltInCalls.d.ts +1 -1
  29. package/lib/lexer/graph.d.ts +1 -1
  30. package/lib/lexer/lexer.d.ts +2 -2
  31. package/lib/lexer/symbols.d.ts +1 -1
  32. package/lib/lexer/terminals.d.ts +1 -1
  33. package/lib/sparql11HelperTypes.d.ts +1 -0
  34. package/lib/sparql11HelperTypes.js.map +1 -1
  35. package/lib/utils.d.ts +2 -2
  36. package/lib/utils.js +2 -2
  37. package/lib/utils.js.map +1 -1
  38. package/package.json +3 -3
package/lib/index.cjs CHANGED
@@ -414,7 +414,7 @@ var AstCoreFactory = class {
414
414
  if (filtered.length === 0) {
415
415
  return this.gen();
416
416
  }
417
- const first2 = filtered[0];
417
+ const first2 = filtered.at(0);
418
418
  const last2 = filtered.at(-1);
419
419
  return {
420
420
  sourceLocationType: "source",
@@ -9841,21 +9841,31 @@ var LexerBuilder = class _LexerBuilder {
9841
9841
  }
9842
9842
  };
9843
9843
 
9844
- // ../core/lib/Transformers.js
9845
- var TransformerType = class {
9846
- clone(obj) {
9847
- const newObj = Object.create(Object.getPrototypeOf(obj));
9848
- Object.defineProperties(newObj, Object.getOwnPropertyDescriptors(obj));
9849
- return newObj;
9844
+ // ../core/lib/TransformerObject.js
9845
+ var TransformerObject = class {
9846
+ defaultContext;
9847
+ maxStackSize = 1e6;
9848
+ /**
9849
+ * Creates stateless transformer.
9850
+ * @param defaultContext
9851
+ */
9852
+ constructor(defaultContext = {}) {
9853
+ this.defaultContext = defaultContext;
9850
9854
  }
9851
- safeObjectVisit(value, mapper) {
9852
- if (value && typeof value === "object") {
9853
- if (Array.isArray(value)) {
9854
- return value.map((x) => this.safeObjectVisit(x, mapper));
9855
- }
9856
- return mapper(value);
9855
+ /**
9856
+ * Function to shallow clone any type.
9857
+ * @param obj
9858
+ * @protected
9859
+ */
9860
+ clone(obj) {
9861
+ if (obj === null || typeof obj !== "object") {
9862
+ return obj;
9857
9863
  }
9858
- return value;
9864
+ const proto = Object.getPrototypeOf(obj);
9865
+ if (proto === Object.prototype || proto === null) {
9866
+ return { ...obj };
9867
+ }
9868
+ return Object.assign(Object.create(proto), obj);
9859
9869
  }
9860
9870
  /**
9861
9871
  * Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
@@ -9867,90 +9877,228 @@ var TransformerType = class {
9867
9877
  * - Default false
9868
9878
  */
9869
9879
  transformObject(startObject, mapper, preVisitor = () => ({})) {
9880
+ const defaults2 = this.defaultContext;
9881
+ const defaultCopyFlag = defaults2.copy ?? true;
9882
+ const defaultContinues = defaults2.continue ?? true;
9883
+ const defaultIgnoreKeys = defaults2.ignoreKeys;
9884
+ const defaultShallowKeys = defaults2.shallowKeys;
9885
+ const defaultDidShortCut = defaults2.shortcut ?? false;
9870
9886
  let didShortCut = false;
9871
- const recurse = (curObject) => {
9872
- const copy3 = this.clone(curObject);
9873
- const context = preVisitor(copy3);
9874
- didShortCut = context.shortcut ?? false;
9875
- const continues = context.continue ?? true;
9876
- if (continues && !didShortCut) {
9877
- for (const [key, value] of Object.entries(copy3)) {
9878
- if (didShortCut) {
9879
- return copy3;
9887
+ const resultWrap = { res: startObject };
9888
+ const stack = [startObject];
9889
+ const stackParent = [resultWrap];
9890
+ const stackParentKey = ["res"];
9891
+ const handleMapperOnLen = [];
9892
+ const mapperCopyStack = [];
9893
+ const mapperOrigStack = [];
9894
+ const mapperParent = [];
9895
+ const mapperParentKey = [];
9896
+ function handleMapper() {
9897
+ while (stack.length === handleMapperOnLen.at(-1)) {
9898
+ handleMapperOnLen.pop();
9899
+ const copyToMap = mapperCopyStack.pop();
9900
+ const origToMap = mapperOrigStack.pop();
9901
+ const parent = mapperParent.pop();
9902
+ const parentKey = mapperParentKey.pop();
9903
+ parent[parentKey] = mapper(copyToMap, origToMap);
9904
+ }
9905
+ }
9906
+ while (stack.length > 0 && stack.length < this.maxStackSize) {
9907
+ const curObject = stack.pop();
9908
+ const curParent = stackParent.pop();
9909
+ const curKey = stackParentKey.pop();
9910
+ if (!didShortCut) {
9911
+ if (Array.isArray(curObject)) {
9912
+ const newArr = [...curObject];
9913
+ handleMapperOnLen.push(stack.length);
9914
+ mapperCopyStack.push(newArr);
9915
+ mapperOrigStack.push(curObject);
9916
+ mapperParent.push(curParent);
9917
+ mapperParentKey.push(curKey);
9918
+ for (let index = curObject.length - 1; index >= 0; index--) {
9919
+ const val = curObject[index];
9920
+ if (val !== null && typeof val === "object") {
9921
+ stack.push(val);
9922
+ stackParent.push(newArr);
9923
+ stackParentKey.push(index.toString());
9924
+ }
9925
+ }
9926
+ handleMapper();
9927
+ continue;
9928
+ }
9929
+ const context = preVisitor(curObject);
9930
+ const copyFlag = context.copy ?? defaultCopyFlag;
9931
+ const continues = context.continue ?? defaultContinues;
9932
+ const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
9933
+ const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
9934
+ didShortCut = context.shortcut ?? defaultDidShortCut;
9935
+ const copy3 = copyFlag ? this.clone(curObject) : curObject;
9936
+ handleMapperOnLen.push(stack.length);
9937
+ mapperCopyStack.push(copy3);
9938
+ mapperOrigStack.push(curObject);
9939
+ mapperParent.push(curParent);
9940
+ mapperParentKey.push(curKey);
9941
+ if (continues && !didShortCut) {
9942
+ for (const key in copy3) {
9943
+ if (!Object.hasOwn(copy3, key)) {
9944
+ continue;
9945
+ }
9946
+ const val = copy3[key];
9947
+ const onlyShallow = shallowKeys && shallowKeys?.has(key);
9948
+ if (onlyShallow) {
9949
+ copy3[key] = this.clone(val);
9950
+ }
9951
+ if (ignoreKeys && ignoreKeys.has(key)) {
9952
+ continue;
9953
+ }
9954
+ if (!onlyShallow && val !== null && typeof val === "object") {
9955
+ stack.push(val);
9956
+ stackParentKey.push(key);
9957
+ stackParent.push(copy3);
9958
+ }
9880
9959
  }
9881
- copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
9882
9960
  }
9883
9961
  }
9884
- return mapper(copy3);
9885
- };
9886
- return recurse(startObject);
9962
+ handleMapper();
9963
+ }
9964
+ if (stack.length >= this.maxStackSize) {
9965
+ throw new Error("Transform object stack overflowed");
9966
+ }
9967
+ handleMapper();
9968
+ return resultWrap.res;
9887
9969
  }
9888
9970
  /**
9889
9971
  * Visitor that visits all objects. Visits deeper objects first.
9890
9972
  */
9891
9973
  visitObject(startObject, visitor, preVisitor = () => ({})) {
9974
+ const defaults2 = this.defaultContext;
9975
+ const defaultContinues = defaults2.continue ?? true;
9976
+ const defaultIgnoreKeys = defaults2.ignoreKeys;
9977
+ const defaultShortcut = defaults2.shortcut ?? false;
9892
9978
  let didShortCut = false;
9893
- const recurse = (curObject) => {
9894
- const context = preVisitor(curObject);
9895
- didShortCut = context.shortcut ?? false;
9896
- const continues = context.continue ?? true;
9897
- if (continues && !didShortCut) {
9898
- for (const value of Object.values(curObject)) {
9899
- if (didShortCut) {
9900
- return;
9979
+ const stack = [startObject];
9980
+ const handleVisitorOnLen = [];
9981
+ const visitorStack = [];
9982
+ function handleVisitor() {
9983
+ while (stack.length === handleVisitorOnLen.at(-1)) {
9984
+ handleVisitorOnLen.pop();
9985
+ const toVisit = visitorStack.pop();
9986
+ visitor(toVisit);
9987
+ }
9988
+ }
9989
+ while (stack.length > 0 && stack.length < this.maxStackSize) {
9990
+ const curObject = stack.pop();
9991
+ if (!didShortCut) {
9992
+ if (Array.isArray(curObject)) {
9993
+ for (let i = curObject.length - 1; i >= 0; i--) {
9994
+ stack.push(curObject[i]);
9995
+ }
9996
+ handleVisitor();
9997
+ continue;
9998
+ }
9999
+ const context = preVisitor(curObject);
10000
+ didShortCut = context.shortcut ?? defaultShortcut;
10001
+ const continues = context.continue ?? defaultContinues;
10002
+ const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
10003
+ handleVisitorOnLen.push(stack.length);
10004
+ visitorStack.push(curObject);
10005
+ if (continues && !didShortCut) {
10006
+ for (const key in curObject) {
10007
+ if (!Object.hasOwn(curObject, key)) {
10008
+ continue;
10009
+ }
10010
+ if (ignoreKeys && ignoreKeys.has(key)) {
10011
+ continue;
10012
+ }
10013
+ const val = curObject[key];
10014
+ if (val && typeof val === "object") {
10015
+ stack.push(val);
10016
+ }
9901
10017
  }
9902
- this.safeObjectVisit(value, (obj) => recurse(obj));
9903
10018
  }
9904
10019
  }
9905
- visitor(curObject);
9906
- };
9907
- recurse(startObject);
10020
+ handleVisitor();
10021
+ }
10022
+ if (stack.length >= this.maxStackSize) {
10023
+ throw new Error("Transform object stack overflowed");
10024
+ }
10025
+ handleVisitor();
9908
10026
  }
10027
+ };
10028
+
10029
+ // ../core/lib/TransformerTyped.js
10030
+ var TransformerTyped = class extends TransformerObject {
10031
+ defaultNodePreVisitor;
10032
+ constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
10033
+ super(defaultContext);
10034
+ this.defaultNodePreVisitor = defaultNodePreVisitor;
10035
+ }
10036
+ /**
10037
+ * Transform a single node.
10038
+ * The transformation calls the preVisitor from starting from the startObject.
10039
+ * The preVisitor can dictate whether transformation should be stopped.
10040
+ * Note that stopping the transformation also prevets further copying.
10041
+ * The transformer itself transforms object starting with the deepest one that can be visited.
10042
+ * The transformer callback is performed on a copy of the original.
10043
+ * @param startObject
10044
+ * @param nodeCallBacks
10045
+ */
9909
10046
  transformNode(startObject, nodeCallBacks) {
9910
- const transformWrapper = (curObject) => {
9911
- const casted = curObject;
10047
+ const transformWrapper = (copy3, orig) => {
10048
+ let ogTransform;
10049
+ const casted = copy3;
9912
10050
  if (casted.type) {
9913
- const ogFunc = nodeCallBacks[casted.type]?.transform;
9914
- if (ogFunc) {
9915
- return ogFunc(casted);
9916
- }
10051
+ ogTransform = nodeCallBacks[casted.type]?.transform;
9917
10052
  }
9918
- return curObject;
10053
+ return ogTransform ? ogTransform(casted, orig) : copy3;
9919
10054
  };
9920
- const preTransformWrapper = (curObject) => {
10055
+ const nodeDefaults = this.defaultNodePreVisitor;
10056
+ const preVisitWrapper = (curObject) => {
10057
+ let ogPreVisit;
10058
+ let nodeContext = {};
9921
10059
  const casted = curObject;
9922
10060
  if (casted.type) {
9923
- const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9924
- if (ogFunc) {
9925
- return ogFunc(casted);
9926
- }
10061
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
10062
+ nodeContext = nodeDefaults[casted.type] ?? nodeContext;
9927
10063
  }
9928
- return {};
10064
+ return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
9929
10065
  };
9930
- return this.transformObject(startObject, transformWrapper, preTransformWrapper);
10066
+ return this.transformObject(startObject, transformWrapper, preVisitWrapper);
9931
10067
  }
10068
+ /**
10069
+ * Similar to {@link this.transformNode}, but without copying the startObject.
10070
+ * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
10071
+ * @param startObject
10072
+ * @param nodeCallBacks
10073
+ */
9932
10074
  visitNode(startObject, nodeCallBacks) {
9933
- const visitWrapper = (curObject) => {
10075
+ const visitorWrapper = (curObject) => {
9934
10076
  const casted = curObject;
9935
10077
  if (casted.type) {
9936
- const ogFunc = nodeCallBacks[casted.type]?.visitor;
9937
- if (ogFunc) {
9938
- ogFunc(casted);
10078
+ const ogTransform = nodeCallBacks[casted.type]?.visitor;
10079
+ if (ogTransform) {
10080
+ ogTransform(casted);
9939
10081
  }
9940
10082
  }
9941
10083
  };
10084
+ const nodeDefaults = this.defaultNodePreVisitor;
9942
10085
  const preVisitWrapper = (curObject) => {
10086
+ let ogPreVisit;
10087
+ let nodeContext = {};
9943
10088
  const casted = curObject;
9944
10089
  if (casted.type) {
9945
- const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9946
- if (ogFunc) {
9947
- return ogFunc(casted);
9948
- }
10090
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
10091
+ nodeContext = nodeDefaults[casted.type] ?? nodeContext;
9949
10092
  }
9950
- return {};
10093
+ return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
9951
10094
  };
9952
- this.visitObject(startObject, visitWrapper, preVisitWrapper);
10095
+ return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
9953
10096
  }
10097
+ /**
10098
+ * Traverses only selected nodes as returned by the function.
10099
+ * @param currentNode
10100
+ * @param traverse
10101
+ */
9954
10102
  traverseNodes(currentNode, traverse) {
9955
10103
  let didShortCut = false;
9956
10104
  const recurse = (curNode) => {
@@ -9971,11 +10119,24 @@ var TransformerType = class {
9971
10119
  recurse(currentNode);
9972
10120
  }
9973
10121
  };
9974
- var TransformerSubType = class extends TransformerType {
10122
+
10123
+ // ../core/lib/TransformerSubTyped.js
10124
+ var TransformerSubTyped = class extends TransformerTyped {
10125
+ constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
10126
+ super(defaultContext, defaultNodePreVisitor);
10127
+ }
10128
+ /**
10129
+ * Shares the functionality and first two arguments with {@link this.transformNode}.
10130
+ * The third argument allows you to also transform based on the subType of objects.
10131
+ * Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
10132
+ * @param startObject
10133
+ * @param nodeCallBacks
10134
+ * @param nodeSpecificCallBacks
10135
+ */
9975
10136
  transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
9976
- const transformWrapper = (curObject) => {
10137
+ const transformWrapper = (copy3, orig) => {
9977
10138
  let ogTransform;
9978
- const casted = curObject;
10139
+ const casted = copy3;
9979
10140
  if (casted.type && casted.subType) {
9980
10141
  const specific = nodeSpecificCallBacks[casted.type];
9981
10142
  if (specific) {
@@ -9985,7 +10146,7 @@ var TransformerSubType = class extends TransformerType {
9985
10146
  ogTransform = nodeCallBacks[casted.type]?.transform;
9986
10147
  }
9987
10148
  }
9988
- return ogTransform ? ogTransform(casted) : curObject;
10149
+ return ogTransform ? ogTransform(casted, orig) : copy3;
9989
10150
  };
9990
10151
  const preVisitWrapper = (curObject) => {
9991
10152
  let ogPreVisit;
@@ -9999,12 +10160,13 @@ var TransformerSubType = class extends TransformerType {
9999
10160
  ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
10000
10161
  }
10001
10162
  }
10002
- return ogPreVisit ? ogPreVisit(casted) : curObject;
10163
+ return ogPreVisit ? ogPreVisit(casted) : {};
10003
10164
  };
10004
10165
  return this.transformObject(startObject, transformWrapper, preVisitWrapper);
10005
10166
  }
10006
10167
  /**
10007
- * When both nodeCallBack and NodeSpecific callBack are matched, will only look at nodeSpecifCallback
10168
+ * Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
10169
+ * When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
10008
10170
  */
10009
10171
  visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
10010
10172
  const visitWrapper = (curObject) => {
@@ -10035,10 +10197,16 @@ var TransformerSubType = class extends TransformerType {
10035
10197
  ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
10036
10198
  }
10037
10199
  }
10038
- return ogPreVisit ? ogPreVisit(casted) : curObject;
10200
+ return ogPreVisit ? ogPreVisit(casted) : {};
10039
10201
  };
10040
10202
  this.visitObject(startObject, visitWrapper, preVisitWrapper);
10041
10203
  }
10204
+ /**
10205
+ * Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
10206
+ * @param currentNode
10207
+ * @param traverseNode
10208
+ * @param traverseSubNode
10209
+ */
10042
10210
  traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
10043
10211
  let didShortCut = false;
10044
10212
  const recurse = (curNode) => {
@@ -10762,8 +10930,8 @@ function PatternFactoryMixin(Base) {
10762
10930
  isPatternOptional(obj) {
10763
10931
  return this.isOfSubType(obj, nodeType5, "optional");
10764
10932
  }
10765
- patternValues(values3, loc) {
10766
- return { type: nodeType5, subType: "values", values: values3, loc };
10933
+ patternValues(variables, values3, loc) {
10934
+ return { type: nodeType5, subType: "values", variables, values: values3, loc };
10767
10935
  }
10768
10936
  isPatternValues(obj) {
10769
10937
  return this.isOfSubType(obj, nodeType5, "values");
@@ -10938,7 +11106,7 @@ function TermFactoryMixin(Base) {
10938
11106
  isTerm(x) {
10939
11107
  return this.isOfType(x, "term");
10940
11108
  }
10941
- blankNode(label, loc) {
11109
+ termBlank(label, loc) {
10942
11110
  const base = {
10943
11111
  type: "term",
10944
11112
  subType: "blankNode",
@@ -10952,7 +11120,7 @@ function TermFactoryMixin(Base) {
10952
11120
  isTermBlank(obj) {
10953
11121
  return this.isOfSubType(obj, nodeType8, "blankNode");
10954
11122
  }
10955
- literalTerm(loc, value, langOrIri) {
11123
+ termLiteral(loc, value, langOrIri) {
10956
11124
  return {
10957
11125
  type: nodeType8,
10958
11126
  subType: "literal",
@@ -10974,7 +11142,7 @@ function TermFactoryMixin(Base) {
10974
11142
  const casted = obj;
10975
11143
  return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
10976
11144
  }
10977
- variable(value, loc) {
11145
+ termVariable(value, loc) {
10978
11146
  return {
10979
11147
  type: nodeType8,
10980
11148
  subType: "variable",
@@ -10985,7 +11153,7 @@ function TermFactoryMixin(Base) {
10985
11153
  isTermVariable(obj) {
10986
11154
  return this.isOfSubType(obj, nodeType8, "variable");
10987
11155
  }
10988
- namedNode(loc, value, prefix) {
11156
+ termNamed(loc, value, prefix) {
10989
11157
  const base = {
10990
11158
  type: nodeType8,
10991
11159
  subType: "namedNode",
@@ -11248,7 +11416,7 @@ var CommonIRIs;
11248
11416
  CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
11249
11417
  CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
11250
11418
  })(CommonIRIs || (CommonIRIs = {}));
11251
- var AstTransformer = class extends TransformerSubType {
11419
+ var AstTransformer = class extends TransformerSubTyped {
11252
11420
  };
11253
11421
 
11254
11422
  // lib/validation/validators.js
@@ -11464,17 +11632,20 @@ var rdfLiteral = {
11464
11632
  return OPTION(() => OR([
11465
11633
  { ALT: () => {
11466
11634
  const lang2 = CONSUME(terminals_exports.langTag);
11467
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
11635
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
11468
11636
  } },
11469
11637
  { ALT: () => {
11470
11638
  CONSUME(symbols_exports.hathat);
11471
11639
  const iriVal = SUBRULE1(iri2);
11472
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
11640
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
11473
11641
  } }
11474
11642
  ])) ?? value;
11475
11643
  },
11476
- gImpl: ({ SUBRULE, PRINT, PRINT_SPACE_LEFT }) => (ast, { astFactory }) => {
11477
- astFactory.printFilter(ast, () => PRINT_SPACE_LEFT(stringEscapedLexical(ast.value)));
11644
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
11645
+ astFactory.printFilter(ast, () => {
11646
+ PRINT_WORD("");
11647
+ PRINT(stringEscapedLexical(ast.value));
11648
+ });
11478
11649
  if (ast.langOrIri) {
11479
11650
  if (typeof ast.langOrIri === "string") {
11480
11651
  astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
@@ -11501,7 +11672,7 @@ var numericLiteralUnsigned = {
11501
11672
  { ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
11502
11673
  { ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
11503
11674
  ]);
11504
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11675
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11505
11676
  }
11506
11677
  };
11507
11678
  var numericLiteralPositive = {
@@ -11512,7 +11683,7 @@ var numericLiteralPositive = {
11512
11683
  { ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
11513
11684
  { ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
11514
11685
  ]);
11515
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11686
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11516
11687
  }
11517
11688
  };
11518
11689
  var numericLiteralNegative = {
@@ -11523,7 +11694,7 @@ var numericLiteralNegative = {
11523
11694
  { ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
11524
11695
  { ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
11525
11696
  ]);
11526
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11697
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11527
11698
  }
11528
11699
  };
11529
11700
  var booleanLiteral = {
@@ -11533,7 +11704,7 @@ var booleanLiteral = {
11533
11704
  { ALT: () => CONSUME(true_) },
11534
11705
  { ALT: () => CONSUME(false_) }
11535
11706
  ]);
11536
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
11707
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
11537
11708
  }
11538
11709
  };
11539
11710
  var string = {
@@ -11575,7 +11746,7 @@ var string = {
11575
11746
  return char;
11576
11747
  }
11577
11748
  });
11578
- return F2.literalTerm(F2.sourceLocation(x[0]), value);
11749
+ return F2.termLiteral(F2.sourceLocation(x[0]), value);
11579
11750
  });
11580
11751
  }
11581
11752
  };
@@ -11591,7 +11762,7 @@ var iriFull = {
11591
11762
  name: "iriFull",
11592
11763
  impl: ({ ACTION, CONSUME }) => (C) => {
11593
11764
  const iriToken = CONSUME(terminals_exports.iriRef);
11594
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
11765
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
11595
11766
  },
11596
11767
  gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
11597
11768
  F2.printFilter(ast, () => PRINT("<", ast.value, ">"));
@@ -11604,16 +11775,16 @@ var prefixedName = {
11604
11775
  const longName = CONSUME(terminals_exports.pNameLn);
11605
11776
  return ACTION(() => {
11606
11777
  const [prefix, localName] = longName.image.split(":");
11607
- return C.astFactory.namedNode(C.astFactory.sourceLocation(longName), localName, prefix);
11778
+ return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
11608
11779
  });
11609
11780
  } },
11610
11781
  { ALT: () => {
11611
11782
  const shortName = CONSUME(terminals_exports.pNameNs);
11612
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
11783
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
11613
11784
  } }
11614
11785
  ]),
11615
- gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F2 }) => {
11616
- F2.printFilter(ast, () => PRINT_WORD(ast.prefix, ":", ast.value));
11786
+ gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
11787
+ F2.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
11617
11788
  }
11618
11789
  };
11619
11790
  var canCreateBlankNodes = Symbol("canCreateBlankNodes");
@@ -11623,11 +11794,11 @@ var blankNode = {
11623
11794
  const result = OR([
11624
11795
  { ALT: () => {
11625
11796
  const labelToken = CONSUME(terminals_exports.blankNodeLabel);
11626
- return ACTION(() => C.astFactory.blankNode(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
11797
+ return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
11627
11798
  } },
11628
11799
  { ALT: () => {
11629
11800
  const anonToken = CONSUME(terminals_exports.anon);
11630
- return ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocation(anonToken)));
11801
+ return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
11631
11802
  } }
11632
11803
  ]);
11633
11804
  ACTION(() => {
@@ -11637,15 +11808,15 @@ var blankNode = {
11637
11808
  });
11638
11809
  return result;
11639
11810
  },
11640
- gImpl: ({ PRINT_WORD }) => (ast, { astFactory }) => {
11641
- astFactory.printFilter(ast, () => PRINT_WORD("_:", ast.label.replace(/^e_/u, "")));
11811
+ gImpl: ({ PRINT }) => (ast, { astFactory }) => {
11812
+ astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
11642
11813
  }
11643
11814
  };
11644
11815
  var verbA = {
11645
11816
  name: "VerbA",
11646
11817
  impl: ({ ACTION, CONSUME }) => (C) => {
11647
11818
  const token = CONSUME(a);
11648
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
11819
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
11649
11820
  }
11650
11821
  };
11651
11822
 
@@ -11679,10 +11850,10 @@ var baseDecl2 = {
11679
11850
  const val = SUBRULE(iriFull);
11680
11851
  return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
11681
11852
  },
11682
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
11683
- F2.printFilter(ast, () => PRINT_WORD("BASE"));
11853
+ gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
11854
+ F2.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
11684
11855
  SUBRULE(iri2, ast.value);
11685
- F2.printFilter(ast, () => PRINT_WORD("\n"));
11856
+ F2.printFilter(ast, () => NEW_LINE());
11686
11857
  }
11687
11858
  };
11688
11859
  var prefixDecl2 = {
@@ -11693,12 +11864,12 @@ var prefixDecl2 = {
11693
11864
  const value = SUBRULE(iriFull);
11694
11865
  return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
11695
11866
  },
11696
- gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { astFactory: F2 }) => {
11867
+ gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F2 }) => {
11697
11868
  F2.printFilter(ast, () => {
11698
- PRINT_WORDS("PREFIX", `${ast.key}:`);
11869
+ PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
11699
11870
  });
11700
11871
  SUBRULE(iri2, ast.value);
11701
- F2.printFilter(ast, () => PRINT_WORDS("\n"));
11872
+ F2.printFilter(ast, () => NEW_LINE());
11702
11873
  }
11703
11874
  };
11704
11875
  var verb = {
@@ -11735,10 +11906,10 @@ var var_ = {
11735
11906
  { ALT: () => CONSUME(terminals_exports.var1) },
11736
11907
  { ALT: () => CONSUME(terminals_exports.var2) }
11737
11908
  ]);
11738
- return ACTION(() => C.astFactory.variable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
11909
+ return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
11739
11910
  },
11740
- gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F2 }) => {
11741
- F2.printFilter(ast, () => PRINT_WORD(`?${ast.value}`));
11911
+ gImpl: ({ PRINT }) => (ast, { astFactory: F2 }) => {
11912
+ F2.printFilter(ast, () => PRINT(`?${ast.value}`));
11742
11913
  }
11743
11914
  };
11744
11915
  var graphTerm = {
@@ -11751,7 +11922,7 @@ var graphTerm = {
11751
11922
  { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
11752
11923
  { ALT: () => {
11753
11924
  const tokenNil = CONSUME(terminals_exports.nil);
11754
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
11925
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
11755
11926
  } }
11756
11927
  ]),
11757
11928
  gImpl: ({ SUBRULE }) => (ast, { astFactory: F2 }) => {
@@ -12381,13 +12552,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
12381
12552
  var triplesBlock = {
12382
12553
  name: "triplesBlock",
12383
12554
  impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
12384
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F2 }) => {
12555
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F2 }) => {
12385
12556
  for (const [index, triple] of ast.triples.entries()) {
12386
12557
  HANDLE_LOC(triple, () => {
12387
12558
  const nextTriple = ast.triples.at(index);
12388
12559
  if (F2.isTripleCollection(triple)) {
12389
12560
  SUBRULE(graphNodePath, triple);
12390
- F2.printFilter(triple, () => PRINT_WORD(".\n"));
12561
+ F2.printFilter(triple, () => {
12562
+ PRINT_WORD(".");
12563
+ NEW_LINE();
12564
+ });
12391
12565
  } else {
12392
12566
  SUBRULE(graphNodePath, triple.subject);
12393
12567
  F2.printFilter(triple, () => PRINT_WORD(""));
@@ -12399,11 +12573,17 @@ var triplesBlock = {
12399
12573
  F2.printFilter(triple, () => PRINT_WORD(""));
12400
12574
  SUBRULE(graphNodePath, triple.object);
12401
12575
  if (nextTriple === void 0 || F2.isTripleCollection(nextTriple) || !F2.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12402
- F2.printFilter(ast, () => PRINT_WORD(".\n"));
12576
+ F2.printFilter(ast, () => {
12577
+ PRINT_WORD(".");
12578
+ NEW_LINE();
12579
+ });
12403
12580
  } else if (F2.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12404
12581
  F2.printFilter(ast, () => PRINT_WORD(","));
12405
12582
  } else {
12406
- F2.printFilter(ast, () => PRINT_WORD(";\n"));
12583
+ F2.printFilter(ast, () => {
12584
+ PRINT_WORD(";");
12585
+ NEW_LINE();
12586
+ });
12407
12587
  }
12408
12588
  }
12409
12589
  });
@@ -12536,10 +12716,10 @@ function collectionImpl(name, allowPaths) {
12536
12716
  return ACTION(() => {
12537
12717
  const F2 = C.astFactory;
12538
12718
  const triples = [];
12539
- const predFirst = F2.namedNode(F2.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
12540
- const predRest = F2.namedNode(F2.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
12541
- const predNil = F2.namedNode(F2.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
12542
- const listHead = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12719
+ const predFirst = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
12720
+ const predRest = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
12721
+ const predNil = F2.termNamed(F2.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
12722
+ const listHead = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
12543
12723
  let iterHead = listHead;
12544
12724
  for (const [index, term] of terms.entries()) {
12545
12725
  const lastInList = index === terms.length - 1;
@@ -12549,7 +12729,7 @@ function collectionImpl(name, allowPaths) {
12549
12729
  const nilTriple = F2.triple(iterHead, predRest, predNil);
12550
12730
  triples.push(nilTriple);
12551
12731
  } else {
12552
- const tail = F2.blankNode(void 0, F2.sourceLocationNoMaterialize());
12732
+ const tail = F2.termBlank(void 0, F2.sourceLocationNoMaterialize());
12553
12733
  const linkTriple = F2.triple(iterHead, predRest, tail);
12554
12734
  triples.push(linkTriple);
12555
12735
  iterHead = tail;
@@ -12589,16 +12769,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
12589
12769
  name,
12590
12770
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12591
12771
  const startToken = CONSUME(symbols_exports.LSquare);
12592
- const blankNode2 = ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocationNoMaterialize()));
12772
+ const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
12593
12773
  const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
12594
12774
  const endToken = CONSUME(symbols_exports.RSquare);
12595
12775
  return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
12596
12776
  },
12597
- gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
12777
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
12598
12778
  const { astFactory: F2, indentInc } = c;
12599
12779
  F2.printFilter(ast, () => {
12600
12780
  c[traqulaIndentation] += indentInc;
12601
- PRINT("[\n");
12781
+ PRINT("[");
12782
+ NEW_LINE();
12602
12783
  });
12603
12784
  for (const triple of ast.triples) {
12604
12785
  HANDLE_LOC(triple, () => {
@@ -12609,7 +12790,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
12609
12790
  }
12610
12791
  F2.printFilter(triple, () => PRINT_WORD(""));
12611
12792
  SUBRULE(graphNodePath, triple.object);
12612
- F2.printFilter(ast, () => PRINT_WORD(";\n"));
12793
+ F2.printFilter(ast, () => {
12794
+ PRINT_WORD(";");
12795
+ NEW_LINE();
12796
+ });
12613
12797
  });
12614
12798
  }
12615
12799
  F2.printFilter(ast, () => {
@@ -12668,18 +12852,19 @@ var groupGraphPattern = {
12668
12852
  const close = CONSUME(symbols_exports.RCurly);
12669
12853
  return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
12670
12854
  },
12671
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
12855
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
12672
12856
  const { astFactory: F2, indentInc } = C;
12673
12857
  F2.printFilter(ast, () => {
12674
12858
  C[traqulaIndentation] += indentInc;
12675
- PRINT_WORD("{\n");
12859
+ PRINT_WORD("{");
12860
+ NEW_LINE();
12676
12861
  });
12677
12862
  for (const pattern of ast.patterns) {
12678
12863
  SUBRULE(generatePattern, pattern);
12679
12864
  }
12680
12865
  F2.printFilter(ast, () => {
12681
12866
  C[traqulaIndentation] -= indentInc;
12682
- PRINT_ON_EMPTY("}\n");
12867
+ PRINT_ON_OWN_LINE("}");
12683
12868
  });
12684
12869
  }
12685
12870
  };
@@ -12829,12 +13014,15 @@ var bind2 = {
12829
13014
  const close = CONSUME(symbols_exports.RParen);
12830
13015
  return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
12831
13016
  },
12832
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13017
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
12833
13018
  F2.printFilter(ast, () => PRINT_WORD("BIND", "("));
12834
13019
  SUBRULE(expression, ast.expression);
12835
13020
  F2.printFilter(ast, () => PRINT_WORD("AS"));
12836
13021
  SUBRULE(var_, ast.variable);
12837
- F2.printFilter(ast, () => PRINT_WORD(")\n"));
13022
+ F2.printFilter(ast, () => {
13023
+ PRINT_WORD(")");
13024
+ NEW_LINE();
13025
+ });
12838
13026
  }
12839
13027
  };
12840
13028
  var inlineData = {
@@ -12842,34 +13030,46 @@ var inlineData = {
12842
13030
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12843
13031
  const values3 = CONSUME(values2);
12844
13032
  const datablock = SUBRULE(dataBlock);
12845
- return ACTION(() => C.astFactory.patternValues(datablock.val, C.astFactory.sourceLocation(values3, datablock)));
13033
+ return ACTION(() => {
13034
+ datablock.loc = C.astFactory.sourceLocation(values3, datablock);
13035
+ return datablock;
13036
+ });
12846
13037
  },
12847
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
13038
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
12848
13039
  const { astFactory: F2, indentInc } = C;
12849
- const variables = Object.keys(ast.values.at(0) ?? {});
13040
+ const variables = ast.variables;
13041
+ const singleVar = variables.length === 1;
13042
+ F2.printFilter(ast, () => {
13043
+ PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
13044
+ });
13045
+ for (const variable of variables) {
13046
+ F2.printFilter(ast, () => PRINT_WORD(""));
13047
+ SUBRULE(varOrTerm, variable);
13048
+ F2.printFilter(ast, () => PRINT_WORD(""));
13049
+ }
12850
13050
  F2.printFilter(ast, () => {
12851
- PRINT_ON_EMPTY("");
12852
- PRINT_WORD("VALUES", "(");
12853
- for (const variable of variables) {
12854
- PRINT_WORD(`?${variable}`);
12855
- }
12856
13051
  C[traqulaIndentation] += indentInc;
12857
- PRINT_WORD(")", "{\n");
13052
+ PRINT_WORD(singleVar ? "" : ")", "{");
13053
+ NEW_LINE();
12858
13054
  });
12859
13055
  for (const mapping of ast.values) {
12860
- F2.printFilter(ast, () => PRINT_WORD("("));
13056
+ F2.printFilter(ast, () => !singleVar && PRINT_WORD("("));
12861
13057
  for (const variable of variables) {
12862
- if (mapping[variable] === void 0) {
13058
+ const var_2 = variable.value;
13059
+ if (mapping[var_2] === void 0) {
12863
13060
  F2.printFilter(ast, () => PRINT_WORD("UNDEF"));
12864
13061
  } else {
12865
- SUBRULE(graphNodePath, mapping[variable]);
13062
+ SUBRULE(graphNodePath, mapping[var_2]);
12866
13063
  }
12867
13064
  }
12868
- F2.printFilter(ast, () => PRINT_WORD(")\n"));
13065
+ F2.printFilter(ast, () => {
13066
+ PRINT_WORD(singleVar ? "" : ")");
13067
+ NEW_LINE();
13068
+ });
12869
13069
  }
12870
13070
  F2.printFilter(ast, () => {
12871
13071
  C[traqulaIndentation] -= indentInc;
12872
- PRINT_ON_EMPTY("}\n");
13072
+ PRINT_ON_OWN_LINE("}");
12873
13073
  });
12874
13074
  }
12875
13075
  };
@@ -12893,7 +13093,7 @@ var inlineDataOneVar = {
12893
13093
  });
12894
13094
  });
12895
13095
  const close = CONSUME(symbols_exports.RCurly);
12896
- return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(varVal, close)));
13096
+ return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
12897
13097
  }
12898
13098
  };
12899
13099
  var inlineDataFull = {
@@ -12910,7 +13110,7 @@ var inlineDataFull = {
12910
13110
  res.push({});
12911
13111
  });
12912
13112
  const close = CONSUME1(symbols_exports.RCurly);
12913
- return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(nil2, close)));
13113
+ return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
12914
13114
  } },
12915
13115
  { ALT: () => {
12916
13116
  const open = CONSUME1(symbols_exports.LParen);
@@ -12942,7 +13142,7 @@ var inlineDataFull = {
12942
13142
  });
12943
13143
  });
12944
13144
  const close = CONSUME2(symbols_exports.RCurly);
12945
- return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(open, close)));
13145
+ return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
12946
13146
  } }
12947
13147
  ]);
12948
13148
  }
@@ -13005,10 +13205,13 @@ var filter3 = {
13005
13205
  const expression2 = SUBRULE(constraint);
13006
13206
  return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
13007
13207
  },
13008
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13208
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F2 }) => {
13009
13209
  F2.printFilter(ast, () => PRINT_WORD("FILTER ("));
13010
13210
  SUBRULE(expression, ast.expression);
13011
- F2.printFilter(ast, () => PRINT_WORD(")\n"));
13211
+ F2.printFilter(ast, () => {
13212
+ PRINT_WORD(")");
13213
+ NEW_LINE();
13214
+ });
13012
13215
  }
13013
13216
  };
13014
13217
  var constraint = {
@@ -13394,8 +13597,7 @@ var groupClause = {
13394
13597
  },
13395
13598
  gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
13396
13599
  F2.printFilter(ast, () => {
13397
- PRINT_ON_EMPTY("");
13398
- PRINT_WORDS("GROUP", "BY");
13600
+ PRINT_ON_EMPTY("GROUP BY ");
13399
13601
  });
13400
13602
  for (const grouping of ast.groupings) {
13401
13603
  if (F2.isExpression(grouping)) {
@@ -13451,10 +13653,9 @@ var havingClause = {
13451
13653
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13452
13654
  return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
13453
13655
  },
13454
- gImpl: ({ PRINT_WORD, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
13656
+ gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
13455
13657
  F2.printFilter(ast, () => {
13456
- PRINT_ON_EMPTY("");
13457
- PRINT_WORD("HAVING");
13658
+ PRINT_ON_EMPTY("HAVING ");
13458
13659
  });
13459
13660
  for (const having2 of ast.having) {
13460
13661
  SUBRULE(expression, having2);
@@ -13480,8 +13681,7 @@ var orderClause = {
13480
13681
  },
13481
13682
  gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F2 }) => {
13482
13683
  F2.printFilter(ast, () => {
13483
- PRINT_ON_EMPTY("");
13484
- PRINT_WORDS("ORDER", "BY");
13684
+ PRINT_ON_EMPTY("ORDER BY ");
13485
13685
  });
13486
13686
  for (const ordering of ast.orderDefs) {
13487
13687
  if (ordering.descending) {
@@ -13540,9 +13740,9 @@ var limitOffsetClauses = {
13540
13740
  return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
13541
13741
  } }
13542
13742
  ]),
13543
- gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
13743
+ gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F2 }) => {
13544
13744
  F2.printFilter(ast, () => {
13545
- PRINT_ON_EMPTY("");
13745
+ NEW_LINE();
13546
13746
  if (ast.limit) {
13547
13747
  PRINT_WORDS("LIMIT", String(ast.limit));
13548
13748
  }
@@ -13727,9 +13927,9 @@ var selectClause = {
13727
13927
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13728
13928
  return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
13729
13929
  },
13730
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13930
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
13731
13931
  F2.printFilter(ast, () => {
13732
- PRINT_WORD("SELECT");
13932
+ PRINT_ON_EMPTY("SELECT ");
13733
13933
  if (ast.val.distinct) {
13734
13934
  PRINT_WORD("DISTINCT");
13735
13935
  } else if (ast.val.reduced) {
@@ -13748,7 +13948,9 @@ var selectClause = {
13748
13948
  SUBRULE(var_, variable.variable);
13749
13949
  F2.printFilter(ast, () => PRINT_WORD(")"));
13750
13950
  }
13951
+ F2.printFilter(ast, () => PRINT_WORD(""));
13751
13952
  }
13953
+ F2.printFilter(ast, () => PRINT_WORD(""));
13752
13954
  }
13753
13955
  };
13754
13956
  var constructQuery = {
@@ -13786,18 +13988,19 @@ var constructQuery = {
13786
13988
  } }
13787
13989
  ]);
13788
13990
  },
13789
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
13991
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
13790
13992
  const { astFactory: F2, indentInc } = C;
13791
- F2.printFilter(ast, () => PRINT_WORD("CONSTRUCT"));
13993
+ F2.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
13792
13994
  if (!F2.isSourceLocationNoMaterialize(ast.where.loc)) {
13793
13995
  F2.printFilter(ast, () => {
13794
13996
  C[traqulaIndentation] += indentInc;
13795
- PRINT_WORD("{\n");
13997
+ PRINT_WORD("{");
13998
+ NEW_LINE();
13796
13999
  });
13797
14000
  SUBRULE(triplesBlock, ast.template);
13798
14001
  F2.printFilter(ast, () => {
13799
14002
  C[traqulaIndentation] -= indentInc;
13800
- PRINT_ON_EMPTY("}\n");
14003
+ PRINT_ON_OWN_LINE("}");
13801
14004
  });
13802
14005
  }
13803
14006
  SUBRULE(datasetClauseStar, ast.datasets);
@@ -13838,8 +14041,8 @@ var describeQuery = {
13838
14041
  loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13839
14042
  }));
13840
14043
  },
13841
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13842
- F2.printFilter(ast, () => PRINT_WORD("DESCRIBE"));
14044
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
14045
+ F2.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
13843
14046
  if (F2.isWildcard(ast.variables[0])) {
13844
14047
  F2.printFilter(ast, () => PRINT_WORD("*"));
13845
14048
  } else {
@@ -13869,8 +14072,8 @@ var askQuery = {
13869
14072
  loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
13870
14073
  }));
13871
14074
  },
13872
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
13873
- F2.printFilter(ast, () => PRINT_WORD("ASK"));
14075
+ gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
14076
+ F2.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
13874
14077
  SUBRULE(datasetClauseStar, ast.datasets);
13875
14078
  SUBRULE(whereClause, F2.wrap(ast.where, ast.loc));
13876
14079
  SUBRULE(solutionModifier, ast.solutionModifiers);
@@ -13929,7 +14132,7 @@ var update = {
13929
14132
  return update2;
13930
14133
  });
13931
14134
  },
13932
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14135
+ gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F2 }) => {
13933
14136
  const [head2, ...tail] = ast.updates;
13934
14137
  if (head2) {
13935
14138
  SUBRULE(prologue, head2.context);
@@ -13938,7 +14141,10 @@ var update = {
13938
14141
  }
13939
14142
  }
13940
14143
  for (const update2 of tail) {
13941
- F2.printFilter(ast, () => PRINT_WORD(";\n"));
14144
+ F2.printFilter(ast, () => {
14145
+ PRINT(";");
14146
+ NEW_LINE();
14147
+ });
13942
14148
  SUBRULE(prologue, update2.context);
13943
14149
  if (update2.operation) {
13944
14150
  SUBRULE(update1, update2.operation);
@@ -14011,9 +14217,9 @@ var load2 = {
14011
14217
  });
14012
14218
  return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
14013
14219
  },
14014
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14220
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
14015
14221
  F2.printFilter(ast, () => {
14016
- PRINT_WORD("LOAD");
14222
+ PRINT_ON_EMPTY("LOAD ");
14017
14223
  if (ast.silent) {
14018
14224
  PRINT_WORD("SILENT");
14019
14225
  }
@@ -14034,9 +14240,9 @@ function clearOrDrop(operation) {
14034
14240
  const destination = SUBRULE1(graphRefAll);
14035
14241
  return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
14036
14242
  },
14037
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14243
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
14038
14244
  F2.printFilter(ast, () => {
14039
- PRINT_WORD(operation.name.toUpperCase());
14245
+ PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
14040
14246
  if (ast.silent) {
14041
14247
  PRINT_WORD("SILENT");
14042
14248
  }
@@ -14055,9 +14261,9 @@ var create2 = {
14055
14261
  const destination = SUBRULE1(graphRef);
14056
14262
  return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
14057
14263
  },
14058
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14264
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
14059
14265
  F2.printFilter(ast, () => {
14060
- PRINT_WORD("CREATE");
14266
+ PRINT_ON_EMPTY("CREATE ");
14061
14267
  if (ast.silent) {
14062
14268
  PRINT_WORD("SILENT");
14063
14269
  }
@@ -14076,9 +14282,9 @@ function copyMoveAddOperation(operation) {
14076
14282
  const destination = SUBRULE2(graphOrDefault);
14077
14283
  return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
14078
14284
  },
14079
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F2 }) => {
14285
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F2 }) => {
14080
14286
  F2.printFilter(ast, () => {
14081
- PRINT_WORD(operation.name.toUpperCase());
14287
+ PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
14082
14288
  if (ast.silent) {
14083
14289
  PRINT_WORD("SILENT");
14084
14290
  }
@@ -14127,23 +14333,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
14127
14333
  }
14128
14334
  return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
14129
14335
  },
14130
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14336
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
14131
14337
  const { astFactory: F2, indentInc } = C;
14132
14338
  F2.printFilter(ast, () => {
14133
- C[traqulaIndentation] += indentInc;
14134
14339
  if (subType === "insertdata") {
14135
- PRINT_WORD("INSERT DATA");
14340
+ PRINT_ON_EMPTY("INSERT DATA ");
14136
14341
  } else if (subType === "deletedata") {
14137
- PRINT_WORD("DELETE DATA");
14342
+ PRINT_ON_EMPTY("DELETE DATA ");
14138
14343
  } else if (subType === "deletewhere") {
14139
- PRINT_WORD("DELETE WHERE");
14344
+ PRINT_ON_EMPTY("DELETE WHERE ");
14140
14345
  }
14141
- PRINT_WORD("{\n");
14346
+ C[traqulaIndentation] += indentInc;
14347
+ PRINT_WORD("{");
14348
+ NEW_LINE();
14142
14349
  });
14143
14350
  SUBRULE(quads, F2.wrap(ast.data, ast.loc));
14144
14351
  F2.printFilter(ast, () => {
14145
14352
  C[traqulaIndentation] -= indentInc;
14146
- PRINT_ON_EMPTY("}\n");
14353
+ PRINT_ON_OWN_LINE("}");
14147
14354
  });
14148
14355
  }
14149
14356
  };
@@ -14175,36 +14382,40 @@ var modify = {
14175
14382
  const where2 = SUBRULE1(groupGraphPattern);
14176
14383
  return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
14177
14384
  },
14178
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14385
+ gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
14179
14386
  const { astFactory: F2, indentInc } = C;
14180
14387
  if (ast.graph) {
14181
- F2.printFilter(ast, () => PRINT_WORD("WITH"));
14388
+ F2.printFilter(ast, () => PRINT_WORDS("WITH"));
14182
14389
  SUBRULE(iri2, ast.graph);
14183
14390
  }
14184
14391
  if (ast.delete.length > 0) {
14185
14392
  F2.printFilter(ast, () => {
14186
14393
  C[traqulaIndentation] += indentInc;
14187
- PRINT_WORD("DELETE", "{\n");
14394
+ PRINT_WORDS("DELETE", "{");
14395
+ NEW_LINE();
14188
14396
  });
14189
14397
  SUBRULE(quads, F2.wrap(ast.delete, ast.loc));
14190
14398
  F2.printFilter(ast, () => {
14191
14399
  C[traqulaIndentation] -= indentInc;
14192
- PRINT_ON_EMPTY("}\n");
14400
+ PRINT_ON_EMPTY("}");
14401
+ NEW_LINE();
14193
14402
  });
14194
14403
  }
14195
14404
  if (ast.insert.length > 0) {
14196
14405
  F2.printFilter(ast, () => {
14197
14406
  C[traqulaIndentation] += indentInc;
14198
- PRINT_WORD("INSERT", "{\n");
14407
+ PRINT_WORDS("INSERT", "{");
14408
+ NEW_LINE();
14199
14409
  });
14200
14410
  SUBRULE(quads, F2.wrap(ast.insert, ast.loc));
14201
14411
  F2.printFilter(ast, () => {
14202
14412
  C[traqulaIndentation] -= indentInc;
14203
- PRINT_ON_EMPTY("}\n");
14413
+ PRINT_ON_EMPTY("} ");
14414
+ NEW_LINE();
14204
14415
  });
14205
14416
  }
14206
14417
  SUBRULE(usingClauseStar, ast.from);
14207
- F2.printFilter(ast, () => PRINT_WORD("WHERE"));
14418
+ F2.printFilter(ast, () => PRINT_WORDS("WHERE"));
14208
14419
  SUBRULE(groupGraphPattern, ast.where);
14209
14420
  }
14210
14421
  };
@@ -14328,18 +14539,19 @@ var quadsNotTriples = {
14328
14539
  const close = CONSUME(symbols_exports.RCurly);
14329
14540
  return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
14330
14541
  },
14331
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14542
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
14332
14543
  const { astFactory: F2, indentInc } = C;
14333
14544
  F2.printFilter(ast, () => PRINT_WORD("GRAPH"));
14334
14545
  SUBRULE(varOrTerm, ast.graph);
14335
14546
  F2.printFilter(ast, () => {
14336
14547
  C[traqulaIndentation] += indentInc;
14337
- PRINT_WORD("{\n");
14548
+ PRINT_WORD("{");
14549
+ NEW_LINE();
14338
14550
  });
14339
14551
  SUBRULE(triplesBlock, ast.triples);
14340
14552
  F2.printFilter(ast, () => {
14341
14553
  C[traqulaIndentation] -= indentInc;
14342
- PRINT_ON_EMPTY("}\n");
14554
+ PRINT_ON_OWN_LINE("}");
14343
14555
  });
14344
14556
  }
14345
14557
  };