Practise vocabulary for tree-sitter and Abstract Syntax Trees: grammar rules, syntax nodes, incremental parsing, and tree queries.
0 / 5 completed
1 / 5
An Abstract Syntax Tree (AST) is a ___ representation of source code, capturing its structure without whitespace or comments.
An AST represents code as a tree of nodes — each node represents a syntactic construct (function declaration, if statement, binary expression). The tree structure captures nesting and relationships without irrelevant syntax details.
2 / 5
Tree-sitter is a ___ parser generator that produces concrete syntax trees incrementally, without needing a full re-parse on each edit.
Tree-sitter uses incremental parsing: when the user edits a file, it only re-parses the changed region, not the whole file. This makes it fast enough for real-time use in editors — providing syntax highlighting and code navigation with sub-millisecond latency.
3 / 5
A tree-sitter ___ defines the language's syntax rules in terms of node types, relationships, and precedence rules.
A tree-sitter grammar (grammar.js) defines all syntactic constructs: node types, their children, precedence rules, and conflict resolutions. From the grammar, tree-sitter generates a C parsing library for that language.
4 / 5
Tree-sitter ___ allow users to write pattern expressions that find specific node types and their relationships in a syntax tree.
Tree-sitter queries use S-expression syntax to pattern-match nodes in the syntax tree: '(function_declaration name: (identifier) @name)' captures function names. They're used for syntax highlighting captures, code navigation, and code refactoring tools.
5 / 5
Tree-sitter produces ___ syntax trees (CSTs) that preserve all tokens including whitespace and comments, unlike abstract syntax trees.
Tree-sitter produces Concrete Syntax Trees (CSTs), not ASTs — every token (including whitespace, comments, punctuation) is in the tree. This enables formatting tools that must preserve or modify whitespace precisely.