(expr: Json, v: string | null)
| 54 | // (expr is `[head, arg0, arg1, ...]`). Null when there is no single argument |
| 55 | // position (parametric or non-trivial expressions). |
| 56 | function argIndexOf(expr: Json, v: string | null): number | null { |
| 57 | if (v === null || !Array.isArray(expr)) return null; |
| 58 | const i = (expr as Json[]).slice(1).findIndex((a) => a === v); |
| 59 | return i < 0 ? null : i; |
| 60 | } |
| 61 | |
| 62 | function compile(source: { generator?: string; entries: SourceEntry[] }) { |
| 63 | const operators: Record<string, CompiledRecord[]> = {}; |