]> git.lizzy.rs Git - rust.git/commitdiff
Rename Parser::last_token_kind as prev_token_kind.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 21 Sep 2016 02:16:28 +0000 (12:16 +1000)
committerNicholas Nethercote <nnethercote@mozilla.com>
Tue, 4 Oct 2016 21:53:18 +0000 (08:53 +1100)
Likewise, rename LastTokenKind as PrevTokenKind.

This is a [breaking-change] for libsyntax.

src/libsyntax/parse/parser.rs

index 1ecda9942966cd7f05bf57d4539f1f72ef0f9cf5..61268d457ce44a6658c0f46cdadc5a8a7c53d166 100644 (file)
@@ -238,7 +238,7 @@ fn maybe_append(mut lhs: Vec<Attribute>, rhs: Option<Vec<Attribute>>)
 }
 
 #[derive(PartialEq)]
-enum LastTokenKind {
+enum PrevTokenKind {
     DocComment,
     Comma,
     Interpolated,
@@ -258,7 +258,7 @@ pub struct Parser<'a> {
     pub prev_span: Span,
     pub cfg: CrateConfig,
     /// the previous token kind
-    last_token_kind: LastTokenKind,
+    prev_token_kind: PrevTokenKind,
     pub buffer: [TokenAndSpan; 4],
     pub buffer_start: isize,
     pub buffer_end: isize,
@@ -369,7 +369,7 @@ pub fn new(sess: &'a ParseSess,
             token: tok0.tok,
             span: span,
             prev_span: span,
-            last_token_kind: LastTokenKind::Other,
+            prev_token_kind: PrevTokenKind::Other,
             buffer: [
                 placeholder.clone(),
                 placeholder.clone(),
@@ -504,7 +504,7 @@ fn interpolated_or_expr_span(&self,
                                  expr: PResult<'a, P<Expr>>)
                                  -> PResult<'a, (Span, P<Expr>)> {
         expr.map(|e| {
-            if self.last_token_kind == LastTokenKind::Interpolated {
+            if self.prev_token_kind == PrevTokenKind::Interpolated {
                 (self.prev_span, e)
             } else {
                 (e.span, e)
@@ -524,7 +524,7 @@ pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
                 self.bug("ident interpolation not converted to real token");
             }
             _ => {
-                Err(if self.last_token_kind == LastTokenKind::DocComment {
+                Err(if self.prev_token_kind == PrevTokenKind::DocComment {
                     self.span_fatal_help(self.prev_span,
                         "found a documentation comment that doesn't document anything",
                         "doc comments must come before what they document, maybe a comment was \
@@ -922,7 +922,7 @@ pub fn parse_seq<T, F>(&mut self,
 
     /// Advance the parser by one token
     pub fn bump(&mut self) {
-        if self.last_token_kind == LastTokenKind::Eof {
+        if self.prev_token_kind == PrevTokenKind::Eof {
             // Bumping after EOF is a bad sign, usually an infinite loop.
             self.bug("attempted to bump the parser past EOF (may be stuck in a loop)");
         }
@@ -930,12 +930,12 @@ pub fn bump(&mut self) {
         self.prev_span = self.span;
 
         // Record last token kind for possible error recovery.
-        self.last_token_kind = match self.token {
-            token::DocComment(..) => LastTokenKind::DocComment,
-            token::Comma => LastTokenKind::Comma,
-            token::Interpolated(..) => LastTokenKind::Interpolated,
-            token::Eof => LastTokenKind::Eof,
-            _ => LastTokenKind::Other,
+        self.prev_token_kind = match self.token {
+            token::DocComment(..) => PrevTokenKind::DocComment,
+            token::Comma => PrevTokenKind::Comma,
+            token::Interpolated(..) => PrevTokenKind::Interpolated,
+            token::Eof => PrevTokenKind::Eof,
+            _ => PrevTokenKind::Other,
         };
 
         let next = if self.buffer_start == self.buffer_end {
@@ -976,8 +976,8 @@ pub fn bump_with(&mut self,
         self.prev_span = mk_sp(self.span.lo, lo);
         // It would be incorrect to record the kind of the current token, but
         // fortunately for tokens currently using `bump_with`, the
-        // last_token_kind will be of no use anyway.
-        self.last_token_kind = LastTokenKind::Other;
+        // prev_token_kind will be of no use anyway.
+        self.prev_token_kind = PrevTokenKind::Other;
         self.span = mk_sp(lo, hi);
         self.token = next;
         self.expected_tokens.clear();
@@ -2950,7 +2950,7 @@ pub fn parse_assoc_expr_with(&mut self,
         self.expected_tokens.push(TokenType::Operator);
         while let Some(op) = AssocOp::from_token(&self.token) {
 
-            let lhs_span = if self.last_token_kind == LastTokenKind::Interpolated {
+            let lhs_span = if self.prev_token_kind == PrevTokenKind::Interpolated {
                 self.prev_span
             } else {
                 lhs.span
@@ -4019,7 +4019,7 @@ fn parse_stmt_without_recovery(&mut self,
                 None => {
                     let unused_attrs = |attrs: &[_], s: &mut Self| {
                         if attrs.len() > 0 {
-                            if s.last_token_kind == LastTokenKind::DocComment {
+                            if s.prev_token_kind == PrevTokenKind::DocComment {
                                 s.span_err_help(s.prev_span,
                                     "found a documentation comment that doesn't document anything",
                                     "doc comments must come before what they document, maybe a \
@@ -4338,7 +4338,7 @@ fn parse_generic_values_after_lt(&mut self) -> PResult<'a, (Vec<ast::Lifetime>,
 
         let missing_comma = !lifetimes.is_empty() &&
                             !self.token.is_like_gt() &&
-                            self.last_token_kind != LastTokenKind::Comma;
+                            self.prev_token_kind != PrevTokenKind::Comma;
 
         if missing_comma {