Skip to content
@go-ruby-parser

go-ruby-parser

go-ruby-parser

go-ruby-parser

A Ruby front-end in pure Go — lexer, parser, AST. No cgo, no Prism.

🌐 Website · 📚 Documentation

Docs License: BSD-3-Clause Go 1.26.4+ Coverage 100%


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).

Repositories

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

Principles

  • 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.Program API 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).

Status

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.

Popular repositories Loading

  1. parser parser Public

    Pure-Go (CGO=0) Ruby front-end: lexer, parser, AST

    Go

  2. brand brand Public

    Brand assets — logos & icons

  3. go-ruby-parser.github.io go-ruby-parser.github.io Public

    go-ruby-parser organization landing page

    HTML

  4. docs docs Public

    go-ruby-parser documentation (MkDocs Material)

  5. .github .github Public

Repositories

Showing 5 of 5 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…