@traqula/rules-sparql-1-1 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/dist/cjs/lib/MinimalSparqlParser.js +64 -0
  2. package/dist/cjs/lib/Sparql11types.js +16 -0
  3. package/dist/cjs/lib/astFactory.js +121 -0
  4. package/dist/cjs/lib/expressionHelpers.js +215 -0
  5. package/dist/cjs/lib/factoryMixins/ContextFactory.js +55 -0
  6. package/dist/cjs/lib/factoryMixins/ExpressionFactory.js +105 -0
  7. package/dist/cjs/lib/factoryMixins/GraphRefFactory.js +76 -0
  8. package/dist/cjs/lib/factoryMixins/PathFactory.js +90 -0
  9. package/dist/cjs/lib/factoryMixins/Patternfactory.js +123 -0
  10. package/dist/cjs/lib/factoryMixins/QueryFactory.js +68 -0
  11. package/dist/cjs/lib/factoryMixins/SolutionModifiersFactory.js +80 -0
  12. package/dist/cjs/lib/factoryMixins/TermFactory.js +105 -0
  13. package/dist/cjs/lib/factoryMixins/UpdateOperationFactory.js +150 -0
  14. package/dist/cjs/lib/factoryMixins/mixins.js +43 -0
  15. package/dist/cjs/lib/grammar/builtIn.js +385 -0
  16. package/dist/cjs/lib/grammar/dataSetClause.js +118 -0
  17. package/dist/cjs/lib/grammar/expression.js +384 -0
  18. package/dist/cjs/lib/grammar/general.js +168 -0
  19. package/dist/cjs/lib/grammar/index.js +115 -0
  20. package/dist/cjs/lib/grammar/literals.js +282 -0
  21. package/dist/cjs/lib/grammar/propertyPaths.js +206 -0
  22. package/dist/cjs/lib/grammar/queryUnit.js +390 -0
  23. package/dist/cjs/lib/grammar/solutionModifier.js +280 -0
  24. package/dist/cjs/lib/grammar/tripleBlock.js +384 -0
  25. package/dist/cjs/lib/grammar/updateUnit.js +546 -0
  26. package/dist/cjs/lib/grammar/whereClause.js +483 -0
  27. package/dist/cjs/lib/index.js +56 -0
  28. package/dist/cjs/lib/lexer/BuiltInCalls.js +337 -0
  29. package/dist/cjs/lib/lexer/graph.js +41 -0
  30. package/dist/cjs/lib/lexer/index.js +50 -0
  31. package/dist/cjs/lib/lexer/lexer.js +199 -0
  32. package/dist/cjs/lib/lexer/lexerPatterns.js +133 -0
  33. package/dist/cjs/lib/lexer/symbols.js +107 -0
  34. package/dist/cjs/lib/lexer/terminals.js +103 -0
  35. package/dist/cjs/lib/sparql11HelperTypes.js +16 -0
  36. package/dist/cjs/lib/utils.js +64 -0
  37. package/dist/cjs/lib/validation/validators.js +214 -0
  38. package/dist/cjs/package.json +1 -0
  39. package/dist/esm/lib/MinimalSparqlParser.js.map +1 -0
  40. package/dist/esm/lib/Sparql11types.js.map +1 -0
  41. package/dist/esm/lib/astFactory.js.map +1 -0
  42. package/{lib → dist/esm/lib}/expressionHelpers.d.ts +1 -1
  43. package/dist/esm/lib/expressionHelpers.js.map +1 -0
  44. package/dist/esm/lib/factoryMixins/ContextFactory.js.map +1 -0
  45. package/dist/esm/lib/factoryMixins/ExpressionFactory.js.map +1 -0
  46. package/dist/esm/lib/factoryMixins/GraphRefFactory.js.map +1 -0
  47. package/dist/esm/lib/factoryMixins/PathFactory.js.map +1 -0
  48. package/dist/esm/lib/factoryMixins/Patternfactory.js.map +1 -0
  49. package/dist/esm/lib/factoryMixins/QueryFactory.js.map +1 -0
  50. package/dist/esm/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -0
  51. package/dist/esm/lib/factoryMixins/TermFactory.js.map +1 -0
  52. package/dist/esm/lib/factoryMixins/UpdateOperationFactory.js.map +1 -0
  53. package/dist/esm/lib/factoryMixins/mixins.js.map +1 -0
  54. package/{lib → dist/esm/lib}/grammar/builtIn.d.ts +1 -1
  55. package/dist/esm/lib/grammar/builtIn.js.map +1 -0
  56. package/{lib → dist/esm/lib}/grammar/dataSetClause.d.ts +1 -1
  57. package/dist/esm/lib/grammar/dataSetClause.js.map +1 -0
  58. package/dist/esm/lib/grammar/expression.js.map +1 -0
  59. package/dist/esm/lib/grammar/general.js.map +1 -0
  60. package/dist/esm/lib/grammar/index.js.map +1 -0
  61. package/dist/esm/lib/grammar/literals.js.map +1 -0
  62. package/{lib → dist/esm/lib}/grammar/propertyPaths.d.ts +3 -3
  63. package/dist/esm/lib/grammar/propertyPaths.js.map +1 -0
  64. package/dist/esm/lib/grammar/queryUnit.js.map +1 -0
  65. package/dist/esm/lib/grammar/solutionModifier.js.map +1 -0
  66. package/{lib → dist/esm/lib}/grammar/tripleBlock.d.ts +4 -4
  67. package/dist/esm/lib/grammar/tripleBlock.js.map +1 -0
  68. package/dist/esm/lib/grammar/updateUnit.js.map +1 -0
  69. package/dist/esm/lib/grammar/whereClause.js.map +1 -0
  70. package/dist/esm/lib/index.js.map +1 -0
  71. package/{lib → dist/esm/lib}/lexer/BuiltInCalls.d.ts +1 -1
  72. package/dist/esm/lib/lexer/BuiltInCalls.js.map +1 -0
  73. package/{lib → dist/esm/lib}/lexer/graph.d.ts +1 -1
  74. package/dist/esm/lib/lexer/graph.js.map +1 -0
  75. package/dist/esm/lib/lexer/index.js.map +1 -0
  76. package/{lib → dist/esm/lib}/lexer/lexer.d.ts +2 -2
  77. package/dist/esm/lib/lexer/lexer.js.map +1 -0
  78. package/dist/esm/lib/lexer/lexerPatterns.js.map +1 -0
  79. package/{lib → dist/esm/lib}/lexer/symbols.d.ts +1 -1
  80. package/dist/esm/lib/lexer/symbols.js.map +1 -0
  81. package/{lib → dist/esm/lib}/lexer/terminals.d.ts +1 -1
  82. package/{lib → dist/esm/lib}/lexer/terminals.js +1 -1
  83. package/dist/esm/lib/lexer/terminals.js.map +1 -0
  84. package/dist/esm/lib/sparql11HelperTypes.js.map +1 -0
  85. package/dist/esm/lib/utils.js.map +1 -0
  86. package/dist/esm/lib/validation/validators.js.map +1 -0
  87. package/package.json +14 -18
  88. package/lib/MinimalSparqlParser.js.map +0 -1
  89. package/lib/Sparql11types.js.map +0 -1
  90. package/lib/astFactory.js.map +0 -1
  91. package/lib/expressionHelpers.js.map +0 -1
  92. package/lib/factoryMixins/ContextFactory.js.map +0 -1
  93. package/lib/factoryMixins/ExpressionFactory.js.map +0 -1
  94. package/lib/factoryMixins/GraphRefFactory.js.map +0 -1
  95. package/lib/factoryMixins/PathFactory.js.map +0 -1
  96. package/lib/factoryMixins/Patternfactory.js.map +0 -1
  97. package/lib/factoryMixins/QueryFactory.js.map +0 -1
  98. package/lib/factoryMixins/SolutionModifiersFactory.js.map +0 -1
  99. package/lib/factoryMixins/TermFactory.js.map +0 -1
  100. package/lib/factoryMixins/UpdateOperationFactory.js.map +0 -1
  101. package/lib/factoryMixins/mixins.js.map +0 -1
  102. package/lib/grammar/builtIn.js.map +0 -1
  103. package/lib/grammar/dataSetClause.js.map +0 -1
  104. package/lib/grammar/expression.js.map +0 -1
  105. package/lib/grammar/general.js.map +0 -1
  106. package/lib/grammar/index.js.map +0 -1
  107. package/lib/grammar/literals.js.map +0 -1
  108. package/lib/grammar/propertyPaths.js.map +0 -1
  109. package/lib/grammar/queryUnit.js.map +0 -1
  110. package/lib/grammar/solutionModifier.js.map +0 -1
  111. package/lib/grammar/tripleBlock.js.map +0 -1
  112. package/lib/grammar/updateUnit.js.map +0 -1
  113. package/lib/grammar/whereClause.js.map +0 -1
  114. package/lib/index.cjs +0 -14673
  115. package/lib/index.js.map +0 -1
  116. package/lib/lexer/BuiltInCalls.js.map +0 -1
  117. package/lib/lexer/graph.js.map +0 -1
  118. package/lib/lexer/index.js.map +0 -1
  119. package/lib/lexer/lexer.js.map +0 -1
  120. package/lib/lexer/lexerPatterns.js.map +0 -1
  121. package/lib/lexer/symbols.js.map +0 -1
  122. package/lib/lexer/terminals.js.map +0 -1
  123. package/lib/sparql11HelperTypes.js.map +0 -1
  124. package/lib/utils.js.map +0 -1
  125. package/lib/validation/validators.js.map +0 -1
  126. /package/{lib → dist/esm/lib}/MinimalSparqlParser.d.ts +0 -0
  127. /package/{lib → dist/esm/lib}/MinimalSparqlParser.js +0 -0
  128. /package/{lib → dist/esm/lib}/Sparql11types.d.ts +0 -0
  129. /package/{lib → dist/esm/lib}/Sparql11types.js +0 -0
  130. /package/{lib → dist/esm/lib}/astFactory.d.ts +0 -0
  131. /package/{lib → dist/esm/lib}/astFactory.js +0 -0
  132. /package/{lib → dist/esm/lib}/expressionHelpers.js +0 -0
  133. /package/{lib → dist/esm/lib}/factoryMixins/ContextFactory.d.ts +0 -0
  134. /package/{lib → dist/esm/lib}/factoryMixins/ContextFactory.js +0 -0
  135. /package/{lib → dist/esm/lib}/factoryMixins/ExpressionFactory.d.ts +0 -0
  136. /package/{lib → dist/esm/lib}/factoryMixins/ExpressionFactory.js +0 -0
  137. /package/{lib → dist/esm/lib}/factoryMixins/GraphRefFactory.d.ts +0 -0
  138. /package/{lib → dist/esm/lib}/factoryMixins/GraphRefFactory.js +0 -0
  139. /package/{lib → dist/esm/lib}/factoryMixins/PathFactory.d.ts +0 -0
  140. /package/{lib → dist/esm/lib}/factoryMixins/PathFactory.js +0 -0
  141. /package/{lib → dist/esm/lib}/factoryMixins/Patternfactory.d.ts +0 -0
  142. /package/{lib → dist/esm/lib}/factoryMixins/Patternfactory.js +0 -0
  143. /package/{lib → dist/esm/lib}/factoryMixins/QueryFactory.d.ts +0 -0
  144. /package/{lib → dist/esm/lib}/factoryMixins/QueryFactory.js +0 -0
  145. /package/{lib → dist/esm/lib}/factoryMixins/SolutionModifiersFactory.d.ts +0 -0
  146. /package/{lib → dist/esm/lib}/factoryMixins/SolutionModifiersFactory.js +0 -0
  147. /package/{lib → dist/esm/lib}/factoryMixins/TermFactory.d.ts +0 -0
  148. /package/{lib → dist/esm/lib}/factoryMixins/TermFactory.js +0 -0
  149. /package/{lib → dist/esm/lib}/factoryMixins/UpdateOperationFactory.d.ts +0 -0
  150. /package/{lib → dist/esm/lib}/factoryMixins/UpdateOperationFactory.js +0 -0
  151. /package/{lib → dist/esm/lib}/factoryMixins/mixins.d.ts +0 -0
  152. /package/{lib → dist/esm/lib}/factoryMixins/mixins.js +0 -0
  153. /package/{lib → dist/esm/lib}/grammar/builtIn.js +0 -0
  154. /package/{lib → dist/esm/lib}/grammar/dataSetClause.js +0 -0
  155. /package/{lib → dist/esm/lib}/grammar/expression.d.ts +0 -0
  156. /package/{lib → dist/esm/lib}/grammar/expression.js +0 -0
  157. /package/{lib → dist/esm/lib}/grammar/general.d.ts +0 -0
  158. /package/{lib → dist/esm/lib}/grammar/general.js +0 -0
  159. /package/{lib → dist/esm/lib}/grammar/index.d.ts +0 -0
  160. /package/{lib → dist/esm/lib}/grammar/index.js +0 -0
  161. /package/{lib → dist/esm/lib}/grammar/literals.d.ts +0 -0
  162. /package/{lib → dist/esm/lib}/grammar/literals.js +0 -0
  163. /package/{lib → dist/esm/lib}/grammar/propertyPaths.js +0 -0
  164. /package/{lib → dist/esm/lib}/grammar/queryUnit.d.ts +0 -0
  165. /package/{lib → dist/esm/lib}/grammar/queryUnit.js +0 -0
  166. /package/{lib → dist/esm/lib}/grammar/solutionModifier.d.ts +0 -0
  167. /package/{lib → dist/esm/lib}/grammar/solutionModifier.js +0 -0
  168. /package/{lib → dist/esm/lib}/grammar/tripleBlock.js +0 -0
  169. /package/{lib → dist/esm/lib}/grammar/updateUnit.d.ts +0 -0
  170. /package/{lib → dist/esm/lib}/grammar/updateUnit.js +0 -0
  171. /package/{lib → dist/esm/lib}/grammar/whereClause.d.ts +0 -0
  172. /package/{lib → dist/esm/lib}/grammar/whereClause.js +0 -0
  173. /package/{lib → dist/esm/lib}/index.d.ts +0 -0
  174. /package/{lib → dist/esm/lib}/index.js +0 -0
  175. /package/{lib → dist/esm/lib}/lexer/BuiltInCalls.js +0 -0
  176. /package/{lib → dist/esm/lib}/lexer/graph.js +0 -0
  177. /package/{lib → dist/esm/lib}/lexer/index.d.ts +0 -0
  178. /package/{lib → dist/esm/lib}/lexer/index.js +0 -0
  179. /package/{lib → dist/esm/lib}/lexer/lexer.js +0 -0
  180. /package/{lib → dist/esm/lib}/lexer/lexerPatterns.d.ts +0 -0
  181. /package/{lib → dist/esm/lib}/lexer/lexerPatterns.js +0 -0
  182. /package/{lib → dist/esm/lib}/lexer/symbols.js +0 -0
  183. /package/{lib → dist/esm/lib}/sparql11HelperTypes.d.ts +0 -0
  184. /package/{lib → dist/esm/lib}/sparql11HelperTypes.js +0 -0
  185. /package/{lib → dist/esm/lib}/utils.d.ts +0 -0
  186. /package/{lib → dist/esm/lib}/utils.js +0 -0
  187. /package/{lib → dist/esm/lib}/validation/validators.d.ts +0 -0
  188. /package/{lib → dist/esm/lib}/validation/validators.js +0 -0
