finds.dev

mjackson/citrus

Parsing Expressions for Ruby

View on GitHubHomepage ↗

★ 411Rubyupdated Aug 2021

// the take

Citrus is a PEG (parsing expression grammar) library for Ruby, letting you write grammars in a dedicated DSL and attach Ruby modules or inline blocks to turn matches into actual values. It's aimed at Ruby developers building small-to-medium parsers (config formats, DSLs, simple languages) who want something lighter than a full compiler-compiler.

The DSL itself is well thought out — labels, ordered choice, lookahead/not-predicate/but-predicate, and a working `super` mechanism so grammars can be composed via module inclusion rather than copy-paste. Semantic actions can live inline or in separate Ruby modules via `<ModuleName>`, which keeps grammar files readable instead of turning into a wall of embedded Ruby. Error reporting via `ParseError` gives line number, offset, and line text out of the box, so you're not stuck debugging with nothing but a boolean match/no-match. It's pure Ruby with no native extension to compile, so installation is trivial.

Last commit is from August 2021 — this is effectively unmaintained, and with only 411 stars after 11+ years it never built significant adoption outside a small niche. There's no visible CI config in the repo tree, so you have no signal on whether it still passes its own test suite against current Ruby versions. Introducing a custom `.citrus` grammar file format means you need `Citrus.load`/`Citrus.eval` tooling and editor support (the bundled TextMate/Vim syntax files are themselves old) rather than writing parsers in plain Ruby, which raises the barrier for casual use. No stated performance characteristics or benchmarks results in the README despite a `benchmark/` directory existing, so you're on your own figuring out if it scales to real input sizes.

We read the README, the directory tree and a key source file in October 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
411
Forks
23
Language
Ruby
Last commit
28 Aug 2021

// nearby

If citrus isn't quite it.

All repos →