No description
  • Zig 99.6%
  • JavaScript 0.4%
Find a file
2026-11-24 12:23:59 +01:00
docs feat(export): a reading page export, Markdown doc comments kept as written 2026-11-01 01:29:41 +01:00
editors/vscode fix(vscode): package the extension with its language client 2026-10-28 02:36:40 +01:00
examples feat(export): a reading page export, Markdown doc comments kept as written 2026-11-01 01:29:41 +01:00
src fix(loader): a missing import names its path with / on every OS 2026-11-24 12:23:59 +01:00
tests/corpus feat(export): a reading page export, Markdown doc comments kept as written 2026-11-01 01:29:41 +01:00
.gitattributes feat(compiler): Nex 0.2, a compiler for small typed graphs 2026-10-27 21:00:37 +01:00
.gitignore feat(compiler): Nex 0.2, a compiler for small typed graphs 2026-10-27 21:00:37 +01:00
build.zig feat(compiler): Nex 0.2, a compiler for small typed graphs 2026-10-27 21:00:37 +01:00
build.zig.zon feat(compiler): Nex 0.2, a compiler for small typed graphs 2026-10-27 21:00:37 +01:00
LICENSE feat(compiler): Nex 0.2, a compiler for small typed graphs 2026-10-27 21:00:37 +01:00
README.md feat(export): a reading page export, Markdown doc comments kept as written 2026-11-01 01:29:41 +01:00
SPEC.md feat(export): a reading page export, Markdown doc comments kept as written 2026-11-01 01:29:41 +01:00

Nex: a compiler for small typed graphs

nex reads graphs written by hand in Nex, a declarative, strictly typed language (SPEC.md), checks them against the rules their author states, lints them, answers queries about them, exports them, and serves editors over the Language Server Protocol. It is a standalone Zig package, std only. The examples are a proof ledger (examples/proofs/), a curriculum and a build order. New to it: docs/guide.md; looking something up: docs/reference/.

Running it

zig build                                  # zig-out/bin/nex
zig build check                            # the gate: tests, corpus, examples, formatting
zig-out/bin/nex check examples/proofs/ledger.nex
zig-out/bin/nex lint examples/proofs/ledger.nex     # check, then the hygiene warnings
zig-out/bin/nex query examples/proofs/ledger.nex 'closure(rh, assumes.sources | premises.sources)'
zig-out/bin/nex export examples/proofs/ledger.nex --format dot | dot -Tsvg > ledger.svg
zig-out/bin/nex export examples/proofs/infinitely-many-primes.nex --format md > primes.md   # one page to read
zig-out/bin/nex lsp                                   # the language server, for an editor to start

Zig 0.16.0, pinned to the patch.

What is here

path what
SPEC.md the language: model, grammar, rule language, checks, lint, exports
docs/reference/ the complete language reference: seventeen chapters, every construct, message and limit
docs/guide.md, docs/design.md, docs/editors.md the tutorial, the reasoning behind the design, and editor setup
src/tokenizer.zig source to tokens, with positions
src/parser.zig tokens to the syntax tree (ast.zig)
src/loader.zig files and imports, units collected first
src/sema.zig resolution, typing, lowering to edges, endpoint rules, axioms
src/rules.zig derive to a fixed point, check and warn, queries
src/lint.zig the hygiene warnings
src/export.zig JSON and DOT
src/markdown.zig the reading page: one Markdown page per module
src/lsp.zig the language server: diagnostics, semantic tokens, hover, definition, symbols
src/pipeline.zig, src/main.zig the whole run, and the command line
examples/proofs/ a proof calculus as a library, a ledger of elementary number theory that imports it, and infinitely-many-primes.nex, a topic written to be read
examples/curriculum/ Nex 0.1's curriculum, in 0.2
examples/rts/ a build-order graph with reachability and tier checks
tests/corpus/ one .nex per class of error, with the diagnostics it must give in .expected
editors/vscode/ the VS Code extension: a TextMate grammar and the client for nex lsp

Conventions

The parser and the evaluator recurse over nested input, each with a named depth limit (DEPTH_MAX, 64) that turns deeper input into an error. A compiler's grammar is recursive, and the limit keeps the recursion bounded.

A change to the language changes SPEC.md and docs/reference/ in the same commit, and a new diagnostic gets a corpus case and a row in docs/reference/13-diagnostics.md.

Licence

MIT, in LICENSE.