syntax: Make _
an identifier
This commit is contained in:
parent
61b6bf54fd
commit
5d06c890fe
20 changed files with 109 additions and 119 deletions
|
@ -122,6 +122,7 @@ fn ident_can_begin_type(ident: ast::Ident) -> bool {
|
|||
!ident_token.is_reserved_ident() ||
|
||||
ident_token.is_path_segment_keyword() ||
|
||||
[
|
||||
keywords::Underscore.name(),
|
||||
keywords::For.name(),
|
||||
keywords::Impl.name(),
|
||||
keywords::Fn.name(),
|
||||
|
@ -175,7 +176,6 @@ pub enum Token {
|
|||
|
||||
/* Name components */
|
||||
Ident(ast::Ident),
|
||||
Underscore,
|
||||
Lifetime(ast::Ident),
|
||||
|
||||
// The `LazyTokenStream` is a pure function of the `Nonterminal`,
|
||||
|
@ -242,7 +242,6 @@ impl Token {
|
|||
Ident(ident) => ident_can_begin_type(ident), // type name or keyword
|
||||
OpenDelim(Paren) | // tuple
|
||||
OpenDelim(Bracket) | // array
|
||||
Underscore | // placeholder
|
||||
Not | // never
|
||||
BinOp(Star) | // raw pointer
|
||||
BinOp(And) | // reference
|
||||
|
@ -371,7 +370,7 @@ impl Token {
|
|||
// unnamed method parameters, crate root module, error recovery etc.
|
||||
pub fn is_special_ident(&self) -> bool {
|
||||
match self.ident() {
|
||||
Some(id) => id.name <= keywords::DollarCrate.name(),
|
||||
Some(id) => id.name <= keywords::Underscore.name(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -441,7 +440,7 @@ impl Token {
|
|||
|
||||
Le | EqEq | Ne | Ge | AndAnd | OrOr | Tilde | BinOpEq(..) | At | DotDotDot | DotEq |
|
||||
DotDotEq | Comma | Semi | ModSep | RArrow | LArrow | FatArrow | Pound | Dollar |
|
||||
Question | OpenDelim(..) | CloseDelim(..) | Underscore => return None,
|
||||
Question | OpenDelim(..) | CloseDelim(..) => return None,
|
||||
|
||||
Literal(..) | Ident(..) | Lifetime(..) | Interpolated(..) | DocComment(..) |
|
||||
Whitespace | Comment | Shebang(..) | Eof => return None,
|
||||
|
@ -573,7 +572,7 @@ impl fmt::Debug for Nonterminal {
|
|||
pub fn is_op(tok: &Token) -> bool {
|
||||
match *tok {
|
||||
OpenDelim(..) | CloseDelim(..) | Literal(..) | DocComment(..) |
|
||||
Ident(..) | Underscore | Lifetime(..) | Interpolated(..) |
|
||||
Ident(..) | Lifetime(..) | Interpolated(..) |
|
||||
Whitespace | Comment | Shebang(..) | Eof => false,
|
||||
_ => true,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue