mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
move stmt to entry points
This commit is contained in:
parent
519ee21bcb
commit
f10f51833c
3 changed files with 11 additions and 13 deletions
|
@ -694,7 +694,11 @@ fn match_meta_var(kind: &str, input: &mut TtIter) -> ExpandResult<Option<Fragmen
|
||||||
"expr" => ParserEntryPoint::Expr,
|
"expr" => ParserEntryPoint::Expr,
|
||||||
"ty" => ParserEntryPoint::Type,
|
"ty" => ParserEntryPoint::Type,
|
||||||
"pat" | "pat_param" => ParserEntryPoint::Pattern, // FIXME: edition2021
|
"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" => {
|
"block" => {
|
||||||
return input
|
return input
|
||||||
.expect_fragment2(parser::PrefixEntryPoint::Block)
|
.expect_fragment2(parser::PrefixEntryPoint::Block)
|
||||||
|
|
|
@ -57,6 +57,10 @@ pub(crate) mod entry {
|
||||||
pub(crate) fn block(p: &mut Parser) {
|
pub(crate) fn block(p: &mut Parser) {
|
||||||
expressions::block_expr(p);
|
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);
|
m.complete(p, SOURCE_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) use expressions::block_expr;
|
|
||||||
|
|
||||||
pub(crate) use paths::type_path as path;
|
pub(crate) use paths::type_path as path;
|
||||||
|
|
||||||
pub(crate) use patterns::pattern_single as pattern;
|
pub(crate) use patterns::pattern_single as pattern;
|
||||||
|
@ -82,10 +84,6 @@ pub(crate) mod entry_points {
|
||||||
let _ = expressions::expr(p);
|
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) {
|
pub(crate) fn stmt_optional_semi(p: &mut Parser) {
|
||||||
expressions::stmt(p, expressions::StmtWithSemi::Optional, false);
|
expressions::stmt(p, expressions::StmtWithSemi::Optional, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ pub use crate::{
|
||||||
pub enum PrefixEntryPoint {
|
pub enum PrefixEntryPoint {
|
||||||
Vis,
|
Vis,
|
||||||
Block,
|
Block,
|
||||||
|
Stmt,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PrefixEntryPoint {
|
impl PrefixEntryPoint {
|
||||||
|
@ -60,6 +61,7 @@ impl PrefixEntryPoint {
|
||||||
let entry_point: fn(&'_ mut parser::Parser) = match self {
|
let entry_point: fn(&'_ mut parser::Parser) = match self {
|
||||||
PrefixEntryPoint::Vis => grammar::entry::prefix::vis,
|
PrefixEntryPoint::Vis => grammar::entry::prefix::vis,
|
||||||
PrefixEntryPoint::Block => grammar::entry::prefix::block,
|
PrefixEntryPoint::Block => grammar::entry::prefix::block,
|
||||||
|
PrefixEntryPoint::Stmt => grammar::entry::prefix::stmt,
|
||||||
};
|
};
|
||||||
let mut p = parser::Parser::new(input);
|
let mut p = parser::Parser::new(input);
|
||||||
entry_point(&mut p);
|
entry_point(&mut p);
|
||||||
|
@ -77,13 +79,10 @@ pub enum ParserEntryPoint {
|
||||||
SourceFile,
|
SourceFile,
|
||||||
Path,
|
Path,
|
||||||
Expr,
|
Expr,
|
||||||
Statement,
|
|
||||||
StatementOptionalSemi,
|
StatementOptionalSemi,
|
||||||
Type,
|
Type,
|
||||||
Pattern,
|
Pattern,
|
||||||
Item,
|
Item,
|
||||||
Block,
|
|
||||||
// Visibility,
|
|
||||||
MetaItem,
|
MetaItem,
|
||||||
Items,
|
Items,
|
||||||
Statements,
|
Statements,
|
||||||
|
@ -111,10 +110,7 @@ pub fn parse(inp: &Input, entry_point: ParserEntryPoint) -> Output {
|
||||||
ParserEntryPoint::Type => grammar::entry_points::type_,
|
ParserEntryPoint::Type => grammar::entry_points::type_,
|
||||||
ParserEntryPoint::Pattern => grammar::entry_points::pattern,
|
ParserEntryPoint::Pattern => grammar::entry_points::pattern,
|
||||||
ParserEntryPoint::Item => grammar::entry_points::item,
|
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::MetaItem => grammar::entry_points::meta_item,
|
||||||
ParserEntryPoint::Statement => grammar::entry_points::stmt,
|
|
||||||
ParserEntryPoint::StatementOptionalSemi => grammar::entry_points::stmt_optional_semi,
|
ParserEntryPoint::StatementOptionalSemi => grammar::entry_points::stmt_optional_semi,
|
||||||
ParserEntryPoint::Items => grammar::entry_points::macro_items,
|
ParserEntryPoint::Items => grammar::entry_points::macro_items,
|
||||||
ParserEntryPoint::Statements => grammar::entry_points::macro_stmts,
|
ParserEntryPoint::Statements => grammar::entry_points::macro_stmts,
|
||||||
|
|
Loading…
Reference in a new issue