@traqula/rules-sparql-1-2 0.0.21 → 0.0.22

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 (43) hide show
  1. package/dist/cjs/lib/AstFactory.js +96 -0
  2. package/dist/cjs/lib/grammar.js +644 -0
  3. package/dist/cjs/lib/index.js +52 -0
  4. package/dist/cjs/lib/lexer.js +96 -0
  5. package/dist/cjs/lib/parserUtils.js +46 -0
  6. package/dist/cjs/lib/sparql12HelperTypes.js +16 -0
  7. package/dist/cjs/lib/sparql12Types.js +16 -0
  8. package/dist/cjs/lib/validators.js +116 -0
  9. package/dist/esm/lib/AstFactory.js.map +1 -0
  10. package/{lib → dist/esm/lib}/grammar.d.ts +2 -2
  11. package/dist/esm/lib/grammar.js.map +1 -0
  12. package/dist/esm/lib/index.js.map +1 -0
  13. package/dist/esm/lib/lexer.d.ts +20 -0
  14. package/dist/esm/lib/lexer.js.map +1 -0
  15. package/dist/esm/lib/parserUtils.js.map +1 -0
  16. package/dist/esm/lib/sparql12HelperTypes.js.map +1 -0
  17. package/dist/esm/lib/sparql12Types.js.map +1 -0
  18. package/dist/esm/lib/validators.js.map +1 -0
  19. package/package.json +13 -15
  20. package/lib/AstFactory.js.map +0 -1
  21. package/lib/grammar.js.map +0 -1
  22. package/lib/index.cjs +0 -15398
  23. package/lib/index.js.map +0 -1
  24. package/lib/lexer.d.ts +0 -20
  25. package/lib/lexer.js.map +0 -1
  26. package/lib/parserUtils.js.map +0 -1
  27. package/lib/sparql12HelperTypes.js.map +0 -1
  28. package/lib/sparql12Types.js.map +0 -1
  29. package/lib/validators.js.map +0 -1
  30. /package/{lib → dist/esm/lib}/AstFactory.d.ts +0 -0
  31. /package/{lib → dist/esm/lib}/AstFactory.js +0 -0
  32. /package/{lib → dist/esm/lib}/grammar.js +0 -0
  33. /package/{lib → dist/esm/lib}/index.d.ts +0 -0
  34. /package/{lib → dist/esm/lib}/index.js +0 -0
  35. /package/{lib → dist/esm/lib}/lexer.js +0 -0
  36. /package/{lib → dist/esm/lib}/parserUtils.d.ts +0 -0
  37. /package/{lib → dist/esm/lib}/parserUtils.js +0 -0
  38. /package/{lib → dist/esm/lib}/sparql12HelperTypes.d.ts +0 -0
  39. /package/{lib → dist/esm/lib}/sparql12HelperTypes.js +0 -0
  40. /package/{lib → dist/esm/lib}/sparql12Types.d.ts +0 -0
  41. /package/{lib → dist/esm/lib}/sparql12Types.js +0 -0
  42. /package/{lib → dist/esm/lib}/validators.d.ts +0 -0
  43. /package/{lib → dist/esm/lib}/validators.js +0 -0
