CstNode
- class CstNode
A CST node
Members defined in
CstNode(23 members)
RGet the node’s number of children.
RGet the node’s number of descendants, including one for the node itself.
RGet the node’s end byte.
RGet the node’s end position in terms of rows and columns (Utf-8 based).
RGet the node’s type as a numerical id as it appears in the grammar ignoring aliases.
RGet the node’s type as it appears in the grammar ignoring aliases as a null-terminated string.
RCheck if a syntax node has been edited.
RCheck if the node is a syntax error or contains any syntax errors.
RGet a numeric id for this node that is unique.
RCheck if the node is a syntax error.
RCheck if the node is extra.
RCheck if the node is missing.
RCheck if the node is named.
RGet the node’s number of named children.
RGet the parse state after this node.
RGet this node’s parse state.
RGet the node’s start byte.
RGet the node’s start position in terms of rows and columns (Utf-8 based).
RGet an S-expression representing the node as a string.
RGet the node’s type as a numerical id.
RGet the node’s type as a string.
Get the field name for node’s child at the given index, where zero represents the first child.
Get the node’s source text.
Attributes
- property child_count: int
Get the node’s number of children.
- property descendant_count: int
Get the node’s number of descendants, including one for the node itself.
- property end_byte: int
Get the node’s end byte.
- property end_point: syside.PositionUtf8
Get the node’s end position in terms of rows and columns (Utf-8 based).
- property grammar_symbol: syside.Symbol
Get the node’s type as a numerical id as it appears in the grammar ignoring aliases.
- property grammar_type: str
Get the node’s type as it appears in the grammar ignoring aliases as a null-terminated string.
- property has_changes: bool
Check if a syntax node has been edited.
- property has_error: bool
Check if the node is a syntax error or contains any syntax errors.
- property id: int
Get a numeric id for this node that is unique.
Within a given syntax tree, no two nodes have the same id. However:
If a new tree is created based on an older tree, and a node from the old tree is reused in the process, then that node will have the same id in both trees.
A node not marked as having changes does not guarantee it was reused.
If a node is marked as having changed in the old tree, it will not be reused.
- property is_error: bool
Check if the node is a syntax error.
- property is_extra: bool
Check if the node is extra.
Extra nodes represent things like comments, which are not required by the grammar, but can appear anywhere.
- property is_missing: bool
Check if the node is missing.
Missing nodes are inserted by the parser in order to recover from certain kinds of syntax errors.
- property is_named: bool
Check if the node is named.
Named nodes correspond to named rules in the grammar, whereas anonymous nodes correspond to string literals in the grammar.
- property named_child_count: int
Get the node’s number of named children.
- property next_parse_state: syside.StateId
Get the parse state after this node.
- property parse_state: syside.StateId
Get this node’s parse state.
- property start_byte: int
Get the node’s start byte.
- property start_point: syside.PositionUtf8
Get the node’s start position in terms of rows and columns (Utf-8 based).
- property string: str
Get an S-expression representing the node as a string.
- property symbol: syside.Symbol
Get the node’s type as a numerical id.
- property type: str
Get the node’s type as a string.
Methods
- field_name_for_child(arg: int, /) str | None
Get the field name for node’s child at the given index, where zero represents the first child.
Returns
None, if no field is found
- text(arg: str, /) str
Get the node’s source text.
This requires an explicit source text as it is not stored in the tree otherwise.