1
0
treerack/readme.md
2026-01-18 22:52:27 +01:00

2.4 KiB

treerack

A parser generator for Go.

Treerack defines and generates recursive descent parsers for arbitrary syntaxes, processing input content into its Abstract Syntax Tree (AST) representation. It utilizes a custom syntax definition format derived from EBNF (Extended Backus-Naur Form), allowing for clear and concise grammar descriptions.

Examples

Overview

Treerack operates without a separate lexing phase, parsing character streams directly to produce an AST. The syntax language supports recursive references, enabling the definition of context-free grammars.

We can define syntaxes during development and use the provided tool to generate static Go code, which is then built into the application. Alternatively, the library supports loading syntaxes dynamically at runtime.

Installation

From source:

git clone https://code.squareroundforest.org/arpio/treerack
cd treerack
make install

Alternatively:

go install code.squareroundforest.org/arpio/treerack/cmd/treerack

Documentation

Developer Notes

We use a Makefile to manage the build and verification lifecycle.

Important: Generating the parser for the Treerack syntax itself (bootstrapping) requires multiple phases. Consequently, running standard go build or go test commands may miss subtle consistency problems.

The authoritative way to verify changes is via the makefile:

make check

Limitations

  • Lexer & UTF-8: Treerack does not require a lexer, which simplifies the architecture. However, this enforces the use of UTF-8 input. We have considered support for custom tokenizers as a potential future improvement.
  • Whitespace Delimited Languages: Due to the recursive descent nature and the lack of a dedicated lexer state, defining whitespace-delimited syntaxes (such as Python-style indentation) can be difficult to achieve with the current feature set.