@traqula/parser-sparql-1-2 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -42,7 +42,7 @@ var AstCoreFactory = class {
42
42
  if (filtered.length === 0) {
43
43
  return this.gen();
44
44
  }
45
- const first2 = filtered[0];
45
+ const first2 = filtered.at(0);
46
46
  const last2 = filtered.at(-1);
47
47
  return {
48
48
  sourceLocationType: "source",
@@ -9655,6 +9655,9 @@ var ParserBuilder = class _ParserBuilder {
9655
9655
  delete this.rules[ruleName];
9656
9656
  return this;
9657
9657
  }
9658
+ getRule(ruleName) {
9659
+ return this.rules[ruleName];
9660
+ }
9658
9661
  /**
9659
9662
  * Merge this grammar builder with another.
9660
9663
  * It is best to merge the bigger grammar with the smaller one.
@@ -9741,21 +9744,34 @@ ${firstError.message}`);
9741
9744
  }
9742
9745
  };
9743
9746
 
9744
- // ../../packages/core/lib/Transformers.js
9745
- var TransformerType = class {
9746
- clone(obj) {
9747
- const newObj = Object.create(Object.getPrototypeOf(obj));
9748
- Object.defineProperties(newObj, Object.getOwnPropertyDescriptors(obj));
9749
- return newObj;
9747
+ // ../../packages/core/lib/TransformerObject.js
9748
+ var TransformerObject = class _TransformerObject {
9749
+ defaultContext;
9750
+ maxStackSize = 1e6;
9751
+ /**
9752
+ * Creates stateless transformer.
9753
+ * @param defaultContext
9754
+ */
9755
+ constructor(defaultContext = {}) {
9756
+ this.defaultContext = defaultContext;
9750
9757
  }
9751
- safeObjectVisit(value, mapper) {
9752
- if (value && typeof value === "object") {
9753
- if (Array.isArray(value)) {
9754
- return value.map((x) => this.safeObjectVisit(x, mapper));
9755
- }
9756
- return mapper(value);
9758
+ clone(newDefaultContext = {}) {
9759
+ return new _TransformerObject({ ...this.defaultContext, ...newDefaultContext });
9760
+ }
9761
+ /**
9762
+ * Function to shallow clone any type.
9763
+ * @param obj
9764
+ * @protected
9765
+ */
9766
+ cloneObj(obj) {
9767
+ if (obj === null || typeof obj !== "object") {
9768
+ return obj;
9757
9769
  }
9758
- return value;
9770
+ const proto = Object.getPrototypeOf(obj);
9771
+ if (proto === Object.prototype || proto === null) {
9772
+ return { ...obj };
9773
+ }
9774
+ return Object.assign(Object.create(proto), obj);
9759
9775
  }
9760
9776
  /**
9761
9777
  * Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
@@ -9767,90 +9783,231 @@ var TransformerType = class {
9767
9783
  * - Default false
9768
9784
  */
9769
9785
  transformObject(startObject, mapper, preVisitor = () => ({})) {
9786
+ const defaults2 = this.defaultContext;
9787
+ const defaultCopyFlag = defaults2.copy ?? true;
9788
+ const defaultContinues = defaults2.continue ?? true;
9789
+ const defaultIgnoreKeys = defaults2.ignoreKeys;
9790
+ const defaultShallowKeys = defaults2.shallowKeys;
9791
+ const defaultDidShortCut = defaults2.shortcut ?? false;
9770
9792
  let didShortCut = false;
9771
- const recurse = (curObject) => {
9772
- const copy3 = this.clone(curObject);
9773
- const context = preVisitor(copy3);
9774
- didShortCut = context.shortcut ?? false;
9775
- const continues = context.continue ?? true;
9776
- if (continues && !didShortCut) {
9777
- for (const [key, value] of Object.entries(copy3)) {
9778
- if (didShortCut) {
9779
- return copy3;
9793
+ const resultWrap = { res: startObject };
9794
+ const stack = [startObject];
9795
+ const stackParent = [resultWrap];
9796
+ const stackParentKey = ["res"];
9797
+ const handleMapperOnLen = [];
9798
+ const mapperCopyStack = [];
9799
+ const mapperOrigStack = [];
9800
+ const mapperParent = [];
9801
+ const mapperParentKey = [];
9802
+ function handleMapper() {
9803
+ while (stack.length === handleMapperOnLen.at(-1)) {
9804
+ handleMapperOnLen.pop();
9805
+ const copyToMap = mapperCopyStack.pop();
9806
+ const origToMap = mapperOrigStack.pop();
9807
+ const parent = mapperParent.pop();
9808
+ const parentKey = mapperParentKey.pop();
9809
+ parent[parentKey] = mapper(copyToMap, origToMap);
9810
+ }
9811
+ }
9812
+ while (stack.length > 0 && stack.length < this.maxStackSize) {
9813
+ const curObject = stack.pop();
9814
+ const curParent = stackParent.pop();
9815
+ const curKey = stackParentKey.pop();
9816
+ if (!didShortCut) {
9817
+ if (Array.isArray(curObject)) {
9818
+ const newArr = [...curObject];
9819
+ handleMapperOnLen.push(stack.length);
9820
+ mapperCopyStack.push(newArr);
9821
+ mapperOrigStack.push(curObject);
9822
+ mapperParent.push(curParent);
9823
+ mapperParentKey.push(curKey);
9824
+ for (let index = curObject.length - 1; index >= 0; index--) {
9825
+ const val = curObject[index];
9826
+ if (val !== null && typeof val === "object") {
9827
+ stack.push(val);
9828
+ stackParent.push(newArr);
9829
+ stackParentKey.push(index.toString());
9830
+ }
9831
+ }
9832
+ handleMapper();
9833
+ continue;
9834
+ }
9835
+ const context = preVisitor(curObject);
9836
+ const copyFlag = context.copy ?? defaultCopyFlag;
9837
+ const continues = context.continue ?? defaultContinues;
9838
+ const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
9839
+ const shallowKeys = context.shallowKeys ?? defaultShallowKeys;
9840
+ didShortCut = context.shortcut ?? defaultDidShortCut;
9841
+ const copy3 = copyFlag ? this.cloneObj(curObject) : curObject;
9842
+ handleMapperOnLen.push(stack.length);
9843
+ mapperCopyStack.push(copy3);
9844
+ mapperOrigStack.push(curObject);
9845
+ mapperParent.push(curParent);
9846
+ mapperParentKey.push(curKey);
9847
+ if (continues && !didShortCut) {
9848
+ for (const key in copy3) {
9849
+ if (!Object.hasOwn(copy3, key)) {
9850
+ continue;
9851
+ }
9852
+ const val = copy3[key];
9853
+ const onlyShallow = shallowKeys && shallowKeys?.has(key);
9854
+ if (onlyShallow) {
9855
+ copy3[key] = this.cloneObj(val);
9856
+ }
9857
+ if (ignoreKeys && ignoreKeys.has(key)) {
9858
+ continue;
9859
+ }
9860
+ if (!onlyShallow && val !== null && typeof val === "object") {
9861
+ stack.push(val);
9862
+ stackParentKey.push(key);
9863
+ stackParent.push(copy3);
9864
+ }
9780
9865
  }
9781
- copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
9782
9866
  }
9783
9867
  }
9784
- return mapper(copy3);
9785
- };
9786
- return recurse(startObject);
9868
+ handleMapper();
9869
+ }
9870
+ if (stack.length >= this.maxStackSize) {
9871
+ throw new Error("Transform object stack overflowed");
9872
+ }
9873
+ handleMapper();
9874
+ return resultWrap.res;
9787
9875
  }
9788
9876
  /**
9789
9877
  * Visitor that visits all objects. Visits deeper objects first.
9790
9878
  */
9791
9879
  visitObject(startObject, visitor, preVisitor = () => ({})) {
9880
+ const defaults2 = this.defaultContext;
9881
+ const defaultContinues = defaults2.continue ?? true;
9882
+ const defaultIgnoreKeys = defaults2.ignoreKeys;
9883
+ const defaultShortcut = defaults2.shortcut ?? false;
9792
9884
  let didShortCut = false;
9793
- const recurse = (curObject) => {
9794
- const context = preVisitor(curObject);
9795
- didShortCut = context.shortcut ?? false;
9796
- const continues = context.continue ?? true;
9797
- if (continues && !didShortCut) {
9798
- for (const value of Object.values(curObject)) {
9799
- if (didShortCut) {
9800
- return;
9885
+ const stack = [startObject];
9886
+ const handleVisitorOnLen = [];
9887
+ const visitorStack = [];
9888
+ function handleVisitor() {
9889
+ while (stack.length === handleVisitorOnLen.at(-1)) {
9890
+ handleVisitorOnLen.pop();
9891
+ const toVisit = visitorStack.pop();
9892
+ visitor(toVisit);
9893
+ }
9894
+ }
9895
+ while (stack.length > 0 && stack.length < this.maxStackSize) {
9896
+ const curObject = stack.pop();
9897
+ if (!didShortCut) {
9898
+ if (Array.isArray(curObject)) {
9899
+ for (let i = curObject.length - 1; i >= 0; i--) {
9900
+ stack.push(curObject[i]);
9901
+ }
9902
+ handleVisitor();
9903
+ continue;
9904
+ }
9905
+ const context = preVisitor(curObject);
9906
+ didShortCut = context.shortcut ?? defaultShortcut;
9907
+ const continues = context.continue ?? defaultContinues;
9908
+ const ignoreKeys = context.ignoreKeys ?? defaultIgnoreKeys;
9909
+ handleVisitorOnLen.push(stack.length);
9910
+ visitorStack.push(curObject);
9911
+ if (continues && !didShortCut) {
9912
+ for (const key in curObject) {
9913
+ if (!Object.hasOwn(curObject, key)) {
9914
+ continue;
9915
+ }
9916
+ if (ignoreKeys && ignoreKeys.has(key)) {
9917
+ continue;
9918
+ }
9919
+ const val = curObject[key];
9920
+ if (val && typeof val === "object") {
9921
+ stack.push(val);
9922
+ }
9801
9923
  }
9802
- this.safeObjectVisit(value, (obj) => recurse(obj));
9803
9924
  }
9804
9925
  }
9805
- visitor(curObject);
9806
- };
9807
- recurse(startObject);
9926
+ handleVisitor();
9927
+ }
9928
+ if (stack.length >= this.maxStackSize) {
9929
+ throw new Error("Transform object stack overflowed");
9930
+ }
9931
+ handleVisitor();
9932
+ }
9933
+ };
9934
+
9935
+ // ../../packages/core/lib/TransformerTyped.js
9936
+ var TransformerTyped = class _TransformerTyped extends TransformerObject {
9937
+ defaultNodePreVisitor;
9938
+ constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
9939
+ super(defaultContext);
9940
+ this.defaultNodePreVisitor = defaultNodePreVisitor;
9941
+ }
9942
+ clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
9943
+ return new _TransformerTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
9808
9944
  }
9945
+ /**
9946
+ * Transform a single node.
9947
+ * The transformation calls the preVisitor from starting from the startObject.
9948
+ * The preVisitor can dictate whether transformation should be stopped.
9949
+ * Note that stopping the transformation also prevets further copying.
9950
+ * The transformer itself transforms object starting with the deepest one that can be visited.
9951
+ * The transformer callback is performed on a copy of the original.
9952
+ * @param startObject
9953
+ * @param nodeCallBacks
9954
+ */
9809
9955
  transformNode(startObject, nodeCallBacks) {
9810
- const transformWrapper = (curObject) => {
9811
- const casted = curObject;
9956
+ const transformWrapper = (copy3, orig) => {
9957
+ let ogTransform;
9958
+ const casted = copy3;
9812
9959
  if (casted.type) {
9813
- const ogFunc = nodeCallBacks[casted.type]?.transform;
9814
- if (ogFunc) {
9815
- return ogFunc(casted);
9816
- }
9960
+ ogTransform = nodeCallBacks[casted.type]?.transform;
9817
9961
  }
9818
- return curObject;
9962
+ return ogTransform ? ogTransform(casted, orig) : copy3;
9819
9963
  };
9820
- const preTransformWrapper = (curObject) => {
9964
+ const nodeDefaults = this.defaultNodePreVisitor;
9965
+ const preVisitWrapper = (curObject) => {
9966
+ let ogPreVisit;
9967
+ let nodeContext = {};
9821
9968
  const casted = curObject;
9822
9969
  if (casted.type) {
9823
- const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9824
- if (ogFunc) {
9825
- return ogFunc(casted);
9826
- }
9970
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
9971
+ nodeContext = nodeDefaults[casted.type] ?? nodeContext;
9827
9972
  }
9828
- return {};
9973
+ return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
9829
9974
  };
9830
- return this.transformObject(startObject, transformWrapper, preTransformWrapper);
9975
+ return this.transformObject(startObject, transformWrapper, preVisitWrapper);
9831
9976
  }
9977
+ /**
9978
+ * Similar to {@link this.transformNode}, but without copying the startObject.
9979
+ * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.
9980
+ * @param startObject
9981
+ * @param nodeCallBacks
9982
+ */
9832
9983
  visitNode(startObject, nodeCallBacks) {
9833
- const visitWrapper = (curObject) => {
9984
+ const visitorWrapper = (curObject) => {
9834
9985
  const casted = curObject;
9835
9986
  if (casted.type) {
9836
- const ogFunc = nodeCallBacks[casted.type]?.visitor;
9837
- if (ogFunc) {
9838
- ogFunc(casted);
9987
+ const ogTransform = nodeCallBacks[casted.type]?.visitor;
9988
+ if (ogTransform) {
9989
+ ogTransform(casted);
9839
9990
  }
9840
9991
  }
9841
9992
  };
9993
+ const nodeDefaults = this.defaultNodePreVisitor;
9842
9994
  const preVisitWrapper = (curObject) => {
9995
+ let ogPreVisit;
9996
+ let nodeContext = {};
9843
9997
  const casted = curObject;
9844
9998
  if (casted.type) {
9845
- const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9846
- if (ogFunc) {
9847
- return ogFunc(casted);
9848
- }
9999
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
10000
+ nodeContext = nodeDefaults[casted.type] ?? nodeContext;
9849
10001
  }
9850
- return {};
10002
+ return ogPreVisit ? { ...nodeContext, ...ogPreVisit(casted) } : nodeContext;
9851
10003
  };
9852
- this.visitObject(startObject, visitWrapper, preVisitWrapper);
10004
+ return this.visitObject(startObject, visitorWrapper, preVisitWrapper);
9853
10005
  }
10006
+ /**
10007
+ * Traverses only selected nodes as returned by the function.
10008
+ * @param currentNode
10009
+ * @param traverse
10010
+ */
9854
10011
  traverseNodes(currentNode, traverse) {
9855
10012
  let didShortCut = false;
9856
10013
  const recurse = (curNode) => {
@@ -9871,11 +10028,27 @@ var TransformerType = class {
9871
10028
  recurse(currentNode);
9872
10029
  }
9873
10030
  };
9874
- var TransformerSubType = class extends TransformerType {
10031
+
10032
+ // ../../packages/core/lib/TransformerSubTyped.js
10033
+ var TransformerSubTyped = class _TransformerSubTyped extends TransformerTyped {
10034
+ constructor(defaultContext = {}, defaultNodePreVisitor = {}) {
10035
+ super(defaultContext, defaultNodePreVisitor);
10036
+ }
10037
+ clone(newDefaultContext = {}, newDefaultNodePreVisitor = {}) {
10038
+ return new _TransformerSubTyped({ ...this.defaultContext, ...newDefaultContext }, { ...this.defaultNodePreVisitor, ...newDefaultNodePreVisitor });
10039
+ }
10040
+ /**
10041
+ * Shares the functionality and first two arguments with {@link this.transformNode}.
10042
+ * The third argument allows you to also transform based on the subType of objects.
10043
+ * Note that when a callback for the subtype is provided, the callback for the general type is **NOT** executed.
10044
+ * @param startObject
10045
+ * @param nodeCallBacks
10046
+ * @param nodeSpecificCallBacks
10047
+ */
9875
10048
  transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
9876
- const transformWrapper = (curObject) => {
10049
+ const transformWrapper = (copy3, orig) => {
9877
10050
  let ogTransform;
9878
- const casted = curObject;
10051
+ const casted = copy3;
9879
10052
  if (casted.type && casted.subType) {
9880
10053
  const specific = nodeSpecificCallBacks[casted.type];
9881
10054
  if (specific) {
@@ -9885,7 +10058,7 @@ var TransformerSubType = class extends TransformerType {
9885
10058
  ogTransform = nodeCallBacks[casted.type]?.transform;
9886
10059
  }
9887
10060
  }
9888
- return ogTransform ? ogTransform(casted) : curObject;
10061
+ return ogTransform ? ogTransform(casted, orig) : copy3;
9889
10062
  };
9890
10063
  const preVisitWrapper = (curObject) => {
9891
10064
  let ogPreVisit;
@@ -9899,12 +10072,13 @@ var TransformerSubType = class extends TransformerType {
9899
10072
  ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
9900
10073
  }
9901
10074
  }
9902
- return ogPreVisit ? ogPreVisit(casted) : curObject;
10075
+ return ogPreVisit ? ogPreVisit(casted) : {};
9903
10076
  };
9904
10077
  return this.transformObject(startObject, transformWrapper, preVisitWrapper);
9905
10078
  }
9906
10079
  /**
9907
- * When both nodeCallBack and NodeSpecific callBack are matched, will only look at nodeSpecifCallback
10080
+ * Similar to {@link this.visitNode} but also allows you to match based on the subtype of objects.
10081
+ * When both nodeCallBack and NodeSpecific callBack are matched, will only visit nodeSpecifCallback
9908
10082
  */
9909
10083
  visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
9910
10084
  const visitWrapper = (curObject) => {
@@ -9935,10 +10109,16 @@ var TransformerSubType = class extends TransformerType {
9935
10109
  ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
9936
10110
  }
9937
10111
  }
9938
- return ogPreVisit ? ogPreVisit(casted) : curObject;
10112
+ return ogPreVisit ? ogPreVisit(casted) : {};
9939
10113
  };
9940
10114
  this.visitObject(startObject, visitWrapper, preVisitWrapper);
9941
10115
  }
10116
+ /**
10117
+ * Similar to {@link this.traverseNodes} but also allows you to match based on the subtype of objects.
10118
+ * @param currentNode
10119
+ * @param traverseNode
10120
+ * @param traverseSubNode
10121
+ */
9942
10122
  traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
9943
10123
  let didShortCut = false;
9944
10124
  const recurse = (curNode) => {
@@ -11011,8 +11191,8 @@ function PatternFactoryMixin(Base) {
11011
11191
  isPatternOptional(obj) {
11012
11192
  return this.isOfSubType(obj, nodeType5, "optional");
11013
11193
  }
11014
- patternValues(values3, loc) {
11015
- return { type: nodeType5, subType: "values", values: values3, loc };
11194
+ patternValues(variables, values3, loc) {
11195
+ return { type: nodeType5, subType: "values", variables, values: values3, loc };
11016
11196
  }
11017
11197
  isPatternValues(obj) {
11018
11198
  return this.isOfSubType(obj, nodeType5, "values");
@@ -11187,7 +11367,7 @@ function TermFactoryMixin(Base) {
11187
11367
  isTerm(x) {
11188
11368
  return this.isOfType(x, "term");
11189
11369
  }
11190
- blankNode(label, loc) {
11370
+ termBlank(label, loc) {
11191
11371
  const base = {
11192
11372
  type: "term",
11193
11373
  subType: "blankNode",
@@ -11201,7 +11381,7 @@ function TermFactoryMixin(Base) {
11201
11381
  isTermBlank(obj) {
11202
11382
  return this.isOfSubType(obj, nodeType8, "blankNode");
11203
11383
  }
11204
- literalTerm(loc, value, langOrIri) {
11384
+ termLiteral(loc, value, langOrIri) {
11205
11385
  return {
11206
11386
  type: nodeType8,
11207
11387
  subType: "literal",
@@ -11223,7 +11403,7 @@ function TermFactoryMixin(Base) {
11223
11403
  const casted = obj;
11224
11404
  return this.isTermLiteral(obj) && typeof casted.langOrIri === "object" && casted.langOrIri !== null && this.isTermNamed(casted.langOrIri);
11225
11405
  }
11226
- variable(value, loc) {
11406
+ termVariable(value, loc) {
11227
11407
  return {
11228
11408
  type: nodeType8,
11229
11409
  subType: "variable",
@@ -11234,7 +11414,7 @@ function TermFactoryMixin(Base) {
11234
11414
  isTermVariable(obj) {
11235
11415
  return this.isOfSubType(obj, nodeType8, "variable");
11236
11416
  }
11237
- namedNode(loc, value, prefix) {
11417
+ termNamed(loc, value, prefix) {
11238
11418
  const base = {
11239
11419
  type: nodeType8,
11240
11420
  subType: "namedNode",
@@ -11497,7 +11677,7 @@ var CommonIRIs;
11497
11677
  CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
11498
11678
  CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
11499
11679
  })(CommonIRIs || (CommonIRIs = {}));
11500
- var AstTransformer = class extends TransformerSubType {
11680
+ var AstTransformer = class extends TransformerSubTyped {
11501
11681
  };
11502
11682
 
11503
11683
  // ../../packages/rules-sparql-1-1/lib/validation/validators.js
@@ -11625,8 +11805,7 @@ function findPatternBoundedVars(iter, boundedVars) {
11625
11805
  optional: (op) => ({ next: op.patterns }),
11626
11806
  service: (op) => ({ next: [op.name, ...op.patterns] }),
11627
11807
  bind: (op) => ({ next: [op.variable] }),
11628
- graph: (op) => ({ next: [op.name, ...op.patterns] }),
11629
- minus: (op) => ({ next: op.patterns.slice(0, 1) })
11808
+ graph: (op) => ({ next: [op.name, ...op.patterns] })
11630
11809
  },
11631
11810
  term: {
11632
11811
  variable: (op) => {
@@ -11713,17 +11892,20 @@ var rdfLiteral = {
11713
11892
  return OPTION(() => OR([
11714
11893
  { ALT: () => {
11715
11894
  const lang2 = CONSUME(terminals_exports.langTag);
11716
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
11895
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang2), value.value, lang2.image.slice(1).toLowerCase()));
11717
11896
  } },
11718
11897
  { ALT: () => {
11719
11898
  CONSUME(symbols_exports.hathat);
11720
11899
  const iriVal = SUBRULE1(iri2);
11721
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
11900
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
11722
11901
  } }
11723
11902
  ])) ?? value;
11724
11903
  },
11725
- gImpl: ({ SUBRULE, PRINT, PRINT_SPACE_LEFT }) => (ast, { astFactory }) => {
11726
- astFactory.printFilter(ast, () => PRINT_SPACE_LEFT(stringEscapedLexical(ast.value)));
11904
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
11905
+ astFactory.printFilter(ast, () => {
11906
+ PRINT_WORD("");
11907
+ PRINT(stringEscapedLexical(ast.value));
11908
+ });
11727
11909
  if (ast.langOrIri) {
11728
11910
  if (typeof ast.langOrIri === "string") {
11729
11911
  astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
@@ -11750,7 +11932,7 @@ var numericLiteralUnsigned = {
11750
11932
  { ALT: () => [CONSUME(terminals_exports.decimal), CommonIRIs.DECIMAL] },
11751
11933
  { ALT: () => [CONSUME(terminals_exports.double), CommonIRIs.DOUBLE] }
11752
11934
  ]);
11753
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11935
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11754
11936
  }
11755
11937
  };
11756
11938
  var numericLiteralPositive = {
@@ -11761,7 +11943,7 @@ var numericLiteralPositive = {
11761
11943
  { ALT: () => [CONSUME(terminals_exports.decimalPositive), CommonIRIs.DECIMAL] },
11762
11944
  { ALT: () => [CONSUME(terminals_exports.doublePositive), CommonIRIs.DOUBLE] }
11763
11945
  ]);
11764
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11946
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11765
11947
  }
11766
11948
  };
11767
11949
  var numericLiteralNegative = {
@@ -11772,7 +11954,7 @@ var numericLiteralNegative = {
11772
11954
  { ALT: () => [CONSUME(terminals_exports.decimalNegative), CommonIRIs.DECIMAL] },
11773
11955
  { ALT: () => [CONSUME(terminals_exports.doubleNegative), CommonIRIs.DOUBLE] }
11774
11956
  ]);
11775
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11957
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
11776
11958
  }
11777
11959
  };
11778
11960
  var booleanLiteral = {
@@ -11782,7 +11964,7 @@ var booleanLiteral = {
11782
11964
  { ALT: () => CONSUME(true_) },
11783
11965
  { ALT: () => CONSUME(false_) }
11784
11966
  ]);
11785
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.namedNode(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
11967
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), CommonIRIs.BOOLEAN)));
11786
11968
  }
11787
11969
  };
11788
11970
  var string = {
@@ -11824,7 +12006,7 @@ var string = {
11824
12006
  return char;
11825
12007
  }
11826
12008
  });
11827
- return F3.literalTerm(F3.sourceLocation(x[0]), value);
12009
+ return F3.termLiteral(F3.sourceLocation(x[0]), value);
11828
12010
  });
11829
12011
  }
11830
12012
  };
@@ -11840,7 +12022,7 @@ var iriFull = {
11840
12022
  name: "iriFull",
11841
12023
  impl: ({ ACTION, CONSUME }) => (C) => {
11842
12024
  const iriToken = CONSUME(terminals_exports.iriRef);
11843
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
12025
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
11844
12026
  },
11845
12027
  gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
11846
12028
  F3.printFilter(ast, () => PRINT("<", ast.value, ">"));
@@ -11853,16 +12035,16 @@ var prefixedName = {
11853
12035
  const longName = CONSUME(terminals_exports.pNameLn);
11854
12036
  return ACTION(() => {
11855
12037
  const [prefix, localName] = longName.image.split(":");
11856
- return C.astFactory.namedNode(C.astFactory.sourceLocation(longName), localName, prefix);
12038
+ return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
11857
12039
  });
11858
12040
  } },
11859
12041
  { ALT: () => {
11860
12042
  const shortName = CONSUME(terminals_exports.pNameNs);
11861
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
12043
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
11862
12044
  } }
11863
12045
  ]),
11864
- gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F3 }) => {
11865
- F3.printFilter(ast, () => PRINT_WORD(ast.prefix, ":", ast.value));
12046
+ gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
12047
+ F3.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
11866
12048
  }
11867
12049
  };
11868
12050
  var canCreateBlankNodes = Symbol("canCreateBlankNodes");
@@ -11872,11 +12054,11 @@ var blankNode = {
11872
12054
  const result = OR([
11873
12055
  { ALT: () => {
11874
12056
  const labelToken = CONSUME(terminals_exports.blankNodeLabel);
11875
- return ACTION(() => C.astFactory.blankNode(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
12057
+ return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
11876
12058
  } },
11877
12059
  { ALT: () => {
11878
12060
  const anonToken = CONSUME(terminals_exports.anon);
11879
- return ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocation(anonToken)));
12061
+ return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
11880
12062
  } }
11881
12063
  ]);
11882
12064
  ACTION(() => {
@@ -11886,15 +12068,15 @@ var blankNode = {
11886
12068
  });
11887
12069
  return result;
11888
12070
  },
11889
- gImpl: ({ PRINT_WORD }) => (ast, { astFactory }) => {
11890
- astFactory.printFilter(ast, () => PRINT_WORD("_:", ast.label.replace(/^e_/u, "")));
12071
+ gImpl: ({ PRINT }) => (ast, { astFactory }) => {
12072
+ astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
11891
12073
  }
11892
12074
  };
11893
12075
  var verbA = {
11894
12076
  name: "VerbA",
11895
12077
  impl: ({ ACTION, CONSUME }) => (C) => {
11896
12078
  const token = CONSUME(a);
11897
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
12079
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE, void 0));
11898
12080
  }
11899
12081
  };
11900
12082
 
@@ -11928,10 +12110,10 @@ var baseDecl2 = {
11928
12110
  const val = SUBRULE(iriFull);
11929
12111
  return ACTION(() => C.astFactory.contextDefinitionBase(C.astFactory.sourceLocation(base, val), val));
11930
12112
  },
11931
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
11932
- F3.printFilter(ast, () => PRINT_WORD("BASE"));
12113
+ gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
12114
+ F3.printFilter(ast, () => PRINT_ON_EMPTY("BASE "));
11933
12115
  SUBRULE(iri2, ast.value);
11934
- F3.printFilter(ast, () => PRINT_WORD("\n"));
12116
+ F3.printFilter(ast, () => NEW_LINE());
11935
12117
  }
11936
12118
  };
11937
12119
  var prefixDecl2 = {
@@ -11942,12 +12124,12 @@ var prefixDecl2 = {
11942
12124
  const value = SUBRULE(iriFull);
11943
12125
  return ACTION(() => C.astFactory.contextDefinitionPrefix(C.astFactory.sourceLocation(prefix, value), name, value));
11944
12126
  },
11945
- gImpl: ({ SUBRULE, PRINT_WORDS }) => (ast, { astFactory: F3 }) => {
12127
+ gImpl: ({ SUBRULE, PRINT_ON_EMPTY, NEW_LINE }) => (ast, { astFactory: F3 }) => {
11946
12128
  F3.printFilter(ast, () => {
11947
- PRINT_WORDS("PREFIX", `${ast.key}:`);
12129
+ PRINT_ON_EMPTY("PREFIX ", `${ast.key}: `);
11948
12130
  });
11949
12131
  SUBRULE(iri2, ast.value);
11950
- F3.printFilter(ast, () => PRINT_WORDS("\n"));
12132
+ F3.printFilter(ast, () => NEW_LINE());
11951
12133
  }
11952
12134
  };
11953
12135
  var verb = {
@@ -11984,10 +12166,10 @@ var var_ = {
11984
12166
  { ALT: () => CONSUME(terminals_exports.var1) },
11985
12167
  { ALT: () => CONSUME(terminals_exports.var2) }
11986
12168
  ]);
11987
- return ACTION(() => C.astFactory.variable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
12169
+ return ACTION(() => C.astFactory.termVariable(varToken.image.slice(1), C.astFactory.sourceLocation(varToken)));
11988
12170
  },
11989
- gImpl: ({ PRINT_WORD }) => (ast, { astFactory: F3 }) => {
11990
- F3.printFilter(ast, () => PRINT_WORD(`?${ast.value}`));
12171
+ gImpl: ({ PRINT }) => (ast, { astFactory: F3 }) => {
12172
+ F3.printFilter(ast, () => PRINT(`?${ast.value}`));
11991
12173
  }
11992
12174
  };
11993
12175
  var graphTerm = {
@@ -12000,7 +12182,7 @@ var graphTerm = {
12000
12182
  { GATE: () => C.parseMode.has("canCreateBlankNodes"), ALT: () => SUBRULE(blankNode) },
12001
12183
  { ALT: () => {
12002
12184
  const tokenNil = CONSUME(terminals_exports.nil);
12003
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
12185
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(tokenNil), CommonIRIs.NIL));
12004
12186
  } }
12005
12187
  ]),
12006
12188
  gImpl: ({ SUBRULE }) => (ast, { astFactory: F3 }) => {
@@ -12630,13 +12812,16 @@ function triplesDotSeperated(triplesSameSubjectSubrule) {
12630
12812
  var triplesBlock = {
12631
12813
  name: "triplesBlock",
12632
12814
  impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
12633
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
12815
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F3 }) => {
12634
12816
  for (const [index, triple] of ast.triples.entries()) {
12635
12817
  HANDLE_LOC(triple, () => {
12636
12818
  const nextTriple = ast.triples.at(index);
12637
12819
  if (F3.isTripleCollection(triple)) {
12638
12820
  SUBRULE(graphNodePath, triple);
12639
- F3.printFilter(triple, () => PRINT_WORD(".\n"));
12821
+ F3.printFilter(triple, () => {
12822
+ PRINT_WORD(".");
12823
+ NEW_LINE();
12824
+ });
12640
12825
  } else {
12641
12826
  SUBRULE(graphNodePath, triple.subject);
12642
12827
  F3.printFilter(triple, () => PRINT_WORD(""));
@@ -12648,11 +12833,17 @@ var triplesBlock = {
12648
12833
  F3.printFilter(triple, () => PRINT_WORD(""));
12649
12834
  SUBRULE(graphNodePath, triple.object);
12650
12835
  if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
12651
- F3.printFilter(ast, () => PRINT_WORD(".\n"));
12836
+ F3.printFilter(ast, () => {
12837
+ PRINT_WORD(".");
12838
+ NEW_LINE();
12839
+ });
12652
12840
  } else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
12653
12841
  F3.printFilter(ast, () => PRINT_WORD(","));
12654
12842
  } else {
12655
- F3.printFilter(ast, () => PRINT_WORD(";\n"));
12843
+ F3.printFilter(ast, () => {
12844
+ PRINT_WORD(";");
12845
+ NEW_LINE();
12846
+ });
12656
12847
  }
12657
12848
  }
12658
12849
  });
@@ -12785,10 +12976,10 @@ function collectionImpl(name, allowPaths) {
12785
12976
  return ACTION(() => {
12786
12977
  const F3 = C.astFactory;
12787
12978
  const triples = [];
12788
- const predFirst = F3.namedNode(F3.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
12789
- const predRest = F3.namedNode(F3.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
12790
- const predNil = F3.namedNode(F3.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
12791
- const listHead = F3.blankNode(void 0, F3.sourceLocationNoMaterialize());
12979
+ const predFirst = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.FIRST, void 0);
12980
+ const predRest = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.REST, void 0);
12981
+ const predNil = F3.termNamed(F3.sourceLocationNoMaterialize(), CommonIRIs.NIL, void 0);
12982
+ const listHead = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
12792
12983
  let iterHead = listHead;
12793
12984
  for (const [index, term] of terms.entries()) {
12794
12985
  const lastInList = index === terms.length - 1;
@@ -12798,7 +12989,7 @@ function collectionImpl(name, allowPaths) {
12798
12989
  const nilTriple = F3.triple(iterHead, predRest, predNil);
12799
12990
  triples.push(nilTriple);
12800
12991
  } else {
12801
- const tail = F3.blankNode(void 0, F3.sourceLocationNoMaterialize());
12992
+ const tail = F3.termBlank(void 0, F3.sourceLocationNoMaterialize());
12802
12993
  const linkTriple = F3.triple(iterHead, predRest, tail);
12803
12994
  triples.push(linkTriple);
12804
12995
  iterHead = tail;
@@ -12838,16 +13029,17 @@ function blankNodePropertyListImpl(name, allowPaths) {
12838
13029
  name,
12839
13030
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
12840
13031
  const startToken = CONSUME(symbols_exports.LSquare);
12841
- const blankNode2 = ACTION(() => C.astFactory.blankNode(void 0, C.astFactory.sourceLocationNoMaterialize()));
13032
+ const blankNode2 = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
12842
13033
  const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode2);
12843
13034
  const endToken = CONSUME(symbols_exports.RSquare);
12844
13035
  return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode2, propList, C.astFactory.sourceLocation(startToken, endToken)));
12845
13036
  },
12846
- gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, c) => {
13037
+ gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
12847
13038
  const { astFactory: F3, indentInc } = c;
12848
13039
  F3.printFilter(ast, () => {
12849
13040
  c[traqulaIndentation] += indentInc;
12850
- PRINT("[\n");
13041
+ PRINT("[");
13042
+ NEW_LINE();
12851
13043
  });
12852
13044
  for (const triple of ast.triples) {
12853
13045
  HANDLE_LOC(triple, () => {
@@ -12858,7 +13050,10 @@ function blankNodePropertyListImpl(name, allowPaths) {
12858
13050
  }
12859
13051
  F3.printFilter(triple, () => PRINT_WORD(""));
12860
13052
  SUBRULE(graphNodePath, triple.object);
12861
- F3.printFilter(ast, () => PRINT_WORD(";\n"));
13053
+ F3.printFilter(ast, () => {
13054
+ PRINT_WORD(";");
13055
+ NEW_LINE();
13056
+ });
12862
13057
  });
12863
13058
  }
12864
13059
  F3.printFilter(ast, () => {
@@ -12917,18 +13112,19 @@ var groupGraphPattern = {
12917
13112
  const close = CONSUME(symbols_exports.RCurly);
12918
13113
  return ACTION(() => C.astFactory.patternGroup(patterns, C.astFactory.sourceLocation(open, close)));
12919
13114
  },
12920
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
13115
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
12921
13116
  const { astFactory: F3, indentInc } = C;
12922
13117
  F3.printFilter(ast, () => {
12923
13118
  C[traqulaIndentation] += indentInc;
12924
- PRINT_WORD("{\n");
13119
+ PRINT_WORD("{");
13120
+ NEW_LINE();
12925
13121
  });
12926
13122
  for (const pattern of ast.patterns) {
12927
13123
  SUBRULE(generatePattern, pattern);
12928
13124
  }
12929
13125
  F3.printFilter(ast, () => {
12930
13126
  C[traqulaIndentation] -= indentInc;
12931
- PRINT_ON_EMPTY("}\n");
13127
+ PRINT_ON_OWN_LINE("}");
12932
13128
  });
12933
13129
  }
12934
13130
  };
@@ -13078,12 +13274,15 @@ var bind2 = {
13078
13274
  const close = CONSUME(symbols_exports.RParen);
13079
13275
  return ACTION(() => C.astFactory.patternBind(expressionVal, variable, C.astFactory.sourceLocation(bind3, close)));
13080
13276
  },
13081
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
13277
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
13082
13278
  F3.printFilter(ast, () => PRINT_WORD("BIND", "("));
13083
13279
  SUBRULE(expression, ast.expression);
13084
13280
  F3.printFilter(ast, () => PRINT_WORD("AS"));
13085
13281
  SUBRULE(var_, ast.variable);
13086
- F3.printFilter(ast, () => PRINT_WORD(")\n"));
13282
+ F3.printFilter(ast, () => {
13283
+ PRINT_WORD(")");
13284
+ NEW_LINE();
13285
+ });
13087
13286
  }
13088
13287
  };
13089
13288
  var inlineData = {
@@ -13091,34 +13290,46 @@ var inlineData = {
13091
13290
  impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
13092
13291
  const values3 = CONSUME(values2);
13093
13292
  const datablock = SUBRULE(dataBlock);
13094
- return ACTION(() => C.astFactory.patternValues(datablock.val, C.astFactory.sourceLocation(values3, datablock)));
13293
+ return ACTION(() => {
13294
+ datablock.loc = C.astFactory.sourceLocation(values3, datablock);
13295
+ return datablock;
13296
+ });
13095
13297
  },
13096
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
13298
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
13097
13299
  const { astFactory: F3, indentInc } = C;
13098
- const variables = Object.keys(ast.values.at(0) ?? {});
13300
+ const variables = ast.variables;
13301
+ const singleVar = variables.length === 1;
13302
+ F3.printFilter(ast, () => {
13303
+ PRINT_ON_EMPTY("VALUES", singleVar ? "" : "( ");
13304
+ });
13305
+ for (const variable of variables) {
13306
+ F3.printFilter(ast, () => PRINT_WORD(""));
13307
+ SUBRULE(varOrTerm, variable);
13308
+ F3.printFilter(ast, () => PRINT_WORD(""));
13309
+ }
13099
13310
  F3.printFilter(ast, () => {
13100
- PRINT_ON_EMPTY("");
13101
- PRINT_WORD("VALUES", "(");
13102
- for (const variable of variables) {
13103
- PRINT_WORD(`?${variable}`);
13104
- }
13105
13311
  C[traqulaIndentation] += indentInc;
13106
- PRINT_WORD(")", "{\n");
13312
+ PRINT_WORD(singleVar ? "" : ")", "{");
13313
+ NEW_LINE();
13107
13314
  });
13108
13315
  for (const mapping of ast.values) {
13109
- F3.printFilter(ast, () => PRINT_WORD("("));
13316
+ F3.printFilter(ast, () => !singleVar && PRINT_WORD("("));
13110
13317
  for (const variable of variables) {
13111
- if (mapping[variable] === void 0) {
13318
+ const var_2 = variable.value;
13319
+ if (mapping[var_2] === void 0) {
13112
13320
  F3.printFilter(ast, () => PRINT_WORD("UNDEF"));
13113
13321
  } else {
13114
- SUBRULE(graphNodePath, mapping[variable]);
13322
+ SUBRULE(graphNodePath, mapping[var_2]);
13115
13323
  }
13116
13324
  }
13117
- F3.printFilter(ast, () => PRINT_WORD(")\n"));
13325
+ F3.printFilter(ast, () => {
13326
+ PRINT_WORD(singleVar ? "" : ")");
13327
+ NEW_LINE();
13328
+ });
13118
13329
  }
13119
13330
  F3.printFilter(ast, () => {
13120
13331
  C[traqulaIndentation] -= indentInc;
13121
- PRINT_ON_EMPTY("}\n");
13332
+ PRINT_ON_OWN_LINE("}");
13122
13333
  });
13123
13334
  }
13124
13335
  };
@@ -13142,7 +13353,7 @@ var inlineDataOneVar = {
13142
13353
  });
13143
13354
  });
13144
13355
  const close = CONSUME(symbols_exports.RCurly);
13145
- return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(varVal, close)));
13356
+ return ACTION(() => C.astFactory.patternValues([varVal], res, C.astFactory.sourceLocation(varVal, close)));
13146
13357
  }
13147
13358
  };
13148
13359
  var inlineDataFull = {
@@ -13159,7 +13370,7 @@ var inlineDataFull = {
13159
13370
  res.push({});
13160
13371
  });
13161
13372
  const close = CONSUME1(symbols_exports.RCurly);
13162
- return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(nil2, close)));
13373
+ return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(nil2, close)));
13163
13374
  } },
