about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-09-26 18:46:10 -0700
committerbors <bors@rust-lang.org>2013-09-26 18:46:10 -0700
commita94158ce64524b7e21e6c8ec23a6b762d45926fb (patch)
tree910767022dcecd289d5725833b1150054be5ef68 /src/libsyntax
parent1434b4bfcafe90cffa6627e3be18a9e5b6501ad1 (diff)
parentc1d64297f071ea166ffbe5aea4fa5f94da3b3622 (diff)
downloadrust-a94158ce64524b7e21e6c8ec23a6b762d45926fb.tar.gz
rust-a94158ce64524b7e21e6c8ec23a6b762d45926fb.zip
auto merge of #9504 : brson/rust/continue, r=alexcrichton
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/asm.rs12
-rw-r--r--src/libsyntax/parse/parser.rs12
-rw-r--r--src/libsyntax/parse/token.rs39
3 files changed, 39 insertions, 24 deletions
diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs
index b350ef7bb08..d47435dab56 100644
--- a/src/libsyntax/ext/asm.rs
+++ b/src/libsyntax/ext/asm.rs
@@ -54,8 +54,8 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
     let mut state = Asm;
 
     // Not using labeled break to get us through one round of bootstrapping.
-    let mut continue = true;
-    while continue {
+    let mut continue_ = true;
+    while continue_ {
         match state {
             Asm => {
                 asm = expr_to_str(cx, p.parse_expr(),
@@ -142,7 +142,7 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
                 match next_state(state) {
                     Some(x) => x,
                     None    => {
-                        continue = false;
+                        continue_ = false;
                         break
                     }
                 }
@@ -151,19 +151,19 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
                 let s = match next_state(state) {
                     Some(x) => x,
                     None    => {
-                        continue = false;
+                        continue_ = false;
                         break
                     }
                 };
                 match next_state(s) {
                     Some(x) => x,
                     None    => {
-                        continue = false;
+                        continue_ = false;
                         break
                     }
                 }
             } else if *p.token == token::EOF {
-                continue = false;
+                continue_ = false;
                 break;
             } else {
                state
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 74447b5dae1..d9fb53b4677 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -1786,6 +1786,17 @@ impl Parser {
             }
         } else if self.eat_keyword(keywords::Loop) {
             return self.parse_loop_expr(None);
+        } else if self.eat_keyword(keywords::Continue) {
+            let lo = self.span.lo;
+            let ex = if self.token_is_lifetime(&*self.token) {
+                let lifetime = self.get_lifetime(&*self.token);
+                self.bump();
+                ExprAgain(Some(lifetime.name))
+            } else {
+                ExprAgain(None)
+            };
+            let hi = self.span.hi;
+            return self.mk_expr(lo, hi, ex);
         } else if self.eat_keyword(keywords::Match) {
             return self.parse_match_expr();
         } else if self.eat_keyword(keywords::Unsafe) {
@@ -2578,6 +2589,7 @@ impl Parser {
             return self.mk_expr(lo, hi, ExprLoop(body, opt_ident));
         } else {
             // This is a 'continue' expression
+            // FIXME #9467 rm support for 'loop' here after snapshot
             if opt_ident.is_some() {
                 self.span_err(*self.last_span,
                               "a label may not be used with a `loop` expression");
diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs
index 6cc1058954c..eec4a81b2cf 100644
--- a/src/libsyntax/parse/token.rs
+++ b/src/libsyntax/parse/token.rs
@@ -477,14 +477,15 @@ fn mk_fresh_ident_interner() -> @ident_interner {
         "use",                // 61
         "while",              // 62
         "in",                 // 63
-
-        "be",                 // 64
-        "pure",               // 65
-        "yield",              // 66
-        "typeof",             // 67
-        "alignof",            // 68
-        "offsetof",           // 69
-        "sizeof",             // 70
+        "continue",           // 64
+
+        "be",                 // 65
+        "pure",               // 66
+        "yield",              // 67
+        "typeof",             // 68
+        "alignof",            // 69
+        "offsetof",           // 70
+        "sizeof",             // 71
     ];
 
     @interner::StrInterner::prefill(init_vec)
@@ -628,6 +629,7 @@ pub mod keywords {
         Unsafe,
         Use,
         While,
+        Continue,
 
         // Reserved keywords
         Alignof,
@@ -676,14 +678,15 @@ pub mod keywords {
                 Unsafe => Ident { name: 60, ctxt: 0 },
                 Use => Ident { name: 61, ctxt: 0 },
                 While => Ident { name: 62, ctxt: 0 },
-
-                Alignof => Ident { name: 68, ctxt: 0 },
-                Be => Ident { name: 64, ctxt: 0 },
-                Offsetof => Ident { name: 69, ctxt: 0 },
-                Pure => Ident { name: 65, ctxt: 0 },
-                Sizeof => Ident { name: 70, ctxt: 0 },
-                Typeof => Ident { name: 67, ctxt: 0 },
-                Yield => Ident { name: 66, ctxt: 0 },
+                Continue => Ident { name: 64, ctxt: 0 },
+
+                Alignof => Ident { name: 69, ctxt: 0 },
+                Be => Ident { name: 65, ctxt: 0 },
+                Offsetof => Ident { name: 70, ctxt: 0 },
+                Pure => Ident { name: 66, ctxt: 0 },
+                Sizeof => Ident { name: 71, ctxt: 0 },
+                Typeof => Ident { name: 68, ctxt: 0 },
+                Yield => Ident { name: 67, ctxt: 0 },
             }
         }
     }
@@ -709,7 +712,7 @@ pub fn is_any_keyword(tok: &Token) -> bool {
 pub fn is_strict_keyword(tok: &Token) -> bool {
     match *tok {
         token::IDENT(sid, false) => match sid.name {
-            8 | 27 | 32 .. 63 => true,
+            8 | 27 | 32 .. 64 => true,
             _ => false,
         },
         _ => false,
@@ -719,7 +722,7 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
 pub fn is_reserved_keyword(tok: &Token) -> bool {
     match *tok {
         token::IDENT(sid, false) => match sid.name {
-            64 .. 70 => true,
+            65 .. 71 => true,
             _ => false,
         },
         _ => false,