All projects

Arborist

A PEG parser combinator in Crystal, with support for left and right recursion and a command-line parser.

Technologies: Crystal, Parsing, PEG

GitHub repository

Giving syntax a structure

Arborist is a parsing expression grammar (PEG) parser written in Crystal. It supports left and right recursion, including left-associative left recursion, and can be used as a parser combinator library or a command-line tool.

The same core idea supports two workflows: compose a parser inside a Crystal program, or describe a grammar in a file and use it to parse an input document.

From a grammar to a parse tree

The command-line parser reads a grammar and produces a parse tree that can be written to a file or piped to another tool. As a library, Arborist also supports semantic actions associated with a grammar.

That separation is useful: the grammar describes the structure, while a later step decides what to do with the result.

What this project explores

  • PEG parsing and parser composition.
  • Left-recursive expression grammars.
  • Parse-tree output for downstream processing.
  • Grammar-driven tools in Crystal.

The repository includes command-line examples and library usage.