How tree-sitter/tree-sitter-rust works
Project type and purpose
• This is an open-source Tree-sitter grammar library for Rust (“tree-sitter-rust”) with first-class language bindings (C, Go, Node, Python, Rust, Swift) and query files for highlighting, injections, and tags.
• Purpose: define Rust’s grammar, generate a C parser/lexer library, and expose it to multiple host languages for incremental parsing in editors, linters, formatters, etc.
File structure
• Top-level build/config files: CMakeLists.txt, Makefile, binding.gyp, Cargo.toml, Package.json, setup.py, pyproject.toml, go.mod, Package.swift
• Core grammar & parser implementation in src/ and grammar.js, scanner.c, parser.c, node-types.json, grammar.json
• Language bindings under bindings/{c,go,node,python,rust,swift}
• Query files (highlighting, injections, tags) in queries/
• Examples in examples/, tests in test/ and bindings/*/tests
• CI/workflows in .github/workflows/
README for additional insights
• Confirms it’s a performance-focused grammar implementation