#tree-sitter #rpg #dice #xdy

tree-sitter-xdy

tree-sitter grammar for xDy dice expression language

2 unstable releases

Uses new Rust 2024

new 0.8.0 Apr 26, 2025
0.7.0 Apr 24, 2025

#617 in Math

Download history 89/week @ 2025-04-19

89 downloads per month
Used in xdy

BSD-3-Clause

74KB
2K SLoC

C 2K SLoC JavaScript 106 SLoC // 0.3% comments Rust 30 SLoC // 0.2% comments

xDy: Tree-sitter

This is the Tree-sitter grammar for the xDy dice expression language. Most of the mainline documentation is in the compiler crate, where the compiler, optimizer, evaluator, and application reside.

Building

The Rust bindings are checked in, so you can build the compiler without doing anything special. The relevant build instructions are here, and you can safely ignore the directions hereinafter unless you want to build bindings for a different language or modify the grammar.

Generating the parser

To generate the parser, you need to have the tree-sitter command-line tool installed. There's a Rust version and a Node.js version, and you can find the pertinent installation instructions here. Once you have the tool installed, you can generate the parser using npm:

$ npm run build

Or using tree-sitter directly:

$ tree-sitter generate
$ tree-sitter build

Testing

After the parser has been generated, you can run the tests using npm:

$ tree-sitter test

Or you can run the grammar tests and the Rust integration test piecewise:

$ tree-sitter test
$ cargo test

Dependencies

~2.8–4.5MB
~81K SLoC