Remove the 'to' keyword

This commit is contained in:
Brian Anderson 2012-09-01 18:38:05 -07:00
parent d777e51333
commit 80c4f74c29
13 changed files with 2418 additions and 2419 deletions

View File

@ -2211,14 +2211,14 @@ fn main() {
~~~~
Multiple match patterns may be joined with the `|` operator. A
range of values may be specified with `to`. For example:
range of values may be specified with `..`. For example:
~~~~
# let x = 2;
let message = match x {
0 | 1 => ~"not many",
2 to 9 => ~"a few",
2 .. 9 => ~"a few",
_ => ~"lots"
};
~~~~

View File

@ -120,9 +120,9 @@ pure fn is_digit(c: char) -> bool {
*/
pure fn to_digit(c: char, radix: uint) -> Option<uint> {
let val = match c {
'0' to '9' => c as uint - ('0' as uint),
'a' to 'z' => c as uint + 10u - ('a' as uint),
'A' to 'Z' => c as uint + 10u - ('A' as uint),
'0' .. '9' => c as uint - ('0' as uint),
'a' .. 'z' => c as uint + 10u - ('a' as uint),
'A' .. 'Z' => c as uint + 10u - ('A' as uint),
_ => return None
};
if val < radix { Some(val) }
@ -171,7 +171,7 @@ fn escape_default(c: char) -> ~str {
'\\' => ~"\\\\",
'\'' => ~"\\'",
'"' => ~"\\\"",
'\x20' to '\x7e' => str::from_char(c),
'\x20' .. '\x7e' => str::from_char(c),
_ => escape_unicode(c)
}
}

View File

@ -263,7 +263,7 @@ fn from_str(num: &str) -> Option<float> {
//The string must start with one of the following characters.
match str::char_at(num, 0u) {
'-' | '+' | '0' to '9' | '.' => (),
'-' | '+' | '0' .. '9' | '.' => (),
_ => return None
}
@ -286,7 +286,7 @@ fn from_str(num: &str) -> Option<float> {
c = char_range.ch;
pos = char_range.next;
match c {
'0' to '9' => {
'0' .. '9' => {
total = total * 10f;
total += ((c as int) - ('0' as int)) as float;
}

File diff suppressed because it is too large Load Diff

View File

@ -267,7 +267,7 @@ impl Parser {
'n' => self.parse_ident(~"ull", Null),
't' => self.parse_ident(~"rue", Boolean(true)),
'f' => self.parse_ident(~"alse", Boolean(false)),
'0' to '9' | '-' => self.parse_number(),
'0' .. '9' | '-' => self.parse_number(),
'"' => match self.parse_str() {
Ok(s) => Ok(String(s)),
Err(e) => Err(e)
@ -330,14 +330,14 @@ impl Parser {
// There can be only one leading '0'.
match self.ch {
'0' to '9' => return self.error(~"invalid number"),
'0' .. '9' => return self.error(~"invalid number"),
_ => ()
}
}
'1' to '9' => {
'1' .. '9' => {
while !self.eof() {
match self.ch {
'0' to '9' => {
'0' .. '9' => {
res *= 10f;
res += ((self.ch as int) - ('0' as int)) as float;
@ -358,7 +358,7 @@ impl Parser {
// Make sure a digit follows the decimal place.
match self.ch {
'0' to '9' => (),
'0' .. '9' => (),
_ => return self.error(~"invalid number")
}
@ -366,7 +366,7 @@ impl Parser {
let mut dec = 1f;
while !self.eof() {
match self.ch {
'0' to '9' => {
'0' .. '9' => {
dec /= 10f;
res += (((self.ch as int) - ('0' as int)) as float) * dec;
@ -394,13 +394,13 @@ impl Parser {
// Make sure a digit follows the exponent place.
match self.ch {
'0' to '9' => (),
'0' .. '9' => (),
_ => return self.error(~"invalid number")
}
while !self.eof() {
match self.ch {
'0' to '9' => {
'0' .. '9' => {
exp *= 10u;
exp += (self.ch as uint) - ('0' as uint);
@ -443,7 +443,7 @@ impl Parser {
let mut n = 0u;
while i < 4u {
match self.next_char() {
'0' to '9' => {
'0' .. '9' => {
n = n * 16u + (self.ch as uint)
- ('0' as uint);
},

View File

@ -50,9 +50,9 @@ fn encode_inner(s: ~str, full_url: bool) -> ~str {
let ch = rdr.read_byte() as char;
match ch {
// unreserved:
'A' to 'Z' |
'a' to 'z' |
'0' to '9' |
'A' .. 'Z' |
'a' .. 'z' |
'0' .. '9' |
'-' | '.' | '_' | '~' => {
str::push_char(out, ch);
}
@ -162,7 +162,7 @@ fn encode_plus(s: ~str) -> ~str {
while !rdr.eof() {
let ch = rdr.read_byte() as char;
match ch {
'A' to 'Z' | 'a' to 'z' | '0' to '9' | '_' | '.' | '-' => {
'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '_' | '.' | '-' => {
str::push_char(out, ch);
}
' ' => str::push_char(out, '+'),
@ -340,8 +340,8 @@ fn query_to_str(query: Query) -> ~str {
fn get_scheme(rawurl: ~str) -> result::Result<(~str, ~str), @~str> {
for str::each_chari(rawurl) |i,c| {
match c {
'A' to 'Z' | 'a' to 'z' => again,
'0' to '9' | '+' | '-' | '.' => {
'A' .. 'Z' | 'a' .. 'z' => again,
'0' .. '9' | '+' | '-' | '.' => {
if i == 0 {
return result::Err(@~"url: Scheme must begin with a letter.");
}
@ -415,13 +415,13 @@ fn get_authority(rawurl: ~str) ->
// deal with input class first
match c {
'0' to '9' => (),
'A' to 'F' | 'a' to 'f' => {
'0' .. '9' => (),
'A' .. 'F' | 'a' .. 'f' => {
if in == Digit {
in = Hex;
}
}
'G' to 'Z' | 'g' to 'z' | '-' | '.' | '_' | '~' | '%' |
'G' .. 'Z' | 'g' .. 'z' | '-' | '.' | '_' | '~' | '%' |
'&' |'\'' | '(' | ')' | '+' | '!' | '*' | ',' | ';' | '=' => {
in = Unreserved;
}
@ -558,7 +558,7 @@ fn get_path(rawurl: ~str, authority : bool) ->
let mut end = len;
for str::each_chari(rawurl) |i,c| {
match c {
'A' to 'Z' | 'a' to 'z' | '0' to '9' | '&' |'\'' | '(' | ')' | '.'
'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '&' |'\'' | '(' | ')' | '.'
| '@' | ':' | '%' | '/' | '+' | '!' | '*' | ',' | ';' | '='
| '_' | '-' => {
again;

View File

@ -215,7 +215,7 @@ fn strptime(s: &str, format: &str) -> Result<Tm, ~str> {
pos = next;
match ch {
'0' to '9' => {
'0' .. '9' => {
value = value * 10_i32 + (ch as i32 - '0' as i32);
}
' ' if ws => (),

View File

@ -1869,7 +1869,7 @@ struct parser {
|| self.is_keyword(~"false")
{
let val = self.parse_expr_res(RESTRICT_NO_BAR_OP);
if self.eat_keyword(~"to") || self.eat(token::DOTDOT) {
if self.eat(token::DOTDOT) {
let end = self.parse_expr_res(RESTRICT_NO_BAR_OP);
pat = pat_range(val, end);
} else {

View File

@ -389,7 +389,6 @@ fn contextual_keyword_table() -> hashmap<~str, ()> {
~"of",
~"priv", ~"pub",
~"self", ~"send", ~"static",
~"to",
~"use",
~"with"
];

View File

@ -547,9 +547,9 @@ fn sanitize(s: ~str) -> ~str {
',' => result += ~"_",
'{' | '(' => result += ~"_of_",
'a' to 'z'
| 'A' to 'Z'
| '0' to '9'
'a' .. 'z'
| 'A' .. 'Z'
| '0' .. '9'
| '_' => str::push_char(result,c),
_ => {
if c > 'z' && char::is_XID_continue(c) {

View File

@ -6,31 +6,31 @@
fn main() {
match 5u {
1u to 10u => { }
5u to 6u => { }
1u .. 10u => { }
5u .. 6u => { }
_ => {}
};
match 5u {
3u to 6u => { }
4u to 6u => { }
3u .. 6u => { }
4u .. 6u => { }
_ => {}
};
match 5u {
4u to 6u => { }
4u to 6u => { }
4u .. 6u => { }
4u .. 6u => { }
_ => {}
};
match 'c' {
'A' to 'z' => {}
'a' to 'z' => {}
'A' .. 'z' => {}
'a' .. 'z' => {}
_ => {}
};
match 1.0 {
0.01 to 6.5 => {}
0.01 .. 6.5 => {}
0.02 => {}
_ => {}
};

View File

@ -4,16 +4,16 @@
fn main() {
match 5u {
6u to 1u => { }
6u .. 1u => { }
_ => { }
};
match "wow" {
"bar" to "foo" => { }
"bar" .. "foo" => { }
};
match 5u {
'c' to 100u => { }
'c' .. 100u => { }
_ => { }
};
}

View File

@ -1,21 +1,21 @@
fn main() {
let x = 2;
let x_message = match x {
0 to 1 => { ~"not many" }
0 .. 1 => { ~"not many" }
_ => { ~"lots" }
};
assert x_message == ~"lots";
let y = 2i;
let y_message = match y {
0 to 1 => { ~"not many" }
0 .. 1 => { ~"not many" }
_ => { ~"lots" }
};
assert y_message == ~"lots";
let z = 1u64;
let z_message = match z {
0 to 1 => { ~"not many" }
0 .. 1 => { ~"not many" }
_ => { ~"lots" }
};
assert z_message == ~"not many";