rustfmt with nightly options

also some other minor formatting changes
This commit is contained in:
Moritz Gmeiner 2024-09-03 16:48:00 +02:00
commit f8b59e6034
17 changed files with 91 additions and 291 deletions

View file

@ -3,7 +3,7 @@ use smol_str::SmolStr;
use super::{CodePos, LexerError, Token, TokenType};
/*====================================================================================================================*/
// =================================================================================================
static KEYWORDS: phf::Map<&'static str, TokenType> = phf_map! {
"and" => TokenType::And,
@ -25,7 +25,7 @@ static KEYWORDS: phf::Map<&'static str, TokenType> = phf_map! {
"while" => TokenType::While
};
/*====================================================================================================================*/
// =================================================================================================
pub fn scan_tokens(source_code: &str) -> Result<Vec<Token>, Vec<LexerError>> {
let lexer = Lexer::new(source_code);
@ -33,7 +33,7 @@ pub fn scan_tokens(source_code: &str) -> Result<Vec<Token>, Vec<LexerError>> {
lexer.scan_tokens()
}
/*====================================================================================================================*/
// =================================================================================================
#[derive(Debug)]
struct Lexer {
@ -242,18 +242,6 @@ impl Lexer {
}
fn try_parse_string(&mut self) {
// first '"' already consumed
// advance until second "
/* while self.advance() != '"' {
if self.source_is_empty() {
self.errors.push(LexerError::UnterminatedStringLiteral {
code_pos: self.code_pos,
});
return;
}
} */
let mut s = String::new();
let starting_pos = self.code_pos;
@ -356,11 +344,6 @@ impl Lexer {
let lexeme: String = self.source[self.start..self.current].iter().collect();
/* let token_type = KEYWORDS
.get(&lexeme)
.cloned()
.unwrap_or(TokenType::Identifier(Box::new(lexeme))); */
if let Some(token_type) = KEYWORDS.get(&lexeme) {
// Token::new(token_type, self.code_pos)
self.push_token(token_type.clone());