Adding API to get field name of a TSNode
This PR adds an API to get name of the field of TSNode's child.
It uses same set of arguments as that of ts_node_child, but returns
field name if it is found, otherwise it returns NULL.
This API is useful to implement custom printing of S-expressions such
as following:
"(binary_expression
(binary_expression_left (identifier))
(binary_expression_operator ("+"))
(binary_expression_right (identifier)
)"
Currently, ts_node_string does not allow any customization for printing.
This commit is contained in:
parent
6abf77a20c
commit
dffee22736
2 changed files with 23 additions and 0 deletions
|
|
@ -487,6 +487,12 @@ TSNode ts_node_parent(TSNode);
|
|||
*/
|
||||
TSNode ts_node_child(TSNode, uint32_t);
|
||||
|
||||
/**
|
||||
* Get the field_name for node's child at the given index, where zero represents
|
||||
* the first child. Returns NULL, if no field is found.
|
||||
*/
|
||||
const char *ts_node_child_field_name(TSNode, uint32_t);
|
||||
|
||||
/**
|
||||
* Get the node's number of children.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue