Track AST nodes' sizes in characters as well as bytes
The `pos` and `size` functions for Nodes now return TSLength structs, which contain lengths in both characters and bytes. This is important for knowing the number of unicode characters in a Node.
This commit is contained in:
parent
c576d7d4a0
commit
c1565c1aae
16 changed files with 232 additions and 128 deletions
|
|
@ -19,10 +19,10 @@ const char *ts_string_input_read(void *d, size_t *bytes_read) {
|
|||
return data->string + previous_position;
|
||||
}
|
||||
|
||||
int ts_string_input_seek(void *d, size_t position) {
|
||||
int ts_string_input_seek(void *d, TSLength position) {
|
||||
TSStringInput *data = (TSStringInput *)d;
|
||||
data->position = position;
|
||||
return (position < data->length);
|
||||
data->position = position.bytes;
|
||||
return (position.bytes < data->length);
|
||||
}
|
||||
|
||||
TSInput ts_string_input_make(const char *string) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue