mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
Derive kinds information from ungrammar file
This commit is contained in:
parent
8f044d9681
commit
983c9c122e
12 changed files with 448 additions and 718 deletions
|
|
@ -165,42 +165,6 @@ pub(crate) mod entry {
|
|||
}
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
|
||||
pub(crate) fn eager_macro_input(p: &mut Parser<'_>) {
|
||||
let m = p.start();
|
||||
|
||||
let closing_paren_kind = match p.current() {
|
||||
T!['{'] => T!['}'],
|
||||
T!['('] => T![')'],
|
||||
T!['['] => T![']'],
|
||||
_ => {
|
||||
p.error("expected `{`, `[`, `(`");
|
||||
while !p.at(EOF) {
|
||||
p.bump_any();
|
||||
}
|
||||
m.complete(p, ERROR);
|
||||
return;
|
||||
}
|
||||
};
|
||||
p.bump_any();
|
||||
while !p.at(EOF) && !p.at(closing_paren_kind) {
|
||||
if expressions::expr(p).is_none() {
|
||||
break;
|
||||
}
|
||||
if !p.at(EOF) && !p.at(closing_paren_kind) {
|
||||
p.expect(T![,]);
|
||||
}
|
||||
}
|
||||
p.expect(closing_paren_kind);
|
||||
if p.at(EOF) {
|
||||
m.complete(p, MACRO_EAGER_INPUT);
|
||||
return;
|
||||
}
|
||||
while !p.at(EOF) {
|
||||
p.bump_any();
|
||||
}
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,13 +173,6 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
|
|||
}
|
||||
}
|
||||
|
||||
// test existential_type
|
||||
// existential type Foo: Fn() -> usize;
|
||||
if p.at_contextual_kw(T![existential]) && p.nth(1) == T![type] {
|
||||
p.bump_remap(T![existential]);
|
||||
has_mods = true;
|
||||
}
|
||||
|
||||
// items
|
||||
match p.current() {
|
||||
T![fn] => fn_(p, m),
|
||||
|
|
@ -201,7 +194,7 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
|
|||
|
||||
_ if has_visibility || has_mods => {
|
||||
if has_mods {
|
||||
p.error("expected existential, fn, trait or impl");
|
||||
p.error("expected fn, trait or impl");
|
||||
} else {
|
||||
p.error("expected an item");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,8 +82,6 @@ pub enum TopEntryPoint {
|
|||
/// Edge case -- macros generally don't expand to attributes, with the
|
||||
/// exception of `cfg_attr` which does!
|
||||
MetaItem,
|
||||
/// Edge case 2 -- eager macros expand their input to a delimited list of comma separated expressions
|
||||
MacroEagerInput,
|
||||
}
|
||||
|
||||
impl TopEntryPoint {
|
||||
|
|
@ -97,7 +95,6 @@ impl TopEntryPoint {
|
|||
TopEntryPoint::Type => grammar::entry::top::type_,
|
||||
TopEntryPoint::Expr => grammar::entry::top::expr,
|
||||
TopEntryPoint::MetaItem => grammar::entry::top::meta_item,
|
||||
TopEntryPoint::MacroEagerInput => grammar::entry::top::eager_macro_input,
|
||||
};
|
||||
let mut p = parser::Parser::new(input, edition);
|
||||
entry_point(&mut p);
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,31 +0,0 @@
|
|||
SOURCE_FILE
|
||||
TYPE_ALIAS
|
||||
EXISTENTIAL_KW "existential"
|
||||
WHITESPACE " "
|
||||
TYPE_KW "type"
|
||||
WHITESPACE " "
|
||||
NAME
|
||||
IDENT "Foo"
|
||||
COLON ":"
|
||||
WHITESPACE " "
|
||||
TYPE_BOUND_LIST
|
||||
TYPE_BOUND
|
||||
PATH_TYPE
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "Fn"
|
||||
PARAM_LIST
|
||||
L_PAREN "("
|
||||
R_PAREN ")"
|
||||
WHITESPACE " "
|
||||
RET_TYPE
|
||||
THIN_ARROW "->"
|
||||
WHITESPACE " "
|
||||
PATH_TYPE
|
||||
PATH
|
||||
PATH_SEGMENT
|
||||
NAME_REF
|
||||
IDENT "usize"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n"
|
||||
|
|
@ -1 +0,0 @@
|
|||
existential type Foo: Fn() -> usize;
|
||||
Loading…
Add table
Add a link
Reference in a new issue