From 369001615f7ce8624139e51a42e2751da8584766 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 27 Dec 2021 16:23:07 +0300 Subject: [PATCH] move path --- crates/mbe/src/expander/matcher.rs | 6 +++++- crates/parser/src/grammar.rs | 9 +++------ crates/parser/src/lib.rs | 6 ++++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs index 6cc655786cb..3137bd91cf8 100644 --- a/crates/mbe/src/expander/matcher.rs +++ b/crates/mbe/src/expander/matcher.rs @@ -690,7 +690,11 @@ fn match_leaf(lhs: &tt::Leaf, src: &mut TtIter) -> Result<(), ExpandError> { fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult> { let fragment = match kind { - "path" => ParserEntryPoint::Path, + "path" => { + return input + .expect_fragment2(parser::PrefixEntryPoint::Path) + .map(|tt| tt.map(Fragment::Tokens)); + } "expr" => { return input .expect_fragment2(parser::PrefixEntryPoint::Expr) diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index 6789c61f4b3..8310b38b929 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -72,6 +72,9 @@ pub(crate) fn ty(p: &mut Parser) { pub(crate) fn expr(p: &mut Parser) { let _ = expressions::expr(p); } + pub(crate) fn path(p: &mut Parser) { + let _ = paths::type_path(p); + } } } @@ -85,12 +88,6 @@ pub(crate) fn source_file(p: &mut Parser) { m.complete(p, SOURCE_FILE); } - pub(crate) use paths::type_path as path; - - pub(crate) fn expr(p: &mut Parser) { - let _ = expressions::expr(p); - } - pub(crate) fn stmt_optional_semi(p: &mut Parser) { expressions::stmt(p, expressions::StmtWithSemi::Optional, false); } diff --git a/crates/parser/src/lib.rs b/crates/parser/src/lib.rs index 6aeed8a2887..867acc45f3f 100644 --- a/crates/parser/src/lib.rs +++ b/crates/parser/src/lib.rs @@ -58,6 +58,7 @@ pub enum PrefixEntryPoint { Pat, Ty, Expr, + Path, } impl PrefixEntryPoint { @@ -69,6 +70,7 @@ pub fn parse(&self, input: &Input) -> Output { PrefixEntryPoint::Pat => grammar::entry::prefix::pat, PrefixEntryPoint::Ty => grammar::entry::prefix::ty, PrefixEntryPoint::Expr => grammar::entry::prefix::expr, + PrefixEntryPoint::Path => grammar::entry::prefix::path, }; let mut p = parser::Parser::new(input); entry_point(&mut p); @@ -112,8 +114,8 @@ pub fn parse_source_file(inp: &Input) -> Output { pub fn parse(inp: &Input, entry_point: ParserEntryPoint) -> Output { let entry_point: fn(&'_ mut parser::Parser) = match entry_point { ParserEntryPoint::SourceFile => grammar::entry_points::source_file, - ParserEntryPoint::Path => grammar::entry_points::path, - ParserEntryPoint::Expr => grammar::entry_points::expr, + ParserEntryPoint::Path => grammar::entry::prefix::path, + ParserEntryPoint::Expr => grammar::entry::prefix::expr, ParserEntryPoint::Type => grammar::entry::prefix::ty, ParserEntryPoint::Pattern => grammar::entry::prefix::pat, ParserEntryPoint::Item => grammar::entry_points::item,