Slight refactor
This commit is contained in:
parent
33162fda6e
commit
6c6bac142b
|
@ -80,41 +80,24 @@ fn tokenise_current_character(
|
||||||
return Unfinished(Some(Token::Identifier(String::from(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 == '(' {
|
match current_character {
|
||||||
return Unfinished(Some(Token::OpenParanthesis));
|
';' => 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),
|
Some(v) => Finished(v),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue