pub trait Expr: LSend {
// Required method
fn run(
&self,
cursor: usize,
tokens: &[Token],
source: &[char],
) -> Option<Span>;
}
Expand description
A common problem in Harper is that we need to identify tokens that fulfil certain criterion.
An Expr
is a way to express whether a certain set of tokens fulfil that criteria.
When supplied a specific position in a token stream, the job of an Expr
is to determine the window of tokens (including the cursor itself) that fulfils whatever criteria the author desires.
It is then the job of another system to identify portions of documents that fulfil this criteria.