@traqula/rules-sparql-1-2 0.0.23 → 0.0.25

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