about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2021-12-27 15:54:00 +0300
committerAleksey Kladov <aleksey.kladov@gmail.com>2021-12-28 17:00:55 +0300
commitf10f51833c8ea715ef512eb283f1d44f76701378 (patch)
treed231196179669cf374d4dc708f74e3a57c5d8867
parent519ee21bcb754bf972b5f127f17035c5efe196d0 (diff)
downloadrust-f10f51833c8ea715ef512eb283f1d44f76701378.tar.gz
rust-f10f51833c8ea715ef512eb283f1d44f76701378.zip
move stmt to entry points
-rw-r--r--crates/mbe/src/expander/matcher.rs6
-rw-r--r--crates/parser/src/grammar.rs10
-rw-r--r--crates/parser/src/lib.rs8
3 files changed, 11 insertions, 13 deletions
diff --git a/crates/mbe/src/expander/matcher.rs b/crates/mbe/src/expander/matcher.rs
index 621ff791d4f..b5d1e098c4f 100644
--- a/crates/mbe/src/expander/matcher.rs
+++ b/crates/mbe/src/expander/matcher.rs
@@ -694,7 +694,11 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
         "expr" => ParserEntryPoint::Expr,
         "ty" => ParserEntryPoint::Type,
         "pat" | "pat_param" => ParserEntryPoint::Pattern, // FIXME: edition2021
-        "stmt" => ParserEntryPoint::Statement,
+        "stmt" => {
+            return input
+                .expect_fragment2(parser::PrefixEntryPoint::Stmt)
+                .map(|tt| tt.map(Fragment::Tokens));
+        }
         "block" => {
             return input
                 .expect_fragment2(parser::PrefixEntryPoint::Block)
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index cf17e8453ba..f15272ce870 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -57,6 +57,10 @@ pub(crate) mod entry {
         pub(crate) fn block(p: &mut Parser) {
             expressions::block_expr(p);
         }
+
+        pub(crate) fn stmt(p: &mut Parser) {
+            expressions::stmt(p, expressions::StmtWithSemi::No, true);
+        }
     }
 }
 
@@ -70,8 +74,6 @@ pub(crate) mod entry_points {
         m.complete(p, SOURCE_FILE);
     }
 
-    pub(crate) use expressions::block_expr;
-
     pub(crate) use paths::type_path as path;
 
     pub(crate) use patterns::pattern_single as pattern;
@@ -82,10 +84,6 @@ pub(crate) mod entry_points {
         let _ = expressions::expr(p);
     }
 
-    pub(crate) fn stmt(p: &mut Parser) {
-        expressions::stmt(p, expressions::StmtWithSemi::No, true);
-    }
-
     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 778c8b10ec6..97b717346b1 100644
--- a/crates/parser/src/lib.rs
+++ b/crates/parser/src/lib.rs
@@ -53,6 +53,7 @@ pub use crate::{
 pub enum PrefixEntryPoint {
     Vis,
     Block,
+    Stmt,
 }
 
 impl PrefixEntryPoint {
@@ -60,6 +61,7 @@ impl PrefixEntryPoint {
         let entry_point: fn(&'_ mut parser::Parser) = match self {
             PrefixEntryPoint::Vis => grammar::entry::prefix::vis,
             PrefixEntryPoint::Block => grammar::entry::prefix::block,
+            PrefixEntryPoint::Stmt => grammar::entry::prefix::stmt,
         };
         let mut p = parser::Parser::new(input);
         entry_point(&mut p);
@@ -77,13 +79,10 @@ pub enum ParserEntryPoint {
     SourceFile,
     Path,
     Expr,
-    Statement,
     StatementOptionalSemi,
     Type,
     Pattern,
     Item,
-    Block,
-    // Visibility,
     MetaItem,
     Items,
     Statements,
@@ -111,10 +110,7 @@ pub fn parse(inp: &Input, entry_point: ParserEntryPoint) -> Output {
         ParserEntryPoint::Type => grammar::entry_points::type_,
         ParserEntryPoint::Pattern => grammar::entry_points::pattern,
         ParserEntryPoint::Item => grammar::entry_points::item,
-        ParserEntryPoint::Block => grammar::entry_points::block_expr,
-        // ParserEntryPoint::Visibility => grammar::entry_points::visibility,
         ParserEntryPoint::MetaItem => grammar::entry_points::meta_item,
-        ParserEntryPoint::Statement => grammar::entry_points::stmt,
         ParserEntryPoint::StatementOptionalSemi => grammar::entry_points::stmt_optional_semi,
         ParserEntryPoint::Items => grammar::entry_points::macro_items,
         ParserEntryPoint::Statements => grammar::entry_points::macro_stmts,