about summary refs log tree commit diff
path: root/src/libsyntax/parse/token.rs
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-04-16 04:12:02 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2016-04-24 20:59:44 +0300
commit546c052d225d41cd31f610e87a20f15cd0fa8e3c (patch)
treed2d1bb3b10895f266c2d5137c7aba8f8515583af /src/libsyntax/parse/token.rs
parent8dbf8f5f0a26a8f80f895294532ad567c156beb3 (diff)
downloadrust-546c052d225d41cd31f610e87a20f15cd0fa8e3c.tar.gz
rust-546c052d225d41cd31f610e87a20f15cd0fa8e3c.zip
syntax: Get rid of token::IdentStyle
Diffstat (limited to 'src/libsyntax/parse/token.rs')
-rw-r--r--src/libsyntax/parse/token.rs56
1 files changed, 24 insertions, 32 deletions
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 46cf79ba336..76bd0f66cd8 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -11,7 +11,6 @@
 pub use self::BinOpToken::*;
 pub use self::Nonterminal::*;
 pub use self::DelimToken::*;
-pub use self::IdentStyle::*;
 pub use self::Lit::*;
 pub use self::Token::*;
 
@@ -52,13 +51,6 @@ pub enum DelimToken {
 }
 
 #[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug, Copy)]
-pub enum IdentStyle {
-    /// `::` follows the identifier with no whitespace in-between.
-    ModName,
-    Plain,
-}
-
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Debug, Copy)]
 pub enum SpecialMacroVar {
     /// `$crate` will be filled in with the name of the crate a macro was
     /// imported from, if any.
@@ -139,7 +131,7 @@ pub enum Token {
     Literal(Lit, Option<ast::Name>),
 
     /* Name components */
-    Ident(ast::Ident, IdentStyle),
+    Ident(ast::Ident),
     Underscore,
     Lifetime(ast::Ident),
 
@@ -150,10 +142,10 @@ pub enum Token {
     DocComment(ast::Name),
     // In left-hand-sides of MBE macros:
     /// Parse a nonterminal (name to bind, name of NT, styles of their idents)
-    MatchNt(ast::Ident, ast::Ident, IdentStyle, IdentStyle),
+    MatchNt(ast::Ident, ast::Ident),
     // In right-hand-sides of MBE macros:
     /// A syntactic variable that will be filled in by macro expansion.
-    SubstNt(ast::Ident, IdentStyle),
+    SubstNt(ast::Ident),
     /// A macro variable with special meaning.
     SpecialVarNt(SpecialMacroVar),
 
@@ -279,16 +271,16 @@ impl Token {
     /// Returns `true` if the token is a given keyword, `kw`.
     pub fn is_keyword(&self, kw: keywords::Keyword) -> bool {
         match *self {
-            Ident(id, _) => id.name == kw.to_name(),
+            Ident(id) => id.name == kw.to_name(),
             _ => false,
         }
     }
 
     pub fn is_path_segment_keyword(&self) -> bool {
         match *self {
-            Ident(id, _) => id.name == SUPER_KEYWORD_NAME ||
-                            id.name == SELF_KEYWORD_NAME ||
-                            id.name == SELF_TYPE_KEYWORD_NAME,
+            Ident(id) => id.name == SUPER_KEYWORD_NAME ||
+                         id.name == SELF_KEYWORD_NAME ||
+                         id.name == SELF_TYPE_KEYWORD_NAME,
             _ => false,
         }
     }
@@ -296,12 +288,12 @@ impl Token {
     /// Returns `true` if the token is either a strict or reserved keyword.
     pub fn is_any_keyword(&self) -> bool {
         match *self {
-            Ident(id, _) => id.name == SELF_KEYWORD_NAME ||
-                            id.name == STATIC_KEYWORD_NAME ||
-                            id.name == SUPER_KEYWORD_NAME ||
-                            id.name == SELF_TYPE_KEYWORD_NAME ||
-                            id.name >= STRICT_KEYWORD_START &&
-                            id.name <= RESERVED_KEYWORD_FINAL,
+            Ident(id) => id.name == SELF_KEYWORD_NAME ||
+                         id.name == STATIC_KEYWORD_NAME ||
+                         id.name == SUPER_KEYWORD_NAME ||
+                         id.name == SELF_TYPE_KEYWORD_NAME ||
+                         id.name >= STRICT_KEYWORD_START &&
+                         id.name <= RESERVED_KEYWORD_FINAL,
             _ => false
         }
     }
@@ -309,12 +301,12 @@ impl Token {
     /// Returns `true` if the token is either a strict keyword.
     pub fn is_strict_keyword(&self) -> bool {
         match *self {
-            Ident(id, _) => id.name == SELF_KEYWORD_NAME ||
-                            id.name == STATIC_KEYWORD_NAME ||
-                            id.name == SUPER_KEYWORD_NAME ||
-                            id.name == SELF_TYPE_KEYWORD_NAME ||
-                            id.name >= STRICT_KEYWORD_START &&
-                            id.name <= STRICT_KEYWORD_FINAL,
+            Ident(id) => id.name == SELF_KEYWORD_NAME ||
+                         id.name == STATIC_KEYWORD_NAME ||
+                         id.name == SUPER_KEYWORD_NAME ||
+                         id.name == SELF_TYPE_KEYWORD_NAME ||
+                         id.name >= STRICT_KEYWORD_START &&
+                         id.name <= STRICT_KEYWORD_FINAL,
             _ => false,
         }
     }
@@ -322,8 +314,8 @@ impl Token {
     /// Returns `true` if the token is either a keyword reserved for possible future use.
     pub fn is_reserved_keyword(&self) -> bool {
         match *self {
-            Ident(id, _) => id.name >= RESERVED_KEYWORD_START &&
-                            id.name <= RESERVED_KEYWORD_FINAL,
+            Ident(id) => id.name >= RESERVED_KEYWORD_START &&
+                         id.name <= RESERVED_KEYWORD_FINAL,
             _ => false,
         }
     }
@@ -333,7 +325,7 @@ impl Token {
     /// See `styntax::ext::mtwt`.
     pub fn mtwt_eq(&self, other : &Token) -> bool {
         match (self, other) {
-            (&Ident(id1,_), &Ident(id2,_)) | (&Lifetime(id1), &Lifetime(id2)) =>
+            (&Ident(id1), &Ident(id2)) | (&Lifetime(id1), &Lifetime(id2)) =>
                 mtwt::resolve(id1) == mtwt::resolve(id2),
             _ => *self == *other
         }
@@ -349,7 +341,7 @@ pub enum Nonterminal {
     NtPat(P<ast::Pat>),
     NtExpr(P<ast::Expr>),
     NtTy(P<ast::Ty>),
-    NtIdent(Box<ast::SpannedIdent>, IdentStyle),
+    NtIdent(Box<ast::SpannedIdent>),
     /// Stuff inside brackets for attributes
     NtMeta(P<ast::MetaItem>),
     NtPath(Box<ast::Path>),
@@ -743,6 +735,6 @@ mod tests {
         assert!(Gt.mtwt_eq(&Gt));
         let a = str_to_ident("bac");
         let a1 = mark_ident(a,92);
-        assert!(Ident(a, ModName).mtwt_eq(&Ident(a1, Plain)));
+        assert!(Ident(a).mtwt_eq(&Ident(a1)));
     }
 }