Grammars
jint uses tree-sitter to parse your code and embeds ten grammars in the binary.
A grammar is a directory named for its id. It holds three files:
<id>.wasmparses the language. Itstree_sitter_<id>export must match the directory name.extensions.jsonroutes files to the grammar. It is a bare JSON array, such as[".md"].queries.scmholds the extraction patterns and the shape directives.
The walker knows no node types. The .scm assigns captures, and the rest of jint
sees only captures.
Your own grammars live in $JINT_GRAMMAR_DIR, default ~/.jint/grammars. Each subdirectory is one
grammar. See Bring your own grammar.
Embedded grammars
| grammar | extensions |
|---|---|
typescript |
.ts, .mts, .cts |
tsx |
.tsx |
python |
.py |
go |
.go |
c |
.c, .h |
cpp |
.cpp, .cc, .cxx, .hpp, .h |
css |
.css |
markdown |
.md |
php |
.php |
bash |
.sh, .bash |
Both c and cpp claim .h. Registration order decides, and cpp serves it.
css captures comments only, because the code captures have no honest reading of css.
Walk
The walk turns one parsed file into elements. Each element carries a capture, a span, a positional
label (d0, c2, i0), an optional name, its parent label and its source.
- Parsing is demand-driven. jint parses a file only when a rule targets elements in it. A
filesrule reads the raw source and skips the parse. - Unparsed files are a note. Without a grammar, a file is measured as raw source by a
filesrule. Otherwise the run notes it once, for examplenot parsed (no grammar): .json, .sql. - A named file with no grammar is an error. An explicit path, an element-target rule and no
grammar give a
MISSING_GRAMMARsetup error that names the supported grammars.