@traqula/rules-sparql-1-2 0.0.1-alpha.145 → 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 +31 -30
- package/lib/grammar.js +123 -122
- package/lib/grammar.js.map +1 -1
- package/lib/index.cjs +1195 -1202
- package/lib/lexer.d.ts +1 -1
- package/package.json +4 -4
package/lib/grammar.d.ts
CHANGED
|
@@ -4,137 +4,138 @@
|
|
|
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 type { RuleDefReturn
|
|
7
|
+
import type { RuleDefReturn } from '@traqula/core';
|
|
8
|
+
import { SparqlRuleDef } from '@traqula/rules-sparql-1-1';
|
|
8
9
|
import { gram as S11 } from '@traqula/rules-sparql-1-1';
|
|
9
10
|
import type * as T11 from '@traqula/rules-sparql-1-1';
|
|
10
11
|
import type { BaseQuadTerm, Expression, IGraphNode, Term, Triple } from './sparql12Types';
|
|
11
12
|
/**
|
|
12
13
|
* [[56]](https://www.w3.org/TR/sparql12-query/#rReifiedTripleBlock) Used by triplesSameSubject
|
|
13
14
|
*/
|
|
14
|
-
export declare const reifiedTripleBlock:
|
|
15
|
+
export declare const reifiedTripleBlock: SparqlRuleDef<"reifiedTripleBlock", Triple[]>;
|
|
15
16
|
/**
|
|
16
17
|
* [[57]](https://www.w3.org/TR/sparql12-query/#rReifiedTripleBlockPath) Used by TriplesSameSubjectPath
|
|
17
18
|
*/
|
|
18
|
-
export declare const reifiedTripleBlockPath:
|
|
19
|
+
export declare const reifiedTripleBlockPath: SparqlRuleDef<"reifiedTripleBlockPath", Triple[]>;
|
|
19
20
|
/**
|
|
20
21
|
* OVERRIDING RULE: {@link S11.dataBlockValue}.
|
|
21
22
|
* [[67]](https://www.w3.org/TR/sparql12-query/#rDataBlockValue)
|
|
22
23
|
*/
|
|
23
|
-
export declare const dataBlockValue:
|
|
24
|
+
export declare const dataBlockValue: SparqlRuleDef<'dataBlockValue', RuleDefReturn<typeof S11.dataBlockValue> | BaseQuadTerm>;
|
|
24
25
|
/**
|
|
25
26
|
* [[68]](https://www.w3.org/TR/sparql12-query/#rReifier)
|
|
26
27
|
*/
|
|
27
|
-
export declare const reifier:
|
|
28
|
+
export declare const reifier: SparqlRuleDef<'reifier', T11.VariableTerm | T11.IriTerm | T11.BlankTerm>;
|
|
28
29
|
/**
|
|
29
30
|
* [[68]](https://www.w3.org/TR/sparql12-query/#rVarOrReifierId)
|
|
30
31
|
*/
|
|
31
|
-
export declare const varOrReifierId:
|
|
32
|
+
export declare const varOrReifierId: SparqlRuleDef<'varOrReifierId', T11.VariableTerm | T11.IriTerm | T11.BlankTerm>;
|
|
32
33
|
/**
|
|
33
34
|
* OVERRIDING RULE {@link S11.triplesSameSubject}
|
|
34
35
|
* [[79]](https://www.w3.org/TR/sparql12-query/#rTriplesSameSubject)
|
|
35
36
|
*/
|
|
36
|
-
export declare const triplesSameSubject:
|
|
37
|
+
export declare const triplesSameSubject: SparqlRuleDef<"triplesSameSubject", Triple[]>;
|
|
37
38
|
/**
|
|
38
39
|
* OVERRIDING RULE {@link S11.triplesSameSubjectPath}
|
|
39
40
|
* [[85]](https://www.w3.org/TR/sparql12-query/#rTriplesSameSubjectPath)
|
|
40
41
|
*/
|
|
41
|
-
export declare const triplesSameSubjectPath:
|
|
42
|
+
export declare const triplesSameSubjectPath: SparqlRuleDef<"triplesSameSubjectPath", Triple[]>;
|
|
42
43
|
/**
|
|
43
44
|
* OVERRIDING RULE: {@link S11.object}.
|
|
44
45
|
* [[84]](https://www.w3.org/TR/sparql12-query/#rObject) Used by ObjectList
|
|
45
46
|
*/
|
|
46
|
-
export declare const object:
|
|
47
|
+
export declare const object: SparqlRuleDef<"object", Triple[], Pick<Triple, "subject" | "predicate">>;
|
|
47
48
|
/**
|
|
48
49
|
* OVERRIDING RULE: {@link S11.objectPath}.
|
|
49
50
|
* [[91]](https://www.w3.org/TR/sparql12-query/#rTriplesSameSubjectPath) Used by ObjectListPath
|
|
50
51
|
*/
|
|
51
|
-
export declare const objectPath:
|
|
52
|
+
export declare const objectPath: SparqlRuleDef<"objectPath", Triple[], Pick<Triple, "subject" | "predicate">>;
|
|
52
53
|
/**
|
|
53
54
|
* [[107]](https://www.w3.org/TR/sparql12-query/#rAnnotationPath)
|
|
54
55
|
*/
|
|
55
|
-
export declare const annotationPath:
|
|
56
|
+
export declare const annotationPath: SparqlRuleDef<"annotationPath", IGraphNode[]>;
|
|
56
57
|
/**
|
|
57
58
|
* [[109]](https://www.w3.org/TR/sparql12-query/#rAnnotation)
|
|
58
59
|
*/
|
|
59
|
-
export declare const annotation:
|
|
60
|
+
export declare const annotation: SparqlRuleDef<"annotation", IGraphNode[]>;
|
|
60
61
|
/**
|
|
61
62
|
* [[108]](https://www.w3.org/TR/sparql12-query/#rAnnotationBlockPath)
|
|
62
63
|
*/
|
|
63
|
-
export declare const annotationBlockPath:
|
|
64
|
+
export declare const annotationBlockPath: SparqlRuleDef<"annotationBlockPath", Triple[], Pick<Triple, "subject">>;
|
|
64
65
|
/**
|
|
65
66
|
* [[110]](https://www.w3.org/TR/sparql12-query/#rAnnotationBlock)
|
|
66
67
|
*/
|
|
67
|
-
export declare const annotationBlock:
|
|
68
|
+
export declare const annotationBlock: SparqlRuleDef<"annotationBlock", Triple[], Pick<Triple, "subject">>;
|
|
68
69
|
/**
|
|
69
70
|
* OVERRIDING RULE: {@link S11.graphNode}.
|
|
70
71
|
* [[111]](https://www.w3.org/TR/sparql12-query/#rGraphNode)
|
|
71
72
|
*/
|
|
72
|
-
export declare const graphNode:
|
|
73
|
+
export declare const graphNode: SparqlRuleDef<'graphNode', IGraphNode>;
|
|
73
74
|
/**
|
|
74
75
|
* OVERRIDING RULE: {@link S11.graphNodePath}.
|
|
75
76
|
* [[112]](https://www.w3.org/TR/sparql12-query/#rGraphNodePath)
|
|
76
77
|
*/
|
|
77
|
-
export declare const graphNodePath:
|
|
78
|
+
export declare const graphNodePath: SparqlRuleDef<'graphNodePath', IGraphNode>;
|
|
78
79
|
/**
|
|
79
80
|
* OVERRIDING RULE: {@link S11.varOrTerm}.
|
|
80
81
|
* [[113]](https://www.w3.org/TR/sparql12-query/#rVarOrTerm)
|
|
81
82
|
*/
|
|
82
|
-
export declare const varOrTerm:
|
|
83
|
+
export declare const varOrTerm: SparqlRuleDef<'varOrTerm', Term>;
|
|
83
84
|
/**
|
|
84
85
|
* [[114]](https://www.w3.org/TR/sparql12-query/#rReifiedTriple)
|
|
85
86
|
*/
|
|
86
|
-
export declare const reifiedTriple:
|
|
87
|
+
export declare const reifiedTriple: SparqlRuleDef<'reifiedTriple', IGraphNode & {
|
|
87
88
|
node: T11.BlankTerm | T11.VariableTerm | T11.IriTerm;
|
|
88
89
|
}>;
|
|
89
90
|
/**
|
|
90
91
|
* [[115]](https://www.w3.org/TR/sparql12-query/#rReifiedTripleSubject)
|
|
91
92
|
*/
|
|
92
|
-
export declare const reifiedTripleSubject:
|
|
93
|
+
export declare const reifiedTripleSubject: SparqlRuleDef<'reifiedTripleSubject', IGraphNode>;
|
|
93
94
|
/**
|
|
94
95
|
* [[116]](https://www.w3.org/TR/sparql12-query/#rReifiedTripleObject)
|
|
95
96
|
*/
|
|
96
|
-
export declare const reifiedTripleObject:
|
|
97
|
+
export declare const reifiedTripleObject: SparqlRuleDef<'reifiedTripleObject', RuleDefReturn<typeof reifiedTripleSubject>>;
|
|
97
98
|
/**
|
|
98
99
|
* [[117]](https://www.w3.org/TR/sparql12-query/#rTripleTerm)
|
|
99
100
|
*/
|
|
100
|
-
export declare const tripleTerm:
|
|
101
|
+
export declare const tripleTerm: SparqlRuleDef<'tripleTerm', BaseQuadTerm>;
|
|
101
102
|
/**
|
|
102
103
|
* [[118]](https://www.w3.org/TR/sparql12-query/#rTripleTermSubject)
|
|
103
104
|
*/
|
|
104
|
-
export declare const tripleTermSubject:
|
|
105
|
+
export declare const tripleTermSubject: SparqlRuleDef<'tripleTermSubject', T11.VariableTerm | T11.IriTerm | T11.LiteralTerm | T11.BlankTerm>;
|
|
105
106
|
/**
|
|
106
107
|
* [[119]](https://www.w3.org/TR/sparql12-query/#rTripleTermObject)
|
|
107
108
|
*/
|
|
108
|
-
export declare const tripleTermObject:
|
|
109
|
+
export declare const tripleTermObject: SparqlRuleDef<'tripleTermObject', RuleDefReturn<typeof tripleTermSubject> | BaseQuadTerm>;
|
|
109
110
|
/**
|
|
110
111
|
* [[120]](https://www.w3.org/TR/sparql12-query/#rTripleTermData)
|
|
111
112
|
*/
|
|
112
|
-
export declare const tripleTermData:
|
|
113
|
+
export declare const tripleTermData: SparqlRuleDef<'tripleTermData', BaseQuadTerm>;
|
|
113
114
|
/**
|
|
114
115
|
* [[121]](https://www.w3.org/TR/sparql12-query/#rTripleTermDataSubject)
|
|
115
116
|
*/
|
|
116
|
-
export declare const tripleTermDataSubject:
|
|
117
|
+
export declare const tripleTermDataSubject: SparqlRuleDef<'tripleTermDataSubject', T11.IriTerm | T11.LiteralTerm>;
|
|
117
118
|
/**
|
|
118
119
|
* [[122]](https://www.w3.org/TR/sparql12-query/#rTripleTermDataObject)
|
|
119
120
|
*/
|
|
120
|
-
export declare const tripleTermDataObject:
|
|
121
|
+
export declare const tripleTermDataObject: SparqlRuleDef<'tripleTermDataObject', RuleDefReturn<typeof tripleTermDataSubject> | BaseQuadTerm>;
|
|
121
122
|
/**
|
|
122
123
|
* OVERRIDING RULE: {@link S11.primaryExpression}.
|
|
123
124
|
* [[134]](https://www.w3.org/TR/sparql12-query/#rPrimaryExpression)
|
|
124
125
|
*/
|
|
125
|
-
export declare const primaryExpression:
|
|
126
|
+
export declare const primaryExpression: SparqlRuleDef<'primaryExpression', Expression>;
|
|
126
127
|
/**
|
|
127
128
|
* [[135]](https://www.w3.org/TR/sparql12-query/#rExprTripleTerm)
|
|
128
129
|
*/
|
|
129
|
-
export declare const exprTripleTerm:
|
|
130
|
+
export declare const exprTripleTerm: SparqlRuleDef<'exprTripleTerm', BaseQuadTerm>;
|
|
130
131
|
/**
|
|
131
132
|
* [[136]](https://www.w3.org/TR/sparql12-query/#rExprTripleTermSubject)
|
|
132
133
|
*/
|
|
133
|
-
export declare const exprTripleTermSubject:
|
|
134
|
+
export declare const exprTripleTermSubject: SparqlRuleDef<'exprTripleTermSubject', T11.IriTerm | T11.VariableTerm | T11.LiteralTerm>;
|
|
134
135
|
/**
|
|
135
136
|
* [[137]](https://www.w3.org/TR/sparql12-query/#rExprTripleTermObject)
|
|
136
137
|
*/
|
|
137
|
-
export declare const exprTripleTermObject:
|
|
138
|
+
export declare const exprTripleTermObject: SparqlRuleDef<'exprTripleTermObject', RuleDefReturn<typeof exprTripleTermSubject> | BaseQuadTerm>;
|
|
138
139
|
export declare const builtinLangDir: S11.RuleDefExpressionFunctionX<"builtInLangdir", [T11.Expression]>;
|
|
139
140
|
export declare const builtinLangStrDir: S11.RuleDefExpressionFunctionX<"builtInStrLangdir", [T11.Expression, T11.Expression, T11.Expression]>;
|
|
140
141
|
export declare const builtinHasLang: S11.RuleDefExpressionFunctionX<"builtInHasLang", [T11.Expression]>;
|
package/lib/grammar.js
CHANGED
|
@@ -12,8 +12,8 @@ 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, triple.node);
|
|
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
19
|
...properties,
|
|
@@ -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,12 +89,13 @@ 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
95
|
// This rule knows the annotation. And for each annotation node, we need to make a triple:
|
|
96
96
|
// <annotationNode, reifies, parsedSubjectAndObject>
|
|
97
97
|
return ACTION(() => {
|
|
98
|
+
const { subject, predicate } = arg;
|
|
98
99
|
if ('type' in predicate && predicate.type === 'path' && annotationVal.length > 0) {
|
|
99
100
|
throw new Error('Note 17 violation');
|
|
100
101
|
}
|
|
@@ -105,7 +106,7 @@ function objectImpl(name, allowPaths) {
|
|
|
105
106
|
...objectVal.triples,
|
|
106
107
|
];
|
|
107
108
|
for (const annotation of annotationVal) {
|
|
108
|
-
result.push(
|
|
109
|
+
result.push(C.dataFactory.quad(annotation.node, C.dataFactory.namedNode(CommonIRIs.REIFIES), C.dataFactory.quad(subject, predicate, objectVal.node)));
|
|
109
110
|
result.push(...annotation.triples);
|
|
110
111
|
}
|
|
111
112
|
return result;
|
|
@@ -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,19 +139,19 @@ 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;
|
|
147
|
-
const block = SUBRULE(allowPaths ? annotationBlockPath : annotationBlock, ACTION(() => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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
|
+
}) });
|
|
154
155
|
ACTION(() => {
|
|
155
156
|
annotations.push({
|
|
156
157
|
node,
|
|
@@ -179,9 +180,9 @@ export const annotation = annotationImpl('annotation', false);
|
|
|
179
180
|
function annotationBlockImpl(name, allowPaths) {
|
|
180
181
|
return {
|
|
181
182
|
name,
|
|
182
|
-
impl: ({ SUBRULE, CONSUME }) => (
|
|
183
|
+
impl: ({ ACTION, SUBRULE, CONSUME }) => (_, arg) => {
|
|
183
184
|
CONSUME(l12.annotationOpen);
|
|
184
|
-
const res = SUBRULE(allowPaths ? S11.propertyListPathNotEmpty : S11.propertyListNotEmpty, subject);
|
|
185
|
+
const res = SUBRULE(allowPaths ? S11.propertyListPathNotEmpty : S11.propertyListNotEmpty, { subject: ACTION(() => arg.subject) });
|
|
185
186
|
CONSUME(l12.annotationClose);
|
|
186
187
|
return res;
|
|
187
188
|
},
|
|
@@ -201,9 +202,9 @@ export const annotationBlock = annotationBlockImpl('annotationBlock', false);
|
|
|
201
202
|
*/
|
|
202
203
|
export const graphNode = {
|
|
203
204
|
name: 'graphNode',
|
|
204
|
-
impl: $ => () => $.OR2([
|
|
205
|
-
{ ALT: () => S11.graphNode.impl($)() },
|
|
206
|
-
{ ALT: () => $.SUBRULE(reifiedTriple) },
|
|
205
|
+
impl: $ => (C) => $.OR2([
|
|
206
|
+
{ ALT: () => S11.graphNode.impl($)(C, undefined) },
|
|
207
|
+
{ ALT: () => $.SUBRULE(reifiedTriple, undefined) },
|
|
207
208
|
]),
|
|
208
209
|
};
|
|
209
210
|
/**
|
|
@@ -212,9 +213,9 @@ export const graphNode = {
|
|
|
212
213
|
*/
|
|
213
214
|
export const graphNodePath = {
|
|
214
215
|
name: 'graphNodePath',
|
|
215
|
-
impl: $ => () => $.OR2([
|
|
216
|
-
{ ALT: () => S11.graphNodePath.impl($)() },
|
|
217
|
-
{ ALT: () => $.SUBRULE(reifiedTriple) },
|
|
216
|
+
impl: $ => (C) => $.OR2([
|
|
217
|
+
{ ALT: () => S11.graphNodePath.impl($)(C, undefined) },
|
|
218
|
+
{ ALT: () => $.SUBRULE(reifiedTriple, undefined) },
|
|
218
219
|
]),
|
|
219
220
|
};
|
|
220
221
|
/**
|
|
@@ -223,18 +224,18 @@ export const graphNodePath = {
|
|
|
223
224
|
*/
|
|
224
225
|
export const varOrTerm = {
|
|
225
226
|
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) },
|
|
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) },
|
|
233
234
|
{ ALT: () => {
|
|
234
235
|
CONSUME(l11.terminals.nil);
|
|
235
|
-
return
|
|
236
|
+
return ACTION(() => C.dataFactory.namedNode(CommonIRIs.NIL));
|
|
236
237
|
} },
|
|
237
|
-
{ ALT: () => SUBRULE(tripleTerm) },
|
|
238
|
+
{ ALT: () => SUBRULE(tripleTerm, undefined) },
|
|
238
239
|
]),
|
|
239
240
|
};
|
|
240
241
|
/**
|
|
@@ -242,24 +243,24 @@ export const varOrTerm = {
|
|
|
242
243
|
*/
|
|
243
244
|
export const reifiedTriple = {
|
|
244
245
|
name: 'reifiedTriple',
|
|
245
|
-
impl: ({ ACTION, CONSUME, SUBRULE, OPTION
|
|
246
|
+
impl: ({ ACTION, CONSUME, SUBRULE, OPTION }) => (C) => {
|
|
246
247
|
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));
|
|
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));
|
|
251
252
|
CONSUME(l12.reificationClose);
|
|
252
253
|
return ACTION(() => {
|
|
253
|
-
if (reifierVal === undefined && !
|
|
254
|
+
if (reifierVal === undefined && !C.parseMode.has('canCreateBlankNodes')) {
|
|
254
255
|
throw new Error('Cannot create blanknodes in current parse mode');
|
|
255
256
|
}
|
|
256
|
-
const reifier = reifierVal ??
|
|
257
|
-
const tripleTerm =
|
|
257
|
+
const reifier = reifierVal ?? C.dataFactory.blankNode();
|
|
258
|
+
const tripleTerm = C.dataFactory.quad(subject.node, predicate, object.node);
|
|
258
259
|
return {
|
|
259
260
|
node: reifier,
|
|
260
261
|
triples: [
|
|
261
262
|
...subject.triples,
|
|
262
|
-
|
|
263
|
+
C.dataFactory.quad(reifier, C.dataFactory.namedNode(CommonIRIs.REIFIES), tripleTerm),
|
|
263
264
|
...object.triples,
|
|
264
265
|
],
|
|
265
266
|
};
|
|
@@ -272,13 +273,13 @@ export const reifiedTriple = {
|
|
|
272
273
|
export const reifiedTripleSubject = {
|
|
273
274
|
name: 'reifiedTripleSubject',
|
|
274
275
|
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) },
|
|
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) },
|
|
282
283
|
]),
|
|
283
284
|
};
|
|
284
285
|
/**
|
|
@@ -286,9 +287,9 @@ export const reifiedTripleSubject = {
|
|
|
286
287
|
*/
|
|
287
288
|
export const reifiedTripleObject = {
|
|
288
289
|
name: 'reifiedTripleObject',
|
|
289
|
-
impl: $ => () => $.OR2([
|
|
290
|
-
{ ALT: () => reifiedTripleSubject.impl($)() },
|
|
291
|
-
{ ALT: () => ({ node: $.SUBRULE(tripleTerm), triples: [] }) },
|
|
290
|
+
impl: $ => (C) => $.OR2([
|
|
291
|
+
{ ALT: () => reifiedTripleSubject.impl($)(C, undefined) },
|
|
292
|
+
{ ALT: () => ({ node: $.SUBRULE(tripleTerm, undefined), triples: [] }) },
|
|
292
293
|
]),
|
|
293
294
|
};
|
|
294
295
|
/**
|
|
@@ -296,13 +297,13 @@ export const reifiedTripleObject = {
|
|
|
296
297
|
*/
|
|
297
298
|
export const tripleTerm = {
|
|
298
299
|
name: 'tripleTerm',
|
|
299
|
-
impl: ({ CONSUME, SUBRULE
|
|
300
|
+
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
300
301
|
CONSUME(l12.tripleTermOpen);
|
|
301
|
-
const subject = SUBRULE(tripleTermSubject);
|
|
302
|
-
const predicate = SUBRULE(S11.verb);
|
|
303
|
-
const object = SUBRULE(tripleTermObject);
|
|
302
|
+
const subject = SUBRULE(tripleTermSubject, undefined);
|
|
303
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
304
|
+
const object = SUBRULE(tripleTermObject, undefined);
|
|
304
305
|
CONSUME(l12.tripleTermClose);
|
|
305
|
-
return
|
|
306
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
306
307
|
},
|
|
307
308
|
};
|
|
308
309
|
/**
|
|
@@ -311,12 +312,12 @@ export const tripleTerm = {
|
|
|
311
312
|
export const tripleTermSubject = {
|
|
312
313
|
name: 'tripleTermSubject',
|
|
313
314
|
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) },
|
|
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) },
|
|
320
321
|
]),
|
|
321
322
|
};
|
|
322
323
|
/**
|
|
@@ -324,9 +325,9 @@ export const tripleTermSubject = {
|
|
|
324
325
|
*/
|
|
325
326
|
export const tripleTermObject = {
|
|
326
327
|
name: 'tripleTermObject',
|
|
327
|
-
impl: $ => () => $.OR2([
|
|
328
|
-
{ ALT: () => tripleTermSubject.impl($)() },
|
|
329
|
-
{ ALT: () => $.SUBRULE(tripleTerm) },
|
|
328
|
+
impl: $ => (C) => $.OR2([
|
|
329
|
+
{ ALT: () => tripleTermSubject.impl($)(C, undefined) },
|
|
330
|
+
{ ALT: () => $.SUBRULE(tripleTerm, undefined) },
|
|
330
331
|
]),
|
|
331
332
|
};
|
|
332
333
|
/**
|
|
@@ -334,19 +335,19 @@ export const tripleTermObject = {
|
|
|
334
335
|
*/
|
|
335
336
|
export const tripleTermData = {
|
|
336
337
|
name: 'tripleTermData',
|
|
337
|
-
impl: ({ ACTION, CONSUME, OR, SUBRULE
|
|
338
|
+
impl: ({ ACTION, CONSUME, OR, SUBRULE }) => (C) => {
|
|
338
339
|
CONSUME(l12.tripleTermOpen);
|
|
339
|
-
const subject = SUBRULE(tripleTermDataSubject);
|
|
340
|
+
const subject = SUBRULE(tripleTermDataSubject, undefined);
|
|
340
341
|
const predicate = OR([
|
|
341
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
342
|
+
{ ALT: () => SUBRULE(S11.iri, undefined) },
|
|
342
343
|
{ ALT: () => {
|
|
343
344
|
CONSUME(l11.a);
|
|
344
|
-
return ACTION(() =>
|
|
345
|
+
return ACTION(() => C.dataFactory.namedNode(CommonIRIs.TYPE));
|
|
345
346
|
} },
|
|
346
347
|
]);
|
|
347
|
-
const object = SUBRULE(tripleTermDataObject);
|
|
348
|
+
const object = SUBRULE(tripleTermDataObject, undefined);
|
|
348
349
|
CONSUME(l12.tripleTermClose);
|
|
349
|
-
return ACTION(() =>
|
|
350
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
350
351
|
},
|
|
351
352
|
};
|
|
352
353
|
/**
|
|
@@ -355,10 +356,10 @@ export const tripleTermData = {
|
|
|
355
356
|
export const tripleTermDataSubject = {
|
|
356
357
|
name: 'tripleTermDataSubject',
|
|
357
358
|
impl: ({ OR, SUBRULE }) => () => OR([
|
|
358
|
-
{ ALT: () => SUBRULE(S11.iri) },
|
|
359
|
-
{ ALT: () => SUBRULE(rdfLiteral) },
|
|
360
|
-
{ ALT: () => SUBRULE(S11.numericLiteral) },
|
|
361
|
-
{ 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) },
|
|
362
363
|
]),
|
|
363
364
|
};
|
|
364
365
|
/**
|
|
@@ -366,9 +367,9 @@ export const tripleTermDataSubject = {
|
|
|
366
367
|
*/
|
|
367
368
|
export const tripleTermDataObject = {
|
|
368
369
|
name: 'tripleTermDataObject',
|
|
369
|
-
impl: $ => () => $.OR2([
|
|
370
|
-
{ ALT: () => tripleTermDataSubject.impl($)() },
|
|
371
|
-
{ ALT: () => $.SUBRULE(tripleTermData) },
|
|
370
|
+
impl: $ => (C) => $.OR2([
|
|
371
|
+
{ ALT: () => tripleTermDataSubject.impl($)(C, undefined) },
|
|
372
|
+
{ ALT: () => $.SUBRULE(tripleTermData, undefined) },
|
|
372
373
|
]),
|
|
373
374
|
};
|
|
374
375
|
/**
|
|
@@ -377,9 +378,9 @@ export const tripleTermDataObject = {
|
|
|
377
378
|
*/
|
|
378
379
|
export const primaryExpression = {
|
|
379
380
|
name: 'primaryExpression',
|
|
380
|
-
impl: $ => () => $.OR2([
|
|
381
|
-
{ ALT: () => S11.primaryExpression.impl($)() },
|
|
382
|
-
{ ALT: () => $.SUBRULE(exprTripleTerm) },
|
|
381
|
+
impl: $ => (C) => $.OR2([
|
|
382
|
+
{ ALT: () => S11.primaryExpression.impl($)(C, undefined) },
|
|
383
|
+
{ ALT: () => $.SUBRULE(exprTripleTerm, undefined) },
|
|
383
384
|
]),
|
|
384
385
|
};
|
|
385
386
|
/**
|
|
@@ -387,13 +388,13 @@ export const primaryExpression = {
|
|
|
387
388
|
*/
|
|
388
389
|
export const exprTripleTerm = {
|
|
389
390
|
name: 'exprTripleTerm',
|
|
390
|
-
impl: ({ ACTION, CONSUME, SUBRULE
|
|
391
|
+
impl: ({ ACTION, CONSUME, SUBRULE }) => (C) => {
|
|
391
392
|
CONSUME(l12.tripleTermOpen);
|
|
392
|
-
const subject = SUBRULE(exprTripleTermSubject);
|
|
393
|
-
const predicate = SUBRULE(S11.verb);
|
|
394
|
-
const object = SUBRULE(exprTripleTermObject);
|
|
393
|
+
const subject = SUBRULE(exprTripleTermSubject, undefined);
|
|
394
|
+
const predicate = SUBRULE(S11.verb, undefined);
|
|
395
|
+
const object = SUBRULE(exprTripleTermObject, undefined);
|
|
395
396
|
CONSUME(l12.tripleTermClose);
|
|
396
|
-
return ACTION(() =>
|
|
397
|
+
return ACTION(() => C.dataFactory.quad(subject, predicate, object));
|
|
397
398
|
},
|
|
398
399
|
};
|
|
399
400
|
/**
|
|
@@ -402,11 +403,11 @@ export const exprTripleTerm = {
|
|
|
402
403
|
export const exprTripleTermSubject = {
|
|
403
404
|
name: 'exprTripleTermSubject',
|
|
404
405
|
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_) },
|
|
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) },
|
|
410
411
|
]),
|
|
411
412
|
};
|
|
412
413
|
/**
|
|
@@ -414,9 +415,9 @@ export const exprTripleTermSubject = {
|
|
|
414
415
|
*/
|
|
415
416
|
export const exprTripleTermObject = {
|
|
416
417
|
name: 'exprTripleTermObject',
|
|
417
|
-
impl: $ => () => $.OR2([
|
|
418
|
-
{ ALT: () => exprTripleTermSubject.impl($)() },
|
|
419
|
-
{ ALT: () => $.SUBRULE(exprTripleTerm) },
|
|
418
|
+
impl: $ => (C) => $.OR2([
|
|
419
|
+
{ ALT: () => exprTripleTermSubject.impl($)(C, undefined) },
|
|
420
|
+
{ ALT: () => $.SUBRULE(exprTripleTerm, undefined) },
|
|
420
421
|
]),
|
|
421
422
|
};
|
|
422
423
|
export const builtinLangDir = funcExpr1(l12.builtinLangDir);
|
|
@@ -434,17 +435,17 @@ export const builtinObject = funcExpr1(l12.builtinOBJECT);
|
|
|
434
435
|
*/
|
|
435
436
|
export const builtInCall = {
|
|
436
437
|
name: 'builtInCall',
|
|
437
|
-
impl: $ => () => $.OR2([
|
|
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) },
|
|
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) },
|
|
448
449
|
]),
|
|
449
450
|
};
|
|
450
451
|
function isLangDir(dir) {
|
|
@@ -457,8 +458,8 @@ function isLangDir(dir) {
|
|
|
457
458
|
*/
|
|
458
459
|
export const rdfLiteral = {
|
|
459
460
|
name: 'rdfLiteral',
|
|
460
|
-
impl: ({ ACTION, SUBRULE, OPTION, CONSUME, OR
|
|
461
|
-
const value = SUBRULE(S11.string);
|
|
461
|
+
impl: ({ ACTION, SUBRULE, OPTION, CONSUME, OR }) => (C) => {
|
|
462
|
+
const value = SUBRULE(S11.string, undefined);
|
|
462
463
|
const langOrDataType = OPTION(() => OR([
|
|
463
464
|
{ ALT: () => {
|
|
464
465
|
const langTag = CONSUME(l12.LANG_DIR).image.slice(1);
|
|
@@ -479,10 +480,10 @@ export const rdfLiteral = {
|
|
|
479
480
|
} },
|
|
480
481
|
{ ALT: () => {
|
|
481
482
|
CONSUME(l11.symbols.hathat);
|
|
482
|
-
return SUBRULE(S11.iri);
|
|
483
|
+
return SUBRULE(S11.iri, undefined);
|
|
483
484
|
} },
|
|
484
485
|
]));
|
|
485
|
-
return
|
|
486
|
+
return ACTION(() => C.dataFactory.literal(value, langOrDataType));
|
|
486
487
|
},
|
|
487
488
|
};
|
|
488
489
|
//# sourceMappingURL=grammar.js.map
|