Lexing of keywords now uses is_ascii_alphabetic instead of is_alphabetic
This commit is contained in:
parent
73861a1848
commit
388825f9ac
@ -41,7 +41,7 @@ pub fn lex(input: &str) -> Result<TokenVector, String> {
|
||||
'\'' => 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<TokenVector, String> {
|
||||
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;
|
||||
|
||||
@ -88,12 +88,13 @@ mod evaluator;
|
||||
mod lookup;
|
||||
|
||||
fn main() {
|
||||
let lex_start = Instant::now();
|
||||
|
||||
use std::env;
|
||||
let args: Vec<String> = 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;
|
||||
|
||||
@ -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)),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user