13164
13375
  { ALT: () => {
13165
13376
  const open = CONSUME1(symbols_exports.LParen);
@@ -13191,7 +13402,7 @@ var inlineDataFull = {
13191
13402
  });
13192
13403
  });
13193
13404
  const close = CONSUME2(symbols_exports.RCurly);
13194
- return ACTION(() => C.astFactory.wrap(res, C.astFactory.sourceLocation(open, close)));
13405
+ return ACTION(() => C.astFactory.patternValues(vars, res, C.astFactory.sourceLocation(open, close)));
13195
13406
  } }
13196
13407
  ]);
13197
13408
  }
@@ -13254,10 +13465,13 @@ var filter3 = {
13254
13465
  const expression2 = SUBRULE(constraint);
13255
13466
  return ACTION(() => C.astFactory.patternFilter(expression2, C.astFactory.sourceLocation(filterToken, expression2)));
13256
13467
  },
13257
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
13468
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE }) => (ast, { astFactory: F3 }) => {
13258
13469
  F3.printFilter(ast, () => PRINT_WORD("FILTER ("));
13259
13470
  SUBRULE(expression, ast.expression);
13260
- F3.printFilter(ast, () => PRINT_WORD(")\n"));
13471
+ F3.printFilter(ast, () => {
13472
+ PRINT_WORD(")");
13473
+ NEW_LINE();
13474
+ });
13261
13475
  }
