Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/mbe/src/expander/matcher.rs6
-rw-r--r--crates/parser/src/grammar.rs9
-rw-r--r--crates/parser/src/lib.rs6
3 files changed, 12 insertions, 9 deletions
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index 6cc655786c..3137bd91cf 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<Option<Fragment>> {
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 6789c61f4b..8310b38b92 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -72,6 +72,9 @@ pub(crate) mod entry {
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) mod entry_points {
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 6aeed8a288..867acc45f3 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 @@ impl PrefixEntryPoint {
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,