simple-graph-query 3.1.0 → 3.3.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/LANGUAGE.md ADDED
@@ -0,0 +1,337 @@
1
+ <!-- GENERATED FILE — DO NOT EDIT.
2
+ Built from src/forge-antlr/ForgeLexer.g4, src/forge-antlr/Forge.g4, and
3
+ the evaluator's builtin tables by scripts/generate-lang-ref.mjs.
4
+ Regenerate with: npm run docs:lang -->
5
+
6
+ # The Expression Language
7
+
8
+ This library evaluates a single **expression** (the `parseExpr` grammar entry
9
+ point) against a data instance. The language is the expression fragment of
10
+ [Forge](https://forge-fm.org) (itself a dialect of Alloy), with a few
11
+ extensions (string literals, label access, string comparison) and deliberate omissions.
12
+
13
+ **Everything is a set of tuples.** A sig name denotes the set of its atoms, a
14
+ relation name the set of its tuples, and a scalar (one atom, one number, one
15
+ string) is a singleton set. Boolean formulas evaluate to `true`/`false`.
16
+
17
+ **There is no temporal fragment.** The temporal operators (`always`,
18
+ `eventually`, `after`, `before`, `once`, `historically`, `until`,
19
+ `release`, `since`, `triggered`) and primed expressions (`e'`) were
20
+ removed from the grammar; their syntax is a parse error, and the former
21
+ keywords are ordinary identifiers.
22
+
23
+ ## Lexical structure
24
+
25
+ - **STRING_TOK** — A double-quoted string literal: `"dark blue"`. Escapes: `\"`, `\\`, `\n`, `\t`, `\r`, `\0`; any other escaped character stands for itself.
26
+ - **NUM_CONST_TOK** — An integer or decimal literal: `42`, `3.5`. Negate with a leading `-`.
27
+ - **QUOTED_IDENTIFIER_TOK** — A backquoted name: `` `n0 ``. Names an atom by id, and escapes reserved words.
28
+ - **IDENTIFIER_TOK** — A name: letters, digits, `_`, `$`, `/` (not starting with a digit).
29
+
30
+ Comments run from `//` or `--` to the end of the line, or between `/*`
31
+ and `*/`. A `#lang` line is ignored.
32
+
33
+ ### Reserved words
34
+
35
+ `Int`, `abstract`, `all`, `and`, `as`, `assert`, `bind`, `but`, `check`, `checked`, `consistent`, `disj`, `else`, `eval`, `exactly`, `example`, `expect`, `extends`, `for`, `forge_error`, `fun`, `func`, `iden`, `iff`, `implies`, `in`, `inconsistent`, `inst`, `is`, `let`, `lone`, `necessary`, `ni`, `no`, `none`, `not`, `one`, `open`, `option`, `or`, `pfunc`, `pred`, `run`, `sat`, `set`, `sexpr`, `sig`, `some`, `sufficient`, `suite`, `sum`, `test`, `theorem`, `this`, `two`, `univ`, `unsat`, `var`, `wheat`, `with`, `xor`
36
+
37
+ A data-instance entity whose name collides with a reserved word is still
38
+ reachable by backquoting: `` `set` `` names the *atom* with id `set`.
39
+
40
+ ### Names that must be backquoted
41
+
42
+ `/` matches the identifier pattern but lexes as the qualified-name separator. A name that is exactly `/` can only be written backquoted (`` `/` ``); a name that merely contains it, like `foo/bar`, is an ordinary identifier and needs no quoting.
43
+
44
+ ### Machine-readable form
45
+
46
+ Code that *generates* expressions needs this page's content as data rather than
47
+ as prose. [`docs/sgq-language.json`](docs/sgq-language.json) carries it: the
48
+ bare-identifier character classes, both quoting forms with their escape tables,
49
+ every spelling a bare identifier cannot carry, and the whole cascade below —
50
+ each construct with its spellings, its precedence, and the level each of its
51
+ operands descends to. It is generated from this same grammar, ships in the npm
52
+ package, and is checked against the real lexer and parser by a test.
53
+
54
+ The parenthesisation rule is the one thing worth restating: a subexpression
55
+ needs parentheses exactly when its own `precedence` is below the level of the
56
+ slot it fills. Those levels are not always the neighbouring one — `+` takes
57
+ its right operand two levels in, so `a + #b` is a parse error.
58
+
59
+ ## Operators and precedence
60
+
61
+ Constructs are listed loosest-binding first; higher numbers bind tighter.
62
+ "Evaluates ✗" marks syntax the grammar accepts but the evaluator rejects.
63
+
64
+ | # | Construct | Example | Operators | Yields | Evaluates | Meaning |
65
+ |---|-----------|---------|-----------|--------|:---------:|---------|
66
+ | 1 | let binding | `let x = e \| body` | — | — | ✗ | Bind names to expression values inside a body. Parses, but evaluation is not implemented and fails. |
67
+ | 1 | bind | `bind x = e \| body` | — | — | ✗ | Alloy `bind`. Parses, but evaluation is rejected. |
68
+ | 1 | quantified formula | `all x: S \| body` | — | boolean (`sum` number) | ✓ | Quantifiers `all`, `no`, `some`, `lone`, `one`, `two`, and the aggregator `sum x: S \| intExpr`. `disj` requires the bound variables to take pairwise-distinct values. The body must use the bar form (`\| expr`). |
69
+ | 2 | disjunction | `a or b` | `\|\|` / `or` | boolean | ✓ | Logical or (short-circuits). |
70
+ | 3 | exclusive or | `a xor b` | `xor` | boolean | ✓ | Logical exclusive or. |
71
+ | 4 | biconditional | `a iff b` | `<=>` / `iff` | boolean | ✓ | Logical if-and-only-if. |
72
+ | 5 | implication | `a implies b else c` | `implies` / `=>`, `else` | boolean | ✓ | Implication, with an optional else branch (`a => b else c` means `(a and b) or ((not a) and c)`). |
73
+ | 6 | conjunction | `a and b` | `&&` / `and` | boolean | ✓ | Logical and (short-circuits). |
74
+ | 7 | negation | `not a` | `!` / `not` | boolean | ✓ | Logical negation of a boolean formula. |
75
+ | 8 | comparison | `a in b` | `in`, `=`, `<`, `>`, `<=` / `=<`, `>=`, `ni`, `is` | boolean | ✓ | Subset (`in`), reverse containment (`ni`), set equality (`=`), and numeric comparisons. A scalar is a singleton set, so `in` doubles as membership. A leading `!`/`not` negates the comparison. `is` parses but its evaluation is rejected. |
76
+ | 9 | multiplicity test | `some e` | `no`, `some`, `lone`, `one`, `two`, `set` | boolean (`set` operand) | ✓ | Cardinality predicates over a set: `no` (empty), `some` (non-empty), `lone` (at most one), `one` (exactly one), `two` (exactly two). `set e` is the identity. |
77
+ | 10 | union / difference | `a + b` | `+`, `-` | relation | ✓ | Set union and set difference. (For integer arithmetic use the `add[...]`/`subtract[...]` builtins; `1 + 2` is the two-element set.) |
78
+ | 11 | cardinality | `#e` | `#` | number | ✓ | Number of tuples in the set. |
79
+ | 12 | override | `a ++ b` | `++` | relation | ✓ | Relational override: tuples of `b`, plus the tuples of `a` whose first atom is not a first atom of `b`. |
80
+ | 13 | intersection | `a & b` | `&` | relation | ✓ | Set intersection. |
81
+ | 14 | product | `a -> b` | `->` | relation | ✓ | Cartesian product. Multiplicity annotations (`a one -> lone b`) are declaration syntax and are rejected in expressions. |
82
+ | 15 | restriction | `S <: r` | `<:`, `:>` | relation | ✓ | Domain restriction (`S <: r`: tuples of `r` starting in `S`) and range restriction (`r :> S`: tuples ending in `S`). |
83
+ | 16 | box join / builtin call | `f[a, b]` | `[`, `]` | — | ✓ | `a[b]` is the box join `b.a`. When the callee names a builtin (see the builtin table) it is a function call instead: `add[1, 2]`. |
84
+ | 17 | join | `a.f` | `.` | relation | ✓ | Relational join: match the last column of the left operand against the first column of the right. |
85
+ | 17 | applied name (grammar corner) | `x.f[a]` | — | — | ✗ | A bracket application whose callee is parsed as a bare name inside a dot-chain. Redundant with box join; evaluation is not implemented. |
86
+ | 18 | unary prefixes | `^r` | `~`, `^`, `*`, `@:`, `@str:`, `@bool:`, `@num:` | relation (`@:` string, `@str:` string, `@bool:` boolean, `@num:` number) | ✓ | `~r` transpose, `^r` transitive closure, `*r` reflexive-transitive closure. `@:`/`@str:` label of an atom as a string, `@bool:`/`@num:` label converted to boolean/number (extensions; not Forge). |
87
+ | 19 | constant | `none` | — | — (`none` relation, `univ` relation, `iden` relation) | ✓ | `none` (empty set), `univ` (all atoms), `iden` (identity relation), integer literals (incl. negative), and `"..."` string literals. |
88
+ | 19 | name | `Person` | — | relation | ✓ | A type, relation, atom, or bound variable. An unresolved name evaluates to the empty set and raises an `unresolved-name` diagnostic. |
89
+ | 19 | @name | `@x` | — | — | ✗ | Alloy-specific; evaluation is rejected. |
90
+ | 19 | atom literal | <code>&#96;n0</code> | — | relation | ✓ | The atom with exactly this id, bypassing type/relation/variable lookup. |
91
+ | 19 | this | `this` | — | — | ✗ | Alloy-specific; evaluation is rejected. |
92
+ | 19 | set comprehension | `{x: S \| body}` | — | relation | ✓ | The set of bindings satisfying the body. Multiple binders build a relation: `{x: A, y: B \| body}` is a set of pairs. |
93
+ | 19 | parentheses | `(e)` | — | operand | ✓ | Grouping. |
94
+ | 19 | block | `{ e1 e2 }` | — | boolean | ✓ | A conjunction of boolean expressions, separated by whitespace (there is no `;` in the language). |
95
+ | 19 | s-expression | `sexpr` | — | — | ✗ | Reserved for internal use; evaluation is rejected. |
96
+
97
+ ## Builtin functions
98
+
99
+ Called with square brackets, e.g. `add[1, 2]`.
100
+
101
+ | Builtins | Arity | Notes |
102
+ |----------|-------|-------|
103
+ | `add`, `subtract`, `multiply`, `divide`, `remainder` | 2 | Integer/real arithmetic. `divide` is real division. |
104
+ | `lexCompare` | 2 | String comparison (SGQ extension), returning -1, 0, or 1. |
105
+ | `abs`, `sign`, `floor`, `ceil` | 1 | |
106
+ | `min`, `max`, `sum` | set | Aggregate over a set; numeric strings resolve to numbers. `sum` also has a quantifier form `sum x: S \| intExpr`. |
107
+
108
+ Builtin names are **not** reserved words: a data instance that names an
109
+ entity `add` shadows the builtin (see issue #59).
110
+
111
+ ### String comparison
112
+
113
+ `lexCompare[a, b]` returns -1 if `a` precedes `b`, 0 if they are equal,
114
+ and 1 if `a` follows `b`. Each argument must be a string or a singleton
115
+ unary string relation; empty relations, multiple values, higher-arity tuples,
116
+ numbers, and booleans are rejected. No implicit conversion or label lookup occurs.
117
+
118
+ Ordering uses JavaScript's `<` and `>`: case-sensitive, locale-independent
119
+ lexicographic comparison of UTF-16 code units, with no Unicode normalization.
120
+ A proper prefix comes first (`""` precedes `"a"`, which precedes `"aa"`);
121
+ numeric-looking strings remain strings (`"10"` precedes `"2"`).
122
+ Use label extraction explicitly when ordering atoms by their displayed labels:
123
+
124
+ `{a, b: Person | lexCompare[@:a, @:b] < 0}`
125
+
126
+ Atom IDs are also represented as strings, so `lexCompare[a, b]` compares IDs
127
+ when given atoms. Distinct atoms with identical labels compare equal after
128
+ label extraction. The infix ordering operators remain numeric.
129
+
130
+ ## Grammar
131
+
132
+ The expression grammar, with token literals substituted in. Pattern tokens
133
+ (see [Lexical structure](#lexical-structure)) keep their names.
134
+
135
+ ```
136
+ parseExpr
137
+ : expr EOF
138
+ ;
139
+
140
+ expr
141
+ : expr1
142
+ | 'let' letDeclList blockOrBar
143
+ | 'bind' letDeclList blockOrBar
144
+ | quant 'disj'? quantDeclList blockOrBar
145
+ ;
146
+
147
+ expr1
148
+ : expr1_5
149
+ | expr1 ('||' | 'or') expr1_5
150
+ ;
151
+
152
+ letDeclList
153
+ : letDecl
154
+ | letDecl ',' letDeclList
155
+ ;
156
+
157
+ blockOrBar
158
+ : block
159
+ | '|' expr
160
+ ;
161
+
162
+ quant
163
+ : 'all'
164
+ | 'no'
165
+ | 'sum'
166
+ | mult
167
+ ;
168
+
169
+ quantDeclList
170
+ : quantDecl
171
+ | quantDecl ',' quantDeclList
172
+ ;
173
+
174
+ expr1_5
175
+ : expr2
176
+ | expr1_5 'xor' expr2
177
+ ;
178
+
179
+ letDecl
180
+ : name '=' expr
181
+ ;
182
+
183
+ block
184
+ : '{' expr* '}'
185
+ ;
186
+
187
+ mult
188
+ : 'lone'
189
+ | 'some'
190
+ | 'one'
191
+ | 'two'
192
+ ;
193
+
194
+ quantDecl
195
+ : 'disj'? nameList ':' 'set'? expr
196
+ ;
197
+
198
+ expr2
199
+ : expr3
200
+ | expr2 ('<=>' | 'iff') expr3
201
+ ;
202
+
203
+ name
204
+ : IDENTIFIER_TOK
205
+ | QUOTED_IDENTIFIER_TOK
206
+ ;
207
+
208
+ nameList
209
+ : name
210
+ | name ',' nameList
211
+ ;
212
+
213
+ expr3
214
+ : expr4
215
+ | expr4 ('implies' | '=>') expr3 ('else' expr3)?
216
+ ;
217
+
218
+ expr4
219
+ : expr5
220
+ | expr4 ('&&' | 'and') expr5
221
+ ;
222
+
223
+ expr5
224
+ : expr6
225
+ | ('!' | 'not') expr5
226
+ ;
227
+
228
+ expr6
229
+ : expr7
230
+ | expr6 ('!' | 'not')? compareOp expr7
231
+ ;
232
+
233
+ expr7
234
+ : expr8
235
+ | ('no' | 'some' | 'lone' | 'one' | 'two' | 'set') expr8
236
+ ;
237
+
238
+ compareOp
239
+ : 'in'
240
+ | '='
241
+ | '<'
242
+ | '>'
243
+ | ('<=' | '=<')
244
+ | '>='
245
+ | 'is'
246
+ | 'ni'
247
+ ;
248
+
249
+ expr8
250
+ : expr9
251
+ | expr8 ('+' | '-') expr10
252
+ ;
253
+
254
+ expr9
255
+ : expr10
256
+ | '#' expr9
257
+ ;
258
+
259
+ expr10
260
+ : expr11
261
+ | expr10 '++' expr11
262
+ ;
263
+
264
+ expr11
265
+ : expr12
266
+ | expr11 '&' expr12
267
+ ;
268
+
269
+ expr12
270
+ : expr13
271
+ | expr12 arrowOp expr13
272
+ ;
273
+
274
+ expr13
275
+ : expr14
276
+ | expr13 ('<:' | ':>') expr14
277
+ ;
278
+
279
+ arrowOp
280
+ : (mult | 'set')? '->' (mult | 'set')?
281
+ ;
282
+
283
+ expr14
284
+ : expr15
285
+ | expr14 '[' exprList ']'
286
+ ;
287
+
288
+ expr15
289
+ : expr17
290
+ | expr15 '.' expr17
291
+ | name '[' exprList ']'
292
+ ;
293
+
294
+ exprList
295
+ : expr
296
+ | expr ',' exprList
297
+ ;
298
+
299
+ expr17
300
+ : expr18
301
+ | ('~' | '^' | '*' | '@:' | '@str:' | '@bool:' | '@num:') expr17
302
+ ;
303
+
304
+ expr18
305
+ : const
306
+ | qualName
307
+ | '@' name
308
+ | '`' name
309
+ | 'this'
310
+ | '{' quantDeclList blockOrBar '}'
311
+ | '(' expr ')'
312
+ | block
313
+ | sexpr
314
+ ;
315
+
316
+ const
317
+ : 'none'
318
+ | 'univ'
319
+ | 'iden'
320
+ | '-'? number
321
+ | STRING_TOK
322
+ ;
323
+
324
+ qualName
325
+ : ('this' '/')? (name '/')* name
326
+ | 'Int'
327
+ | 'sum'
328
+ ;
329
+
330
+ sexpr
331
+ : 'sexpr'
332
+ ;
333
+
334
+ number
335
+ : NUM_CONST_TOK
336
+ ;
337
+ ```
package/README.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  A TypeScript library for evaluating relational + some more expressions with a browser-compatible UMD bundle.
4
4
 
5
+ The full language — operators, precedence, reserved words, builtins, and the
6
+ grammar itself — is documented in [LANGUAGE.md](LANGUAGE.md), which is
7
+ **generated from the ANTLR grammars** (`npm run docs`) and kept fresh by
8
+ a test. Note that the language has no temporal fragment: the temporal
9
+ operators (`always`, `until`, ...) and primed expressions (`e'`) were removed
10
+ from the grammar, and their former keywords are ordinary identifiers.
11
+
12
+ Tools that *generate* expressions should read
13
+ [`docs/sgq-language.json`](docs/sgq-language.json) instead of copying the rules
14
+ into their own source. It is generated from the same grammar, ships in the
15
+ package, and states the bare-identifier character classes, the reserved
16
+ spellings, the escape tables for both quoting forms, the builtins, and the
17
+ precedence cascade — each construct with its operator spellings and the level
18
+ each operand descends to, which is what decides parentheses.
19
+ `test/language-manifest.test.ts` checks it by building expressions from the
20
+ manifest alone and running them through the lexer and parser.
21
+
5
22
  ## License
6
23
 
7
24
  MIT
@@ -26,6 +43,23 @@ stands for itself.
26
43
  There is no implicit conversion: `"12" = 12` and `"true" = true` are both false.
27
44
  Use `@num:` / `@bool:` to convert explicitly.
28
45
 
46
+ ### Lexicographic comparison
47
+
48
+ `lexCompare[a, b]` returns `-1`, `0`, or `1` for strings that precede, equal,
49
+ or follow one another, using JavaScript's case-sensitive UTF-16 string ordering
50
+ (`a < b` / `a > b`). It has no locale rules, Unicode normalization, or numeric
51
+ conversion: `"10"` precedes `"2"`, and a proper prefix comes first.
52
+
53
+ ```
54
+ lexCompare["apple", "banana"] < 0
55
+ {a, b: Person | lexCompare[@:a, @:b] < 0}
56
+ ```
57
+
58
+ Each argument must be a string or a singleton unary string relation. Empty or
59
+ multi-value relations, higher-arity tuples, numbers, and booleans are rejected.
60
+ Atom IDs are represented as strings too; use `@:` explicitly to compare labels.
61
+ The infix `<`, `>`, `<=`, and `>=` operators continue to require numbers.
62
+
29
63
  ### Embedding in YAML
30
64
 
31
65
  `@` is a reserved indicator in YAML, so an expression beginning with `@:` cannot
@@ -1,10 +1,12 @@
1
1
  import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor";
2
2
  import { ForgeVisitor } from "./forge-antlr/ForgeVisitor";
3
- import { ExprContext, Expr1Context, Expr1_5Context, Expr2Context, Expr3Context, Expr4Context, Expr4_5Context, Expr5Context, Expr6Context, Expr7Context, Expr8Context, Expr9Context, Expr10Context, Expr11Context, Expr12Context, Expr13Context, Expr14Context, Expr15Context, Expr16Context, Expr17Context, Expr18Context, ExprListContext, NameContext, PredDeclContext, BlockContext, QualNameContext, QuantDeclListContext, NameListContext, QuantDeclContext, CompareOpContext } from "./forge-antlr/ForgeParser";
3
+ import { ExprContext, Expr1Context, Expr1_5Context, Expr2Context, Expr3Context, Expr4Context, Expr5Context, Expr6Context, Expr7Context, Expr8Context, Expr9Context, Expr10Context, Expr11Context, Expr12Context, Expr13Context, Expr14Context, Expr15Context, Expr17Context, Expr18Context, ExprListContext, NameContext, PredDeclContext, BlockContext, QualNameContext, QuantDeclListContext, NameListContext, QuantDeclContext, CompareOpContext } from "./forge-antlr/ForgeParser";
4
4
  import { IDataInstance } from "./types";
5
5
  export type SingleValue = string | number | boolean;
6
6
  export type Tuple = SingleValue[];
7
7
  export type EvalResult = SingleValue | Tuple[];
8
+ /** JavaScript's case-sensitive, locale-independent UTF-16 string ordering. */
9
+ export declare function compareStrings(a: string, b: string): -1 | 0 | 1;
8
10
  export declare function areTupleArraysEqual(a: Tuple[], b: Tuple[]): boolean;
9
11
  export declare const SUPPORTED_BUILTINS: string[];
10
12
  /**
@@ -98,7 +100,6 @@ export declare class ForgeExprEvaluator extends AbstractParseTreeVisitor<EvalRes
98
100
  visitExpr2(ctx: Expr2Context): EvalResult;
99
101
  visitExpr3(ctx: Expr3Context): EvalResult;
100
102
  visitExpr4(ctx: Expr4Context): EvalResult;
101
- visitExpr4_5(ctx: Expr4_5Context): EvalResult;
102
103
  visitExpr5(ctx: Expr5Context): EvalResult;
103
104
  visitExpr6(ctx: Expr6Context): EvalResult;
104
105
  visitExpr7(ctx: Expr7Context): EvalResult;
@@ -110,7 +111,6 @@ export declare class ForgeExprEvaluator extends AbstractParseTreeVisitor<EvalRes
110
111
  visitExpr13(ctx: Expr13Context): EvalResult;
111
112
  visitExpr14(ctx: Expr14Context): EvalResult;
112
113
  visitExpr15(ctx: Expr15Context): EvalResult;
113
- visitExpr16(ctx: Expr16Context): EvalResult;
114
114
  visitExpr17(ctx: Expr17Context): EvalResult;
115
115
  getNameListValues(ctx: NameListContext): string[];
116
116
  getQuantDeclValues(ctx: QuantDeclContext): Record<string, Tuple[]>;
@@ -2,7 +2,7 @@ import { AbstractParseTreeVisitor } from "antlr4ts/tree/AbstractParseTreeVisitor
2
2
  import { ParseTree } from "antlr4ts/tree/ParseTree";
3
3
  import { ForgeVisitor } from "./forge-antlr/ForgeVisitor";
4
4
  import { IDataInstance } from "./types";
5
- import { BlockContext, Expr10Context, Expr11Context, Expr12Context, Expr13Context, Expr14Context, Expr15Context, Expr16Context, Expr17Context, Expr18Context, Expr1Context, Expr1_5Context, Expr2Context, Expr3Context, Expr4Context, Expr4_5Context, Expr5Context, Expr6Context, Expr7Context, Expr8Context, Expr9Context, ExprContext, ExprListContext, NameContext, NameListContext, PredDeclContext, QuantDeclContext, QuantDeclListContext } from "./forge-antlr/ForgeParser";
5
+ import { BlockContext, Expr10Context, Expr11Context, Expr12Context, Expr13Context, Expr14Context, Expr15Context, Expr17Context, Expr18Context, Expr1Context, Expr1_5Context, Expr2Context, Expr3Context, Expr4Context, Expr5Context, Expr6Context, Expr7Context, Expr8Context, Expr9Context, ExprContext, ExprListContext, NameContext, NameListContext, PredDeclContext, QuantDeclContext, QuantDeclListContext } from "./forge-antlr/ForgeParser";
6
6
  export type FreeVariables = Map<ParseTree, Set<string>>;
7
7
  /**
8
8
  * A recursive visitor to find all the free variables referenced in a forge
@@ -25,7 +25,6 @@ export declare class ForgeExprFreeVariableFinder extends AbstractParseTreeVisito
25
25
  visitExpr2(ctx: Expr2Context): FreeVariables;
26
26
  visitExpr3(ctx: Expr3Context): FreeVariables;
27
27
  visitExpr4(ctx: Expr4Context): FreeVariables;
28
- visitExpr4_5(ctx: Expr4_5Context): FreeVariables;
29
28
  visitExpr5(ctx: Expr5Context): FreeVariables;
30
29
  visitExpr6(ctx: Expr6Context): FreeVariables;
31
30
  visitExpr7(ctx: Expr7Context): FreeVariables;
@@ -37,7 +36,6 @@ export declare class ForgeExprFreeVariableFinder extends AbstractParseTreeVisito
37
36
  visitExpr13(ctx: Expr13Context): FreeVariables;
38
37
  visitExpr14(ctx: Expr14Context): FreeVariables;
39
38
  visitExpr15(ctx: Expr15Context): FreeVariables;
40
- visitExpr16(ctx: Expr16Context): FreeVariables;
41
39
  visitExpr17(ctx: Expr17Context): FreeVariables;
42
40
  visitExpr18(ctx: Expr18Context): FreeVariables;
43
41
  visitExprList(ctx: ExprListContext): FreeVariables;
@@ -9,6 +9,9 @@ type Abstract = {
9
9
  } | {
10
10
  kind: "num";
11
11
  value: number;
12
+ } | {
13
+ kind: "str";
14
+ value: string;
12
15
  } | {
13
16
  kind: "empty";
14
17
  } | {
@@ -65,58 +65,47 @@ export declare class ForgeLexer extends Lexer {
65
65
  static readonly IMP_TOK = 60;
66
66
  static readonly ELSE_TOK = 61;
67
67
  static readonly AND_TOK = 62;
68
- static readonly UNTIL_TOK = 63;
69
- static readonly RELEASE_TOK = 64;
70
- static readonly SINCE_TOK = 65;
71
- static readonly TRIGGERED_TOK = 66;
72
- static readonly NEG_TOK = 67;
73
- static readonly ALWAYS_TOK = 68;
74
- static readonly EVENTUALLY_TOK = 69;
75
- static readonly AFTER_TOK = 70;
76
- static readonly BEFORE_TOK = 71;
77
- static readonly ONCE_TOK = 72;
78
- static readonly HISTORICALLY_TOK = 73;
79
- static readonly CARD_TOK = 74;
80
- static readonly PPLUS_TOK = 75;
81
- static readonly AMP_TOK = 76;
82
- static readonly SUBT_TOK = 77;
83
- static readonly SUPT_TOK = 78;
84
- static readonly PRIME_TOK = 79;
85
- static readonly TILDE_TOK = 80;
86
- static readonly EXP_TOK = 81;
87
- static readonly STAR_TOK = 82;
88
- static readonly AT_TOK = 83;
89
- static readonly BACKQUOTE_TOK = 84;
90
- static readonly THIS_TOK = 85;
91
- static readonly SEXPR_TOK = 86;
92
- static readonly INST_TOK = 87;
93
- static readonly EVAL_TOK = 88;
94
- static readonly EXAMPLE_TOK = 89;
95
- static readonly ARROW_TOK = 90;
96
- static readonly GET_LABEL_TOK = 91;
97
- static readonly GET_LABEL_STR_TOK = 92;
98
- static readonly GET_LABEL_BOOL_TOK = 93;
99
- static readonly GET_LABEL_NUM_TOK = 94;
100
- static readonly EQ_TOK = 95;
101
- static readonly LT_TOK = 96;
102
- static readonly GT_TOK = 97;
103
- static readonly LEQ_TOK = 98;
104
- static readonly GEQ_TOK = 99;
105
- static readonly NI_TOK = 100;
106
- static readonly NO_TOK = 101;
107
- static readonly SUM_TOK = 102;
108
- static readonly INT_TOK = 103;
109
- static readonly OPTION_TOK = 104;
110
- static readonly COMMA_TOK = 105;
111
- static readonly SLASH_TOK = 106;
112
- static readonly NUM_CONST_TOK = 107;
113
- static readonly QUOTED_IDENTIFIER_TOK = 108;
114
- static readonly IDENTIFIER_TOK = 109;
115
- static readonly WS = 110;
116
- static readonly CCOMMENT = 111;
117
- static readonly COMMENT = 112;
118
- static readonly MULTCOMMENT = 113;
119
- static readonly LANG_DECL = 114;
68
+ static readonly NEG_TOK = 63;
69
+ static readonly CARD_TOK = 64;
70
+ static readonly PPLUS_TOK = 65;
71
+ static readonly AMP_TOK = 66;
72
+ static readonly SUBT_TOK = 67;
73
+ static readonly SUPT_TOK = 68;
74
+ static readonly TILDE_TOK = 69;
75
+ static readonly EXP_TOK = 70;
76
+ static readonly STAR_TOK = 71;
77
+ static readonly AT_TOK = 72;
78
+ static readonly BACKQUOTE_TOK = 73;
79
+ static readonly THIS_TOK = 74;
80
+ static readonly SEXPR_TOK = 75;
81
+ static readonly INST_TOK = 76;
82
+ static readonly EVAL_TOK = 77;
83
+ static readonly EXAMPLE_TOK = 78;
84
+ static readonly ARROW_TOK = 79;
85
+ static readonly GET_LABEL_TOK = 80;
86
+ static readonly GET_LABEL_STR_TOK = 81;
87
+ static readonly GET_LABEL_BOOL_TOK = 82;
88
+ static readonly GET_LABEL_NUM_TOK = 83;
89
+ static readonly EQ_TOK = 84;
90
+ static readonly LT_TOK = 85;
91
+ static readonly GT_TOK = 86;
92
+ static readonly LEQ_TOK = 87;
93
+ static readonly GEQ_TOK = 88;
94
+ static readonly NI_TOK = 89;
95
+ static readonly NO_TOK = 90;
96
+ static readonly SUM_TOK = 91;
97
+ static readonly INT_TOK = 92;
98
+ static readonly OPTION_TOK = 93;
99
+ static readonly COMMA_TOK = 94;
100
+ static readonly SLASH_TOK = 95;
101
+ static readonly NUM_CONST_TOK = 96;
102
+ static readonly QUOTED_IDENTIFIER_TOK = 97;
103
+ static readonly IDENTIFIER_TOK = 98;
104
+ static readonly WS = 99;
105
+ static readonly CCOMMENT = 100;
106
+ static readonly COMMENT = 101;
107
+ static readonly MULTCOMMENT = 102;
108
+ static readonly LANG_DECL = 103;
120
109
  static readonly channelNames: string[];
121
110
  static readonly modeNames: string[];
122
111
  static readonly ruleNames: string[];
@@ -52,7 +52,6 @@ import { Expr1_5Context } from "./ForgeParser";
52
52
  import { Expr2Context } from "./ForgeParser";
53
53
  import { Expr3Context } from "./ForgeParser";
54
54
  import { Expr4Context } from "./ForgeParser";
55
- import { Expr4_5Context } from "./ForgeParser";
56
55
  import { Expr5Context } from "./ForgeParser";
57
56
  import { Expr6Context } from "./ForgeParser";
58
57
  import { Expr7Context } from "./ForgeParser";
@@ -64,7 +63,6 @@ import { Expr12Context } from "./ForgeParser";
64
63
  import { Expr13Context } from "./ForgeParser";
65
64
  import { Expr14Context } from "./ForgeParser";
66
65
  import { Expr15Context } from "./ForgeParser";
67
- import { Expr16Context } from "./ForgeParser";
68
66
  import { Expr17Context } from "./ForgeParser";
69
67
  import { Expr18Context } from "./ForgeParser";
70
68
  import { ArrowExprContext } from "./ForgeParser";
@@ -619,16 +617,6 @@ export interface ForgeListener extends ParseTreeListener {
619
617
  * @param ctx the parse tree
620
618
  */
621
619
  exitExpr4?: (ctx: Expr4Context) => void;
622
- /**
623
- * Enter a parse tree produced by `ForgeParser.expr4_5`.
624
- * @param ctx the parse tree
625
- */
626
- enterExpr4_5?: (ctx: Expr4_5Context) => void;
627
- /**
628
- * Exit a parse tree produced by `ForgeParser.expr4_5`.
629
- * @param ctx the parse tree
630
- */
631
- exitExpr4_5?: (ctx: Expr4_5Context) => void;
632
620
  /**
633
621
  * Enter a parse tree produced by `ForgeParser.expr5`.
634
622
  * @param ctx the parse tree
@@ -739,16 +727,6 @@ export interface ForgeListener extends ParseTreeListener {
739
727
  * @param ctx the parse tree
740
728
  */
741
729
  exitExpr15?: (ctx: Expr15Context) => void;
742
- /**
743
- * Enter a parse tree produced by `ForgeParser.expr16`.
744
- * @param ctx the parse tree
745
- */
746
- enterExpr16?: (ctx: Expr16Context) => void;
747
- /**
748
- * Exit a parse tree produced by `ForgeParser.expr16`.
749
- * @param ctx the parse tree
750
- */
751
- exitExpr16?: (ctx: Expr16Context) => void;
752
730
  /**
753
731
  * Enter a parse tree produced by `ForgeParser.expr17`.
754
732
  * @param ctx the parse tree