mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
simplify
This commit is contained in:
parent
369001615f
commit
8e7fc7be65
5 changed files with 27 additions and 104 deletions
|
@ -75,6 +75,13 @@ pub(crate) mod entry {
|
|||
pub(crate) fn path(p: &mut Parser) {
|
||||
let _ = paths::type_path(p);
|
||||
}
|
||||
pub(crate) fn item(p: &mut Parser) {
|
||||
items::item_or_macro(p, true);
|
||||
}
|
||||
// Parse a meta item , which excluded [], e.g : #[ MetaItem ]
|
||||
pub(crate) fn meta_item(p: &mut Parser) {
|
||||
attributes::meta(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,15 +99,6 @@ pub(crate) mod entry_points {
|
|||
expressions::stmt(p, expressions::StmtWithSemi::Optional, false);
|
||||
}
|
||||
|
||||
// Parse a meta item , which excluded [], e.g : #[ MetaItem ]
|
||||
pub(crate) fn meta_item(p: &mut Parser) {
|
||||
attributes::meta(p);
|
||||
}
|
||||
|
||||
pub(crate) fn item(p: &mut Parser) {
|
||||
items::item_or_macro(p, true);
|
||||
}
|
||||
|
||||
pub(crate) fn macro_items(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
items::mod_contents(p, false);
|
||||
|
|
|
@ -59,6 +59,8 @@ pub enum PrefixEntryPoint {
|
|||
Ty,
|
||||
Expr,
|
||||
Path,
|
||||
Item,
|
||||
MetaItem,
|
||||
}
|
||||
|
||||
impl PrefixEntryPoint {
|
||||
|
@ -71,6 +73,8 @@ impl PrefixEntryPoint {
|
|||
PrefixEntryPoint::Ty => grammar::entry::prefix::ty,
|
||||
PrefixEntryPoint::Expr => grammar::entry::prefix::expr,
|
||||
PrefixEntryPoint::Path => grammar::entry::prefix::path,
|
||||
PrefixEntryPoint::Item => grammar::entry::prefix::item,
|
||||
PrefixEntryPoint::MetaItem => grammar::entry::prefix::meta_item,
|
||||
};
|
||||
let mut p = parser::Parser::new(input);
|
||||
entry_point(&mut p);
|
||||
|
@ -118,8 +122,8 @@ pub fn parse(inp: &Input, entry_point: ParserEntryPoint) -> Output {
|
|||
ParserEntryPoint::Expr => grammar::entry::prefix::expr,
|
||||
ParserEntryPoint::Type => grammar::entry::prefix::ty,
|
||||
ParserEntryPoint::Pattern => grammar::entry::prefix::pat,
|
||||
ParserEntryPoint::Item => grammar::entry_points::item,
|
||||
ParserEntryPoint::MetaItem => grammar::entry_points::meta_item,
|
||||
ParserEntryPoint::Item => grammar::entry::prefix::item,
|
||||
ParserEntryPoint::MetaItem => grammar::entry::prefix::meta_item,
|
||||
ParserEntryPoint::StatementOptionalSemi => grammar::entry_points::stmt_optional_semi,
|
||||
ParserEntryPoint::Items => grammar::entry_points::macro_items,
|
||||
ParserEntryPoint::Statements => grammar::entry_points::macro_stmts,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue