diff --git a/src/lexer.rs b/src/lexer.rs index 11a9e89..51ad6a5 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -41,7 +41,7 @@ pub fn lex(input: &str) -> Result { '\'' => tokens.push(Token::Unit(Foot)), '"' | '“' | '”' | '″' => tokens.push(Token::LexerKeyword(DoubleQuotes)), value if value.is_whitespace() => {}, - value if value.is_alphabetic() => { + value if value.is_ascii_alphabetic() => { let start_index = byte_index; let mut end_index = byte_index; @@ -52,7 +52,7 @@ pub fn lex(input: &str) -> Result { return Err(format!("Invalid string starting with: {}", string)); } - if current_char.is_alphabetic() { + if current_char.is_ascii_alphabetic() { byte_index += current_char.len_utf8(); chars.next(); end_index += 1; diff --git a/src/main.rs b/src/main.rs index 6e65173..2ebb2d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,12 +88,13 @@ mod evaluator; mod lookup; fn main() { - let lex_start = Instant::now(); use std::env; let args: Vec = env::args().collect(); let s = if args.len() >= 2 { &args[1] } else { "0.1" }; + let lex_start = Instant::now(); + match lexer::lex(s) { Ok(tokens) => { let lex_time = Instant::now().duration_since(lex_start).as_nanos() as f32; diff --git a/src/units.rs b/src/units.rs index 1ce9e85..ec287d0 100644 --- a/src/units.rs +++ b/src/units.rs @@ -71,6 +71,7 @@ create_units!( Foot: (Length, d128!(304.8)), Yard: (Length, d128!(914.4)), Mile: (Length, d128!(1609344)), + // 1-dimensional only: NauticalMile: (Length, d128!(1852000)), LightYear: (Length, d128!(9460730472580800000)), LightSecond: (Length, d128!(299792458000)), @@ -84,6 +85,7 @@ create_units!( SquareFoot: (Area, d128!(92903.04)), SquareYard: (Area, d128!(836127.36)), SquareMile: (Area, d128!(2589988110336.00)), + // 2-dimensional only Are: (Area, d128!(100000000)), Decare: (Area, d128!(1000000000)), Hectare: (Area, d128!(10000000000)), @@ -98,6 +100,7 @@ create_units!( CubicFoot: (Volume, d128!(28316846.592)), CubicYard: (Volume, d128!(764554857.984)), CubicMile: (Volume, d128!(4168181825440579584)), + // 3-dimensional only Milliliter: (Volume, d128!(1000)), Centiliter: (Volume, d128!(10000)), Deciliter: (Volume, d128!(100000)),