13262
13476
  };
13263
13477
  var constraint = {
@@ -13643,8 +13857,7 @@ var groupClause = {
13643
13857
  },
13644
13858
  gImpl: ({ PRINT_WORDS, SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
13645
13859
  F3.printFilter(ast, () => {
13646
- PRINT_ON_EMPTY("");
13647
- PRINT_WORDS("GROUP", "BY");
13860
+ PRINT_ON_EMPTY("GROUP BY ");
13648
13861
  });
13649
13862
  for (const grouping of ast.groupings) {
13650
13863
  if (F3.isExpression(grouping)) {
@@ -13700,10 +13913,9 @@ var havingClause = {
13700
13913
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13701
13914
  return ACTION(() => C.astFactory.solutionModifierHaving(expressions, C.astFactory.sourceLocation(having2, expressions.at(-1))));
13702
13915
  },
13703
- gImpl: ({ PRINT_WORD, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
13916
+ gImpl: ({ PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
13704
13917
  F3.printFilter(ast, () => {
13705
- PRINT_ON_EMPTY("");
13706
- PRINT_WORD("HAVING");
13918
+ PRINT_ON_EMPTY("HAVING ");
13707
13919
  });
13708
13920
  for (const having2 of ast.having) {
13709
13921
  SUBRULE(expression, having2);
@@ -13729,8 +13941,7 @@ var orderClause = {
13729
13941
  },
13730
13942
  gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY, SUBRULE }) => (ast, { astFactory: F3 }) => {
13731
13943
  F3.printFilter(ast, () => {
13732
- PRINT_ON_EMPTY("");
13733
- PRINT_WORDS("ORDER", "BY");
13944
+ PRINT_ON_EMPTY("ORDER BY ");
13734
13945
  });
13735
13946
  for (const ordering of ast.orderDefs) {
13736
13947
  if (ordering.descending) {
@@ -13789,9 +14000,9 @@ var limitOffsetClauses = {
13789
14000
  return ACTION(() => C.astFactory.solutionModifierLimitOffset(limit2?.val, offset2.val, C.astFactory.sourceLocation(offset2, limit2)));
13790
14001
  } }
13791
14002
  ]),
13792
- gImpl: ({ PRINT_WORDS, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
14003
+ gImpl: ({ PRINT_WORDS, NEW_LINE }) => (ast, { astFactory: F3 }) => {
13793
14004
  F3.printFilter(ast, () => {
13794
- PRINT_ON_EMPTY("");
14005
+ NEW_LINE();
13795
14006
  if (ast.limit) {
13796
14007
  PRINT_WORDS("LIMIT", String(ast.limit));
13797
14008
  }
@@ -13976,9 +14187,9 @@ var selectClause = {
13976
14187
  ACTION(() => !couldParseAgg && C.parseMode.delete("canParseAggregate"));
13977
14188
  return ACTION(() => C.astFactory.wrap(val, C.astFactory.sourceLocation(select2, last2)));
13978
14189
  },
13979
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14190
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
13980
14191
  F3.printFilter(ast, () => {
13981
- PRINT_WORD("SELECT");
14192
+ PRINT_ON_EMPTY("SELECT ");
13982
14193
  if (ast.val.distinct) {
13983
14194
  PRINT_WORD("DISTINCT");
13984
14195
  } else if (ast.val.reduced) {
@@ -13997,7 +14208,9 @@ var selectClause = {
13997
14208
  SUBRULE(var_, variable.variable);
13998
14209
  F3.printFilter(ast, () => PRINT_WORD(")"));
13999
14210
  }
14211
+ F3.printFilter(ast, () => PRINT_WORD(""));
14000
14212
  }
14213
+ F3.printFilter(ast, () => PRINT_WORD(""));
14001
14214
  }
14002
14215
  };
14003
14216
  var constructQuery = {
@@ -14035,18 +14248,19 @@ var constructQuery = {
14035
14248
  } }
14036
14249
  ]);
14037
14250
  },
14038
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14251
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
14039
14252
  const { astFactory: F3, indentInc } = C;
14040
- F3.printFilter(ast, () => PRINT_WORD("CONSTRUCT"));
14253
+ F3.printFilter(ast, () => PRINT_ON_EMPTY("CONSTRUCT "));
14041
14254
  if (!F3.isSourceLocationNoMaterialize(ast.where.loc)) {
14042
14255
  F3.printFilter(ast, () => {
14043
14256
  C[traqulaIndentation] += indentInc;
14044
- PRINT_WORD("{\n");
14257
+ PRINT_WORD("{");
14258
+ NEW_LINE();
14045
14259
  });
14046
14260
  SUBRULE(triplesBlock, ast.template);
14047
14261
  F3.printFilter(ast, () => {
14048
14262
  C[traqulaIndentation] -= indentInc;
14049
- PRINT_ON_EMPTY("}\n");
14263
+ PRINT_ON_OWN_LINE("}");
14050
14264
  });
14051
14265
  }
14052
14266
  SUBRULE(datasetClauseStar, ast.datasets);
@@ -14087,8 +14301,8 @@ var describeQuery = {
14087
14301
  loc: C.astFactory.sourceLocation(describe2, ...variables, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
14088
14302
  }));
14089
14303
  },
14090
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14091
- F3.printFilter(ast, () => PRINT_WORD("DESCRIBE"));
14304
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
14305
+ F3.printFilter(ast, () => PRINT_ON_EMPTY("DESCRIBE "));
14092
14306
  if (F3.isWildcard(ast.variables[0])) {
14093
14307
  F3.printFilter(ast, () => PRINT_WORD("*"));
14094
14308
  } else {
@@ -14118,8 +14332,8 @@ var askQuery = {
14118
14332
  loc: C.astFactory.sourceLocation(ask2, from2, where2, modifiers.group, modifiers.having, modifiers.order, modifiers.limitOffset)
14119
14333
  }));
14120
14334
  },
14121
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14122
- F3.printFilter(ast, () => PRINT_WORD("ASK"));
14335
+ gImpl: ({ SUBRULE, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
14336
+ F3.printFilter(ast, () => PRINT_ON_EMPTY("ASK "));
14123
14337
  SUBRULE(datasetClauseStar, ast.datasets);
14124
14338
  SUBRULE(whereClause, F3.wrap(ast.where, ast.loc));
14125
14339
  SUBRULE(solutionModifier, ast.solutionModifiers);
@@ -14178,7 +14392,7 @@ var update = {
14178
14392
  return update2;
14179
14393
  });
14180
14394
  },
14181
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14395
+ gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F3 }) => {
14182
14396
  const [head2, ...tail] = ast.updates;
14183
14397
  if (head2) {
14184
14398
  SUBRULE(prologue, head2.context);
@@ -14187,7 +14401,10 @@ var update = {
14187
14401
  }
14188
14402
  }
14189
14403
  for (const update2 of tail) {
14190
- F3.printFilter(ast, () => PRINT_WORD(";\n"));
14404
+ F3.printFilter(ast, () => {
14405
+ PRINT(";");
14406
+ NEW_LINE();
14407
+ });
14191
14408
  SUBRULE(prologue, update2.context);
14192
14409
  if (update2.operation) {
14193
14410
  SUBRULE(update1, update2.operation);
@@ -14260,9 +14477,9 @@ var load2 = {
14260
14477
  });
14261
14478
  return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent2), destination));
14262
14479
  },
14263
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14480
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
14264
14481
  F3.printFilter(ast, () => {
14265
- PRINT_WORD("LOAD");
14482
+ PRINT_ON_EMPTY("LOAD ");
14266
14483
  if (ast.silent) {
14267
14484
  PRINT_WORD("SILENT");
14268
14485
  }
@@ -14283,9 +14500,9 @@ function clearOrDrop(operation) {
14283
14500
  const destination = SUBRULE1(graphRefAll);
14284
14501
  return ACTION(() => C.astFactory.updateOperationClearDrop(unCapitalize(operation.name), Boolean(silent2), destination, C.astFactory.sourceLocation(opToken, destination)));
14285
14502
  },
14286
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14503
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
14287
14504
  F3.printFilter(ast, () => {
14288
- PRINT_WORD(operation.name.toUpperCase());
14505
+ PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
14289
14506
  if (ast.silent) {
14290
14507
  PRINT_WORD("SILENT");
14291
14508
  }
@@ -14304,9 +14521,9 @@ var create2 = {
14304
14521
  const destination = SUBRULE1(graphRef);
14305
14522
  return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent2), C.astFactory.sourceLocation(createToken3, destination)));
14306
14523
  },
14307
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14524
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
14308
14525
  F3.printFilter(ast, () => {
14309
- PRINT_WORD("CREATE");
14526
+ PRINT_ON_EMPTY("CREATE ");
14310
14527
  if (ast.silent) {
14311
14528
  PRINT_WORD("SILENT");
14312
14529
  }
@@ -14325,9 +14542,9 @@ function copyMoveAddOperation(operation) {
14325
14542
  const destination = SUBRULE2(graphOrDefault);
14326
14543
  return ACTION(() => C.astFactory.updateOperationAddMoveCopy(unCapitalize(operation.name), source, destination, Boolean(silent2), C.astFactory.sourceLocation(op, destination)));
14327
14544
  },
14328
- gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
14545
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F3 }) => {
14329
14546
  F3.printFilter(ast, () => {
14330
- PRINT_WORD(operation.name.toUpperCase());
14547
+ PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
14331
14548
  if (ast.silent) {
14332
14549
  PRINT_WORD("SILENT");
14333
14550
  }
@@ -14376,23 +14593,24 @@ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
14376
14593
  }
14377
14594
  return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
14378
14595
  },
14379
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14596
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
14380
14597
  const { astFactory: F3, indentInc } = C;
14381
14598
  F3.printFilter(ast, () => {
14382
- C[traqulaIndentation] += indentInc;
14383
14599
  if (subType === "insertdata") {
14384
- PRINT_WORD("INSERT DATA");
14600
+ PRINT_ON_EMPTY("INSERT DATA ");
14385
14601
  } else if (subType === "deletedata") {
14386
- PRINT_WORD("DELETE DATA");
14602
+ PRINT_ON_EMPTY("DELETE DATA ");
14387
14603
  } else if (subType === "deletewhere") {
14388
- PRINT_WORD("DELETE WHERE");
14604
+ PRINT_ON_EMPTY("DELETE WHERE ");
14389
14605
  }
14390
- PRINT_WORD("{\n");
14606
+ C[traqulaIndentation] += indentInc;
14607
+ PRINT_WORD("{");
14608
+ NEW_LINE();
14391
14609
  });
14392
14610
  SUBRULE(quads, F3.wrap(ast.data, ast.loc));
14393
14611
  F3.printFilter(ast, () => {
14394
14612
  C[traqulaIndentation] -= indentInc;
14395
- PRINT_ON_EMPTY("}\n");
14613
+ PRINT_ON_OWN_LINE("}");
14396
14614
  });
14397
14615
  }
14398
14616
  };
@@ -14424,36 +14642,40 @@ var modify = {
14424
14642
  const where2 = SUBRULE1(groupGraphPattern);
14425
14643
  return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph2?.withToken, del, insert, where2), insert?.val ?? [], del?.val ?? [], where2, using, graph2?.graph));
