@traqula/rules-sparql-1-1 0.0.21 → 0.0.23
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/cjs/package.json +1 -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 +3 -3
- 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/{lib → dist/esm/lib}/grammar/tripleBlock.d.ts +4 -4
- 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/{lib → dist/esm/lib}/lexer/BuiltInCalls.d.ts +1 -1
- package/dist/esm/lib/lexer/BuiltInCalls.js.map +1 -0
- package/{lib → dist/esm/lib}/lexer/graph.d.ts +1 -1
- package/dist/esm/lib/lexer/graph.js.map +1 -0
- package/dist/esm/lib/lexer/index.js.map +1 -0
- package/{lib → dist/esm/lib}/lexer/lexer.d.ts +2 -2
- package/dist/esm/lib/lexer/lexer.js.map +1 -0
- package/dist/esm/lib/lexer/lexerPatterns.js.map +1 -0
- package/{lib → dist/esm/lib}/lexer/symbols.d.ts +1 -1
- package/dist/esm/lib/lexer/symbols.js.map +1 -0
- package/{lib → dist/esm/lib}/lexer/terminals.d.ts +1 -1
- 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/dist/esm/lib/validation/validators.js.map +1 -0
- package/package.json +14 -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 -14673
- 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.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.js +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.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.js +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
- /package/{lib → dist/esm/lib}/validation/validators.js +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
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 literals_exports = {};
|
|
30
|
+
__export(literals_exports, {
|
|
31
|
+
blankNode: () => blankNode,
|
|
32
|
+
booleanLiteral: () => booleanLiteral,
|
|
33
|
+
canCreateBlankNodes: () => canCreateBlankNodes,
|
|
34
|
+
iri: () => iri,
|
|
35
|
+
iriFull: () => iriFull,
|
|
36
|
+
numericLiteral: () => numericLiteral,
|
|
37
|
+
numericLiteralNegative: () => numericLiteralNegative,
|
|
38
|
+
numericLiteralPositive: () => numericLiteralPositive,
|
|
39
|
+
numericLiteralUnsigned: () => numericLiteralUnsigned,
|
|
40
|
+
prefixedName: () => prefixedName,
|
|
41
|
+
rdfLiteral: () => rdfLiteral,
|
|
42
|
+
string: () => string,
|
|
43
|
+
stringEscapedLexical: () => stringEscapedLexical,
|
|
44
|
+
verbA: () => verbA
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(literals_exports);
|
|
47
|
+
var l = __toESM(require("../lexer/index.js"), 1);
|
|
48
|
+
var import_utils = require("../utils.js");
|
|
49
|
+
function stringEscapedLexical(str) {
|
|
50
|
+
const lexical = str.replaceAll(/["\\\t\n\r\b\f]/gu, (char) => {
|
|
51
|
+
switch (char) {
|
|
52
|
+
case " ":
|
|
53
|
+
return "\\t";
|
|
54
|
+
case "\n":
|
|
55
|
+
return "\\n";
|
|
56
|
+
case "\r":
|
|
57
|
+
return "\\r";
|
|
58
|
+
case "\b":
|
|
59
|
+
return "\\b";
|
|
60
|
+
case "\f":
|
|
61
|
+
return "\\f";
|
|
62
|
+
case '"':
|
|
63
|
+
return '\\"';
|
|
64
|
+
case "\\":
|
|
65
|
+
return "\\\\";
|
|
66
|
+
default:
|
|
67
|
+
return char;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return `"${lexical}"`;
|
|
71
|
+
}
|
|
72
|
+
const rdfLiteral = {
|
|
73
|
+
name: "rdfLiteral",
|
|
74
|
+
impl: ({ ACTION, SUBRULE1, CONSUME, OPTION, OR }) => (C) => {
|
|
75
|
+
const value = SUBRULE1(string);
|
|
76
|
+
return OPTION(() => OR([
|
|
77
|
+
{ ALT: () => {
|
|
78
|
+
const lang = CONSUME(l.terminals.langTag);
|
|
79
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, lang), value.value, lang.image.slice(1).toLowerCase()));
|
|
80
|
+
} },
|
|
81
|
+
{ ALT: () => {
|
|
82
|
+
CONSUME(l.symbols.hathat);
|
|
83
|
+
const iriVal = SUBRULE1(iri);
|
|
84
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(value, iriVal), value.value, iriVal));
|
|
85
|
+
} }
|
|
86
|
+
])) ?? value;
|
|
87
|
+
},
|
|
88
|
+
gImpl: ({ SUBRULE, PRINT, PRINT_WORD }) => (ast, { astFactory }) => {
|
|
89
|
+
astFactory.printFilter(ast, () => {
|
|
90
|
+
PRINT_WORD("");
|
|
91
|
+
PRINT(stringEscapedLexical(ast.value));
|
|
92
|
+
});
|
|
93
|
+
if (ast.langOrIri) {
|
|
94
|
+
if (typeof ast.langOrIri === "string") {
|
|
95
|
+
astFactory.printFilter(ast, () => PRINT("@", ast.langOrIri));
|
|
96
|
+
} else {
|
|
97
|
+
astFactory.printFilter(ast, () => PRINT("^^"));
|
|
98
|
+
SUBRULE(iri, ast.langOrIri);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const numericLiteral = {
|
|
104
|
+
name: "numericLiteral",
|
|
105
|
+
impl: ({ SUBRULE, OR }) => () => OR([
|
|
106
|
+
{ ALT: () => SUBRULE(numericLiteralUnsigned) },
|
|
107
|
+
{ ALT: () => SUBRULE(numericLiteralPositive) },
|
|
108
|
+
{ ALT: () => SUBRULE(numericLiteralNegative) }
|
|
109
|
+
])
|
|
110
|
+
};
|
|
111
|
+
const numericLiteralUnsigned = {
|
|
112
|
+
name: "numericLiteralUnsigned",
|
|
113
|
+
impl: ({ ACTION, CONSUME, OR }) => (C) => {
|
|
114
|
+
const parsed = OR([
|
|
115
|
+
{ ALT: () => [CONSUME(l.terminals.integer), import_utils.CommonIRIs.INTEGER] },
|
|
116
|
+
{ ALT: () => [CONSUME(l.terminals.decimal), import_utils.CommonIRIs.DECIMAL] },
|
|
117
|
+
{ ALT: () => [CONSUME(l.terminals.double), import_utils.CommonIRIs.DOUBLE] }
|
|
118
|
+
]);
|
|
119
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const numericLiteralPositive = {
|
|
123
|
+
name: "numericLiteralPositive",
|
|
124
|
+
impl: ({ ACTION, CONSUME, OR }) => (C) => {
|
|
125
|
+
const parsed = OR([
|
|
126
|
+
{ ALT: () => [CONSUME(l.terminals.integerPositive), import_utils.CommonIRIs.INTEGER] },
|
|
127
|
+
{ ALT: () => [CONSUME(l.terminals.decimalPositive), import_utils.CommonIRIs.DECIMAL] },
|
|
128
|
+
{ ALT: () => [CONSUME(l.terminals.doublePositive), import_utils.CommonIRIs.DOUBLE] }
|
|
129
|
+
]);
|
|
130
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const numericLiteralNegative = {
|
|
134
|
+
name: "numericLiteralNegative",
|
|
135
|
+
impl: ({ ACTION, CONSUME, OR }) => (C) => {
|
|
136
|
+
const parsed = OR([
|
|
137
|
+
{ ALT: () => [CONSUME(l.terminals.integerNegative), import_utils.CommonIRIs.INTEGER] },
|
|
138
|
+
{ ALT: () => [CONSUME(l.terminals.decimalNegative), import_utils.CommonIRIs.DECIMAL] },
|
|
139
|
+
{ ALT: () => [CONSUME(l.terminals.doubleNegative), import_utils.CommonIRIs.DOUBLE] }
|
|
140
|
+
]);
|
|
141
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(parsed[0]), parsed[0].image, C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), parsed[1])));
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const booleanLiteral = {
|
|
145
|
+
name: "booleanLiteral",
|
|
146
|
+
impl: ({ ACTION, CONSUME, OR }) => (C) => {
|
|
147
|
+
const token = OR([
|
|
148
|
+
{ ALT: () => CONSUME(l.true_) },
|
|
149
|
+
{ ALT: () => CONSUME(l.false_) }
|
|
150
|
+
]);
|
|
151
|
+
return ACTION(() => C.astFactory.termLiteral(C.astFactory.sourceLocation(token), token.image.toLowerCase(), C.astFactory.termNamed(C.astFactory.sourceLocationNoMaterialize(), import_utils.CommonIRIs.BOOLEAN)));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const string = {
|
|
155
|
+
name: "string",
|
|
156
|
+
impl: ({ ACTION, CONSUME, OR }) => (C) => {
|
|
157
|
+
const x = OR([
|
|
158
|
+
{ ALT: () => {
|
|
159
|
+
const token = CONSUME(l.terminals.stringLiteral1);
|
|
160
|
+
return [token, token.image.slice(1, -1)];
|
|
161
|
+
} },
|
|
162
|
+
{ ALT: () => {
|
|
163
|
+
const token = CONSUME(l.terminals.stringLiteral2);
|
|
164
|
+
return [token, token.image.slice(1, -1)];
|
|
165
|
+
} },
|
|
166
|
+
{ ALT: () => {
|
|
167
|
+
const token = CONSUME(l.terminals.stringLiteralLong1);
|
|
168
|
+
return [token, token.image.slice(3, -3)];
|
|
169
|
+
} },
|
|
170
|
+
{ ALT: () => {
|
|
171
|
+
const token = CONSUME(l.terminals.stringLiteralLong2);
|
|
172
|
+
return [token, token.image.slice(3, -3)];
|
|
173
|
+
} }
|
|
174
|
+
]);
|
|
175
|
+
return ACTION(() => {
|
|
176
|
+
const F = C.astFactory;
|
|
177
|
+
const value = x[1].replaceAll(/\\([tnrbf"'\\])/gu, (_, char) => {
|
|
178
|
+
switch (char) {
|
|
179
|
+
case "t":
|
|
180
|
+
return " ";
|
|
181
|
+
case "n":
|
|
182
|
+
return "\n";
|
|
183
|
+
case "r":
|
|
184
|
+
return "\r";
|
|
185
|
+
case "b":
|
|
186
|
+
return "\b";
|
|
187
|
+
case "f":
|
|
188
|
+
return "\f";
|
|
189
|
+
default:
|
|
190
|
+
return char;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
return F.termLiteral(F.sourceLocation(x[0]), value);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const iri = {
|
|
198
|
+
name: "iri",
|
|
199
|
+
impl: ({ SUBRULE, OR }) => () => OR([
|
|
200
|
+
{ ALT: () => SUBRULE(iriFull) },
|
|
201
|
+
{ ALT: () => SUBRULE(prefixedName) }
|
|
202
|
+
]),
|
|
203
|
+
gImpl: ({ SUBRULE }) => (ast, { astFactory: F }) => F.isTermNamedPrefixed(ast) ? SUBRULE(prefixedName, ast) : SUBRULE(iriFull, ast)
|
|
204
|
+
};
|
|
205
|
+
const iriFull = {
|
|
206
|
+
name: "iriFull",
|
|
207
|
+
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
208
|
+
const iriToken = CONSUME(l.terminals.iriRef);
|
|
209
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(iriToken), iriToken.image.slice(1, -1)));
|
|
210
|
+
},
|
|
211
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F }) => {
|
|
212
|
+
F.printFilter(ast, () => PRINT("<", ast.value, ">"));
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const prefixedName = {
|
|
216
|
+
name: "prefixedName",
|
|
217
|
+
impl: ({ ACTION, CONSUME, OR }) => (C) => OR([
|
|
218
|
+
{ ALT: () => {
|
|
219
|
+
const longName = CONSUME(l.terminals.pNameLn);
|
|
220
|
+
return ACTION(() => {
|
|
221
|
+
const [prefix, localName] = longName.image.split(":");
|
|
222
|
+
return C.astFactory.termNamed(C.astFactory.sourceLocation(longName), localName, prefix);
|
|
223
|
+
});
|
|
224
|
+
} },
|
|
225
|
+
{ ALT: () => {
|
|
226
|
+
const shortName = CONSUME(l.terminals.pNameNs);
|
|
227
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(shortName), "", shortName.image.slice(0, -1)));
|
|
228
|
+
} }
|
|
229
|
+
]),
|
|
230
|
+
gImpl: ({ PRINT }) => (ast, { astFactory: F }) => {
|
|
231
|
+
F.printFilter(ast, () => PRINT(ast.prefix, ":", ast.value));
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
const canCreateBlankNodes = Symbol("canCreateBlankNodes");
|
|
235
|
+
const blankNode = {
|
|
236
|
+
name: "blankNode",
|
|
237
|
+
impl: ({ ACTION, CONSUME, OR }) => (C) => {
|
|
238
|
+
const result = OR([
|
|
239
|
+
{ ALT: () => {
|
|
240
|
+
const labelToken = CONSUME(l.terminals.blankNodeLabel);
|
|
241
|
+
return ACTION(() => C.astFactory.termBlank(labelToken.image.slice(2), C.astFactory.sourceLocation(labelToken)));
|
|
242
|
+
} },
|
|
243
|
+
{ ALT: () => {
|
|
244
|
+
const anonToken = CONSUME(l.terminals.anon);
|
|
245
|
+
return ACTION(() => C.astFactory.termBlank(void 0, C.astFactory.sourceLocation(anonToken)));
|
|
246
|
+
} }
|
|
247
|
+
]);
|
|
248
|
+
ACTION(() => {
|
|
249
|
+
if (!C.parseMode.has("canCreateBlankNodes")) {
|
|
250
|
+
throw new Error("Blank nodes are not allowed in this context");
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
return result;
|
|
254
|
+
},
|
|
255
|
+
gImpl: ({ PRINT }) => (ast, { astFactory }) => {
|
|
256
|
+
astFactory.printFilter(ast, () => PRINT("_:", ast.label.replace(/^e_/u, "")));
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const verbA = {
|
|
260
|
+
name: "VerbA",
|
|
261
|
+
impl: ({ ACTION, CONSUME }) => (C) => {
|
|
262
|
+
const token = CONSUME(l.a);
|
|
263
|
+
return ACTION(() => C.astFactory.termNamed(C.astFactory.sourceLocation(token), import_utils.CommonIRIs.TYPE, void 0));
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
267
|
+
0 && (module.exports = {
|
|
268
|
+
blankNode,
|
|
269
|
+
booleanLiteral,
|
|
270
|
+
canCreateBlankNodes,
|
|
271
|
+
iri,
|
|
272
|
+
iriFull,
|
|
273
|
+
numericLiteral,
|
|
274
|
+
numericLiteralNegative,
|
|
275
|
+
numericLiteralPositive,
|
|
276
|
+
numericLiteralUnsigned,
|
|
277
|
+
prefixedName,
|
|
278
|
+
rdfLiteral,
|
|
279
|
+
string,
|
|
280
|
+
stringEscapedLexical,
|
|
281
|
+
verbA
|
|
282
|
+
});
|
|
@@ -0,0 +1,206 @@
|
|
|
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 propertyPaths_exports = {};
|
|
30
|
+
__export(propertyPaths_exports, {
|
|
31
|
+
path: () => path,
|
|
32
|
+
pathAlternative: () => pathAlternative,
|
|
33
|
+
pathChainHelper: () => pathChainHelper,
|
|
34
|
+
pathElt: () => pathElt,
|
|
35
|
+
pathEltOrInverse: () => pathEltOrInverse,
|
|
36
|
+
pathGenerator: () => pathGenerator,
|
|
37
|
+
pathMod: () => pathMod,
|
|
38
|
+
pathNegatedPropertySet: () => pathNegatedPropertySet,
|
|
39
|
+
pathOneInPropertySet: () => pathOneInPropertySet,
|
|
40
|
+
pathPrimary: () => pathPrimary,
|
|
41
|
+
pathSequence: () => pathSequence
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(propertyPaths_exports);
|
|
44
|
+
var l = __toESM(require("../lexer/index.js"), 1);
|
|
45
|
+
var import_literals = require("./literals.js");
|
|
46
|
+
const path = {
|
|
47
|
+
name: "path",
|
|
48
|
+
impl: ({ SUBRULE }) => () => SUBRULE(pathAlternative)
|
|
49
|
+
};
|
|
50
|
+
const pathGenerator = {
|
|
51
|
+
name: "path",
|
|
52
|
+
gImpl: ({ PRINT, SUBRULE }) => (ast, { astFactory: F }, braces = true) => {
|
|
53
|
+
if (F.isTerm(ast) && F.isTermNamed(ast)) {
|
|
54
|
+
SUBRULE(import_literals.iri, ast);
|
|
55
|
+
} else {
|
|
56
|
+
F.printFilter(ast, () => braces && PRINT("("));
|
|
57
|
+
switch (ast.subType) {
|
|
58
|
+
case "|":
|
|
59
|
+
case "/": {
|
|
60
|
+
const [head, ...tail] = ast.items;
|
|
61
|
+
SUBRULE(pathGenerator, head, braces);
|
|
62
|
+
for (const val of tail) {
|
|
63
|
+
F.printFilter(ast, () => PRINT(ast.subType));
|
|
64
|
+
SUBRULE(pathGenerator, val, braces);
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
case "^":
|
|
69
|
+
F.printFilter(ast, () => PRINT("^"));
|
|
70
|
+
SUBRULE(pathGenerator, ast.items[0], braces);
|
|
71
|
+
break;
|
|
72
|
+
case "?":
|
|
73
|
+
case "*":
|
|
74
|
+
case "+":
|
|
75
|
+
SUBRULE(pathGenerator, ast.items[0], braces);
|
|
76
|
+
F.printFilter(ast, () => PRINT(ast.subType));
|
|
77
|
+
break;
|
|
78
|
+
case "!":
|
|
79
|
+
F.printFilter(ast, () => PRINT("!"));
|
|
80
|
+
F.printFilter(ast, () => PRINT("("));
|
|
81
|
+
SUBRULE(pathGenerator, ast.items[0], false);
|
|
82
|
+
F.printFilter(ast, () => PRINT(")"));
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
F.printFilter(ast, () => braces && PRINT(")"));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function pathChainHelper(name, SEP, subType, subRule) {
|
|
90
|
+
return {
|
|
91
|
+
name,
|
|
92
|
+
impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, MANY }) => (C) => {
|
|
93
|
+
const head = SUBRULE1(subRule);
|
|
94
|
+
let tailEnd = head;
|
|
95
|
+
const tail = [];
|
|
96
|
+
MANY(() => {
|
|
97
|
+
CONSUME(SEP);
|
|
98
|
+
tailEnd = SUBRULE2(subRule);
|
|
99
|
+
tail.push(tailEnd);
|
|
100
|
+
});
|
|
101
|
+
return ACTION(() => tail.length === 0 ? head : C.astFactory.path(subType, [head, ...tail], C.astFactory.sourceLocation(head, tailEnd)));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
const pathEltOrInverse = {
|
|
106
|
+
name: "pathEltOrInverse",
|
|
107
|
+
impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR }) => (C) => OR([
|
|
108
|
+
{ ALT: () => SUBRULE1(pathElt) },
|
|
109
|
+
{ ALT: () => {
|
|
110
|
+
const hat = CONSUME(l.symbols.hat);
|
|
111
|
+
const item = SUBRULE2(pathElt);
|
|
112
|
+
return ACTION(() => C.astFactory.path("^", [item], C.astFactory.sourceLocation(hat, item)));
|
|
113
|
+
} }
|
|
114
|
+
])
|
|
115
|
+
};
|
|
116
|
+
const pathSequence = pathChainHelper("pathSequence", l.symbols.slash, "/", pathEltOrInverse);
|
|
117
|
+
const pathAlternative = pathChainHelper("pathAlternative", l.symbols.pipe, "|", pathSequence);
|
|
118
|
+
const pathElt = {
|
|
119
|
+
name: "pathElt",
|
|
120
|
+
impl: ({ ACTION, SUBRULE, OPTION }) => (C) => {
|
|
121
|
+
const item = SUBRULE(pathPrimary);
|
|
122
|
+
const modification = OPTION(() => SUBRULE(pathMod));
|
|
123
|
+
return ACTION(() => modification === void 0 ? item : C.astFactory.path(modification.image, [item], C.astFactory.sourceLocation(item, modification)));
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const pathMod = {
|
|
127
|
+
name: "pathMod",
|
|
128
|
+
impl: ({ CONSUME, OR }) => () => OR([
|
|
129
|
+
{ ALT: () => CONSUME(l.symbols.question) },
|
|
130
|
+
{ ALT: () => CONSUME(l.symbols.star) },
|
|
131
|
+
{ ALT: () => CONSUME(l.symbols.opPlus) }
|
|
132
|
+
])
|
|
133
|
+
};
|
|
134
|
+
const pathPrimary = {
|
|
135
|
+
name: "pathPrimary",
|
|
136
|
+
impl: ({ SUBRULE, CONSUME, OR }) => () => OR([
|
|
137
|
+
{ ALT: () => SUBRULE(import_literals.iri) },
|
|
138
|
+
{ ALT: () => SUBRULE(import_literals.verbA) },
|
|
139
|
+
{ ALT: () => SUBRULE(pathNegatedPropertySet) },
|
|
140
|
+
{ ALT: () => {
|
|
141
|
+
CONSUME(l.symbols.LParen);
|
|
142
|
+
const resRecursive = SUBRULE(path);
|
|
143
|
+
CONSUME(l.symbols.RParen);
|
|
144
|
+
return resRecursive;
|
|
145
|
+
} }
|
|
146
|
+
])
|
|
147
|
+
};
|
|
148
|
+
const pathNegatedPropertySet = {
|
|
149
|
+
name: "pathNegatedPropertySet",
|
|
150
|
+
impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, SUBRULE3, OR, MANY }) => (C) => {
|
|
151
|
+
const exclamation = CONSUME(l.symbols.exclamation);
|
|
152
|
+
return OR([
|
|
153
|
+
{ ALT: () => {
|
|
154
|
+
const noAlternative = SUBRULE1(pathOneInPropertySet);
|
|
155
|
+
return ACTION(() => C.astFactory.path("!", [noAlternative], C.astFactory.sourceLocation(exclamation, noAlternative)));
|
|
156
|
+
} },
|
|
157
|
+
{ ALT: () => {
|
|
158
|
+
const open = CONSUME(l.symbols.LParen);
|
|
159
|
+
const head = SUBRULE2(pathOneInPropertySet);
|
|
160
|
+
const tail = [];
|
|
161
|
+
MANY(() => {
|
|
162
|
+
CONSUME(l.symbols.pipe);
|
|
163
|
+
const item = SUBRULE3(pathOneInPropertySet);
|
|
164
|
+
tail.push(item);
|
|
165
|
+
});
|
|
166
|
+
const close = CONSUME(l.symbols.RParen);
|
|
167
|
+
return ACTION(() => {
|
|
168
|
+
const F = C.astFactory;
|
|
169
|
+
if (tail.length === 0) {
|
|
170
|
+
return F.path("!", [head], F.sourceLocation(exclamation, close));
|
|
171
|
+
}
|
|
172
|
+
return F.path("!", [F.path("|", [head, ...tail], F.sourceLocation(open, close))], F.sourceLocation(exclamation, close));
|
|
173
|
+
});
|
|
174
|
+
} }
|
|
175
|
+
]);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const pathOneInPropertySet = {
|
|
179
|
+
name: "pathOneInPropertySet",
|
|
180
|
+
impl: ({ ACTION, CONSUME, SUBRULE1, SUBRULE2, OR1, OR2 }) => (C) => OR1([
|
|
181
|
+
{ ALT: () => SUBRULE1(import_literals.iri) },
|
|
182
|
+
{ ALT: () => SUBRULE1(import_literals.verbA) },
|
|
183
|
+
{ ALT: () => {
|
|
184
|
+
const hat = CONSUME(l.symbols.hat);
|
|
185
|
+
const item = OR2([
|
|
186
|
+
{ ALT: () => SUBRULE2(import_literals.iri) },
|
|
187
|
+
{ ALT: () => SUBRULE2(import_literals.verbA) }
|
|
188
|
+
]);
|
|
189
|
+
return ACTION(() => C.astFactory.path("^", [item], C.astFactory.sourceLocation(hat, item)));
|
|
190
|
+
} }
|
|
191
|
+
])
|
|
192
|
+
};
|
|
193
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
194
|
+
0 && (module.exports = {
|
|
195
|
+
path,
|
|
196
|
+
pathAlternative,
|
|
197
|
+
pathChainHelper,
|
|
198
|
+
pathElt,
|
|
199
|
+
pathEltOrInverse,
|
|
200
|
+
pathGenerator,
|
|
201
|
+
pathMod,
|
|
202
|
+
pathNegatedPropertySet,
|
|
203
|
+
pathOneInPropertySet,
|
|
204
|
+
pathPrimary,
|
|
205
|
+
pathSequence
|
|
206
|
+
});
|