@traqula/rules-sparql-1-2 0.0.1-alpha.145 → 0.0.1-alpha.176
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/README.md +5 -3
- package/lib/grammar.d.ts +73 -31
- package/lib/grammar.js +148 -125
- package/lib/grammar.js.map +1 -1
- package/lib/index.cjs +2564 -2054
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/lexer.d.ts +18 -52
- package/lib/lexer.js +2 -3
- package/lib/lexer.js.map +1 -1
- package/lib/sparql12Types.d.ts +149 -16
- package/lib/sparql12Types.js.map +1 -1
- package/package.json +12 -12
package/lib/grammar.js
CHANGED
|
@@ -4,16 +4,14 @@
|
|
|
4
4
|
* Rules in this module redefine the return type of core grammar rules.
|
|
5
5
|
* It is therefore essential that the parser retypes the rules from the core grammar.
|
|
6
6
|
*/
|
|
7
|
+
import { funcExpr1, funcExpr3, gram as S11, lex as l11, CommonIRIs } from '@traqula/rules-sparql-1-1';
|
|
7
8
|
import * as l12 from './lexer';
|
|
8
|
-
import { funcExpr1, funcExpr3 } from '@traqula/rules-sparql-1-1';
|
|
9
|
-
import { gram as S11, lex as l11 } from '@traqula/rules-sparql-1-1';
|
|
10
|
-
import { CommonIRIs } from '@traqula/core';
|
|
11
9
|
function reifiedTripleBlockImpl(name, allowPath) {
|
|
12
10
|
return {
|
|
13
11
|
name,
|
|
14
12
|
impl: ({ ACTION, SUBRULE }) => () => {
|
|
15
|
-
const triple = SUBRULE(reifiedTriple);
|
|
16
|
-
const properties = SUBRULE(allowPath ? S11.propertyListPath : S11.propertyList, triple.node);
|
|
13
|
+
const triple = SUBRULE(reifiedTriple, undefined);
|
|
14
|
+
const properties = SUBRULE(allowPath ? S11.propertyListPath : S11.propertyList, { subject: triple.node });
|
|
17
15
|
return ACTION(() => [
|
|
18
16
|
...triple.triples,
|
|
19
17
|
...properties,
|
|
@@ -35,24 +33,30 @@ export const reifiedTripleBlockPath = reifiedTripleBlockImpl('reifiedTripleBlock
|
|
|
35
33
|
*/
|
|
36
34
|
export const dataBlockValue = {
|
|
37
35
|
name: 'dataBlockValue',
|
|
38
|
-
impl: $ =>
|
|
39
|
-
{ ALT: () => S11.dataBlockValue.impl($)() },
|
|
40
|
-
{ ALT: () => $.SUBRULE(tripleTermData) },
|
|
36
|
+
impl: $ => C => $.OR2([
|
|
37
|
+
{ ALT: () => S11.dataBlockValue.impl($)(C, undefined) },
|
|
38
|
+
{ ALT: () => $.SUBRULE(tripleTermData, undefined) },
|
|
41
39
|
]),
|
|
40
|
+
gImpl: ({ SUBRULE }) => (ast) => {
|
|
41
|
+
if (ast) {
|
|
42
|
+
return SUBRULE(varOrTerm, ast, undefined);
|
|
43
|
+
}
|
|
44
|
+
return 'UNDEF';
|
|
45
|
+
},
|
|
42
46
|
};
|
|
43
47
|
/**
|
|
44
48
|
* [[68]](https://www.w3.org/TR/sparql12-query/#rReifier)
|
|
45
49
|
*/
|
|
46
50
|
export const reifier = {
|
|
47
51
|
name: 'reifier',
|
|
48
|
-
impl: ({ ACTION, CONSUME, SUBRULE, OPTION
|
|
52
|
+
impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
|
|
49
53
|
CONSUME(l12.tilde);
|
|
50
|
-
const reifier = OPTION(() => SUBRULE(varOrReifierId));
|
|
54
|
+
const reifier = OPTION(() => SUBRULE(varOrReifierId, undefined));
|
|
51
55
|
return ACTION(() => {
|
|
52
|
-
if (reifier === undefined && !
|
|
56
|
+
if (reifier === undefined && !C.parseMode.has('canCreateBlankNodes')) {
|
|
53
57
|
throw new Error('Cannot create blanknodes in current parse mode');
|
|
54
58
|
}
|
|
55
|
-
return reifier ??
|
|
59
|
+
return reifier ?? C.dataFactory.blankNode();
|
|
56
60
|
});
|
|
57
61
|
},
|
|
58
62
|
};
|
|
@@ -62,17 +66,19 @@ export const reifier = {
|
|
|
62
66
|
export const varOrReifierId = {
|
|
63
67
|
name: 'varOrReifierId',
|
|
64
68
|
impl: ({ SUBRULE, OR }) => () => OR([
|
|
65
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
66
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
67
|
-
{ ALT: () => SUBRULE(S11.blankNode) },
|
|
69
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
70
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
71
|
+
{ ALT: () => SUBRULE(S11.blankNode, undefined) },
|
|
68
72
|
]),
|
|
69
73
|
};
|
|
70
74
|
function triplesSameSubjectImpl(name, allowPaths) {
|
|
71
75
|
return {
|
|
72
76
|
name,
|
|
73
|
-
impl: $ =>
|
|
74
|
-
{ ALT: () => allowPaths ?
|
|
75
|
-
|
|
77
|
+
impl: $ => C => $.OR2([
|
|
78
|
+
{ ALT: () => allowPaths ?
|
|
79
|
+
S11.triplesSameSubjectPath.impl($)(C, undefined) :
|
|
80
|
+
S11.triplesSameSubject.impl($)(C, undefined) },
|
|
81
|
+
{ ALT: () => $.SUBRULE(allowPaths ? reifiedTripleBlockPath : reifiedTripleBlock, undefined) },
|
|
76
82
|
]),
|
|
77
83
|
};
|
|
78
84
|
}
|
|
@@ -89,12 +95,13 @@ export const triplesSameSubjectPath = triplesSameSubjectImpl('triplesSameSubject
|
|
|
89
95
|
function objectImpl(name, allowPaths) {
|
|
90
96
|
return {
|
|
91
97
|
name,
|
|
92
|
-
impl: ({ ACTION, SUBRULE
|
|
93
|
-
const objectVal = SUBRULE(allowPaths ? graphNodePath : graphNode);
|
|
94
|
-
const annotationVal = SUBRULE(allowPaths ? annotationPath : annotation);
|
|
98
|
+
impl: ({ ACTION, SUBRULE }) => (C, arg) => {
|
|
99
|
+
const objectVal = SUBRULE(allowPaths ? graphNodePath : graphNode, undefined);
|
|
100
|
+
const annotationVal = SUBRULE(allowPaths ? annotationPath : annotation, undefined);
|
|
95
101
|
// This rule knows the annotation. And for each annotation node, we need to make a triple:
|
|
96
102
|
// <annotationNode, reifies, parsedSubjectAndObject>
|
|
97
103
|
return ACTION(() => {
|
|
104
|
+
const { subject, predicate } = arg;
|
|
98
105
|
if ('type' in predicate && predicate.type === 'path' && annotationVal.length > 0) {
|
|
99
106
|
throw new Error('Note 17 violation');
|
|
100
107
|
}
|
|
@@ -105,7 +112,7 @@ function objectImpl(name, allowPaths) {
|
|
|
105
112
|
...objectVal.triples,
|
|
106
113
|
];
|
|
107
114
|
for (const annotation of annotationVal) {
|
|
108
|
-
result.push(
|
|
115
|
+
result.push(C.dataFactory.quad(annotation.node, C.dataFactory.namedNode(CommonIRIs.REIFIES), C.dataFactory.quad(subject, predicate, objectVal.node)));
|
|
109
116
|
result.push(...annotation.triples);
|
|
110
117
|
}
|
|
111
118
|
return result;
|
|
@@ -126,7 +133,7 @@ export const objectPath = objectImpl('objectPath', true);
|
|
|
126
133
|
function annotationImpl(name, allowPaths) {
|
|
127
134
|
return {
|
|
128
135
|
name,
|
|
129
|
-
impl: ({ ACTION, SUBRULE, OR, MANY
|
|
136
|
+
impl: ({ ACTION, SUBRULE, OR, MANY }) => (C) => {
|
|
130
137
|
const annotations = [];
|
|
131
138
|
let currentReifier;
|
|
132
139
|
function flush() {
|
|
@@ -138,19 +145,19 @@ function annotationImpl(name, allowPaths) {
|
|
|
138
145
|
MANY(() => {
|
|
139
146
|
OR([
|
|
140
147
|
{ ALT: () => {
|
|
141
|
-
const node = SUBRULE(reifier);
|
|
148
|
+
const node = SUBRULE(reifier, undefined);
|
|
142
149
|
ACTION(() => flush());
|
|
143
150
|
currentReifier = node;
|
|
144
151
|
} },
|
|
145
152
|
{ ALT: () => {
|
|
146
153
|
let node;
|
|
147
|
-
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, ACTION(() => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, { subject: ACTION(() => {
|
|
155
|
+
if (currentReifier === undefined && !C.parseMode.has('canCreateBlankNodes')) {
|
|
156
|
+
throw new Error('Cannot create blanknodes in current parse mode');
|
|
157
|
+
}
|
|
158
|
+
node = currentReifier ?? C.dataFactory.blankNode();
|
|
159
|
+
return node;
|
|
160
|
+
}) });
|
|
154
161
|
ACTION(() => {
|
|
155
162
|
annotations.push({
|
|
156
163
|
node,
|
|
@@ -179,9 +186,9 @@ export const annotation = annotationImpl('annotation', false);
|
|
|
179
186
|
function annotationBlockImpl(name, allowPaths) {
|
|
180
187
|
return {
|
|
181
188
|
name,
|
|
182
|
-
impl: ({ SUBRULE, CONSUME }) => (
|
|
189
|
+
impl: ({ ACTION, SUBRULE, CONSUME }) => (_, arg) => {
|
|
183
190
|
CONSUME(l12.annotationOpen);
|
|
184
|
-
const res = SUBRULE(allowPaths ? S11.propertyListPathNotEmpty : S11.propertyListNotEmpty, subject);
|
|
191
|
+
const res = SUBRULE(allowPaths ? S11.propertyListPathNotEmpty : S11.propertyListNotEmpty, { subject: ACTION(() => arg.subject) });
|
|
185
192
|
CONSUME(l12.annotationClose);
|
|
186
193
|
return res;
|
|
187
194
|
},
|
|
@@ -201,9 +208,9 @@ export const annotationBlock = annotationBlockImpl('annotationBlock', false);
|
|
|
201
208
|
*/
|
|
202
209
|
export const graphNode = {
|
|
203
210
|
name: 'graphNode',
|
|
204
|
-
impl: $ =>
|
|
205
|
-
{ ALT: () => S11.graphNode.impl($)() },
|
|
206
|
-
{ ALT: () => $.SUBRULE(reifiedTriple) },
|
|
211
|
+
impl: $ => C => $.OR2([
|
|
212
|
+
{ ALT: () => S11.graphNode.impl($)(C, undefined) },
|
|
213
|
+
{ ALT: () => $.SUBRULE(reifiedTriple, undefined) },
|
|
207
214
|
]),
|
|
208
215
|
};
|
|
209
216
|
/**
|
|
@@ -212,9 +219,9 @@ export const graphNode = {
|
|
|
212
219
|
*/
|
|
213
220
|
export const graphNodePath = {
|
|
214
221
|
name: 'graphNodePath',
|
|
215
|
-
impl: $ =>
|
|
216
|
-
{ ALT: () => S11.graphNodePath.impl($)() },
|
|
217
|
-
{ ALT: () => $.SUBRULE(reifiedTriple) },
|
|
222
|
+
impl: $ => C => $.OR2([
|
|
223
|
+
{ ALT: () => S11.graphNodePath.impl($)(C, undefined) },
|
|
224
|
+
{ ALT: () => $.SUBRULE(reifiedTriple, undefined) },
|
|
218
225
|
]),
|
|
219
226
|
};
|
|
220
227
|
/**
|
|
@@ -223,43 +230,58 @@ export const graphNodePath = {
|
|
|
223
230
|
*/
|
|
224
231
|
export const varOrTerm = {
|
|
225
232
|
name: 'varOrTerm',
|
|
226
|
-
impl: ({ SUBRULE, OR, CONSUME
|
|
227
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
228
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
229
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
230
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
231
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
232
|
-
{ ALT: () => SUBRULE(S11.blankNode) },
|
|
233
|
+
impl: ({ ACTION, SUBRULE, OR, CONSUME }) => C => OR([
|
|
234
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
235
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
236
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
237
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
238
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
239
|
+
{ ALT: () => SUBRULE(S11.blankNode, undefined) },
|
|
233
240
|
{ ALT: () => {
|
|
234
241
|
CONSUME(l11.terminals.nil);
|
|
235
|
-
return
|
|
242
|
+
return ACTION(() => C.dataFactory.namedNode(CommonIRIs.NIL));
|
|
236
243
|
} },
|
|
237
|
-
{ ALT: () => SUBRULE(tripleTerm) },
|
|
244
|
+
{ ALT: () => SUBRULE(tripleTerm, undefined) },
|
|
238
245
|
]),
|
|
246
|
+
gImpl: ({ SUBRULE }) => (ast) => {
|
|
247
|
+
if (ast.termType === 'Variable') {
|
|
248
|
+
return SUBRULE(S11.var_, ast, undefined);
|
|
249
|
+
}
|
|
250
|
+
if (ast.termType === 'NamedNode') {
|
|
251
|
+
return SUBRULE(S11.iri, ast, undefined);
|
|
252
|
+
}
|
|
253
|
+
if (ast.termType === 'BlankNode') {
|
|
254
|
+
return SUBRULE(S11.blankNode, ast, undefined);
|
|
255
|
+
}
|
|
256
|
+
if (ast.termType === 'Quad') {
|
|
257
|
+
return SUBRULE(tripleTerm, ast, undefined);
|
|
258
|
+
}
|
|
259
|
+
return SUBRULE(S11.rdfLiteral, ast, undefined);
|
|
260
|
+
},
|
|
239
261
|
};
|
|
240
262
|
/**
|
|
241
263
|
* [[114]](https://www.w3.org/TR/sparql12-query/#rReifiedTriple)
|
|
242
264
|
*/
|
|
243
265
|
export const reifiedTriple = {
|
|
244
266
|
name: 'reifiedTriple',
|
|
245
|
-
impl: ({ ACTION, CONSUME, SUBRULE, OPTION
|
|
267
|
+
impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
|
|
246
268
|
CONSUME(l12.reificationOpen);
|
|
247
|
-
const subject = SUBRULE(reifiedTripleSubject);
|
|
248
|
-
const predicate = SUBRULE(S11.verb);
|
|
249
|
-
const object = SUBRULE(reifiedTripleObject);
|
|
250
|
-
const reifierVal = OPTION(() => SUBRULE(reifier));
|
|
269
|
+
const subject = SUBRULE(reifiedTripleSubject, undefined);
|
|
270
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
271
|
+
const object = SUBRULE(reifiedTripleObject, undefined);
|
|
272
|
+
const reifierVal = OPTION(() => SUBRULE(reifier, undefined));
|
|
251
273
|
CONSUME(l12.reificationClose);
|
|
252
274
|
return ACTION(() => {
|
|
253
|
-
if (reifierVal === undefined && !
|
|
275
|
+
if (reifierVal === undefined && !C.parseMode.has('canCreateBlankNodes')) {
|
|
254
276
|
throw new Error('Cannot create blanknodes in current parse mode');
|
|
255
277
|
}
|
|
256
|
-
const reifier = reifierVal ??
|
|
257
|
-
const tripleTerm =
|
|
278
|
+
const reifier = reifierVal ?? C.dataFactory.blankNode();
|
|
279
|
+
const tripleTerm = C.dataFactory.quad(subject.node, predicate, object.node);
|
|
258
280
|
return {
|
|
259
281
|
node: reifier,
|
|
260
282
|
triples: [
|
|
261
283
|
...subject.triples,
|
|
262
|
-
|
|
284
|
+
C.dataFactory.quad(reifier, C.dataFactory.namedNode(CommonIRIs.REIFIES), tripleTerm),
|
|
263
285
|
...object.triples,
|
|
264
286
|
],
|
|
265
287
|
};
|
|
@@ -272,13 +294,13 @@ export const reifiedTriple = {
|
|
|
272
294
|
export const reifiedTripleSubject = {
|
|
273
295
|
name: 'reifiedTripleSubject',
|
|
274
296
|
impl: ({ OR, SUBRULE }) => () => OR([
|
|
275
|
-
{ ALT: () => ({ node: SUBRULE(S11.var_), triples: [] }) },
|
|
276
|
-
{ ALT: () => ({ node: SUBRULE(S11.iri), triples: [] }) },
|
|
277
|
-
{ ALT: () => ({ node: SUBRULE(rdfLiteral), triples: [] }) },
|
|
278
|
-
{ ALT: () => ({ node: SUBRULE(S11.numericLiteral), triples: [] }) },
|
|
279
|
-
{ ALT: () => ({ node: SUBRULE(S11.booleanLiteral), triples: [] }) },
|
|
280
|
-
{ ALT: () => ({ node: SUBRULE(S11.blankNode), triples: [] }) },
|
|
281
|
-
{ ALT: () => SUBRULE(reifiedTriple) },
|
|
297
|
+
{ ALT: () => ({ node: SUBRULE(S11.var_, undefined), triples: [] }) },
|
|
298
|
+
{ ALT: () => ({ node: SUBRULE(S11.iri, undefined), triples: [] }) },
|
|
299
|
+
{ ALT: () => ({ node: SUBRULE(rdfLiteral, undefined), triples: [] }) },
|
|
300
|
+
{ ALT: () => ({ node: SUBRULE(S11.numericLiteral, undefined), triples: [] }) },
|
|
301
|
+
{ ALT: () => ({ node: SUBRULE(S11.booleanLiteral, undefined), triples: [] }) },
|
|
302
|
+
{ ALT: () => ({ node: SUBRULE(S11.blankNode, undefined), triples: [] }) },
|
|
303
|
+
{ ALT: () => SUBRULE(reifiedTriple, undefined) },
|
|
282
304
|
]),
|
|
283
305
|
};
|
|
284
306
|
/**
|
|
@@ -286,9 +308,9 @@ export const reifiedTripleSubject = {
|
|
|
286
308
|
*/
|
|
287
309
|
export const reifiedTripleObject = {
|
|
288
310
|
name: 'reifiedTripleObject',
|
|
289
|
-
impl: $ =>
|
|
290
|
-
{ ALT: () => reifiedTripleSubject.impl($)() },
|
|
291
|
-
{ ALT: () => ({ node: $.SUBRULE(tripleTerm), triples: [] }) },
|
|
311
|
+
impl: $ => C => $.OR2([
|
|
312
|
+
{ ALT: () => reifiedTripleSubject.impl($)(C, undefined) },
|
|
313
|
+
{ ALT: () => ({ node: $.SUBRULE(tripleTerm, undefined), triples: [] }) },
|
|
292
314
|
]),
|
|
293
315
|
};
|
|
294
316
|
/**
|
|
@@ -296,14 +318,15 @@ export const reifiedTripleObject = {
|
|
|
296
318
|
*/
|
|
297
319
|
export const tripleTerm = {
|
|
298
320
|
name: 'tripleTerm',
|
|
299
|
-
impl: ({ CONSUME, SUBRULE
|
|
321
|
+
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
300
322
|
CONSUME(l12.tripleTermOpen);
|
|
301
|
-
const subject = SUBRULE(tripleTermSubject);
|
|
302
|
-
const predicate = SUBRULE(S11.verb);
|
|
303
|
-
const object = SUBRULE(tripleTermObject);
|
|
323
|
+
const subject = SUBRULE(tripleTermSubject, undefined);
|
|
324
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
325
|
+
const object = SUBRULE(tripleTermObject, undefined);
|
|
304
326
|
CONSUME(l12.tripleTermClose);
|
|
305
|
-
return
|
|
327
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
306
328
|
},
|
|
329
|
+
gImpl: ({ SUBRULE }) => ast => `<<( ${SUBRULE(varOrTerm, ast.subject, undefined)} ${SUBRULE(varOrTerm, ast.predicate, undefined)} ${SUBRULE(varOrTerm, ast.object, undefined)} )>>`,
|
|
307
330
|
};
|
|
308
331
|
/**
|
|
309
332
|
* [[118]](https://www.w3.org/TR/sparql12-query/#rTripleTermSubject)
|
|
@@ -311,12 +334,12 @@ export const tripleTerm = {
|
|
|
311
334
|
export const tripleTermSubject = {
|
|
312
335
|
name: 'tripleTermSubject',
|
|
313
336
|
impl: ({ SUBRULE, OR }) => () => OR([
|
|
314
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
315
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
316
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
317
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
318
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
319
|
-
{ ALT: () => SUBRULE(S11.blankNode) },
|
|
337
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
338
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
339
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
340
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
341
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
342
|
+
{ ALT: () => SUBRULE(S11.blankNode, undefined) },
|
|
320
343
|
]),
|
|
321
344
|
};
|
|
322
345
|
/**
|
|
@@ -324,9 +347,9 @@ export const tripleTermSubject = {
|
|
|
324
347
|
*/
|
|
325
348
|
export const tripleTermObject = {
|
|
326
349
|
name: 'tripleTermObject',
|
|
327
|
-
impl: $ =>
|
|
328
|
-
{ ALT: () => tripleTermSubject.impl($)() },
|
|
329
|
-
{ ALT: () => $.SUBRULE(tripleTerm) },
|
|
350
|
+
impl: $ => C => $.OR2([
|
|
351
|
+
{ ALT: () => tripleTermSubject.impl($)(C, undefined) },
|
|
352
|
+
{ ALT: () => $.SUBRULE(tripleTerm, undefined) },
|
|
330
353
|
]),
|
|
331
354
|
};
|
|
332
355
|
/**
|
|
@@ -334,19 +357,19 @@ export const tripleTermObject = {
|
|
|
334
357
|
*/
|
|
335
358
|
export const tripleTermData = {
|
|
336
359
|
name: 'tripleTermData',
|
|
337
|
-
impl: ({ ACTION, CONSUME, OR, SUBRULE
|
|
360
|
+
impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
|
|
338
361
|
CONSUME(l12.tripleTermOpen);
|
|
339
|
-
const subject = SUBRULE(tripleTermDataSubject);
|
|
362
|
+
const subject = SUBRULE(tripleTermDataSubject, undefined);
|
|
340
363
|
const predicate = OR([
|
|
341
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
364
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
342
365
|
{ ALT: () => {
|
|
343
366
|
CONSUME(l11.a);
|
|
344
|
-
return ACTION(() =>
|
|
367
|
+
return ACTION(() => C.dataFactory.namedNode(CommonIRIs.TYPE));
|
|
345
368
|
} },
|
|
346
369
|
]);
|
|
347
|
-
const object = SUBRULE(tripleTermDataObject);
|
|
370
|
+
const object = SUBRULE(tripleTermDataObject, undefined);
|
|
348
371
|
CONSUME(l12.tripleTermClose);
|
|
349
|
-
return ACTION(() =>
|
|
372
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
350
373
|
},
|
|
351
374
|
};
|
|
352
375
|
/**
|
|
@@ -355,10 +378,10 @@ export const tripleTermData = {
|
|
|
355
378
|
export const tripleTermDataSubject = {
|
|
356
379
|
name: 'tripleTermDataSubject',
|
|
357
380
|
impl: ({ OR, SUBRULE }) => () => OR([
|
|
358
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
359
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
360
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
361
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
381
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
382
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
383
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
384
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
362
385
|
]),
|
|
363
386
|
};
|
|
364
387
|
/**
|
|
@@ -366,9 +389,9 @@ export const tripleTermDataSubject = {
|
|
|
366
389
|
*/
|
|
367
390
|
export const tripleTermDataObject = {
|
|
368
391
|
name: 'tripleTermDataObject',
|
|
369
|
-
impl: $ =>
|
|
370
|
-
{ ALT: () => tripleTermDataSubject.impl($)() },
|
|
371
|
-
{ ALT: () => $.SUBRULE(tripleTermData) },
|
|
392
|
+
impl: $ => C => $.OR2([
|
|
393
|
+
{ ALT: () => tripleTermDataSubject.impl($)(C, undefined) },
|
|
394
|
+
{ ALT: () => $.SUBRULE(tripleTermData, undefined) },
|
|
372
395
|
]),
|
|
373
396
|
};
|
|
374
397
|
/**
|
|
@@ -377,9 +400,9 @@ export const tripleTermDataObject = {
|
|
|
377
400
|
*/
|
|
378
401
|
export const primaryExpression = {
|
|
379
402
|
name: 'primaryExpression',
|
|
380
|
-
impl: $ =>
|
|
381
|
-
{ ALT: () => S11.primaryExpression.impl($)() },
|
|
382
|
-
{ ALT: () => $.SUBRULE(exprTripleTerm) },
|
|
403
|
+
impl: $ => C => $.OR2([
|
|
404
|
+
{ ALT: () => S11.primaryExpression.impl($)(C, undefined) },
|
|
405
|
+
{ ALT: () => $.SUBRULE(exprTripleTerm, undefined) },
|
|
383
406
|
]),
|
|
384
407
|
};
|
|
385
408
|
/**
|
|
@@ -387,13 +410,13 @@ export const primaryExpression = {
|
|
|
387
410
|
*/
|
|
388
411
|
export const exprTripleTerm = {
|
|
389
412
|
name: 'exprTripleTerm',
|
|
390
|
-
impl: ({ ACTION, CONSUME, SUBRULE
|
|
413
|
+
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
391
414
|
CONSUME(l12.tripleTermOpen);
|
|
392
|
-
const subject = SUBRULE(exprTripleTermSubject);
|
|
393
|
-
const predicate = SUBRULE(S11.verb);
|
|
394
|
-
const object = SUBRULE(exprTripleTermObject);
|
|
415
|
+
const subject = SUBRULE(exprTripleTermSubject, undefined);
|
|
416
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
417
|
+
const object = SUBRULE(exprTripleTermObject, undefined);
|
|
395
418
|
CONSUME(l12.tripleTermClose);
|
|
396
|
-
return ACTION(() =>
|
|
419
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
397
420
|
},
|
|
398
421
|
};
|
|
399
422
|
/**
|
|
@@ -402,11 +425,11 @@ export const exprTripleTerm = {
|
|
|
402
425
|
export const exprTripleTermSubject = {
|
|
403
426
|
name: 'exprTripleTermSubject',
|
|
404
427
|
impl: ({ OR, SUBRULE }) => () => OR([
|
|
405
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
406
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
407
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
408
|
-
{ ALT: () => SUBRULE(S11.booleanLiteral) },
|
|
409
|
-
{ ALT: () => SUBRULE(S11.var_) },
|
|
428
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
429
|
+
{ ALT: () => SUBRULE(rdfLiteral, undefined) },
|
|
430
|
+
{ ALT: () => SUBRULE(S11.numericLiteral, undefined) },
|
|
431
|
+
{ ALT: () => SUBRULE(S11.booleanLiteral, undefined) },
|
|
432
|
+
{ ALT: () => SUBRULE(S11.var_, undefined) },
|
|
410
433
|
]),
|
|
411
434
|
};
|
|
412
435
|
/**
|
|
@@ -414,9 +437,9 @@ export const exprTripleTermSubject = {
|
|
|
414
437
|
*/
|
|
415
438
|
export const exprTripleTermObject = {
|
|
416
439
|
name: 'exprTripleTermObject',
|
|
417
|
-
impl: $ =>
|
|
418
|
-
{ ALT: () => exprTripleTermSubject.impl($)() },
|
|
419
|
-
{ ALT: () => $.SUBRULE(exprTripleTerm) },
|
|
440
|
+
impl: $ => C => $.OR2([
|
|
441
|
+
{ ALT: () => exprTripleTermSubject.impl($)(C, undefined) },
|
|
442
|
+
{ ALT: () => $.SUBRULE(exprTripleTerm, undefined) },
|
|
420
443
|
]),
|
|
421
444
|
};
|
|
422
445
|
export const builtinLangDir = funcExpr1(l12.builtinLangDir);
|
|
@@ -434,17 +457,17 @@ export const builtinObject = funcExpr1(l12.builtinOBJECT);
|
|
|
434
457
|
*/
|
|
435
458
|
export const builtInCall = {
|
|
436
459
|
name: 'builtInCall',
|
|
437
|
-
impl: $ =>
|
|
438
|
-
{ ALT: () => S11.builtInCall.impl($)() },
|
|
439
|
-
{ ALT: () => $.SUBRULE(builtinLangDir) },
|
|
440
|
-
{ ALT: () => $.SUBRULE(builtinLangStrDir) },
|
|
441
|
-
{ ALT: () => $.SUBRULE(builtinHasLang) },
|
|
442
|
-
{ ALT: () => $.SUBRULE(builtinHasLangDir) },
|
|
443
|
-
{ ALT: () => $.SUBRULE(builtinIsTriple) },
|
|
444
|
-
{ ALT: () => $.SUBRULE(builtinTriple) },
|
|
445
|
-
{ ALT: () => $.SUBRULE(builtinSubject) },
|
|
446
|
-
{ ALT: () => $.SUBRULE(builtinPredicate) },
|
|
447
|
-
{ ALT: () => $.SUBRULE(builtinObject) },
|
|
460
|
+
impl: $ => C => $.OR2([
|
|
461
|
+
{ ALT: () => S11.builtInCall.impl($)(C, undefined) },
|
|
462
|
+
{ ALT: () => $.SUBRULE(builtinLangDir, undefined) },
|
|
463
|
+
{ ALT: () => $.SUBRULE(builtinLangStrDir, undefined) },
|
|
464
|
+
{ ALT: () => $.SUBRULE(builtinHasLang, undefined) },
|
|
465
|
+
{ ALT: () => $.SUBRULE(builtinHasLangDir, undefined) },
|
|
466
|
+
{ ALT: () => $.SUBRULE(builtinIsTriple, undefined) },
|
|
467
|
+
{ ALT: () => $.SUBRULE(builtinTriple, undefined) },
|
|
468
|
+
{ ALT: () => $.SUBRULE(builtinSubject, undefined) },
|
|
469
|
+
{ ALT: () => $.SUBRULE(builtinPredicate, undefined) },
|
|
470
|
+
{ ALT: () => $.SUBRULE(builtinObject, undefined) },
|
|
448
471
|
]),
|
|
449
472
|
};
|
|
450
473
|
function isLangDir(dir) {
|
|
@@ -457,8 +480,8 @@ function isLangDir(dir) {
|
|
|
457
480
|
*/
|
|
458
481
|
export const rdfLiteral = {
|
|
459
482
|
name: 'rdfLiteral',
|
|
460
|
-
impl: ({ ACTION, SUBRULE, OPTION, CONSUME, OR
|
|
461
|
-
const value = SUBRULE(S11.string);
|
|
483
|
+
impl: ({ ACTION, SUBRULE, OPTION, CONSUME, OR }) => (C) => {
|
|
484
|
+
const value = SUBRULE(S11.string, undefined);
|
|
462
485
|
const langOrDataType = OPTION(() => OR([
|
|
463
486
|
{ ALT: () => {
|
|
464
487
|
const langTag = CONSUME(l12.LANG_DIR).image.slice(1);
|
|
@@ -479,10 +502,10 @@ export const rdfLiteral = {
|
|
|
479
502
|
} },
|
|
480
503
|
{ ALT: () => {
|
|
481
504
|
CONSUME(l11.symbols.hathat);
|
|
482
|
-
return SUBRULE(S11.iri);
|
|
505
|
+
return SUBRULE(S11.iri, undefined);
|
|
483
506
|
} },
|
|
484
507
|
]));
|
|
485
|
-
return
|
|
508
|
+
return ACTION(() => C.dataFactory.literal(value, langOrDataType));
|
|
486
509
|
},
|
|
487
510
|
};
|
|
488
511
|
//# sourceMappingURL=grammar.js.map
|