@traqula/rules-sparql-1-1 0.0.20 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/lib/MinimalSparqlParser.js +64 -0
- package/dist/cjs/lib/Sparql11types.js +16 -0
- package/dist/cjs/lib/astFactory.js +121 -0
- package/dist/cjs/lib/expressionHelpers.js +215 -0
- package/dist/cjs/lib/factoryMixins/ContextFactory.js +55 -0
- package/dist/cjs/lib/factoryMixins/ExpressionFactory.js +105 -0
- package/dist/cjs/lib/factoryMixins/GraphRefFactory.js +76 -0
- package/dist/cjs/lib/factoryMixins/PathFactory.js +90 -0
- package/dist/cjs/lib/factoryMixins/Patternfactory.js +123 -0
- package/dist/cjs/lib/factoryMixins/QueryFactory.js +68 -0
- package/dist/cjs/lib/factoryMixins/SolutionModifiersFactory.js +80 -0
- package/dist/cjs/lib/factoryMixins/TermFactory.js +105 -0
- package/dist/cjs/lib/factoryMixins/UpdateOperationFactory.js +150 -0
- package/dist/cjs/lib/factoryMixins/mixins.js +43 -0
- package/dist/cjs/lib/grammar/builtIn.js +385 -0
- package/dist/cjs/lib/grammar/dataSetClause.js +118 -0
- package/dist/cjs/lib/grammar/expression.js +384 -0
- package/dist/cjs/lib/grammar/general.js +168 -0
- package/dist/cjs/lib/grammar/index.js +115 -0
- package/dist/cjs/lib/grammar/literals.js +282 -0
- package/dist/cjs/lib/grammar/propertyPaths.js +206 -0
- package/dist/cjs/lib/grammar/queryUnit.js +390 -0
- package/dist/cjs/lib/grammar/solutionModifier.js +280 -0
- package/dist/cjs/lib/grammar/tripleBlock.js +384 -0
- package/dist/cjs/lib/grammar/updateUnit.js +546 -0
- package/dist/cjs/lib/grammar/whereClause.js +483 -0
- package/dist/cjs/lib/index.js +56 -0
- package/dist/cjs/lib/lexer/BuiltInCalls.js +337 -0
- package/dist/cjs/lib/lexer/graph.js +41 -0
- package/dist/cjs/lib/lexer/index.js +50 -0
- package/dist/cjs/lib/lexer/lexer.js +199 -0
- package/dist/cjs/lib/lexer/lexerPatterns.js +133 -0
- package/dist/cjs/lib/lexer/symbols.js +107 -0
- package/dist/cjs/lib/lexer/terminals.js +103 -0
- package/dist/cjs/lib/sparql11HelperTypes.js +16 -0
- package/dist/cjs/lib/utils.js +64 -0
- package/dist/cjs/lib/validation/validators.js +214 -0
- package/dist/esm/lib/MinimalSparqlParser.js.map +1 -0
- package/dist/esm/lib/Sparql11types.js.map +1 -0
- package/dist/esm/lib/astFactory.js.map +1 -0
- package/{lib → dist/esm/lib}/expressionHelpers.d.ts +1 -1
- package/dist/esm/lib/expressionHelpers.js.map +1 -0
- package/dist/esm/lib/factoryMixins/ContextFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/ExpressionFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/GraphRefFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/PathFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/Patternfactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/QueryFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/TermFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/UpdateOperationFactory.js.map +1 -0
- package/dist/esm/lib/factoryMixins/mixins.js.map +1 -0
- package/{lib → dist/esm/lib}/grammar/builtIn.d.ts +1 -1
- package/dist/esm/lib/grammar/builtIn.js.map +1 -0
- package/{lib → dist/esm/lib}/grammar/dataSetClause.d.ts +1 -1
- package/dist/esm/lib/grammar/dataSetClause.js.map +1 -0
- package/dist/esm/lib/grammar/expression.js.map +1 -0
- package/dist/esm/lib/grammar/general.js.map +1 -0
- package/dist/esm/lib/grammar/index.js.map +1 -0
- package/dist/esm/lib/grammar/literals.js.map +1 -0
- package/{lib → dist/esm/lib}/grammar/propertyPaths.d.ts +1 -1
- package/dist/esm/lib/grammar/propertyPaths.js.map +1 -0
- package/dist/esm/lib/grammar/queryUnit.js.map +1 -0
- package/dist/esm/lib/grammar/solutionModifier.js.map +1 -0
- package/dist/esm/lib/grammar/tripleBlock.js.map +1 -0
- package/dist/esm/lib/grammar/updateUnit.js.map +1 -0
- package/dist/esm/lib/grammar/whereClause.js.map +1 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/lexer/BuiltInCalls.js.map +1 -0
- package/dist/esm/lib/lexer/graph.js.map +1 -0
- package/dist/esm/lib/lexer/index.js.map +1 -0
- package/dist/esm/lib/lexer/lexer.js.map +1 -0
- package/dist/esm/lib/lexer/lexerPatterns.js.map +1 -0
- package/dist/esm/lib/lexer/symbols.js.map +1 -0
- package/{lib → dist/esm/lib}/lexer/terminals.js +1 -1
- package/dist/esm/lib/lexer/terminals.js.map +1 -0
- package/dist/esm/lib/sparql11HelperTypes.js.map +1 -0
- package/dist/esm/lib/utils.js.map +1 -0
- package/{lib → dist/esm/lib}/validation/validators.js +0 -1
- package/dist/esm/lib/validation/validators.js.map +1 -0
- package/package.json +13 -18
- package/lib/MinimalSparqlParser.js.map +0 -1
- package/lib/Sparql11types.js.map +0 -1
- package/lib/astFactory.js.map +0 -1
- package/lib/expressionHelpers.js.map +0 -1
- package/lib/factoryMixins/ContextFactory.js.map +0 -1
- package/lib/factoryMixins/ExpressionFactory.js.map +0 -1
- package/lib/factoryMixins/GraphRefFactory.js.map +0 -1
- package/lib/factoryMixins/PathFactory.js.map +0 -1
- package/lib/factoryMixins/Patternfactory.js.map +0 -1
- package/lib/factoryMixins/QueryFactory.js.map +0 -1
- package/lib/factoryMixins/SolutionModifiersFactory.js.map +0 -1
- package/lib/factoryMixins/TermFactory.js.map +0 -1
- package/lib/factoryMixins/UpdateOperationFactory.js.map +0 -1
- package/lib/factoryMixins/mixins.js.map +0 -1
- package/lib/grammar/builtIn.js.map +0 -1
- package/lib/grammar/dataSetClause.js.map +0 -1
- package/lib/grammar/expression.js.map +0 -1
- package/lib/grammar/general.js.map +0 -1
- package/lib/grammar/index.js.map +0 -1
- package/lib/grammar/literals.js.map +0 -1
- package/lib/grammar/propertyPaths.js.map +0 -1
- package/lib/grammar/queryUnit.js.map +0 -1
- package/lib/grammar/solutionModifier.js.map +0 -1
- package/lib/grammar/tripleBlock.js.map +0 -1
- package/lib/grammar/updateUnit.js.map +0 -1
- package/lib/grammar/whereClause.js.map +0 -1
- package/lib/index.cjs +0 -14665
- package/lib/index.js.map +0 -1
- package/lib/lexer/BuiltInCalls.js.map +0 -1
- package/lib/lexer/graph.js.map +0 -1
- package/lib/lexer/index.js.map +0 -1
- package/lib/lexer/lexer.js.map +0 -1
- package/lib/lexer/lexerPatterns.js.map +0 -1
- package/lib/lexer/symbols.js.map +0 -1
- package/lib/lexer/terminals.js.map +0 -1
- package/lib/sparql11HelperTypes.js.map +0 -1
- package/lib/utils.js.map +0 -1
- package/lib/validation/validators.js.map +0 -1
- /package/{lib → dist/esm/lib}/MinimalSparqlParser.d.ts +0 -0
- /package/{lib → dist/esm/lib}/MinimalSparqlParser.js +0 -0
- /package/{lib → dist/esm/lib}/Sparql11types.d.ts +0 -0
- /package/{lib → dist/esm/lib}/Sparql11types.js +0 -0
- /package/{lib → dist/esm/lib}/astFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/astFactory.js +0 -0
- /package/{lib → dist/esm/lib}/expressionHelpers.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/ContextFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/ContextFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/ExpressionFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/ExpressionFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/GraphRefFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/GraphRefFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/PathFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/PathFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/Patternfactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/Patternfactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/QueryFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/QueryFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/SolutionModifiersFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/SolutionModifiersFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/TermFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/TermFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/UpdateOperationFactory.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/UpdateOperationFactory.js +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/mixins.d.ts +0 -0
- /package/{lib → dist/esm/lib}/factoryMixins/mixins.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/builtIn.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/dataSetClause.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/expression.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/expression.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/general.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/general.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/index.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/index.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/literals.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/literals.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/propertyPaths.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/queryUnit.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/queryUnit.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/solutionModifier.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/solutionModifier.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/tripleBlock.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/tripleBlock.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/updateUnit.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/updateUnit.js +0 -0
- /package/{lib → dist/esm/lib}/grammar/whereClause.d.ts +0 -0
- /package/{lib → dist/esm/lib}/grammar/whereClause.js +0 -0
- /package/{lib → dist/esm/lib}/index.d.ts +0 -0
- /package/{lib → dist/esm/lib}/index.js +0 -0
- /package/{lib → dist/esm/lib}/lexer/BuiltInCalls.d.ts +0 -0
- /package/{lib → dist/esm/lib}/lexer/BuiltInCalls.js +0 -0
- /package/{lib → dist/esm/lib}/lexer/graph.d.ts +0 -0
- /package/{lib → dist/esm/lib}/lexer/graph.js +0 -0
- /package/{lib → dist/esm/lib}/lexer/index.d.ts +0 -0
- /package/{lib → dist/esm/lib}/lexer/index.js +0 -0
- /package/{lib → dist/esm/lib}/lexer/lexer.d.ts +0 -0
- /package/{lib → dist/esm/lib}/lexer/lexer.js +0 -0
- /package/{lib → dist/esm/lib}/lexer/lexerPatterns.d.ts +0 -0
- /package/{lib → dist/esm/lib}/lexer/lexerPatterns.js +0 -0
- /package/{lib → dist/esm/lib}/lexer/symbols.d.ts +0 -0
- /package/{lib → dist/esm/lib}/lexer/symbols.js +0 -0
- /package/{lib → dist/esm/lib}/lexer/terminals.d.ts +0 -0
- /package/{lib → dist/esm/lib}/sparql11HelperTypes.d.ts +0 -0
- /package/{lib → dist/esm/lib}/sparql11HelperTypes.js +0 -0
- /package/{lib → dist/esm/lib}/utils.d.ts +0 -0
- /package/{lib → dist/esm/lib}/utils.js +0 -0
- /package/{lib → dist/esm/lib}/validation/validators.d.ts +0 -0
|
@@ -0,0 +1,384 @@
|
|
|
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 tripleBlock_exports = {};
|
|
30
|
+
__export(tripleBlock_exports, {
|
|
31
|
+
blankNodePropertyList: () => blankNodePropertyList,
|
|
32
|
+
blankNodePropertyListPath: () => blankNodePropertyListPath,
|
|
33
|
+
collection: () => collection,
|
|
34
|
+
collectionPath: () => collectionPath,
|
|
35
|
+
graphNode: () => graphNode,
|
|
36
|
+
graphNodePath: () => graphNodePath,
|
|
37
|
+
object: () => object,
|
|
38
|
+
objectList: () => objectList,
|
|
39
|
+
objectListPath: () => objectListPath,
|
|
40
|
+
objectPath: () => objectPath,
|
|
41
|
+
propertyList: () => propertyList,
|
|
42
|
+
propertyListNotEmpty: () => propertyListNotEmpty,
|
|
43
|
+
propertyListPath: () => propertyListPath,
|
|
44
|
+
propertyListPathNotEmpty: () => propertyListPathNotEmpty,
|
|
45
|
+
triplesBlock: () => triplesBlock,
|
|
46
|
+
triplesNode: () => triplesNode,
|
|
47
|
+
triplesNodePath: () => triplesNodePath,
|
|
48
|
+
triplesSameSubject: () => triplesSameSubject,
|
|
49
|
+
triplesSameSubjectPath: () => triplesSameSubjectPath,
|
|
50
|
+
triplesTemplate: () => triplesTemplate,
|
|
51
|
+
verbPath: () => verbPath,
|
|
52
|
+
verbSimple: () => verbSimple
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(tripleBlock_exports);
|
|
55
|
+
var import_core = require("@traqula/core");
|
|
56
|
+
var l = __toESM(require("../lexer/index.js"), 1);
|
|
57
|
+
var import_utils = require("../utils.js");
|
|
58
|
+
var import_general = require("./general.js");
|
|
59
|
+
var import_propertyPaths = require("./propertyPaths.js");
|
|
60
|
+
function triplesDotSeperated(triplesSameSubjectSubrule) {
|
|
61
|
+
return ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME, OPTION }) => (C) => {
|
|
62
|
+
const triples = [];
|
|
63
|
+
let parsedDot = true;
|
|
64
|
+
let dotToken;
|
|
65
|
+
AT_LEAST_ONE({
|
|
66
|
+
GATE: () => parsedDot,
|
|
67
|
+
DEF: () => {
|
|
68
|
+
parsedDot = false;
|
|
69
|
+
const template = SUBRULE(triplesSameSubjectSubrule);
|
|
70
|
+
ACTION(() => {
|
|
71
|
+
triples.push(...template);
|
|
72
|
+
});
|
|
73
|
+
OPTION(() => {
|
|
74
|
+
dotToken = CONSUME(l.symbols.dot);
|
|
75
|
+
parsedDot = true;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return ACTION(() => C.astFactory.patternBgp(triples, C.astFactory.sourceLocation(...triples, dotToken)));
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const triplesBlock = {
|
|
83
|
+
name: "triplesBlock",
|
|
84
|
+
impl: (implArgs) => (C) => triplesDotSeperated(triplesSameSubjectPath)(implArgs)(C),
|
|
85
|
+
gImpl: ({ SUBRULE, PRINT_WORD, HANDLE_LOC, NEW_LINE }) => (ast, { astFactory: F }) => {
|
|
86
|
+
for (const [index, triple] of ast.triples.entries()) {
|
|
87
|
+
HANDLE_LOC(triple, () => {
|
|
88
|
+
const nextTriple = ast.triples.at(index);
|
|
89
|
+
if (F.isTripleCollection(triple)) {
|
|
90
|
+
SUBRULE(graphNodePath, triple);
|
|
91
|
+
F.printFilter(triple, () => {
|
|
92
|
+
PRINT_WORD(".");
|
|
93
|
+
NEW_LINE();
|
|
94
|
+
});
|
|
95
|
+
} else {
|
|
96
|
+
SUBRULE(graphNodePath, triple.subject);
|
|
97
|
+
F.printFilter(triple, () => PRINT_WORD(""));
|
|
98
|
+
if (F.isTerm(triple.predicate) && F.isTermVariable(triple.predicate)) {
|
|
99
|
+
SUBRULE(import_general.varOrTerm, triple.predicate);
|
|
100
|
+
} else {
|
|
101
|
+
SUBRULE(import_propertyPaths.pathGenerator, triple.predicate, void 0);
|
|
102
|
+
}
|
|
103
|
+
F.printFilter(triple, () => PRINT_WORD(""));
|
|
104
|
+
SUBRULE(graphNodePath, triple.object);
|
|
105
|
+
if (nextTriple === void 0 || F.isTripleCollection(nextTriple) || !F.isSourceLocationNoMaterialize(nextTriple.subject.loc)) {
|
|
106
|
+
F.printFilter(ast, () => {
|
|
107
|
+
PRINT_WORD(".");
|
|
108
|
+
NEW_LINE();
|
|
109
|
+
});
|
|
110
|
+
} else if (F.isSourceLocationNoMaterialize(nextTriple.predicate.loc)) {
|
|
111
|
+
F.printFilter(ast, () => PRINT_WORD(","));
|
|
112
|
+
} else {
|
|
113
|
+
F.printFilter(ast, () => {
|
|
114
|
+
PRINT_WORD(";");
|
|
115
|
+
NEW_LINE();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
function triplesSameSubjectImpl(name, allowPaths) {
|
|
124
|
+
return {
|
|
125
|
+
name,
|
|
126
|
+
impl: ({ ACTION, SUBRULE, OR }) => (C) => OR([
|
|
127
|
+
{ ALT: () => {
|
|
128
|
+
const subject = SUBRULE(import_general.varOrTerm);
|
|
129
|
+
const res = SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, ACTION(() => C.astFactory.dematerialized(subject)));
|
|
130
|
+
return ACTION(() => {
|
|
131
|
+
if (res.length > 0) {
|
|
132
|
+
res[0].subject = subject;
|
|
133
|
+
res[0].loc = C.astFactory.sourceLocation(subject, res[0]);
|
|
134
|
+
}
|
|
135
|
+
return res;
|
|
136
|
+
});
|
|
137
|
+
} },
|
|
138
|
+
{ ALT: () => {
|
|
139
|
+
const subjectNode = SUBRULE(allowPaths ? triplesNodePath : triplesNode);
|
|
140
|
+
const restNode = SUBRULE(allowPaths ? propertyListPath : propertyList, ACTION(() => C.astFactory.graphNodeIdentifier(subjectNode)));
|
|
141
|
+
return ACTION(() => {
|
|
142
|
+
if (restNode.length === 0) {
|
|
143
|
+
return [subjectNode];
|
|
144
|
+
}
|
|
145
|
+
restNode[0].subject = subjectNode;
|
|
146
|
+
restNode[0].loc = C.astFactory.sourceLocation(subjectNode, restNode[0]);
|
|
147
|
+
return restNode;
|
|
148
|
+
});
|
|
149
|
+
} }
|
|
150
|
+
])
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const triplesSameSubject = triplesSameSubjectImpl("triplesSameSubject", false);
|
|
154
|
+
const triplesSameSubjectPath = triplesSameSubjectImpl("triplesSameSubjectPath", true);
|
|
155
|
+
const triplesTemplate = {
|
|
156
|
+
name: "triplesTemplate",
|
|
157
|
+
impl: triplesDotSeperated(triplesSameSubject)
|
|
158
|
+
};
|
|
159
|
+
function propertyListImpl(name, allowPaths) {
|
|
160
|
+
return {
|
|
161
|
+
name,
|
|
162
|
+
impl: ({ SUBRULE, OPTION }) => (_, subject) => OPTION(() => SUBRULE(allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty, subject)) ?? []
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
const propertyList = propertyListImpl("propertyList", false);
|
|
166
|
+
const propertyListPath = propertyListImpl("propertyListPath", true);
|
|
167
|
+
function propertyListNotEmptyImplementation(name, allowPaths) {
|
|
168
|
+
return {
|
|
169
|
+
name,
|
|
170
|
+
impl: ({ ACTION, CONSUME, AT_LEAST_ONE, SUBRULE1, MANY2, OR1 }) => (_, subject) => {
|
|
171
|
+
const result = [];
|
|
172
|
+
let parsedSemi = true;
|
|
173
|
+
AT_LEAST_ONE({
|
|
174
|
+
GATE: () => parsedSemi,
|
|
175
|
+
DEF: () => {
|
|
176
|
+
parsedSemi = false;
|
|
177
|
+
const predicate = allowPaths ? OR1([
|
|
178
|
+
{ ALT: () => SUBRULE1(verbPath) },
|
|
179
|
+
{ ALT: () => SUBRULE1(verbSimple) }
|
|
180
|
+
]) : SUBRULE1(import_general.verb);
|
|
181
|
+
const triples = SUBRULE1(allowPaths ? objectListPath : objectList, subject, predicate);
|
|
182
|
+
MANY2(() => {
|
|
183
|
+
CONSUME(l.symbols.semi);
|
|
184
|
+
parsedSemi = true;
|
|
185
|
+
});
|
|
186
|
+
ACTION(() => {
|
|
187
|
+
result.push(...triples);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const propertyListNotEmpty = propertyListNotEmptyImplementation("propertyListNotEmpty", false);
|
|
196
|
+
const propertyListPathNotEmpty = propertyListNotEmptyImplementation("propertyListPathNotEmpty", true);
|
|
197
|
+
const verbPath = {
|
|
198
|
+
name: "verbPath",
|
|
199
|
+
impl: ({ SUBRULE }) => () => SUBRULE(import_propertyPaths.path)
|
|
200
|
+
};
|
|
201
|
+
const verbSimple = {
|
|
202
|
+
name: "verbSimple",
|
|
203
|
+
impl: ({ SUBRULE }) => () => SUBRULE(import_general.var_)
|
|
204
|
+
};
|
|
205
|
+
function objectListImpl(name, allowPaths) {
|
|
206
|
+
return {
|
|
207
|
+
name,
|
|
208
|
+
impl: ({ ACTION, SUBRULE, AT_LEAST_ONE_SEP }) => (_, subj, pred) => {
|
|
209
|
+
const objects = [];
|
|
210
|
+
AT_LEAST_ONE_SEP({
|
|
211
|
+
SEP: l.symbols.comma,
|
|
212
|
+
DEF: () => {
|
|
213
|
+
const objectTriple = SUBRULE(allowPaths ? objectPath : object, subj, pred);
|
|
214
|
+
ACTION(() => {
|
|
215
|
+
objects.push(objectTriple);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return objects;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
const objectList = objectListImpl("objectList", false);
|
|
224
|
+
const objectListPath = objectListImpl("objectListPath", true);
|
|
225
|
+
function objectImpl(name, allowPaths) {
|
|
226
|
+
return {
|
|
227
|
+
name,
|
|
228
|
+
impl: ({ ACTION, SUBRULE }) => (C, subject, predicate) => {
|
|
229
|
+
const node = SUBRULE(allowPaths ? graphNodePath : graphNode);
|
|
230
|
+
return ACTION(() => C.astFactory.triple(subject, predicate, node));
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const object = objectImpl("object", false);
|
|
235
|
+
const objectPath = objectImpl("objectPath", true);
|
|
236
|
+
function collectionImpl(name, allowPaths) {
|
|
237
|
+
return {
|
|
238
|
+
name,
|
|
239
|
+
impl: ({ ACTION, AT_LEAST_ONE, SUBRULE, CONSUME }) => (C) => {
|
|
240
|
+
const terms = [];
|
|
241
|
+
const startToken = CONSUME(l.symbols.LParen);
|
|
242
|
+
AT_LEAST_ONE(() => {
|
|
243
|
+
terms.push(SUBRULE(allowPaths ? graphNodePath : graphNode));
|
|
244
|
+
});
|
|
245
|
+
const endToken = CONSUME(l.symbols.RParen);
|
|
246
|
+
return ACTION(() => {
|
|
247
|
+
const F = C.astFactory;
|
|
248
|
+
const triples = [];
|
|
249
|
+
const predFirst = F.termNamed(F.sourceLocationNoMaterialize(), import_utils.CommonIRIs.FIRST, void 0);
|
|
250
|
+
const predRest = F.termNamed(F.sourceLocationNoMaterialize(), import_utils.CommonIRIs.REST, void 0);
|
|
251
|
+
const predNil = F.termNamed(F.sourceLocationNoMaterialize(), import_utils.CommonIRIs.NIL, void 0);
|
|
252
|
+
const listHead = F.termBlank(void 0, F.sourceLocationNoMaterialize());
|
|
253
|
+
let iterHead = listHead;
|
|
254
|
+
for (const [index, term] of terms.entries()) {
|
|
255
|
+
const lastInList = index === terms.length - 1;
|
|
256
|
+
const headTriple = F.triple(iterHead, predFirst, term);
|
|
257
|
+
triples.push(headTriple);
|
|
258
|
+
if (lastInList) {
|
|
259
|
+
const nilTriple = F.triple(iterHead, predRest, predNil);
|
|
260
|
+
triples.push(nilTriple);
|
|
261
|
+
} else {
|
|
262
|
+
const tail = F.termBlank(void 0, F.sourceLocationNoMaterialize());
|
|
263
|
+
const linkTriple = F.triple(iterHead, predRest, tail);
|
|
264
|
+
triples.push(linkTriple);
|
|
265
|
+
iterHead = tail;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return F.tripleCollectionList(listHead, triples, F.sourceLocation(startToken, endToken));
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
gImpl: ({ SUBRULE, PRINT_WORD }) => (ast, { astFactory: F }) => {
|
|
272
|
+
F.printFilter(ast, () => PRINT_WORD("("));
|
|
273
|
+
for (const [idx, triple] of ast.triples.entries()) {
|
|
274
|
+
if (idx % 2 === 0) {
|
|
275
|
+
SUBRULE(allowPaths ? graphNodePath : graphNode, triple.object);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
F.printFilter(ast, () => PRINT_WORD(")"));
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const collection = collectionImpl("collection", false);
|
|
283
|
+
const collectionPath = collectionImpl("collectionPath", true);
|
|
284
|
+
function triplesNodeImpl(name, allowPaths) {
|
|
285
|
+
return {
|
|
286
|
+
name,
|
|
287
|
+
impl: ({ SUBRULE, OR }) => () => OR([
|
|
288
|
+
{ ALT: () => SUBRULE(allowPaths ? collectionPath : collection) },
|
|
289
|
+
{ ALT: () => SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList) }
|
|
290
|
+
]),
|
|
291
|
+
gImpl: ({ SUBRULE }) => (ast) => ast.subType === "list" ? SUBRULE(allowPaths ? collectionPath : collection, ast) : SUBRULE(allowPaths ? blankNodePropertyListPath : blankNodePropertyList, ast)
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
const triplesNode = triplesNodeImpl("triplesNode", false);
|
|
295
|
+
const triplesNodePath = triplesNodeImpl("triplesNodePath", true);
|
|
296
|
+
function blankNodePropertyListImpl(name, allowPaths) {
|
|
297
|
+
const propertyPathNotEmptyImpl = allowPaths ? propertyListPathNotEmpty : propertyListNotEmpty;
|
|
298
|
+
return {
|
|
299
|
+
name,
|
|
300
|
+
impl: ({ ACTION, SUBRULE, CONSUME }) => (C) => {
|
|
301
|
+
const startToken = CONSUME(l.symbols.LSquare);
|
|
302
|
+
const blankNode = ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocationNoMaterialize()));
|
|
303
|
+
const propList = SUBRULE(propertyPathNotEmptyImpl, blankNode);
|
|
304
|
+
const endToken = CONSUME(l.symbols.RSquare);
|
|
305
|
+
return ACTION(() => C.astFactory.tripleCollectionBlankNodeProperties(blankNode, propList, C.astFactory.sourceLocation(startToken, endToken)));
|
|
306
|
+
},
|
|
307
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD, HANDLE_LOC, PRINT_ON_EMPTY, NEW_LINE }) => (ast, c) => {
|
|
308
|
+
const { astFactory: F, indentInc } = c;
|
|
309
|
+
F.printFilter(ast, () => {
|
|
310
|
+
c[import_core.traqulaIndentation] += indentInc;
|
|
311
|
+
PRINT("[");
|
|
312
|
+
NEW_LINE();
|
|
313
|
+
});
|
|
314
|
+
for (const triple of ast.triples) {
|
|
315
|
+
HANDLE_LOC(triple, () => {
|
|
316
|
+
if (F.isTerm(triple.predicate) && F.isTermVariable(triple.predicate)) {
|
|
317
|
+
SUBRULE(import_general.varOrTerm, triple.predicate);
|
|
318
|
+
} else {
|
|
319
|
+
SUBRULE(import_propertyPaths.pathGenerator, triple.predicate, void 0);
|
|
320
|
+
}
|
|
321
|
+
F.printFilter(triple, () => PRINT_WORD(""));
|
|
322
|
+
SUBRULE(graphNodePath, triple.object);
|
|
323
|
+
F.printFilter(ast, () => {
|
|
324
|
+
PRINT_WORD(";");
|
|
325
|
+
NEW_LINE();
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
F.printFilter(ast, () => {
|
|
330
|
+
c[import_core.traqulaIndentation] -= indentInc;
|
|
331
|
+
PRINT_ON_EMPTY("]");
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
const blankNodePropertyList = blankNodePropertyListImpl("blankNodePropertyList", false);
|
|
337
|
+
const blankNodePropertyListPath = blankNodePropertyListImpl("blankNodePropertyListPath", true);
|
|
338
|
+
function graphNodeImpl(name, allowPaths) {
|
|
339
|
+
const triplesNodeRule = allowPaths ? triplesNodePath : triplesNode;
|
|
340
|
+
return {
|
|
341
|
+
name,
|
|
342
|
+
impl: ({ SUBRULE, OR }) => (C) => OR([
|
|
343
|
+
{ ALT: () => SUBRULE(import_general.varOrTerm) },
|
|
344
|
+
{
|
|
345
|
+
GATE: () => C.parseMode.has("canCreateBlankNodes"),
|
|
346
|
+
ALT: () => SUBRULE(triplesNodeRule)
|
|
347
|
+
}
|
|
348
|
+
]),
|
|
349
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F }) => {
|
|
350
|
+
if (F.isTerm(ast)) {
|
|
351
|
+
SUBRULE(import_general.varOrTerm, ast);
|
|
352
|
+
} else {
|
|
353
|
+
SUBRULE(triplesNodeRule, ast);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
const graphNode = graphNodeImpl("graphNode", false);
|
|
359
|
+
const graphNodePath = graphNodeImpl("graphNodePath", true);
|
|
360
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
361
|
+
0 && (module.exports = {
|
|
362
|
+
blankNodePropertyList,
|
|
363
|
+
blankNodePropertyListPath,
|
|
364
|
+
collection,
|
|
365
|
+
collectionPath,
|
|
366
|
+
graphNode,
|
|
367
|
+
graphNodePath,
|
|
368
|
+
object,
|
|
369
|
+
objectList,
|
|
370
|
+
objectListPath,
|
|
371
|
+
objectPath,
|
|
372
|
+
propertyList,
|
|
373
|
+
propertyListNotEmpty,
|
|
374
|
+
propertyListPath,
|
|
375
|
+
propertyListPathNotEmpty,
|
|
376
|
+
triplesBlock,
|
|
377
|
+
triplesNode,
|
|
378
|
+
triplesNodePath,
|
|
379
|
+
triplesSameSubject,
|
|
380
|
+
triplesSameSubjectPath,
|
|
381
|
+
triplesTemplate,
|
|
382
|
+
verbPath,
|
|
383
|
+
verbSimple
|
|
384
|
+
});
|