@@ -0,0 +1,644 @@
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 grammar_exports = {};
30
+ __export(grammar_exports, {
31
+ annotation: () => annotation,
32
+ annotationBlock: () => annotationBlock,
33
+ annotationBlockPath: () => annotationBlockPath,
34
+ annotationPath: () => annotationPath,
35
+ buildInHasLang: () => buildInHasLang,
36
+ buildInHasLangDir: () => buildInHasLangDir,
37
+ buildInIsTriple: () => buildInIsTriple,
38
+ buildInLangDir: () => buildInLangDir,
39
+ buildInLangStrDir: () => buildInLangStrDir,
40
+ buildInObject: () => buildInObject,
41
+ buildInPredicate: () => buildInPredicate,
42
+ buildInSubject: () => buildInSubject,
43
+ buildInTriple: () => buildInTriple,
44
+ builtInCall: () => builtInCall,
45
+ dataBlockValue: () => dataBlockValue,
46
+ exprTripleTerm: () => exprTripleTerm,
47
+ exprTripleTermObject: () => exprTripleTermObject,
48
+ exprTripleTermSubject: () => exprTripleTermSubject,
49
+ generateGraphTerm: () => generateGraphTerm,
50
+ generateTriplesBlock: () => generateTriplesBlock,
51
+ graphNode: () => graphNode,
52
+ graphNodePath: () => graphNodePath,
53
+ object: () => object,
54
+ objectPath: () => objectPath,
55
+ primaryExpression: () => primaryExpression,
56
+ prologue: () => prologue,
57
+ rdfLiteral: () => rdfLiteral,
58
+ reifiedTriple: () => reifiedTriple,
59
+ reifiedTripleBlock: () => reifiedTripleBlock,
60
+ reifiedTripleBlockPath: () => reifiedTripleBlockPath,
61
+ reifiedTripleObject: () => reifiedTripleObject,
62
+ reifiedTripleSubject: () => reifiedTripleSubject,
63
+ reifier: () => reifier,
64
+ tripleTerm: () => tripleTerm,
65
+ tripleTermData: () => tripleTermData,
66
+ tripleTermDataObject: () => tripleTermDataObject,
67
+ tripleTermDataSubject: () => tripleTermDataSubject,
68
+ tripleTermObject: () => tripleTermObject,
69
+ tripleTermSubject: () => tripleTermSubject,
70
+ triplesSameSubject: () => triplesSameSubject,
71
+ triplesSameSubjectPath: () => triplesSameSubjectPath,
72
+ unaryExpression: () => unaryExpression,
73
+ varOrReifierId: () => varOrReifierId,
74
+ varOrTerm: () => varOrTerm,
75
+ versionDecl: () => versionDecl,
76
+ versionSpecifier: () => versionSpecifier
77
+ });
78
+ module.exports = __toCommonJS(grammar_exports);
79
+ var import_core = require("@traqula/core");
80
+ var import_rules_sparql_1_1 = require("@traqula/rules-sparql-1-1");
81
+ var l12 = __toESM(require("./lexer.js"), 1);
82
+ var import_validators = require("./validators.js");
83
+ const versionDecl = {
84
+ name: "versionDecl",
85
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
86
+ const versionToken = CONSUME(l12.version);
87
+ const identifier = SUBRULE(versionSpecifier);
88
+ return ACTION(() => C.astFactory.contextDefinitionVersion(identifier.val, C.astFactory.sourceLocation(versionToken, identifier)));
89
+ },
90
+ gImpl: ({ PRINT_ON_OWN_LINE }) => (ast, { astFactory: F }) => {
91
+ F.printFilter(ast, () => {
92
+ PRINT_ON_OWN_LINE("VERSION ", `${import_rules_sparql_1_1.gram.stringEscapedLexical(ast.version)}`);
93
+ });
94
+ }
95
+ };
96
+ const versionSpecifier = {
97
+ name: "versionSpecifier",
98
+ impl: ({ ACTION, CONSUME, OR }) => (C) => {
99
+ const token = OR([
100
+ { ALT: () => CONSUME(import_rules_sparql_1_1.lex.terminals.stringLiteral1) },
101
+ { ALT: () => CONSUME(import_rules_sparql_1_1.lex.terminals.stringLiteral2) }
102
+ ]);
103
+ return ACTION(() => C.astFactory.wrap(token.image.slice(1, -1), C.astFactory.sourceLocation(token)));
104
+ }
105
+ };
106
+ const prologue = {
107
+ name: "prologue",
108
+ impl: ({ SUBRULE, MANY, OR }) => () => {
109
+ const result = [];
110
+ MANY(() => OR([
111
+ { ALT: () => result.push(SUBRULE(import_rules_sparql_1_1.gram.baseDecl)) },
112
+ // TODO: the [spec](https://www.w3.org/TR/sparql11-query/#iriRefs) says you cannot redefine prefixes.
113
+ // We might need to check this.
114
+ { ALT: () => result.push(SUBRULE(import_rules_sparql_1_1.gram.prefixDecl)) },
115
+ { ALT: () => result.push(SUBRULE(versionDecl)) }
116
+ ]));
117
+ return result;
118
+ },
119
+ gImpl: ({ SUBRULE }) => (ast, { astFactory: F }) => {
120
+ for (const context of ast) {
121
+ if (F.isContextDefinitionBase(context)) {
122
+ SUBRULE(import_rules_sparql_1_1.gram.baseDecl, context);
123
+ } else if (F.isContextDefinitionPrefix(context)) {
124
+ SUBRULE(import_rules_sparql_1_1.gram.prefixDecl, context);
125
+ } else if (F.isContextDefinitionVersion(context)) {
126
+ SUBRULE(versionDecl, context);
127
+ }
128
+ }
129
+ }
130
+ };
131
+ function reifiedTripleBlockImpl(name, allowPath) {
132
+ return {
133
+ name,
134
+ impl: ({ ACTION, SUBRULE }) => (C) => {
135
+ const triple = SUBRULE(reifiedTriple);
136
+ const properties = SUBRULE(allowPath ? import_rules_sparql_1_1.gram.propertyListPath : import_rules_sparql_1_1.gram.propertyList, ACTION(() => C.astFactory.dematerialized(triple.identifier)));
137
+ return ACTION(() => [triple, ...properties]);
138
+ }
139
+ };
140
+ }
141
+ const reifiedTripleBlock = reifiedTripleBlockImpl("reifiedTripleBlock", false);
142
+ const reifiedTripleBlockPath = reifiedTripleBlockImpl("reifiedTripleBlockPath", true);
143
+ const dataBlockValue = {
144
+ name: "dataBlockValue",
145
+ impl: ($) => (C) => $.OR2([
146
+ { ALT: () => import_rules_sparql_1_1.gram.dataBlockValue.impl($)(C) },
147
+ { ALT: () => $.SUBRULE(tripleTermData) }
148
+ ])
149
+ };
150
+ const reifier = {
151
+ name: "reifier",
152
+ impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
153
+ const tildeToken = CONSUME(l12.tilde);
154
+ const reifier2 = OPTION(() => SUBRULE(varOrReifierId));
155
+ return ACTION(() => {
156
+ if (reifier2 === void 0 && !C.parseMode.has("canCreateBlankNodes")) {
157
+ throw new Error("Cannot create blanknodes in current parse mode");
158
+ }
159
+ return C.astFactory.wrap(reifier2 ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation()), C.astFactory.sourceLocation(tildeToken, reifier2));
160
+ });
161
+ }
162
+ };
163
+ const varOrReifierId = {
164
+ name: "varOrReifierId",
165
+ impl: ({ SUBRULE, OR }) => (C) => OR([
166
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(import_rules_sparql_1_1.gram.var_) },
167
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.iri) },
168
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.blankNode) }
169
+ ])
170
+ };
171
+ function triplesSameSubjectImpl(name, allowPaths) {
172
+ return {
173
+ name,
174
+ impl: ($) => (C) => $.OR2([
175
+ { ALT: () => allowPaths ? import_rules_sparql_1_1.gram.triplesSameSubjectPath.impl($)(C) : import_rules_sparql_1_1.gram.triplesSameSubject.impl($)(C) },
176
+ { ALT: () => $.SUBRULE(allowPaths ? reifiedTripleBlockPath : reifiedTripleBlock) }
177
+ ])
178
+ };
179
+ }
180
+ const triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
181
+ const triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
182
+ function objectImpl(name, allowPaths) {
183
+ return {
184
+ name,
185
+ impl: ({ ACTION, SUBRULE }) => (C, subject, predicate) => {
186
+ const objectVal = SUBRULE(allowPaths ? graphNodePath : graphNode);
187
+ const annotationVal = SUBRULE(allowPaths ? annotationPath : annotation);
188
+ return ACTION(() => {
189
+ const F = C.astFactory;
190
+ if (F.isPathPure(predicate) && annotationVal.length > 0) {
191
+ throw new Error("Note 17 violation");
192
+ }
193
+ return F.annotatedTriple(subject, predicate, objectVal, annotationVal);
194
+ });
195
+ }
196
+ };
197
+ }
198
+ const object = objectImpl("object", false);
199
+ const objectPath = objectImpl("objectPath", true);
200
+ function annotationImpl(name, allowPaths) {
201
+ return {
202
+ name,
203
+ impl: ({ ACTION, SUBRULE, OR, MANY }) => (C) => {
204
+ const annotations = [];
205
+ let currentReifier;
206
+ MANY(() => {
207
+ OR([
208
+ { ALT: () => {
209
+ const node = SUBRULE(reifier);
210
+ annotations.push(node);
211
+ currentReifier = node.val;
212
+ } },
213
+ { ALT: () => {
214
+ ACTION(() => {
215
+ if (!currentReifier && !C.parseMode.has("canCreateBlankNodes")) {
216
+ throw new Error("Cannot create blanknodes in current parse mode");
217
+ }
218
+ currentReifier = currentReifier ?? C.astFactory.termBlank(void 0, C.astFactory.sourceLocation());
219
+ });
220
+ const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, currentReifier);
221
+ ACTION(() => {
222
+ annotations.push(block);
223
+ currentReifier = void 0;
224
+ });
225
+ } }
226
+ ]);
227
+ });
228
+ return annotations;
229
+ },
230
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F }) => {
231
+ for (const annotation2 of ast) {
232
+ if (F.isTripleCollectionBlankNodeProperties(annotation2)) {
233
+ SUBRULE(annotationBlockPath, annotation2);
234
+ } else {
235
+ F.printFilter(annotation2, () => PRINT_WORD("~"));
236
+ SUBRULE(graphNodePath, annotation2.val);
237
+ }
238
+ }
239
+ }
240
+ };
241
+ }
242
+ const annotationPath = annotationImpl("annotationPath", true);
243
+ const annotation = annotationImpl("annotation", false);
244
+ function annotationBlockImpl(name, allowPaths) {
245
+ return {
246
+ name,
247
+ impl: ({ ACTION, SUBRULE, CONSUME }) => (C, arg) => {
248
+ const open = CONSUME(l12.annotationOpen);
249
+ const res = SUBRULE(allowPaths ? import_rules_sparql_1_1.gram.propertyListPathNotEmpty : import_rules_sparql_1_1.gram.propertyListNotEmpty, arg);
250
+ const close = CONSUME(l12.annotationClose);
251
+ return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(arg, res, C.astFactory.sourceLocation(open, close)));
252
+ },
253
+ gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE, PRINT_ON_OWN_LINE }) => (ast, C) => {
254
+ const { astFactory: F, indentInc } = C;
255
+ F.printFilter(ast, () => {
256
+ PRINT_WORD("{|");
257
+ if (ast.triples.length > 1) {
258
+ C[import_core.traqulaIndentation] += indentInc;
259
+ NEW_LINE();
260
+ }
261
+ });
262
+ function printTriple(triple) {
263
+ HANDLE_LOC(triple, () => {
264
+ if (F.isTerm(triple.predicate)) {
265
+ SUBRULE(graphNodePath, triple.predicate);
266
+ } else {
267
+ SUBRULE(import_rules_sparql_1_1.gram.pathGenerator, triple.predicate, void 0);
268
+ }
269
+ F.printFilter(triple, () => PRINT_WORD(""));
270
+ SUBRULE(graphNodePath, triple.object);
271
+ });
272
+ }
273
+ const [head, ...tail] = ast.triples;
274
+ printTriple(head);
275
+ for (const triple of tail) {
276
+ F.printFilter(ast, () => {
277
+ PRINT_WORD(";");
278
+ NEW_LINE();
279
+ });
280
+ printTriple(triple);
281
+ }
282
+ F.printFilter(ast, () => {
283
+ if (ast.triples.length > 1) {
284
+ PRINT_ON_OWN_LINE("|}");
285
+ } else {
286
+ PRINT_WORD("|}");
287
+ }
288
+ });
289
+ }
290
+ };
291
+ }
292
+ const annotationBlockPath = annotationBlockImpl("annotationBlockPath", true);
293
+ const annotationBlock = annotationBlockImpl("annotationBlock", false);
294
+ const graphNode = {
295
+ name: "graphNode",
296
+ impl: ($) => (C) => $.OR2([
297
+ { ALT: () => import_rules_sparql_1_1.gram.graphNode.impl($)(C) },
298
+ { ALT: () => $.SUBRULE(reifiedTriple) }
299
+ ])
300
+ };
301
+ const graphNodePath = {
302
+ name: "graphNodePath",
303
+ impl: ($) => (C) => $.OR2([
304
+ { ALT: () => import_rules_sparql_1_1.gram.graphNodePath.impl($)(C) },
305
+ { ALT: () => $.SUBRULE(reifiedTriple) }
306
+ ]),
307
+ gImpl: ($) => (ast, C) => {
308
+ if (C.astFactory.isTripleCollectionReifiedTriple(ast)) {
309
+ $.SUBRULE(reifiedTriple, ast);
310
+ } else {
311
+ import_rules_sparql_1_1.gram.graphNodePath.gImpl($)(ast, C);
312
+ }
313
+ }
314
+ };
315
+ const varOrTerm = {
316
+ name: "varOrTerm",
317
+ impl: ({ ACTION, SUBRULE, OR, CONSUME }) => (C) => OR([
318
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(import_rules_sparql_1_1.gram.var_) },
319
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.iri) },
320
+ { ALT: () => SUBRULE(rdfLiteral) },
321
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.numericLiteral) },
322
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.booleanLiteral) },
323
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.blankNode) },
324
+ { ALT: () => {
325
+ const token = CONSUME(import_rules_sparql_1_1.lex.terminals.nil);
326
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), import_rules_sparql_1_1.CommonIRIs.NIL));
327
+ } },
328
+ { ALT: () => SUBRULE(tripleTerm) }
329
+ ])
330
+ // Generation remains untouched - go through graphTerm
331
+ };
332
+ const reifiedTriple = {
333
+ name: "reifiedTriple",
334
+ impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
335
+ const open = CONSUME(l12.reificationOpen);
336
+ const subject = SUBRULE(reifiedTripleSubject);
337
+ const predicate = SUBRULE(import_rules_sparql_1_1.gram.verb);
338
+ const object2 = SUBRULE(reifiedTripleObject);
339
+ const reifierVal = OPTION(() => SUBRULE(reifier));
340
+ const close = CONSUME(l12.reificationClose);
341
+ return ACTION(() => {
342
+ if (reifierVal === void 0 && !C.parseMode.has("canCreateBlankNodes")) {
343
+ throw new Error("Cannot create blanknodes in current parse mode");
344
+ }
345
+ return C.astFactory.tripleCollectionReifiedTriple(C.astFactory.sourceLocation(open, close), subject, predicate, object2, reifierVal?.val);
346
+ });
347
+ },
348
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F }) => {
349
+ F.printFilter(ast, () => PRINT_WORD("<<"));
350
+ const triple = ast.triples[0];
351
+ SUBRULE(graphNodePath, triple.subject);
352
+ F.printFilter(ast, () => PRINT_WORD(""));
353
+ if (F.isPathPure(triple.predicate)) {
354
+ SUBRULE(import_rules_sparql_1_1.gram.pathGenerator, triple.predicate, void 0);
355
+ } else {
356
+ SUBRULE(graphNodePath, triple.predicate);
357
+ }
358
+ F.printFilter(ast, () => PRINT_WORD(""));
359
+ SUBRULE(graphNodePath, triple.object);
360
+ SUBRULE(annotationPath, [F.wrap(ast.identifier, ast.identifier.loc)]);
361
+ F.printFilter(ast, () => PRINT_WORD(">>"));
362
+ }
363
+ };
364
+ const reifiedTripleSubject = {
365
+ name: "reifiedTripleSubject",
366
+ impl: ({ OR, SUBRULE }) => (C) => OR([
367
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(import_rules_sparql_1_1.gram.var_) },
368
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.iri) },
369
+ { ALT: () => SUBRULE(rdfLiteral) },
370
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.numericLiteral) },
371
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.booleanLiteral) },
372
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.blankNode) },
373
+ { ALT: () => SUBRULE(reifiedTriple) },
374
+ { ALT: () => SUBRULE(tripleTerm) }
375
+ ])
376
+ };
377
+ const reifiedTripleObject = {
378
+ name: "reifiedTripleObject",
379
+ impl: reifiedTripleSubject.impl
380
+ };
381
+ const tripleTerm = {
382
+ name: "tripleTerm",
383
+ impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
384
+ const open = CONSUME(l12.tripleTermOpen);
385
+ const subject = SUBRULE(tripleTermSubject);
386
+ const predicate = SUBRULE(import_rules_sparql_1_1.gram.verb);
387
+ const object2 = SUBRULE(tripleTermObject);
388
+ const close = CONSUME(l12.tripleTermClose);
389
+ return ACTION(() => C.astFactory.termTriple(subject, predicate, object2, C.astFactory.sourceLocation(open, close)));
390
+ },
391
+ gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F }) => {
392
+ F.printFilter(ast, () => PRINT_WORD("<<("));
393
+ SUBRULE(graphNodePath, ast.subject);
394
+ F.printFilter(ast, () => PRINT_WORD(""));
395
+ SUBRULE(graphNodePath, ast.predicate);
396
+ F.printFilter(ast, () => PRINT_WORD(""));
397
+ SUBRULE(graphNodePath, ast.object);
398
+ F.printFilter(ast, () => PRINT_WORD(")>>"));
399
+ }
400
+ };
401
+ const tripleTermSubject = {
402
+ name: "tripleTermSubject",
403
+ impl: ({ SUBRULE, OR }) => (C) => OR([
404
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(import_rules_sparql_1_1.gram.var_) },
405
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.iri) },
406
+ { ALT: () => SUBRULE(rdfLiteral) },
407
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.numericLiteral) },
408
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.booleanLiteral) },
409
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.blankNode) },
410
+ { ALT: () => SUBRULE(tripleTerm) }
411
+ ])
412
+ };
413
+ const tripleTermObject = {
414
+ name: "tripleTermObject",
415
+ impl: tripleTermSubject.impl
416
+ };
417
+ const tripleTermData = {
418
+ name: "tripleTermData",
419
+ impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
420
+ const open = CONSUME(l12.tripleTermOpen);
421
+ const subject = SUBRULE(tripleTermDataSubject);
422
+ const predicate = OR([
423
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.iri) },
424
+ { ALT: () => {
425
+ const token = CONSUME(import_rules_sparql_1_1.lex.a);
426
+ return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), import_rules_sparql_1_1.CommonIRIs.TYPE));
427
+ } }
428
+ ]);
429
+ const object2 = SUBRULE(tripleTermDataObject);
430
+ const close = CONSUME(l12.tripleTermClose);
431
+ return ACTION(() => C.astFactory.termTriple(subject, predicate, object2, C.astFactory.sourceLocation(open, close)));
432
+ }
433
+ };
434
+ const tripleTermDataSubject = {
435
+ name: "tripleTermDataSubject",
436
+ impl: ({ OR, SUBRULE }) => () => OR([
437
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.iri) },
438
+ { ALT: () => SUBRULE(rdfLiteral) },
439
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.numericLiteral) },
440
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.booleanLiteral) },
441
+ { ALT: () => SUBRULE(tripleTermData) }
442
+ ])
443
+ };
444
+ const tripleTermDataObject = {
445
+ name: "tripleTermDataObject",
446
+ impl: tripleTermDataSubject.impl
447
+ };
448
+ const primaryExpression = {
449
+ name: "primaryExpression",
450
+ impl: ($) => (C) => $.OR2([
451
+ { ALT: () => import_rules_sparql_1_1.gram.primaryExpression.impl($)(C) },
452
+ { ALT: () => $.SUBRULE(exprTripleTerm) }
453
+ ])
454
+ };
455
+ const exprTripleTerm = {
456
+ name: "exprTripleTerm",
457
+ impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
458
+ const open = CONSUME(l12.tripleTermOpen);
459
+ const subject = SUBRULE(exprTripleTermSubject);
460
+ const predicate = SUBRULE(import_rules_sparql_1_1.gram.verb);
461
+ const object2 = SUBRULE(exprTripleTermObject);
462
+ const close = CONSUME(l12.tripleTermClose);
463
+ return ACTION(() => C.astFactory.termTriple(subject, predicate, object2, C.astFactory.sourceLocation(open, close)));
464
+ }
465
+ };
466
+ const exprTripleTermSubject = {
467
+ name: "exprTripleTermSubject",
468
+ impl: ({ OR, SUBRULE }) => (C) => OR([
469
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.iri) },
470
+ { ALT: () => SUBRULE(rdfLiteral) },
471
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.numericLiteral) },
472
+ { ALT: () => SUBRULE(import_rules_sparql_1_1.gram.booleanLiteral) },
473
+ { GATE: () => C.parseMode.has("canParseVars"), ALT: () => SUBRULE(import_rules_sparql_1_1.gram.var_) },
474
+ { ALT: () => SUBRULE(exprTripleTerm) }
475
+ ])
476
+ };
477
+ const exprTripleTermObject = {
478
+ name: "exprTripleTermObject",
479
+ impl: exprTripleTermSubject.impl
480
+ };
481
+ const buildInLangDir = (0, import_rules_sparql_1_1.funcExpr1)(l12.buildInLangDir);
482
+ const buildInLangStrDir = (0, import_rules_sparql_1_1.funcExpr3)(l12.buildInStrLangDir);
483
+ const buildInHasLang = (0, import_rules_sparql_1_1.funcExpr1)(l12.buildInHasLang);
484
+ const buildInHasLangDir = (0, import_rules_sparql_1_1.funcExpr1)(l12.buildInHasLangDir);
485
+ const buildInIsTriple = (0, import_rules_sparql_1_1.funcExpr1)(l12.buildInIsTRIPLE);
486
+ const buildInTriple = (0, import_rules_sparql_1_1.funcExpr3)(l12.buildInTRIPLE);
487
+ const buildInSubject = (0, import_rules_sparql_1_1.funcExpr1)(l12.buildInSUBJECT);
488
+ const buildInPredicate = (0, import_rules_sparql_1_1.funcExpr1)(l12.buildInPREDICATE);
489
+ const buildInObject = (0, import_rules_sparql_1_1.funcExpr1)(l12.buildInOBJECT);
490
+ const builtInCall = {
491
+ name: "builtInCall",
492
+ impl: ($) => (C) => $.OR2([
493
+ { ALT: () => import_rules_sparql_1_1.gram.builtInCall.impl($)(C) },
494
+ { ALT: () => $.SUBRULE(buildInLangDir) },
495
+ { ALT: () => $.SUBRULE(buildInLangStrDir) },
496
+ { ALT: () => $.SUBRULE(buildInHasLang) },
497
+ { ALT: () => $.SUBRULE(buildInHasLangDir) },
498
+ { ALT: () => $.SUBRULE(buildInIsTriple) },
499
+ { ALT: () => $.SUBRULE(buildInTriple) },
500
+ { ALT: () => $.SUBRULE(buildInSubject) },
501
+ { ALT: () => $.SUBRULE(buildInPredicate) },
502
+ { ALT: () => $.SUBRULE(buildInObject) }
503
+ ])
504
+ };
505
+ const rdfLiteral = {
506
+ name: "rdfLiteral",
507
+ impl: ({ ACTION, SUBRULE, OPTION, CONSUME, OR }) => (C) => {
508
+ const value = SUBRULE(import_rules_sparql_1_1.gram.string);
509
+ return OPTION(() => OR([
510
+ { ALT: () => {
511
+ const langTag = CONSUME(l12.LANG_DIR);
512
+ return ACTION(() => {
513
+ const literal = C.astFactory.termLiteral(C.astFactory.sourceLocation(value, langTag), value.value, langTag.image.slice(1).toLowerCase());
514
+ (0, import_validators.langTagHasCorrectRange)(literal);
515
+ return literal;
516
+ });
517
+ } },
518
+ { ALT: () => {
519
+ CONSUME(import_rules_sparql_1_1.lex.symbols.hathat);
520
+ const iriVal = SUBRULE(import_rules_sparql_1_1.gram.iri);
521
+ return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
522
+ } }
523
+ ])) ?? value;
524
+ }
525
+ };
526
+ const unaryExpression = {
527
+ name: "unaryExpression",
528
+ impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
529
+ { ALT: () => SUBRULE1(primaryExpression) },
530
+ { ALT: () => {
531
+ const operator = CONSUME(import_rules_sparql_1_1.lex.symbols.exclamation);
532
+ const expr = SUBRULE1(unaryExpression);
533
+ return ACTION(() => C.astFactory.expressionOperation("!", [expr], C.astFactory.sourceLocation(operator, expr)));
534
+ } },
535
+ { ALT: () => {
536
+ const operator = OR2([
537
+ { ALT: () => CONSUME(import_rules_sparql_1_1.lex.symbols.opPlus) },
538
+ { ALT: () => CONSUME(import_rules_sparql_1_1.lex.symbols.opMinus) }
539
+ ]);
540
+ const expr = SUBRULE2(primaryExpression);
541
+ return ACTION(() => C.astFactory.expressionOperation(operator.image === "!" ? "!" : operator.image === "+" ? "UPLUS" : "UMINUS", [expr], C.astFactory.sourceLocation(operator, expr)));
542
+ } }
543
+ ])
544
+ };
545
+ const generateTriplesBlock = {
546
+ name: "triplesBlock",
547
+ gImpl: ({ SUBRULE, PRINT_WORD, NEW_LINE, HANDLE_LOC }) => (ast, { astFactory: F }) => {
548
+ for (const [index, triple] of ast.triples.entries()) {
549
+ HANDLE_LOC(triple, () => {
550
+ const nextTriple = ast.triples.at(index);
551
+ if (F.isTripleCollection(triple)) {
552
+ SUBRULE(graphNodePath, triple);
553
+ F.printFilter(triple, () => {
554
+ PRINT_WORD(".");
555
+ NEW_LINE();
556
+ });
557
+ } else {
558
+ SUBRULE(graphNodePath, triple.subject);
559
+ F.printFilter(ast, () => PRINT_WORD(""));
560
+ if (F.isPathPure(triple.predicate)) {
561
+ SUBRULE(import_rules_sparql_1_1.gram.pathGenerator, triple.predicate, void 0);
562
+ } else {
563
+ SUBRULE(graphNodePath, triple.predicate);
564
+ }
565
+ F.printFilter(ast, () => PRINT_WORD(""));
566
+ SUBRULE(graphNodePath, triple.object);
567
+ SUBRULE(annotationPath, triple.annotations ?? []);
568
+ if (nextTriple === void 0 || F.isTripleCollection(nextTriple) || !F.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
569
+ F.printFilter(ast, () => {
570
+ PRINT_WORD(".");
571
+ NEW_LINE();
572
+ });
573
+ } else if (F.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
574
+ F.printFilter(ast, () => PRINT_WORD(","));
575
+ } else {
576
+ F.printFilter(ast, () => {
577
+ PRINT_WORD(";");
578
+ NEW_LINE();
579
+ });
580
+ }
581
+ }
582
+ });
583
+ }
584
+ }
585
+ };
586
+ const generateGraphTerm = {
587
+ name: "graphTerm",
588
+ gImpl: ($) => (ast, C) => {
589
+ if (C.astFactory.isTermTriple(ast)) {
590
+ $.SUBRULE(tripleTerm, ast);
591
+ } else {
592
+ import_rules_sparql_1_1.gram.graphTerm.gImpl($)(ast, C);
593
+ }
594
+ }
595
+ };
596
+ // Annotate the CommonJS export names for ESM import in node:
597
+ 0 && (module.exports = {
598
+ annotation,
599
+ annotationBlock,
600
+ annotationBlockPath,
601
+ annotationPath,
602
+ buildInHasLang,
603
+ buildInHasLangDir,
604
+ buildInIsTriple,
605
+ buildInLangDir,
606
+ buildInLangStrDir,
607
+ buildInObject,
608
+ buildInPredicate,
609
+ buildInSubject,
610
+ buildInTriple,
611
+ builtInCall,
612
+ dataBlockValue,
613
+ exprTripleTerm,
614
+ exprTripleTermObject,
615
+ exprTripleTermSubject,
616
+ generateGraphTerm,
617
+ generateTriplesBlock,
618
+ graphNode,
619
+ graphNodePath,
620
+ object,
621
+ objectPath,
622
+ primaryExpression,
623
+ prologue,
624
+ rdfLiteral,
625
+ reifiedTriple,
626
+ reifiedTripleBlock,
627
+ reifiedTripleBlockPath,
628
+ reifiedTripleObject,
629
+ reifiedTripleSubject,
630
+ reifier,
631
+ tripleTerm,
632
+ tripleTermData,
633
+ tripleTermDataObject,
634
+ tripleTermDataSubject,
635
+ tripleTermObject,
636
+ tripleTermSubject,
637
+ triplesSameSubject,
638
+ triplesSameSubjectPath,
639
+ unaryExpression,
640
+ varOrReifierId,
641
+ varOrTerm,
642
+ versionDecl,
643
+ versionSpecifier
644
+ });
@@ -0,0 +1,52 @@
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ gram: () => gram,
33
+ lex: () => lex
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+ var gram = __toESM(require("./grammar.js"), 1);
37
+ var lex = __toESM(require("./lexer.js"), 1);
38
+ __reExport(index_exports, require("./sparql12Types.js"), module.exports);
39
+ __reExport(index_exports, require("./sparql12HelperTypes.js"), module.exports);
40
+ __reExport(index_exports, require("./parserUtils.js"), module.exports);
41
+ __reExport(index_exports, require("./AstFactory.js"), module.exports);
42
+ __reExport(index_exports, require("./validators.js"), module.exports);
43
+ // Annotate the CommonJS export names for ESM import in node:
44
+ 0 && (module.exports = {
45
+ gram,
46
+ lex,
47
+ ...require("./sparql12Types.js"),
48
+ ...require("./sparql12HelperTypes.js"),
49
+ ...require("./parserUtils.js"),
50
+ ...require("./AstFactory.js"),
51
+ ...require("./validators.js")
52
+ });