14426
14644
  },
14427
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14645
+ gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
14428
14646
  const { astFactory: F3, indentInc } = C;
14429
14647
  if (ast.graph) {
14430
- F3.printFilter(ast, () => PRINT_WORD("WITH"));
14648
+ F3.printFilter(ast, () => PRINT_WORDS("WITH"));
14431
14649
  SUBRULE(iri2, ast.graph);
14432
14650
  }
14433
14651
  if (ast.delete.length > 0) {
14434
14652
  F3.printFilter(ast, () => {
14435
14653
  C[traqulaIndentation] += indentInc;
14436
- PRINT_WORD("DELETE", "{\n");
14654
+ PRINT_WORDS("DELETE", "{");
14655
+ NEW_LINE();
14437
14656
  });
14438
14657
  SUBRULE(quads, F3.wrap(ast.delete, ast.loc));
14439
14658
  F3.printFilter(ast, () => {
14440
14659
  C[traqulaIndentation] -= indentInc;
14441
- PRINT_ON_EMPTY("}\n");
14660
+ PRINT_ON_EMPTY("}");
14661
+ NEW_LINE();
14442
14662
  });
14443
14663
  }
14444
14664
  if (ast.insert.length > 0) {
14445
14665
  F3.printFilter(ast, () => {
14446
14666
  C[traqulaIndentation] += indentInc;
14447
- PRINT_WORD("INSERT", "{\n");
14667
+ PRINT_WORDS("INSERT", "{");
14668
+ NEW_LINE();
14448
14669
  });
14449
14670
  SUBRULE(quads, F3.wrap(ast.insert, ast.loc));
14450
14671
  F3.printFilter(ast, () => {
14451
14672
  C[traqulaIndentation] -= indentInc;
14452
- PRINT_ON_EMPTY("}\n");
14673
+ PRINT_ON_EMPTY("} ");
14674
+ NEW_LINE();
14453
14675
  });
14454
14676
  }