@@ -0,0 +1,546 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var updateUnit_exports = {};
30
+ __export(updateUnit_exports, {
31
+ add: () => add,
32
+ clear: () => clear,
33
+ copy: () => copy,
34
+ create: () => create,
35
+ deleteClause: () => deleteClause,
36
+ deleteData: () => deleteData,
37
+ deleteWhere: () => deleteWhere,
38
+ drop: () => drop,
39
+ graphOrDefault: () => graphOrDefault,
40
+ graphRef: () => graphRef,
41
+ graphRefAll: () => graphRefAll,
42
+ insertClause: () => insertClause,
43
+ insertData: () => insertData,
44
+ load: () => load,
45
+ modify: () => modify,
46
+ move: () => move,
47
+ quadData: () => quadData,
48
+ quadPattern: () => quadPattern,
49
+ quads: () => quads,
50
+ quadsNotTriples: () => quadsNotTriples,
51
+ update: () => update,
52
+ update1: () => update1,
53
+ updateUnit: () => updateUnit
54
+ });
55
+ module.exports = __toCommonJS(updateUnit_exports);
56
+ var import_core = require("@traqula/core");
57
+ var l = __toESM(require("../lexer/index.js"), 1);
58
+ var import_validators = require("../validation/validators.js");
59
+ var import_dataSetClause = require("./dataSetClause.js");
60
+ var import_general = require("./general.js");
61
+ var import_literals = require("./literals.js");
62
+ var import_tripleBlock = require("./tripleBlock.js");
63
+ var import_whereClause = require("./whereClause.js");
64
+ const updateUnit = {
65
+ name: "updateUnit",
66
+ impl: ({ SUBRULE }) => () => SUBRULE(update)
67
+ };
68
+ const update = {
69
+ name: "update",
70
+ impl: ({ ACTION, SUBRULE, SUBRULE1, SUBRULE2, CONSUME, OPTION1, MANY }) => (C) => {
71
+ const updates = [];
72
+ const prologueValues = SUBRULE1(import_general.prologue);
73
+ updates.push({ context: prologueValues });
74
+ let parsedSemi = true;
75
+ MANY({
76
+ GATE: () => parsedSemi,
77
+ DEF: () => {
78
+ parsedSemi = false;
79
+ updates.at(-1).operation = SUBRULE(update1);
80
+ OPTION1(() => {
81
+ CONSUME(l.symbols.semi);
82
+ parsedSemi = true;
83
+ const innerPrologue = SUBRULE2(import_general.prologue);
84
+ updates.push({ context: innerPrologue });
85
+ });
86
+ }
87
+ });
88
+ return ACTION(() => {
89
+ const update2 = {
90
+ type: "update",
91
+ updates,
92
+ loc: C.astFactory.sourceLocation(...updates[0].context, updates[0].operation, ...updates.at(-1).context, updates.at(-1)?.operation)
93
+ };
94
+ (0, import_validators.updateNoReuseBlankNodeLabels)(update2);
95
+ return update2;
96
+ });
97
+ },
98
+ gImpl: ({ SUBRULE, PRINT, NEW_LINE }) => (ast, { astFactory: F }) => {
99
+ const [head, ...tail] = ast.updates;
100
+ if (head) {
101
+ SUBRULE(import_general.prologue, head.context);
102
+ if (head.operation) {
103
+ SUBRULE(update1, head.operation);
104
+ }
105
+ }
106
+ for (const update2 of tail) {
107
+ F.printFilter(ast, () => {
108
+ PRINT(";");
109
+ NEW_LINE();
110
+ });
111
+ SUBRULE(import_general.prologue, update2.context);
112
+ if (update2.operation) {
113
+ SUBRULE(update1, update2.operation);
114
+ }
115
+ }
116
+ }
117
+ };
118
+ const update1 = {
119
+ name: "update1",
120
+ impl: ({ SUBRULE, OR }) => () => OR([
121
+ { ALT: () => SUBRULE(load) },
122
+ { ALT: () => SUBRULE(clear) },
123
+ { ALT: () => SUBRULE(drop) },
124
+ { ALT: () => SUBRULE(add) },
125
+ { ALT: () => SUBRULE(move) },
126
+ { ALT: () => SUBRULE(copy) },
127
+ { ALT: () => SUBRULE(create) },
128
+ { ALT: () => SUBRULE(insertData) },
129
+ { ALT: () => SUBRULE(deleteData) },
130
+ { ALT: () => SUBRULE(deleteWhere) },
131
+ { ALT: () => SUBRULE(modify) }
132
+ ]),
133
+ gImpl: ({ SUBRULE }) => (ast) => {
134
+ switch (ast.subType) {
135
+ case "load":
136
+ SUBRULE(load, ast);
137
+ break;
138
+ case "clear":
139
+ SUBRULE(clear, ast);
140
+ break;
141
+ case "drop":
142
+ SUBRULE(drop, ast);
143
+ break;
144
+ case "add":
145
+ SUBRULE(add, ast);
146
+ break;
147
+ case "move":
148
+ SUBRULE(move, ast);
149
+ break;
150
+ case "copy":
151
+ SUBRULE(copy, ast);
152
+ break;
153
+ case "create":
154
+ SUBRULE(create, ast);
155
+ break;
156
+ case "insertdata":
157
+ SUBRULE(insertData, ast);
158
+ break;
159
+ case "deletedata":
160
+ SUBRULE(deleteData, ast);
161
+ break;
162
+ case "deletewhere":
163
+ SUBRULE(deleteWhere, ast);
164
+ break;
165
+ case "modify":
166
+ SUBRULE(modify, ast);
167
+ break;
168
+ }
169
+ }
170
+ };
171
+ const load = {
172
+ name: "load",
173
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION1, OPTION2 }) => (C) => {
174
+ const loadToken = CONSUME(l.load);
175
+ const silent = OPTION1(() => CONSUME(l.silent));
176
+ const source = SUBRULE1(import_literals.iri);
177
+ const destination = OPTION2(() => {
178
+ CONSUME(l.loadInto);
179
+ return SUBRULE1(graphRef);
180
+ });
181
+ return ACTION(() => C.astFactory.updateOperationLoad(C.astFactory.sourceLocation(loadToken, source, destination), source, Boolean(silent), destination));
182
+ },
183
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F }) => {
184
+ F.printFilter(ast, () => {
185
+ PRINT_ON_EMPTY("LOAD ");
186
+ if (ast.silent) {
187
+ PRINT_WORD("SILENT");
188
+ }
189
+ });
190
+ SUBRULE(import_literals.iri, ast.source);
191
+ if (ast.destination) {
192
+ F.printFilter(ast, () => PRINT_WORD("INTO"));
193
+ SUBRULE(graphRefAll, ast.destination);
194
+ }
195
+ }
196
+ };
197
+ function clearOrDrop(operation) {
198
+ return {
199
+ name: (0, import_core.unCapitalize)(operation.name),
200
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
201
+ const opToken = CONSUME(operation);
202
+ const silent = OPTION(() => CONSUME(l.silent));
203
+ const destination = SUBRULE1(graphRefAll);
204
+ return ACTION(() => C.astFactory.updateOperationClearDrop((0, import_core.unCapitalize)(operation.name), Boolean(silent), destination, C.astFactory.sourceLocation(opToken, destination)));
205
+ },
206
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F }) => {
207
+ F.printFilter(ast, () => {
208
+ PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
209
+ if (ast.silent) {
210
+ PRINT_WORD("SILENT");
211
+ }
212
+ });
213
+ SUBRULE(graphRefAll, ast.destination);
214
+ }
215
+ };
216
+ }
217
+ const clear = clearOrDrop(l.clear);
218
+ const drop = clearOrDrop(l.drop);
219
+ const create = {
220
+ name: "create",
221
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
222
+ const createToken = CONSUME(l.create);
223
+ const silent = OPTION(() => CONSUME(l.silent));
224
+ const destination = SUBRULE1(graphRef);
225
+ return ACTION(() => C.astFactory.updateOperationCreate(destination, Boolean(silent), C.astFactory.sourceLocation(createToken, destination)));
226
+ },
227
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F }) => {
228
+ F.printFilter(ast, () => {
229
+ PRINT_ON_EMPTY("CREATE ");
230
+ if (ast.silent) {
231
+ PRINT_WORD("SILENT");
232
+ }
233
+ });
234
+ SUBRULE(graphRefAll, ast.destination);
235
+ }
236
+ };
237
+ function copyMoveAddOperation(operation) {
238
+ return {
239
+ name: (0, import_core.unCapitalize)(operation.name),
240
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION }) => (C) => {
241
+ const op = CONSUME(operation);
242
+ const silent = OPTION(() => CONSUME(l.silent));
243
+ const source = SUBRULE1(graphOrDefault);
244
+ CONSUME(l.to);
245
+ const destination = SUBRULE2(graphOrDefault);
246
+ return ACTION(() => C.astFactory.updateOperationAddMoveCopy((0, import_core.unCapitalize)(operation.name), source, destination, Boolean(silent), C.astFactory.sourceLocation(op, destination)));
247
+ },
248
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY }) => (ast, { astFactory: F }) => {
249
+ F.printFilter(ast, () => {
250
+ PRINT_ON_EMPTY(operation.name.toUpperCase(), " ");
251
+ if (ast.silent) {
252
+ PRINT_WORD("SILENT");
253
+ }
254
+ });
255
+ SUBRULE(graphRefAll, ast.source);
256
+ F.printFilter(ast, () => PRINT_WORD("TO"));
257
+ SUBRULE(graphRefAll, ast.destination);
258
+ }
259
+ };
260
+ }
261
+ const add = copyMoveAddOperation(l.add);
262
+ const move = copyMoveAddOperation(l.move);
263
+ const copy = copyMoveAddOperation(l.copy);
264
+ const quadPattern = {
265
+ name: "quadPattern",
266
+ impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
267
+ const open = CONSUME(l.symbols.LCurly);
268
+ const val = SUBRULE1(quads);
269
+ const close = CONSUME(l.symbols.RCurly);
270
+ return ACTION(() => C.astFactory.wrap(val.val, C.astFactory.sourceLocation(open, close)));
271
+ }
272
+ };
273
+ const quadData = {
274
+ name: "quadData",
275
+ impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
276
+ const open = CONSUME(l.symbols.LCurly);
277
+ const couldParseVars = ACTION(() => C.parseMode.delete("canParseVars"));
278
+ const val = SUBRULE1(quads);
279
+ ACTION(() => couldParseVars && C.parseMode.add("canParseVars"));
280
+ const close = CONSUME(l.symbols.RCurly);
281
+ return ACTION(() => C.astFactory.wrap(val.val, C.astFactory.sourceLocation(open, close)));
282
+ }
283
+ };
284
+ function insertDeleteDelWhere(name, subType, cons1, dataRule) {
285
+ return {
286
+ name,
287
+ impl: ({ ACTION, SUBRULE1, CONSUME }) => (C) => {
288
+ const insDelToken = CONSUME(cons1);
289
+ let couldCreateBlankNodes = true;
290
+ if (name !== "insertData") {
291
+ couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
292
+ }
293
+ const data = SUBRULE1(dataRule);
294
+ if (name !== "insertData") {
295
+ ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
296
+ }
297
+ return ACTION(() => C.astFactory.updateOperationInsDelDataWhere(subType, data.val, C.astFactory.sourceLocation(insDelToken, data)));
298
+ },
299
+ gImpl: ({ SUBRULE, PRINT_WORD, PRINT_ON_EMPTY, PRINT_ON_OWN_LINE, NEW_LINE }) => (ast, C) => {
300
+ const { astFactory: F, indentInc } = C;
301
+ F.printFilter(ast, () => {
302
+ if (subType === "insertdata") {
303
+ PRINT_ON_EMPTY("INSERT DATA ");
304
+ } else if (subType === "deletedata") {
305
+ PRINT_ON_EMPTY("DELETE DATA ");
306
+ } else if (subType === "deletewhere") {
307
+ PRINT_ON_EMPTY("DELETE WHERE ");
308
+ }
309
+ C[import_core.traqulaIndentation] += indentInc;
310
+ PRINT_WORD("{");
311
+ NEW_LINE();
312
+ });
313
+ SUBRULE(quads, F.wrap(ast.data, ast.loc));
314
+ F.printFilter(ast, () => {
315
+ C[import_core.traqulaIndentation] -= indentInc;
316
+ PRINT_ON_OWN_LINE("}");
317
+ });
318
+ }
319
+ };
320
+ }
321
+ const insertData = insertDeleteDelWhere("insertData", "insertdata", l.insertDataClause, quadData);
322
+ const deleteData = insertDeleteDelWhere("deleteData", "deletedata", l.deleteDataClause, quadData);
323
+ const deleteWhere = insertDeleteDelWhere("deleteWhere", "deletewhere", l.deleteWhereClause, quadPattern);
324
+ const modify = {
325
+ name: "modify",
326
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OR }) => (C) => {
327
+ const graph = OPTION1(() => {
328
+ const withToken = CONSUME(l.modifyWith);
329
+ const graph2 = SUBRULE1(import_literals.iri);
330
+ return { withToken, graph: graph2 };
331
+ });
332
+ const { insert, del } = OR([
333
+ { ALT: () => {
334
+ const del2 = SUBRULE1(deleteClause);
335
+ const insert2 = OPTION2(() => SUBRULE1(insertClause));
336
+ return { del: del2, insert: insert2 };
337
+ } },
338
+ { ALT: () => {
339
+ const insert2 = SUBRULE2(insertClause);
340
+ return { insert: insert2, del: void 0 };
341
+ } }
342
+ ]);
343
+ const using = SUBRULE1(import_dataSetClause.usingClauseStar);
344
+ CONSUME(l.where);
345
+ const where = SUBRULE1(import_whereClause.groupGraphPattern);
346
+ return ACTION(() => C.astFactory.updateOperationModify(C.astFactory.sourceLocation(graph?.withToken, del, insert, where), insert?.val ?? [], del?.val ?? [], where, using, graph?.graph));
347
+ },
348
+ gImpl: ({ SUBRULE, PRINT_WORDS, PRINT_ON_EMPTY, NEW_LINE }) => (ast, C) => {
349
+ const { astFactory: F, indentInc } = C;
350
+ if (ast.graph) {
351
+ F.printFilter(ast, () => PRINT_WORDS("WITH"));
352
+ SUBRULE(import_literals.iri, ast.graph);
353
+ }
354
+ if (ast.delete.length > 0) {
355
+ F.printFilter(ast, () => {
356
+ C[import_core.traqulaIndentation] += indentInc;
357
+ PRINT_WORDS("DELETE", "{");
358
+ NEW_LINE();
359
+ });
360
+ SUBRULE(quads, F.wrap(ast.delete, ast.loc));
361
+ F.printFilter(ast, () => {
362
+ C[import_core.traqulaIndentation] -= indentInc;
363
+ PRINT_ON_EMPTY("}");
364
+ NEW_LINE();
365
+ });
366
+ }
367
+ if (ast.insert.length > 0) {
368
+ F.printFilter(ast, () => {
369
+ C[import_core.traqulaIndentation] += indentInc;
370
+ PRINT_WORDS("INSERT", "{");
371
+ NEW_LINE();
372
+ });
373
+ SUBRULE(quads, F.wrap(ast.insert, ast.loc));
374
+ F.printFilter(ast, () => {
375
+ C[import_core.traqulaIndentation] -= indentInc;
376
+ PRINT_ON_EMPTY("} ");
377
+ NEW_LINE();
378
+ });
379
+ }
380
+ SUBRULE(import_dataSetClause.usingClauseStar, ast.from);
381
+ F.printFilter(ast, () => PRINT_WORDS("WHERE"));
382
+ SUBRULE(import_whereClause.groupGraphPattern, ast.where);
383
+ }
384
+ };
385
+ const deleteClause = {
386
+ name: "deleteClause",
387
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
388
+ const delToken = CONSUME(l.deleteClause);
389
+ const couldCreateBlankNodes = ACTION(() => C.parseMode.delete("canCreateBlankNodes"));
390
+ const del = SUBRULE(quadPattern);
391
+ ACTION(() => couldCreateBlankNodes && C.parseMode.add("canCreateBlankNodes"));
392
+ return ACTION(() => C.astFactory.wrap(del.val, C.astFactory.sourceLocation(delToken, del)));
393
+ }
394
+ };
395
+ const insertClause = {
396
+ name: "insertClause",
397
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
398
+ const insertToken = CONSUME(l.insertClause);
399
+ const insert = SUBRULE(quadPattern);
400
+ return ACTION(() => C.astFactory.wrap(insert.val, C.astFactory.sourceLocation(insertToken, insert)));
401
+ }
402
+ };
403
+ const graphOrDefault = {
404
+ name: "graphOrDefault",
405
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION, OR }) => (C) => OR([
406
+ { ALT: () => {
407
+ const def = CONSUME(l.graph.default_);
408
+ return ACTION(() => C.astFactory.graphRefDefault(C.astFactory.sourceLocation(def)));
409
+ } },
410
+ { ALT: () => {
411
+ const graph = OPTION(() => CONSUME(l.graph.graph));
412
+ const name = SUBRULE1(import_literals.iri);
413
+ return ACTION(() => C.astFactory.graphRefSpecific(name, C.astFactory.sourceLocation(graph, name)));
414
+ } }
415
+ ])
416
+ };
417
+ const graphRef = {
418
+ name: "graphRef",
419
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
420
+ const graph = CONSUME(l.graph.graph);
421
+ const val = SUBRULE(import_literals.iri);
422
+ return ACTION(() => C.astFactory.graphRefSpecific(val, C.astFactory.sourceLocation(graph, val)));
423
+ },
424
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F }) => {
425
+ F.printFilter(ast, () => PRINT_WORD("GRAPH"));
426
+ SUBRULE(import_literals.iri, ast.graph);
427
+ }
428
+ };
429
+ const graphRefAll = {
430
+ name: "graphRefAll",
431
+ impl: ({ ACTION, SUBRULE, CONSUME, OR }) => (C) => OR([
432
+ { ALT: () => SUBRULE(graphRef) },
433
+ { ALT: () => {
434
+ const def = CONSUME(l.graph.default_);
435
+ return ACTION(() => C.astFactory.graphRefDefault(C.astFactory.sourceLocation(def)));
436
+ } },
437
+ { ALT: () => {
438
+ const named = CONSUME(l.graph.named);
439
+ return ACTION(() => C.astFactory.graphRefNamed(C.astFactory.sourceLocation(named)));
440
+ } },
441
+ { ALT: () => {
442
+ const graphAll = CONSUME(l.graph.graphAll);
443
+ return ACTION(() => C.astFactory.graphRefAll(C.astFactory.sourceLocation(graphAll)));
444
+ } }
445
+ ]),
446
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F }) => {
447
+ if (F.isGraphRefSpecific(ast)) {
448
+ SUBRULE(graphRef, ast);
449
+ } else if (F.isGraphRefDefault(ast)) {
450
+ F.printFilter(ast, () => PRINT_WORD("DEFAULT"));
451
+ } else if (F.isGraphRefNamed(ast)) {
452
+ F.printFilter(ast, () => PRINT_WORD("NAMED"));
453
+ } else if (F.isGraphRefAll(ast)) {
454
+ F.printFilter(ast, () => PRINT_WORD("ALL"));
455
+ }
456
+ }
457
+ };
458
+ const quads = {
459
+ name: "quads",
460
+ impl: ({ ACTION, SUBRULE, CONSUME, MANY, SUBRULE1, SUBRULE2, OPTION1, OPTION2, OPTION3 }) => (C) => {
461
+ const quads2 = [];
462
+ let last;
463
+ OPTION1(() => {
464
+ const triples = SUBRULE1(import_tripleBlock.triplesTemplate);
465
+ last = triples;
466
+ ACTION(() => quads2.push(triples));
467
+ });
468
+ MANY(() => {
469
+ const notTriples = SUBRULE(quadsNotTriples);
470
+ last = notTriples;
471
+ quads2.push(notTriples);
472
+ OPTION2(() => {
473
+ const dotToken = CONSUME(l.symbols.dot);
474
+ last = dotToken;
475
+ return dotToken;
476
+ });
477
+ OPTION3(() => {
478
+ const triples = SUBRULE2(import_tripleBlock.triplesTemplate);
479
+ last = triples;
480
+ ACTION(() => quads2.push(triples));
481
+ });
482
+ });
483
+ return ACTION(() => C.astFactory.wrap(quads2, C.astFactory.sourceLocation(quads2.at(0), last)));
484
+ },
485
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F }) => {
486
+ for (const quad of ast.val) {
487
+ if (F.isPattern(quad)) {
488
+ SUBRULE(import_tripleBlock.triplesBlock, quad);
489
+ } else {
490
+ SUBRULE(quadsNotTriples, quad);
491
+ }
492
+ }
493
+ }
494
+ };
495
+ const quadsNotTriples = {
496
+ name: "quadsNotTriples",
497
+ impl: ({ ACTION, SUBRULE1, CONSUME, OPTION }) => (C) => {
498
+ const graph = CONSUME(l.graph.graph);
499
+ const name = SUBRULE1(import_general.varOrIri);
500
+ CONSUME(l.symbols.LCurly);
501
+ const triples = OPTION(() => SUBRULE1(import_tripleBlock.triplesTemplate));
502
+ const close = CONSUME(l.symbols.RCurly);
503
+ return ACTION(() => C.astFactory.graphQuads(name, triples ?? C.astFactory.patternBgp([], C.astFactory.sourceLocationNoMaterialize()), C.astFactory.sourceLocation(graph, close)));
504
+ },
505
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
506
+ const { astFactory: F, indentInc } = C;
507
+ F.printFilter(ast, () => PRINT_WORD("GRAPH"));
508
+ SUBRULE(import_general.varOrTerm, ast.graph);
509
+ F.printFilter(ast, () => {
510
+ C[import_core.traqulaIndentation] += indentInc;
511
+ PRINT_WORD("{");
512
+ NEW_LINE();
513
+ });
514
+ SUBRULE(import_tripleBlock.triplesBlock, ast.triples);
515
+ F.printFilter(ast, () => {
516
+ C[import_core.traqulaIndentation] -= indentInc;
517
+ PRINT_ON_OWN_LINE("}");
518
+ });
519
+ }
520
+ };
521
+ // Annotate the CommonJS export names for ESM import in node:
522
+ 0 && (module.exports = {
523
+ add,
524
+ clear,
525
+ copy,
526
+ create,
527
+ deleteClause,
528
+ deleteData,
529
+ deleteWhere,
530
+ drop,
531
+ graphOrDefault,
532
+ graphRef,
533
+ graphRefAll,
534
+ insertClause,
535
+ insertData,
536
+ load,
537
+ modify,
538
+ move,
539
+ quadData,
540
+ quadPattern,
541
+ quads,
542
+ quadsNotTriples,
543
+ update,
544
+ update1,
545
+ updateUnit
546
+ });