Slight refactor

This commit is contained in:
vanten-s 2023-09-16 23:44:28 +02:00
parent 33162fda6e
commit 6c6bac142b
Signed by: vanten-s
GPG key ID: DE3060396884D3F2

View file

@ -80,41 +80,24 @@ fn tokenise_current_character(
return Unfinished(Some(Token::Identifier(String::from(current_character))));
}
if current_character == ';' {
return Unfinished(Some(Token::Semi));
}
{
use std::option::Option::Some as s;
use Token as T;
use TokenFinishedUnfinished::Unfinished as uf;
if current_character == '(' {
return Unfinished(Some(Token::OpenParanthesis));
match current_character {
';' => uf(s(T::Semi)),
'(' => uf(s(T::OpenParanthesis)),
')' => uf(s(T::CloseParanthesis)),
'{' => uf(s(T::OpenSquiglyBracket)),
'}' => uf(s(T::CloseSquiglyBracket)),
'=' => uf(s(T::Equals)),
',' => uf(s(T::Comma)),
'+' => uf(s(T::Plus)),
'-' => uf(s(T::Minus)),
_ => uf(None),
}
if current_character == ')' {
return Unfinished(Some(Token::CloseParanthesis));
}
if current_character == '{' {
return Unfinished(Some(Token::OpenSquiglyBracket));
}
if current_character == '}' {
return Unfinished(Some(Token::CloseSquiglyBracket));
}
if current_character == '=' {
return Unfinished(Some(Token::Equals));
}
if current_character == ',' {
return Unfinished(Some(Token::Comma));
}
if current_character == '+' {
return Unfinished(Some(Token::Plus));
}
if current_character == '-' {
return Unfinished(Some(Token::Minus));
}
Unfinished(None)
}
Some(v) => Finished(v),
}