tree-sitter-omega
aien-dev/tree-sitter-omega
Brought by drakestapleton
tree-sitter-omega / README.md
| 1 | # tree-sitter-omega |
| 2 | |
| 3 | A [tree-sitter](https://tree-sitter.github.io/) grammar for Omega (`.om`), the language of |
| 4 | [aien-dev/omega-mv](https://github.com/aien-dev/omega-mv). It gives editors and tools a fast, |
| 5 | error-tolerant syntax tree of Omega source: blocks, declarations, statements, comments, text, numbers, |
| 6 | plus highlight and scope queries. |
| 7 | |
| 8 | [](https://github.com/aien-dev/tree-sitter-omega/actions/workflows/ci.yml) |
| 9 | |
| 10 | **Connected repos:** [aien-dev/omega-mv](https://github.com/aien-dev/omega-mv) (the language and |
| 11 | `omc`; this grammar is measured against commit `e5b32567` in [`omega.ref`](omega.ref)) · |
| 12 | [aien-dev/vscode-omega](https://github.com/aien-dev/vscode-omega) (VS Code support whose TextMate |
| 13 | grammar follows this one). |
| 14 | |
| 15 | ## How well it parses real Omega |
| 16 | |
| 17 | I measure the grammar against every `*.om` file in omega-mv, and I use the real compiler as the judge |
| 18 | of which files are valid. CI clones omega-mv at `omega.ref`, rebuilds `omc` from the 408-byte seed |
| 19 | (`sh seed/omega-from-seed.sh`), feeds each file to `omc`, and parses each file with this grammar. (The |
| 20 | seed chain's own limits: the 408 bytes are a binary written as commented hex text and turned into |
| 21 | bytes by a POSIX shell script whose `printf` is the one outside tool; the chain runs only on AArch64 |
| 22 | Linux; matching the published omc hash is a fixed-output reproducibility check along one build path, |
| 23 | not diverse double compilation, and it does not prove omc correct.) |
| 24 | |
| 25 | MEASURED at omega-mv `e5b32567a7aff3ce594e3254a622a846a6cd190b` (local run on a DGX Spark, 2026-10-28, |
| 26 | grammar of this commit; the file rows match CI on `ubuntu-24.04-arm` for the previous grammar, |
| 27 | [run 40430760804](https://github.com/aien-dev/tree-sitter-omega/actions/runs/40430760804)): |
| 28 | |
| 29 | | files | count | parse with zero ERROR/MISSING nodes | |
| 30 | |---|---:|---:| |
| 31 | | all `*.om` files | 811 | **789** | |
| 32 | | files `omc` accepts on its own | 393 | **393** (the CI gate: this must stay 100%) | |
| 33 | | files `omc` refuses | 418 | 396 parse clean, 22 show ERROR | |
| 34 | | library units composed as their build scripts compose them ([`test/units/omega-mv.units`](test/units/omega-mv.units)) | 16, all accepted by `omc` | **16** (also a CI gate) | |
| 35 | |
| 36 | Read the third row carefully. Most refused files are not broken syntax: library units such as |
| 37 | `om/tls/*.om` are compiled only after their build script prepends an `om2` line and concatenates them |
| 38 | with their neighbours (`om/tls/build.sh`), so `omc` refuses each one alone (for these, error 16), and |
| 39 | many test fixtures are refused for type or contract reasons that a syntax tree does not see. The 22 |
| 40 | files that show ERROR are all deliberate syntax-error fixtures, for example a missing |
| 41 | `end`, an unclosed `(`, an upper-case word, or OM-1/OM-2 brace and bracket probes: |
| 42 | |
| 43 | ``` |
| 44 | seed/omc/om2/s1/diag-eof.om seed/omc/om2/s1/diag-noend.om |
| 45 | seed/omc/om2/s3/l-bad-noend.om seed/omc/om2/s4/x-bad-nofn.om |
| 46 | seed/omc/tests/float/neg_dot.om seed/omc/tests/paren/neg_unclosed.om |
| 47 | seed/omc/tests/struct/no_end.om seed/qualification/om2/sec/s0s2/s0/upper.om |
| 48 | seed/qualification/om2/sec/s0s2/s1/{d-eof-left,d-eof-mid,d-eof-noend,d-unknown-args}.om |
| 49 | seed/qualification/om2/sec/s0s2/s2bnd/{om1,om2}-{brace,bracket,group-open,left-paren,short-eof}.om |
| 50 | ``` |
| 51 | |
| 52 | Run it yourself on any AArch64 Linux machine: |
| 53 | |
| 54 | ```sh |
| 55 | git clone https://github.com/aien-dev/tree-sitter-omega && cd tree-sitter-omega |
| 56 | npm ci --ignore-scripts && (cd node_modules/tree-sitter-cli && node install.js) |
| 57 | sha256sum -c tree-sitter-cli.sha256 # the CLI binary install.js fetched (linux-arm64) |
| 58 | git clone https://github.com/aien-dev/omega-mv /tmp/omega-mv |
| 59 | git -C /tmp/omega-mv checkout --detach e5b32567a7aff3ce594e3254a622a846a6cd190b |
| 60 | (cd /tmp/omega-mv && sh seed/omega-from-seed.sh) |
| 61 | sh scripts/coverage.sh --omc /tmp/omega-mv/seed/out/omc --units test/units/omega-mv.units /tmp/omega-mv |
| 62 | ``` |
| 63 | |
| 64 | `scripts/coverage.sh [--omc OMC] [--units MANIFEST]... [LABEL=]DIR...` measures any list of |
| 65 | directories (the label defaults to the directory's name). It prints one tab-separated line per file |
| 66 | (`path omc=accept|refuse parse=clean|error first-error-node`), one `unit:NAME` line per composed unit |
| 67 | (the first error is located as `in MEMBER:LINE`), and `COVERAGE` lines that end with every |
| 68 | directory's commit. A manifest line `unit NAME MEMBER...` concatenates its members in order, as |
| 69 | `cat` in a build script does; `each NAME LABEL:GLOB MEMBER...` makes one unit per matching file or |
| 70 | directory; a member is `LABEL:PATH` or `@om2` / `@ir` for that profile line. The script exits 1 if |
| 71 | any file or unit `omc` accepts fails to parse clean, and 2 on a usage error (an unknown label, a |
| 72 | member that matches no file). Without `--omc` it reports the `all` row and marks the oracle rows |
| 73 | NOT_RUN. `omc` is a static AArch64 Linux program; on x86_64 the oracle needs qemu-user, and I have not |
| 74 | measured that path. |
| 75 | |
| 76 | ### Every other public aien-dev repository with Omega in it |
| 77 | |
| 78 | MEASURED 2026-10-28 on a DGX Spark with the same `omc` (sha256 `2c824805…029f`), one |
| 79 | `coverage.sh` run over omega-mv and the 25 other public aien-dev repositories that hold `*.om` files, |
| 80 | with every manifest in [`test/units/`](test/units). "Before" is the previous grammar (`9b63612`) under |
| 81 | the same script and manifests. |
| 82 | |
| 83 | | repository @ commit | `*.om` files | `omc` accepts | accepted files clean, before → after | |
| 84 | |---|---:|---:|---:| |
| 85 | | omega-rosetta @ `a5b7330a` (branch `corpus/200`: 216 tasks; 47 exercises with stub, `test.om`, `.meta/example.om`) | 357 | 296 | 296 → **296**; all 357 clean | |
| 86 | | omega-bridge @ `358c5051` | 128 | 126 | 126 → **126** | |
| 87 | | CUDApp @ `e7b9e1fc` | 116 | 34 | 34 → **34** | |
| 88 | | sovereign-intelligence @ `d0f6939a` | 95 | 52 | 52 → **52** | |
| 89 | | aienos.com @ `ee3833cf` | 29 | 14 | 13 → **14** | |
| 90 | | aien-architecture-mv @ `df796a8a` | 13 | 12 | 12 → **12** | |
| 91 | | omnet @ `83f605b1` | 47 | 9 | 9 → **9** | |
| 92 | | babel @ `13ad42d9` (with `build/`, from its `build.sh`) | 10 | 2 | 1 → **2** | |
| 93 | | AienOS-nv @ `240ee9af` | 9 | 2 | 2 → **2** | |
| 94 | | omega-harness @ `82b89c28` | 2 | 2 | 2 → **2** | |
| 95 | | omega-blas, omega-dnn, omega-gpu-bench, omega-kernel-template, omega-packages, omega-bridge-kit | 7 | 6 | 6 → **6** | |
| 96 | | cortex, omtex, omega-gpu-driver, aien-sovereign-core-mv, synapse-{board,claims,map,mcp,pulse} | 75 | 0 | — | |
| 97 | | **all, with omega-mv** | **1699** | **948** | 946 → **948** | |
| 98 | | composed units in `test/units/` (94 of them omega-rosetta exercises: stub + test, example + test) | 169 | 164 | 160 → **164** | |
| 99 | |
| 100 | On omega-rosetta `main` (`60dcf9b2`, 39 files, 34 accepted) the result was the same: 34 → 34. |
| 101 | |
| 102 | Files `omc` refuses alone are mostly library units and exercise parts; the manifests compile them the |
| 103 | way their repositories' build scripts do, and those 164 units cover 209 of them. The 5 refused units |
| 104 | are the synapse tools, whose sources are marked work in progress (`omc` errors 3, 9, 12 and 23 at |
| 105 | omega-mv `e5b32567`). Beyond the 22 fixtures above, two refused files show ERROR: synapse-map |
| 106 | `src/40-xerj.om` line 134 (a stray `end`; its unit is refused with error 3) and aien-architecture-mv |
| 107 | `tools/zero-legacy/fixtures/tree/src/sh.om` (a shell script fixture). |
| 108 | |
| 109 | The two defects these runs found are fixed in this grammar: the `note` comment was lexed inside text |
| 110 | (`" note "`, `"x\nnote add three\nfn"`: a MISSING `"` in seven files and four units), and a name that |
| 111 | starts with `note` (`notes`, `noted`) was split into a comment and a name without any ERROR node |
| 112 | (`omc` ends the `note` word at a blank, a parenthesis or the end). Both are cases in |
| 113 | [`test/corpus/notes.txt`](test/corpus/notes.txt). |
| 114 | |
| 115 | ## What the grammar knows, and where it stops |
| 116 | |
| 117 | Omega is line oriented: one statement per line, words separated by blanks, `(` and `)` as words of |
| 118 | their own, `note` starting a comment line. As in `omc`, the comment word is exactly `note`, ended by a |
| 119 | blank, a parenthesis or the end of the line (`notes` and `noted` are names), and a `note` inside text |
| 120 | is text. The grammar gives structure to everything that is context free: |
| 121 | |
| 122 | - `fn ... to ...` / `export fn` definitions with parameter list and return type, closed by `end` |
| 123 | - `if` / `else`, `while` (with an optional `bound`), `for`, `layout` with `field` lines, one-line `struct ... end` |
| 124 | - `global`, `text`, `const`, `abstract`, `holds` declarations and the `om2 ...` / `ir` profile line |
| 125 | - `ret`, `put`, `trap`, `exit`, `break`, `continue`, `name = value` assignments and call lines |
| 126 | - integers (decimal, `0x` hex), floats (`1.5`, `2.5e-3`, `3f32`), text with escapes, `*` unsized views |
| 127 | |
| 128 | Values stay a flat sequence of words. Omega values are prefix expressions whose arity depends on each |
| 129 | word and, for calls, on the callee's signature, so a context-free grammar cannot build the call tree |
| 130 | honestly; I leave that to `omc`. Operator, type, contract and host words (`add`, `uint`, `requires`, |
| 131 | `fopen`, ...) are ordinary identifiers in the tree and get their colour from |
| 132 | [`queries/highlights.scm`](queries/highlights.scm), because OM-1 units may use OM-2 words such as `open` |
| 133 | or `field` as names; a name a declaration defines (`fn rotr`, `global out`, `at = ...`) keeps the |
| 134 | definition's colour. A word the Omega lexer would reject, like `0xG1`, can still split into tokens here |
| 135 | without an ERROR node. This is a syntax tree for editors, not a checker; `omc` remains the authority. |
| 136 | |
| 137 | ## Tests and CI |
| 138 | |
| 139 | - `tree-sitter test` runs [`test/corpus/`](test/corpus) (16 cases, 4 of them must produce ERROR) and the |
| 140 | highlight assertions in [`test/highlight/`](test/highlight) (22 assertions in 2 files). |
| 141 | - CI regenerates `src/` with the pinned CLI and fails if it differs from the committed parser. |
| 142 | - The coverage gate: every omega-mv file `omc` accepts, and the 16 units in |
| 143 | [`test/units/omega-mv.units`](test/units/omega-mv.units), must parse clean. |
| 144 | - Negative control 1: [`test/negative/malformed.om`](test/negative/malformed.om) must parse with ERROR. |
| 145 | - Negative control 2: the coverage gate, given an oracle that accepts everything, must fail on that |
| 146 | malformed file. |
| 147 | - Negative control 3: the same fake oracle and a unit that composes the malformed file with a valid |
| 148 | one must fail as `unit:... parse=error ... in malformed.om:<line>`, naming the malformed member. |
| 149 | |
| 150 | ## Use it |
| 151 | |
| 152 | The `tree-sitter.json` metadata, generated parser and bindings for C, Go, Node, Python, Rust and |
| 153 | Swift are in this repository (from `tree-sitter init`). CI builds the parser through `tree-sitter |
| 154 | test`; I have not yet published the bindings to npm, crates.io or PyPI, and I have not yet run them |
| 155 | inside Neovim, Helix or Zed. For VS Code, use [aien-dev/vscode-omega](https://github.com/aien-dev/vscode-omega). |
| 156 | |
| 157 | ## Editors and registries |
| 158 | |
| 159 | Where I checked each project's rule for taking a new grammar (2026-10-27), and where Omega stands: |
| 160 | |
| 161 | | project | rule | status | |
| 162 | |---|---|---| |
| 163 | | GitHub Linguist | [CONTRIBUTING: usage requirements](https://github.com/github-linguist/linguist/blob/main/CONTRIBUTING.md#language-extension-and-filename-usage-requirements): at least 2000 files per extension indexed in the last year, spread across many users; the language owner's own repos are filtered out | not met. GitHub code search on 2026-10-27: `extension:om "fn main to int"` gives 718 files, and `-org:aien-dev` gives 0. No PR until Omega is used widely outside my repos | |
| 164 | | nvim-treesitter | [CONTRIBUTING: Parsers](https://github.com/nvim-treesitter/nvim-treesitter/blob/main/CONTRIBUTING.md#parsers): the filetype must be detected by Neovim nightly, the parser tested by users, CI via tree-sitter/workflows, queries checked by `ts_query_ls` | gated: Neovim does not detect `.om` as Omega yet, and the grammar has no outside users yet | |
| 165 | | Helix | [Adding new languages](https://github.com/helix-editor/helix/blob/master/book/src/guides/adding_languages.md): a `languages.toml` entry, Helix-named queries in `runtime/queries/<name>/`, `cargo xtask docgen` | no written usage gate; not submitted, because I have not run the grammar inside Helix (Helix uses its own capture names) | |
| 166 | | Zed | [Publishing prerequisites](https://zed.dev/docs/extensions/publishing/prerequisites): a Zed extension repo, tested manually in Zed at the submitted commit, then a PR to zed-industries/extensions | gated: needs a manual test in Zed, which I have not run | |
| 167 | |
| 168 | ## Foreign dependencies |
| 169 | |
| 170 | These are packaging and editor glue, not part of Omega: |
| 171 | |
| 172 | | dependency | version | what it does here | |
| 173 | |---|---|---| |
| 174 | | tree-sitter-cli (npm, Rust binary) | 0.27.1, linux-arm64 binary sha256 in `tree-sitter-cli.sha256` | generates `src/parser.c` from `grammar.js`, runs the tests, parses the corpus | |
| 175 | | Node.js | 24 | evaluates `grammar.js` and runs the CLI wrapper | |
| 176 | | tree-sitter (npm), node-addon-api, node-gyp-build, prebuildify | as locked in `package-lock.json` | Node binding scaffold from `tree-sitter init`; not used by CI | |
| 177 | |
| 178 | The Omega side has no replacement yet: an Omega-native parser generator would be the |
| 179 | first-party path, and until it exists the generated C parser is the tree-sitter project's format. |
| 180 | |
| 181 | ## Licence |
| 182 | |
| 183 | Apache-2.0 WITH LLVM-exception. See [LICENSE](LICENSE) and [NOTICE](NOTICE). |
| 184 | |
| 185 | ## Human-Directed Agentic Engineering |
| 186 | |
| 187 | Development follows Human-Directed Agentic Engineering (HDAE): humans define goals, |
| 188 | architecture, constraints, acceptance criteria, and stopping points; agents implement, |
| 189 | execute checks, diagnose failures, and revise within those boundaries. Human review |
| 190 | retains responsibility for claims, acceptance, and release decisions. This describes |
| 191 | the development method, not a change to runtime autonomy or historical evidence. |
| 192 | |
| 193 | For the documented method and a systems-software case study, see Gregory M. Kurtzer |
| 194 | (2026), *Ginux: Building an Independent Kernel That Runs Linux Userspace through |
| 195 | Human-Directed Agentic Engineering*, technical report, v1, Zenodo, |
| 196 | <https://doi.org/10.5281/zenodo.23682548>. |