You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encounter the problem when working on the front end for my own language compiler (https://github.com/pc2/tree-sitter-sus). I'm using the rust bindings for it.
It appears that the function TreeCursor::goto_first_child_for_byte cannot find nodes after ERROR nodes.
Steps to reproduce
Grab a copy of a grammar that looks at least like this:
Some code that illustrates how I'm attempting to use the function:
// Enter the byte range of a node coming after an ERROR nodelet desired_span :Range<usize> = ...;println!("DESIRED: {:?}", desired_span);letmut cursor = tree.walk();// First display the nodes and all their byte rangesassert!(cursor.goto_first_child());loop{let node = cursor.node();println!("{}: {:?}", node.kind(), node.byte_range());if !cursor.goto_next_sibling(){break;}}assert!(cursor.goto_parent());// This unwrap fails, even though it should find the node we input at desired_spanlet _ = cursor.goto_first_child_for_byte(desired_span.start).unwrap();
If I run this code I get the following: (outer code loops through all modules, so that 3rd module is the first one to error. Adding or removing errors to the program file moves the one which breaks, which is always the one right after the error.
I would expect TreeCursor::goto_first_child_for_byte to find the first child for that byte, regardless of ERROR nodes, or extra nodes encountered along the way.
Tree-sitter version (tree-sitter --version)
tree-sitter 0.22.2
Cargo.toml:
[dependencies]
tree-sitter = "~0.22.2"
Operating system/version
TUXEDO OS 2 x86_64
The text was updated successfully, but these errors were encountered:
Problem
I encounter the problem when working on the front end for my own language compiler (https://github.com/pc2/tree-sitter-sus). I'm using the rust bindings for it.
It appears that the function
TreeCursor::goto_first_child_for_byte
cannot find nodes after ERROR nodes.Steps to reproduce
Grab a copy of a grammar that looks at least like this:
Some code that illustrates how I'm attempting to use the function:
If I run this code I get the following: (outer code loops through all modules, so that 3rd module is the first one to error. Adding or removing errors to the program file moves the one which breaks, which is always the one right after the error.
In fact, if I replace
cursor.goto_first_child_for_byte
with this:it works as I would expect
cursor.goto_first_child_for_byte
to work.PS it appears extras can also break it the same way. I tried adding a comment before an earlier module, and that also breaks it:
Expected behavior
I would expect
TreeCursor::goto_first_child_for_byte
to find the first child for that byte, regardless of ERROR nodes, or extra nodes encountered along the way.Tree-sitter version (tree-sitter --version)
tree-sitter 0.22.2
Cargo.toml:
Operating system/version
TUXEDO OS 2 x86_64
The text was updated successfully, but these errors were encountered: