clippy lints and moved the operator matchbox to it's own function

This commit is contained in:
2026-05-26 11:54:53 +01:00
parent 4f7abb5f19
commit 59f32e975b
5 changed files with 30 additions and 43 deletions
+8 -15
View File
@@ -47,14 +47,13 @@ pub fn keyword_parse(
{
// TODO can this go in a function?
let mut keyword = "if".to_string();
while keyword == "if".to_string() || keyword == "elif".to_string() || keyword == "else".to_string() // TODO less beefy??
while keyword == "if" || keyword == "elif" || keyword == "else" // TODO less beefy??
{
index += 1;
let mut result: bool = true;
if keyword != "else"
{
let identifier = tokenise::get_identifier_token(tokens, index)
.map(|err| err)?;
let identifier = tokenise::get_identifier_token(tokens, index)?;
(index,result) = match identifier_parse::identifier_parse(index+1, &identifier, tokens, variables)
{
Ok((increment, result)) => (increment,result),
@@ -66,28 +65,22 @@ pub fn keyword_parse(
}
}
if result { index += 1; break; }
else
index = tokenise::get_closing_index(tokens,index)?;
index += 1;
keyword = match tokenise::get_keyword_token(tokens,index)
{
index = tokenise::get_closing_index(tokens, index)
.map(|err| err)?;
index += 1;
keyword = match tokenise::get_keyword_token(tokens,index)
{
Ok(keyword) => keyword,
Err(_) => break,
}
Ok(keyword) => keyword,
Err(_) => break,
}
}
},
"else" =>
{
index += 1;
index = tokenise::get_closing_index(tokens, index)
.map(|err| err)?;
index = tokenise::get_closing_index(tokens, index)?;
},
"elif" =>
{
let current = "elif".to_string();
loop
{
index += 1;