A Ruby front-end in pure Go — lexer, parser, AST. No cgo, no Prism.
🌐 Website · 📚 Documentation
go-ruby-parser is a pure-Go (CGO=0) Ruby front-end — a stateful lexer, a recursive-descent parser with a Pratt expression core, and a typed AST for Ruby source. No cgo, no Prism, no shelling out to Ruby: the front-end the Go ecosystem lacked for building Ruby tooling (linters, formatters, analysers, doc generators, LSP servers, transpilers) in pure Go.
It was extracted from
go-embedded-ruby — the pure-Go Ruby
VM, which now consumes it — and is grown test-first against MRI Ruby 4.0.5,
with 100% coverage enforced in CI across the six 64-bit targets. Being
CGO-free, it also compiles to WebAssembly (js/wasm and wasip1/wasm).
| Repo | What it is |
|---|---|
| parser | the library: parser.Parse(src) (*ast.Program, error), with sub-packages token, ast and lexer — a stateful lexer (MRI spaceSeen semantics), a recursive-descent + Pratt parser with a scope stack, and a typed AST for a broad, practical subset of Ruby 4.0, differential-tested against MRI |
- Pure Go, zero cgo.
CGO_ENABLED=0— no cgo, no Prism, no Ruby process. Cross-compiles and embeds anywhere; a static binary by default, and compiles to WebAssembly. - Differential-tested against MRI 4.0.5. The grammar is validated against the reference interpreter's own parser on a harvested corpus and real CRuby stdlib files.
- Reusable. A clean
Parse → *ast.ProgramAPI any Go tool can build on — linters, formatters, LSP servers, doc generators, transpilers. - 100% test coverage is the target, enforced as a CI gate, green across the six 64-bit Go targets (amd64, arm64, riscv64, loong64, ppc64le, s390x).
A pure-Go Ruby front-end covering a broad, practical subset of Ruby 4.0 — a
stateful lexer, a recursive-descent + Pratt parser, and a typed AST (literals,
operators, control flow, case/in pattern matching, methods/blocks,
classes/modules/metaprogramming). Differential-tested against MRI Ruby 4.0.5,
100% coverage, CI green across 6 arches, and it also builds for WebAssembly. It
is the front-end member of the sibling go-ruby-* family — alongside
go-ruby-marshal and
go-ruby-regexp — that
go-embedded-ruby builds on.
BSD-3-Clause.
