diff options
Diffstat (limited to 'crates/libsyntax2/src/parser_impl/mod.rs')
-rw-r--r-- | crates/libsyntax2/src/parser_impl/mod.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/crates/libsyntax2/src/parser_impl/mod.rs b/crates/libsyntax2/src/parser_impl/mod.rs index 14cceced5..f60ef80f0 100644 --- a/crates/libsyntax2/src/parser_impl/mod.rs +++ b/crates/libsyntax2/src/parser_impl/mod.rs | |||
@@ -2,7 +2,6 @@ mod event; | |||
2 | mod input; | 2 | mod input; |
3 | 3 | ||
4 | use { | 4 | use { |
5 | grammar, | ||
6 | lexer::Token, | 5 | lexer::Token, |
7 | parser_api::Parser, | 6 | parser_api::Parser, |
8 | parser_impl::{ | 7 | parser_impl::{ |
@@ -27,12 +26,16 @@ pub(crate) trait Sink<'a> { | |||
27 | } | 26 | } |
28 | 27 | ||
29 | /// Parse a sequence of tokens into the representative node tree | 28 | /// Parse a sequence of tokens into the representative node tree |
30 | pub(crate) fn parse<'a, S: Sink<'a>>(text: &'a str, tokens: &[Token]) -> S::Tree { | 29 | pub(crate) fn parse_with<'a, S: Sink<'a>>( |
30 | text: &'a str, | ||
31 | tokens: &[Token], | ||
32 | parser: fn(&mut Parser), | ||
33 | ) -> S::Tree { | ||
31 | let events = { | 34 | let events = { |
32 | let input = input::ParserInput::new(text, tokens); | 35 | let input = input::ParserInput::new(text, tokens); |
33 | let parser_impl = ParserImpl::new(&input); | 36 | let parser_impl = ParserImpl::new(&input); |
34 | let mut parser_api = Parser(parser_impl); | 37 | let mut parser_api = Parser(parser_impl); |
35 | grammar::file(&mut parser_api); | 38 | parser(&mut parser_api); |
36 | parser_api.0.into_events() | 39 | parser_api.0.into_events() |
37 | }; | 40 | }; |
38 | let mut sink = S::new(text); | 41 | let mut sink = S::new(text); |