Add TtCursorTokenSource and TtCursorTokenSink

This commit is contained in:
Edwin Cheng 2019-04-06 20:14:28 +08:00
parent 1d7735fbc6
commit aac9dfa464
4 changed files with 216 additions and 24 deletions

View file

@ -49,6 +49,10 @@ pub(crate) fn root(p: &mut Parser) {
m.complete(p, SOURCE_FILE);
}
pub(crate) fn path(p: &mut Parser) {
paths::type_path(p);
}
pub(crate) fn reparser(
node: SyntaxKind,
first_child: Option<SyntaxKind>,

View file

@ -61,6 +61,14 @@ pub fn parse(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) {
event::process(tree_sink, events);
}
/// Parse given tokens into the given sink as a path
pub fn parse_path(token_source: &dyn TokenSource, tree_sink: &mut dyn TreeSink) {
let mut p = parser::Parser::new(token_source);
grammar::path(&mut p);
let events = p.finish();
event::process(tree_sink, events);
}
/// A parsing function for a specific braced-block.
pub struct Reparser(fn(&mut parser::Parser));