incremental reparse
This commit is contained in:
@@ -2,7 +2,6 @@ mod event;
|
||||
mod input;
|
||||
|
||||
use {
|
||||
grammar,
|
||||
lexer::Token,
|
||||
parser_api::Parser,
|
||||
parser_impl::{
|
||||
@@ -27,12 +26,16 @@ pub(crate) trait Sink<'a> {
|
||||
}
|
||||
|
||||
/// Parse a sequence of tokens into the representative node tree
|
||||
pub(crate) fn parse<'a, S: Sink<'a>>(text: &'a str, tokens: &[Token]) -> S::Tree {
|
||||
pub(crate) fn parse_with<'a, S: Sink<'a>>(
|
||||
text: &'a str,
|
||||
tokens: &[Token],
|
||||
parser: fn(&mut Parser),
|
||||
) -> S::Tree {
|
||||
let events = {
|
||||
let input = input::ParserInput::new(text, tokens);
|
||||
let parser_impl = ParserImpl::new(&input);
|
||||
let mut parser_api = Parser(parser_impl);
|
||||
grammar::file(&mut parser_api);
|
||||
parser(&mut parser_api);
|
||||
parser_api.0.into_events()
|
||||
};
|
||||
let mut sink = S::new(text);
|
||||
|
||||
Reference in New Issue
Block a user