about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorMarijn Haverbeke <marijnh@gmail.com>2012-02-22 13:18:15 +0100
committerMarijn Haverbeke <marijnh@gmail.com>2012-02-22 13:18:15 +0100
commitffd50b9cdfa38bc80f2444d917eef5a02c38c32f (patch)
tree383a83ae49b7690a07d9b546e25b3b43a9adddbe /src/comp/syntax
parent72373438d28eecfa565ad16bd84f800b8c8067c0 (diff)
downloadrust-ffd50b9cdfa38bc80f2444d917eef5a02c38c32f.tar.gz
rust-ffd50b9cdfa38bc80f2444d917eef5a02c38c32f.zip
Make the various from_str functions return options
So that they can be used with user input without causing task
failures.

Closes #1335
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ast_util.rs2
-rw-r--r--src/comp/syntax/parse/lexer.rs8
2 files changed, 5 insertions, 5 deletions
diff --git a/src/comp/syntax/ast_util.rs b/src/comp/syntax/ast_util.rs
index 09242f40c42..b9d48cb5fb0 100644
--- a/src/comp/syntax/ast_util.rs
+++ b/src/comp/syntax/ast_util.rs
@@ -301,7 +301,7 @@ fn lit_to_const(lit: @lit) -> const_val {
       lit_str(s) { const_str(s) }
       lit_int(n, _) { const_int(n) }
       lit_uint(n, _) { const_uint(n) }
-      lit_float(n, _) { const_float(float::from_str(n)) }
+      lit_float(n, _) { const_float(option::get(float::from_str(n))) }
       lit_nil { const_int(0i64) }
       lit_bool(b) { const_int(b as i64) }
     }
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);
     }
 }