@manta-eu/datalog-parser 0.1.2 → 0.1.4

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.
Files changed (2) hide show
  1. package/dist/index.js +1415 -1440
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -1,47 +1,44 @@
1
- var br = Object.defineProperty;
2
- var Or = (e, t, r) => t in e ? br(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var d = (e, t, r) => Or(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { match as p, P as u } from "ts-pattern";
5
- import Ie from "decimal.js";
6
- import { GeneratorBuilder as xr, ParserBuilder as P } from "@traqula/core";
7
- import { sparql11GeneratorBuilder as Mt } from "@traqula/generator-sparql-1-1";
8
- import { AstFactory as vr, lex as ze, completeGeneratorContext as Cr, gram as n, MinimalSparqlParser as Ir, sparqlCodepointEscape as Mr } from "@traqula/rules-sparql-1-1";
9
- import { createToken as c, Lexer as Bt, CstParser as Br, EOF as Fr } from "chevrotain";
10
- import { z as q } from "zod";
11
- const Mn = (e) => p(e).with({ type: "triple" }, () => !0).otherwise(() => !1), Bn = (e) => p(e).with({ type: "property" }, () => !0).otherwise(() => !1), Fn = (e) => p(e).with({ type: "class" }, () => !0).otherwise(() => !1), Pn = (e) => p(e).with({ type: "general" }, () => !0).otherwise(() => !1), I = (e) => p(e).with({ type: "variable" }, () => !0).otherwise(() => !1), kn = (e) => p(e).with({ type: "iri" }, () => !0).otherwise(() => !1), tt = (e) => p(e).with({ type: "literal" }, () => !0).otherwise(() => !1), $n = (e) => p(e).with({ type: "blank" }, () => !0).otherwise(() => !1), Dn = (e) => p(e).with({ type: "negation" }, () => !0).otherwise(() => !1), Gn = (e) => p(e).with({ type: "filter" }, () => !0).otherwise(() => !1), _n = (e) => p(e).with({ type: "bind" }, () => !0).otherwise(() => !1), Vn = (e) => p(e).with({ type: "aggregate" }, () => !0).otherwise(() => !1), jn = (e) => p(e).with({ type: "skolem" }, () => !0).otherwise(() => !1), qn = (e) => p(e).with({ type: "binary" }, () => !0).otherwise(() => !1), Xn = (e) => p(e).with({ type: "unary" }, () => !0).otherwise(() => !1), Hn = (e) => p(e).with({ type: "term" }, () => !0).otherwise(() => !1), Qn = (e) => p(e).with({ type: "function" }, () => !0).otherwise(() => !1), zn = (e) => p(e).with({ type: "triple" }, () => "triple").with({ type: "property" }, () => "property").with({ type: "class" }, () => "class").with({ type: "general" }, () => "general").exhaustive(), Kn = (e) => p(e).with({ type: "variable" }, () => "variable").with({ type: "iri" }, () => "iri").with({ type: "literal" }, () => "literal").with({ type: "blank" }, () => "blank").exhaustive(), Wn = (e) => p(e).with({ type: "binary" }, () => "binary").with({ type: "unary" }, () => "unary").with({ type: "term" }, () => "term").with({ type: "function" }, () => "function").with({ type: "in" }, () => "in").exhaustive(), Pr = (e) => p(e).with({ type: "triple" }, (t) => [t.subject, t.predicate, t.object].filter(I)).with({ type: "property" }, (t) => [t.subject, t.object].filter(I)).with({ type: "class" }, (t) => [t.instance].filter(I)).with({ type: "general" }, (t) => t.terms.filter(I)).exhaustive(), kr = (e) => {
12
- const t = Pr(e), r = "graph" in e ? e.graph : void 0;
13
- return r && I(r) ? [...t, r] : t;
14
- }, Yn = (e) => e.function, Zn = (e) => p(e).with(u.union("+", "-", "*", "/", "<", ">", "<=", ">="), () => !0).with(u.union("=", "!=", "||", "&&"), () => !1).exhaustive(), Jn = (e) => p(e).with(u.union("||", "&&", "=", "!=", "<", ">", "<=", ">="), () => !0).with(u.union("+", "-", "*", "/"), () => !1).exhaustive(), Ke = '[^\\s<>"{}|^`\\\\]', $r = new RegExp(`^[a-z][a-z0-9+.-]*:${Ke}*$`, "i");
15
- function ts(e) {
16
- return $r.test(e);
17
- }
18
- function We(e) {
1
+ import { match as p, P as l } from "ts-pattern";
2
+ import Ce from "decimal.js";
3
+ import { GeneratorBuilder as Rr, ParserBuilder as F } from "@traqula/core";
4
+ import { sparql11GeneratorBuilder as It } from "@traqula/generator-sparql-1-1";
5
+ import { AstFactory as br, lex as Qe, completeGeneratorContext as Or, gram as n, MinimalSparqlParser as xr, sparqlCodepointEscape as vr } from "@traqula/rules-sparql-1-1";
6
+ import { createToken as c, Lexer as Mt, CstParser as Cr, EOF as Ir } from "chevrotain";
7
+ import { z as j } from "zod";
8
+ const xn = (e) => p(e).with({ type: "triple" }, () => !0).otherwise(() => !1), vn = (e) => p(e).with({ type: "property" }, () => !0).otherwise(() => !1), Cn = (e) => p(e).with({ type: "class" }, () => !0).otherwise(() => !1), In = (e) => p(e).with({ type: "general" }, () => !0).otherwise(() => !1), v = (e) => p(e).with({ type: "variable" }, () => !0).otherwise(() => !1), Mn = (e) => p(e).with({ type: "iri" }, () => !0).otherwise(() => !1), Z = (e) => p(e).with({ type: "literal" }, () => !0).otherwise(() => !1), Bn = (e) => p(e).with({ type: "blank" }, () => !0).otherwise(() => !1), Fn = (e) => p(e).with({ type: "negation" }, () => !0).otherwise(() => !1), Pn = (e) => p(e).with({ type: "filter" }, () => !0).otherwise(() => !1), kn = (e) => p(e).with({ type: "bind" }, () => !0).otherwise(() => !1), $n = (e) => p(e).with({ type: "aggregate" }, () => !0).otherwise(() => !1), Dn = (e) => p(e).with({ type: "skolem" }, () => !0).otherwise(() => !1), Gn = (e) => p(e).with({ type: "binary" }, () => !0).otherwise(() => !1), _n = (e) => p(e).with({ type: "unary" }, () => !0).otherwise(() => !1), Vn = (e) => p(e).with({ type: "term" }, () => !0).otherwise(() => !1), jn = (e) => p(e).with({ type: "function" }, () => !0).otherwise(() => !1), qn = (e) => p(e).with({ type: "triple" }, () => "triple").with({ type: "property" }, () => "property").with({ type: "class" }, () => "class").with({ type: "general" }, () => "general").exhaustive(), Xn = (e) => p(e).with({ type: "variable" }, () => "variable").with({ type: "iri" }, () => "iri").with({ type: "literal" }, () => "literal").with({ type: "blank" }, () => "blank").exhaustive(), Hn = (e) => p(e).with({ type: "binary" }, () => "binary").with({ type: "unary" }, () => "unary").with({ type: "term" }, () => "term").with({ type: "function" }, () => "function").with({ type: "in" }, () => "in").exhaustive(), Mr = (e) => p(e).with({ type: "triple" }, (t) => [t.subject, t.predicate, t.object].filter(v)).with({ type: "property" }, (t) => [t.subject, t.object].filter(v)).with({ type: "class" }, (t) => [t.instance].filter(v)).with({ type: "general" }, (t) => t.terms.filter(v)).exhaustive(), Br = (e) => {
9
+ const t = Mr(e), r = "graph" in e ? e.graph : void 0;
10
+ return r && v(r) ? [...t, r] : t;
11
+ }, Qn = (e) => e.function, zn = (e) => p(e).with(l.union("+", "-", "*", "/", "<", ">", "<=", ">="), () => !0).with(l.union("=", "!=", "||", "&&"), () => !1).exhaustive(), Kn = (e) => p(e).with(l.union("||", "&&", "=", "!=", "<", ">", "<=", ">="), () => !0).with(l.union("+", "-", "*", "/"), () => !1).exhaustive(), ze = '[^\\s<>"{}|^`\\\\]', Fr = new RegExp(`^[a-z][a-z0-9+.-]*:${ze}*$`, "i");
12
+ function Wn(e) {
13
+ return Fr.test(e);
14
+ }
15
+ function Ke(e) {
19
16
  return e.includes("://");
20
17
  }
21
- const Dr = /^(true|false)$/i, Gr = /^"(true|false)"\^\^<?\S*boolean>?$/i, St = "[eE][+-]?\\d+", _r = new RegExp(
22
- `^[+-]?(?:\\d+\\.\\d*(?:${St})|\\d+\\.\\d+|\\.\\d+(?:${St})?|\\d+(?:${St})?)$`
18
+ const Pr = /^(true|false)$/i, kr = /^"(true|false)"\^\^<?\S*boolean>?$/i, Tt = "[eE][+-]?\\d+", $r = new RegExp(
19
+ `^[+-]?(?:\\d+\\.\\d*(?:${Tt})|\\d+\\.\\d+|\\.\\d+(?:${Tt})?|\\d+(?:${Tt})?)$`
23
20
  );
24
- function Rt(e) {
25
- return _r.test(e);
21
+ function Nt(e) {
22
+ return $r.test(e);
26
23
  }
27
- const Vr = /^([+-]?)(\d*)(?:\.(\d*))?(?:[eE]([+-]?\d+))?$/, jr = 21;
28
- function qr(e, t) {
24
+ const Dr = /^([+-]?)(\d*)(?:\.(\d*))?(?:[eE]([+-]?\d+))?$/, Gr = 21;
25
+ function _r(e, t) {
29
26
  return t <= 0 ? { integer: "0", fraction: "0".repeat(-t) + e } : t >= e.length ? { integer: e + "0".repeat(t - e.length), fraction: "" } : { integer: e.slice(0, t), fraction: e.slice(t) };
30
27
  }
31
- function Xr(e) {
32
- const t = Rt(e) ? e.match(Vr) : null;
28
+ function Vr(e) {
29
+ const t = Nt(e) ? e.match(Dr) : null;
33
30
  if (!t) return e;
34
- const [, r = "", i = "", s = "", a] = t, o = i + s, l = i.length + Number(a ?? 0);
35
- if (o.length + Math.abs(l) > jr) return e;
36
- const E = qr(o, l), y = E.integer.replace(/^0+(?=\d)/, ""), S = E.fraction.replace(/0+$/, ""), h = S ? `${y}.${S}` : y;
31
+ const [, r = "", i = "", s = "", o] = t, a = i + s, u = i.length + Number(o ?? 0);
32
+ if (a.length + Math.abs(u) > Gr) return e;
33
+ const f = _r(a, u), y = f.integer.replace(/^0+(?=\d)/, ""), m = f.fraction.replace(/0+$/, ""), h = m ? `${y}.${m}` : y;
37
34
  return h === "0" || r === "+" ? h : `${r}${h}`;
38
35
  }
39
- function es(e) {
40
- if (Dr.test(e)) return e.toLowerCase() === "true";
41
- const t = e.match(Gr);
42
- if (t != null && t[1]) return t[1].toLowerCase() === "true";
36
+ function Yn(e) {
37
+ if (Pr.test(e)) return e.toLowerCase() === "true";
38
+ const t = e.match(kr);
39
+ if (t?.[1]) return t[1].toLowerCase() === "true";
43
40
  }
44
- const bt = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", Ot = "http://www.w3.org/2001/XMLSchema#", j = {
41
+ const Rt = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", bt = "http://www.w3.org/2001/XMLSchema#", V = {
45
42
  integer: "xsd:integer",
46
43
  decimal: "xsd:decimal",
47
44
  double: "xsd:double",
@@ -49,7 +46,7 @@ const bt = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", Ot = "http://www.w
49
46
  string: "xsd:string",
50
47
  date: "xsd:date",
51
48
  dateTime: "xsd:dateTime"
52
- }, Hr = ["integer", "decimal", "double"], Me = {
49
+ }, jr = ["integer", "decimal", "double"], Ie = {
53
50
  "||": 1,
54
51
  "&&": 2,
55
52
  "=": 3,
@@ -62,7 +59,7 @@ const bt = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", Ot = "http://www.w
62
59
  "-": 4,
63
60
  "*": 5,
64
61
  "/": 5
65
- }, Ft = {
62
+ }, Bt = {
66
63
  "=": "=",
67
64
  "!=": "!=",
68
65
  "<": ">",
@@ -70,30 +67,30 @@ const bt = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", Ot = "http://www.w
70
67
  ">": "<",
71
68
  ">=": "<="
72
69
  };
73
- function Be(e) {
74
- return p(e).with({ type: u.union("triple", "property", "class", "general") }, () => !0).otherwise(() => !1);
70
+ function Me(e) {
71
+ return p(e).with({ type: l.union("triple", "property", "class", "general") }, () => !0).otherwise(() => !1);
75
72
  }
76
- function B(e) {
77
- return p(e).with({ type: "binary" }, ({ left: t, right: r }) => B(t) || B(r)).with({ type: "unary" }, ({ operand: t }) => B(t)).with({ type: "term" }, () => !1).with(
73
+ function M(e) {
74
+ return p(e).with({ type: "binary" }, ({ left: t, right: r }) => M(t) || M(r)).with({ type: "unary" }, ({ operand: t }) => M(t)).with({ type: "term" }, () => !1).with(
78
75
  { type: "function" },
79
- ({ name: t, args: r }) => t.toUpperCase() === "SKOLEM" || r.some(B)
76
+ ({ name: t, args: r }) => t.toUpperCase() === "SKOLEM" || r.some(M)
80
77
  ).with(
81
78
  { type: "in" },
82
- ({ expression: t, list: r }) => B(t) || r.some(B)
79
+ ({ expression: t, list: r }) => M(t) || r.some(M)
83
80
  ).exhaustive();
84
81
  }
85
- function xt(e) {
86
- return p(e).with({ type: "skolem" }, () => !0).with({ type: u.union("filter", "bind") }, ({ expression: t }) => B(t)).with({ type: "negation" }, ({ formulas: t }) => t.some(xt)).with(
82
+ function Ot(e) {
83
+ return p(e).with({ type: "skolem" }, () => !0).with({ type: l.union("filter", "bind") }, ({ expression: t }) => M(t)).with({ type: "negation" }, ({ formulas: t }) => t.some(Ot)).with(
87
84
  { type: "aggregate" },
88
- ({ atoms: t, bindings: r }) => t.some(xt) || ((r == null ? void 0 : r.some(
89
- ({ expression: i, secondExpression: s }) => i !== "*" && B(i) || s !== void 0 && B(s)
90
- )) ?? !1)
91
- ).with({ type: u.union("triple", "property", "class", "general") }, () => !1).exhaustive();
85
+ ({ atoms: t, bindings: r }) => t.some(Ot) || (r?.some(
86
+ ({ expression: i, secondExpression: s }) => i !== "*" && M(i) || s !== void 0 && M(s)
87
+ ) ?? !1)
88
+ ).with({ type: l.union("triple", "property", "class", "general") }, () => !1).exhaustive();
92
89
  }
93
- function Ye(e) {
94
- return e.some((t) => t.type !== "negation" && xt(t));
90
+ function We(e) {
91
+ return e.some((t) => t.type !== "negation" && Ot(t));
95
92
  }
96
- function Ze(e) {
93
+ function Ye(e) {
97
94
  return p(e).with({ type: "class" }, (t) => ({
98
95
  className: t.className,
99
96
  instance: t.instance,
@@ -101,7 +98,7 @@ function Ze(e) {
101
98
  })).with(
102
99
  {
103
100
  type: "property",
104
- predicate: u.union("a", "rdf:type", bt),
101
+ predicate: l.union("a", "rdf:type", Rt),
105
102
  object: { type: "iri" }
106
103
  },
107
104
  (t) => ({
@@ -112,7 +109,7 @@ function Ze(e) {
112
109
  ).with(
113
110
  {
114
111
  type: "triple",
115
- predicate: { type: "iri", value: u.union("a", "rdf:type", bt) },
112
+ predicate: { type: "iri", value: l.union("a", "rdf:type", Rt) },
116
113
  object: { type: "iri" }
117
114
  },
118
115
  (t) => ({
@@ -122,14 +119,14 @@ function Ze(e) {
122
119
  })
123
120
  ).otherwise(() => null);
124
121
  }
125
- function Je(e) {
122
+ function Ze(e) {
126
123
  return p(e).with({ type: "property" }, (t) => ({
127
124
  predicate: t.predicate,
128
125
  subject: t.subject,
129
126
  object: t.object,
130
127
  graph: t.graph
131
128
  })).with(
132
- { type: "triple", predicate: { type: "iri", value: u.not(u.union("a", "rdf:type", bt)) } },
129
+ { type: "triple", predicate: { type: "iri", value: l.not(l.union("a", "rdf:type", Rt)) } },
133
130
  (t) => ({
134
131
  predicate: t.predicate.value,
135
132
  subject: t.subject,
@@ -138,320 +135,318 @@ function Je(e) {
138
135
  })
139
136
  ).otherwise(() => null);
140
137
  }
141
- function rs(e) {
142
- return e in Ft;
138
+ function Zn(e) {
139
+ return e in Bt;
143
140
  }
144
- function is(e) {
145
- return Ft[e];
141
+ function Jn(e) {
142
+ return Bt[e];
146
143
  }
147
- function it(e, t) {
148
- return e === j[t] || e === `${Ot}${t}`;
144
+ function et(e, t) {
145
+ return e === V[t] || e === `${bt}${t}`;
149
146
  }
150
- function Fe(e) {
147
+ function Be(e) {
151
148
  const { datatype: t } = e;
152
- if (!(!t || it(t, "string")))
153
- return t.startsWith(Ot) ? `xsd:${t.slice(Ot.length)}` : t;
149
+ if (!(!t || et(t, "string")))
150
+ return t.startsWith(bt) ? `xsd:${t.slice(bt.length)}` : t;
154
151
  }
155
- function tr(e, t) {
156
- return p([e, t]).with([{ type: "literal" }, { type: "literal" }], ([r, i]) => Q(r) && Q(i) && Rt(r.value) && Rt(i.value) ? new Ie(r.value).equals(new Ie(i.value)) : r.value === i.value && r.language === i.language && Fe(r) === Fe(i)).with([{ type: "iri" }, { type: "iri" }], ([r, i]) => r.value === i.value).with([{ type: "blank" }, { type: "blank" }], ([r, i]) => r.label === i.label).with([{ type: "variable" }, { type: "variable" }], ([r, i]) => r.name === i.name).otherwise(() => !1);
152
+ function Je(e, t) {
153
+ return p([e, t]).with([{ type: "literal" }, { type: "literal" }], ([r, i]) => H(r) && H(i) && Nt(r.value) && Nt(i.value) ? new Ce(r.value).equals(new Ce(i.value)) : r.value === i.value && r.language === i.language && Be(r) === Be(i)).with([{ type: "iri" }, { type: "iri" }], ([r, i]) => r.value === i.value).with([{ type: "blank" }, { type: "blank" }], ([r, i]) => r.label === i.label).with([{ type: "variable" }, { type: "variable" }], ([r, i]) => r.name === i.name).otherwise(() => !1);
157
154
  }
158
- function Q(e) {
159
- return Hr.some((t) => it(e.datatype, t));
155
+ function H(e) {
156
+ return jr.some((t) => et(e.datatype, t));
160
157
  }
161
- function ns(e) {
162
- return !Q(e) || !e.termSpan || !e.valueSpan ? !1 : e.termSpan.start === e.valueSpan.start && e.termSpan.end === e.valueSpan.end;
158
+ function ts(e) {
159
+ return !H(e) || !e.termSpan || !e.valueSpan ? !1 : e.termSpan.start === e.valueSpan.start && e.termSpan.end === e.valueSpan.end;
163
160
  }
164
- function ss(e) {
165
- return tt(e) && Q(e);
161
+ function es(e) {
162
+ return Z(e) && H(e);
166
163
  }
167
- function er(e) {
168
- return it(e.datatype, "boolean");
164
+ function tr(e) {
165
+ return et(e.datatype, "boolean");
169
166
  }
170
- function Qr(e) {
171
- return it(e.datatype, "date");
167
+ function qr(e) {
168
+ return et(e.datatype, "date");
172
169
  }
173
- function zr(e) {
174
- return it(e.datatype, "dateTime");
170
+ function Xr(e) {
171
+ return et(e.datatype, "dateTime");
175
172
  }
176
- function as(e) {
177
- return Q(e) ? Xr(e.value) : er(e) || Qr(e) ? e.value : zr(e) ? e.value.replace("T", " ") : JSON.stringify(e.value);
173
+ function rs(e) {
174
+ return H(e) ? Vr(e.value) : tr(e) || qr(e) ? e.value : Xr(e) ? e.value.replace("T", " ") : JSON.stringify(e.value);
178
175
  }
179
- function os(e) {
180
- return Kr(e.expression);
176
+ function is(e) {
177
+ return Hr(e.expression);
181
178
  }
182
- function Kr(e) {
179
+ function Hr(e) {
183
180
  return p(e).with(
184
- { type: "binary", operator: u.union("=", "!=", "<", ">", "<=", ">=") },
181
+ { type: "binary", operator: l.union("=", "!=", "<", ">", "<=", ">=") },
185
182
  (t) => {
186
- const r = G(t.left), i = G(t.right);
187
- return !r || !i ? null : I(r) && tt(i) ? { variableName: r.name, operator: t.operator, literal: i } : tt(r) && I(i) ? {
183
+ const r = D(t.left), i = D(t.right);
184
+ return !r || !i ? null : v(r) && Z(i) ? { variableName: r.name, operator: t.operator, literal: i } : Z(r) && v(i) ? {
188
185
  variableName: i.name,
189
- operator: Ft[t.operator],
186
+ operator: Bt[t.operator],
190
187
  literal: r
191
188
  } : null;
192
189
  }
193
190
  ).otherwise(() => null);
194
191
  }
195
- function Wr(e) {
192
+ function Qr(e) {
196
193
  return p(e).returnType().with(
197
194
  { type: "binary", operator: "=" },
198
- (t) => p([G(t.left), G(t.right)]).returnType().with([u.not(u.nullish), { type: "literal" }], ([r, i]) => ({ subject: r, literal: i })).with([{ type: "literal" }, u.not(u.nullish)], ([r, i]) => ({ subject: i, literal: r })).otherwise(() => null)
195
+ (t) => p([D(t.left), D(t.right)]).returnType().with([l.not(l.nullish), { type: "literal" }], ([r, i]) => ({ subject: r, literal: i })).with([{ type: "literal" }, l.not(l.nullish)], ([r, i]) => ({ subject: i, literal: r })).otherwise(() => null)
199
196
  ).otherwise(() => null);
200
197
  }
201
- function ls(e) {
202
- var s;
198
+ function ns(e) {
203
199
  if (e.type === "in") {
204
- const a = G(e.expression), o = e.list.flatMap((l) => {
205
- const E = ti(l);
206
- return E ? [E] : [];
200
+ const s = D(e.expression), o = e.list.flatMap((a) => {
201
+ const u = Yr(a);
202
+ return u ? [u] : [];
207
203
  });
208
- return a && o.length > 0 && o.length === e.list.length ? { subject: a, literals: o, negated: e.negated } : null;
204
+ return s && o.length > 0 && o.length === e.list.length ? { subject: s, literals: o, negated: e.negated } : null;
209
205
  }
210
- const t = vt(e, "||");
206
+ const t = xt(e, "||");
211
207
  if (t.length < 2) return null;
212
- const r = t.flatMap((a) => {
213
- const o = Wr(a);
208
+ const r = t.flatMap((s) => {
209
+ const o = Qr(s);
214
210
  return o ? [o] : [];
215
211
  });
216
212
  if (r.length !== t.length) return null;
217
- const i = (s = r[0]) == null ? void 0 : s.subject;
218
- return !i || !r.every((a) => tr(a.subject, i)) ? null : {
213
+ const i = r[0]?.subject;
214
+ return !i || !r.every((s) => Je(s.subject, i)) ? null : {
219
215
  subject: i,
220
- literals: r.map((a) => a.literal),
216
+ literals: r.map((s) => s.literal),
221
217
  negated: !1
222
218
  };
223
219
  }
224
- function Yr(e) {
225
- const t = G(e);
226
- return t && I(t) ? t.name : null;
220
+ function zr(e) {
221
+ const t = D(e);
222
+ return t && v(t) ? t.name : null;
227
223
  }
228
- function Zr(e) {
224
+ function Kr(e) {
229
225
  return p(e).with({ type: "skolem" }, (t) => {
230
226
  const r = t.args.at(-1);
231
- return r ? Yr(r) : null;
227
+ return r ? zr(r) : null;
232
228
  }).with({ type: "bind", expression: { type: "function", name: "SKOLEM" } }, (t) => t.variable).otherwise(() => null);
233
229
  }
234
- function us(e) {
235
- const t = /* @__PURE__ */ new Set(), r = (a) => {
236
- T(a).forEach((o) => t.add(o));
237
- }, i = (a) => {
238
- nt(a).forEach((o) => t.add(o));
239
- }, s = (a) => {
240
- p(a).with({ type: u.union("triple", "property", "class", "general") }, i).with({ type: "negation" }, (o) => o.formulas.forEach(s)).with({ type: "filter" }, (o) => r(o.expression)).with({ type: "bind" }, (o) => {
241
- r(o.expression), t.add(o.variable);
242
- }).with({ type: "aggregate" }, (o) => {
243
- var l, E;
244
- o.atoms.forEach(s), (l = o.onVars) == null || l.forEach((y) => t.add(y)), (E = o.bindings) == null || E.forEach((y) => {
245
- t.add(y.variable), y.expression !== "*" && r(y.expression), y.secondExpression && r(y.secondExpression);
230
+ function ss(e) {
231
+ const t = /* @__PURE__ */ new Set(), r = (o) => {
232
+ w(o).forEach((a) => t.add(a));
233
+ }, i = (o) => {
234
+ rt(o).forEach((a) => t.add(a));
235
+ }, s = (o) => {
236
+ p(o).with({ type: l.union("triple", "property", "class", "general") }, i).with({ type: "negation" }, (a) => a.formulas.forEach(s)).with({ type: "filter" }, (a) => r(a.expression)).with({ type: "bind" }, (a) => {
237
+ r(a.expression), t.add(a.variable);
238
+ }).with({ type: "aggregate" }, (a) => {
239
+ a.atoms.forEach(s), a.onVars?.forEach((u) => t.add(u)), a.bindings?.forEach((u) => {
240
+ t.add(u.variable), u.expression !== "*" && r(u.expression), u.secondExpression && r(u.secondExpression);
246
241
  });
247
- }).with({ type: "skolem" }, (o) => o.args.forEach(r)).exhaustive();
242
+ }).with({ type: "skolem" }, (a) => a.args.forEach(r)).exhaustive();
248
243
  };
249
244
  return e.head.forEach(i), e.body.forEach(s), Array.from(t);
250
245
  }
251
- function cs(e, t) {
252
- const r = /* @__PURE__ */ new Set(), i = (o) => {
253
- o.includes(t) && o.forEach((l) => r.add(l));
254
- }, s = (o) => {
255
- i(nt(o));
256
- }, a = (o) => {
257
- p(o).with({ type: u.union("triple", "property", "class", "general") }, s).with({ type: "negation" }, (l) => l.formulas.forEach(a)).with({ type: "filter" }, (l) => i(T(l.expression))).with(
246
+ function as(e, t) {
247
+ const r = /* @__PURE__ */ new Set(), i = (a) => {
248
+ a.includes(t) && a.forEach((u) => r.add(u));
249
+ }, s = (a) => {
250
+ i(rt(a));
251
+ }, o = (a) => {
252
+ p(a).with({ type: l.union("triple", "property", "class", "general") }, s).with({ type: "negation" }, (u) => u.formulas.forEach(o)).with({ type: "filter" }, (u) => i(w(u.expression))).with(
258
253
  { type: "bind" },
259
- (l) => i([...T(l.expression), l.variable])
260
- ).with({ type: "aggregate" }, (l) => {
261
- l.atoms.forEach(a);
262
- const E = [
263
- ...l.onVars ?? [],
264
- ...(l.bindings ?? []).flatMap((y) => [
254
+ (u) => i([...w(u.expression), u.variable])
255
+ ).with({ type: "aggregate" }, (u) => {
256
+ u.atoms.forEach(o);
257
+ const f = [
258
+ ...u.onVars ?? [],
259
+ ...(u.bindings ?? []).flatMap((y) => [
265
260
  y.variable,
266
- ...y.expression === "*" ? [] : T(y.expression),
267
- ...y.secondExpression ? T(y.secondExpression) : []
261
+ ...y.expression === "*" ? [] : w(y.expression),
262
+ ...y.secondExpression ? w(y.secondExpression) : []
268
263
  ])
269
264
  ];
270
- i(E);
265
+ i(f);
271
266
  }).with(
272
267
  { type: "skolem" },
273
- (l) => i(l.args.flatMap((E) => T(E)))
268
+ (u) => i(u.args.flatMap((f) => w(f)))
274
269
  ).exhaustive();
275
270
  };
276
- return e.head.forEach(s), e.body.forEach(a), r;
271
+ return e.head.forEach(s), e.body.forEach(o), r;
277
272
  }
278
- function nt(e) {
279
- return kr(e).map((t) => t.name);
273
+ function rt(e) {
274
+ return Br(e).map((t) => t.name);
280
275
  }
281
- function Jr(e) {
282
- return e && I(e) ? [e.name] : [];
276
+ function Wr(e) {
277
+ return e && v(e) ? [e.name] : [];
283
278
  }
284
- function T(e) {
279
+ function w(e) {
285
280
  return p(e).with({ type: "binary" }, (t) => [
286
- ...T(t.left),
287
- ...T(t.right)
288
- ]).with({ type: "unary" }, (t) => T(t.operand)).with({ type: "term" }, (t) => Jr(t.term)).with({ type: "function" }, (t) => t.args.flatMap(T)).with({ type: "in" }, (t) => [
289
- ...T(t.expression),
290
- ...t.list.flatMap(T)
281
+ ...w(t.left),
282
+ ...w(t.right)
283
+ ]).with({ type: "unary" }, (t) => w(t.operand)).with({ type: "term" }, (t) => Wr(t.term)).with({ type: "function" }, (t) => t.args.flatMap(w)).with({ type: "in" }, (t) => [
284
+ ...w(t.expression),
285
+ ...t.list.flatMap(w)
291
286
  ]).exhaustive();
292
287
  }
293
- function ti(e) {
294
- const t = G(e);
295
- return t && tt(t) ? t : null;
288
+ function Yr(e) {
289
+ const t = D(e);
290
+ return t && Z(t) ? t : null;
296
291
  }
297
- function vt(e, t) {
292
+ function xt(e, t) {
298
293
  return e.type !== "binary" || e.operator !== t ? [e] : [
299
- ...vt(e.left, t),
300
- ...vt(e.right, t)
294
+ ...xt(e.left, t),
295
+ ...xt(e.right, t)
301
296
  ];
302
297
  }
303
- function rr(e) {
304
- return We(e) ? `<${e}>` : e;
298
+ function er(e) {
299
+ return Ke(e) ? `<${e}>` : e;
305
300
  }
306
- function x(e, t = {}) {
301
+ function b(e, t = {}) {
307
302
  return p(e).with({ type: "variable" }, (r) => `?${r.name}`).with({ type: "iri" }, (r) => r.prefixed ? r.value : `<${r.value}>`).with({ type: "literal" }, (r) => {
308
- const i = t.stripSimpleLiteralDatatypes && Pe(r) ? r.value : JSON.stringify(r.value);
309
- return r.language ? `${i}@${r.language}` : r.datatype ? t.stripSimpleLiteralDatatypes && Pe(r) ? i : `${i}^^${rr(r.datatype)}` : i;
303
+ const i = t.stripSimpleLiteralDatatypes && Fe(r) ? r.value : JSON.stringify(r.value);
304
+ return r.language ? `${i}@${r.language}` : r.datatype ? t.stripSimpleLiteralDatatypes && Fe(r) ? i : `${i}^^${er(r.datatype)}` : i;
310
305
  }).with({ type: "blank" }, (r) => `_:${r.label}`).exhaustive();
311
306
  }
312
- function ps(e, t = {}) {
313
- const r = "graph" in e && e.graph ? ` ${x(e.graph, t)}` : "";
307
+ function os(e, t = {}) {
308
+ const r = "graph" in e && e.graph ? ` ${b(e.graph, t)}` : "";
314
309
  return p(e).with(
315
310
  { type: "property" },
316
- (i) => `${i.predicate}[${x(i.subject, t)}, ${x(i.object, t)}]${r}`
311
+ (i) => `${i.predicate}[${b(i.subject, t)}, ${b(i.object, t)}]${r}`
317
312
  ).with(
318
313
  { type: "triple" },
319
- (i) => `[${x(i.subject, t)}, ${x(i.predicate, t)}, ${x(i.object, t)}]${r}`
314
+ (i) => `[${b(i.subject, t)}, ${b(i.predicate, t)}, ${b(i.object, t)}]${r}`
320
315
  ).with(
321
316
  { type: "class" },
322
- (i) => `${i.className}[${x(i.instance, t)}]${r}`
317
+ (i) => `${i.className}[${b(i.instance, t)}]${r}`
323
318
  ).with(
324
319
  { type: "general" },
325
- (i) => `${i.tableName}(${i.terms.map((s) => x(s, t)).join(", ")})`
320
+ (i) => `${i.tableName}(${i.terms.map((s) => b(s, t)).join(", ")})`
326
321
  ).exhaustive();
327
322
  }
328
- function Pe(e) {
329
- return Q(e) || er(e);
323
+ function Fe(e) {
324
+ return H(e) || tr(e);
330
325
  }
331
- function hs(e, t = {}) {
332
- return si(H(e, t));
326
+ function ls(e, t = {}) {
327
+ return ri(X(e, t));
333
328
  }
334
- function H(e, t = {}) {
329
+ function X(e, t = {}) {
335
330
  return p(e).with({ type: "binary" }, (r) => [
336
- ...ke(r.left, r.operator, "left", t),
337
- C(` ${r.operator} `),
338
- ...ke(r.right, r.operator, "right", t)
339
- ]).with({ type: "unary" }, (r) => [C(r.operator), ...ii(r.operand, t)]).with({ type: "term" }, (r) => ni(r.term, t)).with({ type: "function" }, (r) => [
340
- C(`${r.name}(`),
341
- ...$e(
342
- r.args.map((i) => H(i, t)),
331
+ ...Pe(r.left, r.operator, "left", t),
332
+ x(` ${r.operator} `),
333
+ ...Pe(r.right, r.operator, "right", t)
334
+ ]).with({ type: "unary" }, (r) => [x(r.operator), ...ti(r.operand, t)]).with({ type: "term" }, (r) => ei(r.term, t)).with({ type: "function" }, (r) => [
335
+ x(`${r.name}(`),
336
+ ...ke(
337
+ r.args.map((i) => X(i, t)),
343
338
  ", "
344
339
  ),
345
- C(")")
340
+ x(")")
346
341
  ]).with({ type: "in" }, (r) => [
347
- ...H(r.expression, t),
348
- C(` ${r.negated ? "NOT IN" : "IN"} (`),
349
- ...$e(
350
- r.list.map((i) => H(i, t)),
342
+ ...X(r.expression, t),
343
+ x(` ${r.negated ? "NOT IN" : "IN"} (`),
344
+ ...ke(
345
+ r.list.map((i) => X(i, t)),
351
346
  ", "
352
347
  ),
353
- C(")")
348
+ x(")")
354
349
  ]).exhaustive();
355
350
  }
356
- function ei(e, t, r) {
351
+ function Zr(e, t, r) {
357
352
  if (e.type !== "binary") return !1;
358
- const i = Me[e.operator], s = Me[t];
353
+ const i = Ie[e.operator], s = Ie[t];
359
354
  return i < s || r === "right" && i === s && (t === "-" || t === "/");
360
355
  }
361
- function ri(e) {
356
+ function Jr(e) {
362
357
  return e.type === "binary" || e.type === "in";
363
358
  }
364
- function ke(e, t, r, i) {
365
- const s = H(e, i);
366
- return ei(e, t, r) ? ir(s) : s;
359
+ function Pe(e, t, r, i) {
360
+ const s = X(e, i);
361
+ return Zr(e, t, r) ? rr(s) : s;
367
362
  }
368
- function ii(e, t) {
369
- const r = H(e, t);
370
- return ri(e) ? ir(r) : r;
363
+ function ti(e, t) {
364
+ const r = X(e, t);
365
+ return Jr(e) ? rr(r) : r;
371
366
  }
372
- function ni(e, t) {
373
- return I(e) ? [ai(e.name)] : tt(e) ? [oi(e, t)] : [C(x(e, t))];
367
+ function ei(e, t) {
368
+ return v(e) ? [ii(e.name)] : Z(e) ? [ni(e, t)] : [x(b(e, t))];
374
369
  }
375
- function ir(e) {
376
- return [C("("), ...e, C(")")];
370
+ function rr(e) {
371
+ return [x("("), ...e, x(")")];
377
372
  }
378
- function $e(e, t) {
379
- return e.flatMap((r, i) => i === 0 ? r : [C(t), ...r]);
373
+ function ke(e, t) {
374
+ return e.flatMap((r, i) => i === 0 ? r : [x(t), ...r]);
380
375
  }
381
- function si(e) {
376
+ function ri(e) {
382
377
  return e.map((t) => t.type === "variable" ? `?${t.name}` : t.text).join("");
383
378
  }
384
- function C(e) {
379
+ function x(e) {
385
380
  return { type: "text", text: e };
386
381
  }
387
- function ai(e) {
382
+ function ii(e) {
388
383
  return { type: "variable", name: e };
389
384
  }
390
- function oi(e, t) {
391
- return { type: "literal", literal: e, text: x(e, t) };
385
+ function ni(e, t) {
386
+ return { type: "literal", literal: e, text: b(e, t) };
392
387
  }
393
- function G(e) {
388
+ function D(e) {
394
389
  return e.type === "term" ? e.term : null;
395
390
  }
396
- const li = "Cannot translate grounded Datalog rules to SPARQL.";
397
- function nr(e) {
398
- if (e.some(Ct)) throw new Error(li);
391
+ const si = "Cannot translate grounded Datalog rules to SPARQL.";
392
+ function ir(e) {
393
+ if (e.some(vt)) throw new Error(si);
399
394
  }
400
- function Ct(e) {
395
+ function vt(e) {
401
396
  return p(e).with({ type: "bind" }, ({ groundedTarget: t }) => t !== void 0).with(
402
397
  { type: "aggregate" },
403
- ({ groundedOnTargets: t, bindings: r, atoms: i }) => t !== void 0 || ((r == null ? void 0 : r.some((s) => s.groundedTarget !== void 0)) ?? !1) || i.some(Ct)
404
- ).with({ type: "negation" }, ({ formulas: t }) => t.some(Ct)).with({ type: u.union("triple", "property", "class", "general", "filter", "skolem") }, () => !1).exhaustive();
398
+ ({ groundedOnTargets: t, bindings: r, atoms: i }) => t !== void 0 || (r?.some((s) => s.groundedTarget !== void 0) ?? !1) || i.some(vt)
399
+ ).with({ type: "negation" }, ({ formulas: t }) => t.some(vt)).with({ type: l.union("triple", "property", "class", "general", "filter", "skolem") }, () => !1).exhaustive();
405
400
  }
406
- const g = new vr(), m = g.gen(), De = Mt.getRule("aggregate"), Ge = Mt.getRule("expression"), ui = {
407
- ...De,
401
+ const E = new br(), g = E.gen(), $e = It.getRule("aggregate"), De = It.getRule("expression"), ai = {
402
+ ...$e,
408
403
  gImpl: (e) => (t, r) => {
409
404
  const i = t.secondExpression;
410
405
  if (!i)
411
- return De.gImpl(e)(t, r);
412
- const { PRINT_WORD: s, SUBRULE: a } = e, o = t.expression[0], l = r.astFactory;
413
- if (l.isWildcard(o))
406
+ return $e.gImpl(e)(t, r);
407
+ const { PRINT_WORD: s, SUBRULE: o } = e, a = t.expression[0], u = r.astFactory;
408
+ if (u.isWildcard(a))
414
409
  throw new Error(`Aggregate ${t.aggregation.toUpperCase()} cannot combine * with a second expression.`);
415
- l.printFilter(t, () => {
410
+ u.printFilter(t, () => {
416
411
  s(t.aggregation.toUpperCase(), "("), t.distinct && s("DISTINCT");
417
- }), a(Ge, o), l.printFilter(t, () => s(",")), a(Ge, i), l.printFilter(t, () => s(")"));
412
+ }), o(De, a), u.printFilter(t, () => s(",")), o(De, i), u.printFilter(t, () => s(")"));
418
413
  }
419
- }, ci = xr.create(Mt).patchRule(ui).build(), pi = /* @__PURE__ */ new Set(["MIN_ARGMIN", "MAX_ARGMIN", "MIN_ARGMAX", "MAX_ARGMAX"]), hi = new Map(
420
- Object.entries(ze.builtIn).filter(([e]) => e !== "BuiltInCalls" && e !== "allBuiltInCalls").filter(([, e]) => e && typeof e == "object" && "LABEL" in e).map(([, e]) => {
414
+ }, oi = Rr.create(It).patchRule(ai).build(), li = /* @__PURE__ */ new Set(["MIN_ARGMIN", "MAX_ARGMIN", "MIN_ARGMAX", "MAX_ARGMAX"]), ui = new Map(
415
+ Object.entries(Qe.builtIn).filter(([e]) => e !== "BuiltInCalls" && e !== "allBuiltInCalls").filter(([, e]) => e && typeof e == "object" && "LABEL" in e).map(([, e]) => {
421
416
  const t = e;
422
417
  return [t.LABEL.toLowerCase(), t.LABEL];
423
418
  })
424
419
  );
425
- function D(e) {
420
+ function $(e) {
426
421
  if (e.includes("://") || e.startsWith("urn:") || e.startsWith("mailto:") || e.startsWith("tel:") || e.startsWith("data:"))
427
- return g.termNamed(m, e);
422
+ return E.termNamed(g, e);
428
423
  const r = e.indexOf(":");
429
- return r >= 0 ? g.termNamed(m, e.slice(r + 1), e.slice(0, r)) : g.termNamed(m, e);
424
+ return r >= 0 ? E.termNamed(g, e.slice(r + 1), e.slice(0, r)) : E.termNamed(g, e);
430
425
  }
431
- function ot(e, t) {
432
- return g.expressionOperation(e, t, m);
426
+ function st(e, t) {
427
+ return E.expressionOperation(e, t, g);
433
428
  }
434
- function di(e, t) {
435
- const { function: r, expression: i, secondExpression: s } = e, a = pi.has(r), o = s !== void 0;
436
- if (a && s == null)
429
+ function ci(e, t) {
430
+ const { function: r, expression: i, secondExpression: s } = e, o = li.has(r), a = s !== void 0;
431
+ if (o && s == null)
437
432
  throw new Error(`Aggregate ${r} requires two expressions.`);
438
- if (a && i === "*")
433
+ if (o && i === "*")
439
434
  throw new Error(`Aggregate ${r} cannot use * as an expression.`);
440
- if (!a && o)
435
+ if (!o && a)
441
436
  throw new Error(`Aggregate ${r} accepts only one expression.`);
442
- const l = i === "*" ? g.wildcard(m) : O(i, t), E = g.aggregate(
437
+ const u = i === "*" ? E.wildcard(g) : R(i, t), f = E.aggregate(
443
438
  r.toLowerCase(),
444
439
  e.distinct || !1,
445
- l,
440
+ u,
446
441
  void 0,
447
- m
442
+ g
448
443
  );
449
- return o ? {
450
- ...E,
451
- secondExpression: O(s, t)
452
- } : E;
444
+ return a ? {
445
+ ...f,
446
+ secondExpression: R(s, t)
447
+ } : f;
453
448
  }
454
- function $(e, t, r = void 0) {
449
+ function P(e, t, r = void 0) {
455
450
  return p(r).with("predicate", () => {
456
451
  if (e.type !== "variable" && e.type !== "iri")
457
452
  throw new Error(`Invalid predicate term: ${e.type}. RDF predicates cannot be ${e.type} nodes.`);
@@ -461,137 +456,136 @@ function $(e, t, r = void 0) {
461
456
  }).with("graph", () => {
462
457
  if (e.type !== "variable" && e.type !== "iri")
463
458
  throw new Error(`Invalid graph name term: ${e.type}. Graph names can only be variables or IRIs.`);
464
- }).with(u.nullish, () => {
465
- }).exhaustive(), r === "predicate" && e.type === "iri" && e.value === "a" ? D("rdf:type") : p(e).with({ type: "variable" }, (i) => (t.add(i.name), g.termVariable(i.name, m))).with({ type: "iri", prefixed: !0 }, (i) => D(i.value)).with({ type: "iri", prefixed: !1 }, (i) => g.termNamed(m, i.value)).with(
466
- { type: "literal", language: u.string },
467
- (i) => g.termLiteral(m, i.value, i.language)
468
- ).with({ type: "literal", datatype: u.string }, (i) => {
469
- const s = D(i.datatype);
470
- return g.termLiteral(m, i.value, s);
471
- }).with({ type: "literal" }, (i) => g.termLiteral(m, i.value)).with({ type: "blank" }, (i) => g.termBlank(i.label, m)).exhaustive();
472
- }
473
- function Ei(e, t) {
474
- const r = e.args.map((a) => O(a, t)), i = hi.get(e.name.toLowerCase());
459
+ }).with(l.nullish, () => {
460
+ }).exhaustive(), r === "predicate" && e.type === "iri" && e.value === "a" ? $("rdf:type") : p(e).with({ type: "variable" }, (i) => (t.add(i.name), E.termVariable(i.name, g))).with({ type: "iri", prefixed: !0 }, (i) => $(i.value)).with({ type: "iri", prefixed: !1 }, (i) => E.termNamed(g, i.value)).with(
461
+ { type: "literal", language: l.string },
462
+ (i) => E.termLiteral(g, i.value, i.language)
463
+ ).with({ type: "literal", datatype: l.string }, (i) => {
464
+ const s = $(i.datatype);
465
+ return E.termLiteral(g, i.value, s);
466
+ }).with({ type: "literal" }, (i) => E.termLiteral(g, i.value)).with({ type: "blank" }, (i) => E.termBlank(i.label, g)).exhaustive();
467
+ }
468
+ function pi(e, t) {
469
+ const r = e.args.map((o) => R(o, t)), i = ui.get(e.name.toLowerCase());
475
470
  if (i)
476
- return ot(i.toLowerCase(), r);
477
- const s = D(e.name);
478
- return g.expressionFunctionCall(s, r, !1, m);
471
+ return st(i.toLowerCase(), r);
472
+ const s = $(e.name);
473
+ return E.expressionFunctionCall(s, r, !1, g);
479
474
  }
480
- function O(e, t) {
475
+ function R(e, t) {
481
476
  return p(e).with(
482
477
  { type: "binary" },
483
- (r) => ot(r.operator, [
484
- O(r.left, t),
485
- O(r.right, t)
478
+ (r) => st(r.operator, [
479
+ R(r.left, t),
480
+ R(r.right, t)
486
481
  ])
487
482
  ).with(
488
483
  { type: "unary" },
489
- (r) => ot(r.operator, [O(r.operand, t)])
490
- ).with({ type: "term" }, (r) => $(r.term, t, "expression")).with({ type: "function" }, (r) => Ei(r, t)).with(
484
+ (r) => st(r.operator, [R(r.operand, t)])
485
+ ).with({ type: "term" }, (r) => P(r.term, t, "expression")).with({ type: "function" }, (r) => pi(r, t)).with(
491
486
  { type: "in" },
492
- (r) => ot(r.negated ? "notin" : "in", [
493
- O(r.expression, t),
494
- ...r.list.map((i) => O(i, t))
487
+ (r) => st(r.negated ? "notin" : "in", [
488
+ R(r.expression, t),
489
+ ...r.list.map((i) => R(i, t))
495
490
  ])
496
491
  ).exhaustive();
497
492
  }
498
- function Pt(e, t) {
493
+ function Ft(e, t) {
499
494
  const r = p(e).with(
500
495
  { type: "triple" },
501
- (i) => g.triple(
502
- $(i.subject, t),
503
- $(i.predicate, t, "predicate"),
504
- $(i.object, t)
496
+ (i) => E.triple(
497
+ P(i.subject, t),
498
+ P(i.predicate, t, "predicate"),
499
+ P(i.object, t)
505
500
  )
506
501
  ).with({ type: "property" }, (i) => {
507
- const s = D(i.predicate);
508
- return g.triple($(i.subject, t), s, $(i.object, t));
502
+ const s = $(i.predicate);
503
+ return E.triple(P(i.subject, t), s, P(i.object, t));
509
504
  }).with({ type: "class" }, (i) => {
510
- const s = D("rdf:type"), a = D(i.className);
511
- return g.triple($(i.instance, t), s, a);
505
+ const s = $("rdf:type"), o = $(i.className);
506
+ return E.triple(P(i.instance, t), s, o);
512
507
  }).with({ type: "general" }, () => {
513
508
  throw new Error("General formulas are not supported as triple patterns.");
514
509
  }).exhaustive();
515
510
  if (!r) return { triples: [] };
516
511
  if ("graph" in e && e.graph) {
517
- const i = g.patternBgp([r], m);
518
- return { graph: g.patternGraph(
519
- $(e.graph, t, "graph"),
512
+ const i = E.patternBgp([r], g);
513
+ return { graph: E.patternGraph(
514
+ P(e.graph, t, "graph"),
520
515
  [i],
521
- m
516
+ g
522
517
  ) };
523
518
  }
524
519
  return { triples: [r] };
525
520
  }
526
- function fi(e, t) {
521
+ function hi(e, t) {
527
522
  return e.formulas.filter((r) => "type" in r).flatMap(
528
- (r) => p(r).with({ type: u.union("triple", "property", "class") }, (i) => Pt(i, t).triples || []).with({ type: "general" }, () => {
523
+ (r) => p(r).with({ type: l.union("triple", "property", "class") }, (i) => Ft(i, t).triples || []).with({ type: "general" }, () => {
529
524
  throw new Error("General formulas are not supported in negation patterns.");
530
525
  }).exhaustive()
531
526
  );
532
527
  }
533
- function gi(e, t) {
528
+ function di(e, t) {
534
529
  return e.reduce(
535
- (r, i) => "type" in i ? p(i).with({ type: u.union("triple", "property", "class") }, (s) => {
536
- const a = Pt(s, t);
537
- return a.graph ? { ...r, graphPatterns: [...r.graphPatterns, a.graph] } : a.triples ? { ...r, triples: [...r.triples, ...a.triples] } : r;
530
+ (r, i) => "type" in i ? p(i).with({ type: l.union("triple", "property", "class") }, (s) => {
531
+ const o = Ft(s, t);
532
+ return o.graph ? { ...r, graphPatterns: [...r.graphPatterns, o.graph] } : o.triples ? { ...r, triples: [...r.triples, ...o.triples] } : r;
538
533
  }).with({ type: "filter" }, (s) => {
539
- const a = O(s.expression, t), o = g.patternFilter(a, m);
540
- return { ...r, filters: [...r.filters, o] };
534
+ const o = R(s.expression, t), a = E.patternFilter(o, g);
535
+ return { ...r, filters: [...r.filters, a] };
541
536
  }).with({ type: "bind" }, (s) => {
542
537
  t.add(s.variable);
543
- const a = O(s.expression, t), o = g.termVariable(s.variable, m), l = g.patternBind(a, o, m);
544
- return { ...r, binds: [...r.binds, l] };
538
+ const o = R(s.expression, t), a = E.termVariable(s.variable, g), u = E.patternBind(o, a, g);
539
+ return { ...r, binds: [...r.binds, u] };
545
540
  }).with({ type: "general" }, () => {
546
541
  throw new Error("General formulas are not supported in atom processing.");
547
542
  }).exhaustive() : r,
548
543
  { triples: [], filters: [], binds: [], graphPatterns: [] }
549
544
  );
550
545
  }
551
- function mi(e, t) {
552
- var S;
553
- const { triples: r, filters: i, binds: s, graphPatterns: a } = gi(e.atoms, t), o = e.onVars || [], l = o.map((h) => (t.add(h), g.termVariable(h, m))), E = [], y = [];
554
- return (S = e.bindings) == null || S.forEach((h) => {
555
- if (t.add(h.variable), h.expression === void 0) {
556
- const W = h.function !== void 0 ? `Aggregate ${h.function}` : "Expression-only aggregate binding";
557
- throw new Error(`${W} requires an expression.`);
546
+ function Ei(e, t) {
547
+ const { triples: r, filters: i, binds: s, graphPatterns: o } = di(e.atoms, t), a = e.onVars || [], u = a.map((m) => (t.add(m), E.termVariable(m, g))), f = [], y = [];
548
+ return e.bindings?.forEach((m) => {
549
+ if (t.add(m.variable), m.expression === void 0) {
550
+ const k = m.function !== void 0 ? `Aggregate ${m.function}` : "Expression-only aggregate binding";
551
+ throw new Error(`${k} requires an expression.`);
558
552
  }
559
- if (h.function === void 0 && h.secondExpression !== void 0)
553
+ if (m.function === void 0 && m.secondExpression !== void 0)
560
554
  throw new Error("Expression-only aggregate bindings cannot have a second expression.");
561
- const R = h.function !== void 0, L = R ? di(h, t) : O(h.expression, t), A = g.termVariable(h.variable, m), k = g.patternBind(L, A, m);
562
- R ? E.push(k) : y.push(k);
555
+ const h = m.function !== void 0, C = h ? ci(m, t) : R(m.expression, t), T = E.termVariable(m.variable, g), A = E.patternBind(C, T, g);
556
+ h ? f.push(A) : y.push(A);
563
557
  }), {
564
558
  triples: r,
565
559
  filters: i,
566
560
  binds: [...s, ...y],
567
- graphPatterns: a,
568
- selectVars: [...l, ...E],
569
- groupBy: o
561
+ graphPatterns: o,
562
+ selectVars: [...u, ...f],
563
+ groupBy: a
570
564
  };
571
565
  }
572
- function yi(e, t) {
573
- nr(e);
566
+ function fi(e, t) {
567
+ ir(e);
574
568
  const r = /* @__PURE__ */ new Set(), i = e.reduce(
575
- (h, R) => p(R).with({ type: u.union("triple", "property", "class", "general") }, (L) => {
576
- const A = Pt(L, r);
569
+ (h, C) => p(C).with({ type: l.union("triple", "property", "class", "general") }, (T) => {
570
+ const A = Ft(T, r);
577
571
  return A.graph ? { ...h, graphPatterns: [...h.graphPatterns, A.graph] } : A.triples ? { ...h, triples: [...h.triples, ...A.triples] } : h;
578
- }).with({ type: "filter" }, (L) => {
579
- const A = O(L.expression, r), k = g.patternFilter(A, m);
572
+ }).with({ type: "filter" }, (T) => {
573
+ const A = R(T.expression, r), k = E.patternFilter(A, g);
580
574
  return { ...h, filters: [...h.filters, k] };
581
- }).with({ type: "bind" }, (L) => {
582
- const A = O(L.expression, r);
583
- r.add(L.variable);
584
- const k = g.termVariable(L.variable, m), W = g.patternBind(A, k, m);
585
- return { ...h, binds: [...h.binds, W] };
586
- }).with({ type: "negation" }, (L) => {
587
- const A = fi(L, r);
575
+ }).with({ type: "bind" }, (T) => {
576
+ const A = R(T.expression, r);
577
+ r.add(T.variable);
578
+ const k = E.termVariable(T.variable, g), At = E.patternBind(A, k, g);
579
+ return { ...h, binds: [...h.binds, At] };
580
+ }).with({ type: "negation" }, (T) => {
581
+ const A = hi(T, r);
588
582
  if (A.length > 0) {
589
- const k = g.patternBgp(A, m), W = g.patternGroup([k], m), Nr = g.expressionPatternOperation("notexists", W, m), Rr = g.patternFilter(Nr, m);
590
- return { ...h, filters: [...h.filters, Rr] };
583
+ const k = E.patternBgp(A, g), At = E.patternGroup([k], g), Sr = E.expressionPatternOperation("notexists", At, g), Nr = E.patternFilter(Sr, g);
584
+ return { ...h, filters: [...h.filters, Nr] };
591
585
  }
592
586
  return h;
593
- }).with({ type: "aggregate" }, (L) => {
594
- const A = mi(L, r);
587
+ }).with({ type: "aggregate" }, (T) => {
588
+ const A = Ei(T, r);
595
589
  return {
596
590
  triples: [...h.triples, ...A.triples],
597
591
  filters: [...h.filters, ...A.filters],
@@ -612,139 +606,140 @@ function yi(e, t) {
612
606
  aggregateSelectVars: []
613
607
  }
614
608
  ), s = [
615
- ...i.triples.length > 0 ? [g.patternBgp(i.triples, m)] : [],
609
+ ...i.triples.length > 0 ? [E.patternBgp(i.triples, g)] : [],
616
610
  ...i.graphPatterns,
617
611
  ...i.filters,
618
612
  ...i.binds
619
- ], a = i.aggregateSelectVars.length > 0 ? i.aggregateSelectVars : r.size > 0 ? Array.from(r).map((h) => g.termVariable(h, m)) : [g.wildcard(m)], o = i.groupByVars.length > 0 ? {
620
- group: g.solutionModifierGroup(
621
- i.groupByVars.map((h) => g.termVariable(h, m)),
622
- m
613
+ ], o = i.aggregateSelectVars.length > 0 ? i.aggregateSelectVars : r.size > 0 ? Array.from(r).map((h) => E.termVariable(h, g)) : [E.wildcard(g)], a = i.groupByVars.length > 0 ? {
614
+ group: E.solutionModifierGroup(
615
+ i.groupByVars.map((h) => E.termVariable(h, g)),
616
+ g
623
617
  )
624
- } : {}, l = t ? Object.entries(t).map(([h, R]) => {
625
- const L = g.termNamed(m, R);
626
- return g.contextDefinitionPrefix(m, h, L);
627
- }) : [], E = g.querySelect(
618
+ } : {}, u = t ? Object.entries(t).map(([h, C]) => {
619
+ const T = E.termNamed(g, C);
620
+ return E.contextDefinitionPrefix(g, h, T);
621
+ }) : [], f = E.querySelect(
628
622
  {
629
- context: l,
623
+ context: u,
630
624
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-ts-comment
631
- variables: a,
625
+ variables: o,
632
626
  // @ts-ignore - Fails in CI for some reason
633
- where: g.patternGroup(s, m),
634
- datasets: g.datasetClauses([], m),
635
- solutionModifiers: o
627
+ where: E.patternGroup(s, g),
628
+ datasets: E.datasetClauses([], g),
629
+ solutionModifiers: a
636
630
  },
637
- m
638
- ), y = ci.queryOrUpdate(E, Cr({ indentInc: 2 })).trim(), S = i.aggregateSelectVars.length > 0 ? i.aggregateSelectVars.map((h) => "value" in h && typeof h.value == "string" ? h.value : "variable" in h && h.variable && "value" in h.variable ? h.variable.value : null).filter((h) => h !== null) : Array.from(r);
631
+ g
632
+ ), y = oi.queryOrUpdate(f, Or({ indentInc: 2 })).trim(), m = i.aggregateSelectVars.length > 0 ? i.aggregateSelectVars.map((h) => "value" in h && typeof h.value == "string" ? h.value : "variable" in h && h.variable && "value" in h.variable ? h.variable.value : null).filter((h) => h !== null) : Array.from(r);
639
633
  return {
640
634
  query: y,
641
- variables: S
635
+ variables: m
642
636
  };
643
637
  }
644
- const kt = c({ name: "RULE_ARROW", pattern: /:-/ }), lt = c({ name: "NOT", pattern: /NOT/ }), $t = c({ name: "EXISTS", pattern: /EXISTS?/ }), Z = c({ name: "IN", pattern: /IN/ }), Dt = c({ name: "FILTER", pattern: /FILTER/ }), z = c({ name: "BIND", pattern: /BIND/ }), K = c({ name: "AS", pattern: /AS/ }), wt = c({ name: "AGGREGATE", pattern: /AGGREGATE/ }), At = c({ name: "ON", pattern: /ON/ }), Gt = c({ name: "COUNT", pattern: /COUNT/ }), _t = c({ name: "MIN", pattern: /MIN/ }), Vt = c({ name: "MAX", pattern: /MAX/ }), jt = c({ name: "SUM", pattern: /SUM/ }), qt = c({ name: "MUL", pattern: /MUL/ }), Xt = c({ name: "AVG", pattern: /AVG/ }), Ht = c({ name: "COUNT_MIN", pattern: /COUNT_MIN/ }), Qt = c({ name: "COUNT_MAX", pattern: /COUNT_MAX/ }), zt = c({ name: "MIN_ARGMIN", pattern: /MIN_ARGMIN/ }), Kt = c({ name: "MAX_ARGMIN", pattern: /MAX_ARGMIN/ }), Wt = c({ name: "MIN_ARGMAX", pattern: /MIN_ARGMAX/ }), Yt = c({ name: "MAX_ARGMAX", pattern: /MAX_ARGMAX/ }), ut = c({ name: "DISTINCT", pattern: /DISTINCT/ }), Zt = c({ name: "CONCAT", pattern: /CONCAT/ }), Jt = c({ name: "STR", pattern: /STR/ }), te = c({ name: "IF", pattern: /IF/ }), ee = c({ name: "IRI", pattern: /IRI/ }), ct = c({ name: "SKOLEM", pattern: /SKOLEM/ }), re = c({ name: "ROUND", pattern: /ROUND/ }), ie = c({ name: "REGEX", pattern: /REGEX/ }), ne = c({ name: "TRUE", pattern: /true/ }), se = c({ name: "FALSE", pattern: /false/ }), ae = c({ name: "EQUALS", pattern: /=/ }), oe = c({ name: "NOT_EQUALS", pattern: /!=/ }), le = c({ name: "LESS_THAN", pattern: /</ }), ue = c({ name: "LESS_THAN_OR_EQUAL", pattern: /<=/ }), ce = c({ name: "GREATER_THAN", pattern: />/ }), pe = c({ name: "GREATER_THAN_OR_EQUAL", pattern: />=/ }), he = c({ name: "AND", pattern: /&&/ }), de = c({ name: "OR", pattern: /\|\|/ }), pt = c({ name: "PLUS", pattern: /\+/ }), ht = c({ name: "MINUS", pattern: /-/ }), dt = c({ name: "STAR", pattern: /\*/ }), Ee = c({ name: "SLASH", pattern: /\// }), fe = c({ name: "EXCLAMATION", pattern: /!/ }), ge = c({ name: "DOT", pattern: /\./ }), N = c({ name: "COMMA", pattern: /,/ }), U = c({ name: "LPAREN", pattern: /\(/ }), w = c({ name: "RPAREN", pattern: /\)/ }), Et = c({ name: "LBRACKET", pattern: /\[/ }), ft = c({ name: "RBRACKET", pattern: /\]/ }), sr = c({ name: "AT", pattern: /@/ }), gt = c({ name: "HAT", pattern: /\^/ }), ar = c({ name: "COLON", pattern: /:/ }), b = c({ name: "VARIABLE", pattern: /\?[a-zA-Z_][a-zA-Z0-9_]*/ }), me = c({ name: "IRI_REF", pattern: new RegExp(`<${Ke}*>`) }), ye = c({ name: "INTERNAL_FUNCTION", pattern: /<internal:[^>]+>/ }), et = c({ name: "BLANK_NODE", pattern: /_:[\w](?:[\w.-]*[\w-])?/ }), Le = "%[0-9a-fA-F]{2}|\\\\[-_~.!$&'()*+,;=/?#@%]", Li = `(?:[\\w:]|${Le})`, Ui = `(?:[\\w:.-]|${Le})`, wi = `(?:[\\w:-]|${Le})`, or = `${Li}(?:${Ui}*${wi})?`, st = c({
638
+ const Pt = c({ name: "RULE_ARROW", pattern: /:-/ }), at = c({ name: "NOT", pattern: /NOT/ }), kt = c({ name: "EXISTS", pattern: /EXISTS?/ }), W = c({ name: "IN", pattern: /IN/ }), $t = c({ name: "FILTER", pattern: /FILTER/ }), Q = c({ name: "BIND", pattern: /BIND/ }), z = c({ name: "AS", pattern: /AS/ }), Lt = c({ name: "AGGREGATE", pattern: /AGGREGATE/ }), Ut = c({ name: "ON", pattern: /ON/ }), Dt = c({ name: "COUNT", pattern: /COUNT/ }), Gt = c({ name: "MIN", pattern: /MIN/ }), _t = c({ name: "MAX", pattern: /MAX/ }), Vt = c({ name: "SUM", pattern: /SUM/ }), jt = c({ name: "MUL", pattern: /MUL/ }), qt = c({ name: "AVG", pattern: /AVG/ }), Xt = c({ name: "COUNT_MIN", pattern: /COUNT_MIN/ }), Ht = c({ name: "COUNT_MAX", pattern: /COUNT_MAX/ }), Qt = c({ name: "MIN_ARGMIN", pattern: /MIN_ARGMIN/ }), zt = c({ name: "MAX_ARGMIN", pattern: /MAX_ARGMIN/ }), Kt = c({ name: "MIN_ARGMAX", pattern: /MIN_ARGMAX/ }), Wt = c({ name: "MAX_ARGMAX", pattern: /MAX_ARGMAX/ }), ot = c({ name: "DISTINCT", pattern: /DISTINCT/ }), Yt = c({ name: "CONCAT", pattern: /CONCAT/ }), Zt = c({ name: "STR", pattern: /STR/ }), Jt = c({ name: "IF", pattern: /IF/ }), te = c({ name: "IRI", pattern: /IRI/ }), lt = c({ name: "SKOLEM", pattern: /SKOLEM/ }), ee = c({ name: "ROUND", pattern: /ROUND/ }), re = c({ name: "REGEX", pattern: /REGEX/ }), ie = c({ name: "TRUE", pattern: /true/ }), ne = c({ name: "FALSE", pattern: /false/ }), se = c({ name: "EQUALS", pattern: /=/ }), ae = c({ name: "NOT_EQUALS", pattern: /!=/ }), oe = c({ name: "LESS_THAN", pattern: /</ }), le = c({ name: "LESS_THAN_OR_EQUAL", pattern: /<=/ }), ue = c({ name: "GREATER_THAN", pattern: />/ }), ce = c({ name: "GREATER_THAN_OR_EQUAL", pattern: />=/ }), pe = c({ name: "AND", pattern: /&&/ }), he = c({ name: "OR", pattern: /\|\|/ }), ut = c({ name: "PLUS", pattern: /\+/ }), ct = c({ name: "MINUS", pattern: /-/ }), pt = c({ name: "STAR", pattern: /\*/ }), de = c({ name: "SLASH", pattern: /\// }), Ee = c({ name: "EXCLAMATION", pattern: /!/ }), fe = c({ name: "DOT", pattern: /\./ }), S = c({ name: "COMMA", pattern: /,/ }), L = c({ name: "LPAREN", pattern: /\(/ }), U = c({ name: "RPAREN", pattern: /\)/ }), ht = c({ name: "LBRACKET", pattern: /\[/ }), dt = c({ name: "RBRACKET", pattern: /\]/ }), nr = c({ name: "AT", pattern: /@/ }), Et = c({ name: "HAT", pattern: /\^/ }), sr = c({ name: "COLON", pattern: /:/ }), N = c({ name: "VARIABLE", pattern: /\?[a-zA-Z_][a-zA-Z0-9_]*/ }), ge = c({ name: "IRI_REF", pattern: new RegExp(`<${ze}*>`) }), me = c({ name: "INTERNAL_FUNCTION", pattern: /<internal:[^>]+>/ }), J = c({ name: "BLANK_NODE", pattern: /_:[\w](?:[\w.-]*[\w-])?/ }), ye = "%[0-9a-fA-F]{2}|\\\\[-_~.!$&'()*+,;=/?#@%]", gi = `(?:[\\w:]|${ye})`, mi = `(?:[\\w:.-]|${ye})`, yi = `(?:[\\w:-]|${ye})`, ar = `${gi}(?:${mi}*${yi})?`, it = c({
645
639
  name: "PREFIXED_NAME",
646
- pattern: new RegExp(`[a-zA-Z_][\\w]*:${or}`)
647
- }), Tt = c({ name: "PREFIX_ONLY", pattern: /[a-zA-Z_][\w]*:/ }), Ue = c({
640
+ pattern: new RegExp(`[a-zA-Z_][\\w]*:${ar}`)
641
+ }), wt = c({ name: "PREFIX_ONLY", pattern: /[a-zA-Z_][\w]*:/ }), Le = c({
648
642
  name: "DEFAULT_NS_IRI",
649
- pattern: new RegExp(`:${or}`)
650
- }), we = c({ name: "INTEGER", pattern: /[+-]?\d+/ }), Ae = c({ name: "DECIMAL", pattern: /[+-]?\d*\.\d+/ }), Te = c({
643
+ pattern: new RegExp(`:${ar}`)
644
+ }), Ue = c({ name: "INTEGER", pattern: /[+-]?\d+/ }), we = c({ name: "DECIMAL", pattern: /[+-]?\d*\.\d+/ }), Ae = c({
651
645
  name: "DOUBLE",
652
646
  pattern: /[+-]?(\d+\.\d*[eE][+-]?\d+|\.\d+[eE][+-]?\d+|\d+[eE][+-]?\d+)/
653
- }), Se = c({
647
+ }), Te = c({
654
648
  name: "STRING_LITERAL_LONG",
655
649
  pattern: /"""(?:[^"\\]|\\.|"(?!""))*"""|'''(?:[^'\\]|\\.|'(?!''))*'''/
656
- }), mt = c({
650
+ }), ft = c({
657
651
  name: "STRING_LITERAL",
658
652
  pattern: /"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/
659
- }), Ne = c({ name: "LANGTAG", pattern: /@[a-zA-Z]+(-[a-zA-Z0-9]+)*/ }), rt = c({
653
+ }), Se = c({ name: "LANGTAG", pattern: /@[a-zA-Z]+(-[a-zA-Z0-9]+)*/ }), tt = c({
660
654
  name: "IDENTIFIER",
661
655
  pattern: /[a-zA-Z_][a-zA-Z0-9_]*/,
662
- longer_alt: st
663
- }), Ai = c({
656
+ longer_alt: it
657
+ }), Li = c({
664
658
  name: "COMMENT",
665
659
  pattern: /#[^\r\n]*/,
666
- group: Bt.SKIPPED
667
- }), Ti = c({
660
+ group: Mt.SKIPPED
661
+ }), Ui = c({
668
662
  name: "WHITESPACE",
669
663
  pattern: /\s+/,
670
- group: Bt.SKIPPED
671
- }), lr = [
664
+ group: Mt.SKIPPED
665
+ }), or = [
672
666
  // Whitespace and comments (skipped)
673
- Ti,
674
- Ai,
667
+ Ui,
668
+ Li,
675
669
  // Multi-character operators (before single-char)
676
- kt,
677
- oe,
678
- ue,
670
+ Pt,
671
+ ae,
672
+ le,
673
+ ce,
679
674
  pe,
680
675
  he,
681
- de,
682
- gt,
676
+ Et,
683
677
  // Keywords (before identifiers)
684
- lt,
678
+ at,
679
+ kt,
680
+ W,
685
681
  $t,
686
- Z,
687
- Dt,
682
+ Q,
688
683
  z,
689
- K,
690
- wt,
691
- At,
684
+ Lt,
685
+ Ut,
686
+ Qt,
692
687
  zt,
693
688
  Kt,
694
689
  Wt,
695
- Yt,
690
+ Xt,
696
691
  Ht,
697
- Qt,
692
+ Dt,
698
693
  Gt,
699
694
  _t,
700
695
  Vt,
701
696
  jt,
702
697
  qt,
703
- Xt,
704
- ut,
698
+ ot,
699
+ Yt,
705
700
  Zt,
706
701
  Jt,
707
702
  te,
703
+ lt,
708
704
  ee,
709
- ct,
710
705
  re,
711
706
  ie,
712
707
  ne,
713
- se,
714
708
  // Literals (specific patterns before generic)
715
- Se,
716
- mt,
717
709
  Te,
710
+ ft,
718
711
  Ae,
719
712
  we,
720
- Ne,
713
+ Ue,
714
+ Se,
721
715
  // Identifiers and names
722
- b,
723
- ye,
716
+ N,
724
717
  me,
725
- et,
726
- st,
727
- Ue,
728
- Tt,
729
- rt,
718
+ ge,
719
+ J,
720
+ it,
721
+ Le,
722
+ wt,
723
+ tt,
730
724
  // Single character tokens
731
- ae,
732
- le,
733
- ce,
725
+ se,
726
+ oe,
727
+ ue,
728
+ ut,
729
+ ct,
734
730
  pt,
735
- ht,
736
- dt,
731
+ de,
737
732
  Ee,
738
733
  fe,
739
- ge,
740
- N,
734
+ S,
735
+ L,
741
736
  U,
742
- w,
743
- Et,
744
- ft,
745
- sr,
746
- ar
747
- ], Si = /* @__PURE__ */ new Set([lt, $t, Z, Dt, z, K, wt, At, ut]), Ni = /* @__PURE__ */ new Set([
737
+ ht,
738
+ dt,
739
+ nr,
740
+ sr
741
+ ], wi = /* @__PURE__ */ new Set([at, kt, W, $t, Q, z, Lt, Ut, ot]), Ai = /* @__PURE__ */ new Set([
742
+ Dt,
748
743
  Gt,
749
744
  _t,
750
745
  Vt,
@@ -760,12 +755,12 @@ const kt = c({ name: "RULE_ARROW", pattern: /:-/ }), lt = c({ name: "NOT", patte
760
755
  Zt,
761
756
  Jt,
762
757
  te,
758
+ lt,
763
759
  ee,
764
- ct,
765
- re,
766
- ie
767
- ]), Ri = /* @__PURE__ */ new Set([ne, se]), ds = /* @__PURE__ */ new Set([we, Ae, Te]), bi = /* @__PURE__ */ new Set([mt, Se]), Es = /* @__PURE__ */ new Set([me, ye, st, Tt, Ue]), fs = /* @__PURE__ */ new Set([
768
- kt,
760
+ re
761
+ ]), Ti = /* @__PURE__ */ new Set([ie, ne]), us = /* @__PURE__ */ new Set([Ue, we, Ae]), Si = /* @__PURE__ */ new Set([ft, Te]), cs = /* @__PURE__ */ new Set([ge, me, it, wt, Le]), ps = /* @__PURE__ */ new Set([
762
+ Pt,
763
+ se,
769
764
  ae,
770
765
  oe,
771
766
  le,
@@ -773,31 +768,29 @@ const kt = c({ name: "RULE_ARROW", pattern: /:-/ }), lt = c({ name: "NOT", patte
773
768
  ce,
774
769
  pe,
775
770
  he,
776
- de,
771
+ ut,
772
+ ct,
777
773
  pt,
778
- ht,
779
- dt,
780
- Ee,
781
- fe
782
- ]), gs = /* @__PURE__ */ new Set([ge, N, U, w, Et, ft, sr, gt, ar]), ms = /* @__PURE__ */ new Set([b, et, Ne, rt]);
783
- for (const e of [...Si, ...Ni, ...Ri])
784
- e.LONGER_ALT = [st, Tt, rt];
785
- let Oi;
786
- function Re(e) {
787
- return (Oi ?? (Oi = new Bt(lr))).tokenize(e);
788
- }
789
- function J(e, t, r, i) {
790
- var o;
791
- const a = e.slice(0, t).split(/\r\n|\r|\n/);
774
+ de,
775
+ Ee
776
+ ]), hs = /* @__PURE__ */ new Set([fe, S, L, U, ht, dt, nr, Et, sr]), ds = /* @__PURE__ */ new Set([N, J, Se, tt]);
777
+ for (const e of [...wi, ...Ai, ...Ti])
778
+ e.LONGER_ALT = [it, wt, tt];
779
+ let Ni;
780
+ function Ne(e) {
781
+ return (Ni ??= new Mt(or)).tokenize(e);
782
+ }
783
+ function Y(e, t, r, i) {
784
+ const o = e.slice(0, t).split(/\r\n|\r|\n/);
792
785
  return {
793
786
  message: i,
794
- line: a.length,
795
- column: (((o = a.at(-1)) == null ? void 0 : o.length) ?? 0) + 1,
787
+ line: o.length,
788
+ column: (o.at(-1)?.length ?? 0) + 1,
796
789
  offset: t,
797
790
  endOffset: t + r
798
791
  };
799
792
  }
800
- function be(e) {
793
+ function Re(e) {
801
794
  for (let t = 0; t < e.length; t++) {
802
795
  const r = e.charCodeAt(t);
803
796
  if (r >= 55296 && r <= 56319) {
@@ -806,15 +799,15 @@ function be(e) {
806
799
  t++;
807
800
  continue;
808
801
  }
809
- return J(e, t, 1, "Unpaired high surrogate is not a valid Unicode scalar value");
802
+ return Y(e, t, 1, "Unpaired high surrogate is not a valid Unicode scalar value");
810
803
  }
811
804
  if (r >= 56320 && r <= 57343)
812
- return J(e, t, 1, "Unpaired low surrogate is not a valid Unicode scalar value");
805
+ return Y(e, t, 1, "Unpaired low surrogate is not a valid Unicode scalar value");
813
806
  }
814
807
  }
815
- function Oe(e, t) {
808
+ function be(e, t) {
816
809
  for (const r of t)
817
- if (bi.has(r.tokenType))
810
+ if (Si.has(r.tokenType))
818
811
  for (let i = 0; i < r.image.length; i++) {
819
812
  if (r.image[i] !== "\\") continue;
820
813
  const s = r.image[i + 1];
@@ -822,416 +815,416 @@ function Oe(e, t) {
822
815
  i++;
823
816
  continue;
824
817
  }
825
- const a = s === "u" ? 4 : 8, o = a + 2, l = r.image.slice(i, i + o), E = r.image.slice(i + 2, i + o), y = r.startOffset + i;
826
- if (E.length !== a || !/^[0-9a-fA-F]+$/.test(E))
827
- return J(
818
+ const o = s === "u" ? 4 : 8, a = o + 2, u = r.image.slice(i, i + a), f = r.image.slice(i + 2, i + a), y = r.startOffset + i;
819
+ if (f.length !== o || !/^[0-9a-fA-F]+$/.test(f))
820
+ return Y(
828
821
  e,
829
822
  y,
830
- l.length,
831
- `Unicode escape \\${s} must contain ${a} hexadecimal digits`
823
+ u.length,
824
+ `Unicode escape \\${s} must contain ${o} hexadecimal digits`
832
825
  );
833
- const S = Number.parseInt(E, 16);
834
- if (S >= 55296 && S <= 57343)
835
- return J(e, y, o, `Unicode escape ${l} denotes a surrogate code point`);
836
- if (S > 1114111)
837
- return J(e, y, o, `Unicode escape ${l} is outside the Unicode range`);
838
- i += o - 1;
826
+ const m = Number.parseInt(f, 16);
827
+ if (m >= 55296 && m <= 57343)
828
+ return Y(e, y, a, `Unicode escape ${u} denotes a surrogate code point`);
829
+ if (m > 1114111)
830
+ return Y(e, y, a, `Unicode escape ${u} is outside the Unicode range`);
831
+ i += a - 1;
839
832
  }
840
833
  }
841
- class xe extends Br {
842
- constructor(r = {}) {
843
- super(lr);
844
- // Rule := RuleHead ':-' RuleBody '.'
845
- d(this, "rule", this.RULE("rule", () => {
846
- this.SUBRULE(this.ruleHead), this.CONSUME(kt), this.OPTION(() => {
847
- this.SUBRULE(this.ruleBody);
848
- }), this.CONSUME(ge);
849
- }));
850
- // RuleHead := TupleTableAtom (',' TupleTableAtom)*
851
- d(this, "ruleHead", this.RULE("ruleHead", () => {
852
- this.SUBRULE(this.tupleTableAtom), this.MANY(() => {
853
- this.CONSUME(N), this.SUBRULE2(this.tupleTableAtom);
854
- });
855
- }));
856
- // RuleBody := BodyFormula (',' BodyFormula)*
857
- d(this, "ruleBody", this.RULE("ruleBody", () => {
858
- this.SUBRULE(this.bodyFormula), this.MANY(() => {
859
- this.CONSUME(N), this.SUBRULE2(this.bodyFormula);
860
- });
861
- }));
862
- // BodyFormula := Negation | FilterAtom | BindAtom | Aggregate | SkolemAtom | TupleTableAtom
863
- d(this, "bodyFormula", this.RULE("bodyFormula", () => {
864
- this.OR([
865
- { ALT: () => this.SUBRULE(this.negation) },
866
- { ALT: () => this.SUBRULE(this.filterAtom) },
867
- { ALT: () => this.SUBRULE(this.bindAtom) },
868
- { ALT: () => this.SUBRULE(this.aggregate) },
869
- { ALT: () => this.SUBRULE(this.skolemAtom) },
870
- { ALT: () => this.SUBRULE(this.tupleTableAtom) }
871
- ]);
872
- }));
873
- // TupleTableAtom := (DefaultGraphAtom Graph?) | GeneralAtom
874
- // NamedGraphAtom := DefaultGraphAtom Graph
875
- // Graph := Term (IRI or Variable)
876
- d(this, "tupleTableAtom", this.RULE("tupleTableAtom", () => {
877
- this.OR([{ ALT: () => this.SUBRULE(this.defaultGraphAtom) }, { ALT: () => this.SUBRULE(this.generalAtom) }]), this.OPTION(() => {
878
- this.SUBRULE(this.graphName, { LABEL: "graph" });
879
- });
880
- }));
881
- // Graph name for named graph atoms - can be IRI or Variable
882
- d(this, "graphName", this.RULE("graphName", () => {
883
- this.OR([{ ALT: () => this.CONSUME(b) }, { ALT: () => this.SUBRULE(this.iri) }]);
884
- }));
885
- // DefaultGraphAtom := TripleAtom | PropertyAtom | ClassAtom
886
- d(this, "defaultGraphAtom", this.RULE("defaultGraphAtom", () => {
887
- this.OR([
888
- // TripleAtom: [term, term, term]
889
- {
890
- ALT: () => {
891
- this.CONSUME(Et), this.SUBRULE(this.term, { LABEL: "subject" }), this.CONSUME(N), this.SUBRULE2(this.term, { LABEL: "predicate" }), this.CONSUME2(N), this.SUBRULE3(this.term, { LABEL: "object" }), this.CONSUME(ft);
892
- }
893
- },
894
- // PropertyAtom: predicate[term, term] or ClassAtom: class[term]
834
+ class Oe extends Cr {
835
+ constructor(t = {}) {
836
+ super(or);
837
+ const { selfAnalysis: r = !0 } = t;
838
+ r && this.performSelfAnalysis();
839
+ }
840
+ // Chevrotain only reports leftover input for the rule it was entered on, so
841
+ // callers entering on a nested rule have to reject trailing tokens themselves.
842
+ get atEndOfInput() {
843
+ return this.LA(1).tokenType === Ir;
844
+ }
845
+ // Rule := RuleHead ':-' RuleBody '.'
846
+ rule = this.RULE("rule", () => {
847
+ this.SUBRULE(this.ruleHead), this.CONSUME(Pt), this.OPTION(() => {
848
+ this.SUBRULE(this.ruleBody);
849
+ }), this.CONSUME(fe);
850
+ });
851
+ // RuleHead := TupleTableAtom (',' TupleTableAtom)*
852
+ ruleHead = this.RULE("ruleHead", () => {
853
+ this.SUBRULE(this.tupleTableAtom), this.MANY(() => {
854
+ this.CONSUME(S), this.SUBRULE2(this.tupleTableAtom);
855
+ });
856
+ });
857
+ // RuleBody := BodyFormula (',' BodyFormula)*
858
+ ruleBody = this.RULE("ruleBody", () => {
859
+ this.SUBRULE(this.bodyFormula), this.MANY(() => {
860
+ this.CONSUME(S), this.SUBRULE2(this.bodyFormula);
861
+ });
862
+ });
863
+ // BodyFormula := Negation | FilterAtom | BindAtom | Aggregate | SkolemAtom | TupleTableAtom
864
+ bodyFormula = this.RULE("bodyFormula", () => {
865
+ this.OR([
866
+ { ALT: () => this.SUBRULE(this.negation) },
867
+ { ALT: () => this.SUBRULE(this.filterAtom) },
868
+ { ALT: () => this.SUBRULE(this.bindAtom) },
869
+ { ALT: () => this.SUBRULE(this.aggregate) },
870
+ { ALT: () => this.SUBRULE(this.skolemAtom) },
871
+ { ALT: () => this.SUBRULE(this.tupleTableAtom) }
872
+ ]);
873
+ });
874
+ // TupleTableAtom := (DefaultGraphAtom Graph?) | GeneralAtom
875
+ // NamedGraphAtom := DefaultGraphAtom Graph
876
+ // Graph := Term (IRI or Variable)
877
+ tupleTableAtom = this.RULE("tupleTableAtom", () => {
878
+ this.OR([{ ALT: () => this.SUBRULE(this.defaultGraphAtom) }, { ALT: () => this.SUBRULE(this.generalAtom) }]), this.OPTION(() => {
879
+ this.SUBRULE(this.graphName, { LABEL: "graph" });
880
+ });
881
+ });
882
+ // Graph name for named graph atoms - can be IRI or Variable
883
+ graphName = this.RULE("graphName", () => {
884
+ this.OR([{ ALT: () => this.CONSUME(N) }, { ALT: () => this.SUBRULE(this.iri) }]);
885
+ });
886
+ // DefaultGraphAtom := TripleAtom | PropertyAtom | ClassAtom
887
+ defaultGraphAtom = this.RULE("defaultGraphAtom", () => {
888
+ this.OR([
889
+ // TripleAtom: [term, term, term]
890
+ {
891
+ ALT: () => {
892
+ this.CONSUME(ht), this.SUBRULE(this.term, { LABEL: "subject" }), this.CONSUME(S), this.SUBRULE2(this.term, { LABEL: "predicate" }), this.CONSUME2(S), this.SUBRULE3(this.term, { LABEL: "object" }), this.CONSUME(dt);
893
+ }
894
+ },
895
+ // PropertyAtom: predicate[term, term] or ClassAtom: class[term]
896
+ {
897
+ ALT: () => {
898
+ this.SUBRULE(this.iri, { LABEL: "predicateOrClass" }), this.CONSUME2(ht), this.SUBRULE4(this.term, { LABEL: "firstTerm" }), this.OPTION(() => {
899
+ this.CONSUME3(S), this.SUBRULE5(this.term, { LABEL: "secondTerm" });
900
+ }), this.CONSUME2(dt);
901
+ }
902
+ }
903
+ ]);
904
+ });
905
+ // GeneralAtom := tableName(term, ...)
906
+ generalAtom = this.RULE("generalAtom", () => {
907
+ this.OR([{ ALT: () => this.CONSUME(tt) }, { ALT: () => this.CONSUME(ft) }]), this.CONSUME(L), this.SUBRULE(this.term), this.MANY(() => {
908
+ this.CONSUME(S), this.SUBRULE2(this.term);
909
+ }), this.CONSUME(U);
910
+ });
911
+ // Term := Variable | IRI | Literal | BlankNode
912
+ term = this.RULE("term", () => {
913
+ this.OR([
914
+ { ALT: () => this.CONSUME(N) },
915
+ { ALT: () => this.SUBRULE(this.iri) },
916
+ { ALT: () => this.SUBRULE(this.literal) },
917
+ { ALT: () => this.CONSUME(J) }
918
+ ]);
919
+ });
920
+ // IRI := IRI_REF | PrefixedName | DefaultNsIRI | InternalFunction
921
+ iri = this.RULE("iri", () => {
922
+ this.OR([
923
+ { ALT: () => this.CONSUME(ge) },
924
+ { ALT: () => this.CONSUME(me) },
925
+ { ALT: () => this.CONSUME(it) },
926
+ { ALT: () => this.CONSUME(Le) },
927
+ { ALT: () => this.CONSUME(wt) },
928
+ { ALT: () => this.CONSUME(tt) }
929
+ ]);
930
+ });
931
+ // Literal := NumericLiteral | BooleanLiteral | StringLiteral
932
+ literal = this.RULE("literal", () => {
933
+ this.OR([
934
+ { ALT: () => this.SUBRULE(this.numericLiteral) },
935
+ { ALT: () => this.SUBRULE(this.booleanLiteral) },
936
+ { ALT: () => this.SUBRULE(this.stringLiteral) }
937
+ ]);
938
+ });
939
+ numericLiteral = this.RULE("numericLiteral", () => {
940
+ this.OR([
941
+ { ALT: () => this.CONSUME(Ae) },
942
+ { ALT: () => this.CONSUME(we) },
943
+ { ALT: () => this.CONSUME(Ue) }
944
+ ]);
945
+ });
946
+ booleanLiteral = this.RULE("booleanLiteral", () => {
947
+ this.OR([{ ALT: () => this.CONSUME(ie) }, { ALT: () => this.CONSUME(ne) }]);
948
+ });
949
+ stringLiteral = this.RULE("stringLiteral", () => {
950
+ this.OR([
951
+ { ALT: () => this.CONSUME(Te) },
952
+ { ALT: () => this.CONSUME(ft) }
953
+ ]), this.OPTION(() => {
954
+ this.OR2([
955
+ { ALT: () => this.CONSUME(Se) },
895
956
  {
896
957
  ALT: () => {
897
- this.SUBRULE(this.iri, { LABEL: "predicateOrClass" }), this.CONSUME2(Et), this.SUBRULE4(this.term, { LABEL: "firstTerm" }), this.OPTION(() => {
898
- this.CONSUME3(N), this.SUBRULE5(this.term, { LABEL: "secondTerm" });
899
- }), this.CONSUME2(ft);
958
+ this.CONSUME(Et), this.CONSUME2(Et), this.SUBRULE(this.iri);
900
959
  }
901
960
  }
902
961
  ]);
903
- }));
904
- // GeneralAtom := tableName(term, ...)
905
- d(this, "generalAtom", this.RULE("generalAtom", () => {
906
- this.OR([{ ALT: () => this.CONSUME(rt) }, { ALT: () => this.CONSUME(mt) }]), this.CONSUME(U), this.SUBRULE(this.term), this.MANY(() => {
907
- this.CONSUME(N), this.SUBRULE2(this.term);
908
- }), this.CONSUME(w);
909
- }));
910
- // Term := Variable | IRI | Literal | BlankNode
911
- d(this, "term", this.RULE("term", () => {
912
- this.OR([
913
- { ALT: () => this.CONSUME(b) },
914
- { ALT: () => this.SUBRULE(this.iri) },
915
- { ALT: () => this.SUBRULE(this.literal) },
916
- { ALT: () => this.CONSUME(et) }
917
- ]);
918
- }));
919
- // IRI := IRI_REF | PrefixedName | DefaultNsIRI | InternalFunction
920
- d(this, "iri", this.RULE("iri", () => {
921
- this.OR([
922
- { ALT: () => this.CONSUME(me) },
923
- { ALT: () => this.CONSUME(ye) },
924
- { ALT: () => this.CONSUME(st) },
925
- { ALT: () => this.CONSUME(Ue) },
926
- { ALT: () => this.CONSUME(Tt) },
927
- { ALT: () => this.CONSUME(rt) }
928
- ]);
929
- }));
930
- // Literal := NumericLiteral | BooleanLiteral | StringLiteral
931
- d(this, "literal", this.RULE("literal", () => {
932
- this.OR([
933
- { ALT: () => this.SUBRULE(this.numericLiteral) },
934
- { ALT: () => this.SUBRULE(this.booleanLiteral) },
935
- { ALT: () => this.SUBRULE(this.stringLiteral) }
936
- ]);
937
- }));
938
- d(this, "numericLiteral", this.RULE("numericLiteral", () => {
939
- this.OR([
940
- { ALT: () => this.CONSUME(Te) },
941
- { ALT: () => this.CONSUME(Ae) },
942
- { ALT: () => this.CONSUME(we) }
943
- ]);
944
- }));
945
- d(this, "booleanLiteral", this.RULE("booleanLiteral", () => {
946
- this.OR([{ ALT: () => this.CONSUME(ne) }, { ALT: () => this.CONSUME(se) }]);
947
- }));
948
- d(this, "stringLiteral", this.RULE("stringLiteral", () => {
962
+ });
963
+ });
964
+ // Negation := 'NOT' ExistsClause? (Atom | '(' BodyFormulaList ')')
965
+ negation = this.RULE("negation", () => {
966
+ this.CONSUME(at), this.OPTION(() => {
967
+ this.SUBRULE(this.existsClause);
968
+ }), this.OR([
969
+ {
970
+ ALT: () => {
971
+ this.CONSUME(L), this.SUBRULE(this.bodyFormulaList), this.CONSUME(U);
972
+ }
973
+ },
974
+ { ALT: () => this.SUBRULE(this.tupleTableAtom) }
975
+ ]);
976
+ });
977
+ // ExistsClause := 'EXISTS' variable (',' variable)* 'IN'
978
+ existsClause = this.RULE("existsClause", () => {
979
+ this.CONSUME(kt), this.CONSUME(N), this.MANY(() => {
980
+ this.CONSUME(S), this.CONSUME2(N);
981
+ }), this.CONSUME(W);
982
+ });
983
+ // AtomList := Atom (',' Atom)*
984
+ atomList = this.RULE("atomList", () => {
985
+ this.SUBRULE(this.atom), this.MANY(() => {
986
+ this.CONSUME(S), this.SUBRULE2(this.atom);
987
+ });
988
+ });
989
+ // Atom := TupleTableAtom | FilterAtom | BindAtom
990
+ atom = this.RULE("atom", () => {
991
+ this.OR([
992
+ { ALT: () => this.SUBRULE(this.tupleTableAtom) },
993
+ { ALT: () => this.SUBRULE(this.filterAtom) },
994
+ { ALT: () => this.SUBRULE(this.bindAtom) }
995
+ ]);
996
+ });
997
+ // BodyFormulaList := BodyFormula (',' BodyFormula)*
998
+ bodyFormulaList = this.RULE("bodyFormulaList", () => {
999
+ this.SUBRULE(this.bodyFormula), this.MANY(() => {
1000
+ this.CONSUME(S), this.SUBRULE2(this.bodyFormula);
1001
+ });
1002
+ });
1003
+ // FilterAtom := 'FILTER' '(' Expression ')'
1004
+ filterAtom = this.RULE("filterAtom", () => {
1005
+ this.CONSUME($t), this.CONSUME(L), this.SUBRULE(this.expression), this.CONSUME(U);
1006
+ });
1007
+ // BindAtom := 'BIND' '(' Expression 'AS' variable ')'
1008
+ bindAtom = this.RULE("bindAtom", () => {
1009
+ this.CONSUME(Q), this.CONSUME(L), this.SUBRULE(this.expression), this.CONSUME(z), this.CONSUME(N), this.CONSUME(U);
1010
+ });
1011
+ // SkolemAtom := 'SKOLEM' '(' ArgumentList ')'
1012
+ skolemAtom = this.RULE("skolemAtom", () => {
1013
+ this.CONSUME(lt), this.CONSUME(L), this.SUBRULE(this.argumentList), this.CONSUME(U);
1014
+ });
1015
+ // Aggregate := 'AGGREGATE' '(' AtomList OnClause? AggregateBind* ')'
1016
+ aggregate = this.RULE("aggregate", () => {
1017
+ this.CONSUME(Lt), this.CONSUME(L), this.SUBRULE(this.atomList), this.OPTION(() => {
1018
+ this.SUBRULE(this.onClause);
1019
+ }), this.MANY(() => {
1020
+ this.SUBRULE(this.aggregateBind);
1021
+ }), this.CONSUME(U);
1022
+ });
1023
+ // OnClause := 'ON' variable+
1024
+ onClause = this.RULE("onClause", () => {
1025
+ this.CONSUME(Ut), this.CONSUME(N), this.MANY(() => {
1026
+ this.CONSUME2(N);
1027
+ });
1028
+ });
1029
+ // AggregateBind := ('BIND' AggregateFunction | AggregateFunction) 'AS' variable
1030
+ aggregateBind = this.RULE("aggregateBind", () => {
1031
+ this.OPTION(() => {
1032
+ this.CONSUME(Q);
1033
+ }), this.SUBRULE(this.aggregateFunction), this.CONSUME(z), this.CONSUME(N);
1034
+ });
1035
+ // AggregateFunction := AggregateFunction1 | AggregateFunction2
1036
+ aggregateFunction = this.RULE("aggregateFunction", () => {
1037
+ this.OR([
1038
+ { ALT: () => this.SUBRULE(this.aggregateFunction1) },
1039
+ { ALT: () => this.SUBRULE(this.aggregateFunction2) }
1040
+ ]);
1041
+ });
1042
+ // AggregateFunction1 := (SUM | MUL | AVG | MIN | COUNT_MIN | MAX | COUNT_MAX | COUNT) '(' DISTINCT? (STAR | Expression) ')'
1043
+ aggregateFunction1 = this.RULE("aggregateFunction1", () => {
1044
+ this.OR([
1045
+ { ALT: () => this.CONSUME(Xt) },
1046
+ { ALT: () => this.CONSUME(Ht) },
1047
+ { ALT: () => this.CONSUME(Dt) },
1048
+ { ALT: () => this.CONSUME(Gt) },
1049
+ { ALT: () => this.CONSUME(_t) },
1050
+ { ALT: () => this.CONSUME(Vt) },
1051
+ { ALT: () => this.CONSUME(jt) },
1052
+ { ALT: () => this.CONSUME(qt) }
1053
+ ]), this.CONSUME(L), this.OPTION(() => {
1054
+ this.CONSUME(ot);
1055
+ }), this.OR2([{ ALT: () => this.CONSUME(pt) }, { ALT: () => this.SUBRULE(this.expression) }]), this.CONSUME(U);
1056
+ });
1057
+ // AggregateFunction2 := (MIN_ARGMIN | MAX_ARGMIN | MIN_ARGMAX | MAX_ARGMAX) '(' DISTINCT? Expression ',' Expression ')'
1058
+ aggregateFunction2 = this.RULE("aggregateFunction2", () => {
1059
+ this.OR([
1060
+ { ALT: () => this.CONSUME(Qt) },
1061
+ { ALT: () => this.CONSUME(zt) },
1062
+ { ALT: () => this.CONSUME(Kt) },
1063
+ { ALT: () => this.CONSUME(Wt) }
1064
+ ]), this.CONSUME(L), this.OPTION(() => {
1065
+ this.CONSUME(ot);
1066
+ }), this.SUBRULE(this.expression, { LABEL: "firstExpr" }), this.CONSUME(S), this.SUBRULE2(this.expression, { LABEL: "secondExpr" }), this.CONSUME(U);
1067
+ });
1068
+ // Expression (simplified for now)
1069
+ expression = this.RULE("expression", () => {
1070
+ this.SUBRULE(this.conditionalOrExpression);
1071
+ });
1072
+ conditionalOrExpression = this.RULE("conditionalOrExpression", () => {
1073
+ this.SUBRULE(this.conditionalAndExpression), this.MANY(() => {
1074
+ this.CONSUME(he), this.SUBRULE2(this.conditionalAndExpression);
1075
+ });
1076
+ });
1077
+ conditionalAndExpression = this.RULE("conditionalAndExpression", () => {
1078
+ this.SUBRULE(this.relationalExpression), this.MANY(() => {
1079
+ this.CONSUME(pe), this.SUBRULE2(this.relationalExpression);
1080
+ });
1081
+ });
1082
+ relationalExpression = this.RULE("relationalExpression", () => {
1083
+ this.SUBRULE(this.additiveExpression), this.OPTION(() => {
949
1084
  this.OR([
950
- { ALT: () => this.CONSUME(Se) },
951
- { ALT: () => this.CONSUME(mt) }
952
- ]), this.OPTION(() => {
953
- this.OR2([
954
- { ALT: () => this.CONSUME(Ne) },
955
- {
956
- ALT: () => {
957
- this.CONSUME(gt), this.CONSUME2(gt), this.SUBRULE(this.iri);
958
- }
959
- }
960
- ]);
961
- });
962
- }));
963
- // Negation := 'NOT' ExistsClause? (Atom | '(' BodyFormulaList ')')
964
- d(this, "negation", this.RULE("negation", () => {
965
- this.CONSUME(lt), this.OPTION(() => {
966
- this.SUBRULE(this.existsClause);
967
- }), this.OR([
968
1085
  {
969
1086
  ALT: () => {
970
- this.CONSUME(U), this.SUBRULE(this.bodyFormulaList), this.CONSUME(w);
1087
+ this.OR2([
1088
+ { ALT: () => this.CONSUME(se) },
1089
+ { ALT: () => this.CONSUME(ae) },
1090
+ { ALT: () => this.CONSUME(oe) },
1091
+ { ALT: () => this.CONSUME(ue) },
1092
+ { ALT: () => this.CONSUME(le) },
1093
+ { ALT: () => this.CONSUME(ce) }
1094
+ ]), this.SUBRULE2(this.additiveExpression);
971
1095
  }
972
1096
  },
973
- { ALT: () => this.SUBRULE(this.tupleTableAtom) }
974
- ]);
975
- }));
976
- // ExistsClause := 'EXISTS' variable (',' variable)* 'IN'
977
- d(this, "existsClause", this.RULE("existsClause", () => {
978
- this.CONSUME($t), this.CONSUME(b), this.MANY(() => {
979
- this.CONSUME(N), this.CONSUME2(b);
980
- }), this.CONSUME(Z);
981
- }));
982
- // AtomList := Atom (',' Atom)*
983
- d(this, "atomList", this.RULE("atomList", () => {
984
- this.SUBRULE(this.atom), this.MANY(() => {
985
- this.CONSUME(N), this.SUBRULE2(this.atom);
986
- });
987
- }));
988
- // Atom := TupleTableAtom | FilterAtom | BindAtom
989
- d(this, "atom", this.RULE("atom", () => {
990
- this.OR([
991
- { ALT: () => this.SUBRULE(this.tupleTableAtom) },
992
- { ALT: () => this.SUBRULE(this.filterAtom) },
993
- { ALT: () => this.SUBRULE(this.bindAtom) }
994
- ]);
995
- }));
996
- // BodyFormulaList := BodyFormula (',' BodyFormula)*
997
- d(this, "bodyFormulaList", this.RULE("bodyFormulaList", () => {
998
- this.SUBRULE(this.bodyFormula), this.MANY(() => {
999
- this.CONSUME(N), this.SUBRULE2(this.bodyFormula);
1000
- });
1001
- }));
1002
- // FilterAtom := 'FILTER' '(' Expression ')'
1003
- d(this, "filterAtom", this.RULE("filterAtom", () => {
1004
- this.CONSUME(Dt), this.CONSUME(U), this.SUBRULE(this.expression), this.CONSUME(w);
1005
- }));
1006
- // BindAtom := 'BIND' '(' Expression 'AS' variable ')'
1007
- d(this, "bindAtom", this.RULE("bindAtom", () => {
1008
- this.CONSUME(z), this.CONSUME(U), this.SUBRULE(this.expression), this.CONSUME(K), this.CONSUME(b), this.CONSUME(w);
1009
- }));
1010
- // SkolemAtom := 'SKOLEM' '(' ArgumentList ')'
1011
- d(this, "skolemAtom", this.RULE("skolemAtom", () => {
1012
- this.CONSUME(ct), this.CONSUME(U), this.SUBRULE(this.argumentList), this.CONSUME(w);
1013
- }));
1014
- // Aggregate := 'AGGREGATE' '(' AtomList OnClause? AggregateBind* ')'
1015
- d(this, "aggregate", this.RULE("aggregate", () => {
1016
- this.CONSUME(wt), this.CONSUME(U), this.SUBRULE(this.atomList), this.OPTION(() => {
1017
- this.SUBRULE(this.onClause);
1018
- }), this.MANY(() => {
1019
- this.SUBRULE(this.aggregateBind);
1020
- }), this.CONSUME(w);
1021
- }));
1022
- // OnClause := 'ON' variable+
1023
- d(this, "onClause", this.RULE("onClause", () => {
1024
- this.CONSUME(At), this.CONSUME(b), this.MANY(() => {
1025
- this.CONSUME2(b);
1026
- });
1027
- }));
1028
- // AggregateBind := ('BIND' AggregateFunction | AggregateFunction) 'AS' variable
1029
- d(this, "aggregateBind", this.RULE("aggregateBind", () => {
1030
- this.OPTION(() => {
1031
- this.CONSUME(z);
1032
- }), this.SUBRULE(this.aggregateFunction), this.CONSUME(K), this.CONSUME(b);
1033
- }));
1034
- // AggregateFunction := AggregateFunction1 | AggregateFunction2
1035
- d(this, "aggregateFunction", this.RULE("aggregateFunction", () => {
1036
- this.OR([
1037
- { ALT: () => this.SUBRULE(this.aggregateFunction1) },
1038
- { ALT: () => this.SUBRULE(this.aggregateFunction2) }
1039
- ]);
1040
- }));
1041
- // AggregateFunction1 := (SUM | MUL | AVG | MIN | COUNT_MIN | MAX | COUNT_MAX | COUNT) '(' DISTINCT? (STAR | Expression) ')'
1042
- d(this, "aggregateFunction1", this.RULE("aggregateFunction1", () => {
1043
- this.OR([
1044
- { ALT: () => this.CONSUME(Ht) },
1045
- { ALT: () => this.CONSUME(Qt) },
1046
- { ALT: () => this.CONSUME(Gt) },
1047
- { ALT: () => this.CONSUME(_t) },
1048
- { ALT: () => this.CONSUME(Vt) },
1049
- { ALT: () => this.CONSUME(jt) },
1050
- { ALT: () => this.CONSUME(qt) },
1051
- { ALT: () => this.CONSUME(Xt) }
1052
- ]), this.CONSUME(U), this.OPTION(() => {
1053
- this.CONSUME(ut);
1054
- }), this.OR2([{ ALT: () => this.CONSUME(dt) }, { ALT: () => this.SUBRULE(this.expression) }]), this.CONSUME(w);
1055
- }));
1056
- // AggregateFunction2 := (MIN_ARGMIN | MAX_ARGMIN | MIN_ARGMAX | MAX_ARGMAX) '(' DISTINCT? Expression ',' Expression ')'
1057
- d(this, "aggregateFunction2", this.RULE("aggregateFunction2", () => {
1058
- this.OR([
1059
- { ALT: () => this.CONSUME(zt) },
1060
- { ALT: () => this.CONSUME(Kt) },
1061
- { ALT: () => this.CONSUME(Wt) },
1062
- { ALT: () => this.CONSUME(Yt) }
1063
- ]), this.CONSUME(U), this.OPTION(() => {
1064
- this.CONSUME(ut);
1065
- }), this.SUBRULE(this.expression, { LABEL: "firstExpr" }), this.CONSUME(N), this.SUBRULE2(this.expression, { LABEL: "secondExpr" }), this.CONSUME(w);
1066
- }));
1067
- // Expression (simplified for now)
1068
- d(this, "expression", this.RULE("expression", () => {
1069
- this.SUBRULE(this.conditionalOrExpression);
1070
- }));
1071
- d(this, "conditionalOrExpression", this.RULE("conditionalOrExpression", () => {
1072
- this.SUBRULE(this.conditionalAndExpression), this.MANY(() => {
1073
- this.CONSUME(de), this.SUBRULE2(this.conditionalAndExpression);
1074
- });
1075
- }));
1076
- d(this, "conditionalAndExpression", this.RULE("conditionalAndExpression", () => {
1077
- this.SUBRULE(this.relationalExpression), this.MANY(() => {
1078
- this.CONSUME(he), this.SUBRULE2(this.relationalExpression);
1079
- });
1080
- }));
1081
- d(this, "relationalExpression", this.RULE("relationalExpression", () => {
1082
- this.SUBRULE(this.additiveExpression), this.OPTION(() => {
1083
- this.OR([
1084
- {
1085
- ALT: () => {
1086
- this.OR2([
1087
- { ALT: () => this.CONSUME(ae) },
1088
- { ALT: () => this.CONSUME(oe) },
1089
- { ALT: () => this.CONSUME(le) },
1090
- { ALT: () => this.CONSUME(ce) },
1091
- { ALT: () => this.CONSUME(ue) },
1092
- { ALT: () => this.CONSUME(pe) }
1093
- ]), this.SUBRULE2(this.additiveExpression);
1094
- }
1095
- },
1096
- // Handle IN
1097
- {
1098
- ALT: () => {
1099
- this.CONSUME(Z), this.CONSUME2(U), this.SUBRULE(this.argumentList), this.CONSUME3(w);
1100
- }
1101
- },
1102
- // Handle NOT IN
1103
- {
1104
- ALT: () => {
1105
- this.CONSUME(lt), this.CONSUME2(Z), this.CONSUME4(U), this.SUBRULE2(this.argumentList), this.CONSUME5(w);
1106
- }
1097
+ // Handle IN
1098
+ {
1099
+ ALT: () => {
1100
+ this.CONSUME(W), this.CONSUME2(L), this.SUBRULE(this.argumentList), this.CONSUME3(U);
1107
1101
  }
1108
- ]);
1109
- });
1110
- }));
1111
- d(this, "additiveExpression", this.RULE("additiveExpression", () => {
1112
- this.SUBRULE(this.multiplicativeExpression), this.MANY(() => {
1113
- this.OR([{ ALT: () => this.CONSUME(pt) }, { ALT: () => this.CONSUME(ht) }]), this.SUBRULE2(this.multiplicativeExpression);
1114
- });
1115
- }));
1116
- d(this, "multiplicativeExpression", this.RULE("multiplicativeExpression", () => {
1117
- this.SUBRULE(this.unaryExpression), this.MANY(() => {
1118
- this.OR([{ ALT: () => this.CONSUME(dt) }, { ALT: () => this.CONSUME(Ee) }]), this.SUBRULE2(this.unaryExpression);
1119
- });
1120
- }));
1121
- d(this, "unaryExpression", this.RULE("unaryExpression", () => {
1122
- this.OPTION(() => {
1123
- this.OR([
1124
- { ALT: () => this.CONSUME(fe) },
1125
- { ALT: () => this.CONSUME(pt) },
1126
- { ALT: () => this.CONSUME(ht) }
1127
- ]);
1128
- }), this.SUBRULE(this.primaryExpression);
1129
- }));
1130
- // Function calls
1131
- d(this, "functionCall", this.RULE("functionCall", () => {
1132
- this.OR([
1133
- // Built-in functions
1134
- { ALT: () => this.SUBRULE(this.concatFunction) },
1135
- { ALT: () => this.SUBRULE(this.strFunction) },
1136
- { ALT: () => this.SUBRULE(this.ifFunction) },
1137
- { ALT: () => this.SUBRULE(this.iriFunction) },
1138
- { ALT: () => this.SUBRULE(this.skolemFunction) },
1139
- { ALT: () => this.SUBRULE(this.roundFunction) },
1140
- { ALT: () => this.SUBRULE(this.regexFunction) },
1141
- // Generic function call (IRI followed by arguments)
1102
+ },
1103
+ // Handle NOT IN
1142
1104
  {
1143
1105
  ALT: () => {
1144
- this.SUBRULE(this.iri), this.CONSUME(U), this.OPTION(() => {
1145
- this.SUBRULE(this.argumentList);
1146
- }), this.CONSUME(w);
1106
+ this.CONSUME(at), this.CONSUME2(W), this.CONSUME4(L), this.SUBRULE2(this.argumentList), this.CONSUME5(U);
1147
1107
  }
1148
1108
  }
1149
1109
  ]);
1150
- }));
1151
- // CONCAT function
1152
- d(this, "concatFunction", this.RULE("concatFunction", () => {
1153
- this.CONSUME(Zt), this.CONSUME(U), this.SUBRULE(this.argumentList), this.CONSUME(w);
1154
- }));
1155
- // STR function
1156
- d(this, "strFunction", this.RULE("strFunction", () => {
1157
- this.CONSUME(Jt), this.CONSUME(U), this.SUBRULE(this.expression), this.CONSUME(w);
1158
- }));
1159
- // IF function
1160
- d(this, "ifFunction", this.RULE("ifFunction", () => {
1161
- this.CONSUME(te), this.CONSUME(U), this.SUBRULE(this.expression, { LABEL: "condition" }), this.CONSUME(N), this.SUBRULE2(this.expression, { LABEL: "thenExpr" }), this.CONSUME2(N), this.SUBRULE3(this.expression, { LABEL: "elseExpr" }), this.CONSUME(w);
1162
- }));
1163
- // IRI function
1164
- d(this, "iriFunction", this.RULE("iriFunction", () => {
1165
- this.CONSUME(ee), this.CONSUME(U), this.SUBRULE(this.expression, { LABEL: "iriExpr" }), this.OPTION(() => {
1166
- this.CONSUME(N), this.SUBRULE2(this.expression, { LABEL: "baseIri" });
1167
- }), this.CONSUME(w);
1168
- }));
1169
- // SKOLEM function
1170
- d(this, "skolemFunction", this.RULE("skolemFunction", () => {
1171
- this.CONSUME(ct), this.CONSUME(U), this.SUBRULE(this.argumentList), this.CONSUME(w);
1172
- }));
1173
- // ROUND function
1174
- d(this, "roundFunction", this.RULE("roundFunction", () => {
1175
- this.CONSUME(re), this.CONSUME(U), this.SUBRULE(this.expression), this.CONSUME(w);
1176
- }));
1177
- // REGEX function
1178
- d(this, "regexFunction", this.RULE("regexFunction", () => {
1179
- this.CONSUME(ie), this.CONSUME(U), this.SUBRULE(this.expression, { LABEL: "textExpr" }), this.CONSUME(N), this.SUBRULE2(this.expression, { LABEL: "patternExpr" }), this.OPTION(() => {
1180
- this.CONSUME2(N), this.SUBRULE3(this.expression, { LABEL: "flagsExpr" });
1181
- }), this.CONSUME(w);
1182
- }));
1183
- // Argument list
1184
- d(this, "argumentList", this.RULE("argumentList", () => {
1185
- this.SUBRULE(this.expression), this.MANY(() => {
1186
- this.CONSUME(N), this.SUBRULE2(this.expression);
1187
- });
1188
- }));
1189
- d(this, "primaryExpression", this.RULE("primaryExpression", () => {
1110
+ });
1111
+ });
1112
+ additiveExpression = this.RULE("additiveExpression", () => {
1113
+ this.SUBRULE(this.multiplicativeExpression), this.MANY(() => {
1114
+ this.OR([{ ALT: () => this.CONSUME(ut) }, { ALT: () => this.CONSUME(ct) }]), this.SUBRULE2(this.multiplicativeExpression);
1115
+ });
1116
+ });
1117
+ multiplicativeExpression = this.RULE("multiplicativeExpression", () => {
1118
+ this.SUBRULE(this.unaryExpression), this.MANY(() => {
1119
+ this.OR([{ ALT: () => this.CONSUME(pt) }, { ALT: () => this.CONSUME(de) }]), this.SUBRULE2(this.unaryExpression);
1120
+ });
1121
+ });
1122
+ unaryExpression = this.RULE("unaryExpression", () => {
1123
+ this.OPTION(() => {
1190
1124
  this.OR([
1191
- {
1192
- ALT: () => {
1193
- this.CONSUME(U), this.SUBRULE(this.expression), this.CONSUME(w);
1194
- }
1195
- },
1196
- { ALT: () => this.SUBRULE(this.functionCall) },
1197
- { ALT: () => this.SUBRULE(this.literal) },
1198
- { ALT: () => this.CONSUME(b) },
1199
- { ALT: () => this.SUBRULE(this.iri) }
1125
+ { ALT: () => this.CONSUME(Ee) },
1126
+ { ALT: () => this.CONSUME(ut) },
1127
+ { ALT: () => this.CONSUME(ct) }
1200
1128
  ]);
1201
- }));
1202
- const { selfAnalysis: i = !0 } = r;
1203
- i && this.performSelfAnalysis();
1204
- }
1205
- // Chevrotain only reports leftover input for the rule it was entered on, so
1206
- // callers entering on a nested rule have to reject trailing tokens themselves.
1207
- get atEndOfInput() {
1208
- return this.LA(1).tokenType === Fr;
1209
- }
1129
+ }), this.SUBRULE(this.primaryExpression);
1130
+ });
1131
+ // Function calls
1132
+ functionCall = this.RULE("functionCall", () => {
1133
+ this.OR([
1134
+ // Built-in functions
1135
+ { ALT: () => this.SUBRULE(this.concatFunction) },
1136
+ { ALT: () => this.SUBRULE(this.strFunction) },
1137
+ { ALT: () => this.SUBRULE(this.ifFunction) },
1138
+ { ALT: () => this.SUBRULE(this.iriFunction) },
1139
+ { ALT: () => this.SUBRULE(this.skolemFunction) },
1140
+ { ALT: () => this.SUBRULE(this.roundFunction) },
1141
+ { ALT: () => this.SUBRULE(this.regexFunction) },
1142
+ // Generic function call (IRI followed by arguments)
1143
+ {
1144
+ ALT: () => {
1145
+ this.SUBRULE(this.iri), this.CONSUME(L), this.OPTION(() => {
1146
+ this.SUBRULE(this.argumentList);
1147
+ }), this.CONSUME(U);
1148
+ }
1149
+ }
1150
+ ]);
1151
+ });
1152
+ // CONCAT function
1153
+ concatFunction = this.RULE("concatFunction", () => {
1154
+ this.CONSUME(Yt), this.CONSUME(L), this.SUBRULE(this.argumentList), this.CONSUME(U);
1155
+ });
1156
+ // STR function
1157
+ strFunction = this.RULE("strFunction", () => {
1158
+ this.CONSUME(Zt), this.CONSUME(L), this.SUBRULE(this.expression), this.CONSUME(U);
1159
+ });
1160
+ // IF function
1161
+ ifFunction = this.RULE("ifFunction", () => {
1162
+ this.CONSUME(Jt), this.CONSUME(L), this.SUBRULE(this.expression, { LABEL: "condition" }), this.CONSUME(S), this.SUBRULE2(this.expression, { LABEL: "thenExpr" }), this.CONSUME2(S), this.SUBRULE3(this.expression, { LABEL: "elseExpr" }), this.CONSUME(U);
1163
+ });
1164
+ // IRI function
1165
+ iriFunction = this.RULE("iriFunction", () => {
1166
+ this.CONSUME(te), this.CONSUME(L), this.SUBRULE(this.expression, { LABEL: "iriExpr" }), this.OPTION(() => {
1167
+ this.CONSUME(S), this.SUBRULE2(this.expression, { LABEL: "baseIri" });
1168
+ }), this.CONSUME(U);
1169
+ });
1170
+ // SKOLEM function
1171
+ skolemFunction = this.RULE("skolemFunction", () => {
1172
+ this.CONSUME(lt), this.CONSUME(L), this.SUBRULE(this.argumentList), this.CONSUME(U);
1173
+ });
1174
+ // ROUND function
1175
+ roundFunction = this.RULE("roundFunction", () => {
1176
+ this.CONSUME(ee), this.CONSUME(L), this.SUBRULE(this.expression), this.CONSUME(U);
1177
+ });
1178
+ // REGEX function
1179
+ regexFunction = this.RULE("regexFunction", () => {
1180
+ this.CONSUME(re), this.CONSUME(L), this.SUBRULE(this.expression, { LABEL: "textExpr" }), this.CONSUME(S), this.SUBRULE2(this.expression, { LABEL: "patternExpr" }), this.OPTION(() => {
1181
+ this.CONSUME2(S), this.SUBRULE3(this.expression, { LABEL: "flagsExpr" });
1182
+ }), this.CONSUME(U);
1183
+ });
1184
+ // Argument list
1185
+ argumentList = this.RULE("argumentList", () => {
1186
+ this.SUBRULE(this.expression), this.MANY(() => {
1187
+ this.CONSUME(S), this.SUBRULE2(this.expression);
1188
+ });
1189
+ });
1190
+ primaryExpression = this.RULE("primaryExpression", () => {
1191
+ this.OR([
1192
+ {
1193
+ ALT: () => {
1194
+ this.CONSUME(L), this.SUBRULE(this.expression), this.CONSUME(U);
1195
+ }
1196
+ },
1197
+ { ALT: () => this.SUBRULE(this.functionCall) },
1198
+ { ALT: () => this.SUBRULE(this.literal) },
1199
+ { ALT: () => this.CONSUME(N) },
1200
+ { ALT: () => this.SUBRULE(this.iri) }
1201
+ ]);
1202
+ });
1210
1203
  }
1211
- let xi;
1212
- function ve() {
1213
- return xi ?? (xi = new xe());
1204
+ let Ri;
1205
+ function xe() {
1206
+ return Ri ??= new Oe();
1214
1207
  }
1215
- function ur(e, t) {
1216
- const r = be(t);
1208
+ function lr(e, t) {
1209
+ const r = Re(t);
1217
1210
  if (r) throw new Error(r.message);
1218
- const i = Re(t);
1211
+ const i = Ne(t);
1219
1212
  if (i.errors.length > 0)
1220
- throw new Error(`Lexer errors: ${i.errors.map((o) => o.message).join(", ")}`);
1221
- const s = Oe(t, i.tokens);
1213
+ throw new Error(`Lexer errors: ${i.errors.map((a) => a.message).join(", ")}`);
1214
+ const s = be(t, i.tokens);
1222
1215
  if (s) throw new Error(s.message);
1223
1216
  e.input = i.tokens;
1224
- const a = e.rule();
1217
+ const o = e.rule();
1225
1218
  if (e.errors.length > 0)
1226
- throw new Error(`Parser errors: ${e.errors.map((o) => o.message).join(", ")}`);
1227
- return a;
1219
+ throw new Error(`Parser errors: ${e.errors.map((a) => a.message).join(", ")}`);
1220
+ return o;
1228
1221
  }
1229
- function cr(e) {
1230
- return ur(ve(), e);
1222
+ function ur(e) {
1223
+ return lr(xe(), e);
1231
1224
  }
1232
- function ys(e) {
1225
+ function Es(e) {
1233
1226
  try {
1234
- return cr(e), { valid: !0 };
1227
+ return ur(e), { valid: !0 };
1235
1228
  } catch (t) {
1236
1229
  return {
1237
1230
  valid: !1,
@@ -1239,137 +1232,136 @@ function ys(e) {
1239
1232
  };
1240
1233
  }
1241
1234
  }
1242
- class vi extends xe {
1235
+ class bi extends Oe {
1243
1236
  constructor() {
1244
- super({ selfAnalysis: !1 });
1245
- // `term` cannot be used directly as the alternative to a variable: its own
1246
- // first alternative is VARIABLE, which would make the enclosing OR ambiguous.
1247
- d(this, "groundedAsTarget", this.RULE("groundedAsTarget", () => {
1248
- this.OR([
1249
- { ALT: () => this.SUBRULE(this.iri) },
1250
- { ALT: () => this.SUBRULE(this.literal) },
1251
- { ALT: () => this.CONSUME(et) }
1252
- ]);
1253
- }));
1254
- // OnClause := 'ON' (variable | GroundedAsTarget)*
1255
- // Grounding substitutes the grouping variables as well, and an aggregate
1256
- // over the whole store comes back with a bare 'ON', so both are accepted.
1257
- d(this, "expandedOnClause", this.OVERRIDE_RULE("onClause", () => {
1258
- this.CONSUME(At), this.MANY(() => {
1259
- this.variableOrGroundedTarget();
1260
- });
1261
- }));
1262
- // BindAtom := 'BIND' '(' Expression 'AS' (variable | GroundedAsTarget) ')'
1263
- d(this, "expandedBindAtom", this.OVERRIDE_RULE("bindAtom", () => {
1264
- this.CONSUME(z), this.CONSUME(U), this.SUBRULE(this.expression), this.CONSUME(K), this.variableOrGroundedTarget(), this.CONSUME(w);
1265
- }));
1266
- // Aggregate := 'AGGREGATE' '(' AtomList? OnClause? AggregateBind* ')'
1267
- // atomList is optional so engine-emitted atom-free forms parse; empty
1268
- // `AGGREGATE()` / `AGGREGATE(ON ?x)` are rejected after parse (visitor).
1269
- d(this, "expandedAggregate", this.OVERRIDE_RULE("aggregate", () => {
1270
- this.CONSUME(wt), this.CONSUME(U), this.OPTION(() => {
1271
- this.SUBRULE(this.atomList);
1272
- }), this.OPTION2(() => {
1273
- this.SUBRULE(this.onClause);
1274
- }), this.MANY(() => {
1275
- this.SUBRULE(this.aggregateBind);
1276
- }), this.CONSUME(w);
1277
- }));
1278
- // AggregateBind := 'BIND'? (AggregateFunction | Expression) 'AS' (variable | GroundedAsTarget)
1279
- d(this, "expandedAggregateBind", this.OVERRIDE_RULE("aggregateBind", () => {
1280
- this.OPTION(() => {
1281
- this.CONSUME(z);
1282
- }), this.OR2([{ ALT: () => this.SUBRULE(this.aggregateFunction) }, { ALT: () => this.SUBRULE(this.expression) }]), this.CONSUME(K), this.variableOrGroundedTarget();
1283
- }));
1284
- // Grounding substitutes SKOLEM outputs into expression positions as blank
1285
- // nodes, so the expanded grammar accepts them as primary expressions.
1286
- d(this, "expandedPrimaryExpression", this.OVERRIDE_RULE("primaryExpression", () => {
1287
- this.OR([
1288
- {
1289
- ALT: () => {
1290
- this.CONSUME(U), this.SUBRULE(this.expression), this.CONSUME(w);
1291
- }
1292
- },
1293
- { ALT: () => this.SUBRULE(this.functionCall) },
1294
- { ALT: () => this.SUBRULE(this.literal) },
1295
- { ALT: () => this.CONSUME(b) },
1296
- { ALT: () => this.CONSUME(et) },
1297
- { ALT: () => this.SUBRULE(this.iri) }
1298
- ]);
1299
- }));
1300
- this.performSelfAnalysis();
1301
- }
1237
+ super({ selfAnalysis: !1 }), this.performSelfAnalysis();
1238
+ }
1239
+ // `term` cannot be used directly as the alternative to a variable: its own
1240
+ // first alternative is VARIABLE, which would make the enclosing OR ambiguous.
1241
+ groundedAsTarget = this.RULE("groundedAsTarget", () => {
1242
+ this.OR([
1243
+ { ALT: () => this.SUBRULE(this.iri) },
1244
+ { ALT: () => this.SUBRULE(this.literal) },
1245
+ { ALT: () => this.CONSUME(J) }
1246
+ ]);
1247
+ });
1302
1248
  // Each rule below records this once, so the default occurrence index is unambiguous.
1303
1249
  variableOrGroundedTarget() {
1304
- this.OR([{ ALT: () => this.CONSUME(b) }, { ALT: () => this.SUBRULE(this.groundedAsTarget) }]);
1305
- }
1250
+ this.OR([{ ALT: () => this.CONSUME(N) }, { ALT: () => this.SUBRULE(this.groundedAsTarget) }]);
1251
+ }
1252
+ // OnClause := 'ON' (variable | GroundedAsTarget)*
1253
+ // Grounding substitutes the grouping variables as well, and an aggregate
1254
+ // over the whole store comes back with a bare 'ON', so both are accepted.
1255
+ expandedOnClause = this.OVERRIDE_RULE("onClause", () => {
1256
+ this.CONSUME(Ut), this.MANY(() => {
1257
+ this.variableOrGroundedTarget();
1258
+ });
1259
+ });
1260
+ // BindAtom := 'BIND' '(' Expression 'AS' (variable | GroundedAsTarget) ')'
1261
+ expandedBindAtom = this.OVERRIDE_RULE("bindAtom", () => {
1262
+ this.CONSUME(Q), this.CONSUME(L), this.SUBRULE(this.expression), this.CONSUME(z), this.variableOrGroundedTarget(), this.CONSUME(U);
1263
+ });
1264
+ // Aggregate := 'AGGREGATE' '(' AtomList? OnClause? AggregateBind* ')'
1265
+ // atomList is optional so engine-emitted atom-free forms parse; empty
1266
+ // `AGGREGATE()` / `AGGREGATE(ON ?x)` are rejected after parse (visitor).
1267
+ expandedAggregate = this.OVERRIDE_RULE("aggregate", () => {
1268
+ this.CONSUME(Lt), this.CONSUME(L), this.OPTION(() => {
1269
+ this.SUBRULE(this.atomList);
1270
+ }), this.OPTION2(() => {
1271
+ this.SUBRULE(this.onClause);
1272
+ }), this.MANY(() => {
1273
+ this.SUBRULE(this.aggregateBind);
1274
+ }), this.CONSUME(U);
1275
+ });
1276
+ // AggregateBind := 'BIND'? (AggregateFunction | Expression) 'AS' (variable | GroundedAsTarget)
1277
+ expandedAggregateBind = this.OVERRIDE_RULE("aggregateBind", () => {
1278
+ this.OPTION(() => {
1279
+ this.CONSUME(Q);
1280
+ }), this.OR2([{ ALT: () => this.SUBRULE(this.aggregateFunction) }, { ALT: () => this.SUBRULE(this.expression) }]), this.CONSUME(z), this.variableOrGroundedTarget();
1281
+ });
1282
+ // Grounding substitutes SKOLEM outputs into expression positions as blank
1283
+ // nodes, so the expanded grammar accepts them as primary expressions.
1284
+ expandedPrimaryExpression = this.OVERRIDE_RULE("primaryExpression", () => {
1285
+ this.OR([
1286
+ {
1287
+ ALT: () => {
1288
+ this.CONSUME(L), this.SUBRULE(this.expression), this.CONSUME(U);
1289
+ }
1290
+ },
1291
+ { ALT: () => this.SUBRULE(this.functionCall) },
1292
+ { ALT: () => this.SUBRULE(this.literal) },
1293
+ { ALT: () => this.CONSUME(N) },
1294
+ { ALT: () => this.CONSUME(J) },
1295
+ { ALT: () => this.SUBRULE(this.iri) }
1296
+ ]);
1297
+ });
1306
1298
  }
1307
- let Ci;
1308
- function Ii() {
1309
- return Ci ?? (Ci = new vi());
1299
+ let Oi;
1300
+ function xi() {
1301
+ return Oi ??= new bi();
1310
1302
  }
1311
- function Mi(e) {
1312
- return ur(Ii(), e);
1303
+ function vi(e) {
1304
+ return lr(xi(), e);
1313
1305
  }
1314
- function Bi(e) {
1315
- nr(e.body);
1316
- const t = e.body.filter((s) => s.type !== "negation"), r = Ye(e.body) ? t.filter(
1317
- (s) => p(s).with({ type: u.union("triple", "property", "class") }, () => !0).otherwise(() => !1)
1318
- ) : t, { query: i } = yi(r);
1306
+ function Ci(e) {
1307
+ ir(e.body);
1308
+ const t = e.body.filter((s) => s.type !== "negation"), r = We(e.body) ? t.filter(
1309
+ (s) => p(s).with({ type: l.union("triple", "property", "class") }, () => !0).otherwise(() => !1)
1310
+ ) : t, { query: i } = fi(r);
1319
1311
  return `${i}
1320
1312
  LIMIT 1`;
1321
1313
  }
1322
- function Ls(e) {
1323
- return p(e).with({ type: "variable" }, (t) => `?${t.name}`).with({ type: "iri", value: "a" }, () => "rdf:type").with({ type: "iri", prefixed: !0 }, (t) => t.value).with({ type: "iri", prefixed: !1 }, (t) => `<${t.value}>`).with({ type: "literal", language: u.string }, (t) => `"${t.value}"@${t.language}`).with({ type: "literal", datatype: u.string }, (t) => `"${t.value}"^^${rr(t.datatype)}`).with({ type: "literal" }, (t) => `"${t.value}"`).with({ type: "blank" }, (t) => `_:${t.label}`).exhaustive();
1314
+ function fs(e) {
1315
+ return p(e).with({ type: "variable" }, (t) => `?${t.name}`).with({ type: "iri", value: "a" }, () => "rdf:type").with({ type: "iri", prefixed: !0 }, (t) => t.value).with({ type: "iri", prefixed: !1 }, (t) => `<${t.value}>`).with({ type: "literal", language: l.string }, (t) => `"${t.value}"@${t.language}`).with({ type: "literal", datatype: l.string }, (t) => `"${t.value}"^^${er(t.datatype)}`).with({ type: "literal" }, (t) => `"${t.value}"`).with({ type: "blank" }, (t) => `_:${t.label}`).exhaustive();
1324
1316
  }
1325
- function Fi(e) {
1317
+ function Ii(e) {
1326
1318
  const t = e.head[0];
1327
1319
  return t ? p(t).with({ type: "triple" }, (r) => ({
1328
- subject: _(r.subject),
1329
- predicate: _(r.predicate),
1330
- object: _(r.object)
1320
+ subject: G(r.subject),
1321
+ predicate: G(r.predicate),
1322
+ object: G(r.object)
1331
1323
  })).with({ type: "property" }, (r) => ({
1332
- subject: _(r.subject),
1324
+ subject: G(r.subject),
1333
1325
  predicate: r.predicate,
1334
- object: _(r.object)
1326
+ object: G(r.object)
1335
1327
  })).with({ type: "class" }, (r) => ({
1336
- subject: _(r.instance),
1328
+ subject: G(r.instance),
1337
1329
  predicate: "rdf:type",
1338
1330
  object: r.className
1339
1331
  })).with({ type: "general" }, () => null).exhaustive() : null;
1340
1332
  }
1341
- function _(e) {
1342
- return p(e).with({ type: "variable" }, (t) => `:test_${t.name}`).with({ type: "iri", prefixed: !0 }, (t) => t.value).with({ type: "iri", prefixed: !1 }, (t) => `<${t.value}>`).with({ type: "literal", datatype: u.string }, (t) => `"${t.value}"^^${t.datatype}`).with({ type: "literal" }, (t) => `"${t.value}"`).with({ type: "blank" }, (t) => `_:${t.label}`).exhaustive();
1333
+ function G(e) {
1334
+ return p(e).with({ type: "variable" }, (t) => `:test_${t.name}`).with({ type: "iri", prefixed: !0 }, (t) => t.value).with({ type: "iri", prefixed: !1 }, (t) => `<${t.value}>`).with({ type: "literal", datatype: l.string }, (t) => `"${t.value}"^^${t.datatype}`).with({ type: "literal" }, (t) => `"${t.value}"`).with({ type: "blank" }, (t) => `_:${t.label}`).exhaustive();
1343
1335
  }
1344
- const Pi = q.object({
1345
- results: q.object({
1346
- bindings: q.array(q.unknown())
1336
+ const Mi = j.object({
1337
+ results: j.object({
1338
+ bindings: j.array(j.unknown())
1347
1339
  })
1348
- }), ki = q.object({
1349
- boolean: q.boolean()
1340
+ }), Bi = j.object({
1341
+ boolean: j.boolean()
1350
1342
  });
1351
- async function Us(e, t, r, i, s) {
1352
- if (Ye(e.body) && !s)
1343
+ async function gs(e, t, r, i, s) {
1344
+ if (We(e.body) && !s)
1353
1345
  return {
1354
1346
  verified: !1,
1355
1347
  error: "Rules containing SKOLEM require a concrete test triple for inference verification"
1356
1348
  };
1357
1349
  try {
1358
- const o = s || Fi(e);
1359
- if (!o)
1350
+ const a = s || Ii(e);
1351
+ if (!a)
1360
1352
  return {
1361
1353
  verified: !1,
1362
1354
  error: "Could not generate test triple from rule head"
1363
1355
  };
1364
- const l = Bi(e), E = await $i(l, t, r, i);
1365
- if (E)
1356
+ const u = Ci(e), f = await Fi(u, t, r, i);
1357
+ if (f)
1366
1358
  return {
1367
1359
  verified: !1,
1368
- testTriple: o,
1369
- candidateQuery: l,
1370
- error: E
1360
+ testTriple: a,
1361
+ candidateQuery: u,
1362
+ error: f
1371
1363
  };
1372
- const y = Di(o), S = new URL(`datastores/${r}/sparql`, t), h = await fetch(S.toString(), {
1364
+ const y = Pi(a), m = new URL(`datastores/${r}/sparql`, t), h = await fetch(m.toString(), {
1373
1365
  method: "POST",
1374
1366
  headers: {
1375
1367
  Authorization: i,
@@ -1381,22 +1373,22 @@ async function Us(e, t, r, i, s) {
1381
1373
  if (!h.ok)
1382
1374
  throw new Error(`SPARQL query failed: ${h.status} - ${await h.text()}`);
1383
1375
  return {
1384
- verified: ki.parse(await h.json()).boolean,
1385
- testTriple: o,
1376
+ verified: Bi.parse(await h.json()).boolean,
1377
+ testTriple: a,
1386
1378
  sparqlQuery: y,
1387
- candidateQuery: l
1379
+ candidateQuery: u
1388
1380
  };
1389
- } catch (o) {
1381
+ } catch (a) {
1390
1382
  return {
1391
1383
  verified: !1,
1392
1384
  testTriple: s,
1393
- error: o instanceof Error ? o.message : "Unknown error during inference verification"
1385
+ error: a instanceof Error ? a.message : "Unknown error during inference verification"
1394
1386
  };
1395
1387
  }
1396
1388
  }
1397
- async function $i(e, t, r, i) {
1389
+ async function Fi(e, t, r, i) {
1398
1390
  try {
1399
- const s = new URL(`datastores/${r}/sparql`, t), a = await fetch(s.toString(), {
1391
+ const s = new URL(`datastores/${r}/sparql`, t), o = await fetch(s.toString(), {
1400
1392
  method: "POST",
1401
1393
  headers: {
1402
1394
  Authorization: i,
@@ -1405,21 +1397,21 @@ async function $i(e, t, r, i) {
1405
1397
  },
1406
1398
  body: e
1407
1399
  });
1408
- if (!a.ok) {
1409
- let l = "";
1400
+ if (!o.ok) {
1401
+ let u = "";
1410
1402
  try {
1411
- l = await a.text();
1403
+ u = await o.text();
1412
1404
  } catch {
1413
1405
  }
1414
- const E = l || a.statusText;
1415
- return `Candidate query failed: ${a.status}${E ? ` - ${E}` : ""}`;
1406
+ const f = u || o.statusText;
1407
+ return `Candidate query failed: ${o.status}${f ? ` - ${f}` : ""}`;
1416
1408
  }
1417
- return Pi.parse(await a.json()).results.bindings.length > 0 ? void 0 : "No candidate variable bindings found for rule body - rule cannot fire";
1409
+ return Mi.parse(await o.json()).results.bindings.length > 0 ? void 0 : "No candidate variable bindings found for rule body - rule cannot fire";
1418
1410
  } catch (s) {
1419
1411
  return `Candidate query failed: ${s instanceof Error ? s.message : "Unknown error"}`;
1420
1412
  }
1421
1413
  }
1422
- function Di(e) {
1414
+ function Pi(e) {
1423
1415
  return `
1424
1416
  ASK WHERE {
1425
1417
  ${e.subject} ${e.predicate} ${e.object} .
@@ -1429,8 +1421,8 @@ function Di(e) {
1429
1421
  }
1430
1422
  `.trim();
1431
1423
  }
1432
- function ws(e) {
1433
- return p(e).with({ verified: !0 }, () => "Inference verification succeeded").with({ error: u.string }, (t) => t.error).with({ testTriple: u.nullish }, () => "Could not determine what triple should be inferred by this rule").with({ testTriple: u.not(u.nullish) }, (t) => {
1424
+ function ms(e) {
1425
+ return p(e).with({ verified: !0 }, () => "Inference verification succeeded").with({ error: l.string }, (t) => t.error).with({ testTriple: l.nullish }, () => "Could not determine what triple should be inferred by this rule").with({ testTriple: l.not(l.nullish) }, (t) => {
1434
1426
  const { subject: r, predicate: i, object: s } = t.testTriple;
1435
1427
  return `Expected inference was not produced:
1436
1428
 
@@ -1449,48 +1441,48 @@ To debug:
1449
1441
  4. Test rule components individually`;
1450
1442
  }).exhaustive();
1451
1443
  }
1452
- const Gi = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
1453
- function pr() {
1444
+ const ki = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
1445
+ function cr() {
1454
1446
  return { classes: [], predicates: [] };
1455
1447
  }
1456
- function yt(e) {
1448
+ function gt(e) {
1457
1449
  return {
1458
1450
  classes: e.flatMap(({ classes: t }) => t),
1459
1451
  predicates: e.flatMap(({ predicates: t }) => t)
1460
1452
  };
1461
1453
  }
1462
- function _i(e) {
1463
- return e === "a" || e === "rdf:type" || e === Gi;
1454
+ function $i(e) {
1455
+ return e === "a" || e === "rdf:type" || e === ki;
1464
1456
  }
1465
- function hr(e) {
1466
- const t = Ze(e);
1457
+ function pr(e) {
1458
+ const t = Ye(e);
1467
1459
  if (t)
1468
1460
  return {
1469
1461
  classes: [{ term: t.className, graph: t.graph }],
1470
1462
  predicates: []
1471
1463
  };
1472
- const r = Je(e);
1473
- return r && !_i(r.predicate) ? {
1464
+ const r = Ze(e);
1465
+ return r && !$i(r.predicate) ? {
1474
1466
  classes: [],
1475
1467
  predicates: [{ term: r.predicate, graph: r.graph }]
1476
- } : pr();
1468
+ } : cr();
1477
1469
  }
1478
- function It(e) {
1479
- return p(e).with({ type: u.union("triple", "property", "class", "general") }, hr).with(
1470
+ function Ct(e) {
1471
+ return p(e).with({ type: l.union("triple", "property", "class", "general") }, pr).with(
1480
1472
  { type: "negation" },
1481
- ({ formulas: t }) => yt(t.map(It))
1473
+ ({ formulas: t }) => gt(t.map(Ct))
1482
1474
  ).with(
1483
1475
  { type: "aggregate" },
1484
- ({ atoms: t }) => yt(t.map(It))
1485
- ).with({ type: u.union("filter", "bind", "skolem") }, pr).exhaustive();
1476
+ ({ atoms: t }) => gt(t.map(Ct))
1477
+ ).with({ type: l.union("filter", "bind", "skolem") }, cr).exhaustive();
1486
1478
  }
1487
- function Vi(e) {
1479
+ function Di(e) {
1488
1480
  return {
1489
- head: yt(e.head.map(hr)),
1490
- body: yt(e.body.map(It))
1481
+ head: gt(e.head.map(pr)),
1482
+ body: gt(e.body.map(Ct))
1491
1483
  };
1492
1484
  }
1493
- const ji = [
1485
+ const Gi = [
1494
1486
  n.expression,
1495
1487
  n.conditionalOrExpression,
1496
1488
  n.conditionalAndExpression,
@@ -1530,10 +1522,10 @@ const ji = [
1530
1522
  n.builtInUcase,
1531
1523
  n.builtInLcase,
1532
1524
  n.builtInEncode_for_uri
1533
- ], qi = {
1525
+ ], _i = {
1534
1526
  name: "builtInCall",
1535
1527
  impl: ({ OR: e, SUBRULE: t }) => () => e(n.builtInCallList(t).slice(0, -2))
1536
- }, Xi = P.create(ji).addMany(n.builtInContains, n.builtInStrstarts, n.builtInStrends, n.builtInStrbefore, n.builtInStrafter, n.builtInYear, n.builtInMonth, n.builtInDay, n.builtInHours, n.builtInMinutes, n.builtInSeconds, n.builtInTimezone, n.builtInTz, n.builtInNow, n.builtInUuid, n.builtInStruuid, n.builtInMd5, n.builtInSha1, n.builtInSha256, n.builtInSha384, n.builtInSha512, n.builtInCoalesce, n.builtInIf, n.builtInStrlang, n.builtInStrdt, n.builtInSameterm, n.builtInIsiri, n.builtInIsuri, n.builtInIsblank, n.builtInIsliteral, n.builtInIsnumeric, n.regexExpression, n.substringExpression, n.strReplaceExpression, n.aggregateCount, n.aggregateSum, n.aggregateMin, n.aggregateMax, n.aggregateAvg, n.aggregateSample, n.aggregateGroup_concat, n.aggregate, n.iri, n.prefixedName, n.argList, n.string).addRule(qi), Hi = [
1528
+ }, Vi = F.create(Gi).addMany(n.builtInContains, n.builtInStrstarts, n.builtInStrends, n.builtInStrbefore, n.builtInStrafter, n.builtInYear, n.builtInMonth, n.builtInDay, n.builtInHours, n.builtInMinutes, n.builtInSeconds, n.builtInTimezone, n.builtInTz, n.builtInNow, n.builtInUuid, n.builtInStruuid, n.builtInMd5, n.builtInSha1, n.builtInSha256, n.builtInSha384, n.builtInSha512, n.builtInCoalesce, n.builtInIf, n.builtInStrlang, n.builtInStrdt, n.builtInSameterm, n.builtInIsiri, n.builtInIsuri, n.builtInIsblank, n.builtInIsliteral, n.builtInIsnumeric, n.regexExpression, n.substringExpression, n.strReplaceExpression, n.aggregateCount, n.aggregateSum, n.aggregateMin, n.aggregateMax, n.aggregateAvg, n.aggregateSample, n.aggregateGroup_concat, n.aggregate, n.iri, n.prefixedName, n.argList, n.string).addRule(_i), ji = [
1537
1529
  n.objectList,
1538
1530
  n.object,
1539
1531
  n.graphNode,
@@ -1559,7 +1551,7 @@ const ji = [
1559
1551
  n.numericLiteralUnsigned,
1560
1552
  n.numericLiteralPositive,
1561
1553
  n.numericLiteralNegative
1562
- ], dr = P.create(Hi), Qi = P.create([
1554
+ ], hr = F.create(ji), qi = F.create([
1563
1555
  n.triplesBlock,
1564
1556
  n.triplesSameSubjectPath,
1565
1557
  // VarOrTerm is included in the required ObjectList rule
@@ -1570,7 +1562,7 @@ const ji = [
1570
1562
  n.verbPath,
1571
1563
  n.verbSimple,
1572
1564
  n.objectListPath
1573
- ]).merge(dr, []).addMany(
1565
+ ]).merge(hr, []).addMany(
1574
1566
  n.path,
1575
1567
  n.pathAlternative,
1576
1568
  n.pathSequence,
@@ -1585,13 +1577,13 @@ const ji = [
1585
1577
  n.graphNodePath,
1586
1578
  n.collectionPath,
1587
1579
  n.blankNodePropertyListPath
1588
- ), zi = [
1580
+ ), Xi = [
1589
1581
  n.subSelect,
1590
1582
  n.selectClause,
1591
1583
  n.whereClause,
1592
1584
  n.solutionModifier,
1593
1585
  n.valuesClause
1594
- ], Er = P.create(zi).merge(Xi, []).patchRule(n.builtInCall).addMany(n.existsFunc, n.notExistsFunc, n.groupGraphPattern, n.groupGraphPatternSub).merge(Qi, []).addMany(
1586
+ ], dr = F.create(Xi).merge(Vi, []).patchRule(n.builtInCall).addMany(n.existsFunc, n.notExistsFunc, n.groupGraphPattern, n.groupGraphPatternSub).merge(qi, []).addMany(
1595
1587
  n.graphPatternNotTriples,
1596
1588
  n.groupOrUnionGraphPattern,
1597
1589
  n.optionalGraphPattern,
@@ -1617,7 +1609,7 @@ const ji = [
1617
1609
  n.orderCondition,
1618
1610
  n.limitClause,
1619
1611
  n.offsetClause
1620
- ), Ki = [
1612
+ ), Hi = [
1621
1613
  n.triplesTemplate,
1622
1614
  n.triplesSameSubject,
1623
1615
  n.varOrTerm,
@@ -1645,7 +1637,7 @@ const ji = [
1645
1637
  n.collection,
1646
1638
  n.blankNodePropertyList,
1647
1639
  n.graphNode
1648
- ], fr = P.create(Ki), Wi = [
1640
+ ], Er = F.create(Hi), Qi = [
1649
1641
  n.queryUnit,
1650
1642
  n.query,
1651
1643
  n.prologue,
@@ -1656,7 +1648,7 @@ const ji = [
1656
1648
  n.valuesClause,
1657
1649
  n.baseDecl,
1658
1650
  n.prefixDecl
1659
- ], Yi = P.create(Wi).merge(Er, []).addRule(n.datasetClause).addRule(n.datasetClauseStar).addRule(n.defaultGraphClause).addRule(n.namedGraphClause).addRule(n.sourceSelector).addRule(n.constructTemplate).merge(fr, []).addRule(n.constructTriples), Zi = {
1651
+ ], zi = F.create(Qi).merge(dr, []).addRule(n.datasetClause).addRule(n.datasetClauseStar).addRule(n.defaultGraphClause).addRule(n.namedGraphClause).addRule(n.sourceSelector).addRule(n.constructTemplate).merge(Er, []).addRule(n.constructTriples), Ki = {
1660
1652
  name: "update1",
1661
1653
  impl: ({ SUBRULE: e, OR: t }) => () => t([
1662
1654
  { ALT: () => e(n.load) },
@@ -1671,7 +1663,7 @@ const ji = [
1671
1663
  { ALT: () => e(n.deleteWhere) }
1672
1664
  ]),
1673
1665
  gImpl: n.update1.gImpl
1674
- }, Ji = [
1666
+ }, Wi = [
1675
1667
  n.updateUnit,
1676
1668
  n.update,
1677
1669
  n.prologue,
@@ -1695,36 +1687,36 @@ const ji = [
1695
1687
  n.graphOrDefault,
1696
1688
  n.quadData,
1697
1689
  n.quads
1698
- ], tn = P.create(Ji).addRule(Zi).merge(fr, []).addRule(n.quadPattern).addRule(n.quadsNotTriples), en = P.create(tn).patchRule(n.update1).addMany(n.modify, n.deleteClause, n.insertClause, n.usingClause, n.defaultGraphClause, n.namedGraphClause, n.sourceSelector, n.usingClauseStar, n.groupGraphPattern).merge(dr, []).merge(Er, []), rn = P.create(Yi).merge(en, []).addRule(n.queryOrUpdate);
1699
- class gr extends Ir {
1690
+ ], Yi = F.create(Wi).addRule(Ki).merge(Er, []).addRule(n.quadPattern).addRule(n.quadsNotTriples), Zi = F.create(Yi).patchRule(n.update1).addMany(n.modify, n.deleteClause, n.insertClause, n.usingClause, n.defaultGraphClause, n.namedGraphClause, n.sourceSelector, n.usingClauseStar, n.groupGraphPattern).merge(hr, []).merge(dr, []), Ji = F.create(zi).merge(Zi, []).addRule(n.queryOrUpdate);
1691
+ class fr extends xr {
1700
1692
  constructor(t = {}) {
1701
- const r = rn.build({
1693
+ const r = Ji.build({
1702
1694
  ...t,
1703
- tokenVocabulary: ze.sparql11LexerBuilder.tokenVocabulary,
1704
- queryPreProcessor: Mr
1695
+ tokenVocabulary: Qe.sparql11LexerBuilder.tokenVocabulary,
1696
+ queryPreProcessor: vr
1705
1697
  });
1706
1698
  super(r, t.defaultContext);
1707
1699
  }
1708
1700
  }
1709
- let Lt;
1710
- function nn(e) {
1701
+ let mt;
1702
+ function tn(e) {
1711
1703
  return e.type === "query";
1712
1704
  }
1713
- function mr(e) {
1705
+ function gr(e) {
1714
1706
  return e.type === "update";
1715
1707
  }
1716
- function yr(e) {
1708
+ function mr(e) {
1717
1709
  return e.replace(/\s+EXPLICIT\s+(TRUE|FALSE)\b/gi, "");
1718
1710
  }
1719
- function sn(e) {
1720
- Lt ?? (Lt = new gr());
1711
+ function en(e) {
1712
+ mt ??= new fr();
1721
1713
  try {
1722
- const t = Lt.parse(yr(e));
1723
- return mr(t) ? {
1714
+ const t = mt.parse(mr(e));
1715
+ return gr(t) ? {
1724
1716
  valid: !0,
1725
1717
  queryType: "update",
1726
1718
  isReadOnly: !1
1727
- } : nn(t) ? {
1719
+ } : tn(t) ? {
1728
1720
  valid: !0,
1729
1721
  queryType: t.subType,
1730
1722
  isReadOnly: !0
@@ -1739,19 +1731,19 @@ function sn(e) {
1739
1731
  };
1740
1732
  }
1741
1733
  }
1742
- function As(e) {
1743
- const t = sn(e);
1734
+ function ys(e) {
1735
+ const t = en(e);
1744
1736
  return t.valid ? t.isReadOnly ? { allowed: !0, queryType: t.queryType } : {
1745
1737
  allowed: !1,
1746
1738
  error: "UPDATE operations not allowed. Only SELECT, CONSTRUCT, DESCRIBE, and ASK queries are permitted.",
1747
1739
  queryType: t.queryType
1748
1740
  } : { allowed: !1, error: t.error };
1749
1741
  }
1750
- const an = /* @__PURE__ */ new Set([
1742
+ const rn = /* @__PURE__ */ new Set([
1751
1743
  "insertdata",
1752
1744
  "deletedata",
1753
1745
  "modify"
1754
- ]), on = {
1746
+ ]), nn = {
1755
1747
  insertdata: "INSERT DATA",
1756
1748
  deletedata: "DELETE DATA",
1757
1749
  deletewhere: "DELETE WHERE",
@@ -1764,189 +1756,189 @@ const an = /* @__PURE__ */ new Set([
1764
1756
  move: "MOVE",
1765
1757
  copy: "COPY"
1766
1758
  };
1767
- function _e(e) {
1768
- return an.has(e);
1759
+ function Ge(e) {
1760
+ return rn.has(e);
1769
1761
  }
1770
- function Ve(e) {
1762
+ function _e(e) {
1771
1763
  return e.type === "term" && e.subType === "variable";
1772
1764
  }
1773
- function ln(e) {
1774
- return Ve(e.subject) && e.predicate.subType === "variable" && Ve(e.object);
1765
+ function sn(e) {
1766
+ return _e(e.subject) && e.predicate.subType === "variable" && _e(e.object);
1775
1767
  }
1776
- function un(e) {
1768
+ function an(e) {
1777
1769
  for (const t of e) {
1778
1770
  const r = t.type === "graph" ? t.triples.triples : t.triples;
1779
1771
  for (const i of r)
1780
- if (i.type === "triple" && ln(i)) return !0;
1772
+ if (i.type === "triple" && sn(i)) return !0;
1781
1773
  }
1782
1774
  return !1;
1783
1775
  }
1784
- function cn(e) {
1785
- return e.delete.length > 0 && un(e.delete);
1776
+ function on(e) {
1777
+ return e.delete.length > 0 && an(e.delete);
1786
1778
  }
1787
- function Ts(e) {
1788
- Lt ?? (Lt = new gr());
1779
+ function Ls(e) {
1780
+ mt ??= new fr();
1789
1781
  let t;
1790
1782
  try {
1791
- t = Lt.parse(yr(e));
1792
- } catch (o) {
1783
+ t = mt.parse(mr(e));
1784
+ } catch (a) {
1793
1785
  return {
1794
1786
  allowed: !1,
1795
- error: o instanceof Error ? o.message : "Failed to parse SPARQL update"
1787
+ error: a instanceof Error ? a.message : "Failed to parse SPARQL update"
1796
1788
  };
1797
1789
  }
1798
- if (!mr(t))
1790
+ if (!gr(t))
1799
1791
  return {
1800
1792
  allowed: !1,
1801
1793
  error: "Expected a SPARQL UPDATE statement, not a query."
1802
1794
  };
1803
1795
  const r = [];
1804
- for (const o of t.updates)
1805
- o.operation && r.push(o.operation);
1796
+ for (const a of t.updates)
1797
+ a.operation && r.push(a.operation);
1806
1798
  if (r.length === 0)
1807
1799
  return { allowed: !1, error: "Empty SPARQL update -- no operations found." };
1808
- const i = r.filter((o) => !_e(o.subType));
1800
+ const i = r.filter((a) => !Ge(a.subType));
1809
1801
  if (i.length > 0) {
1810
- const o = i.map((E) => E.subType);
1802
+ const a = i.map((f) => f.subType);
1811
1803
  return {
1812
1804
  allowed: !1,
1813
- error: `Blocked operations: ${i.map((E) => on[E.subType]).join(", ")}. Only INSERT DATA, DELETE DATA, and DELETE/INSERT WHERE are permitted.`,
1814
- blockedOperations: o
1805
+ error: `Blocked operations: ${i.map((f) => nn[f.subType]).join(", ")}. Only INSERT DATA, DELETE DATA, and DELETE/INSERT WHERE are permitted.`,
1806
+ blockedOperations: a
1815
1807
  };
1816
1808
  }
1817
1809
  return r.filter(
1818
- (o) => o.subType === "modify" && cn(o)
1810
+ (a) => a.subType === "modify" && on(a)
1819
1811
  ).length > 0 ? {
1820
1812
  allowed: !1,
1821
1813
  error: "Unscoped DELETE patterns (all-variable triples) are not permitted.",
1822
1814
  blockedOperations: ["modify"]
1823
- } : { allowed: !0, operationTypes: r.map((o) => o.subType).filter(_e) };
1815
+ } : { allowed: !0, operationTypes: r.map((a) => a.subType).filter(Ge) };
1824
1816
  }
1825
- async function pn(e) {
1826
- const { endpointUrl: t, datastoreName: r, authorization: i } = e, s = new URL(`datastores/${r}/connections`, t), a = await fetch(s.toString(), {
1817
+ async function ln(e) {
1818
+ const { endpointUrl: t, datastoreName: r, authorization: i } = e, s = new URL(`datastores/${r}/connections`, t), o = await fetch(s.toString(), {
1827
1819
  method: "POST",
1828
1820
  headers: {
1829
1821
  Authorization: i
1830
1822
  }
1831
1823
  });
1832
- if (!a.ok) {
1833
- const l = await a.text();
1834
- throw new Error(`Failed to create connection: ${a.status} - ${l}`);
1824
+ if (!o.ok) {
1825
+ const u = await o.text();
1826
+ throw new Error(`Failed to create connection: ${o.status} - ${u}`);
1835
1827
  }
1836
- const o = a.headers.get("Location");
1837
- if (!o)
1828
+ const a = o.headers.get("Location");
1829
+ if (!a)
1838
1830
  throw new Error("Connection creation response missing Location header");
1839
- return o.split("/").pop();
1831
+ return a.split("/").pop();
1840
1832
  }
1841
- async function hn(e) {
1842
- const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, a = new URL(`datastores/${r}/connections/${i}/transaction`, t);
1843
- a.searchParams.set("operation", "begin-read-write-transaction");
1844
- const o = await fetch(a.toString(), {
1833
+ async function un(e) {
1834
+ const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, o = new URL(`datastores/${r}/connections/${i}/transaction`, t);
1835
+ o.searchParams.set("operation", "begin-read-write-transaction");
1836
+ const a = await fetch(o.toString(), {
1845
1837
  method: "PATCH",
1846
1838
  headers: {
1847
1839
  Authorization: s
1848
1840
  }
1849
1841
  });
1850
- if (!o.ok) {
1851
- const l = await o.text();
1852
- throw new Error(`Failed to begin transaction: ${o.status} - ${l}`);
1842
+ if (!a.ok) {
1843
+ const u = await a.text();
1844
+ throw new Error(`Failed to begin transaction: ${a.status} - ${u}`);
1853
1845
  }
1854
1846
  }
1855
- async function dn(e) {
1856
- const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, a = new URL(`datastores/${r}/connections/${i}/transaction`, t);
1857
- a.searchParams.set("operation", "commit-transaction");
1858
- const o = await fetch(a.toString(), {
1847
+ async function cn(e) {
1848
+ const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, o = new URL(`datastores/${r}/connections/${i}/transaction`, t);
1849
+ o.searchParams.set("operation", "commit-transaction");
1850
+ const a = await fetch(o.toString(), {
1859
1851
  method: "PATCH",
1860
1852
  headers: {
1861
1853
  Authorization: s
1862
1854
  }
1863
1855
  });
1864
- if (!o.ok) {
1865
- const l = await o.text();
1866
- throw new Error(`Failed to commit transaction: ${o.status} - ${l}`);
1856
+ if (!a.ok) {
1857
+ const u = await a.text();
1858
+ throw new Error(`Failed to commit transaction: ${a.status} - ${u}`);
1867
1859
  }
1868
1860
  }
1869
- async function En(e) {
1870
- const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, a = new URL(`datastores/${r}/connections/${i}/transaction`, t);
1871
- a.searchParams.set("operation", "rollback-transaction");
1872
- const o = await fetch(a.toString(), {
1861
+ async function pn(e) {
1862
+ const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, o = new URL(`datastores/${r}/connections/${i}/transaction`, t);
1863
+ o.searchParams.set("operation", "rollback-transaction");
1864
+ const a = await fetch(o.toString(), {
1873
1865
  method: "PATCH",
1874
1866
  headers: {
1875
1867
  Authorization: s
1876
1868
  }
1877
1869
  });
1878
- if (!o.ok) {
1879
- const l = await o.text();
1880
- throw new Error(`Failed to rollback transaction: ${o.status} - ${l}`);
1870
+ if (!a.ok) {
1871
+ const u = await a.text();
1872
+ throw new Error(`Failed to rollback transaction: ${a.status} - ${u}`);
1881
1873
  }
1882
1874
  }
1883
- async function fn(e) {
1884
- const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, a = new URL(`datastores/${r}/connections/${i}`, t), o = await fetch(a.toString(), {
1875
+ async function hn(e) {
1876
+ const { endpointUrl: t, datastoreName: r, connectionId: i, authorization: s } = e, o = new URL(`datastores/${r}/connections/${i}`, t), a = await fetch(o.toString(), {
1885
1877
  method: "DELETE",
1886
1878
  headers: {
1887
1879
  Authorization: s
1888
1880
  }
1889
1881
  });
1890
- if (!o.ok) {
1891
- const l = await o.text();
1892
- throw new Error(`Failed to delete connection: ${o.status} - ${l}`);
1882
+ if (!a.ok) {
1883
+ const u = await a.text();
1884
+ throw new Error(`Failed to delete connection: ${a.status} - ${u}`);
1893
1885
  }
1894
1886
  }
1895
- async function Ss(e, t) {
1896
- const r = await pn(e);
1887
+ async function Us(e, t) {
1888
+ const r = await ln(e);
1897
1889
  try {
1898
- await hn({ ...e, connectionId: r });
1890
+ await un({ ...e, connectionId: r });
1899
1891
  const i = await t(r);
1900
- return await dn({ ...e, connectionId: r }), i;
1892
+ return await cn({ ...e, connectionId: r }), i;
1901
1893
  } catch (i) {
1902
1894
  try {
1903
- await En({ ...e, connectionId: r });
1895
+ await pn({ ...e, connectionId: r });
1904
1896
  } catch (s) {
1905
1897
  console.error("Failed to rollback transaction:", s);
1906
1898
  }
1907
1899
  throw i;
1908
1900
  } finally {
1909
1901
  try {
1910
- await fn({ ...e, connectionId: r });
1902
+ await hn({ ...e, connectionId: r });
1911
1903
  } catch (i) {
1912
1904
  console.error("Failed to delete connection:", i);
1913
1905
  }
1914
1906
  }
1915
1907
  }
1916
- function Nt(e) {
1908
+ function St(e) {
1917
1909
  return e.type === "variable" ? `?${e.name}` : void 0;
1918
1910
  }
1919
- function Ns(e) {
1911
+ function ws(e) {
1920
1912
  const t = /* @__PURE__ */ new Map();
1921
- function r(a) {
1922
- let o = t.get(a);
1923
- return o || (o = { variable: a, predicateEvidence: [] }, t.set(a, o)), o;
1924
- }
1925
- function i(a) {
1926
- const { atom: o, fromBody: l = !1 } = a, E = Ze(o);
1927
- if (E) {
1928
- const R = Nt(E.instance);
1929
- if (R) {
1930
- const L = r(R);
1931
- L.classTerm ?? (L.classTerm = E.className), l && (L.bodyClassTerm ?? (L.bodyClassTerm = E.className));
1913
+ function r(o) {
1914
+ let a = t.get(o);
1915
+ return a || (a = { variable: o, predicateEvidence: [] }, t.set(o, a)), a;
1916
+ }
1917
+ function i(o) {
1918
+ const { atom: a, fromBody: u = !1 } = o, f = Ye(a);
1919
+ if (f) {
1920
+ const C = St(f.instance);
1921
+ if (C) {
1922
+ const T = r(C);
1923
+ T.classTerm ??= f.className, u && (T.bodyClassTerm ??= f.className);
1932
1924
  }
1933
1925
  return;
1934
1926
  }
1935
- const y = Je(o);
1927
+ const y = Ze(a);
1936
1928
  if (!y) return;
1937
- const S = Nt(y.subject), h = Nt(y.object);
1938
- S && r(S).predicateEvidence.push({ term: y.predicate, position: "domain" }), h && r(h).predicateEvidence.push({ term: y.predicate, position: "range" });
1929
+ const m = St(y.subject), h = St(y.object);
1930
+ m && r(m).predicateEvidence.push({ term: y.predicate, position: "domain" }), h && r(h).predicateEvidence.push({ term: y.predicate, position: "range" });
1939
1931
  }
1940
- function s(a) {
1941
- if (Be(a)) {
1942
- i({ atom: a, fromBody: !0 });
1932
+ function s(o) {
1933
+ if (Me(o)) {
1934
+ i({ atom: o, fromBody: !0 });
1943
1935
  return;
1944
1936
  }
1945
- a.type === "aggregate" && a.atoms.filter(Be).forEach((o) => i({ atom: o, fromBody: !0 }));
1937
+ o.type === "aggregate" && o.atoms.filter(Me).forEach((a) => i({ atom: a, fromBody: !0 }));
1946
1938
  }
1947
- return e.head.forEach((a) => i({ atom: a })), e.body.forEach(s), [...t.values()];
1939
+ return e.head.forEach((o) => i({ atom: o })), e.body.forEach(s), [...t.values()];
1948
1940
  }
1949
- function Rs(e, t) {
1941
+ function As(e, t) {
1950
1942
  const r = [];
1951
1943
  for (const i of e) {
1952
1944
  const s = i.bodyClassTerm ?? i.classTerm;
@@ -1954,68 +1946,66 @@ function Rs(e, t) {
1954
1946
  r.push({ variable: i.variable, typeTerm: s, source: "class" });
1955
1947
  continue;
1956
1948
  }
1957
- const a = gn(i.predicateEvidence, t);
1958
- a && r.push({ variable: i.variable, ...a });
1949
+ const o = dn(i.predicateEvidence, t);
1950
+ o && r.push({ variable: i.variable, ...o });
1959
1951
  }
1960
1952
  return r;
1961
1953
  }
1962
- function gn(e, t) {
1954
+ function dn(e, t) {
1963
1955
  for (const { term: r, position: i } of e) {
1964
- const s = t(r), a = i === "domain" ? s == null ? void 0 : s.domainIncludes[0] : s == null ? void 0 : s.rangeIncludes[0];
1965
- if (a) return { typeTerm: a, source: i };
1956
+ const s = t(r), o = i === "domain" ? s?.domainIncludes[0] : s?.rangeIncludes[0];
1957
+ if (o) return { typeTerm: o, source: i };
1966
1958
  }
1967
1959
  }
1968
- const mn = new xe({ selfAnalysis: !1 }).getBaseCstVisitorConstructor();
1969
- function v(e, t) {
1960
+ const En = new Oe({ selfAnalysis: !1 }).getBaseCstVisitorConstructor();
1961
+ function O(e, t) {
1970
1962
  if (e === void 0)
1971
1963
  throw new Error(t);
1972
1964
  return e;
1973
1965
  }
1974
- function at(e, t, ...r) {
1975
- var s;
1966
+ function nt(e, t, ...r) {
1976
1967
  if (!e)
1977
1968
  throw new Error(`Children is undefined when looking for keys: [${r.join(", ")}]`);
1978
- for (const a of r)
1979
- if ((s = e[a]) != null && s[0]) return t(e[a][0]);
1969
+ for (const s of r)
1970
+ if (e[s]?.[0]) return t(e[s][0]);
1980
1971
  const i = Object.keys(e);
1981
1972
  throw new Error(`None of [${r.join(", ")}] found. Available keys: [${i.join(", ")}]`);
1982
1973
  }
1983
- const f = (e) => e != null && e.length > 0;
1984
- function je(e) {
1974
+ const d = (e) => e != null && e.length > 0;
1975
+ function Ve(e) {
1985
1976
  return e.flatMap(({ arr: t, op: r }) => (t ?? []).map((i) => ({ offset: i.startOffset, op: r }))).sort((t, r) => t.offset - r.offset).map(({ op: t }) => t);
1986
1977
  }
1987
- function Y(e) {
1978
+ function K(e) {
1988
1979
  const t = e.startOffset ?? 0, r = e.endOffset ?? t + e.image.length - 1;
1989
1980
  return { start: t, end: r + 1 };
1990
1981
  }
1991
- function V(e, t, r = e.image) {
1982
+ function _(e, t, r = e.image) {
1992
1983
  return {
1993
1984
  token: e,
1994
1985
  term: { type: "iri", value: r, prefixed: t }
1995
1986
  };
1996
1987
  }
1997
- function qe(e) {
1988
+ function je(e) {
1998
1989
  return p(e).returnType().with(
1999
- { IRI_REF: u.when(f) },
2000
- ({ IRI_REF: t }) => V(t[0], !1, t[0].image.slice(1, -1))
2001
- ).with({ PREFIXED_NAME: u.when(f) }, ({ PREFIXED_NAME: t }) => V(t[0], !0)).with({ PREFIX_ONLY: u.when(f) }, ({ PREFIX_ONLY: t }) => V(t[0], !0)).with({ IDENTIFIER: u.when(f) }, ({ IDENTIFIER: t }) => V(t[0], !1)).with({ DEFAULT_NS_IRI: u.when(f) }, ({ DEFAULT_NS_IRI: t }) => V(t[0], !0)).with(
2002
- { INTERNAL_FUNCTION: u.when(f) },
2003
- ({ INTERNAL_FUNCTION: t }) => V(t[0], !1)
1990
+ { IRI_REF: l.when(d) },
1991
+ ({ IRI_REF: t }) => _(t[0], !1, t[0].image.slice(1, -1))
1992
+ ).with({ PREFIXED_NAME: l.when(d) }, ({ PREFIXED_NAME: t }) => _(t[0], !0)).with({ PREFIX_ONLY: l.when(d) }, ({ PREFIX_ONLY: t }) => _(t[0], !0)).with({ IDENTIFIER: l.when(d) }, ({ IDENTIFIER: t }) => _(t[0], !1)).with({ DEFAULT_NS_IRI: l.when(d) }, ({ DEFAULT_NS_IRI: t }) => _(t[0], !0)).with(
1993
+ { INTERNAL_FUNCTION: l.when(d) },
1994
+ ({ INTERNAL_FUNCTION: t }) => _(t[0], !1)
2004
1995
  ).otherwise(() => {
2005
1996
  throw new Error("Unknown IRI type");
2006
1997
  });
2007
1998
  }
2008
- function yn(e, t) {
2009
- const r = Y(e);
1999
+ function fn(e, t) {
2000
+ const r = K(e);
2010
2001
  return {
2011
2002
  start: r.start + t,
2012
2003
  end: r.end - t
2013
2004
  };
2014
2005
  }
2015
- class Ln extends mn {
2006
+ class gn extends En {
2016
2007
  rule(t) {
2017
- var s;
2018
- const r = this.visit(v(t.ruleHead, "Rule missing head")), i = (s = t.ruleBody) != null && s[0] ? this.visit(t.ruleBody) : [];
2008
+ const r = this.visit(O(t.ruleHead, "Rule missing head")), i = t.ruleBody?.[0] ? this.visit(t.ruleBody) : [];
2019
2009
  return { head: r, body: i };
2020
2010
  }
2021
2011
  ruleHead(t) {
@@ -2025,7 +2015,7 @@ class Ln extends mn {
2025
2015
  return t.bodyFormula.map((r) => this.visit(r));
2026
2016
  }
2027
2017
  bodyFormula(t) {
2028
- return at(
2018
+ return nt(
2029
2019
  t,
2030
2020
  this.visit.bind(this),
2031
2021
  "negation",
@@ -2037,8 +2027,8 @@ class Ln extends mn {
2037
2027
  );
2038
2028
  }
2039
2029
  tupleTableAtom(t) {
2040
- const r = at(t, this.visit.bind(this), "defaultGraphAtom", "generalAtom");
2041
- if (f(t.graph)) {
2030
+ const r = nt(t, this.visit.bind(this), "defaultGraphAtom", "generalAtom");
2031
+ if (d(t.graph)) {
2042
2032
  const i = this.visit(t.graph[0]);
2043
2033
  if (r.type === "triple" || r.type === "property" || r.type === "class")
2044
2034
  return { ...r, graph: i };
@@ -2047,24 +2037,24 @@ class Ln extends mn {
2047
2037
  return r;
2048
2038
  }
2049
2039
  graphName(t) {
2050
- if (f(t.VARIABLE))
2040
+ if (d(t.VARIABLE))
2051
2041
  return { type: "variable", name: t.VARIABLE[0].image.substring(1) };
2052
- if (f(t.iri))
2042
+ if (d(t.iri))
2053
2043
  return this.visit(t.iri[0]);
2054
2044
  throw new Error("Unknown graph name type");
2055
2045
  }
2056
2046
  defaultGraphAtom(t) {
2057
2047
  const r = t;
2058
- if (f(r.subject) && f(r.predicate) && f(r.object))
2048
+ if (d(r.subject) && d(r.predicate) && d(r.object))
2059
2049
  return {
2060
2050
  type: "triple",
2061
2051
  subject: this.visit(r.subject[0]),
2062
2052
  predicate: this.visit(r.predicate[0]),
2063
2053
  object: this.visit(r.object[0])
2064
2054
  };
2065
- if (f(r.predicateOrClass) && f(r.firstTerm)) {
2055
+ if (d(r.predicateOrClass) && d(r.firstTerm)) {
2066
2056
  const i = this.extractIriValue(r.predicateOrClass[0]), s = this.visit(r.firstTerm[0]);
2067
- return f(r.secondTerm) ? {
2057
+ return d(r.secondTerm) ? {
2068
2058
  type: "property",
2069
2059
  predicate: i,
2070
2060
  subject: s,
@@ -2081,7 +2071,7 @@ class Ln extends mn {
2081
2071
  const r = t;
2082
2072
  return {
2083
2073
  type: "general",
2084
- tableName: f(r.IDENTIFIER) ? r.IDENTIFIER[0].image : f(r.STRING_LITERAL) ? this.unquoteString(r.STRING_LITERAL[0].image) : (() => {
2074
+ tableName: d(r.IDENTIFIER) ? r.IDENTIFIER[0].image : d(r.STRING_LITERAL) ? this.unquoteString(r.STRING_LITERAL[0].image) : (() => {
2085
2075
  throw new Error("Missing table name");
2086
2076
  })(),
2087
2077
  terms: r.term.map((s) => this.visit(s))
@@ -2089,17 +2079,17 @@ class Ln extends mn {
2089
2079
  }
2090
2080
  term(t) {
2091
2081
  const r = t;
2092
- if (f(r.VARIABLE)) return { type: "variable", name: r.VARIABLE[0].image.substring(1) };
2093
- if (f(r.iri)) return this.visit(r.iri[0]);
2094
- if (f(r.literal)) return this.visit(r.literal[0]);
2095
- if (f(r.BLANK_NODE)) return { type: "blank", label: r.BLANK_NODE[0].image.substring(2) };
2082
+ if (d(r.VARIABLE)) return { type: "variable", name: r.VARIABLE[0].image.substring(1) };
2083
+ if (d(r.iri)) return this.visit(r.iri[0]);
2084
+ if (d(r.literal)) return this.visit(r.literal[0]);
2085
+ if (d(r.BLANK_NODE)) return { type: "blank", label: r.BLANK_NODE[0].image.substring(2) };
2096
2086
  throw new Error("Unknown term type");
2097
2087
  }
2098
2088
  iri(t) {
2099
- return qe(t).term;
2089
+ return je(t).term;
2100
2090
  }
2101
2091
  literal(t) {
2102
- return at(
2092
+ return nt(
2103
2093
  t,
2104
2094
  this.visit.bind(this),
2105
2095
  "numericLiteral",
@@ -2109,38 +2099,36 @@ class Ln extends mn {
2109
2099
  }
2110
2100
  numericLiteral(t) {
2111
2101
  const r = t;
2112
- if (f(r.INTEGER)) return this.numericTokenLiteral(r.INTEGER[0], j.integer);
2113
- if (f(r.DECIMAL)) return this.numericTokenLiteral(r.DECIMAL[0], j.decimal);
2114
- if (f(r.DOUBLE)) return this.numericTokenLiteral(r.DOUBLE[0], j.double);
2102
+ if (d(r.INTEGER)) return this.numericTokenLiteral(r.INTEGER[0], V.integer);
2103
+ if (d(r.DECIMAL)) return this.numericTokenLiteral(r.DECIMAL[0], V.decimal);
2104
+ if (d(r.DOUBLE)) return this.numericTokenLiteral(r.DOUBLE[0], V.double);
2115
2105
  throw new Error("Unknown numeric literal type");
2116
2106
  }
2117
2107
  booleanLiteral(t) {
2118
2108
  const r = t;
2119
- if (f(r.TRUE)) return { type: "literal", value: "true", datatype: j.boolean };
2120
- if (f(r.FALSE)) return { type: "literal", value: "false", datatype: j.boolean };
2109
+ if (d(r.TRUE)) return { type: "literal", value: "true", datatype: V.boolean };
2110
+ if (d(r.FALSE)) return { type: "literal", value: "false", datatype: V.boolean };
2121
2111
  throw new Error("Unknown boolean literal type");
2122
2112
  }
2123
2113
  stringLiteral(t) {
2124
- var h, R, L, A;
2125
- const r = (h = t.STRING_LITERAL_LONG) == null ? void 0 : h[0], i = (R = t.STRING_LITERAL) == null ? void 0 : R[0], s = r ?? i;
2114
+ const r = t.STRING_LITERAL_LONG?.[0], i = t.STRING_LITERAL?.[0], s = r ?? i;
2126
2115
  if (!s) throw new Error("Unknown string literal format");
2127
- const a = r ? this.unquoteTripleString(s.image) : this.unquoteString(s.image), o = Y(s), l = (L = t.LANGTAG) == null ? void 0 : L[0], E = (A = t.iri) != null && A[0] ? qe(t.iri[0].children) : void 0, y = l ? Y(l).end : E ? Y(E.token).end : o.end, S = {
2116
+ const o = r ? this.unquoteTripleString(s.image) : this.unquoteString(s.image), a = K(s), u = t.LANGTAG?.[0], f = t.iri?.[0] ? je(t.iri[0].children) : void 0, y = u ? K(u).end : f ? K(f.token).end : a.end, m = {
2128
2117
  type: "literal",
2129
- value: a,
2130
- termSpan: { start: o.start, end: y },
2131
- valueSpan: yn(s, r ? 3 : 1)
2118
+ value: o,
2119
+ termSpan: { start: a.start, end: y },
2120
+ valueSpan: fn(s, r ? 3 : 1)
2132
2121
  };
2133
- return l ? S.language = l.image.substring(1) : E && (S.datatype = E.term.value), S;
2122
+ return u ? m.language = u.image.substring(1) : f && (m.datatype = f.term.value), m;
2134
2123
  }
2135
2124
  negation(t) {
2136
- var s, a, o;
2137
2125
  const r = [];
2138
- if ((s = t.existsClause) != null && s[0]) {
2139
- const l = this.visit(t.existsClause);
2140
- r.push(...l);
2126
+ if (t.existsClause?.[0]) {
2127
+ const s = this.visit(t.existsClause);
2128
+ r.push(...s);
2141
2129
  }
2142
2130
  const i = [];
2143
- return (a = t.bodyFormulaList) != null && a[0] ? i.push(...this.visit(t.bodyFormulaList)) : (o = t.tupleTableAtom) != null && o[0] && i.push(this.visit(t.tupleTableAtom)), {
2131
+ return t.bodyFormulaList?.[0] ? i.push(...this.visit(t.bodyFormulaList)) : t.tupleTableAtom?.[0] && i.push(this.visit(t.tupleTableAtom)), {
2144
2132
  type: "negation",
2145
2133
  formulas: i,
2146
2134
  existentialVars: r.length > 0 ? r : void 0
@@ -2153,7 +2141,7 @@ class Ln extends mn {
2153
2141
  return t.atom ? t.atom.map((r) => this.visit(r)) : [];
2154
2142
  }
2155
2143
  atom(t) {
2156
- return at(
2144
+ return nt(
2157
2145
  t,
2158
2146
  (r) => this.visit(r),
2159
2147
  "tupleTableAtom",
@@ -2167,24 +2155,23 @@ class Ln extends mn {
2167
2155
  filterAtom(t) {
2168
2156
  return {
2169
2157
  type: "filter",
2170
- expression: this.visit(v(t.expression, "Filter missing expression"))
2158
+ expression: this.visit(O(t.expression, "Filter missing expression"))
2171
2159
  };
2172
2160
  }
2173
2161
  bindAtom(t) {
2174
2162
  return {
2175
2163
  type: "bind",
2176
- expression: this.visit(v(t.expression, "Bind missing expression")),
2164
+ expression: this.visit(O(t.expression, "Bind missing expression")),
2177
2165
  ...this.asTarget(t, "Bind missing variable")
2178
2166
  };
2179
2167
  }
2180
2168
  // The expanded grammar accepts a value where a variable belongs, because the engine
2181
2169
  // substitutes the `AS` target when it grounds a rule.
2182
2170
  asTarget(t, r) {
2183
- var a;
2184
- const i = (a = t.VARIABLE) == null ? void 0 : a[0];
2171
+ const i = t.VARIABLE?.[0];
2185
2172
  if (i) return { variable: i.image.substring(1) };
2186
- const s = this.visit(v(t.groundedAsTarget, r));
2187
- return { variable: x(s, { stripSimpleLiteralDatatypes: !0 }), groundedTarget: s };
2173
+ const s = this.visit(O(t.groundedAsTarget, r));
2174
+ return { variable: b(s, { stripSimpleLiteralDatatypes: !0 }), groundedTarget: s };
2188
2175
  }
2189
2176
  // A variable-free `term`, so it visits identically.
2190
2177
  groundedAsTarget(t) {
@@ -2193,28 +2180,26 @@ class Ln extends mn {
2193
2180
  skolemAtom(t) {
2194
2181
  return {
2195
2182
  type: "skolem",
2196
- args: this.visit(v(t.argumentList, "Skolem missing argument list"))
2183
+ args: this.visit(O(t.argumentList, "Skolem missing argument list"))
2197
2184
  };
2198
2185
  }
2199
2186
  aggregate(t) {
2200
- var a;
2201
- const r = (a = t.atomList) != null && a[0] ? this.visit(t.atomList) : [], i = t.onClause ? this.visit(t.onClause) : void 0, s = t.aggregateBind ? t.aggregateBind.map((o) => this.visit(o)) : void 0;
2202
- if (r.length === 0 && !(s != null && s.length))
2187
+ const r = t.atomList?.[0] ? this.visit(t.atomList) : [], i = t.onClause ? this.visit(t.onClause) : void 0, s = t.aggregateBind ? t.aggregateBind.map((o) => this.visit(o)) : void 0;
2188
+ if (r.length === 0 && !s?.length)
2203
2189
  throw new Error("AGGREGATE requires at least one atom or binding");
2204
2190
  return {
2205
2191
  type: "aggregate",
2206
2192
  atoms: r,
2207
- onVars: i == null ? void 0 : i.onVars,
2208
- groundedOnTargets: i == null ? void 0 : i.groundedOnTargets,
2193
+ onVars: i?.onVars,
2194
+ groundedOnTargets: i?.groundedOnTargets,
2209
2195
  bindings: s
2210
2196
  };
2211
2197
  }
2212
2198
  // The engine grounds every grouping variable or none of them, so listing the
2213
2199
  // variables ahead of any substituted values preserves source order in practice.
2214
2200
  onClause(t) {
2215
- var a, o;
2216
- const r = ((a = t.VARIABLE) == null ? void 0 : a.map((l) => l.image.substring(1))) ?? [], i = ((o = t.groundedAsTarget) == null ? void 0 : o.map((l) => this.visit(l))) ?? [], s = i.map(
2217
- (l) => x(l, { stripSimpleLiteralDatatypes: !0 })
2201
+ const r = t.VARIABLE?.map((o) => o.image.substring(1)) ?? [], i = t.groundedAsTarget?.map((o) => this.visit(o)) ?? [], s = i.map(
2202
+ (o) => b(o, { stripSimpleLiteralDatatypes: !0 })
2218
2203
  );
2219
2204
  return {
2220
2205
  onVars: [...r, ...s],
@@ -2222,73 +2207,70 @@ class Ln extends mn {
2222
2207
  };
2223
2208
  }
2224
2209
  aggregateBind(t) {
2225
- var i;
2226
2210
  const r = this.asTarget(t, "AggregateBind missing variable");
2227
- return (i = t.aggregateFunction) != null && i[0] ? { ...this.visit(t.aggregateFunction), ...r } : {
2228
- expression: this.visit(v(t.expression, "AggregateBind missing expression")),
2211
+ return t.aggregateFunction?.[0] ? { ...this.visit(t.aggregateFunction), ...r } : {
2212
+ expression: this.visit(O(t.expression, "AggregateBind missing expression")),
2229
2213
  ...r
2230
2214
  };
2231
2215
  }
2232
2216
  aggregateFunction(t) {
2233
- return p(t).with({ aggregateFunction1: u.when(f) }, (r) => this.visit(r.aggregateFunction1[0])).with({ aggregateFunction2: u.when(f) }, (r) => this.visit(r.aggregateFunction2[0])).otherwise(() => {
2217
+ return p(t).with({ aggregateFunction1: l.when(d) }, (r) => this.visit(r.aggregateFunction1[0])).with({ aggregateFunction2: l.when(d) }, (r) => this.visit(r.aggregateFunction2[0])).otherwise(() => {
2234
2218
  throw new Error("Unknown aggregate function arity");
2235
2219
  });
2236
2220
  }
2237
2221
  aggregateFunction1(t) {
2238
- var i;
2239
2222
  return {
2240
2223
  function: p(t).when(
2241
- (s) => !!s.COUNT_MIN,
2224
+ (i) => !!i.COUNT_MIN,
2242
2225
  () => "COUNT_MIN"
2243
2226
  ).when(
2244
- (s) => !!s.COUNT_MAX,
2227
+ (i) => !!i.COUNT_MAX,
2245
2228
  () => "COUNT_MAX"
2246
2229
  ).when(
2247
- (s) => !!s.COUNT,
2230
+ (i) => !!i.COUNT,
2248
2231
  () => "COUNT"
2249
2232
  ).when(
2250
- (s) => !!s.MIN,
2233
+ (i) => !!i.MIN,
2251
2234
  () => "MIN"
2252
2235
  ).when(
2253
- (s) => !!s.MAX,
2236
+ (i) => !!i.MAX,
2254
2237
  () => "MAX"
2255
2238
  ).when(
2256
- (s) => !!s.SUM,
2239
+ (i) => !!i.SUM,
2257
2240
  () => "SUM"
2258
2241
  ).when(
2259
- (s) => !!s.MUL,
2242
+ (i) => !!i.MUL,
2260
2243
  () => "MUL"
2261
2244
  ).when(
2262
- (s) => !!s.AVG,
2245
+ (i) => !!i.AVG,
2263
2246
  () => "AVG"
2264
2247
  ).otherwise(() => {
2265
2248
  throw new Error("Unknown aggregate function");
2266
2249
  }),
2267
- expression: t.STAR ? "*" : (i = t.expression) != null && i[0] ? this.visit(t.expression[0]) : { type: "term", term: { type: "literal", value: "", datatype: "xsd:string" } },
2250
+ expression: t.STAR ? "*" : t.expression?.[0] ? this.visit(t.expression[0]) : { type: "term", term: { type: "literal", value: "", datatype: "xsd:string" } },
2268
2251
  ...t.DISTINCT && { distinct: !0 }
2269
2252
  };
2270
2253
  }
2271
2254
  aggregateFunction2(t) {
2272
- var i, s;
2273
2255
  return {
2274
2256
  function: p(t).when(
2275
- (a) => !!a.MIN_ARGMIN,
2257
+ (i) => !!i.MIN_ARGMIN,
2276
2258
  () => "MIN_ARGMIN"
2277
2259
  ).when(
2278
- (a) => !!a.MAX_ARGMIN,
2260
+ (i) => !!i.MAX_ARGMIN,
2279
2261
  () => "MAX_ARGMIN"
2280
2262
  ).when(
2281
- (a) => !!a.MIN_ARGMAX,
2263
+ (i) => !!i.MIN_ARGMAX,
2282
2264
  () => "MIN_ARGMAX"
2283
2265
  ).when(
2284
- (a) => !!a.MAX_ARGMAX,
2266
+ (i) => !!i.MAX_ARGMAX,
2285
2267
  () => "MAX_ARGMAX"
2286
2268
  ).otherwise(() => {
2287
2269
  throw new Error("Unknown aggregate function");
2288
2270
  }),
2289
- expression: this.visit(v((i = t.firstExpr) == null ? void 0 : i[0], "AggregateFunction2 missing first expression")),
2271
+ expression: this.visit(O(t.firstExpr?.[0], "AggregateFunction2 missing first expression")),
2290
2272
  secondExpression: this.visit(
2291
- v((s = t.secondExpr) == null ? void 0 : s[0], "AggregateFunction2 missing second expression")
2273
+ O(t.secondExpr?.[0], "AggregateFunction2 missing second expression")
2292
2274
  ),
2293
2275
  ...t.DISTINCT && { distinct: !0 }
2294
2276
  };
@@ -2319,33 +2301,32 @@ class Ln extends mn {
2319
2301
  );
2320
2302
  }
2321
2303
  relationalExpression(t) {
2322
- var i;
2323
2304
  const r = this.visit(t.additiveExpression);
2324
2305
  if (t.IN) {
2325
- const s = !!t.NOT, a = (i = t.argumentList) == null ? void 0 : i[0], o = a ? this.visit(a) : [];
2306
+ const i = !!t.NOT, s = t.argumentList?.[0], o = s ? this.visit(s) : [];
2326
2307
  return {
2327
2308
  type: "in",
2328
- negated: s,
2309
+ negated: i,
2329
2310
  expression: r,
2330
2311
  list: o
2331
2312
  };
2332
2313
  }
2333
2314
  return t.additiveExpression.length > 1 ? {
2334
2315
  type: "binary",
2335
- operator: p(t).with({ EQUALS: u.when(Boolean) }, () => "=").with({ NOT_EQUALS: u.when(Boolean) }, () => "!=").with({ LESS_THAN: u.when(Boolean) }, () => "<").with({ GREATER_THAN: u.when(Boolean) }, () => ">").with({ LESS_THAN_OR_EQUAL: u.when(Boolean) }, () => "<=").with({ GREATER_THAN_OR_EQUAL: u.when(Boolean) }, () => ">=").otherwise(() => "="),
2316
+ operator: p(t).with({ EQUALS: l.when(Boolean) }, () => "=").with({ NOT_EQUALS: l.when(Boolean) }, () => "!=").with({ LESS_THAN: l.when(Boolean) }, () => "<").with({ GREATER_THAN: l.when(Boolean) }, () => ">").with({ LESS_THAN_OR_EQUAL: l.when(Boolean) }, () => "<=").with({ GREATER_THAN_OR_EQUAL: l.when(Boolean) }, () => ">=").otherwise(() => "="),
2336
2317
  left: r,
2337
2318
  right: t.additiveExpression[1] ? this.visit(t.additiveExpression[1]) : r
2338
2319
  } : r;
2339
2320
  }
2340
2321
  additiveExpression(t) {
2341
- const r = je([
2322
+ const r = Ve([
2342
2323
  { arr: t.PLUS, op: "+" },
2343
2324
  { arr: t.MINUS, op: "-" }
2344
2325
  ]);
2345
2326
  return t.multiplicativeExpression.slice(1).reduce(
2346
- (i, s, a) => ({
2327
+ (i, s, o) => ({
2347
2328
  type: "binary",
2348
- operator: r[a] ?? "+",
2329
+ operator: r[o] ?? "+",
2349
2330
  left: i,
2350
2331
  right: this.visit(s)
2351
2332
  }),
@@ -2353,14 +2334,14 @@ class Ln extends mn {
2353
2334
  );
2354
2335
  }
2355
2336
  multiplicativeExpression(t) {
2356
- const r = je([
2337
+ const r = Ve([
2357
2338
  { arr: t.STAR, op: "*" },
2358
2339
  { arr: t.SLASH, op: "/" }
2359
2340
  ]);
2360
2341
  return t.unaryExpression.slice(1).reduce(
2361
- (i, s, a) => ({
2342
+ (i, s, o) => ({
2362
2343
  type: "binary",
2363
- operator: r[a] ?? "*",
2344
+ operator: r[o] ?? "*",
2364
2345
  left: i,
2365
2346
  right: this.visit(s)
2366
2347
  }),
@@ -2369,21 +2350,21 @@ class Ln extends mn {
2369
2350
  }
2370
2351
  unaryExpression(t) {
2371
2352
  return p(t).with(
2372
- { EXCLAMATION: u.when(Boolean) },
2353
+ { EXCLAMATION: l.when(Boolean) },
2373
2354
  () => ({
2374
2355
  type: "unary",
2375
2356
  operator: "!",
2376
2357
  operand: this.visit(t.primaryExpression)
2377
2358
  })
2378
2359
  ).with(
2379
- { PLUS: u.when(Boolean) },
2360
+ { PLUS: l.when(Boolean) },
2380
2361
  () => ({
2381
2362
  type: "unary",
2382
2363
  operator: "+",
2383
2364
  operand: this.visit(t.primaryExpression)
2384
2365
  })
2385
2366
  ).with(
2386
- { MINUS: u.when(Boolean) },
2367
+ { MINUS: l.when(Boolean) },
2387
2368
  () => ({
2388
2369
  type: "unary",
2389
2370
  operator: "-",
@@ -2392,10 +2373,9 @@ class Ln extends mn {
2392
2373
  ).otherwise(() => this.visit(t.primaryExpression));
2393
2374
  }
2394
2375
  functionCall(t) {
2395
- return p(t).with({ concatFunction: u.when(f) }, (r) => this.visit(r.concatFunction[0])).with({ strFunction: u.when(f) }, (r) => this.visit(r.strFunction[0])).with({ ifFunction: u.when(f) }, (r) => this.visit(r.ifFunction[0])).with({ iriFunction: u.when(f) }, (r) => this.visit(r.iriFunction[0])).with({ skolemFunction: u.when(f) }, (r) => this.visit(r.skolemFunction[0])).with({ roundFunction: u.when(f) }, (r) => this.visit(r.roundFunction[0])).with({ regexFunction: u.when(f) }, (r) => this.visit(r.regexFunction[0])).with({ iri: u.when(f), LPAREN: u.when(f) }, (r) => {
2396
- var o;
2397
- const i = r.iri[0] ? this.visit(r.iri[0]) : null, s = i && typeof i == "object" && "type" in i && i.type === "iri" && "value" in i ? String(i.value) : "unknown", a = (o = r.argumentList) != null && o[0] ? this.visit(r.argumentList[0]) : [];
2398
- return { type: "function", name: s, args: a };
2376
+ return p(t).with({ concatFunction: l.when(d) }, (r) => this.visit(r.concatFunction[0])).with({ strFunction: l.when(d) }, (r) => this.visit(r.strFunction[0])).with({ ifFunction: l.when(d) }, (r) => this.visit(r.ifFunction[0])).with({ iriFunction: l.when(d) }, (r) => this.visit(r.iriFunction[0])).with({ skolemFunction: l.when(d) }, (r) => this.visit(r.skolemFunction[0])).with({ roundFunction: l.when(d) }, (r) => this.visit(r.roundFunction[0])).with({ regexFunction: l.when(d) }, (r) => this.visit(r.regexFunction[0])).with({ iri: l.when(d), LPAREN: l.when(d) }, (r) => {
2377
+ const i = r.iri[0] ? this.visit(r.iri[0]) : null, s = i && typeof i == "object" && "type" in i && i.type === "iri" && "value" in i ? String(i.value) : "unknown", o = r.argumentList?.[0] ? this.visit(r.argumentList[0]) : [];
2378
+ return { type: "function", name: s, args: o };
2399
2379
  }).otherwise(() => {
2400
2380
  throw new Error("Unknown function call type");
2401
2381
  });
@@ -2444,12 +2424,11 @@ class Ln extends mn {
2444
2424
  };
2445
2425
  }
2446
2426
  regexFunction(t) {
2447
- var i;
2448
2427
  const r = [
2449
- this.visit(v(t.textExpr, "REGEX missing text expression")),
2450
- this.visit(v(t.patternExpr, "REGEX missing pattern expression"))
2428
+ this.visit(O(t.textExpr, "REGEX missing text expression")),
2429
+ this.visit(O(t.patternExpr, "REGEX missing pattern expression"))
2451
2430
  ];
2452
- return (i = t.flagsExpr) != null && i[0] && r.push(this.visit(t.flagsExpr)), {
2431
+ return t.flagsExpr?.[0] && r.push(this.visit(t.flagsExpr)), {
2453
2432
  type: "function",
2454
2433
  name: "REGEX",
2455
2434
  args: r
@@ -2459,13 +2438,13 @@ class Ln extends mn {
2459
2438
  return t.expression.map((r) => this.visit(r));
2460
2439
  }
2461
2440
  primaryExpression(t) {
2462
- return p(t).with({ expression: u.when(f) }, (r) => this.visit(r.expression[0])).with({ functionCall: u.when(f) }, (r) => this.visit(r.functionCall[0])).with({ literal: u.when(f) }, (r) => ({ type: "term", term: this.visit(r.literal[0]) })).with({ VARIABLE: u.when(f) }, (r) => ({
2441
+ return p(t).with({ expression: l.when(d) }, (r) => this.visit(r.expression[0])).with({ functionCall: l.when(d) }, (r) => this.visit(r.functionCall[0])).with({ literal: l.when(d) }, (r) => ({ type: "term", term: this.visit(r.literal[0]) })).with({ VARIABLE: l.when(d) }, (r) => ({
2463
2442
  type: "term",
2464
2443
  term: { type: "variable", name: r.VARIABLE[0].image.substring(1) }
2465
- })).with({ BLANK_NODE: u.when(f) }, (r) => ({
2444
+ })).with({ BLANK_NODE: l.when(d) }, (r) => ({
2466
2445
  type: "term",
2467
2446
  term: { type: "blank", label: r.BLANK_NODE[0].image.substring(2) }
2468
- })).with({ iri: u.when(f) }, (r) => ({ type: "term", term: this.visit(r.iri[0]) })).otherwise(() => {
2447
+ })).with({ iri: l.when(d) }, (r) => ({ type: "term", term: this.visit(r.iri[0]) })).otherwise(() => {
2469
2448
  throw new Error("Unknown primary expression type");
2470
2449
  });
2471
2450
  }
@@ -2473,7 +2452,7 @@ class Ln extends mn {
2473
2452
  return this.visit(t).value;
2474
2453
  }
2475
2454
  numericTokenLiteral(t, r) {
2476
- const i = Y(t);
2455
+ const i = K(t);
2477
2456
  return {
2478
2457
  type: "literal",
2479
2458
  value: t.image,
@@ -2489,382 +2468,378 @@ class Ln extends mn {
2489
2468
  return t.substring(3, t.length - 3).replace(/\\(.)/g, "$1");
2490
2469
  }
2491
2470
  }
2492
- let Un;
2493
- function Ce() {
2494
- return Un ?? (Un = new Ln());
2471
+ let mn;
2472
+ function ve() {
2473
+ return mn ??= new gn();
2495
2474
  }
2496
- function M(e, t) {
2475
+ function I(e, t) {
2497
2476
  t.forEach((r) => e.add(r));
2498
2477
  }
2499
- function F(e, t, r) {
2478
+ function B(e, t, r) {
2500
2479
  t.forEach((i) => {
2501
2480
  e.has(i) || r.add(i);
2502
2481
  });
2503
2482
  }
2504
- function Ut(e, t) {
2505
- p(e).with({ type: u.union("triple", "property", "class", "general") }, (r) => {
2506
- M(t, nt(r));
2483
+ function yt(e, t) {
2484
+ p(e).with({ type: l.union("triple", "property", "class", "general") }, (r) => {
2485
+ I(t, rt(r));
2507
2486
  }).with({ type: "filter" }, (r) => {
2508
- M(t, T(r.expression));
2487
+ I(t, w(r.expression));
2509
2488
  }).with({ type: "bind" }, (r) => {
2510
- M(t, T(r.expression)), t.add(r.variable);
2489
+ I(t, w(r.expression)), t.add(r.variable);
2511
2490
  }).with({ type: "skolem" }, (r) => {
2512
- r.args.forEach((i) => M(t, T(i)));
2491
+ r.args.forEach((i) => I(t, w(i)));
2513
2492
  }).with({ type: "negation" }, (r) => {
2514
- var s;
2515
2493
  const i = /* @__PURE__ */ new Set();
2516
- r.formulas.forEach((a) => Ut(a, i)), (s = r.existentialVars) == null || s.forEach((a) => i.delete(a)), M(t, [...i]);
2494
+ r.formulas.forEach((s) => yt(s, i)), r.existentialVars?.forEach((s) => i.delete(s)), I(t, [...i]);
2517
2495
  }).with({ type: "aggregate" }, (r) => {
2518
- var i, s;
2519
- r.atoms.forEach((a) => Ut(a, t)), (i = r.onVars) == null || i.forEach((a) => t.add(a)), (s = r.bindings) == null || s.forEach((a) => {
2520
- t.add(a.variable), a.expression !== "*" && M(t, T(a.expression)), a.secondExpression && M(t, T(a.secondExpression));
2496
+ r.atoms.forEach((i) => yt(i, t)), r.onVars?.forEach((i) => t.add(i)), r.bindings?.forEach((i) => {
2497
+ t.add(i.variable), i.expression !== "*" && I(t, w(i.expression)), i.secondExpression && I(t, w(i.secondExpression));
2521
2498
  });
2522
2499
  }).exhaustive();
2523
2500
  }
2524
- function Lr(e, t) {
2525
- p(e).with({ type: u.union("triple", "property", "class", "general") }, (r) => {
2526
- M(t, nt(r));
2501
+ function yr(e, t) {
2502
+ p(e).with({ type: l.union("triple", "property", "class", "general") }, (r) => {
2503
+ I(t, rt(r));
2527
2504
  }).with({ type: "skolem" }, (r) => {
2528
- const i = Zr(r);
2505
+ const i = Kr(r);
2529
2506
  i && t.add(i);
2530
- }).with({ type: u.union("bind", "filter", "negation", "aggregate") }, () => {
2507
+ }).with({ type: l.union("bind", "filter", "negation", "aggregate") }, () => {
2531
2508
  }).exhaustive();
2532
2509
  }
2533
- function wn(e, t, r, i) {
2534
- F(r, T(t), i), r.add(e);
2510
+ function yn(e, t, r, i) {
2511
+ B(r, w(t), i), r.add(e);
2535
2512
  }
2536
- function Ur(e, t, r) {
2537
- var o;
2513
+ function Lr(e, t, r) {
2538
2514
  const i = /* @__PURE__ */ new Set();
2539
- e.atoms.forEach((l) => Lr(l, i));
2515
+ e.atoms.forEach((a) => yr(a, i));
2540
2516
  const s = e.onVars ?? [];
2541
- s.forEach((l) => {
2542
- t.has(l) && i.add(l);
2543
- }), e.atoms.forEach((l) => Ar(l, i, r));
2544
- const a = /* @__PURE__ */ new Set();
2545
- e.atoms.forEach((l) => Ut(l, a)), s.forEach((l) => {
2546
- a.has(l) && i.has(l) ? t.add(l) : r.add(l);
2547
- }), (o = e.bindings) == null || o.forEach((l) => {
2548
- l.expression !== "*" && F(i, T(l.expression), r), l.secondExpression && F(i, T(l.secondExpression), r), t.add(l.variable);
2517
+ s.forEach((a) => {
2518
+ t.has(a) && i.add(a);
2519
+ }), e.atoms.forEach((a) => wr(a, i, r));
2520
+ const o = /* @__PURE__ */ new Set();
2521
+ e.atoms.forEach((a) => yt(a, o)), s.forEach((a) => {
2522
+ o.has(a) && i.has(a) ? t.add(a) : r.add(a);
2523
+ }), e.bindings?.forEach((a) => {
2524
+ a.expression !== "*" && B(i, w(a.expression), r), a.secondExpression && B(i, w(a.secondExpression), r), t.add(a.variable);
2549
2525
  });
2550
2526
  }
2551
- function wr(e, t, r) {
2527
+ function Ur(e, t, r) {
2552
2528
  const i = new Set(t);
2553
- M(i, e.existentialVars ?? []), e.formulas.forEach((s) => {
2554
- p(s).with({ type: "aggregate" }, (a) => {
2555
- var o;
2556
- F(i, a.onVars ?? [], r), F(i, ((o = a.bindings) == null ? void 0 : o.map(({ variable: l }) => l)) ?? [], r), Ur(a, i, r);
2557
- }).with({ type: "negation" }, (a) => {
2558
- wr(a, i, r);
2559
- }).otherwise((a) => {
2560
- const o = /* @__PURE__ */ new Set();
2561
- Ut(a, o), F(i, [...o], r);
2529
+ I(i, e.existentialVars ?? []), e.formulas.forEach((s) => {
2530
+ p(s).with({ type: "aggregate" }, (o) => {
2531
+ B(i, o.onVars ?? [], r), B(i, o.bindings?.map(({ variable: a }) => a) ?? [], r), Lr(o, i, r);
2532
+ }).with({ type: "negation" }, (o) => {
2533
+ Ur(o, i, r);
2534
+ }).otherwise((o) => {
2535
+ const a = /* @__PURE__ */ new Set();
2536
+ yt(o, a), B(i, [...a], r);
2562
2537
  });
2563
2538
  });
2564
2539
  }
2565
- function Ar(e, t, r) {
2566
- p(e).with({ type: u.union("triple", "property", "class", "general") }, () => {
2540
+ function wr(e, t, r) {
2541
+ p(e).with({ type: l.union("triple", "property", "class", "general") }, () => {
2567
2542
  }).with({ type: "filter" }, (i) => {
2568
- F(t, T(i.expression), r);
2543
+ B(t, w(i.expression), r);
2569
2544
  }).with({ type: "bind" }, (i) => {
2570
- wn(i.variable, i.expression, t, r);
2545
+ yn(i.variable, i.expression, t, r);
2571
2546
  }).with({ type: "skolem" }, (i) => {
2572
- i.args.slice(0, -1).forEach((s) => F(t, T(s), r));
2547
+ i.args.slice(0, -1).forEach((s) => B(t, w(s), r));
2573
2548
  }).with({ type: "negation" }, (i) => {
2574
- wr(i, t, r);
2575
- }).with({ type: "aggregate" }, (i) => {
2576
2549
  Ur(i, t, r);
2550
+ }).with({ type: "aggregate" }, (i) => {
2551
+ Lr(i, t, r);
2577
2552
  }).exhaustive();
2578
2553
  }
2579
- function An(e) {
2554
+ function Ln(e) {
2580
2555
  const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
2581
- return e.body.forEach((i) => Lr(i, t)), e.body.forEach((i) => Ar(i, t, r)), e.head.forEach((i) => F(t, nt(i), r)), [...r].sort();
2556
+ return e.body.forEach((i) => yr(i, t)), e.body.forEach((i) => wr(i, t, r)), e.head.forEach((i) => B(t, rt(i), r)), [...r].sort();
2582
2557
  }
2583
- function Tr(e, t) {
2558
+ function Ar(e, t) {
2584
2559
  const r = t(e);
2585
- return { ...Ce().visit(r), raw: e };
2560
+ return { ...ve().visit(r), raw: e };
2586
2561
  }
2587
- function Xe(e) {
2588
- return Tr(e, cr);
2562
+ function qe(e) {
2563
+ return Ar(e, ur);
2589
2564
  }
2590
- function bs(e) {
2591
- return { ...Tr(e, Mi), grounded: !0 };
2565
+ function Ts(e) {
2566
+ return { ...Ar(e, vi), grounded: !0 };
2592
2567
  }
2593
- function X(e) {
2568
+ function q(e) {
2594
2569
  return e !== void 0 && Number.isFinite(e) ? e : void 0;
2595
2570
  }
2596
- function Tn(e) {
2597
- const t = X(e.startOffset), r = X(e.endOffset);
2571
+ function Un(e) {
2572
+ const t = q(e.startOffset), r = q(e.endOffset);
2598
2573
  return { offset: t, endOffset: r === void 0 ? void 0 : r + 1 };
2599
2574
  }
2600
- function Sr(e) {
2601
- const t = be(e);
2575
+ function Tr(e) {
2576
+ const t = Re(e);
2602
2577
  if (t) return { ok: !1, issues: [t] };
2603
- const r = Re(e);
2578
+ const r = Ne(e);
2604
2579
  if (r.errors.length > 0)
2605
2580
  return {
2606
2581
  ok: !1,
2607
- issues: r.errors.map((o) => ({
2608
- message: o.message,
2609
- line: X(o.line),
2610
- column: X(o.column),
2611
- offset: o.offset,
2612
- endOffset: o.offset + o.length
2582
+ issues: r.errors.map((a) => ({
2583
+ message: a.message,
2584
+ line: q(a.line),
2585
+ column: q(a.column),
2586
+ offset: a.offset,
2587
+ endOffset: a.offset + a.length
2613
2588
  }))
2614
2589
  };
2615
- const i = Oe(e, r.tokens);
2590
+ const i = be(e, r.tokens);
2616
2591
  if (i) return { ok: !1, issues: [i] };
2617
- const s = ve();
2592
+ const s = xe();
2618
2593
  s.input = r.tokens;
2619
- const a = s.rule();
2594
+ const o = s.rule();
2620
2595
  if (s.errors.length > 0)
2621
2596
  return {
2622
2597
  ok: !1,
2623
- issues: s.errors.map((o) => ({
2624
- message: o.message,
2625
- line: X(o.token.startLine),
2626
- column: X(o.token.startColumn),
2627
- ...Tn(o.token)
2598
+ issues: s.errors.map((a) => ({
2599
+ message: a.message,
2600
+ line: q(a.token.startLine),
2601
+ column: q(a.token.startColumn),
2602
+ ...Un(a.token)
2628
2603
  }))
2629
2604
  };
2630
2605
  try {
2631
- return { ok: !0, rule: { ...Ce().visit(a), raw: e } };
2632
- } catch (o) {
2606
+ return { ok: !0, rule: { ...ve().visit(o), raw: e } };
2607
+ } catch (a) {
2633
2608
  return {
2634
2609
  ok: !1,
2635
- issues: [{ message: o instanceof Error ? o.message : "Invalid Datalog rule" }]
2610
+ issues: [{ message: a instanceof Error ? a.message : "Invalid Datalog rule" }]
2636
2611
  };
2637
2612
  }
2638
2613
  }
2639
- function Os(e) {
2640
- const t = Sr(e);
2641
- return t.ok ? { ok: !0, vocabulary: Vi(t.rule) } : t;
2614
+ function Ss(e) {
2615
+ const t = Tr(e);
2616
+ return t.ok ? { ok: !0, vocabulary: Di(t.rule) } : t;
2642
2617
  }
2643
- function Sn(e) {
2644
- if (be(e)) return;
2645
- const t = Re(e);
2646
- if (t.errors.length > 0 || Oe(e, t.tokens)) return;
2647
- const r = ve();
2618
+ function wn(e) {
2619
+ if (Re(e)) return;
2620
+ const t = Ne(e);
2621
+ if (t.errors.length > 0 || be(e, t.tokens)) return;
2622
+ const r = xe();
2648
2623
  r.input = t.tokens;
2649
2624
  const i = r.term();
2650
2625
  if (!(r.errors.length > 0 || !r.atEndOfInput))
2651
- return Ce().visit(i);
2626
+ return ve().visit(i);
2652
2627
  }
2653
- function He(e) {
2654
- const t = Sn(e), r = (t == null ? void 0 : t.type) === "iri" && !t.prefixed && !We(t.value);
2628
+ function Xe(e) {
2629
+ const t = wn(e), r = t?.type === "iri" && !t.prefixed && !Ke(t.value);
2655
2630
  return t && !r ? t : void 0;
2656
2631
  }
2657
- function xs(e, t) {
2658
- const r = He(e), i = He(t);
2632
+ function Ns(e, t) {
2633
+ const r = Xe(e), i = Xe(t);
2659
2634
  if (!(!r || !i))
2660
- return tr(r, i);
2635
+ return Je(r, i);
2661
2636
  }
2662
- function vs(e) {
2663
- const t = Sr(e);
2637
+ function Rs(e) {
2638
+ const t = Tr(e);
2664
2639
  if (!t.ok)
2665
2640
  return {
2666
2641
  valid: !1,
2667
2642
  error: t.issues.map(({ message: s }) => s).join("; ") || "Invalid Datalog rule"
2668
2643
  };
2669
- const r = An(t.rule);
2644
+ const r = Ln(t.rule);
2670
2645
  return r.length === 0 ? { valid: !0 } : {
2671
2646
  valid: !1,
2672
2647
  error: `Unbound variables ${r.map((s) => `?${s}`).join(", ")}. Bind each variable with a body atom, BIND, AGGREGATE, or SKOLEM, or declare negation-local variables with NOT EXIST ?variable IN (...). AGGREGATE ON variables must also occur in the aggregate body.`
2673
2648
  };
2674
2649
  }
2675
- function Cs(e, t) {
2650
+ function bs(e, t) {
2676
2651
  try {
2677
- const r = Xe(e), i = Xe(t);
2678
- return r.head.length !== i.head.length ? !1 : Qe(e) === Qe(t);
2652
+ const r = qe(e), i = qe(t);
2653
+ return r.head.length !== i.head.length ? !1 : He(e) === He(t);
2679
2654
  } catch {
2680
2655
  return !1;
2681
2656
  }
2682
2657
  }
2683
- function Qe(e) {
2658
+ function He(e) {
2684
2659
  return e.replace(/\s+/g, " ").replace(/\s*([(),[\]])\s*/g, "$1").replace(/\s*:-\s*/g, ":-").trim();
2685
2660
  }
2686
2661
  export {
2687
- wt as AGGREGATE,
2688
- he as AND,
2689
- K as AS,
2690
- sr as AT,
2691
- Xt as AVG,
2692
- z as BIND,
2693
- et as BLANK_NODE,
2694
- mn as BaseDatalogVisitor,
2695
- ar as COLON,
2696
- N as COMMA,
2697
- Ai as COMMENT,
2698
- Zt as CONCAT,
2699
- Gt as COUNT,
2700
- Qt as COUNT_MAX,
2701
- Ht as COUNT_MIN,
2702
- Ae as DECIMAL,
2703
- Ue as DEFAULT_NS_IRI,
2704
- ut as DISTINCT,
2705
- ge as DOT,
2706
- Te as DOUBLE,
2707
- Ln as DatalogAstBuilder,
2708
- xe as DatalogParser,
2709
- ae as EQUALS,
2710
- fe as EXCLAMATION,
2711
- $t as EXISTS,
2712
- vi as ExpandedDatalogParser,
2713
- se as FALSE,
2714
- Dt as FILTER,
2715
- ce as GREATER_THAN,
2716
- pe as GREATER_THAN_OR_EQUAL,
2717
- gt as HAT,
2718
- rt as IDENTIFIER,
2719
- te as IF,
2720
- Z as IN,
2721
- we as INTEGER,
2722
- ye as INTERNAL_FUNCTION,
2723
- ee as IRI,
2724
- me as IRI_REF,
2725
- Ne as LANGTAG,
2726
- Et as LBRACKET,
2727
- le as LESS_THAN,
2728
- ue as LESS_THAN_OR_EQUAL,
2729
- U as LPAREN,
2730
- Vt as MAX,
2731
- Yt as MAX_ARGMAX,
2732
- Kt as MAX_ARGMIN,
2733
- _t as MIN,
2734
- ht as MINUS,
2735
- Wt as MIN_ARGMAX,
2736
- zt as MIN_ARGMIN,
2737
- qt as MUL,
2738
- lt as NOT,
2739
- oe as NOT_EQUALS,
2740
- At as ON,
2741
- de as OR,
2742
- pt as PLUS,
2743
- st as PREFIXED_NAME,
2744
- Tt as PREFIX_ONLY,
2745
- ft as RBRACKET,
2746
- ie as REGEX,
2747
- re as ROUND,
2748
- w as RPAREN,
2749
- kt as RULE_ARROW,
2750
- ct as SKOLEM,
2751
- Ee as SLASH,
2752
- dt as STAR,
2753
- Jt as STR,
2754
- mt as STRING_LITERAL,
2755
- Se as STRING_LITERAL_LONG,
2756
- jt as SUM,
2757
- ne as TRUE,
2758
- b as VARIABLE,
2759
- Ti as WHITESPACE,
2760
- lr as allTokens,
2761
- Cs as areRulesEquivalent,
2762
- nr as assertNoGroundedTargets,
2763
- Ce as astBuilder,
2764
- ps as atomToDatalogText,
2765
- hn as beginTransaction,
2766
- ei as binaryOperandNeedsParentheses,
2767
- Ri as booleanLiteralTokenTypes,
2768
- Ni as builtinFunctionTokenTypes,
2769
- Qe as canonicalRuleText,
2770
- Ze as classAssertionFromAtom,
2771
- Ns as collectVariableTypeEvidence,
2772
- dn as commitTransaction,
2773
- pn as createConnection,
2774
- yi as datalogBodyToSparqlSelect,
2775
- rr as datatypeToTermText,
2776
- fn as deleteConnection,
2777
- gs as delimiterTokenTypes,
2778
- Ii as expandedParserInstance,
2779
- ws as explainInferenceFailure,
2780
- H as expressionToDatalogParts,
2781
- hs as expressionToDatalogText,
2782
- Os as extractRuleVocabulary,
2783
- Vi as extractRuleVocabularyFromAst,
2784
- hr as extractRuleVocabularyFromAtom,
2785
- us as extractVariables,
2786
- xt as formulaContainsSkolem,
2787
- Yn as getAggregateFunction,
2788
- zn as getAtomType,
2789
- Wn as getExpressionType,
2790
- cs as getRelatedVariables,
2791
- Kn as getTermType,
2792
- Pr as getVariablesFromAtom,
2793
- kr as getVariablesFromAtomIncludingGraph,
2794
- is as invertComparisonOperator,
2795
- Ke as iriBodyCharClass,
2796
- Es as iriTokenTypes,
2797
- Vn as isAggregateFormula,
2798
- ns as isBareNumericLiteral,
2799
- qn as isBinaryExpression,
2800
- _n as isBindFormula,
2801
- $n as isBlankNodeTerm,
2802
- er as isBooleanLiteral,
2803
- Fn as isClassAtom,
2804
- rs as isComparisonOperator,
2805
- Be as isDatalogAtom,
2806
- Qr as isDateLiteral,
2807
- zr as isDateTimeLiteral,
2808
- Gn as isFilterFormula,
2809
- We as isFullIri,
2810
- Qn as isFunctionCallExpression,
2811
- Pn as isGeneralAtom,
2812
- kn as isIriTerm,
2813
- tt as isLiteralTerm,
2814
- Jn as isLogicalOperator,
2815
- Dn as isNegationFormula,
2816
- Q as isNumericLiteral,
2817
- ss as isNumericLiteralTerm,
2818
- Zn as isNumericOperator,
2819
- Rt as isNumericRdfValue,
2820
- Bn as isPropertyAtom,
2821
- ts as isQueryableTermIri,
2822
- As as isReadOnlySparqlQuery,
2823
- jn as isSkolemFormula,
2824
- Hn as isTermExpression,
2825
- Mn as isTripleAtom,
2826
- Xn as isUnaryExpression,
2827
- I as isVariableTerm,
2828
- it as isXsdDatatype,
2829
- Si as keywordTokenTypes,
2830
- ls as literalSetComparisonFromExpression,
2831
- as as literalToDisplayText,
2832
- ds as numericLiteralTokenTypes,
2833
- fs as operatorTokenTypes,
2834
- es as parseBooleanLiteral,
2835
- Xe as parseDatalogRule,
2836
- Sr as parseDatalogRuleWithIssues,
2837
- Sn as parseDatalogTermText,
2838
- bs as parseGroundedDatalogRule,
2839
- Mi as parseGroundedRule,
2840
- cr as parseRule,
2841
- ur as parseRuleWith,
2842
- ve as parserInstance,
2843
- Xr as plainDecimalText,
2844
- Ye as positiveBodyContainsSkolem,
2845
- Je as propertyAssertionFromAtom,
2846
- Rs as resolveVariableTypes,
2847
- En as rollbackTransaction,
2848
- Kr as simpleComparisonFromExpression,
2849
- os as simpleComparisonFromFilter,
2850
- Zr as skolemMintedVariable,
2851
- bi as stringLiteralTokenTypes,
2852
- xs as termTextsEqual,
2853
- x as termToDatalogText,
2854
- Ls as termToSparql,
2855
- ms as termTokenTypes,
2856
- tr as termsEqual,
2857
- Re as tokenizeDatalog,
2858
- ri as unaryOperandNeedsParentheses,
2859
- G as unwrapTermExpression,
2860
- Ts as validateDataManipulationUpdate,
2861
- vs as validateDatalogRule,
2862
- ys as validateRuleSyntax,
2863
- sn as validateSparqlQuery,
2864
- Yr as variableNameFromTermExpression,
2865
- nt as variableNamesFromAtom,
2866
- T as variableNamesFromExpression,
2867
- Us as verifyRuleInference,
2868
- Ss as withTransaction,
2869
- j as xsdDatatypes
2662
+ Lt as AGGREGATE,
2663
+ pe as AND,
2664
+ z as AS,
2665
+ nr as AT,
2666
+ qt as AVG,
2667
+ Q as BIND,
2668
+ J as BLANK_NODE,
2669
+ En as BaseDatalogVisitor,
2670
+ sr as COLON,
2671
+ S as COMMA,
2672
+ Li as COMMENT,
2673
+ Yt as CONCAT,
2674
+ Dt as COUNT,
2675
+ Ht as COUNT_MAX,
2676
+ Xt as COUNT_MIN,
2677
+ we as DECIMAL,
2678
+ Le as DEFAULT_NS_IRI,
2679
+ ot as DISTINCT,
2680
+ fe as DOT,
2681
+ Ae as DOUBLE,
2682
+ gn as DatalogAstBuilder,
2683
+ Oe as DatalogParser,
2684
+ se as EQUALS,
2685
+ Ee as EXCLAMATION,
2686
+ kt as EXISTS,
2687
+ bi as ExpandedDatalogParser,
2688
+ ne as FALSE,
2689
+ $t as FILTER,
2690
+ ue as GREATER_THAN,
2691
+ ce as GREATER_THAN_OR_EQUAL,
2692
+ Et as HAT,
2693
+ tt as IDENTIFIER,
2694
+ Jt as IF,
2695
+ W as IN,
2696
+ Ue as INTEGER,
2697
+ me as INTERNAL_FUNCTION,
2698
+ te as IRI,
2699
+ ge as IRI_REF,
2700
+ Se as LANGTAG,
2701
+ ht as LBRACKET,
2702
+ oe as LESS_THAN,
2703
+ le as LESS_THAN_OR_EQUAL,
2704
+ L as LPAREN,
2705
+ _t as MAX,
2706
+ Wt as MAX_ARGMAX,
2707
+ zt as MAX_ARGMIN,
2708
+ Gt as MIN,
2709
+ ct as MINUS,
2710
+ Kt as MIN_ARGMAX,
2711
+ Qt as MIN_ARGMIN,
2712
+ jt as MUL,
2713
+ at as NOT,
2714
+ ae as NOT_EQUALS,
2715
+ Ut as ON,
2716
+ he as OR,
2717
+ ut as PLUS,
2718
+ it as PREFIXED_NAME,
2719
+ wt as PREFIX_ONLY,
2720
+ dt as RBRACKET,
2721
+ re as REGEX,
2722
+ ee as ROUND,
2723
+ U as RPAREN,
2724
+ Pt as RULE_ARROW,
2725
+ lt as SKOLEM,
2726
+ de as SLASH,
2727
+ pt as STAR,
2728
+ Zt as STR,
2729
+ ft as STRING_LITERAL,
2730
+ Te as STRING_LITERAL_LONG,
2731
+ Vt as SUM,
2732
+ ie as TRUE,
2733
+ N as VARIABLE,
2734
+ Ui as WHITESPACE,
2735
+ or as allTokens,
2736
+ bs as areRulesEquivalent,
2737
+ ir as assertNoGroundedTargets,
2738
+ ve as astBuilder,
2739
+ os as atomToDatalogText,
2740
+ un as beginTransaction,
2741
+ Zr as binaryOperandNeedsParentheses,
2742
+ Ti as booleanLiteralTokenTypes,
2743
+ Ai as builtinFunctionTokenTypes,
2744
+ He as canonicalRuleText,
2745
+ Ye as classAssertionFromAtom,
2746
+ ws as collectVariableTypeEvidence,
2747
+ cn as commitTransaction,
2748
+ ln as createConnection,
2749
+ fi as datalogBodyToSparqlSelect,
2750
+ er as datatypeToTermText,
2751
+ hn as deleteConnection,
2752
+ hs as delimiterTokenTypes,
2753
+ xi as expandedParserInstance,
2754
+ ms as explainInferenceFailure,
2755
+ X as expressionToDatalogParts,
2756
+ ls as expressionToDatalogText,
2757
+ Ss as extractRuleVocabulary,
2758
+ Di as extractRuleVocabularyFromAst,
2759
+ pr as extractRuleVocabularyFromAtom,
2760
+ ss as extractVariables,
2761
+ Ot as formulaContainsSkolem,
2762
+ Qn as getAggregateFunction,
2763
+ qn as getAtomType,
2764
+ Hn as getExpressionType,
2765
+ as as getRelatedVariables,
2766
+ Xn as getTermType,
2767
+ Mr as getVariablesFromAtom,
2768
+ Br as getVariablesFromAtomIncludingGraph,
2769
+ Jn as invertComparisonOperator,
2770
+ ze as iriBodyCharClass,
2771
+ cs as iriTokenTypes,
2772
+ $n as isAggregateFormula,
2773
+ ts as isBareNumericLiteral,
2774
+ Gn as isBinaryExpression,
2775
+ kn as isBindFormula,
2776
+ Bn as isBlankNodeTerm,
2777
+ tr as isBooleanLiteral,
2778
+ Cn as isClassAtom,
2779
+ Zn as isComparisonOperator,
2780
+ Me as isDatalogAtom,
2781
+ qr as isDateLiteral,
2782
+ Xr as isDateTimeLiteral,
2783
+ Pn as isFilterFormula,
2784
+ Ke as isFullIri,
2785
+ jn as isFunctionCallExpression,
2786
+ In as isGeneralAtom,
2787
+ Mn as isIriTerm,
2788
+ Z as isLiteralTerm,
2789
+ Kn as isLogicalOperator,
2790
+ Fn as isNegationFormula,
2791
+ H as isNumericLiteral,
2792
+ es as isNumericLiteralTerm,
2793
+ zn as isNumericOperator,
2794
+ Nt as isNumericRdfValue,
2795
+ vn as isPropertyAtom,
2796
+ Wn as isQueryableTermIri,
2797
+ ys as isReadOnlySparqlQuery,
2798
+ Dn as isSkolemFormula,
2799
+ Vn as isTermExpression,
2800
+ xn as isTripleAtom,
2801
+ _n as isUnaryExpression,
2802
+ v as isVariableTerm,
2803
+ et as isXsdDatatype,
2804
+ wi as keywordTokenTypes,
2805
+ ns as literalSetComparisonFromExpression,
2806
+ rs as literalToDisplayText,
2807
+ us as numericLiteralTokenTypes,
2808
+ ps as operatorTokenTypes,
2809
+ Yn as parseBooleanLiteral,
2810
+ qe as parseDatalogRule,
2811
+ Tr as parseDatalogRuleWithIssues,
2812
+ wn as parseDatalogTermText,
2813
+ Ts as parseGroundedDatalogRule,
2814
+ vi as parseGroundedRule,
2815
+ ur as parseRule,
2816
+ lr as parseRuleWith,
2817
+ xe as parserInstance,
2818
+ Vr as plainDecimalText,
2819
+ We as positiveBodyContainsSkolem,
2820
+ Ze as propertyAssertionFromAtom,
2821
+ As as resolveVariableTypes,
2822
+ pn as rollbackTransaction,
2823
+ Hr as simpleComparisonFromExpression,
2824
+ is as simpleComparisonFromFilter,
2825
+ Kr as skolemMintedVariable,
2826
+ Si as stringLiteralTokenTypes,
2827
+ Ns as termTextsEqual,
2828
+ b as termToDatalogText,
2829
+ fs as termToSparql,
2830
+ ds as termTokenTypes,
2831
+ Je as termsEqual,
2832
+ Ne as tokenizeDatalog,
2833
+ Jr as unaryOperandNeedsParentheses,
2834
+ D as unwrapTermExpression,
2835
+ Ls as validateDataManipulationUpdate,
2836
+ Rs as validateDatalogRule,
2837
+ Es as validateRuleSyntax,
2838
+ en as validateSparqlQuery,
2839
+ zr as variableNameFromTermExpression,
2840
+ rt as variableNamesFromAtom,
2841
+ w as variableNamesFromExpression,
2842
+ gs as verifyRuleInference,
2843
+ Us as withTransaction,
2844
+ V as xsdDatatypes
2870
2845
  };