14455
14677
  SUBRULE(usingClauseStar, ast.from);
14456
- F3.printFilter(ast, () => PRINT_WORD("WHERE"));
14678
+ F3.printFilter(ast, () => PRINT_WORDS("WHERE"));
14457
14679
  SUBRULE(groupGraphPattern, ast.where);
14458
14680
  }
14459
14681
  };
@@ -14577,18 +14799,19 @@ var quadsNotTriples = {
14577
14799
  const close = CONSUME(symbols_exports.RCurly);
14578
14800
  return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph2, close)));
14579
14801
  },
14580
- gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, C) => {
14802
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
14581
14803
  const { astFactory: F3, indentInc } = C;
14582
14804
  F3.printFilter(ast, () => PRINT_WORD("GRAPH"));
14583
14805
  SUBRULE(varOrTerm, ast.graph);
14584
14806
  F3.printFilter(ast, () => {
14585
14807
  C[traqulaIndentation] += indentInc;
14586
- PRINT_WORD("{\n");
14808
+ PRINT_WORD("{");
14809
+ NEW_LINE();
14587
14810
  });
14588
14811
  SUBRULE(triplesBlock, ast.triples);
14589
14812
  F3.printFilter(ast, () => {
14590
14813
  C[traqulaIndentation] -= indentInc;
14591
- PRINT_ON_EMPTY("}\n");
14814
+ PRINT_ON_OWN_LINE("}");
14592
14815
  });
14593
14816
  }
