Tree-sitter grammar for the Noir zero-knowledge programming language.
- Full syntax support for Noir language constructs
- Zero-knowledge specific syntax (
constrain,assert,assert_eq) - Comptime and unconstrained functions
- Structs, enums, traits, and impl blocks
- Generic types and turbofish syntax
- Format strings and interpolation
- Comprehensive syntax highlighting queries
npm install tree-sitter-noircargo add tree-sitter-noir# Parse a file
tree-sitter parse example.nr
# Run tests
tree-sitter testconst Parser = require("tree-sitter");
const Noir = require("tree-sitter-noir");
const parser = new Parser();
parser.setLanguage(Noir);
const tree = parser.parse(`
fn main() {
let x: Field = 5;
assert(x == 5);
}
`);.nr- Noir source files
The grammar includes the following query files:
queries/highlights.scm- Syntax highlightingqueries/locals.scm- Local variable scopingqueries/injections.scm- Language injections
# Install dependencies
npm install
# Generate parser from grammar
npm run build
# Run tests
npm test
# Build WASM version
npm run build-wasmMIT