Convert alt to match. Stop parsing alt
This commit is contained in:
parent
d3a9bb1bd4
commit
ecaf9e39c9
359 changed files with 2938 additions and 2915 deletions
|
|
@ -76,7 +76,7 @@ fn str_set() {
|
|||
|
||||
let mut found = 0;
|
||||
for int::range(0, 1000) |_i| {
|
||||
alt s.find(r.gen_str(10)) {
|
||||
match s.find(r.gen_str(10)) {
|
||||
some(_) => { found += 1; }
|
||||
none => { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
|||
};
|
||||
|
||||
fn is_gray(c: color) -> bool {
|
||||
alt c {
|
||||
match c {
|
||||
gray(_) => { true }
|
||||
_ => { false }
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
|||
i += 1u;
|
||||
colors = do colors.mapi() |i, c| {
|
||||
let c : color = c;
|
||||
alt c {
|
||||
match c {
|
||||
white => {
|
||||
let i = i as node_id;
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
|
|||
|
||||
// Convert the results.
|
||||
do vec::map(colors) |c| {
|
||||
alt c {
|
||||
match c {
|
||||
white => { -1i64 }
|
||||
black(parent) => { parent }
|
||||
_ => { fail ~"Found remaining gray nodes in BFS" }
|
||||
|
|
@ -227,7 +227,7 @@ fn pbfs(&&graph: arc::arc<graph>, key: node_id) -> bfs_result {
|
|||
|
||||
#[inline(always)]
|
||||
fn is_gray(c: color) -> bool {
|
||||
alt c {
|
||||
match c {
|
||||
gray(_) => { true }
|
||||
_ => { false }
|
||||
}
|
||||
|
|
@ -249,7 +249,7 @@ fn pbfs(&&graph: arc::arc<graph>, key: node_id) -> bfs_result {
|
|||
let c : color = c;
|
||||
let colors = arc::get(&colors);
|
||||
let graph = arc::get(&graph);
|
||||
alt c {
|
||||
match c {
|
||||
white => {
|
||||
let i = i as node_id;
|
||||
|
||||
|
|
@ -276,7 +276,7 @@ fn pbfs(&&graph: arc::arc<graph>, key: node_id) -> bfs_result {
|
|||
|
||||
// Convert the results.
|
||||
do par::map(colors) |c| {
|
||||
alt c {
|
||||
match c {
|
||||
white => { -1i64 }
|
||||
black(parent) => { parent }
|
||||
_ => { fail ~"Found remaining gray nodes in BFS" }
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ fn server(requests: port<request>, responses: pipes::chan<uint>) {
|
|||
let mut count = 0u;
|
||||
let mut done = false;
|
||||
while !done {
|
||||
alt requests.try_recv() {
|
||||
match requests.try_recv() {
|
||||
some(get_count) => { responses.send(copy count); }
|
||||
some(bytes(b)) => {
|
||||
//error!{"server: received %? bytes", b};
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ fn server(requests: port_set<request>, responses: pipes::chan<uint>) {
|
|||
let mut count = 0u;
|
||||
let mut done = false;
|
||||
while !done {
|
||||
alt requests.try_recv() {
|
||||
match requests.try_recv() {
|
||||
some(get_count) => { responses.send(copy count); }
|
||||
some(bytes(b)) => {
|
||||
//error!{"server: received %? bytes", b};
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ fn thread_ring(i: uint,
|
|||
num_port2 <-> num_port;
|
||||
num_chan = some(ring::client::num(option::unwrap(num_chan2), i * j));
|
||||
let port = option::unwrap(num_port2);
|
||||
alt recv(port) {
|
||||
match recv(port) {
|
||||
ring::num(_n, p) => {
|
||||
//log(error, _n);
|
||||
num_port = some(move_out!{p});
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ fn server(requests: comm::port<request>, responses: comm::chan<uint>) {
|
|||
let mut count = 0u;
|
||||
let mut done = false;
|
||||
while !done {
|
||||
alt comm::recv(requests) {
|
||||
match comm::recv(requests) {
|
||||
get_count => { comm::send(responses, copy count); }
|
||||
bytes(b) => { count += b; }
|
||||
stop => { done = true; }
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ macro_rules! follow {
|
|||
{
|
||||
$($message:path($($x: ident),+) -> $next:ident $e:expr)+
|
||||
} => (
|
||||
|m| alt move m {
|
||||
|m| match move m {
|
||||
$(some($message($($x,)* next)) => {
|
||||
// FIXME (#2329) use regular move here once move out of
|
||||
// enums is supported.
|
||||
|
|
@ -53,7 +53,7 @@ macro_rules! follow {
|
|||
{
|
||||
$($message:path -> $next:ident $e:expr)+
|
||||
} => (
|
||||
|m| alt move m {
|
||||
|m| match move m {
|
||||
$(some($message(next)) => {
|
||||
// FIXME (#2329) use regular move here once move out of
|
||||
// enums is supported.
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import methods = std::arena::arena;
|
|||
enum tree/& { nil, node(&tree, &tree, int), }
|
||||
|
||||
fn item_check(t: &tree) -> int {
|
||||
alt *t {
|
||||
match *t {
|
||||
nil => { return 0; }
|
||||
node(left, right, item) => {
|
||||
return item + item_check(left) - item_check(right);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ enum color { Red, Yellow, Blue }
|
|||
type creature_info = { name: uint, color: color };
|
||||
|
||||
fn show_color(cc: color) -> ~str {
|
||||
alt (cc) {
|
||||
match (cc) {
|
||||
Red => {~"red"}
|
||||
Yellow => {~"yellow"}
|
||||
Blue => {~"blue"}
|
||||
|
|
@ -39,7 +39,7 @@ fn show_color_list(set: ~[color]) -> ~str {
|
|||
}
|
||||
|
||||
fn show_digit(nn: uint) -> ~str {
|
||||
alt (nn) {
|
||||
match (nn) {
|
||||
0 => {~"zero"}
|
||||
1 => {~"one"}
|
||||
2 => {~"two"}
|
||||
|
|
@ -71,7 +71,7 @@ fn show_number(nn: uint) -> ~str {
|
|||
}
|
||||
|
||||
fn transform(aa: color, bb: color) -> color {
|
||||
alt (aa, bb) {
|
||||
match (aa, bb) {
|
||||
(Red, Red ) => { Red }
|
||||
(Red, Yellow) => { Blue }
|
||||
(Red, Blue ) => { Yellow }
|
||||
|
|
@ -101,7 +101,7 @@ fn creature(
|
|||
let resp = comm::recv(from_rendezvous);
|
||||
|
||||
// log and change, or print and quit
|
||||
alt resp {
|
||||
match resp {
|
||||
option::some(other_creature) => {
|
||||
color = transform(color, other_creature.color);
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
|
|||
|
||||
// given a map, search for the frequency of a pattern
|
||||
fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint {
|
||||
alt mm.find(str::bytes(str::to_lower(key))) {
|
||||
match mm.find(str::bytes(str::to_lower(key))) {
|
||||
option::none => { return 0u; }
|
||||
option::some(num) => { return num; }
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint {
|
|||
// given a map, increment the counter for a key
|
||||
fn update_freq(mm: hashmap<~[u8], uint>, key: &[u8]) {
|
||||
let key = vec::slice(key, 0, key.len());
|
||||
alt mm.find(key) {
|
||||
match mm.find(key) {
|
||||
option::none => { mm.insert(key, 1u ); }
|
||||
option::some(val) => { mm.insert(key, 1u + val); }
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ fn make_sequence_processor(sz: uint, from_parent: pipes::port<~[u8]>,
|
|||
});
|
||||
}
|
||||
|
||||
let buffer = alt sz {
|
||||
let buffer = match sz {
|
||||
1u => { sort_and_fmt(freqs, total) }
|
||||
2u => { sort_and_fmt(freqs, total) }
|
||||
3u => { fmt!{"%u\t%s", find(freqs, ~"GGT"), ~"GGT"} }
|
||||
|
|
@ -172,11 +172,11 @@ fn main(args: ~[~str]) {
|
|||
|
||||
if str::len(line) == 0u { again; }
|
||||
|
||||
alt (line[0], proc_mode) {
|
||||
match (line[0], proc_mode) {
|
||||
|
||||
// start processing if this is the one
|
||||
('>' as u8, false) => {
|
||||
alt str::find_str_from(line, ~"THREE", 1u) {
|
||||
match str::find_str_from(line, ~"THREE", 1u) {
|
||||
option::some(_) => { proc_mode = true; }
|
||||
option::none => { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ fn sort_and_fmt(mm: hashmap<~[u8], uint>, total: uint) -> ~str {
|
|||
|
||||
// given a map, search for the frequency of a pattern
|
||||
fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint {
|
||||
alt mm.find(str::bytes(str::to_lower(key))) {
|
||||
match mm.find(str::bytes(str::to_lower(key))) {
|
||||
option::none => { return 0u; }
|
||||
option::some(num) => { return num; }
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ fn find(mm: hashmap<~[u8], uint>, key: ~str) -> uint {
|
|||
// given a map, increment the counter for a key
|
||||
fn update_freq(mm: hashmap<~[u8], uint>, key: &[u8]) {
|
||||
let key = vec::slice(key, 0, key.len());
|
||||
alt mm.find(key) {
|
||||
match mm.find(key) {
|
||||
option::none => { mm.insert(key, 1u ); }
|
||||
option::some(val) => { mm.insert(key, 1u + val); }
|
||||
}
|
||||
|
|
@ -108,7 +108,7 @@ fn make_sequence_processor(sz: uint, from_parent: comm::port<~[u8]>,
|
|||
});
|
||||
}
|
||||
|
||||
let buffer = alt sz {
|
||||
let buffer = match sz {
|
||||
1u => { sort_and_fmt(freqs, total) }
|
||||
2u => { sort_and_fmt(freqs, total) }
|
||||
3u => { fmt!{"%u\t%s", find(freqs, ~"GGT"), ~"GGT"} }
|
||||
|
|
@ -159,11 +159,11 @@ fn main(args: ~[~str]) {
|
|||
|
||||
if str::len(line) == 0u { again; }
|
||||
|
||||
alt (line[0], proc_mode) {
|
||||
match (line[0], proc_mode) {
|
||||
|
||||
// start processing if this is the one
|
||||
('>' as u8, false) => {
|
||||
alt str::find_str_from(line, ~"THREE", 1u) {
|
||||
match str::find_str_from(line, ~"THREE", 1u) {
|
||||
option::some(_) => proc_mode = true,
|
||||
option::none => ()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ fn writer(path: ~str, writech: comm::chan<comm::chan<line>>, size: uint)
|
|||
let p: comm::port<line> = comm::port();
|
||||
let ch = comm::chan(p);
|
||||
comm::send(writech, ch);
|
||||
let cout: io::writer = alt path {
|
||||
let cout: io::writer = match path {
|
||||
~"" => {
|
||||
{dn: 0} as io::writer
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ fn parse_opts(argv: ~[~str]) -> config {
|
|||
|
||||
let opt_args = vec::slice(argv, 1u, vec::len(argv));
|
||||
|
||||
alt getopts::getopts(opt_args, opts) {
|
||||
match getopts::getopts(opt_args, opts) {
|
||||
ok(m) => { return {stress: getopts::opt_present(m, ~"stress")} }
|
||||
err(_) => { fail; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fn start(+token: int) {
|
|||
|
||||
fn roundtrip(id: int, p: comm::port<int>, ch: comm::chan<int>) {
|
||||
while (true) {
|
||||
alt comm::recv(p) {
|
||||
match comm::recv(p) {
|
||||
1 => {
|
||||
io::println(fmt!{"%d\n", id});
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ fn recurse_or_fail(depth: int, st: option<st>) {
|
|||
} else {
|
||||
let depth = depth - 1;
|
||||
|
||||
let st = alt st {
|
||||
let st = match st {
|
||||
none => {
|
||||
st_({
|
||||
box: @nil,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) {
|
|||
}
|
||||
|
||||
for iter::repeat (children) {
|
||||
alt check comm::recv(port) {
|
||||
match check comm::recv(port) {
|
||||
ready(child_ch) => {
|
||||
vec::push(child_chs, child_ch);
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) {
|
|||
|
||||
comm::send(parent_ch, ready(chan));
|
||||
|
||||
alt check comm::recv(port) {
|
||||
match check comm::recv(port) {
|
||||
start => {
|
||||
do vec::iter (child_chs) |child_ch| {
|
||||
comm::send(child_ch, start);
|
||||
|
|
@ -37,7 +37,7 @@ fn calc(children: uint, parent_ch: comm::chan<msg>) {
|
|||
}
|
||||
|
||||
for iter::repeat (children) {
|
||||
alt check comm::recv(port) {
|
||||
match check comm::recv(port) {
|
||||
done(child_sum) => { sum += child_sum; }
|
||||
}
|
||||
}
|
||||
|
|
@ -60,12 +60,12 @@ fn main(args: ~[~str]) {
|
|||
do task::spawn {
|
||||
calc(children, chan);
|
||||
};
|
||||
alt check comm::recv(port) {
|
||||
match check comm::recv(port) {
|
||||
ready(chan) => {
|
||||
comm::send(chan, start);
|
||||
}
|
||||
}
|
||||
let sum = alt check comm::recv(port) {
|
||||
let sum = match check comm::recv(port) {
|
||||
done(sum) => { sum }
|
||||
};
|
||||
error!{"How many tasks? %d tasks.", sum};
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ impl of word_reader for io::reader {
|
|||
}
|
||||
|
||||
fn file_word_reader(filename: ~str) -> word_reader {
|
||||
alt io::file_reader(filename) {
|
||||
match io::file_reader(filename) {
|
||||
result::ok(f) => { f as word_reader }
|
||||
result::err(e) => { fail fmt!{"%?", e} }
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ fn file_word_reader(filename: ~str) -> word_reader {
|
|||
fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) {
|
||||
let f = f();
|
||||
loop {
|
||||
alt f.read_word() {
|
||||
match f.read_word() {
|
||||
some(w) => { emit(w, 1); }
|
||||
none => { break; }
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ fn map(f: fn~() -> word_reader, emit: map_reduce::putter<~str, int>) {
|
|||
fn reduce(&&word: ~str, get: map_reduce::getter<int>) {
|
||||
let mut count = 0;
|
||||
|
||||
loop { alt get() { some(_) => { count += 1; } none => { break; } } }
|
||||
loop { match get() { some(_) => { count += 1; } none => { break; } } }
|
||||
|
||||
io::println(fmt!{"%s\t%?", word, count});
|
||||
}
|
||||
|
|
@ -181,12 +181,12 @@ mod map_reduce {
|
|||
|
||||
do map(input) |key, val| {
|
||||
let mut c = none;
|
||||
alt intermediates.find(key) {
|
||||
match intermediates.find(key) {
|
||||
some(_c) => { c = some(_c); }
|
||||
none => {
|
||||
do ctrl.swap |ctrl| {
|
||||
let ctrl = ctrl_proto::client::find_reducer(ctrl, key);
|
||||
alt pipes::recv(ctrl) {
|
||||
match pipes::recv(ctrl) {
|
||||
ctrl_proto::reducer(c_, ctrl) => {
|
||||
c = some(c_);
|
||||
move_out!{ctrl}
|
||||
|
|
@ -224,7 +224,7 @@ mod map_reduce {
|
|||
&ref_count: int, &is_done: bool)
|
||||
-> option<V> {
|
||||
while !is_done || ref_count > 0 {
|
||||
alt recv(p) {
|
||||
match recv(p) {
|
||||
emit_val(v) => {
|
||||
// error!{"received %d", v};
|
||||
return some(v);
|
||||
|
|
@ -259,7 +259,7 @@ mod map_reduce {
|
|||
|
||||
while num_mappers > 0 {
|
||||
let (_ready, message, ctrls) = pipes::select(ctrl);
|
||||
alt option::unwrap(message) {
|
||||
match option::unwrap(message) {
|
||||
ctrl_proto::mapper_done => {
|
||||
// error!{"received mapper terminated."};
|
||||
num_mappers -= 1;
|
||||
|
|
@ -268,7 +268,7 @@ mod map_reduce {
|
|||
ctrl_proto::find_reducer(k, cc) => {
|
||||
let c;
|
||||
// log(error, "finding reducer for " + k);
|
||||
alt reducers.find(k) {
|
||||
match reducers.find(k) {
|
||||
some(_c) => {
|
||||
// log(error,
|
||||
// "reusing existing reducer for " + k);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue