Fix π lexing

This commit is contained in:
Kasper 2021-07-06 19:49:52 +02:00
parent 0c1d2b38c1
commit 10f79dc78f

View File

@ -127,7 +127,6 @@ pub fn parse_token(c: &str, lexer: &mut Lexer) -> Result<(), String> {
// right_paren_count += 1; // right_paren_count += 1;
tokens.push(Token::Operator(RightParen)); tokens.push(Token::Operator(RightParen));
}, },
"π" => tokens.push(Token::Constant(Pi)),
"'" => tokens.push(Token::Unit(Foot)), "'" => tokens.push(Token::Unit(Foot)),
"\"" | "" | "" | "" => tokens.push(Token::LexerKeyword(DoubleQuotes)), "\"" | "" | "" | "" => tokens.push(Token::LexerKeyword(DoubleQuotes)),
"Ω" | "" => tokens.push(Token::Unit(Ohm)), "Ω" | "" => tokens.push(Token::Unit(Ohm)),
@ -168,7 +167,7 @@ pub fn parse_word(word: &str, lexer: &mut Lexer) -> Result<(), String> {
"centillion" => Token::NamedNumber(Centillion), "centillion" => Token::NamedNumber(Centillion),
"googol" => Token::NamedNumber(Googol), "googol" => Token::NamedNumber(Googol),
"pi" => Token::Constant(Pi), "π" | "pi" => Token::Constant(Pi),
"e" => Token::Constant(E), "e" => Token::Constant(E),
"plus" => Token::Operator(Plus), "plus" => Token::Operator(Plus),
@ -464,7 +463,6 @@ pub fn parse_word(word: &str, lexer: &mut Lexer) -> Result<(), String> {
"hr" | "hrs" | "hour" | "hours" => Token::Unit(WattHour), "hr" | "hrs" | "hour" | "hours" => Token::Unit(WattHour),
other => { other => {
lexer.tokens.push(Token::Unit(Watt)); lexer.tokens.push(Token::Unit(Watt));
println!("parse_token({})", other);
parse_token(other, lexer)?; parse_token(other, lexer)?;
return Ok(()); return Ok(());
}, },