remove unused functions, fix tiny lexing bug

before this change, the parser would parse 14.a() as a method call, but
would parse 14.ø() as the floating-point number 14. followed by a function
call. This is because it was checking is_alpha, rather than ident_start,
and was therefore wrong with respect to unicode.
This commit is contained in:
John Clements 2013-04-17 12:24:49 -07:00
parent 5411cbf656
commit 3c10a9412e

View File

@ -225,20 +225,12 @@ pub fn is_whitespace(c: char) -> bool {
return c == ' ' || c == '\t' || c == '\r' || c == '\n';
}
fn may_begin_ident(c: char) -> bool { return is_alpha(c) || c == '_'; }
fn in_range(c: char, lo: char, hi: char) -> bool {
return lo <= c && c <= hi
}
fn is_alpha(c: char) -> bool {
return in_range(c, 'a', 'z') || in_range(c, 'A', 'Z');
}
fn is_dec_digit(c: char) -> bool { return in_range(c, '0', '9'); }
fn is_alnum(c: char) -> bool { return is_alpha(c) || is_dec_digit(c); }
fn is_hex_digit(c: char) -> bool {
return in_range(c, '0', '9') || in_range(c, 'a', 'f') ||
in_range(c, 'A', 'F');
@ -444,8 +436,7 @@ fn scan_number(c: char, rdr: @mut StringReader) -> token::Token {
}
}
let mut is_float = false;
if rdr.curr == '.' && !(is_alpha(nextch(rdr)) || nextch(rdr) == '_' ||
nextch(rdr) == '.') {
if rdr.curr == '.' && !(ident_start(nextch(rdr)) || nextch(rdr) == '.') {
is_float = true;
bump(rdr);
let dec_part = scan_digits(rdr, 10u);