Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/lib.rs')
| -rw-r--r-- | crates/parser/src/lib.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 86c771c000..c7ad025f6b 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -26,6 +26,7 @@ extern crate ra_ap_rustc_lexer as rustc_lexer; #[cfg(feature = "in-rust-tree")] extern crate rustc_lexer; +mod edition; mod event; mod grammar; mod input; @@ -42,6 +43,7 @@ mod tests; pub(crate) use token_set::TokenSet; pub use crate::{ + edition::Edition, input::Input, lexed_str::LexedStr, output::{Output, Step}, @@ -86,7 +88,7 @@ pub enum TopEntryPoint { } impl TopEntryPoint { - pub fn parse(&self, input: &Input) -> Output { + pub fn parse(&self, input: &Input, edition: Edition) -> Output { let _p = tracing::span!(tracing::Level::INFO, "TopEntryPoint::parse", ?self).entered(); let entry_point: fn(&'_ mut parser::Parser<'_>) = match self { TopEntryPoint::SourceFile => grammar::entry::top::source_file, @@ -98,7 +100,7 @@ impl TopEntryPoint { TopEntryPoint::MetaItem => grammar::entry::top::meta_item, TopEntryPoint::MacroEagerInput => grammar::entry::top::eager_macro_input, }; - let mut p = parser::Parser::new(input); + let mut p = parser::Parser::new(input, edition); entry_point(&mut p); let events = p.finish(); let res = event::process(events); @@ -150,7 +152,7 @@ pub enum PrefixEntryPoint { } impl PrefixEntryPoint { - pub fn parse(&self, input: &Input) -> Output { + pub fn parse(&self, input: &Input, edition: Edition) -> Output { let entry_point: fn(&'_ mut parser::Parser<'_>) = match self { PrefixEntryPoint::Vis => grammar::entry::prefix::vis, PrefixEntryPoint::Block => grammar::entry::prefix::block, @@ -163,7 +165,7 @@ impl PrefixEntryPoint { PrefixEntryPoint::Item => grammar::entry::prefix::item, PrefixEntryPoint::MetaItem => grammar::entry::prefix::meta_item, }; - let mut p = parser::Parser::new(input); + let mut p = parser::Parser::new(input, edition); entry_point(&mut p); let events = p.finish(); event::process(events) @@ -187,9 +189,9 @@ impl Reparser { /// /// Tokens must start with `{`, end with `}` and form a valid brace /// sequence. - pub fn parse(self, tokens: &Input) -> Output { + pub fn parse(self, tokens: &Input, edition: Edition) -> Output { let Reparser(r) = self; - let mut p = parser::Parser::new(tokens); + let mut p = parser::Parser::new(tokens, edition); r(&mut p); let events = p.finish(); event::process(events) |