From aac9dfa46418603940ab2333cfea2190d9464d9e Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Sat, 6 Apr 2019 20:14:28 +0800 Subject: Add TtCursorTokenSource and TtCursorTokenSink --- crates/ra_parser/src/grammar.rs | 4 ++++ crates/ra_parser/src/lib.rs | 8 ++++++++ 2 files changed, 12 insertions(+) (limited to 'crates/ra_parser/src') diff --git a/crates/ra_parser/src/grammar.rs b/crates/ra_parser/src/grammar.rs index b2ffeff8c..c5f510e6b 100644 --- a/crates/ra_parser/src/grammar.rs +++ b/crates/ra_parser/src/grammar.rs @@ -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, diff --git a/crates/ra_parser/src/lib.rs b/crates/ra_parser/src/lib.rs index 30ba06aac..3ceeeebd7 100644 --- a/crates/ra_parser/src/lib.rs +++ b/crates/ra_parser/src/lib.rs @@ -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)); -- cgit v1.2.3