@manta-eu/datalog-parser 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manta AI AS
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @manta-eu/datalog-parser
2
+
3
+ RDFox Datalog parser and AST builder with inference verification.
4
+
5
+ ## Features
6
+
7
+ - **Complete Datalog Parser**: Parses RDFox Datalog rules into type-safe ASTs
8
+ - **Syntax Validation**: Comprehensive rule validation with error reporting
9
+ - **Built-in Function Support**: CONCAT, STR, IF, IRI, SKOLEM, ROUND, REGEX functions
10
+ - **Advanced Constructs**: Support for FILTER, BIND, AGGREGATE, NOT EXIST patterns
11
+ - **Inference Verification**: Validate that rules produce expected inferences
12
+ - **Transaction Management**: Safe rule management with rollback capabilities
13
+
14
+ ## API
15
+
16
+ ### Core Functions
17
+
18
+ ```typescript
19
+ import { parseDatalogRule, validateDatalogRule, areRulesEquivalent } from "@manta-eu/datalog-parser";
20
+
21
+ // Parse rule into AST
22
+ const ast = parseDatalogRule(`:Product[?p] :- :Item[?p], :category[?p, "electronics"] .`);
23
+
24
+ // Validate syntax
25
+ const { valid, error } = validateDatalogRule(ruleText);
26
+
27
+ // Compare rules
28
+ const equivalent = areRulesEquivalent(rule1, rule2);
29
+ ```
30
+
31
+ ### Advanced Features
32
+
33
+ ```typescript
34
+ import { verifyRuleInference, transactionManager } from "@manta-eu/datalog-parser";
35
+
36
+ // Verify rule produces expected inferences
37
+ await verifyRuleInference(rule, expectedFacts, rdfoxConfig);
38
+
39
+ // Manage transactions
40
+ await transactionManager.withTransaction(async () => {
41
+ // Rule operations here
42
+ });
43
+ ```
44
+
45
+ ### AST Types
46
+
47
+ ```typescript
48
+ import type { DatalogRule, DatalogAtom, DatalogBodyFormula } from "@manta-eu/datalog-parser";
49
+ ```
50
+
51
+ ## Grammar Support
52
+
53
+ - **Head Atoms**: Property atoms, class atoms, general atoms
54
+ - **Body Formulas**: All atom types plus FILTER, BIND, AGGREGATE, SKOLEM, negation
55
+ - **Expressions**: Binary operators, function calls, literals
56
+ - **Built-in Functions**: Full RDFox function library
57
+ - **Complex Patterns**: NOT EXIST clauses with mixed formulas