14594
14817
  };
@@ -15019,7 +15242,7 @@ var AstFactory2 = class extends AstFactory {
15019
15242
  type: "tripleCollection",
15020
15243
  subType: "reifiedTriple",
15021
15244
  triples: [this.triple(subject, predicate, object3)],
15022
- identifier: reifier2 ?? this.blankNode(void 0, this.sourceLocationNoMaterialize()),
15245
+ identifier: reifier2 ?? this.termBlank(void 0, this.sourceLocationNoMaterialize()),
15023
15246
  loc
15024
15247
  };
15025
15248
  }
@@ -15094,9 +15317,9 @@ var versionDecl = {
15094
15317
  const identifier = SUBRULE(versionSpecifier);
15095
15318
  return ACTION(() => C.astFactory.contextDefinitionVersion(identifier.val, C.astFactory.sourceLocation(versionToken, identifier)));
15096
15319
  },
15097
- gImpl: ({ PRINT_WORDS }) => (ast, { astFactory: F3 }) => {
15320
+ gImpl: ({ PRINT_ON_OWN_LINE }) => (ast, { astFactory: F3 }) => {
15098
15321
  F3.printFilter(ast, () => {
15099
- PRINT_WORDS("VERSION", `${grammar_exports.stringEscapedLexical(ast.version)}`, "\n");
15322
+ PRINT_ON_OWN_LINE("VERSION ", `${grammar_exports.stringEscapedLexical(ast.version)}`);
15100
15323
  });
15101
15324
  }
15102
15325
  };
