A tree-sitter grammar for SugarCube V2. It's been tested against a (small) suite of test passages and individual passages from a game.
I created this to pair with a zed extension since the Zed editor lacks any syntax highlighting for Twine/Sugarcube.
This grammar was written almost entirely by a combination of Claude 4.6 and a local model, Qwen 3.6 35B. I guided the models and provided insight that models would not reach on their own. Nevertheless, this is almost entirely AI-generated.
I learned a bit about making a grammar for tree-sitter and more about wrangling an LLM to do what I want. If I had written it on my own, I would have learned more about tree-sitter but that really was never the point. I just wanted syntax highlighting in Zed. The alternative wasn't writing a grammar by hand, it was using VSCodium with the Twee 3 Language tools.