From ffd50b9cdfa38bc80f2444d917eef5a02c38c32f Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Wed, 22 Feb 2012 13:18:15 +0100 Subject: Make the various from_str functions return options So that they can be used with user input without causing task failures. Closes #1335 --- src/comp/syntax/parse/lexer.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/comp/syntax/parse') diff --git a/src/comp/syntax/parse/lexer.rs b/src/comp/syntax/parse/lexer.rs index aa989cb0f61..113ca056ed4 100644 --- a/src/comp/syntax/parse/lexer.rs +++ b/src/comp/syntax/parse/lexer.rs @@ -174,8 +174,8 @@ fn scan_digits(rdr: reader, radix: uint) -> str { while true { let c = rdr.curr; if c == '_' { rdr.bump(); cont; } - alt char::maybe_digit(c) { - some(d) if (d as uint) < radix { + alt char::to_digit(c, radix) { + some(d) { str::push_char(rslt, c); rdr.bump(); } @@ -229,7 +229,7 @@ fn scan_number(c: char, rdr: reader) -> token::token { if str::len_bytes(num_str) == 0u { rdr.fatal("no valid digits found for number"); } - let parsed = u64::from_str(num_str, base as u64); + let parsed = option::get(u64::from_str(num_str, base as u64)); alt tp { either::left(t) { ret token::LIT_INT(parsed as i64, t); } either::right(t) { ret token::LIT_UINT(parsed, t); } @@ -276,7 +276,7 @@ fn scan_number(c: char, rdr: reader) -> token::token { if str::len_bytes(num_str) == 0u { rdr.fatal("no valid digits found for number"); } - let parsed = u64::from_str(num_str, base as u64); + let parsed = option::get(u64::from_str(num_str, base as u64)); ret token::LIT_INT(parsed as i64, ast::ty_i); } } -- cgit 1.4.1-3-g733a5