@@ -15163,7 +15386,7 @@ var reifier = {
15163
15386
  if (reifier2 === void 0 && !C.parseMode.has("canCreateBlankNodes")) {
15164
15387
  throw new Error("Cannot create blanknodes in current parse mode");
15165
15388
  }
15166
- return C.astFactory.wrap(reifier2 ?? C.astFactory.blankNode(void 0, C.astFactory.sourceLocation()), C.astFactory.sourceLocation(tildeToken, reifier2));
15389
+ return C.astFactory.wrap(reifier2 ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation()), C.astFactory.sourceLocation(tildeToken, reifier2));
15167
15390
  });
15168
15391
  }
15169
15392
  };
@@ -15222,7 +15445,7 @@ function annotationImpl(name, allowPaths) {
15222
15445
  if (!currentReifier && !C.parseMode.has("canCreateBlankNodes")) {
15223
15446
  throw new Error("Cannot create blanknodes in current parse mode");
15224
15447
  }
15225
- currentReifier = currentReifier ?? C.astFactory.blankNode(void 0, C.astFactory.sourceLocation());
15448
+ currentReifier = currentReifier ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation());
15226
15449
  });
15227
15450
  const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, currentReifier);
15228
15451
  ACTION(() => {
@@ -15257,13 +15480,13 @@ function annotationBlockImpl(name, allowPaths) {
15257
15480
  const close = CONSUME(annotationClose);
15258
15481
  return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(arg, res, C.astFactory.sourceLocation(open, close)));
15259
15482
  },
15260
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY }) => (ast, C) => {
15483
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
15261
15484
  const { astFactory: F3, indentInc } = C;
15262
15485
  F3.printFilter(ast, () => {
15263
15486
  PRINT_WORD("{|");
15264
15487
  if (ast.triples.length > 1) {
15265
15488
  C[traqulaIndentation] += indentInc;
15266
- PRINT_WORD("\n");
15489
+ NEW_LINE();
15267
15490
  }
15268
15491
  });
15269
15492
  function printTriple(triple) {
@@ -15273,18 +15496,22 @@ function annotationBlockImpl(name, allowPaths) {
15273
15496
  } else {
15274
15497
  SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
15275
15498
  }
15499
+ F3.printFilter(triple, () => PRINT_WORD(""));
15276
15500
  SUBRULE(graphNodePath2, triple.object);
15277
15501
  });
