Tree-sitter grammar for the Ring programming language (.ring, .rh, .rform).
- Full core language — all three function styles (
func name(params),func name params,func name), all statement terminators (ok/end/endif/next/loop/off/...), classes, packages, anonymous functions, and typed parameters - Faithful keyword demotion —
to/in/from/stepparse as keywords only inforbounds andclass ... fromparents, and as identifiers everywhere else, exactly like Ring's own parser - Same-line postfix rule — a call's
(and a subscript's[must sit on the same line as their operand; enforced by the external scanner - OOP and brace syntax —
new/new from, brace initialization, constructor calls, and brace-object access (obj { ... }) - Rich literals — string interpolation (
#{...}), multiline strings, list literals, all comment forms (//,/* */,#), the^^power operator - Unicode identifiers — including Arabic
- Battle-tested — 147 corpus tests; verified against Ring's own
language/tests/,samples/, andlibraries/(every syntactically valid, non-DSL file parses)
- Editor support — accurate syntax highlighting, code folding, symbol outlines, and navigation in tree-sitter-based editors (Neovim, Helix, Zed, Emacs)
- Developer tooling — a ready-made foundation for a Ring formatter, linter, or language server
- Code intelligence — structural search-and-replace, semantic diffs, metrics, and documentation generators
- AI tooling — code indexing and repo maps that let AI coding assistants understand Ring projects
- Programmatic parsing — Node/Python/Rust/Wasm bindings for scripts, doc sites, and playgrounds
bun install
bun run build # tree-sitter generate
bun run test # run the 147 corpus tests
# Parse any Ring file:
bun run parse yourfile.ringRing mutates its own syntax at runtime; a static grammar cannot follow that. The following are unsupported by design:
- NaturalLib natural-language DSL — commands defined at runtime (
I want window, ...) ChangeRingKeyword/ChangeRingOperator— keywords/operators remapped while the program runs; only remapping onto an already-demotable keyword (e.g.changeringkeyword in) parses- Counter-guarded keywords —
ok/on/off/catch/done/again/but/else/other/casedemote to identifiers in expression positions, a superset of Ring's runtime-counter behavior (so e.g.if ok = 5parses here although Ring rejects it);loop/exit/break/continue/put/get/returnnever demote — exactly like Ring - TypeHints-style declarations — C-style prefixes such as
public static void func ...
This project is licensed under the MIT License. See the LICENSE file for details.