tree-sitter-forge-card-script 0.1.0

Tree-sitter grammar for the Forge card-script DSL used by Magic: The Gathering rules engines
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 1 items with examples
  • Size
  • Source code size: 176.36 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 301.56 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • witchesofthehill/manabrew
    40 19 90
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • khaliostr

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:

yarn install
yarn generate      # tree-sitter generate
yarn test          # runs the corpus tests under test/corpus/
yarn parse <file>  # parse a card script and print its tree

Syntax-highlighting queries live in queries/highlights.scm.

Rust binding

[dependencies]
tree-sitter = "0.24"
tree-sitter-forge-card-script = "0.1"
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_forge_card_script::language()).unwrap();
let tree = parser.parse("Name:Grizzly Bears\nPT:2/2\n", None).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.