eyemind 0.5.1 → 0.5.2

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.
@@ -0,0 +1,40 @@
1
+
2
+ // SPARQL 1.2 RL §4.1 (05 November 2026): assignments, groups, head blank
3
+ // nodes, and head triple-term templates containing variables run once.
4
+ function assignmentsNeedRunOnce(clauses = []) {
5
+ return clauses.some((clause) => clause.type === 'set' || clause.type === 'bind');
6
+ }
7
+
8
+ function ruleNeedsRunOnce(head = [], body = []) {
9
+ return assignmentsNeedRunOnce(body)
10
+ || body.some((clause) => clause.type === 'group')
11
+ || head.some(tripleHasBlankNode)
12
+ || head.some(tripleHasVariableTripleTerm);
13
+ }
14
+
15
+ function tripleHasVariableTripleTerm(triple) {
16
+ return [triple && triple.s, triple && triple.p, triple && triple.o]
17
+ .some((term) => term && term.type === 'triple' && termHasVariable(term));
18
+ }
19
+
20
+ function termHasVariable(term) {
21
+ if (!term) return false;
22
+ if (term.type === 'var') return true;
23
+ if (term.type === 'triple') return termHasVariable(term.s) || termHasVariable(term.p) || termHasVariable(term.o);
24
+ return false;
25
+ }
26
+
27
+ function tripleHasBlankNode(triple) {
28
+ return termHasBlankNode(triple && triple.s)
29
+ || termHasBlankNode(triple && triple.p)
30
+ || termHasBlankNode(triple && triple.o);
31
+ }
32
+
33
+ function termHasBlankNode(term) {
34
+ if (!term) return false;
35
+ if (term.type === 'blank') return true;
36
+ if (term.type === 'triple') return termHasBlankNode(term.s) || termHasBlankNode(term.p) || termHasBlankNode(term.o);
37
+ return false;
38
+ }
39
+
40
+ export { assignmentsNeedRunOnce, ruleNeedsRunOnce, tripleHasBlankNode, termHasBlankNode, tripleHasVariableTripleTerm };
@@ -0,0 +1,78 @@
1
+
2
+ // The SPARQL 1.2 RL BuiltInCall names and arities, from eyeleng's src/builtins.js.
3
+ // This table is intentionally shaped by the SPARQL 1.2 RL grammar production BuiltInCall.
4
+ // Keys are the canonical spellings used by the draft; lookup is case-insensitive so examples
5
+ // may use SPARQL-style uppercase or lowercase spellings while still being checked against the
6
+ // grammar's finite set of built-ins.
7
+ const BUILTIN_SIGNATURES = Object.freeze({
8
+ STR: { min: 1, max: 1 },
9
+ LANG: { min: 1, max: 1 },
10
+ LANGMATCHES: { min: 2, max: 2 },
11
+ LANGDIR: { min: 1, max: 1 },
12
+ DATATYPE: { min: 1, max: 1 },
13
+ IRI: { min: 1, max: 1 },
14
+ URI: { min: 1, max: 1 },
15
+ BNODE: { min: 0, max: 1 },
16
+ ABS: { min: 1, max: 1 },
17
+ CEIL: { min: 1, max: 1 },
18
+ FLOOR: { min: 1, max: 1 },
19
+ ROUND: { min: 1, max: 1 },
20
+ CONCAT: { min: 0, max: Infinity },
21
+ SUBSTR: { min: 2, max: 3 },
22
+ STRLEN: { min: 1, max: 1 },
23
+ REPLACE: { min: 3, max: 4 },
24
+ UCASE: { min: 1, max: 1 },
25
+ LCASE: { min: 1, max: 1 },
26
+ ENCODE_FOR_URI: { min: 1, max: 1 },
27
+ CONTAINS: { min: 2, max: 2 },
28
+ STRSTARTS: { min: 2, max: 2 },
29
+ STRENDS: { min: 2, max: 2 },
30
+ STRBEFORE: { min: 2, max: 2 },
31
+ STRAFTER: { min: 2, max: 2 },
32
+ YEAR: { min: 1, max: 1 },
33
+ MONTH: { min: 1, max: 1 },
34
+ DAY: { min: 1, max: 1 },
35
+ HOURS: { min: 1, max: 1 },
36
+ MINUTES: { min: 1, max: 1 },
37
+ SECONDS: { min: 1, max: 1 },
38
+ TIMEZONE: { min: 1, max: 1 },
39
+ TZ: { min: 1, max: 1 },
40
+ NOW: { min: 0, max: 0 },
41
+ UUID: { min: 0, max: 0 },
42
+ STRUUID: { min: 0, max: 0 },
43
+ IF: { min: 3, max: 3, lazy: true },
44
+ STRLANG: { min: 2, max: 2 },
45
+ STRLANGDIR: { min: 3, max: 3 },
46
+ STRDT: { min: 2, max: 2 },
47
+ sameTerm: { min: 2, max: 2 },
48
+ isIRI: { min: 1, max: 1 },
49
+ isURI: { min: 1, max: 1 },
50
+ isBLANK: { min: 1, max: 1 },
51
+ isLITERAL: { min: 1, max: 1 },
52
+ isNUMERIC: { min: 1, max: 1 },
53
+ hasLANG: { min: 1, max: 1 },
54
+ hasLANGDIR: { min: 1, max: 1 },
55
+ REGEX: { min: 2, max: 3 },
56
+ isTRIPLE: { min: 1, max: 1 },
57
+ TRIPLE: { min: 3, max: 3 },
58
+ SUBJECT: { min: 1, max: 1 },
59
+ PREDICATE: { min: 1, max: 1 },
60
+ OBJECT: { min: 1, max: 1 },
61
+ });
62
+
63
+ const BUILTIN_BY_LOWER = new Map(Object.keys(BUILTIN_SIGNATURES).map((name) => [name.toLowerCase(), name]));
64
+
65
+ function canonicalBuiltinName(name) {
66
+ return BUILTIN_BY_LOWER.get(String(name).toLowerCase()) || null;
67
+ }
68
+
69
+ function isBuiltinName(name) {
70
+ return canonicalBuiltinName(name) !== null;
71
+ }
72
+
73
+ function builtinNames() {
74
+ return Object.keys(BUILTIN_SIGNATURES);
75
+ }
76
+
77
+
78
+ export { BUILTIN_SIGNATURES, canonicalBuiltinName, isBuiltinName, builtinNames };