Skip to content

Commit ceac155

Browse files
committed
For #2229, recognize 'again' in place of 'cont', final change pending snapshot.
1 parent e20f63d commit ceac155

File tree

19 files changed

+34
-34
lines changed

19 files changed

+34
-34
lines changed

doc/rust.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,9 @@ import export use mod
209209
The keywords in [source files](#source-files) are the following strings:
210210

211211
~~~~~~~~ {.keyword}
212-
alt assert
212+
alt again assert
213213
break
214-
check claim class const cont copy
214+
check claim class const copy
215215
drop
216216
else enum export extern
217217
fail false fn for
@@ -2034,19 +2034,19 @@ break_expr : "break" ;
20342034
Executing a `break` expression immediately terminates the innermost loop
20352035
enclosing it. It is only permitted in the body of a loop.
20362036

2037-
### Continue expressions
2037+
### Again expressions
20382038

20392039
~~~~~~~~{.ebnf .gram}
2040-
break_expr : "cont" ;
2040+
again_expr : "again" ;
20412041
~~~~~~~~
20422042

2043-
Evaluating a `cont` expression immediately terminates the current iteration of
2043+
Evaluating an `again` expression immediately terminates the current iteration of
20442044
the innermost loop enclosing it, returning control to the loop *head*. In the
20452045
case of a `while` loop, the head is the conditional expression controlling the
2046-
loop. In the case of a `for` loop, the head is the vector-element increment
2047-
controlling the loop.
2046+
loop. In the case of a `for` loop, the head is the call-expression controlling
2047+
the loop.
20482048

2049-
A `cont` expression is only permitted in the body of a loop.
2049+
An `again` expression is only permitted in the body of a loop.
20502050

20512051

20522052
### For expressions

doc/tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ a specific value, are not allowed.
783783
784784
`while` produces a loop that runs as long as its given condition
785785
(which must have type `bool`) evaluates to true. Inside a loop, the
786-
keyword `break` can be used to abort the loop, and `cont` can be used
786+
keyword `break` can be used to abort the loop, and `again` can be used
787787
to abort the current iteration and continue with the next.
788788
789789
~~~~
@@ -1187,7 +1187,7 @@ Empty argument lists can be omitted from `do` expressions.
11871187
11881188
Most iteration in Rust is done with `for` loops. Like `do`,
11891189
`for` is a nice syntax for doing control flow with closures.
1190-
Additionally, within a `for` loop, `break, `cont`, and `ret`
1190+
Additionally, within a `for` loop, `break, `again`, and `ret`
11911191
work just as they do with `while` and `loop`.
11921192
11931193
Consider again our `each` function, this time improved to
@@ -1221,8 +1221,8 @@ each(~[2, 4, 8, 5, 16], |n| {
12211221
With `for`, functions like `each` can be treated more
12221222
like builtin looping structures. When calling `each`
12231223
in a `for` loop, instead of returning `false` to break
1224-
out of the loop, you just write `break`. To continue
1225-
to the next iteration, write `cont`.
1224+
out of the loop, you just write `break`. To skip ahead
1225+
to the next iteration, write `again`.
12261226
12271227
~~~~
12281228
# import each = vec::each;

src/etc/emacs/rust-mode.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
"trait" "fn" "enum" "iface"
5757
"impl"))
5858
(puthash word 'def table))
59-
(dolist (word '("assert"
59+
(dolist (word '("again" "assert"
6060
"break"
61-
"check" "claim" "cont" "copy"
61+
"check" "claim" "copy"
6262
"do" "drop"
6363
"else" "export" "extern"
6464
"fail" "for"

src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn common_exprs() -> ~[ast::expr] {
4242
}
4343

4444
~[dse(ast::expr_break),
45-
dse(ast::expr_cont),
45+
dse(ast::expr_again),
4646
dse(ast::expr_fail(option::none)),
4747
dse(ast::expr_fail(option::some(
4848
@dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"))))))),

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ enum expr_ {
336336
expr_addr_of(mutability, @expr),
337337
expr_fail(option<@expr>),
338338
expr_break,
339-
expr_cont,
339+
expr_again,
340340
expr_ret(option<@expr>),
341341
expr_log(int, @expr, @expr),
342342

src/libsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ fn noop_fold_expr(e: expr_, fld: ast_fold) -> expr_ {
464464
}
465465
expr_path(pth) { expr_path(fld.fold_path(pth)) }
466466
expr_fail(e) { expr_fail(option::map(e, fld.fold_expr)) }
467-
expr_break | expr_cont { copy e }
467+
expr_break | expr_again { copy e }
468468
expr_ret(e) { expr_ret(option::map(e, fld.fold_expr)) }
469469
expr_log(i, lv, e) { expr_log(i, fld.fold_expr(lv),
470470
fld.fold_expr(e)) }

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,8 +966,9 @@ class parser {
966966
} else if self.eat_keyword("break") {
967967
ex = expr_break;
968968
hi = self.span.hi;
969-
} else if self.eat_keyword("cont") {
970-
ex = expr_cont;
969+
} else if self.eat_keyword("cont") ||
970+
self.eat_keyword("again") {
971+
ex = expr_again;
971972
hi = self.span.hi;
972973
} else if self.eat_keyword("copy") {
973974
let e = self.parse_expr();

src/libsyntax/parse/token.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ fn contextual_keyword_table() -> hashmap<str, ()> {
304304
fn restricted_keyword_table() -> hashmap<str, ()> {
305305
let words = str_hash();
306306
let keys = ~[
307-
"alt",
308-
"assert",
307+
"alt", "again", "assert",
309308
"break",
310309
"check", "claim", "class", "const", "cont", "copy",
311310
"do", "drop",

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
10631063
}
10641064
}
10651065
ast::expr_break { word(s.s, "break"); }
1066-
ast::expr_cont { word(s.s, "cont"); }
1066+
ast::expr_again { word(s.s, "again"); }
10671067
ast::expr_ret(result) {
10681068
word(s.s, "ret");
10691069
alt result {

src/libsyntax/visit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ fn visit_expr<E>(ex: @expr, e: E, v: vt<E>) {
421421
expr_path(p) { visit_path(p, e, v); }
422422
expr_fail(eo) { visit_expr_opt(eo, e, v); }
423423
expr_break { }
424-
expr_cont { }
424+
expr_again { }
425425
expr_ret(eo) { visit_expr_opt(eo, e, v); }
426426
expr_log(_, lv, x) {
427427
v.visit_expr(lv, e, v);

0 commit comments

Comments
 (0)