Skip to content

Source Code Analysis โ€‹

Problem โ€‹

Counting constructs, measuring nesting, and extracting structure from text with regex breaks on nesting and comments.

Why tree-sitter.zig helps โ€‹

The tree already encodes nesting; a cursor walk with depth tracking yields exact metrics.

API โ€‹

TreeCursor (depth, nodeType), Node.descendantCount.

Architecture โ€‹

text
Parse โ†’ cursor walk โ†’ classify by type โ†’ aggregate metrics

Example โ€‹

Count binary operations and max nesting depth in one pass over a + b * (c - d).

Next steps โ€‹

Released under the MIT License.