@omgbase/oqx 0.20.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +65 -0
- package/dist/ast.d.ts +20 -2
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js +11 -1
- package/dist/ast.js.map +1 -1
- package/dist/build.d.ts +4 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +3 -0
- package/dist/build.js.map +1 -1
- package/dist/engine.d.ts +1 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +45 -3
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.d.ts.map +1 -1
- package/dist/lexer.js +92 -5
- package/dist/lexer.js.map +1 -1
- package/dist/optimize/analysis.d.ts.map +1 -1
- package/dist/optimize/analysis.js +8 -1
- package/dist/optimize/analysis.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +58 -5
- package/dist/parser.js.map +1 -1
- package/dist/print.js +36 -17
- package/dist/print.js.map +1 -1
- package/dist/references.d.ts +26 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +225 -0
- package/dist/references.js.map +1 -0
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +4 -0
- package/dist/resolve.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walk.d.ts.map +1 -1
- package/dist/walk.js +8 -3
- package/dist/walk.js.map +1 -1
- package/package.json +1 -1
- package/src/ast.ts +31 -3
- package/src/build.ts +4 -1
- package/src/engine.ts +40 -3
- package/src/index.ts +3 -1
- package/src/lexer.ts +86 -10
- package/src/optimize/analysis.ts +9 -1
- package/src/parser.ts +51 -6
- package/src/print.ts +34 -7
- package/src/references.ts +238 -0
- package/src/resolve.ts +4 -0
- package/src/version.ts +1 -1
- package/src/walk.ts +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,23 @@ All notable changes to `@omgbase/oqx` are recorded here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
|
|
5
5
|
[Semantic Versioning](https://semver.org/) (pre-1.0: a minor bump may break).
|
|
6
6
|
|
|
7
|
+
## [0.23.0] - 2026-10-13
|
|
8
|
+
|
|
9
|
+
### Minor
|
|
10
|
+
- **OQX 0.23 — the `references` static pass** (`spec/oqx` 0.22 → 0.23; `AST.md` §5b; new suite `references` (27 cases): 1350 → 1377 fixtures; new fixture kind `expect.references`). `references(query)` lists every **name a query reads from a row** — a bare identifier, a dotted navigation headed by one (one reference, the full path: `doc.layer`, `meta.owner`), an outer reference (`^title`, `1^title`; `$it` heads dropped) — in canonical source order, each as `{ name, clause, scope: { depth, steps }, span }`. `scope.steps` is the row chain producing the scope's rows, root first with the depth each step produces: the source, a body's `from`, a block's receiver (one deeper), a `follow` node (the walk's frontier rows, which destinations are read on); an outer reference's steps are cut at its depth; the empty list is the root scope (the source head `from people` is reported there with depth 0). Not references: `$`-names, bindings, function/method names (the receiver and arguments are), projection keys, a `select` alias where the language substitutes it (the same body's `where`; items to its right — an alias's own name inside its own item is the row field; `order by`/`frontier`/`limit`/`offset`/`from`/`follow` are never rewritten, so a name there is a reference), and the trailing members of a navigation headed by a value (`refs(before).title` references `before` only). The pass is host-agnostic and knows no data: a host maps each scope to a row type and judges the name (omgbase's "unknown names" hints and errors, spec/surface 4.6, are built on it). Grammar, semantics and AST shape are unchanged. `LANGUAGE_VERSION` 0.23.
|
|
11
|
+
- `@omgbase/oqx-syntax`: `LANGUAGE_VERSION` 0.23 (no lexical change).
|
|
12
|
+
|
|
13
|
+
## [0.22.0] - 2026-10-13
|
|
14
|
+
|
|
15
|
+
### Minor
|
|
16
|
+
- **OQX 0.22 — infix regex operators** (`spec/oqx` 0.21 → 0.22; new suite `regex-operators` (40 cases): 1310 → 1350 fixtures). Four operators at comparison precedence, pure sugar over `matches` (SEMANTICS §11): `a ~ b` ≡ `a.matches(b)`, `a ~* b` ≡ `a.matches(b, "i")`, `a !~ b` ≡ `!a.matches(b)`, `a !~* b` ≡ `!a.matches(b, "i")` — the PostgreSQL spellings, so `uri ~ "newton"` is no longer `unexpected character "~"`. Every rule of `matches` carries over: unanchored unless the pattern anchors, case-sensitive except under `~*`, string forms for a number receiver or pattern, either side any expression (`title ~ pattern` is field-vs-field), the OQX regex baseline (a construct outside it is rejected by name, a malformed pattern is `invalid regular expression`, raised when evaluated). **Absent follows OQX, not SQL**: `absent ~ "x"` is false, so `absent !~ "x"` is **true** (Postgres would yield NULL for both). Non-associative like the rest of the level (`a ~ b ~ c`, `a ~ b == c` are `comparisons do not chain`); `!`/`not` bind tighter, so `not a ~ b` is `(!a) ~ b` — write `a !~ b` or `not (a ~ b)`. Lexer: `!~*`, `!~`, `~*`, `~` are single tokens scanned longest first (`!~` wins over `!`, so `name!~"B"` is `name !~ "B"`; `~*` wins over `~`, so `x~*y` is `x ~* y`; `*` alone is still multiplication). **AST**: the operators are `binary` nodes carrying the operator as written (`op: "~" | "~*" | "!~" | "!~*"`; `RegexOp`, `REGEX_OPS`, `isRegexOp` exported) — not desugared in the tree, so `print` writes `a ~ b` back and the round-trip law holds over every fixture; evaluation goes through the same method dispatch as `.matches(…)`, so a host's `matches` and its `regexDialect` apply. Planners: a regex operator is never translated to SQL (the SQLite adapter leaves it residual, as it leaves the call) and is never raise-free (`exprRaiseFree`). `LANGUAGE_VERSION` 0.22.
|
|
17
|
+
|
|
18
|
+
## [0.21.0] - 2026-10-13
|
|
19
|
+
|
|
20
|
+
### Minor
|
|
21
|
+
- **OQX 0.21 — template literals** (`spec/oqx` 0.20 → 0.21; new suite `template-literals` (50 cases) + 2 in `errors-eval`: 1258 → 1310 fixtures). `` `text ${expr} text` `` is a backtick-delimited **string value** with `${…}` interpolations, usable wherever a value stands — a `select` item (`` label: `${title} (${era})` ``), a `where` operand, an `order by` key, a function argument or method receiver, the haystack of `in`, a nested block's item reading the enclosing row (`` jobs collect { label: `${^title}: ${employer}` values } ``). Semantics (SEMANTICS §7b): the text and each interpolated value's **string form** (§7: a number without a fraction when integer-valued, `true`/`false` as the words) concatenated; **absent propagates** — any absent interpolation makes the whole literal absent, as `+` does; **a list, a record or a range cannot be interpolated** — an eval error `cannot interpolate … it is a list / a record / a range` (where `+` leaves such operands unspecified, a template literal refuses them); every interpolation is evaluated, in order, before the result is decided. Lexically (GRAMMAR §1, §4): the text decodes with the **same escapes as a string** (`\n` `\t` `\r` `\0`, `\<c>` for any other `<c>` — so `` \` `` keeps a backtick, `\$` a dollar that opens nothing, `\\` a backslash); **newlines are kept verbatim** (a literal may span lines); a `$` not followed by `{`, braces outside an interpolation and quotes are text; an interpolation holds one full expression with **balanced braces**, so it may hold a `{ … }` block (`` `${jobs single { employer values where primary }}` ``) or another template literal, to any depth, read at the enclosing scope depth (`^`, `N^` as usual). Errors: `unterminated template literal at N` and `` unterminated ${…} interpolation … `` are lex errors; `` empty interpolation `${}` `` (offset of the `${`) and `expected '}' to close the `${…}` interpolation` are parse errors; a template literal is a literal — not a receiver, not a bracket receiver, and an unaliased item needs an alias. **Bindings**: a tagged-template fragment that ends inside a backtick literal is the lex error `unterminated template literal … a ${…} binding cannot stand inside a backtick literal` (fragments lex independently). **AST** (AST.md): new node `template { parts: (string | Expr)[] }` with `parts` strictly alternating decoded text strings and expressions (odd length, text first and last: `` `${a}` `` is `["", a, ""]`); the text parts are plain strings, not nodes — `visit`/`transform` skip them; `CHILDREN.template = [parts]`; `isExpr` true; `build.template(parts)`; a `template` node spans its backticks, each interpolated expression itself. **Printer**: a template literal prints as one, its text escaped (`\\`, `` \` ``, `\$` before a `{`, the control escapes) and each interpolation as `${…}`; round-trip law holds over every fixture. Lexer: new token types `tmpl_start` / `tmpl_text` / `tmpl_interp_start` / `tmpl_interp_end` / `tmpl_end`, a mode stack per fragment; the backtick is no longer an `unexpected character`. Planners: the SQLite adapter leaves a template residual (not translatable); `exprRaiseFree` is false for a literal with an interpolation (the data decides whether it raises). `LANGUAGE_VERSION` 0.21.
|
|
22
|
+
- `@omgbase/oqx-syntax`: `LANGUAGE_VERSION` 0.21; new token classes `template` (`string.template.oqx`) and `interpolation` (`punctuation.section.interpolation.oqx`); every grammar enters a template state at the backtick, re-enters the language at `${` and tracks the braces of the interpolation (TextMate begin/end rules `template` / `template-interpolation` / `template-block`, Monarch states `template` / `templateInterpolation` / `templateBlock`, a mode stack in the CodeMirror stream state, a Prism `template` token whose interpolations re-enter the grammar through `rest`, braces balanced to three levels); the backtick left `ILLEGAL_CHARACTERS`; `TEMPLATE` / `TEMPLATE_LITERAL` exported; backtick auto-closing pairs; assets regenerated; parity over every fixture.
|
|
23
|
+
|
|
7
24
|
## [0.20.0] - 2026-10-11
|
|
8
25
|
|
|
9
26
|
### Minor
|
package/README.md
CHANGED
|
@@ -375,6 +375,18 @@ oqx`name from ${people} where tags.contains("admin")`; // array membership
|
|
|
375
375
|
written in the **OQX regex baseline** (below), unanchored unless the pattern
|
|
376
376
|
anchors. `flags` is an optional string of `i` (case-insensitive), `m` (`^`/`$`
|
|
377
377
|
also at newlines), `s` (`.` also matches `\n`); an absent receiver is `false`.
|
|
378
|
+
- The **infix regex operators** (0.22) are sugar over `matches` at comparison
|
|
379
|
+
precedence: `a ~ b` is `a.matches(b)`, `a ~* b` is `a.matches(b, "i")`,
|
|
380
|
+
`a !~ b` and `a !~* b` are their negations. Either side is any expression
|
|
381
|
+
(`title ~ pattern`). An absent receiver is `false` under `~` and therefore
|
|
382
|
+
`true` under `!~` — OQX's absent, not SQL's NULL. `!`/`not` bind tighter
|
|
383
|
+
(`not a ~ b` is `(!a) ~ b`; write `a !~ b` or `not (a ~ b)`).
|
|
384
|
+
|
|
385
|
+
```js
|
|
386
|
+
oqx`name from ${people} where title ~ "^Eng"`; // → Bob
|
|
387
|
+
oqx`name from ${people} where title ~* "director"`; // → Alice
|
|
388
|
+
oqx`name from ${people} where title !~ "Eng"`; // → Alice, Carol
|
|
389
|
+
```
|
|
378
390
|
|
|
379
391
|
Anything not in these tables is an **eval error** (`unknown function 'f(…)'` /
|
|
380
392
|
`unknown method '.m(…)'`) — see [custom functions](#custom-functions-and-methods)
|
|
@@ -723,6 +735,33 @@ oqx`n: (mom, dad, siblings) { name values } from ${people}`; // one block
|
|
|
723
735
|
oqx`id from ${g} follow (before, after) { depth 2 }`; // one destination over the union
|
|
724
736
|
```
|
|
725
737
|
|
|
738
|
+
### 9c. Template literals (0.21)
|
|
739
|
+
|
|
740
|
+
`` `text ${expr} text` `` is a string value: the text and each interpolated
|
|
741
|
+
value's **string form** (numbers without a fraction when integer-valued,
|
|
742
|
+
booleans as the words) concatenated. It stands wherever a value does — a
|
|
743
|
+
`select` item, a `where` operand, an `order by` key, a function argument, a
|
|
744
|
+
method receiver. The text decodes with the same escapes as a string (`` \` ``
|
|
745
|
+
keeps a backtick, `\$` a dollar that opens nothing); newlines are kept, so a
|
|
746
|
+
literal may span lines. An interpolation holds any expression with balanced
|
|
747
|
+
braces — a `{ … }` block or another template literal included.
|
|
748
|
+
|
|
749
|
+
```js
|
|
750
|
+
oqx`label: \`\${title} (\${era})\` from ${docs}`; // "Alpha (3)"
|
|
751
|
+
oqx`x: \`\${jobs single { employer values where primary }}\` from ${docs}`; // the block's one value
|
|
752
|
+
oqx`title from ${docs} where \`\${title}!\` == "Alpha!"`;
|
|
753
|
+
oqx`x: jobs collect { label: \`\${^title}: \${employer}\` values } from ${docs}`; // `^` reads the enclosing row
|
|
754
|
+
```
|
|
755
|
+
|
|
756
|
+
Two rules keep it honest: **absent propagates** — any absent interpolation makes
|
|
757
|
+
the whole literal absent (as `+` does), never `"undefined"` — and **a list, a
|
|
758
|
+
record or a range cannot be interpolated**: that is an eval error (`cannot
|
|
759
|
+
interpolate …`), not a silent `[object Object]`. Inside a JavaScript tagged
|
|
760
|
+
template write the backticks and `${` escaped as above (`` \` ``, `\${`), or
|
|
761
|
+
pass the whole query as a string: a `${…}` *binding* can stand beside a template
|
|
762
|
+
literal but never inside one (a fragment that ends inside the literal is an
|
|
763
|
+
unterminated-literal error).
|
|
764
|
+
|
|
726
765
|
### 10. Sugar (0.17)
|
|
727
766
|
|
|
728
767
|
Every form below is shorthand for an explicit directive — it **desugars in the
|
|
@@ -805,6 +844,7 @@ follow before, after / follow (before, after) several destinations: the union
|
|
|
805
844
|
follow ^people { where manager == ^id } a destination block: successors computed per frontier row (`^` = that row; `collect` implicit, 0.20)
|
|
806
845
|
$key / $key: expr the identity a row is known by (the host's, else structural) / give the rows a block yields that identity
|
|
807
846
|
(a, b) / rel distinct { … } a tuple: the elements, one level flat (a value and a receiver) / collect distinct (0.20)
|
|
847
|
+
`${title} (${era})` a template literal: text + string forms; absent anywhere → absent; a list/record → error (0.21)
|
|
808
848
|
obj { title } one object → one record (or absent); a collection → a list; a scalar → an error (0.20)
|
|
809
849
|
${source} <collect|exists|none|count|first|single> { … } whole-query consumer
|
|
810
850
|
```
|
|
@@ -881,6 +921,29 @@ defaults (`build.query(source, { select, where, … })`, `build.op(receiver,
|
|
|
881
921
|
`build.follow`, `build.ident`, `build.lit`, `build.binary`, `build.and`, …), so
|
|
882
922
|
a tree you assemble prints with `print` and has the shape of a parsed one.
|
|
883
923
|
|
|
924
|
+
`references(query)` (0.23, `spec/oqx/AST.md` §5b) lists every **name the query
|
|
925
|
+
reads from a row**, in source order, with the clause it stands in and the scope
|
|
926
|
+
it is read from — so a host that knows what rows an expression yields can say
|
|
927
|
+
which names exist there:
|
|
928
|
+
|
|
929
|
+
```ts
|
|
930
|
+
references(parse('select title, age from docs where blocks exists { where text == ^titel }'));
|
|
931
|
+
// [ { name: "title", clause: "select", scope: { depth: 1, steps: [{ expr: <docs>, depth: 1 }] }, span: [7, 12] },
|
|
932
|
+
// { name: "age", clause: "select", scope: { depth: 1, steps: [<docs>@1] }, … },
|
|
933
|
+
// { name: "docs", clause: "source", scope: { depth: 0, steps: [] }, … }, // a root name
|
|
934
|
+
// { name: "blocks", clause: "where", scope: { depth: 1, steps: [<docs>@1] }, … },
|
|
935
|
+
// { name: "text", clause: "where", scope: { depth: 2, steps: [<docs>@1, <blocks>@2] }, … },
|
|
936
|
+
// { name: "titel", clause: "where", scope: { depth: 1, steps: [<docs>@1] }, … } ] // ^titel: the enclosing row
|
|
937
|
+
```
|
|
938
|
+
|
|
939
|
+
A dotted navigation headed by a name is one reference with its full path
|
|
940
|
+
(`meta.owner`, `doc.layer`); `$it.x` is `x`; a `follow` node is a step (the
|
|
941
|
+
walk's frontier rows). Not references: `$`-names, bindings, function and
|
|
942
|
+
method names (their receiver and arguments are), an item's alias where the
|
|
943
|
+
language substitutes it (the same body's `where`, later items), and the members
|
|
944
|
+
of a navigation headed by a value (`refs(before).title` references `before`
|
|
945
|
+
alone).
|
|
946
|
+
|
|
884
947
|
## Data context: string queries and named roots
|
|
885
948
|
|
|
886
949
|
When you don't need interpolation, `execute` runs a plain string query against a
|
|
@@ -1260,6 +1323,8 @@ adapter lives on the `@omgbase/oqx/sqlite` subpath.
|
|
|
1260
1323
|
`{ strings, count, indices }`).
|
|
1261
1324
|
- `resolveAliases(query)` — the `select`-alias substitution the entry points
|
|
1262
1325
|
apply before evaluation (SEMANTICS §14).
|
|
1326
|
+
- `references(query)` — every name the query reads from a row, with its
|
|
1327
|
+
clause and scope (`Reference`, `ReferenceScope`, `ReferenceStep`; AST.md §5b).
|
|
1263
1328
|
- `toJSON(query)` — the tree stamped with `oqx: LANGUAGE_VERSION`; `stripSpans(node)`
|
|
1264
1329
|
— the tree without spans (`Stripped<T>`); `toUtf16(span, source)` and
|
|
1265
1330
|
`codePointLength(s)` — code-point ↔ UTF-16 offsets; `rawSource(strings)` —
|
package/dist/ast.d.ts
CHANGED
|
@@ -9,12 +9,26 @@ export type Consumer = "collect" | "exists" | "none" | "count" | "first" | "sing
|
|
|
9
9
|
export type RelOp = "==" | "!=" | "<" | "<=" | ">" | ">=";
|
|
10
10
|
/** The identity operators (SEMANTICS §5b, since 0.17). */
|
|
11
11
|
export type IdentityOp = "is" | "is not";
|
|
12
|
-
/** The
|
|
13
|
-
|
|
12
|
+
/** The infix regex operators (SEMANTICS §11, since 0.22): sugar over `matches` —
|
|
13
|
+
* `a ~ b` ≡ `a.matches(b)`, `a ~* b` ≡ `a.matches(b, "i")`, `a !~ b` ≡
|
|
14
|
+
* `!a.matches(b)`, `a !~* b` ≡ `!a.matches(b, "i")`. The tree keeps the
|
|
15
|
+
* operator as written so the canonical print is what the user wrote. */
|
|
16
|
+
export type RegexOp = "~" | "~*" | "!~" | "!~*";
|
|
17
|
+
/** The operator of a `binary` expression: a comparison, an identity test, a regex match, or arithmetic. */
|
|
18
|
+
export type BinaryOp = RelOp | IdentityOp | RegexOp | "+" | "-" | "*" | "/" | "%";
|
|
19
|
+
/** The regex operators, with the `matches` call each stands for. */
|
|
20
|
+
export declare const REGEX_OPS: Readonly<Record<RegexOp, {
|
|
21
|
+
negated: boolean;
|
|
22
|
+
flags: string | undefined;
|
|
23
|
+
}>>;
|
|
24
|
+
export declare function isRegexOp(op: string): op is RegexOp;
|
|
14
25
|
/** The operator of a `unary` expression. */
|
|
15
26
|
export type UnaryOp = "!" | "-";
|
|
16
27
|
/** The operator of a `logical` expression. */
|
|
17
28
|
export type LogicalOp = "&&" | "||";
|
|
29
|
+
/** One part of a template literal (since 0.21): a decoded text run, or an
|
|
30
|
+
* interpolated expression. The strings are not nodes (no `kind`, no span). */
|
|
31
|
+
export type TemplatePart = string | Expr;
|
|
18
32
|
/** Scalar value/predicate expression, evaluated against a row scope + bindings. */
|
|
19
33
|
export type Expr = {
|
|
20
34
|
kind: "lit";
|
|
@@ -80,6 +94,10 @@ export type Expr = {
|
|
|
80
94
|
kind: "tuple";
|
|
81
95
|
span: Span;
|
|
82
96
|
items: Expr[];
|
|
97
|
+
} | {
|
|
98
|
+
kind: "template";
|
|
99
|
+
span: Span;
|
|
100
|
+
parts: TemplatePart[];
|
|
83
101
|
} | OpNode;
|
|
84
102
|
/** One `order by` term. */
|
|
85
103
|
export interface OrderSpec {
|
package/dist/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAaA;;kFAEkF;AAClF,MAAM,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAEhD;kFACkF;AAClF,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEpF,sEAAsE;AACtE,MAAM,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;AAE1D,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,QAAQ,CAAC;AAEzC,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAaA;;kFAEkF;AAClF,MAAM,MAAM,IAAI,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAEhD;kFACkF;AAClF,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEpF,sEAAsE;AACtE,MAAM,MAAM,KAAK,GAAG,IAAI,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC;AAE1D,0DAA0D;AAC1D,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,QAAQ,CAAC;AAEzC;;;wEAGwE;AACxE,MAAM,MAAM,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAEhD,2GAA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G,IAAI,CAAC;IACpB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAC5B,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB;;;6BAGyB;IACzB,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB,gFAAgF;IAChF,QAAQ,EAAE,OAAO,CAAC;IAClB,wDAAwD;IACxD,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,IAAI,GAAG,IAAI,CAAC;CACrB;AAED,iFAAiF;AACjF,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,KAAK,GAAG,IAAI,CAAC;AAEjG,oCAAoC;AACpC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAOtC;wDACwD;AACxD,wBAAgB,MAAM,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,IAAI,CAElD;AAED;4BAC4B;AAC5B,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/ast.js
CHANGED
|
@@ -10,9 +10,19 @@
|
|
|
10
10
|
// bare identifier here; `resolveAliases` (resolve.ts) performs the substitution
|
|
11
11
|
// before evaluation. Nodes built by a tool rather than the parser carry the
|
|
12
12
|
// empty span `[0, 0]` (see `build.ts`).
|
|
13
|
+
/** The regex operators, with the `matches` call each stands for. */
|
|
14
|
+
export const REGEX_OPS = {
|
|
15
|
+
"~": { negated: false, flags: undefined },
|
|
16
|
+
"~*": { negated: false, flags: "i" },
|
|
17
|
+
"!~": { negated: true, flags: undefined },
|
|
18
|
+
"!~*": { negated: true, flags: "i" },
|
|
19
|
+
};
|
|
20
|
+
export function isRegexOp(op) {
|
|
21
|
+
return Object.hasOwn(REGEX_OPS, op);
|
|
22
|
+
}
|
|
13
23
|
/** The expression kinds (`Expr["kind"]`), for `isExpr`. */
|
|
14
24
|
const EXPR_KINDS = new Set([
|
|
15
|
-
"lit", "ident", "outer", "binding", "member", "call", "unary", "required", "binary", "logical", "in", "range", "tuple",
|
|
25
|
+
"lit", "ident", "outer", "binding", "member", "call", "unary", "required", "binary", "logical", "in", "range", "tuple", "template",
|
|
16
26
|
]);
|
|
17
27
|
/** Whether a node is a scalar `Expr` (an `op` in expression position is not: it
|
|
18
28
|
* is an expression only by position, see AST.md §1). */
|
package/dist/ast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,gFAAgF;AAChF,wDAAwD;AACxD,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,4EAA4E;AAC5E,wCAAwC;
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../src/ast.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,gFAAgF;AAChF,+EAA+E;AAC/E,2EAA2E;AAC3E,gFAAgF;AAChF,wDAAwD;AACxD,EAAE;AACF,iFAAiF;AACjF,gFAAgF;AAChF,4EAA4E;AAC5E,wCAAwC;AA0BxC,oEAAoE;AACpE,MAAM,CAAC,MAAM,SAAS,GAA+E;IACnG,GAAG,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE;IACzC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE;IACpC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE;IACzC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE;CACrC,CAAC;AAEF,MAAM,UAAU,SAAS,CAAC,EAAU;IAClC,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AA8KD,2DAA2D;AAC3D,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IAC9C,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU;CACnI,CAAC,CAAC;AAEH;wDACwD;AACxD,MAAM,UAAU,MAAM,CAAC,IAAa;IAClC,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/build.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BinaryOp, Consumer, CountCmp, Expr, Follow, FollowDestination, LogicalOp, OpNode, OrderSpec, Query, SelectItem, Span, Subquery, UnaryOp, Where } from "./ast.js";
|
|
1
|
+
import type { BinaryOp, Consumer, CountCmp, Expr, Follow, FollowDestination, LogicalOp, OpNode, OrderSpec, Query, SelectItem, Span, Subquery, TemplatePart, UnaryOp, Where } from "./ast.js";
|
|
2
2
|
/** A fresh empty span (never shared: spans are mutable tuples). */
|
|
3
3
|
export declare const span: () => Span;
|
|
4
4
|
export declare const lit: (value: string | number | boolean | null) => Expr;
|
|
@@ -18,6 +18,9 @@ export declare const inOp: (left: Expr, right: Expr) => Expr;
|
|
|
18
18
|
export declare const range: (lo: Expr | null, hi: Expr | null, exclusiveEnd?: boolean) => Expr;
|
|
19
19
|
/** `(e1, e2, …)` — a tuple of two or more expressions (SEMANTICS §3b). */
|
|
20
20
|
export declare const tuple: (items: Expr[]) => Expr;
|
|
21
|
+
/** `` `text ${expr} …` `` — a template literal (SEMANTICS §7b); `parts` alternates
|
|
22
|
+
* text, expression, text, … (odd length, text first and last). */
|
|
23
|
+
export declare const template: (parts: TemplatePart[]) => Expr;
|
|
21
24
|
export declare const scalar: (expr: Expr) => Where;
|
|
22
25
|
export declare const and: (parts: Where[]) => Where;
|
|
23
26
|
export declare const or: (parts: Where[]) => Where;
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EACpH,QAAQ,EAAE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EACpH,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EACvC,MAAM,UAAU,CAAC;AAElB,mEAAmE;AACnE,eAAO,MAAM,IAAI,QAAO,IAAc,CAAC;AAEvC,eAAO,MAAM,GAAG,GAAI,OAAO,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,KAAG,IAA8C,CAAC;AAC7G,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,KAAG,IAA+C,CAAC;AACrF,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAG,IAAuD,CAAC;AAC7G,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,KAAG,IAAkD,CAAC;AAC3F,eAAO,MAAM,MAA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AK,KAAG,KAA8C,CAAC;AAEjF,eAAO,MAAM,KAAK,GAAI,MAAM,MAAM,EAAE,MAAM,IAAI,EAAE,aAAQ,KAAG,UAAiE,CAAC;AAC7H,eAAO,MAAM,OAAO,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,KAAG,UAA2D,CAAC;AAC/G,eAAO,MAAM,KAAK,GAAI,MAAM,IAAI,EAAE,cAAY,KAAG,SAA0D,CAAC;AAE5G,2DAA2D;AAC3D,wBAAgB,QAAQ,CAAC,KAAK,GAAE,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,CAAM,GAAG,QAAQ,CAMvF;AAED,wDAAwD;AACxD,wBAAgB,EAAE,CAChB,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,GAAE,QAAqB,EAC9D,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAO,GAC5D,MAAM,CAER;AAED;0EAC0E;AAC1E,wBAAgB,MAAM,CAAC,YAAY,EAAE,iBAAiB,EAAE,EAAE,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,MAAM,CAEnG;AAED;oCACoC;AACpC,wBAAgB,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,GAAE,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAM,GAAG,KAAK,CAOvG"}
|
package/dist/build.js
CHANGED
|
@@ -21,6 +21,9 @@ export const inOp = (left, right) => ({ kind: "in", span: span(), left, right })
|
|
|
21
21
|
export const range = (lo, hi, exclusiveEnd = false) => ({ kind: "range", span: span(), lo, hi, exclusiveEnd });
|
|
22
22
|
/** `(e1, e2, …)` — a tuple of two or more expressions (SEMANTICS §3b). */
|
|
23
23
|
export const tuple = (items) => ({ kind: "tuple", span: span(), items });
|
|
24
|
+
/** `` `text ${expr} …` `` — a template literal (SEMANTICS §7b); `parts` alternates
|
|
25
|
+
* text, expression, text, … (odd length, text first and last). */
|
|
26
|
+
export const template = (parts) => ({ kind: "template", span: span(), parts });
|
|
24
27
|
export const scalar = (expr) => ({ kind: "scalar", span: span(), expr });
|
|
25
28
|
export const and = (parts) => ({ kind: "and", span: span(), parts });
|
|
26
29
|
export const or = (parts) => ({ kind: "or", span: span(), parts });
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,mEAAmE;AAOnE,mEAAmE;AACnE,MAAM,CAAC,MAAM,IAAI,GAAG,GAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEvC,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,KAAuC,EAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7G,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAY,EAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AACrF,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,MAAc,EAAE,IAAY,EAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;AAC7G,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAa,EAAQ,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;A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M;QACnC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI;QACnG,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI;QACzD,GAAG,KAAK;KACT,CAAC;AACJ,CAAC"}
|
package/dist/engine.d.ts
CHANGED
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,KAAK,EAAe,MAAM,EAC3B,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EACV,KAAK,EAAe,MAAM,EAC3B,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD,OAAO,KAAK,EAA0B,IAAI,EAAY,MAAM,qBAAqB,CAAC;AAIlF;;;kDAGkD;AAClD,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,OAAO,EAAE,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACzD;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GACvC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,QAAQ,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAA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f,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,QAAQ;IAahB,OAAO,CAAC,UAAU;CAKnB"}
|
package/dist/engine.js
CHANGED
|
@@ -18,9 +18,10 @@
|
|
|
18
18
|
// the current scope only, and an enclosing scope is reached solely through an
|
|
19
19
|
// explicit `^name` (exactly one scope out per caret). There is no implicit
|
|
20
20
|
// fall-through from an inner scope to an outer one — see `resolveIn`.
|
|
21
|
+
import { isRegexOp, REGEX_OPS } from "./ast.js";
|
|
21
22
|
import { DefaultContext } from "./context.js";
|
|
22
23
|
import { OqxError } from "./errors.js";
|
|
23
|
-
import { relate, arith, membership, truthy, compareForSort, compare, canonicalKey, makeRange, isEntry, isRange, } from "./semantics.js";
|
|
24
|
+
import { relate, arith, membership, truthy, compareForSort, compare, canonicalKey, makeRange, isEntry, isRange, stringForm, } from "./semantics.js";
|
|
24
25
|
import { printTemplate } from "./print.js";
|
|
25
26
|
import { DEFAULT_RULES, HashIndex, intersectPositions, lookupOrder, planFor, residualWithout } from "./optimize/index.js";
|
|
26
27
|
const RECUR = new Set(["$depth", "$stop", "$leaf", "$frontier", "$ordinal"]);
|
|
@@ -816,6 +817,15 @@ export class InMemoryEngine {
|
|
|
816
817
|
const same = canonicalKey(this.hostIdentity(l)) === canonicalKey(this.hostIdentity(r));
|
|
817
818
|
return e.op === "is" ? same : !same;
|
|
818
819
|
}
|
|
820
|
+
if (isRegexOp(e.op)) {
|
|
821
|
+
// The regex operators (SEMANTICS §11, since 0.22) are sugar over
|
|
822
|
+
// `matches`: `a ~ b` is `a.matches(b)`, `~*` adds the `i` flag, `!~`
|
|
823
|
+
// / `!~*` negate. They go through the same method dispatch as the
|
|
824
|
+
// call would, so a host's `matches` (and its regex dialect) applies.
|
|
825
|
+
const { negated, flags } = REGEX_OPS[e.op];
|
|
826
|
+
const hit = this.callMethod("matches", l, flags === undefined ? [r] : [r, flags]);
|
|
827
|
+
return negated ? !truthy(hit) : hit;
|
|
828
|
+
}
|
|
819
829
|
return isRelOp(e.op) ? relate(e.op, l, r) : arith(e.op, l, r);
|
|
820
830
|
}
|
|
821
831
|
case "logical": {
|
|
@@ -845,6 +855,32 @@ export class InMemoryEngine {
|
|
|
845
855
|
}
|
|
846
856
|
return out;
|
|
847
857
|
}
|
|
858
|
+
// A template literal (SEMANTICS §7b): the text parts verbatim and each
|
|
859
|
+
// interpolated value's string form (§7), concatenated. Every interpolation
|
|
860
|
+
// is evaluated, in order; a list, a record or a range is an eval error (it
|
|
861
|
+
// has no string form the language specifies); an absent value makes the
|
|
862
|
+
// whole literal absent, as `+` does.
|
|
863
|
+
case "template": {
|
|
864
|
+
let out = "";
|
|
865
|
+
let absent = false;
|
|
866
|
+
for (const part of e.parts) {
|
|
867
|
+
if (typeof part === "string") {
|
|
868
|
+
out += part;
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
const v = this.evalExpr(part, scope);
|
|
872
|
+
if (v == null) {
|
|
873
|
+
absent = true;
|
|
874
|
+
continue;
|
|
875
|
+
}
|
|
876
|
+
if (typeof v === "object") {
|
|
877
|
+
const what = isRange(v) ? "a range" : Array.isArray(v) || Symbol.iterator in v ? "a list" : "a record";
|
|
878
|
+
throw new OqxError(`cannot interpolate \`\${${describe(part)}}\` in a template literal: it is ${what} — only a string, a number, a boolean or an absent value has a string form`, "eval");
|
|
879
|
+
}
|
|
880
|
+
out += stringForm(v);
|
|
881
|
+
}
|
|
882
|
+
return absent ? undefined : out;
|
|
883
|
+
}
|
|
848
884
|
}
|
|
849
885
|
}
|
|
850
886
|
// Resolve a name against ONE scope — never its ancestors. A scope provides,
|
|
@@ -903,10 +939,15 @@ export class InMemoryEngine {
|
|
|
903
939
|
throw new OqxError(`unknown function '${e.name}(…)'`, "eval");
|
|
904
940
|
}
|
|
905
941
|
const recv = this.evalExpr(e.recv, scope);
|
|
906
|
-
|
|
942
|
+
return this.callMethod(e.name, recv, args);
|
|
943
|
+
}
|
|
944
|
+
// `recv.name(args)` on evaluated values — the dispatch a method call and the
|
|
945
|
+
// regex operators share.
|
|
946
|
+
callMethod(name, recv, args) {
|
|
947
|
+
const r = this.ctx.callMethod?.(name, recv, args);
|
|
907
948
|
if (r?.handled)
|
|
908
949
|
return r.value;
|
|
909
|
-
throw new OqxError(`unknown method '.${
|
|
950
|
+
throw new OqxError(`unknown method '.${name}(…)'`, "eval");
|
|
910
951
|
}
|
|
911
952
|
}
|
|
912
953
|
// ---- free helpers -----------------------------------------------------------
|
|
@@ -1029,6 +1070,7 @@ function exprHasRecur(e) {
|
|
|
1029
1070
|
case "in": return exprHasRecur(e.left) || exprHasRecur(e.right);
|
|
1030
1071
|
case "range": return (e.lo != null && exprHasRecur(e.lo)) || (e.hi != null && exprHasRecur(e.hi));
|
|
1031
1072
|
case "tuple": return e.items.some(exprHasRecur);
|
|
1073
|
+
case "template": return e.parts.some((p) => typeof p !== "string" && exprHasRecur(p));
|
|
1032
1074
|
default: return false;
|
|
1033
1075
|
}
|
|
1034
1076
|
}
|