pub fn cpp_unclosed_construct_openers<'tree>(
root: Node<'tree>,
) -> Vec<Node<'tree>>Expand description
The opening tokens of the constructs a C/C++ parse left open at the end of the file, in source order (#3501). Empty unless the tree’s root is an ERROR node.
The grammar has no preprocessor, so a construct opened in one conditional
branch and closed in another stays open: #if 0 / extern "C" { /
#endif leaves its { unmatched until a later #if 0 / } / #endif.
One such pair repairs with a single MISSING token. With more of them, the
parse version tree-sitter keeps reaches the end of input in its error
state, and tree-sitter wraps every subtree on that version’s stack in one
ERROR node and returns it as the root (recover_eof in its parser.c).
The root’s children are then exactly that stack: completed subtrees, and
the bare tokens of the constructs still waiting to be reduced when input
ran out. A reduced construct is a node of its own, so a bare opener among
the root’s children is one the parse never closed. tdlib/td’s copy of the
SQLite amalgamation parses this way: its root spans all 8,274,268 bytes,
and its outermost open construct is the #ifndef SQLITEINT_H include guard
at byte 19,718.