@traqula/rules-sparql-1-2 0.0.1-alpha.143 → 0.0.1-alpha.148
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/grammar.d.ts +32 -31
- package/lib/grammar.js +134 -130
- package/lib/grammar.js.map +1 -1
- package/lib/index.cjs +1253 -1258
- package/lib/lexer.d.ts +1 -1
- package/lib/sparql12Types.d.ts +0 -8
- package/lib/sparql12Types.js.map +1 -1
- package/package.json +4 -4
package/lib/grammar.js
CHANGED
|
@@ -12,11 +12,11 @@ function reifiedTripleBlockImpl(name, allowPath) {
|
|
|
12
12
|
return {
|
|
13
13
|
name,
|
|
14
14
|
impl: ({ ACTION, SUBRULE }) => () => {
|
|
15
|
-
const triple = SUBRULE(reifiedTriple);
|
|
16
|
-
const properties = SUBRULE(allowPath ? S11.propertyListPath : S11.propertyList);
|
|
15
|
+
const triple = SUBRULE(reifiedTriple, undefined);
|
|
16
|
+
const properties = SUBRULE(allowPath ? S11.propertyListPath : S11.propertyList, { subject: triple.node });
|
|
17
17
|
return ACTION(() => [
|
|
18
18
|
...triple.triples,
|
|
19
|
-
...properties
|
|
19
|
+
...properties,
|
|
20
20
|
]);
|
|
21
21
|
},
|
|
22
22
|
};
|
|
@@ -35,9 +35,9 @@ export const reifiedTripleBlockPath = reifiedTripleBlockImpl('reifiedTripleBlock
|
|
|
35
35
|
*/
|
|
36
36
|
export const dataBlockValue = {
|
|
37
37
|
name: 'dataBlockValue',
|
|
38
|
-
impl: $ => () => $.OR2([
|
|
39
|
-
{ ALT: () => S11.dataBlockValue.impl($)() },
|
|
40
|
-
{ ALT: () => $.SUBRULE(tripleTermData) },
|
|
38
|
+
impl: $ => (C) => $.OR2([
|
|
39
|
+
{ ALT: () => S11.dataBlockValue.impl($)(C, undefined) },
|
|
40
|
+
{ ALT: () => $.SUBRULE(tripleTermData, undefined) },
|
|
41
41
|
]),
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
@@ -45,14 +45,14 @@ export const dataBlockValue = {
|
|
|
45
45
|
*/
|
|
46
46
|
export const reifier = {
|
|
47
47
|
name: 'reifier',
|
|
48
|
-
impl: ({ ACTION, CONSUME, SUBRULE, OPTION
|
|
48
|
+
impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
|
|
49
49
|
CONSUME(l12.tilde);
|
|
50
|
-
const reifier = OPTION(() => SUBRULE(varOrReifierId));
|
|
50
|
+
const reifier = OPTION(() => SUBRULE(varOrReifierId, undefined));
|
|
51
51
|
return ACTION(() => {
|
|
52
|
-
if (reifier === undefined && !
|
|
52
|
+
if (reifier === undefined && !C.parseMode.has('canCreateBlankNodes')) {
|
|
53
53
|
throw new Error('Cannot create blanknodes in current parse mode');
|
|
54
54
|
}
|
|
55
|
-
return reifier ??
|
|
55
|
+
return reifier ?? C.dataFactory.blankNode();
|
|
56
56
|
});
|
|
57
57
|
},
|
|
58
58
|
};
|
|
@@ -62,17 +62,17 @@ export const reifier = {
|
|
|
62
62
|
export const varOrReifierId = {
|
|
63
63
|
name: 'varOrReifierId',
|
|
64
64
|
impl: ({ SUBRULE, OR }) => () => OR([
|
|
65
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
66
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
67
|
-
{ ALT: () => SUBRULE(S11.blankNode) },
|
|
65
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
66
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
67
|
+
{ ALT: () => SUBRULE(S11.blankNode, undefined) },
|
|
68
68
|
]),
|
|
69
69
|
};
|
|
70
70
|
function triplesSameSubjectImpl(name, allowPaths) {
|
|
71
71
|
return {
|
|
72
72
|
name,
|
|
73
|
-
impl: $ => () => $.OR2([
|
|
74
|
-
{ ALT: () => allowPaths ? S11.triplesSameSubjectPath.impl($)() : S11.triplesSameSubject.impl($)() },
|
|
75
|
-
{ ALT: () => $.SUBRULE(allowPaths ? reifiedTripleBlockPath : reifiedTripleBlock) },
|
|
73
|
+
impl: $ => (C) => $.OR2([
|
|
74
|
+
{ ALT: () => allowPaths ? S11.triplesSameSubjectPath.impl($)(C, undefined) : S11.triplesSameSubject.impl($)(C, undefined) },
|
|
75
|
+
{ ALT: () => $.SUBRULE(allowPaths ? reifiedTripleBlockPath : reifiedTripleBlock, undefined) },
|
|
76
76
|
]),
|
|
77
77
|
};
|
|
78
78
|
}
|
|
@@ -89,24 +89,25 @@ export const triplesSameSubjectPath = triplesSameSubjectImpl('triplesSameSubject
|
|
|
89
89
|
function objectImpl(name, allowPaths) {
|
|
90
90
|
return {
|
|
91
91
|
name,
|
|
92
|
-
impl: ({ ACTION, SUBRULE
|
|
93
|
-
const objectVal = SUBRULE(allowPaths ? graphNodePath : graphNode);
|
|
94
|
-
const annotationVal = SUBRULE(allowPaths ? annotationPath : annotation);
|
|
92
|
+
impl: ({ ACTION, SUBRULE }) => (C, arg) => {
|
|
93
|
+
const objectVal = SUBRULE(allowPaths ? graphNodePath : graphNode, undefined);
|
|
94
|
+
const annotationVal = SUBRULE(allowPaths ? annotationPath : annotation, undefined);
|
|
95
|
+
// This rule knows the annotation. And for each annotation node, we need to make a triple:
|
|
96
|
+
// <annotationNode, reifies, parsedSubjectAndObject>
|
|
95
97
|
return ACTION(() => {
|
|
98
|
+
const { subject, predicate } = arg;
|
|
99
|
+
if ('type' in predicate && predicate.type === 'path' && annotationVal.length > 0) {
|
|
100
|
+
throw new Error('Note 17 violation');
|
|
101
|
+
}
|
|
96
102
|
const result = [
|
|
97
103
|
// You parse the object
|
|
98
|
-
|
|
104
|
+
{ subject, predicate, object: objectVal.node },
|
|
99
105
|
// You might get some additional triples from parsing the object (like when it's a collection)
|
|
100
|
-
...objectVal.triples
|
|
106
|
+
...objectVal.triples,
|
|
101
107
|
];
|
|
102
108
|
for (const annotation of annotationVal) {
|
|
103
|
-
result.push((
|
|
104
|
-
|
|
105
|
-
throw new Error('Note 17 violation');
|
|
106
|
-
}
|
|
107
|
-
return context.dataFactory.quad(annotation.node, context.dataFactory.namedNode(CommonIRIs.REIFIES), context.dataFactory.quad(subject, predicate, objectVal.node));
|
|
108
|
-
});
|
|
109
|
-
result.push(...annotation.triples.map(triple => () => triple));
|
|
109
|
+
result.push(C.dataFactory.quad(annotation.node, C.dataFactory.namedNode(CommonIRIs.REIFIES), C.dataFactory.quad(subject, predicate, objectVal.node)));
|
|
110
|
+
result.push(...annotation.triples);
|
|
110
111
|
}
|
|
111
112
|
return result;
|
|
112
113
|
});
|
|
@@ -126,7 +127,7 @@ export const objectPath = objectImpl('objectPath', true);
|
|
|
126
127
|
function annotationImpl(name, allowPaths) {
|
|
127
128
|
return {
|
|
128
129
|
name,
|
|
129
|
-
impl: ({ ACTION, SUBRULE, OR, MANY
|
|
130
|
+
impl: ({ ACTION, SUBRULE, OR, MANY }) => (C) => {
|
|
130
131
|
const annotations = [];
|
|
131
132
|
let currentReifier;
|
|
132
133
|
function flush() {
|
|
@@ -138,20 +139,23 @@ function annotationImpl(name, allowPaths) {
|
|
|
138
139
|
MANY(() => {
|
|
139
140
|
OR([
|
|
140
141
|
{ ALT: () => {
|
|
141
|
-
const node = SUBRULE(reifier);
|
|
142
|
+
const node = SUBRULE(reifier, undefined);
|
|
142
143
|
ACTION(() => flush());
|
|
143
144
|
currentReifier = node;
|
|
144
145
|
} },
|
|
145
146
|
{ ALT: () => {
|
|
146
|
-
|
|
147
|
+
let node;
|
|
148
|
+
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, { subject: ACTION(() => {
|
|
149
|
+
if (currentReifier === undefined && !C.parseMode.has('canCreateBlankNodes')) {
|
|
150
|
+
throw new Error('Cannot create blanknodes in current parse mode');
|
|
151
|
+
}
|
|
152
|
+
node = currentReifier ?? C.dataFactory.blankNode();
|
|
153
|
+
return node;
|
|
154
|
+
}) });
|
|
147
155
|
ACTION(() => {
|
|
148
|
-
if (currentReifier === undefined && !context.parseMode.has(S11.canCreateBlankNodes)) {
|
|
149
|
-
throw new Error('Cannot create blanknodes in current parse mode');
|
|
150
|
-
}
|
|
151
|
-
const node = currentReifier ?? context.dataFactory.blankNode();
|
|
152
156
|
annotations.push({
|
|
153
157
|
node,
|
|
154
|
-
triples: block
|
|
158
|
+
triples: block,
|
|
155
159
|
});
|
|
156
160
|
currentReifier = undefined;
|
|
157
161
|
});
|
|
@@ -176,9 +180,9 @@ export const annotation = annotationImpl('annotation', false);
|
|
|
176
180
|
function annotationBlockImpl(name, allowPaths) {
|
|
177
181
|
return {
|
|
178
182
|
name,
|
|
179
|
-
impl: ({ SUBRULE, CONSUME }) => () => {
|
|
183
|
+
impl: ({ ACTION, SUBRULE, CONSUME }) => (_, arg) => {
|
|
180
184
|
CONSUME(l12.annotationOpen);
|
|
181
|
-
const res = SUBRULE(allowPaths ? S11.propertyListPathNotEmpty : S11.propertyListNotEmpty);
|
|
185
|
+
const res = SUBRULE(allowPaths ? S11.propertyListPathNotEmpty : S11.propertyListNotEmpty, { subject: ACTION(() => arg.subject) });
|
|
182
186
|
CONSUME(l12.annotationClose);
|
|
183
187
|
return res;
|
|
184
188
|
},
|
|
@@ -198,9 +202,9 @@ export const annotationBlock = annotationBlockImpl('annotationBlock', false);
|
|
|
198
202
|
*/
|
|
199
203
|
export const graphNode = {
|
|
200
204
|
name: 'graphNode',
|
|
201
|
-
impl: $ => () => $.OR2([
|
|
202
|
-
{ ALT: () => S11.graphNode.impl($)() },
|
|
203
|
-
{ ALT: () => $.SUBRULE(reifiedTriple) },
|
|
205
|
+
impl: $ => (C) => $.OR2([
|
|
206
|
+
{ ALT: () => S11.graphNode.impl($)(C, undefined) },
|
|
207
|
+
{ ALT: () => $.SUBRULE(reifiedTriple, undefined) },
|
|
204
208
|
]),
|
|
205
209
|
};
|
|
206
210
|
/**
|
|
@@ -209,9 +213,9 @@ export const graphNode = {
|
|
|
209
213
|
*/
|
|
210
214
|
export const graphNodePath = {
|
|
211
215
|
name: 'graphNodePath',
|
|
212
|
-
impl: $ => () => $.OR2([
|
|
213
|
-
{ ALT: () => S11.graphNodePath.impl($)() },
|
|
214
|
-
{ ALT: () => $.SUBRULE(reifiedTriple) },
|
|
216
|
+
impl: $ => (C) => $.OR2([
|
|
217
|
+
{ ALT: () => S11.graphNodePath.impl($)(C, undefined) },
|
|
218
|
+
{ ALT: () => $.SUBRULE(reifiedTriple, undefined) },
|
|
215
219
|
]),
|
|
216
220
|
};
|
|
217
221
|
/**
|
|
@@ -220,18 +224,18 @@ export const graphNodePath = {
|
|
|
220
224
|
*/
|
|
221
225
|
export const varOrTerm = {
|
|
222
226
|
name: 'varOrTerm',
|
|
223
|
-
impl: ({ SUBRULE, OR, CONSUME
|
|
224
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
225
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
226
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
227
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
228
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
229
|
-
{ ALT: () => SUBRULE(S11.blankNode) },
|
|
227
|
+
impl: ({ ACTION, SUBRULE, OR, CONSUME }) => (C) => OR([
|
|
228
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
229
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
230
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
231
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
232
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
233
|
+
{ ALT: () => SUBRULE(S11.blankNode, undefined) },
|
|
230
234
|
{ ALT: () => {
|
|
231
235
|
CONSUME(l11.terminals.nil);
|
|
232
|
-
return
|
|
236
|
+
return ACTION(() => C.dataFactory.namedNode(CommonIRIs.NIL));
|
|
233
237
|
} },
|
|
234
|
-
{ ALT: () => SUBRULE(tripleTerm) },
|
|
238
|
+
{ ALT: () => SUBRULE(tripleTerm, undefined) },
|
|
235
239
|
]),
|
|
236
240
|
};
|
|
237
241
|
/**
|
|
@@ -239,24 +243,24 @@ export const varOrTerm = {
|
|
|
239
243
|
*/
|
|
240
244
|
export const reifiedTriple = {
|
|
241
245
|
name: 'reifiedTriple',
|
|
242
|
-
impl: ({ ACTION, CONSUME, SUBRULE, OPTION
|
|
246
|
+
impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
|
|
243
247
|
CONSUME(l12.reificationOpen);
|
|
244
|
-
const subject = SUBRULE(reifiedTripleSubject);
|
|
245
|
-
const predicate = SUBRULE(S11.verb);
|
|
246
|
-
const object = SUBRULE(reifiedTripleObject);
|
|
247
|
-
const reifierVal = OPTION(() => SUBRULE(reifier));
|
|
248
|
+
const subject = SUBRULE(reifiedTripleSubject, undefined);
|
|
249
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
250
|
+
const object = SUBRULE(reifiedTripleObject, undefined);
|
|
251
|
+
const reifierVal = OPTION(() => SUBRULE(reifier, undefined));
|
|
248
252
|
CONSUME(l12.reificationClose);
|
|
249
253
|
return ACTION(() => {
|
|
250
|
-
if (reifierVal === undefined && !
|
|
254
|
+
if (reifierVal === undefined && !C.parseMode.has('canCreateBlankNodes')) {
|
|
251
255
|
throw new Error('Cannot create blanknodes in current parse mode');
|
|
252
256
|
}
|
|
253
|
-
const reifier = reifierVal ??
|
|
254
|
-
const tripleTerm =
|
|
257
|
+
const reifier = reifierVal ?? C.dataFactory.blankNode();
|
|
258
|
+
const tripleTerm = C.dataFactory.quad(subject.node, predicate, object.node);
|
|
255
259
|
return {
|
|
256
260
|
node: reifier,
|
|
257
261
|
triples: [
|
|
258
262
|
...subject.triples,
|
|
259
|
-
|
|
263
|
+
C.dataFactory.quad(reifier, C.dataFactory.namedNode(CommonIRIs.REIFIES), tripleTerm),
|
|
260
264
|
...object.triples,
|
|
261
265
|
],
|
|
262
266
|
};
|
|
@@ -269,13 +273,13 @@ export const reifiedTriple = {
|
|
|
269
273
|
export const reifiedTripleSubject = {
|
|
270
274
|
name: 'reifiedTripleSubject',
|
|
271
275
|
impl: ({ OR, SUBRULE }) => () => OR([
|
|
272
|
-
{ ALT: () => ({ node: SUBRULE(S11.var_), triples: [] }) },
|
|
273
|
-
{ ALT: () => ({ node: SUBRULE(S11.iri), triples: [] }) },
|
|
274
|
-
{ ALT: () => ({ node: SUBRULE(rdfLiteral), triples: [] }) },
|
|
275
|
-
{ ALT: () => ({ node: SUBRULE(S11.numericLiteral), triples: [] }) },
|
|
276
|
-
{ ALT: () => ({ node: SUBRULE(S11.booleanLiteral), triples: [] }) },
|
|
277
|
-
{ ALT: () => ({ node: SUBRULE(S11.blankNode), triples: [] }) },
|
|
278
|
-
{ ALT: () => SUBRULE(reifiedTriple) },
|
|
276
|
+
{ ALT: () => ({ node: SUBRULE(S11.var_, undefined), triples: [] }) },
|
|
277
|
+
{ ALT: () => ({ node: SUBRULE(S11.iri, undefined), triples: [] }) },
|
|
278
|
+
{ ALT: () => ({ node: SUBRULE(rdfLiteral, undefined), triples: [] }) },
|
|
279
|
+
{ ALT: () => ({ node: SUBRULE(S11.numericLiteral, undefined), triples: [] }) },
|
|
280
|
+
{ ALT: () => ({ node: SUBRULE(S11.booleanLiteral, undefined), triples: [] }) },
|
|
281
|
+
{ ALT: () => ({ node: SUBRULE(S11.blankNode, undefined), triples: [] }) },
|
|
282
|
+
{ ALT: () => SUBRULE(reifiedTriple, undefined) },
|
|
279
283
|
]),
|
|
280
284
|
};
|
|
281
285
|
/**
|
|
@@ -283,9 +287,9 @@ export const reifiedTripleSubject = {
|
|
|
283
287
|
*/
|
|
284
288
|
export const reifiedTripleObject = {
|
|
285
289
|
name: 'reifiedTripleObject',
|
|
286
|
-
impl: $ => () => $.OR2([
|
|
287
|
-
{ ALT: () => reifiedTripleSubject.impl($)() },
|
|
288
|
-
{ ALT: () => ({ node: $.SUBRULE(tripleTerm), triples: [] }) },
|
|
290
|
+
impl: $ => (C) => $.OR2([
|
|
291
|
+
{ ALT: () => reifiedTripleSubject.impl($)(C, undefined) },
|
|
292
|
+
{ ALT: () => ({ node: $.SUBRULE(tripleTerm, undefined), triples: [] }) },
|
|
289
293
|
]),
|
|
290
294
|
};
|
|
291
295
|
/**
|
|
@@ -293,13 +297,13 @@ export const reifiedTripleObject = {
|
|
|
293
297
|
*/
|
|
294
298
|
export const tripleTerm = {
|
|
295
299
|
name: 'tripleTerm',
|
|
296
|
-
impl: ({ CONSUME, SUBRULE
|
|
300
|
+
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
297
301
|
CONSUME(l12.tripleTermOpen);
|
|
298
|
-
const subject = SUBRULE(tripleTermSubject);
|
|
299
|
-
const predicate = SUBRULE(S11.verb);
|
|
300
|
-
const object = SUBRULE(tripleTermObject);
|
|
302
|
+
const subject = SUBRULE(tripleTermSubject, undefined);
|
|
303
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
304
|
+
const object = SUBRULE(tripleTermObject, undefined);
|
|
301
305
|
CONSUME(l12.tripleTermClose);
|
|
302
|
-
return
|
|
306
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
303
307
|
},
|
|
304
308
|
};
|
|
305
309
|
/**
|
|
@@ -308,12 +312,12 @@ export const tripleTerm = {
|
|
|
308
312
|
export const tripleTermSubject = {
|
|
309
313
|
name: 'tripleTermSubject',
|
|
310
314
|
impl: ({ SUBRULE, OR }) => () => OR([
|
|
311
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
312
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
313
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
314
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
315
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
316
|
-
{ ALT: () => SUBRULE(S11.blankNode) },
|
|
315
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
316
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
317
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
318
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
319
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
320
|
+
{ ALT: () => SUBRULE(S11.blankNode, undefined) },
|
|
317
321
|
]),
|
|
318
322
|
};
|
|
319
323
|
/**
|
|
@@ -321,9 +325,9 @@ export const tripleTermSubject = {
|
|
|
321
325
|
*/
|
|
322
326
|
export const tripleTermObject = {
|
|
323
327
|
name: 'tripleTermObject',
|
|
324
|
-
impl: $ => () => $.OR2([
|
|
325
|
-
{ ALT: () => tripleTermSubject.impl($)() },
|
|
326
|
-
{ ALT: () => $.SUBRULE(tripleTerm) },
|
|
328
|
+
impl: $ => (C) => $.OR2([
|
|
329
|
+
{ ALT: () => tripleTermSubject.impl($)(C, undefined) },
|
|
330
|
+
{ ALT: () => $.SUBRULE(tripleTerm, undefined) },
|
|
327
331
|
]),
|
|
328
332
|
};
|
|
329
333
|
/**
|
|
@@ -331,19 +335,19 @@ export const tripleTermObject = {
|
|
|
331
335
|
*/
|
|
332
336
|
export const tripleTermData = {
|
|
333
337
|
name: 'tripleTermData',
|
|
334
|
-
impl: ({ ACTION, CONSUME, OR, SUBRULE
|
|
338
|
+
impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
|
|
335
339
|
CONSUME(l12.tripleTermOpen);
|
|
336
|
-
const subject = SUBRULE(tripleTermDataSubject);
|
|
340
|
+
const subject = SUBRULE(tripleTermDataSubject, undefined);
|
|
337
341
|
const predicate = OR([
|
|
338
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
342
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
339
343
|
{ ALT: () => {
|
|
340
344
|
CONSUME(l11.a);
|
|
341
|
-
return ACTION(() =>
|
|
345
|
+
return ACTION(() => C.dataFactory.namedNode(CommonIRIs.TYPE));
|
|
342
346
|
} },
|
|
343
347
|
]);
|
|
344
|
-
const object = SUBRULE(tripleTermDataObject);
|
|
348
|
+
const object = SUBRULE(tripleTermDataObject, undefined);
|
|
345
349
|
CONSUME(l12.tripleTermClose);
|
|
346
|
-
return ACTION(() =>
|
|
350
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
347
351
|
},
|
|
348
352
|
};
|
|
349
353
|
/**
|
|
@@ -352,10 +356,10 @@ export const tripleTermData = {
|
|
|
352
356
|
export const tripleTermDataSubject = {
|
|
353
357
|
name: 'tripleTermDataSubject',
|
|
354
358
|
impl: ({ OR, SUBRULE }) => () => OR([
|
|
355
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
356
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
357
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
358
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
359
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
360
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
361
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
362
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
359
363
|
]),
|
|
360
364
|
};
|
|
361
365
|
/**
|
|
@@ -363,9 +367,9 @@ export const tripleTermDataSubject = {
|
|
|
363
367
|
*/
|
|
364
368
|
export const tripleTermDataObject = {
|
|
365
369
|
name: 'tripleTermDataObject',
|
|
366
|
-
impl: $ => () => $.OR2([
|
|
367
|
-
{ ALT: () => tripleTermDataSubject.impl($)() },
|
|
368
|
-
{ ALT: () => $.SUBRULE(tripleTermData) },
|
|
370
|
+
impl: $ => (C) => $.OR2([
|
|
371
|
+
{ ALT: () => tripleTermDataSubject.impl($)(C, undefined) },
|
|
372
|
+
{ ALT: () => $.SUBRULE(tripleTermData, undefined) },
|
|
369
373
|
]),
|
|
370
374
|
};
|
|
371
375
|
/**
|
|
@@ -374,9 +378,9 @@ export const tripleTermDataObject = {
|
|
|
374
378
|
*/
|
|
375
379
|
export const primaryExpression = {
|
|
376
380
|
name: 'primaryExpression',
|
|
377
|
-
impl: $ => () => $.OR2([
|
|
378
|
-
{ ALT: () => S11.primaryExpression.impl($)() },
|
|
379
|
-
{ ALT: () => $.SUBRULE(exprTripleTerm) },
|
|
381
|
+
impl: $ => (C) => $.OR2([
|
|
382
|
+
{ ALT: () => S11.primaryExpression.impl($)(C, undefined) },
|
|
383
|
+
{ ALT: () => $.SUBRULE(exprTripleTerm, undefined) },
|
|
380
384
|
]),
|
|
381
385
|
};
|
|
382
386
|
/**
|
|
@@ -384,13 +388,13 @@ export const primaryExpression = {
|
|
|
384
388
|
*/
|
|
385
389
|
export const exprTripleTerm = {
|
|
386
390
|
name: 'exprTripleTerm',
|
|
387
|
-
impl: ({ ACTION, CONSUME, SUBRULE
|
|
391
|
+
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
388
392
|
CONSUME(l12.tripleTermOpen);
|
|
389
|
-
const subject = SUBRULE(exprTripleTermSubject);
|
|
390
|
-
const predicate = SUBRULE(S11.verb);
|
|
391
|
-
const object = SUBRULE(exprTripleTermObject);
|
|
393
|
+
const subject = SUBRULE(exprTripleTermSubject, undefined);
|
|
394
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
395
|
+
const object = SUBRULE(exprTripleTermObject, undefined);
|
|
392
396
|
CONSUME(l12.tripleTermClose);
|
|
393
|
-
return ACTION(() =>
|
|
397
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
394
398
|
},
|
|
395
399
|
};
|
|
396
400
|
/**
|
|
@@ -399,11 +403,11 @@ export const exprTripleTerm = {
|
|
|
399
403
|
export const exprTripleTermSubject = {
|
|
400
404
|
name: 'exprTripleTermSubject',
|
|
401
405
|
impl: ({ OR, SUBRULE }) => () => OR([
|
|
402
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
403
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
404
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
405
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
406
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
406
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
407
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
408
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
409
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
410
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
407
411
|
]),
|
|
408
412
|
};
|
|
409
413
|
/**
|
|
@@ -411,9 +415,9 @@ export const exprTripleTermSubject = {
|
|
|
411
415
|
*/
|
|
412
416
|
export const exprTripleTermObject = {
|
|
413
417
|
name: 'exprTripleTermObject',
|
|
414
|
-
impl: $ => () => $.OR2([
|
|
415
|
-
{ ALT: () => exprTripleTermSubject.impl($)() },
|
|
416
|
-
{ ALT: () => $.SUBRULE(exprTripleTerm) },
|
|
418
|
+
impl: $ => (C) => $.OR2([
|
|
419
|
+
{ ALT: () => exprTripleTermSubject.impl($)(C, undefined) },
|
|
420
|
+
{ ALT: () => $.SUBRULE(exprTripleTerm, undefined) },
|
|
417
421
|
]),
|
|
418
422
|
};
|
|
419
423
|
export const builtinLangDir = funcExpr1(l12.builtinLangDir);
|
|
@@ -431,17 +435,17 @@ export const builtinObject = funcExpr1(l12.builtinOBJECT);
|
|
|
431
435
|
*/
|
|
432
436
|
export const builtInCall = {
|
|
433
437
|
name: 'builtInCall',
|
|
434
|
-
impl: $ => () => $.OR2([
|
|
435
|
-
{ ALT: () => S11.builtInCall.impl($)() },
|
|
436
|
-
{ ALT: () => $.SUBRULE(builtinLangDir) },
|
|
437
|
-
{ ALT: () => $.SUBRULE(builtinLangStrDir) },
|
|
438
|
-
{ ALT: () => $.SUBRULE(builtinHasLang) },
|
|
439
|
-
{ ALT: () => $.SUBRULE(builtinHasLangDir) },
|
|
440
|
-
{ ALT: () => $.SUBRULE(builtinIsTriple) },
|
|
441
|
-
{ ALT: () => $.SUBRULE(builtinTriple) },
|
|
442
|
-
{ ALT: () => $.SUBRULE(builtinSubject) },
|
|
443
|
-
{ ALT: () => $.SUBRULE(builtinPredicate) },
|
|
444
|
-
{ ALT: () => $.SUBRULE(builtinObject) },
|
|
438
|
+
impl: $ => (C) => $.OR2([
|
|
439
|
+
{ ALT: () => S11.builtInCall.impl($)(C, undefined) },
|
|
440
|
+
{ ALT: () => $.SUBRULE(builtinLangDir, undefined) },
|
|
441
|
+
{ ALT: () => $.SUBRULE(builtinLangStrDir, undefined) },
|
|
442
|
+
{ ALT: () => $.SUBRULE(builtinHasLang, undefined) },
|
|
443
|
+
{ ALT: () => $.SUBRULE(builtinHasLangDir, undefined) },
|
|
444
|
+
{ ALT: () => $.SUBRULE(builtinIsTriple, undefined) },
|
|
445
|
+
{ ALT: () => $.SUBRULE(builtinTriple, undefined) },
|
|
446
|
+
{ ALT: () => $.SUBRULE(builtinSubject, undefined) },
|
|
447
|
+
{ ALT: () => $.SUBRULE(builtinPredicate, undefined) },
|
|
448
|
+
{ ALT: () => $.SUBRULE(builtinObject, undefined) },
|
|
445
449
|
]),
|
|
446
450
|
};
|
|
447
451
|
function isLangDir(dir) {
|
|
@@ -454,8 +458,8 @@ function isLangDir(dir) {
|
|
|
454
458
|
*/
|
|
455
459
|
export const rdfLiteral = {
|
|
456
460
|
name: 'rdfLiteral',
|
|
457
|
-
impl: ({ ACTION, SUBRULE, OPTION, CONSUME, OR
|
|
458
|
-
const value = SUBRULE(S11.string);
|
|
461
|
+
impl: ({ ACTION, SUBRULE, OPTION, CONSUME, OR }) => (C) => {
|
|
462
|
+
const value = SUBRULE(S11.string, undefined);
|
|
459
463
|
const langOrDataType = OPTION(() => OR([
|
|
460
464
|
{ ALT: () => {
|
|
461
465
|
const langTag = CONSUME(l12.LANG_DIR).image.slice(1);
|
|
@@ -476,10 +480,10 @@ export const rdfLiteral = {
|
|
|
476
480
|
} },
|
|
477
481
|
{ ALT: () => {
|
|
478
482
|
CONSUME(l11.symbols.hathat);
|
|
479
|
-
return SUBRULE(S11.iri);
|
|
483
|
+
return SUBRULE(S11.iri, undefined);
|
|
480
484
|
} },
|
|
481
485
|
]));
|
|
482
|
-
return
|
|
486
|
+
return ACTION(() => C.dataFactory.literal(value, langOrDataType));
|
|
483
487
|
},
|
|
484
488
|
};
|
|
485
489
|
//# sourceMappingURL=grammar.js.map
|