| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A tree-sitter grammar for Minecraft Bedrock .mcfunction files.
Minimal grammar focused on syntax highlighting. Designed to pair with the Rockide language server, which handles semantic features (completion, hover, goto-definition) via its own parser. Scope is Bedrock commands only — Java Edition commands are intentionally omitted.
| Node | Description |
|---|---|
| command | A command line: command_name + arguments |
| command_name | First token (one of 85 Bedrock commands) |
| comment | Single-hash comment: # ... |
| region_comment | Double-hash comment: ## ... (for fold markers) |
| selector | Target selector: @s, @e[type=...] |
| coordinate | Relative/local position: ~, ~5, ^-3 |
| number | Integer or decimal |
| string | Double-quoted |
| boolean | true / false |
| resource_location | Namespaced identifier: minecraft:stone |
Install the Rockide for Zed extension — it bundles this grammar.
Install via your editor's tree-sitter plugin. Highlight queries are in queries/highlights.scm.
npm install tree-sitter-mcfunctionconst Parser = require("tree-sitter");
const mcfunction = require("tree-sitter-mcfunction");
const parser = new Parser();
parser.setLanguage(mcfunction);
const tree = parser.parse("say Hello\n");
console.log(tree.rootNode.toString());Add to Cargo.toml:
[dependencies]
tree-sitter = "0.22"
tree-sitter-mcfunction = "0.1"use tree_sitter::Parser;
use tree_sitter_mcfunction::language;
let mut parser = Parser::new();
parser.set_language(&language()).expect("Error loading grammar");
let tree = parser.parse("say Hello\n", None).unwrap();
println!("{}", tree.root_node().to_sexp());Prerequisites: Node.js 18+.
| Command | Purpose |
|---|---|
| npm run sync-commands | Re-scrape Bedrock command list from Microsoft docs |
| npm run generate | Regenerate parser from grammar.js |
| npx tree-sitter test | Run corpus tests |
| npx tree-sitter parse <file> | Parse a file and print its tree |
src/commands.json is generated, not hand-edited. The grammar reads it at generation time. To check for new commands, run npm run sync-commands or trigger the Sync Commands workflow (manual workflow_dispatch) — it opens a PR automatically if anything changed.
Corpus tests live in test/corpus/. Run npx tree-sitter test -u to update expected trees after grammar changes.
MIT
| Back | FazBrowse Home | New Git URL |