Add 'continue' as a synonym for 'loop'
This commit is contained in:
parent
41826c48ed
commit
88272a4f24
6 changed files with 54 additions and 39 deletions
|
@ -564,7 +564,7 @@ impl<'self> EachItemContext<'self> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut continue = (self.callback)(*self.path_builder, def_like, vis);
|
let mut continue_ = (self.callback)(*self.path_builder, def_like, vis);
|
||||||
|
|
||||||
let family = item_family(doc);
|
let family = item_family(doc);
|
||||||
if family == ForeignMod {
|
if family == ForeignMod {
|
||||||
|
@ -572,11 +572,11 @@ impl<'self> EachItemContext<'self> {
|
||||||
self.pop_name(old_len)
|
self.pop_name(old_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
if continue {
|
if continue_ {
|
||||||
// Recurse if necessary.
|
// Recurse if necessary.
|
||||||
match family {
|
match family {
|
||||||
Mod | ForeignMod | Trait | Impl => {
|
Mod | ForeignMod | Trait | Impl => {
|
||||||
continue = self.each_item_of_module(def_id);
|
continue_ = self.each_item_of_module(def_id);
|
||||||
}
|
}
|
||||||
ImmStatic | MutStatic | Struct | UnsafeFn | Fn | ForeignFn |
|
ImmStatic | MutStatic | Struct | UnsafeFn | Fn | ForeignFn |
|
||||||
UnsafeStaticMethod | StaticMethod | Type | ForeignType |
|
UnsafeStaticMethod | StaticMethod | Type | ForeignType |
|
||||||
|
@ -589,7 +589,7 @@ impl<'self> EachItemContext<'self> {
|
||||||
self.pop_name(old_len)
|
self.pop_name(old_len)
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue_
|
||||||
}
|
}
|
||||||
|
|
||||||
fn each_item_of_module(&mut self, def_id: ast::DefId) -> bool {
|
fn each_item_of_module(&mut self, def_id: ast::DefId) -> bool {
|
||||||
|
@ -612,7 +612,7 @@ impl<'self> EachItemContext<'self> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn each_child_of_module_or_crate(&mut self, item_doc: ebml::Doc) -> bool {
|
fn each_child_of_module_or_crate(&mut self, item_doc: ebml::Doc) -> bool {
|
||||||
let mut continue = true;
|
let mut continue_ = true;
|
||||||
|
|
||||||
// Iterate over all children.
|
// Iterate over all children.
|
||||||
do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| {
|
do reader::tagged_docs(item_doc, tag_mod_child) |child_info_doc| {
|
||||||
|
@ -654,16 +654,16 @@ impl<'self> EachItemContext<'self> {
|
||||||
// Process this item.
|
// Process this item.
|
||||||
|
|
||||||
let vis = item_visibility(child_item_doc);
|
let vis = item_visibility(child_item_doc);
|
||||||
continue = self.process_item_and_pop_name(child_item_doc,
|
continue_ = self.process_item_and_pop_name(child_item_doc,
|
||||||
child_def_id,
|
child_def_id,
|
||||||
old_len,
|
old_len,
|
||||||
vis);
|
vis);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue_
|
||||||
};
|
};
|
||||||
|
|
||||||
if !continue {
|
if !continue_ {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,7 +705,7 @@ impl<'self> EachItemContext<'self> {
|
||||||
match maybe_find_item(def_id.node, other_crates_items) {
|
match maybe_find_item(def_id.node, other_crates_items) {
|
||||||
None => { self.pop_name(old_len); }
|
None => { self.pop_name(old_len); }
|
||||||
Some(reexported_item_doc) => {
|
Some(reexported_item_doc) => {
|
||||||
continue = self.process_item_and_pop_name(
|
continue_ = self.process_item_and_pop_name(
|
||||||
reexported_item_doc,
|
reexported_item_doc,
|
||||||
def_id,
|
def_id,
|
||||||
old_len,
|
old_len,
|
||||||
|
@ -713,10 +713,10 @@ impl<'self> EachItemContext<'self> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue_
|
||||||
};
|
};
|
||||||
|
|
||||||
continue
|
continue_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -521,12 +521,12 @@ fn encode_reexported_static_methods(ecx: &EncodeContext,
|
||||||
/// * For newtype structs, iterates through the node ID of the constructor.
|
/// * For newtype structs, iterates through the node ID of the constructor.
|
||||||
fn each_auxiliary_node_id(item: @item, callback: &fn(NodeId) -> bool)
|
fn each_auxiliary_node_id(item: @item, callback: &fn(NodeId) -> bool)
|
||||||
-> bool {
|
-> bool {
|
||||||
let mut continue = true;
|
let mut continue_ = true;
|
||||||
match item.node {
|
match item.node {
|
||||||
item_enum(ref enum_def, _) => {
|
item_enum(ref enum_def, _) => {
|
||||||
for variant in enum_def.variants.iter() {
|
for variant in enum_def.variants.iter() {
|
||||||
continue = callback(variant.node.id);
|
continue_ = callback(variant.node.id);
|
||||||
if !continue {
|
if !continue_ {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,7 +537,7 @@ fn each_auxiliary_node_id(item: @item, callback: &fn(NodeId) -> bool)
|
||||||
Some(ctor_id) if struct_def.fields.len() > 0 &&
|
Some(ctor_id) if struct_def.fields.len() > 0 &&
|
||||||
struct_def.fields[0].node.kind ==
|
struct_def.fields[0].node.kind ==
|
||||||
ast::unnamed_field => {
|
ast::unnamed_field => {
|
||||||
continue = callback(ctor_id);
|
continue_ = callback(ctor_id);
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
@ -545,7 +545,7 @@ fn each_auxiliary_node_id(item: @item, callback: &fn(NodeId) -> bool)
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue_
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encode_reexports(ecx: &EncodeContext,
|
fn encode_reexports(ecx: &EncodeContext,
|
||||||
|
|
|
@ -54,8 +54,8 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
||||||
let mut state = Asm;
|
let mut state = Asm;
|
||||||
|
|
||||||
// Not using labeled break to get us through one round of bootstrapping.
|
// Not using labeled break to get us through one round of bootstrapping.
|
||||||
let mut continue = true;
|
let mut continue_ = true;
|
||||||
while continue {
|
while continue_ {
|
||||||
match state {
|
match state {
|
||||||
Asm => {
|
Asm => {
|
||||||
asm = expr_to_str(cx, p.parse_expr(),
|
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) {
|
match next_state(state) {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => {
|
None => {
|
||||||
continue = false;
|
continue_ = false;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,19 +151,19 @@ pub fn expand_asm(cx: @ExtCtxt, sp: Span, tts: &[ast::token_tree])
|
||||||
let s = match next_state(state) {
|
let s = match next_state(state) {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => {
|
None => {
|
||||||
continue = false;
|
continue_ = false;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
match next_state(s) {
|
match next_state(s) {
|
||||||
Some(x) => x,
|
Some(x) => x,
|
||||||
None => {
|
None => {
|
||||||
continue = false;
|
continue_ = false;
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if *p.token == token::EOF {
|
} else if *p.token == token::EOF {
|
||||||
continue = false;
|
continue_ = false;
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
state
|
state
|
||||||
|
|
|
@ -1786,6 +1786,17 @@ impl Parser {
|
||||||
}
|
}
|
||||||
} else if self.eat_keyword(keywords::Loop) {
|
} else if self.eat_keyword(keywords::Loop) {
|
||||||
return self.parse_loop_expr(None);
|
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) {
|
} else if self.eat_keyword(keywords::Match) {
|
||||||
return self.parse_match_expr();
|
return self.parse_match_expr();
|
||||||
} else if self.eat_keyword(keywords::Unsafe) {
|
} else if self.eat_keyword(keywords::Unsafe) {
|
||||||
|
@ -2578,6 +2589,7 @@ impl Parser {
|
||||||
return self.mk_expr(lo, hi, ExprLoop(body, opt_ident));
|
return self.mk_expr(lo, hi, ExprLoop(body, opt_ident));
|
||||||
} else {
|
} else {
|
||||||
// This is a 'continue' expression
|
// This is a 'continue' expression
|
||||||
|
// FIXME #9467 rm support for 'loop' here after snapshot
|
||||||
if opt_ident.is_some() {
|
if opt_ident.is_some() {
|
||||||
self.span_err(*self.last_span,
|
self.span_err(*self.last_span,
|
||||||
"a label may not be used with a `loop` expression");
|
"a label may not be used with a `loop` expression");
|
||||||
|
|
|
@ -477,14 +477,15 @@ fn mk_fresh_ident_interner() -> @ident_interner {
|
||||||
"use", // 61
|
"use", // 61
|
||||||
"while", // 62
|
"while", // 62
|
||||||
"in", // 63
|
"in", // 63
|
||||||
|
"continue", // 64
|
||||||
|
|
||||||
"be", // 64
|
"be", // 65
|
||||||
"pure", // 65
|
"pure", // 66
|
||||||
"yield", // 66
|
"yield", // 67
|
||||||
"typeof", // 67
|
"typeof", // 68
|
||||||
"alignof", // 68
|
"alignof", // 69
|
||||||
"offsetof", // 69
|
"offsetof", // 70
|
||||||
"sizeof", // 70
|
"sizeof", // 71
|
||||||
];
|
];
|
||||||
|
|
||||||
@interner::StrInterner::prefill(init_vec)
|
@interner::StrInterner::prefill(init_vec)
|
||||||
|
@ -628,6 +629,7 @@ pub mod keywords {
|
||||||
Unsafe,
|
Unsafe,
|
||||||
Use,
|
Use,
|
||||||
While,
|
While,
|
||||||
|
Continue,
|
||||||
|
|
||||||
// Reserved keywords
|
// Reserved keywords
|
||||||
Alignof,
|
Alignof,
|
||||||
|
@ -676,14 +678,15 @@ pub mod keywords {
|
||||||
Unsafe => Ident { name: 60, ctxt: 0 },
|
Unsafe => Ident { name: 60, ctxt: 0 },
|
||||||
Use => Ident { name: 61, ctxt: 0 },
|
Use => Ident { name: 61, ctxt: 0 },
|
||||||
While => Ident { name: 62, ctxt: 0 },
|
While => Ident { name: 62, ctxt: 0 },
|
||||||
|
Continue => Ident { name: 64, ctxt: 0 },
|
||||||
|
|
||||||
Alignof => Ident { name: 68, ctxt: 0 },
|
Alignof => Ident { name: 69, ctxt: 0 },
|
||||||
Be => Ident { name: 64, ctxt: 0 },
|
Be => Ident { name: 65, ctxt: 0 },
|
||||||
Offsetof => Ident { name: 69, ctxt: 0 },
|
Offsetof => Ident { name: 70, ctxt: 0 },
|
||||||
Pure => Ident { name: 65, ctxt: 0 },
|
Pure => Ident { name: 66, ctxt: 0 },
|
||||||
Sizeof => Ident { name: 70, ctxt: 0 },
|
Sizeof => Ident { name: 71, ctxt: 0 },
|
||||||
Typeof => Ident { name: 67, ctxt: 0 },
|
Typeof => Ident { name: 68, ctxt: 0 },
|
||||||
Yield => Ident { name: 66, 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 {
|
pub fn is_strict_keyword(tok: &Token) -> bool {
|
||||||
match *tok {
|
match *tok {
|
||||||
token::IDENT(sid, false) => match sid.name {
|
token::IDENT(sid, false) => match sid.name {
|
||||||
8 | 27 | 32 .. 63 => true,
|
8 | 27 | 32 .. 64 => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -719,7 +722,7 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
|
||||||
pub fn is_reserved_keyword(tok: &Token) -> bool {
|
pub fn is_reserved_keyword(tok: &Token) -> bool {
|
||||||
match *tok {
|
match *tok {
|
||||||
token::IDENT(sid, false) => match sid.name {
|
token::IDENT(sid, false) => match sid.name {
|
||||||
64 .. 70 => true,
|
65 .. 71 => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
|
|
|
@ -15,6 +15,6 @@ pub fn main() {
|
||||||
assert!((i > 0));
|
assert!((i > 0));
|
||||||
info!(i);
|
info!(i);
|
||||||
i -= 1;
|
i -= 1;
|
||||||
loop;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue