@traqula/parser-sparql-1-1 0.0.16 → 0.0.18

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
@@ -9493,7 +9493,7 @@ var DynamicParser = class extends EmbeddedActionsParser {
9493
9493
  constructor(rules5, tokenVocabulary, config = {}) {
9494
9494
  super(tokenVocabulary, {
9495
9495
  // RecoveryEnabled: true,
9496
- maxLookahead: 2,
9496
+ maxLookahead: 1,
9497
9497
  skipValidations: true,
9498
9498
  ...config
9499
9499
  });
@@ -9751,6 +9751,11 @@ ${firstError.message}`);
9751
9751
 
9752
9752
  // ../../packages/core/lib/Transformers.js
9753
9753
  var TransformerType = class {
9754
+ clone(obj) {
9755
+ const newObj = Object.create(Object.getPrototypeOf(obj));
9756
+ Object.defineProperties(newObj, Object.getOwnPropertyDescriptors(obj));
9757
+ return newObj;
9758
+ }
9754
9759
  safeObjectVisit(value, mapper) {
9755
9760
  if (value && typeof value === "object") {
9756
9761
  if (Array.isArray(value)) {
@@ -9760,104 +9765,213 @@ var TransformerType = class {
9760
9765
  }
9761
9766
  return value;
9762
9767
  }
9763
- transformNode(curObject, nodeCallBacks) {
9764
- let continueCheck;
9765
- let transformation;
9766
- const casted = curObject;
9767
- if (casted.type) {
9768
- continueCheck = nodeCallBacks[casted.type]?.continue;
9769
- transformation = nodeCallBacks[casted.type]?.transform;
9770
- }
9771
- let shouldContinue = true;
9772
- if (continueCheck) {
9773
- shouldContinue = continueCheck(curObject);
9774
- }
9775
- if (!shouldContinue) {
9776
- return curObject;
9777
- }
9778
- const copy3 = { ...curObject };
9779
- for (const [key, value] of Object.entries(copy3)) {
9780
- copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNode(obj, nodeCallBacks));
9781
- }
9782
- if (transformation) {
9783
- return transformation(copy3);
9784
- }
9785
- return copy3;
9768
+ /**
9769
+ * Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.
9770
+ * @param startObject object to start iterating from
9771
+ * @param mapper mapper to transform the various objects - argument is a copy of the original
9772
+ * @param preVisitor callback that is evaluated before iterating deeper.
9773
+ * If continues is false, we do not iterate deeper, current object is still mapped. - default: true
9774
+ * If shortcut is true, we do not iterate deeper, nor do we branch out, this mapper will be the last one called.
9775
+ * - Default false
9776
+ */
9777
+ transformObject(startObject, mapper, preVisitor = () => ({})) {
9778
+ let didShortCut = false;
9779
+ const recurse = (curObject) => {
9780
+ const copy3 = this.clone(curObject);
9781
+ const context = preVisitor(copy3);
9782
+ didShortCut = context.shortcut ?? false;
9783
+ const continues = context.continue ?? true;
9784
+ if (continues && !didShortCut) {
9785
+ for (const [key, value] of Object.entries(copy3)) {
9786
+ if (didShortCut) {
9787
+ return copy3;
9788
+ }
9789
+ copy3[key] = this.safeObjectVisit(value, (obj) => recurse(obj));
9790
+ }
9791
+ }
9792
+ return mapper(copy3);
9793
+ };
9794
+ return recurse(startObject);
9786
9795
  }
9787
- visitNode(curObject, nodeCallBacks) {
9788
- let callback;
9789
- const casted = curObject;
9790
- if (casted.type) {
9791
- callback = nodeCallBacks[casted.type];
9792
- }
9793
- let shouldIterate = true;
9794
- if (callback) {
9795
- shouldIterate = callback(curObject);
9796
- }
9797
- if (shouldIterate) {
9798
- for (const value of Object.values(curObject)) {
9799
- this.safeObjectVisit(value, (obj) => this.visitNode(obj, nodeCallBacks));
9796
+ /**
9797
+ * Visitor that visits all objects. Visits deeper objects first.
9798
+ */
9799
+ visitObject(startObject, visitor, preVisitor = () => ({})) {
9800
+ let didShortCut = false;
9801
+ const recurse = (curObject) => {
9802
+ const context = preVisitor(curObject);
9803
+ didShortCut = context.shortcut ?? false;
9804
+ const continues = context.continue ?? true;
9805
+ if (continues && !didShortCut) {
9806
+ for (const value of Object.values(curObject)) {
9807
+ if (didShortCut) {
9808
+ return;
9809
+ }
9810
+ this.safeObjectVisit(value, (obj) => recurse(obj));
9811
+ }
9800
9812
  }
9801
- }
9813
+ visitor(curObject);
9814
+ };
9815
+ recurse(startObject);
9816
+ }
9817
+ transformNode(startObject, nodeCallBacks) {
9818
+ const transformWrapper = (curObject) => {
9819
+ const casted = curObject;
9820
+ if (casted.type) {
9821
+ const ogFunc = nodeCallBacks[casted.type]?.transform;
9822
+ if (ogFunc) {
9823
+ return ogFunc(casted);
9824
+ }
9825
+ }
9826
+ return curObject;
9827
+ };
9828
+ const preTransformWrapper = (curObject) => {
9829
+ const casted = curObject;
9830
+ if (casted.type) {
9831
+ const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9832
+ if (ogFunc) {
9833
+ return ogFunc(casted);
9834
+ }
9835
+ }
9836
+ return {};
9837
+ };
9838
+ return this.transformObject(startObject, transformWrapper, preTransformWrapper);
9839
+ }
9840
+ visitNode(startObject, nodeCallBacks) {
9841
+ const visitWrapper = (curObject) => {
9842
+ const casted = curObject;
9843
+ if (casted.type) {
9844
+ const ogFunc = nodeCallBacks[casted.type]?.visitor;
9845
+ if (ogFunc) {
9846
+ ogFunc(casted);
9847
+ }
9848
+ }
9849
+ };
9850
+ const preVisitWrapper = (curObject) => {
9851
+ const casted = curObject;
9852
+ if (casted.type) {
9853
+ const ogFunc = nodeCallBacks[casted.type]?.preVisitor;
9854
+ if (ogFunc) {
9855
+ return ogFunc(casted);
9856
+ }
9857
+ }
9858
+ return {};
9859
+ };
9860
+ this.visitObject(startObject, visitWrapper, preVisitWrapper);
9861
+ }
9862
+ traverseNodes(currentNode, traverse) {
9863
+ let didShortCut = false;
9864
+ const recurse = (curNode) => {
9865
+ const traverser = traverse[curNode.type];
9866
+ if (traverser) {
9867
+ const { next, shortcut } = traverser(curNode);
9868
+ didShortCut = shortcut ?? false;
9869
+ if (!didShortCut) {
9870
+ for (const node of next ?? []) {
9871
+ if (didShortCut) {
9872
+ return;
9873
+ }
9874
+ recurse(node);
9875
+ }
9876
+ }
9877
+ }
9878
+ };
9879
+ recurse(currentNode);
9802
9880
  }
9803
9881
  };
9804
9882
  var TransformerSubType = class extends TransformerType {
9805
- // Public visitObjects(curObject: object, visitor: (current: object) => void): void {
9806
- // for (const value of Object.values(curObject)) {
9807
- // this.safeObjectVisit(value, obj => this.visitObjects(obj, visitor));
9808
- // }
9809
- // }
9810
- transformNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
9811
- let continueCheck;
9812
- let transformation;
9813
- const casted = curObject;
9814
- if (casted.type && casted.subType) {
9815
- const specific = nodeSpecificCallBacks[casted.type];
9816
- if (specific) {
9817
- continueCheck = specific[casted.subType]?.continue;
9818
- transformation = specific[casted.subType]?.transform;
9819
- }
9820
- }
9821
- let shouldContinue = true;
9822
- if (continueCheck) {
9823
- shouldContinue = continueCheck(curObject);
9824
- }
9825
- if (!shouldContinue) {
9826
- return curObject;
9827
- }
9828
- const copy3 = { ...curObject };
9829
- for (const [key, value] of Object.entries(copy3)) {
9830
- copy3[key] = this.safeObjectVisit(value, (obj) => this.transformNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
9831
- }
9832
- if (transformation) {
9833
- return transformation(copy3);
9834
- }
9835
- return copy3;
9883
+ transformNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
9884
+ const transformWrapper = (curObject) => {
9885
+ let ogTransform;
9886
+ const casted = curObject;
9887
+ if (casted.type && casted.subType) {
9888
+ const specific = nodeSpecificCallBacks[casted.type];
9889
+ if (specific) {
9890
+ ogTransform = specific[casted.subType]?.transform;
9891
+ }
9892
+ if (!ogTransform) {
9893
+ ogTransform = nodeCallBacks[casted.type]?.transform;
9894
+ }
9895
+ }
9896
+ return ogTransform ? ogTransform(casted) : curObject;
9897
+ };
9898
+ const preVisitWrapper = (curObject) => {
9899
+ let ogPreVisit;
9900
+ const casted = curObject;
9901
+ if (casted.type && casted.subType) {
9902
+ const specific = nodeSpecificCallBacks[casted.type];
9903
+ if (specific) {
9904
+ ogPreVisit = specific[casted.subType]?.preVisitor;
9905
+ }
9906
+ if (!ogPreVisit) {
9907
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
9908
+ }
9909
+ }
9910
+ return ogPreVisit ? ogPreVisit(casted) : curObject;
9911
+ };
9912
+ return this.transformObject(startObject, transformWrapper, preVisitWrapper);
9836
9913
  }
9837
9914
  /**
9838
9915
  * When both nodeCallBack and NodeSpecific callBack are matched, will only look at nodeSpecifCallback
9839
9916
  */
9840
- visitNodeSpecific(curObject, nodeCallBacks, nodeSpecificCallBacks = {}) {
9841
- let callback;
9842
- const casted = curObject;
9843
- if (casted.type && casted.subType) {
9844
- const specific = nodeSpecificCallBacks[casted.type];
9845
- if (specific) {
9846
- callback = specific[casted.subType];
9917
+ visitNodeSpecific(startObject, nodeCallBacks, nodeSpecificCallBacks) {
9918
+ const visitWrapper = (curObject) => {
9919
+ let ogTransform;
9920
+ const casted = curObject;
9921
+ if (casted.type && casted.subType) {
9922
+ const specific = nodeSpecificCallBacks[casted.type];
9923
+ if (specific) {
9924
+ ogTransform = specific[casted.subType]?.visitor;
9925
+ }
9926
+ if (!ogTransform) {
9927
+ ogTransform = nodeCallBacks[casted.type]?.visitor;
9928
+ }
9847
9929
  }
9848
- }
9849
- if (!callback && casted.type) {
9850
- callback = nodeCallBacks[curObject.type];
9851
- }
9852
- let shouldIterate = true;
9853
- if (callback) {
9854
- shouldIterate = callback(curObject) ?? true;
9855
- }
9856
- if (shouldIterate) {
9857
- for (const value of Object.values(curObject)) {
9858
- this.safeObjectVisit(value, (obj) => this.visitNodeSpecific(obj, nodeCallBacks, nodeSpecificCallBacks));
9930
+ if (ogTransform) {
9931
+ ogTransform(casted);
9859
9932
  }
9860
- }
9933
+ };
9934
+ const preVisitWrapper = (curObject) => {
9935
+ let ogPreVisit;
9936
+ const casted = curObject;
9937
+ if (casted.type && casted.subType) {
9938
+ const specific = nodeSpecificCallBacks[casted.type];
9939
+ if (specific) {
9940
+ ogPreVisit = specific[casted.subType]?.preVisitor;
9941
+ }
9942
+ if (!ogPreVisit) {
9943
+ ogPreVisit = nodeCallBacks[casted.type]?.preVisitor;
9944
+ }
9945
+ }
9946
+ return ogPreVisit ? ogPreVisit(casted) : curObject;
9947
+ };
9948
+ this.visitObject(startObject, visitWrapper, preVisitWrapper);
9949
+ }
9950
+ traverseSubNodes(currentNode, traverseNode, traverseSubNode) {
9951
+ let didShortCut = false;
9952
+ const recurse = (curNode) => {
9953
+ let traverser;
9954
+ const subObj = traverseSubNode[curNode.type];
9955
+ if (subObj) {
9956
+ traverser = subObj[curNode.subType];
9957
+ }
9958
+ if (!traverser) {
9959
+ traverser = traverseNode[curNode.type];
9960
+ }
9961
+ if (traverser) {
9962
+ const { next, shortcut } = traverser(curNode);
9963
+ didShortCut = shortcut ?? false;
9964
+ if (!didShortCut) {
9965
+ for (const node of next ?? []) {
9966
+ if (didShortCut) {
9967
+ return;
9968
+ }
9969
+ recurse(node);
9970
+ }
9971
+ }
9972
+ }
9973
+ };
9974
+ recurse(currentNode);
9861
9975
  }
9862
9976
  };
9863
9977
 
@@ -10099,8 +10213,9 @@ __export(lexer_exports, {
10099
10213
  construct: () => construct,
10100
10214
  copy: () => copy,
10101
10215
  create: () => create,
10102
- dataClause: () => dataClause,
10103
10216
  deleteClause: () => deleteClause,
10217
+ deleteDataClause: () => deleteDataClause,
10218
+ deleteWhereClause: () => deleteWhereClause,
10104
10219
  describe: () => describe,
10105
10220
  distinct: () => distinct,
10106
10221
  drop: () => drop2,
@@ -10112,6 +10227,7 @@ __export(lexer_exports, {
10112
10227
  having: () => having,
10113
10228
  in_: () => in_,
10114
10229
  insertClause: () => insertClause,
10230
+ insertDataClause: () => insertDataClause,
10115
10231
  limit: () => limit,
10116
10232
  load: () => load,
10117
10233
  loadInto: () => loadInto,
@@ -10410,6 +10526,44 @@ var graph = createToken2({ name: "Graph", pattern: /graph/i, label: "GRAPH" });
10410
10526
  var graphAll = createToken2({ name: "GraphAll", pattern: /all/i, label: "ALL" });
10411
10527
  var allGraphTokens = LexerBuilder.create().add(named, default_, graph, graphAll);
10412
10528
 
10529
+ // ../../packages/rules-sparql-1-1/lib/lexer/lexerPatterns.js
10530
+ var pnCharsBasePattern = /[A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF]/;
10531
+ var pnCharsUPattern = new RegExp(`${pnCharsBasePattern.source}|_`);
10532
+ var varNamePattern = new RegExp(`((${pnCharsUPattern.source})|[0-9])((${pnCharsUPattern.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`);
10533
+ var iriRefPattern = /<([^\u0000-\u0020"<>\\^`{|}])*>/;
10534
+ var pnCharsPattern = new RegExp(`(${pnCharsUPattern.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`);
10535
+ var pnPrefixPattern = new RegExp(`(${pnCharsBasePattern.source})(((${pnCharsPattern.source})|\\.)*(${pnCharsPattern.source}))?`);
10536
+ var pNameNsPattern = new RegExp(`(${pnPrefixPattern.source})?:`);
10537
+ var percentPattern = /%[\dA-Fa-f]{2}/;
10538
+ var pnLocalEscPattern = /\\[!#$%&'()*+,./;=?@\\_~-]/;
10539
+ var plxPattern = new RegExp(`(${percentPattern.source})|(${pnLocalEscPattern.source})`);
10540
+ var pnLocalPattern = new RegExp(`((${pnCharsUPattern.source})|:|[0-9]|(${plxPattern.source}))(((${pnCharsPattern.source})|\\.|:|(${plxPattern.source}))*((${pnCharsPattern.source})|:|(${plxPattern.source})))?`);
10541
+ var pNameLnPattern = new RegExp(`(${pNameNsPattern.source})(${pnLocalPattern.source})`);
10542
+ var blankNodeLabelPattern = new RegExp(`_:((${pnCharsUPattern.source})|[0-9])(((${pnCharsPattern.source})|\\.)*(${pnCharsPattern.source}))?`);
10543
+ var var1Pattern = new RegExp(`\\?(${varNamePattern.source})`);
10544
+ var var2Pattern = new RegExp(`\\$(${varNamePattern.source})`);
10545
+ var langTagPattern = /@[A-Za-z]+(-[\dA-Za-z]+)*/;
10546
+ var integerPattern = /\d+/;
10547
+ var decimalPattern2 = /\d+\.\d+/;
10548
+ var exponentPattern = /[Ee][+-]?\d+/;
10549
+ var doublePattern = new RegExp(`([0-9]+\\.[0-9]*(${exponentPattern.source}))|(\\.[0-9]+(${exponentPattern.source}))|([0-9]+(${exponentPattern.source}))`);
10550
+ var interferePositivePattern = new RegExp(`\\+${integerPattern.source}`);
10551
+ var decimalPositivePattern = new RegExp(`\\+${decimalPattern2.source}`);
10552
+ var doublePositivePattern = new RegExp(`\\+${doublePattern.source}`);
10553
+ var integerNegativePattern = new RegExp(`-${integerPattern.source}`);
10554
+ var decimalNegativePattern = new RegExp(`-${decimalPattern2.source}`);
10555
+ var doubleNegativePattern = new RegExp(`-${doublePattern.source}`);
10556
+ var echarPattern = /\\[\\"'bfnrt]/u;
10557
+ var stringLiteral1Pattern = new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${echarPattern.source}))*'`);
10558
+ var stringLiteral2Pattern = new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${echarPattern.source}))*"`);
10559
+ var stringLiteralLong1Pattern = new RegExp(`'''(('|(''))?([^'\\\\]|(${echarPattern.source})))*'''`);
10560
+ var stringLiteralLong2Pattern = new RegExp(`"""(("|(""))?([^"\\\\]|(${echarPattern.source})))*"""`);
10561
+ var wsPattern = /[\u0009\u000A\u000D ]/;
10562
+ var nilPattern = new RegExp(`\\((${wsPattern.source})*\\)`);
10563
+ var anonPattern = new RegExp(`\\[(${wsPattern.source})*\\]`);
10564
+ var commentPattern = /#[^\n]*\n/;
10565
+ var atLeastOneBlankPattern = new RegExp(`((${wsPattern.source}+)|(${commentPattern.source}))+`);
10566
+
10413
10567
  // ../../packages/rules-sparql-1-1/lib/lexer/symbols.js
10414
10568
  var symbols_exports = {};
10415
10569
  __export(symbols_exports, {
@@ -10498,40 +10652,6 @@ __export(terminals_exports, {
10498
10652
  var2: () => var2,
10499
10653
  ws: () => ws
10500
10654
  });
10501
- var pnCharsBasePattern = /[A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF]/;
10502
- var pnCharsUPattern = new RegExp(`${pnCharsBasePattern.source}|_`);
10503
- var varNamePattern = new RegExp(`((${pnCharsUPattern.source})|[0-9])((${pnCharsUPattern.source})|[0-9]|[\xB7\u0300-\u036F\u203F-\u2040])*`);
10504
- var iriRefPattern = /<([^\u0000-\u0020"<>\\^`{|}])*>/;
10505
- var pnCharsPattern = new RegExp(`(${pnCharsUPattern.source})|[\\-0-9\xB7\u0300-\u036F\u203F-\u2040]`);
10506
- var pnPrefixPattern = new RegExp(`(${pnCharsBasePattern.source})(((${pnCharsPattern.source})|\\.)*(${pnCharsPattern.source}))?`);
10507
- var pNameNsPattern = new RegExp(`(${pnPrefixPattern.source})?:`);
10508
- var percentPattern = /%[\dA-Fa-f]{2}/;
10509
- var pnLocalEscPattern = /\\[!#$%&'()*+,./;=?@\\_~-]/;
10510
- var plxPattern = new RegExp(`(${percentPattern.source})|(${pnLocalEscPattern.source})`);
10511
- var pnLocalPattern = new RegExp(`((${pnCharsUPattern.source})|:|[0-9]|(${plxPattern.source}))(((${pnCharsPattern.source})|\\.|:|(${plxPattern.source}))*((${pnCharsPattern.source})|:|(${plxPattern.source})))?`);
10512
- var pNameLnPattern = new RegExp(`(${pNameNsPattern.source})(${pnLocalPattern.source})`);
10513
- var blankNodeLabelPattern = new RegExp(`_:((${pnCharsUPattern.source})|[0-9])(((${pnCharsPattern.source})|\\.)*(${pnCharsPattern.source}))?`);
10514
- var var1Pattern = new RegExp(`\\?(${varNamePattern.source})`);
10515
- var var2Pattern = new RegExp(`\\$(${varNamePattern.source})`);
10516
- var langTagPattern = /@[A-Za-z]+(-[\dA-Za-z]+)*/;
10517
- var integerPattern = /\d+/;
10518
- var decimalPattern2 = /\d+\.\d+/;
10519
- var exponentPattern = /[Ee][+-]?\d+/;
10520
- var doublePattern = new RegExp(`([0-9]+\\.[0-9]*(${exponentPattern.source}))|(\\.[0-9]+(${exponentPattern.source}))|([0-9]+(${exponentPattern.source}))`);
10521
- var interferePositivePattern = new RegExp(`\\+${integerPattern.source}`);
10522
- var decimalPositivePattern = new RegExp(`\\+${decimalPattern2.source}`);
10523
- var doublePositivePattern = new RegExp(`\\+${doublePattern.source}`);
10524
- var integerNegativePattern = new RegExp(`-${integerPattern.source}`);
10525
- var decimalNegativePattern = new RegExp(`-${decimalPattern2.source}`);
10526
- var doubleNegativePattern = new RegExp(`-${doublePattern.source}`);
10527
- var echarPattern = /\\[\\"'bfnrt]/u;
10528
- var stringLiteral1Pattern = new RegExp(`'(([^\\u0027\\u005C\\u000A\r])|(${echarPattern.source}))*'`);
10529
- var stringLiteral2Pattern = new RegExp(`"(([^\\u0022\\u005C\\u000A\\u000D])|(${echarPattern.source}))*"`);
10530
- var stringLiteralLong1Pattern = new RegExp(`'''(('|(''))?([^'\\\\]|(${echarPattern.source})))*'''`);
10531
- var stringLiteralLong2Pattern = new RegExp(`"""(("|(""))?([^"\\\\]|(${echarPattern.source})))*"""`);
10532
- var wsPattern = /[\u0009\u000A\u000D ]/;
10533
- var nilPattern = new RegExp(`\\((${wsPattern.source})*\\)`);
10534
- var anonPattern = new RegExp(`\\[(${wsPattern.source})*\\]`);
10535
10655
  var iriRef = createToken2({ name: "IriRef", pattern: iriRefPattern });
10536
10656
  var pNameLn = createToken2({ name: "PNameLn", pattern: pNameLnPattern });
10537
10657
  var pNameNs = createToken2({ name: "PNameNs", pattern: pNameNsPattern, longer_alt: [pNameLn] });
@@ -10553,7 +10673,7 @@ var stringLiteral2 = createToken2({ name: "StringLiteral2", pattern: stringLiter
10553
10673
  var stringLiteralLong1 = createToken2({ name: "StringLiteralLong1", pattern: stringLiteralLong1Pattern });
10554
10674
  var stringLiteralLong2 = createToken2({ name: "StringLiteralLong2", pattern: stringLiteralLong2Pattern });
10555
10675
  var ws = createToken2({ name: "Ws", pattern: wsPattern, group: Lexer.SKIPPED });
10556
- var comment = createToken2({ name: "Comment", pattern: /#[^\n]*/, group: Lexer.SKIPPED });
10676
+ var comment = createToken2({ name: "Comment", pattern: commentPattern, group: Lexer.SKIPPED });
10557
10677
  var nil = createToken2({ name: "Nil", pattern: nilPattern });
10558
10678
  var anon = createToken2({ name: "Anon", pattern: anonPattern });
10559
10679
  var allTerminals = LexerBuilder.create().add(iriRef, pNameNs, pNameLn, blankNodeLabel, var1, var2, langTag, double, decimal, integer, integerPositive, decimalPositive, doublePositive, integerNegative, decimalNegative, doubleNegative, stringLiteralLong1, stringLiteralLong2, stringLiteral1, stringLiteral2, ws, comment, nil, anon);
@@ -10590,9 +10710,23 @@ var to = createToken2({ name: "To", pattern: /to/i, label: "TO" });
10590
10710
  var move = createToken2({ name: "Move", pattern: /move/i, label: "MOVE" });
10591
10711
  var copy = createToken2({ name: "Copy", pattern: /copy/i, label: "COPY" });
10592
10712
  var modifyWith = createToken2({ name: "ModifyWith", pattern: /with/i, label: "WITH" });
10713
+ var deleteDataClause = createToken2({
10714
+ name: "DeleteDataClause",
10715
+ pattern: new RegExp(`delete(${atLeastOneBlankPattern.source})data`, "i"),
10716
+ label: "DELETE DATA"
10717
+ });
10718
+ var deleteWhereClause = createToken2({
10719
+ name: "DeleteWhereClause",
10720
+ pattern: new RegExp(`delete(${atLeastOneBlankPattern.source})where`, "i"),
10721
+ label: "DELETE WHERE"
10722
+ });
10593
10723
  var deleteClause = createToken2({ name: "DeleteClause", pattern: /delete/i, label: "DELETE" });
10594
- var insertClause = createToken2({ name: "InsertClause", pattern: /insert/i, label: "INSERT" });
10595
- var dataClause = createToken2({ name: "DataClause", pattern: /data/i, label: "DATA", longer_alt: datatype });
10724
+ var insertDataClause = createToken2({
10725
+ name: "InsertDataClause",
10726
+ pattern: new RegExp(`insert(${atLeastOneBlankPattern.source})data`, "i"),
10727
+ label: "INSERT DATA"
10728
+ });
10729
+ var insertClause = createToken2({ name: "InsertClause", pattern: /insert/i, label: "insert" });
10596
10730
  var usingClause = createToken2({ name: "UsingClause", pattern: /using/i, label: "USING" });
10597
10731
  var optional = createToken2({ name: "Optional", pattern: /optional/i, label: "OPTIONAL" });
10598
10732
  var service = createToken2({ name: "Service", pattern: /service/i, label: "SERVICE" });
@@ -10607,8 +10741,8 @@ var false_ = createToken2({ name: "False", pattern: /false/i, label: "false" });
10607
10741
  var in_ = createToken2({ name: "In", pattern: /in/i, label: "IN" });
10608
10742
  var notIn = createToken2({ name: "NotIn", pattern: /not[\u0020\u0009\u000D\u000A]+in/i, label: "NOT IN" });
10609
10743
  var separator = createToken2({ name: "Separator", pattern: /separator/i, label: "SEPARATOR" });
10610
- var allBaseTokens = LexerBuilder.create().add(baseDecl, prefixDecl, select, distinct, reduced, construct, describe, ask, from, where, having, groupByGroup, by, order, orderAsc, orderDesc, limit, offset, values2, load, silent, loadInto, clear, drop2, create, add, to, move, copy, modifyWith, deleteClause, insertClause, dataClause, usingClause, optional, service, bind, undef, minus, union, filter2, as, a, true_, false_, in_, notIn, separator);
10611
- var sparql11LexerBuilder = LexerBuilder.create(allTerminals).merge(allBaseTokens).merge(allBuiltInCalls).merge(allGraphTokens).merge(allSymbols).moveBefore(datatype, dataClause).moveAfter(avg, a).moveBefore(a, graphAll).moveAfter(groupConcat, groupByGroup);
10744
+ var allBaseTokens = LexerBuilder.create().add(baseDecl, prefixDecl, select, distinct, reduced, construct, describe, ask, from, where, having, groupByGroup, by, order, orderAsc, orderDesc, limit, offset, values2, load, silent, loadInto, clear, drop2, create, add, to, move, copy, modifyWith, deleteWhereClause, deleteDataClause, deleteClause, insertDataClause, insertClause, usingClause, optional, service, bind, undef, minus, union, filter2, as, a, true_, false_, in_, notIn, separator);
10745
+ var sparql11LexerBuilder = LexerBuilder.create(allTerminals).merge(allBaseTokens).merge(allBuiltInCalls).merge(allGraphTokens).merge(allSymbols).moveAfter(avg, a).moveBefore(a, graphAll).moveAfter(groupConcat, groupByGroup);
10612
10746
 
10613
10747
  // ../../packages/rules-sparql-1-1/lib/factoryMixins/ContextFactory.js
10614
10748
  var nodeType = "contextDef";
@@ -11371,12 +11505,12 @@ var CommonIRIs;
11371
11505
  CommonIRIs2["NIL"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
11372
11506
  CommonIRIs2["TYPE"] = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
11373
11507
  })(CommonIRIs || (CommonIRIs = {}));
11374
- var TransformerSparql11 = class extends TransformerSubType {
11508
+ var AstTransformer = class extends TransformerSubType {
11375
11509
  };
11376
11510
 
11377
11511
  // ../../packages/rules-sparql-1-1/lib/validation/validators.js
11378
11512
  var F = new AstFactory();
11379
- var transformer = new TransformerSparql11();
11513
+ var transformer = new AstTransformer();
11380
11514
  function getAggregatesOfExpression(expression2) {
11381
11515
  if (F.isExpressionAggregate(expression2)) {
11382
11516
  return [expression2];
@@ -11455,77 +11589,69 @@ function queryIsGood(query2) {
11455
11589
  }
11456
11590
  }
11457
11591
  }
11592
+ function notUndefined(some2) {
11593
+ return some2 !== void 0;
11594
+ }
11458
11595
  function findPatternBoundedVars(iter, boundedVars) {
11459
- if (F.isQuery(iter) || F.isUpdate(iter)) {
11460
- if (F.isQuerySelect(iter) || F.isQueryDescribe(iter)) {
11461
- if (iter.where && iter.variables.some((x) => F.isWildcard(x))) {
11462
- findPatternBoundedVars(iter.where, boundedVars);
11463
- } else {
11464
- for (const v of iter.variables) {
11465
- findPatternBoundedVars(v, boundedVars);
11466
- }
11467
- }
11468
- if (iter.solutionModifiers.group) {
11469
- const grouping = iter.solutionModifiers.group;
11470
- for (const g of grouping.groupings) {
11471
- if ("variable" in g) {
11472
- findPatternBoundedVars(g.variable, boundedVars);
11473
- }
11474
- }
11475
- }
11476
- if (iter.values?.values && iter.values.values.length > 0) {
11477
- const values3 = iter.values.values;
11478
- for (const v of Object.keys(values3[0])) {
11596
+ transformer.traverseSubNodes(iter, {
11597
+ query: (op) => ({ next: [
11598
+ op.solutionModifiers.group
11599
+ ].filter(notUndefined) }),
11600
+ triple: (op) => ({ next: [op.subject, op.predicate, op.object] }),
11601
+ path: (op) => ({ next: op.items }),
11602
+ tripleCollection: (op) => ({ next: [op.identifier, ...op.triples] })
11603
+ }, {
11604
+ query: {
11605
+ select: (op) => ({ next: [
11606
+ ...op.variables.some((x) => F.isWildcard(x)) ? [op.where] : op.variables,
11607
+ op.solutionModifiers.group,
11608
+ op.values
11609
+ ].filter(notUndefined) }),
11610
+ describe: (op) => ({ next: [
11611
+ ...op.variables.some((x) => F.isWildcard(x)) ? [op.where] : op.variables,
11612
+ op.solutionModifiers.group,
11613
+ op.values
11614
+ ].filter(notUndefined) })
11615
+ },
11616
+ solutionModifier: {
11617
+ group: (op) => ({
11618
+ next: op.groupings.filter((g) => "variable" in g).map((x) => x.variable)
11619
+ }),
11620
+ having: (op) => ({ next: op.having }),
11621
+ order: (op) => ({ next: op.orderDefs.map((x) => x.expression) })
11622
+ },
11623
+ pattern: {
11624
+ values: (op) => {
11625
+ for (const v of Object.keys(op.values.at(0) ?? {})) {
11479
11626
  boundedVars.add(v);
11480
11627
  }
11628
+ return {};
11629
+ },
11630
+ bgp: (op) => ({ next: op.triples }),
11631
+ group: (op) => ({ next: op.patterns }),
11632
+ union: (op) => ({ next: op.patterns }),
11633
+ optional: (op) => ({ next: op.patterns }),
11634
+ service: (op) => ({ next: [op.name, ...op.patterns] }),
11635
+ bind: (op) => ({ next: [op.variable] }),
11636
+ graph: (op) => ({ next: [op.name, ...op.patterns] }),
11637
+ minus: (op) => ({ next: op.patterns.slice(0, 1) })
11638
+ },
11639
+ term: {
11640
+ variable: (op) => {
11641
+ boundedVars.add(op.value);
11642
+ return {};
11481
11643
  }
11482
11644
  }
11483
- } else if (F.isTerm(iter)) {
11484
- if (F.isTermVariable(iter)) {
11485
- boundedVars.add(iter.value);
11486
- }
11487
- } else if (F.isTriple(iter)) {
11488
- findPatternBoundedVars(iter.subject, boundedVars);
11489
- findPatternBoundedVars(iter.predicate, boundedVars);
11490
- findPatternBoundedVars(iter.object, boundedVars);
11491
- } else if (F.isPath(iter)) {
11492
- if (!F.isTerm(iter)) {
11493
- for (const item of iter.items) {
11494
- findPatternBoundedVars(item, boundedVars);
11495
- }
11496
- }
11497
- } else if (F.isTripleCollection(iter) || F.isPatternBgp(iter)) {
11498
- for (const triple of iter.triples) {
11499
- findPatternBoundedVars(triple, boundedVars);
11500
- }
11501
- } else if (F.isPatternGroup(iter) || F.isPatternUnion(iter) || F.isPatternOptional(iter) || F.isPatternService(iter)) {
11502
- for (const pattern of iter.patterns) {
11503
- findPatternBoundedVars(pattern, boundedVars);
11504
- }
11505
- if (F.isPatternService(iter)) {
11506
- findPatternBoundedVars(iter.name, boundedVars);
11507
- }
11508
- } else if (F.isPatternBind(iter)) {
11509
- findPatternBoundedVars(iter.variable, boundedVars);
11510
- } else if (F.isPatternValues(iter)) {
11511
- for (const variable of Object.keys(iter.values.at(0) ?? {})) {
11512
- boundedVars.add(variable);
11513
- }
11514
- } else if (F.isPatternGraph(iter)) {
11515
- findPatternBoundedVars(iter.name, boundedVars);
11516
- for (const pattern of iter.patterns) {
11517
- findPatternBoundedVars(pattern, boundedVars);
11518
- }
11519
- }
11645
+ });
11520
11646
  }
11521
11647
  function checkNote13(patterns) {
11522
11648
  for (const [index, pattern] of patterns.entries()) {
11523
11649
  if (F.isPatternBind(pattern) && index > 0 && F.isPatternBgp(patterns[index - 1])) {
11524
11650
  const bgp = patterns[index - 1];
11525
11651
  const variables = [];
11526
- transformer.visitNodeSpecific(bgp, {}, { term: { variable: (var_2) => {
11652
+ transformer.visitNodeSpecific(bgp, {}, { term: { variable: { visitor: (var_2) => {
11527
11653
  variables.push(var_2);
11528
- } } });
11654
+ } } } });
11529
11655
  if (variables.some((var_2) => var_2.value === pattern.variable.value)) {
11530
11656
  throw new Error(`Variable used to bind is already bound (?${pattern.variable.value})`);
11531
11657
  }
@@ -11551,12 +11677,12 @@ function updateNoReuseBlankNodeLabels(updateQuery) {
11551
11677
  const operation = update2.operation;
11552
11678
  if (operation.subType === "insertdata") {
11553
11679
  const blankNodesHere = /* @__PURE__ */ new Set();
11554
- transformer.visitNodeSpecific(operation, {}, { term: { blankNode: (blankNode2) => {
11680
+ transformer.visitNodeSpecific(operation, {}, { term: { blankNode: { visitor: (blankNode2) => {
11555
11681
  blankNodesHere.add(blankNode2.label);
11556
11682
  if (blankLabelsUsedInInsertData.has(blankNode2.label)) {
11557
11683
  throw new Error("Detected reuse blank node across different INSERT DATA clauses");
11558
11684
  }
11559
- } } });
11685
+ } } } });
11560
11686
  for (const blankNode2 of blankNodesHere) {
11561
11687
  blankLabelsUsedInInsertData.add(blankNode2);
11562
11688
  }
@@ -14243,12 +14369,11 @@ var quadData = {
14243
14369
  return ACTION(() => C.astFactory.wrap(val.val, C.astFactory.sourceLocation(open, close)));
14244
14370
  }
14245
14371
  };
14246
- function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14372
+ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
14247
14373
  return {
14248
14374
  name,
14249
14375
  impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
14250
14376
  const insDelToken = CONSUME(cons1);
14251
- CONSUME(cons2);
14252
14377
  let couldCreateBlankNodes = true;
14253
14378
  if (name !== "insertData") {
14254
14379
  couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
@@ -14280,9 +14405,9 @@ function insertDeleteDelWhere(name, subType, cons1, cons2, dataRule) {
14280
14405
  }
14281
14406
  };
14282
14407
  }
14283
- var insertData = insertDeleteDelWhere("insertData", "insertdata", insertClause, dataClause, quadData);
14284
- var deleteData = insertDeleteDelWhere("deleteData", "deletedata", deleteClause, dataClause, quadData);
14285
- var deleteWhere = insertDeleteDelWhere("deleteWhere", "deletewhere", deleteClause, where, quadPattern);
14408
+ var insertData = insertDeleteDelWhere("insertData", "insertdata", insertDataClause, quadData);
14409
+ var deleteData = insertDeleteDelWhere("deleteData", "deletedata", deleteDataClause, quadData);
14410
+ var deleteWhere = insertDeleteDelWhere("deleteWhere", "deletewhere", deleteWhereClause, quadPattern);
14286
14411
  var modify = {
14287
14412
  name: "modify",
14288
14413
  impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => {