A Tree-sitter grammar for SudoLang, the pseudolanguage for instructing LLMs.
- Source: https://github.com/dylan-gluck/tree-sitter-sudolang
- Editor extension: https://github.com/dylan-gluck/zed-sudolang
Version 0.3.2 targets SudoLang v2.2, a strict superset of v2.1. The grammar needs strict block structure and rejects bare prose lines. Write prose as a string literal or as a comment. Identifiers and property names are single words. The grammar reads # Section heading markers at the top level and inside blocks, which drives outline navigation.
Version 2.2 adds:
- qualified capability names:
mcp::linear.getIssue(id) - named arguments:
f(branch = x) - guard statements:
cond -> stmt - decorators:
@retry(3) - optional chaining
?.and nullish default?? - spread and rest
... - the pipe placeholder
_
Read examples/issue-to-pr.sudo for a program that uses all of them.
Write SudoLang in markdown with sudo code fences. Use a plain .md file, or use .sudo.md to mark the file as SudoLang content. Markdown documents need tree-sitter-markdown. A ```sudo or ```SudoLang fence injects this grammar into the fence body. A pure .sudo file holds one whole program and no prose, and the parser reads it as one unit.
For the literate form, read examples/showcase-2.2.sudo.md. To validate fences from a script, read scripts/parse-examples.sh.
From npm, with the Node bindings, the queries, and the wasm build:
npm install tree-sitter-sudolangFrom crates.io, with the Rust binding. The parser is ABI 15, so pair it with tree-sitter >= 0.25:
[dependencies]
tree-sitter = "0.25"
tree-sitter-sudolang = "0.3.2"npm install
npx tree-sitter generate
npx tree-sitter test
npx tree-sitter parse examples/ai-rpg.sudo
npx tree-sitter build --wasmDefault queries ship under queries/:
highlights.scmfor syntax highlightinginjections.scmis empty by design. Injection intosudofences is the job of the host grammar.locals.scmfor scope trackingtags.scmfor ctags and GitHub linguist
An editor integration can shadow these files. See zed-sudolang for the Zed extension that pins this grammar.
MIT. See LICENSE.