Tree-sitter is designed to be resilient and parse partial code. When it encounters invalid syntax:
- It creates an ERROR node in the Concrete Syntax Tree (CST)
- The ERROR node has kind
"ERROR"
- ERROR nodes are typically not "named" nodes (according to tree-sitter's naming rules)
- ERROR nodes can be detected via:
node.kind() == "ERROR" (direct check)
node.has_error() (check if subtree contains errors)