diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-04 17:55:23 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-06-06 14:03:14 +0300 |
| commit | 99b27d749c22117eccf862f5ee4eb540b65b681f (patch) | |
| tree | e891310a8eb306921f8a054bb40cf653433403fe /src/libsyntax/ext | |
| parent | eac3846b65b068a5cbdfafc786e258554b875dae (diff) | |
| download | rust-99b27d749c22117eccf862f5ee4eb540b65b681f.tar.gz rust-99b27d749c22117eccf862f5ee4eb540b65b681f.zip | |
syntax: Rename `Token` into `TokenKind`
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_parser.rs | 16 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 2 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/quoted.rs | 18 | ||||
| -rw-r--r-- | src/libsyntax/ext/tt/transcribe.rs | 6 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 473a5f414df..c22952ed750 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -78,7 +78,7 @@ use crate::ast::Ident; use crate::ext::tt::quoted::{self, TokenTree}; use crate::parse::{Directory, ParseSess}; use crate::parse::parser::{Parser, PathStyle}; -use crate::parse::token::{self, DocComment, Nonterminal, Token}; +use crate::parse::token::{self, DocComment, Nonterminal, TokenKind}; use crate::print::pprust; use crate::symbol::{kw, sym, Symbol}; use crate::tokenstream::{DelimSpan, TokenStream}; @@ -199,7 +199,7 @@ struct MatcherPos<'root, 'tt: 'root> { seq_op: Option<quoted::KleeneOp>, /// The separator if we are in a repetition. - sep: Option<Token>, + sep: Option<TokenKind>, /// The "parent" matcher position if we are in a repetition. That is, the matcher position just /// before we enter the sequence. @@ -273,7 +273,7 @@ pub enum ParseResult<T> { Success(T), /// Arm failed to match. If the second parameter is `token::Eof`, it indicates an unexpected /// end of macro invocation. Otherwise, it indicates that no rules expected the given token. - Failure(syntax_pos::Span, Token, &'static str), + Failure(syntax_pos::Span, TokenKind, &'static str), /// Fatal error (malformed macro?). Abort compilation. Error(syntax_pos::Span, String), } @@ -417,7 +417,7 @@ fn nameize<I: Iterator<Item = NamedMatch>>( /// Generates an appropriate parsing failure message. For EOF, this is "unexpected end...". For /// other tokens, this is "unexpected token...". -pub fn parse_failure_msg(tok: Token) -> String { +pub fn parse_failure_msg(tok: TokenKind) -> String { match tok { token::Eof => "unexpected end of macro invocation".to_string(), _ => format!( @@ -428,7 +428,7 @@ pub fn parse_failure_msg(tok: Token) -> String { } /// Performs a token equality check, ignoring syntax context (that is, an unhygienic comparison) -fn token_name_eq(t1: &Token, t2: &Token) -> bool { +fn token_name_eq(t1: &TokenKind, t2: &TokenKind) -> bool { if let (Some((id1, is_raw1)), Some((id2, is_raw2))) = (t1.ident(), t2.ident()) { id1.name == id2.name && is_raw1 == is_raw2 } else if let (Some(id1), Some(id2)) = (t1.lifetime(), t2.lifetime()) { @@ -466,7 +466,7 @@ fn inner_parse_loop<'root, 'tt>( next_items: &mut Vec<MatcherPosHandle<'root, 'tt>>, eof_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, bb_items: &mut SmallVec<[MatcherPosHandle<'root, 'tt>; 1]>, - token: &Token, + token: &TokenKind, span: syntax_pos::Span, ) -> ParseResult<()> { // Pop items from `cur_items` until it is empty. @@ -807,7 +807,7 @@ pub fn parse( /// The token is an identifier, but not `_`. /// We prohibit passing `_` to macros expecting `ident` for now. -fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { +fn get_macro_ident(token: &TokenKind) -> Option<(Ident, bool)> { match *token { token::Ident(ident, is_raw) if ident.name != kw::Underscore => Some((ident, is_raw)), @@ -819,7 +819,7 @@ fn get_macro_ident(token: &Token) -> Option<(Ident, bool)> { /// /// Returning `false` is a *stability guarantee* that such a matcher will *never* begin with that /// token. Be conservative (return true) if not sure. -fn may_begin_with(name: Symbol, token: &Token) -> bool { +fn may_begin_with(name: Symbol, token: &TokenKind) -> bool { /// Checks whether the non-terminal may contain a single (non-keyword) identifier. fn may_be_ident(nt: &token::Nonterminal) -> bool { match *nt { diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 285c88357a6..9d3ea4d8645 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -12,7 +12,7 @@ use crate::feature_gate::Features; use crate::parse::{Directory, ParseSess}; use crate::parse::parser::Parser; use crate::parse::token::{self, NtTT}; -use crate::parse::token::Token::*; +use crate::parse::token::TokenKind::*; use crate::symbol::{Symbol, kw, sym}; use crate::tokenstream::{DelimSpan, TokenStream, TokenTree}; diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index a029c654659..fe0cb56b29e 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -23,12 +23,12 @@ pub struct Delimited { impl Delimited { /// Returns the opening delimiter (possibly `NoDelim`). - pub fn open_token(&self) -> token::Token { + pub fn open_token(&self) -> token::TokenKind { token::OpenDelim(self.delim) } /// Returns the closing delimiter (possibly `NoDelim`). - pub fn close_token(&self) -> token::Token { + pub fn close_token(&self) -> token::TokenKind { token::CloseDelim(self.delim) } @@ -58,7 +58,7 @@ pub struct SequenceRepetition { /// The sequence of token trees pub tts: Vec<TokenTree>, /// The optional separator - pub separator: Option<token::Token>, + pub separator: Option<token::TokenKind>, /// Whether the sequence can be repeated zero (*), or one or more times (+) pub op: KleeneOp, /// The number of `Match`s that appear in the sequence (and subsequences) @@ -81,7 +81,7 @@ pub enum KleeneOp { /// are "first-class" token trees. Useful for parsing macros. #[derive(Debug, Clone, PartialEq, RustcEncodable, RustcDecodable)] pub enum TokenTree { - Token(Span, token::Token), + Token(Span, token::TokenKind), Delimited(DelimSpan, Lrc<Delimited>), /// A kleene-style repetition sequence Sequence(DelimSpan, Lrc<SequenceRepetition>), @@ -366,7 +366,7 @@ where /// Takes a token and returns `Some(KleeneOp)` if the token is `+` `*` or `?`. Otherwise, return /// `None`. -fn kleene_op(token: &token::Token) -> Option<KleeneOp> { +fn kleene_op(token: &token::TokenKind) -> Option<KleeneOp> { match *token { token::BinOp(token::Star) => Some(KleeneOp::ZeroOrMore), token::BinOp(token::Plus) => Some(KleeneOp::OneOrMore), @@ -383,7 +383,7 @@ fn kleene_op(token: &token::Token) -> Option<KleeneOp> { fn parse_kleene_op<I>( input: &mut I, span: Span, -) -> Result<Result<(KleeneOp, Span), (token::Token, Span)>, Span> +) -> Result<Result<(KleeneOp, Span), (token::TokenKind, Span)>, Span> where I: Iterator<Item = tokenstream::TokenTree>, { @@ -422,7 +422,7 @@ fn parse_sep_and_kleene_op<I>( attrs: &[ast::Attribute], edition: Edition, macro_node_id: NodeId, -) -> (Option<token::Token>, KleeneOp) +) -> (Option<token::TokenKind>, KleeneOp) where I: Iterator<Item = tokenstream::TokenTree>, { @@ -447,7 +447,7 @@ fn parse_sep_and_kleene_op_2015<I>( _features: &Features, _attrs: &[ast::Attribute], macro_node_id: NodeId, -) -> (Option<token::Token>, KleeneOp) +) -> (Option<token::TokenKind>, KleeneOp) where I: Iterator<Item = tokenstream::TokenTree>, { @@ -565,7 +565,7 @@ fn parse_sep_and_kleene_op_2018<I>( sess: &ParseSess, _features: &Features, _attrs: &[ast::Attribute], -) -> (Option<token::Token>, KleeneOp) +) -> (Option<token::TokenKind>, KleeneOp) where I: Iterator<Item = tokenstream::TokenTree>, { diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index c2a1866b03a..1b169d7696a 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -4,7 +4,7 @@ use crate::ext::expand::Marker; use crate::ext::tt::macro_parser::{MatchedNonterminal, MatchedSeq, NamedMatch}; use crate::ext::tt::quoted; use crate::mut_visit::noop_visit_tt; -use crate::parse::token::{self, NtTT, Token}; +use crate::parse::token::{self, NtTT, TokenKind}; use crate::tokenstream::{DelimSpan, TokenStream, TokenTree, TreeAndJoint}; use smallvec::{smallvec, SmallVec}; @@ -18,7 +18,7 @@ use std::rc::Rc; /// An iterator over the token trees in a delimited token tree (`{ ... }`) or a sequence (`$(...)`). enum Frame { Delimited { forest: Lrc<quoted::Delimited>, idx: usize, span: DelimSpan }, - Sequence { forest: Lrc<quoted::SequenceRepetition>, idx: usize, sep: Option<Token> }, + Sequence { forest: Lrc<quoted::SequenceRepetition>, idx: usize, sep: Option<TokenKind> }, } impl Frame { @@ -242,7 +242,7 @@ pub fn transcribe( Ident::new(ident.name, ident.span.apply_mark(cx.current_expansion.mark)); sp = sp.apply_mark(cx.current_expansion.mark); result.push(TokenTree::Token(sp, token::Dollar).into()); - result.push(TokenTree::Token(sp, token::Token::from_ast_ident(ident)).into()); + result.push(TokenTree::Token(sp, token::TokenKind::from_ast_ident(ident)).into()); } } |
