tree-sitter-forge-card-script
A tree-sitter grammar for the Forge card-script DSL — the text format used to describe Magic: The Gathering cards in the Forge rules engine. Part of the ManaBrew project.
It parses the line-oriented card format: field lines (Name:, ManaCost:, …), ability/trigger/
static/replacement lines (A:, T:, S:, R:), SVar: definitions, keyword (K:) lines,
$-delimited parameter records, comments, and multi-face cards (ALTERNATE, SPECIALIZE,
AlternateMode).
Usage
The grammar is authored in grammar.ts (TypeScript DSL). Regenerate and test with the
tree-sitter CLI:
Syntax-highlighting queries live in queries/highlights.scm.
Rust binding
[]
= "0.24"
= "0.1"
let mut parser = new;
parser.set_language.unwrap;
let tree = parser.parse.unwrap;
Coverage note
The grammar recognises the common Forge field keys explicitly; an unrecognised Key: line will
produce an error node. The companion forge-card-script
crate is more permissive and degrades unknown fields gracefully, so the two can disagree on
unusual input.
License
MIT. See LICENSE.