15278
15502
  }
15279
15503
  const [head2, ...tail] = ast.triples;
15280
15504
  printTriple(head2);
15281
15505
  for (const triple of tail) {
15282
- F3.printFilter(ast, () => PRINT_WORD(";\n"));
15506
+ F3.printFilter(ast, () => {
15507
+ PRINT_WORD(";");
15508
+ NEW_LINE();
15509
+ });
15283
15510
  printTriple(triple);
15284
15511
  }
15285
15512
  F3.printFilter(ast, () => {
15286
15513
  if (ast.triples.length > 1) {
15287
- PRINT_ON_EMPTY("|}\n");
15514
+ PRINT_ON_OWN_LINE("|}");
15288
15515
  } else {
15289
15516
  PRINT_WORD("|}");
15290
15517
  }
@@ -15326,7 +15553,7 @@ var varOrTerm2 = {
15326
15553
  { ALT: () => SUBRULE(grammar_exports.blankNode) },
15327
15554
  { ALT: () => {
15328
15555
  const token = CONSUME(lexer_exports.terminals.nil);
15329
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(token), CommonIRIs.NIL));
15556
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.NIL));
15330
15557
  } },
15331
15558
  { ALT: () => SUBRULE(tripleTerm) }
15332
15559
  ])
@@ -15352,11 +15579,13 @@ var reifiedTriple = {
15352
15579
  F3.printFilter(ast, () => PRINT_WORD("<<"));
15353
15580
  const triple = ast.triples[0];
15354
15581
  SUBRULE(graphNodePath2, triple.subject);
15582
+ F3.printFilter(ast, () => PRINT_WORD(""));
15355
15583
  if (F3.isPathPure(triple.predicate)) {
15356
15584
  SUBRULE(grammar_exports.pathGenerator, triple.predicate, void 0);
15357
15585
  } else {
15358
15586
  SUBRULE(graphNodePath2, triple.predicate);
15359
15587
  }
15588
+ F3.printFilter(ast, () => PRINT_WORD(""));
15360
15589
  SUBRULE(graphNodePath2, triple.object);
15361
15590
  SUBRULE(annotationPath, [F3.wrap(ast.identifier, ast.identifier.loc)]);
15362
15591
  F3.printFilter(ast, () => PRINT_WORD(">>"));
@@ -15392,7 +15621,9 @@ var tripleTerm = {
15392
15621
  gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F3 }) => {
15393
15622
  F3.printFilter(ast, () => PRINT_WORD("<<("));
15394
15623
  SUBRULE(graphNodePath2, ast.subject);
15624
+ F3.printFilter(ast, () => PRINT_WORD(""));
15395
15625
  SUBRULE(graphNodePath2, ast.predicate);
15626
+ F3.printFilter(ast, () => PRINT_WORD(""));
15396
15627
  SUBRULE(graphNodePath2, ast.object);
15397
15628
  F3.printFilter(ast, () => PRINT_WORD(")>>"));
15398
15629
  }
@@ -15422,7 +15653,7 @@ var tripleTermData = {
15422
15653
  { ALT: () => SUBRULE(grammar_exports.iri) },
15423
15654
  { ALT: () => {
15424
15655
  const token = CONSUME(lexer_exports.a);
15425
- return ACTION(() => C.astFactory.namedNode(C.astFactory.sourceLocation(token), CommonIRIs.TYPE));
15656
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), CommonIRIs.TYPE));
15426
15657
  } }
15427
15658
  ]);
15428
15659
  const object3 = SUBRULE(tripleTermDataObject);
@@ -15509,7 +15740,7 @@ var rdfLiteral2 = {
15509
15740
  { ALT: () => {
15510
15741
  const langTag2 = CONSUME(LANG_DIR);
15511
15742
  return ACTION(() => {
15512
- const literal = C.astFactory.literalTerm(C.astFactory.sourceLocation(value, langTag2), value.value, langTag2.image.slice(1).toLowerCase());
15743
+ const literal = C.astFactory.termLiteral(C.astFactory.sourceLocation(value, langTag2), value.value, langTag2.image.slice(1).toLowerCase());
15513
15744
  langTagHasCorrectRange(literal);
15514
15745
  return literal;
15515
15746
  });
@@ -15517,7 +15748,7 @@ var rdfLiteral2 = {
15517
15748
  { ALT: () => {
15518
15749
  CONSUME(lexer_exports.symbols.hathat);
15519
15750
  const iriVal = SUBRULE(grammar_exports.iri);
15520
- return ACTION(() => C.astFactory.literalTerm(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
15751
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
15521
15752
  } }
15522
15753
  ])) ?? value;
15523
15754
  }
@@ -15543,13 +15774,16 @@ var unaryExpression2 = {
15543
15774
  };
15544
15775
  var generateTriplesBlock = {
15545
15776
  name: "triplesBlock",
15546
- gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
15777
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, HANDLE_LOC }) => (ast, { astFactory: F3 }) => {
15547
15778
  for (const [index, triple] of ast.triples.entries()) {
15548
15779
  HANDLE_LOC(triple, () => {
15549
15780
  const nextTriple = ast.triples.at(index);
15550
15781
  if (F3.isTripleCollection(triple)) {
15551
15782
  SUBRULE(graphNodePath2, triple);
15552
- F3.printFilter(triple, () => PRINT_WORD(".\n"));
15783
+ F3.printFilter(triple, () => {
15784
+ PRINT_WORD(".");
15785
+ NEW_LINE();
15786
+ });
15553
15787
  } else {
15554
15788
  SUBRULE(graphNodePath2, triple.subject);
15555
15789
  F3.printFilter(ast, () => PRINT_WORD(""));
@@ -15562,11 +15796,17 @@ var generateTriplesBlock = {
15562
15796
  SUBRULE(graphNodePath2, triple.object);
15563
15797
  SUBRULE(annotationPath, triple.annotations ?? []);
15564
15798
  if (nextTriple === void 0 || F3.isTripleCollection(nextTriple) || !F3.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
15565
- F3.printFilter(ast, () => PRINT_WORD(".\n"));
15799
+ F3.printFilter(ast, () => {
15800
+ PRINT_WORD(".");
15801
+ NEW_LINE();
15802
+ });
15566
15803
  } else if (F3.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
15567
15804
  F3.printFilter(ast, () => PRINT_WORD(","));
15568
15805
  } else {
15569
- F3.printFilter(ast, () => PRINT_WORD(";\n"));
15806
+ F3.printFilter(ast, () => {
15807
+ PRINT_WORD(";");
15808
+ NEW_LINE();
15809
+ });
15570
15810
  }
15571
15811
  }
15572
15812
  });
@@ -15604,8 +15844,9 @@ var sparql12ParserBuilder = ParserBuilder.create(sparql11ParserBuilder).widenCon
15604
15844
  var Parser2 = class {
15605
15845
  parser;
15606
15846
  F = new AstFactory2();
15607
- constructor() {
15847
+ constructor(args = {}) {
15608
15848
  this.parser = sparql12ParserBuilder.build({
15849
+ ...args,
15609
15850
  queryPreProcessor: sparqlCodepointEscape,
15610
15851
  tokenVocabulary: lexer_exports2.sparql12LexerBuilder.tokenVocabulary
15611
15852
  });