1
0
Go to file
2026-06-06 22:06:11 +02:00
cmd/treerack set tracing on by default for the utility commands 2026-06-06 22:06:11 +02:00
doc trace parse errors 2026-06-06 21:19:04 +02:00
internal/self only use tracing when explicitly enabled 2026-06-06 21:48:50 +02:00
script formatter script for local syntax files 2026-06-01 21:29:33 +02:00
.gitignore format command line command 2026-06-02 00:04:03 +02:00
.travis.yml update travis key 2017-11-05 04:05:22 +01:00
boot_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
boot.go use generated syntax for all parsers 2018-01-05 19:06:10 +01:00
char_test.go recover tests 2018-01-06 21:30:07 +01:00
char.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
chardefine.go check if all parsers are referenced 2026-06-06 05:54:48 +02:00
check_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
choice.go trace parse errors 2026-06-06 21:19:04 +02:00
choicedefine.go trace parse errors 2026-06-06 21:19:04 +02:00
context_test.go simplify build time pending check 2017-11-06 11:41:00 +01:00
context.go only use tracing when explicitly enabled 2026-06-06 21:48:50 +02:00
define.go flag to override automatic fail pass 2026-06-06 05:23:32 +02:00
errors_test.go trace parse errors 2026-06-06 21:19:04 +02:00
escape_test.go documentation 2026-01-18 22:52:27 +01:00
escape.go documentation 2026-01-18 22:52:27 +01:00
format_test.go automatic fail pass for alias definitions 2026-06-06 04:50:27 +02:00
format.go automatic fail pass for alias definitions 2026-06-06 04:50:27 +02:00
gendoc.go add go modules 2025-08-19 00:56:08 +02:00
generate_test.go generator tests 2018-01-06 22:56:26 +01:00
go.mod refactor build 2026-01-16 01:03:43 +01:00
go.sum refactor build 2026-01-16 01:03:43 +01:00
head.gen.go only use tracing when explicitly enabled 2026-06-06 21:48:50 +02:00
headexported.gen.go only use tracing when explicitly enabled 2026-06-06 21:48:50 +02:00
idset_test.go improve testing 2017-11-05 03:28:36 +01:00
idset.go track parsers by numeric id 2017-07-15 21:49:08 +02:00
json_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
keyval_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
keyword_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
license use non-screaming casing 2025-10-22 21:01:15 +02:00
makefile trace parse errors 2026-06-06 21:19:04 +02:00
mml_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
mmlexp2_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
mmlexp3_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
mmlexp_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
noai noai entry 2026-04-03 14:27:12 +02:00
node_test.go improve testing 2017-11-05 03:28:36 +01:00
node.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
nodehead.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
notes.txt error fixes and doc updates 2026-01-21 20:54:16 +01:00
open_test.go fix choice error reporting 2017-11-25 22:01:02 +01:00
parse_test.go only use tracing when explicitly enabled 2026-06-06 21:48:50 +02:00
readme.md URL example 2026-06-05 18:08:33 +02:00
registry.go check if all parsers are referenced 2026-06-06 05:54:48 +02:00
results_test.go simplify build time pending check 2017-11-06 11:41:00 +01:00
results.go refactor parsing phase 2017-12-31 17:34:10 +01:00
run_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
scheme_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
sequence.go trace parse errors 2026-06-06 21:19:04 +02:00
sequencedefine.go trace parse errors 2026-06-06 21:19:04 +02:00
sexpr_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
syntax_test.go check if all parsers are referenced 2026-06-06 05:54:48 +02:00
syntax.go only use tracing when explicitly enabled 2026-06-06 21:48:50 +02:00
syntax.treerack flag to override automatic fail pass 2026-06-06 05:23:32 +02:00
syntaxhead.go only use tracing when explicitly enabled 2026-06-06 21:48:50 +02:00
trace.go trace parse errors 2026-06-06 21:19:04 +02:00
whitespace_test.go replace Node pointers with values 2026-06-01 22:26:27 +02:00
whitespace.go trace parse errors 2026-06-06 21:19:04 +02:00

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.

The parser engine handles recursive references and left-recursion internally. This way it makes it more convenient writing intuitive grammar definitions, and allows defining context-free languages without complex workarounds.

Installation

From source (recommended):

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

Installing it to one's home directory:

prefix=~/.local make install

Alternatively ("best effort" basis):

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

Made in Berlin, DE