mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 03:33:59 +00:00
Add AST for extern crate
Also change it to parse the crate name as a NAME_REF, not a NAME.
This commit is contained in:
parent
77a824c6a0
commit
e163c908ac
@ -970,7 +970,15 @@ impl ToOwned for ExternCrateItem {
|
||||
}
|
||||
|
||||
|
||||
impl ExternCrateItem {}
|
||||
impl ExternCrateItem {
|
||||
pub fn name_ref(&self) -> Option<&NameRef> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
|
||||
pub fn alias(&self) -> Option<&Alias> {
|
||||
super::child_opt(self)
|
||||
}
|
||||
}
|
||||
|
||||
// FalseKw
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
|
@ -601,7 +601,9 @@ Grammar(
|
||||
"UseTreeList": (
|
||||
collections: [["use_trees", "UseTree"]]
|
||||
),
|
||||
"ExternCrateItem": (),
|
||||
"ExternCrateItem": (
|
||||
options: ["NameRef", "Alias"],
|
||||
),
|
||||
"ArgList": (
|
||||
collections: [
|
||||
["args", "Expr"]
|
||||
|
@ -247,7 +247,7 @@ fn extern_crate_item(p: &mut Parser) {
|
||||
p.bump();
|
||||
assert!(p.at(CRATE_KW));
|
||||
p.bump();
|
||||
name(p);
|
||||
name_ref(p);
|
||||
opt_alias(p);
|
||||
p.expect(SEMI);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ SOURCE_FILE@[0; 18)
|
||||
WHITESPACE@[6; 7)
|
||||
CRATE_KW@[7; 12)
|
||||
WHITESPACE@[12; 13)
|
||||
NAME@[13; 16)
|
||||
NAME_REF@[13; 16)
|
||||
IDENT@[13; 16) "foo"
|
||||
SEMI@[16; 17)
|
||||
WHITESPACE@[17; 18)
|
||||
|
@ -4,7 +4,7 @@ SOURCE_FILE@[0; 43)
|
||||
WHITESPACE@[6; 7)
|
||||
CRATE_KW@[7; 12)
|
||||
WHITESPACE@[12; 13)
|
||||
NAME@[13; 16)
|
||||
NAME_REF@[13; 16)
|
||||
IDENT@[13; 16) "foo"
|
||||
SEMI@[16; 17)
|
||||
WHITESPACE@[17; 18)
|
||||
@ -13,7 +13,7 @@ SOURCE_FILE@[0; 43)
|
||||
WHITESPACE@[24; 25)
|
||||
CRATE_KW@[25; 30)
|
||||
WHITESPACE@[30; 31)
|
||||
NAME@[31; 34)
|
||||
NAME_REF@[31; 34)
|
||||
IDENT@[31; 34) "foo"
|
||||
WHITESPACE@[34; 35)
|
||||
ALIAS@[35; 41)
|
||||
|
Loading…
Reference in New Issue
Block a user