pub struct Tree { /* private fields */ }Expand description
A parsed query.
Implementations§
Source§impl Tree
impl Tree
Sourcepub fn arena_len(&self) -> usize
pub fn arena_len(&self) -> usize
How many nodes the tree has, abandoned ones included.
Not the size of the tree that is reachable from the root. It is the size of the arena, which is what the parse cost, and telling the two apart is what the ratio between them is for.
Sourcepub fn steps(&self) -> u64
pub fn steps(&self) -> u64
How many nodes of the rule table the matcher went into to produce this.
The one number that says what a parse cost, and the one to watch when the grammar or the filter changes. A parse that is linear in the query does a roughly constant number of these per token; one that is backtracking badly does thousands.
Sourcepub fn text<'a>(&self, index: u32, query: &'a str, tokens: &[Token]) -> &'a str
pub fn text<'a>(&self, index: u32, query: &'a str, tokens: &[Token]) -> &'a str
The text a node covers, given the query and its tokens.
A node that covers no tokens, which is any rule whose body matched nothing, gets the empty string at the point it started rather than a span running backwards.