Filled out keyword tokenizing

This commit is contained in:
greg 2015-07-25 13:55:18 -07:00
parent edf100b583
commit 0e4469fa58

View File

@ -17,7 +17,6 @@ pub enum Kw {
Then,
Else,
While,
Do,
End,
Let,
Fn,
@ -92,9 +91,18 @@ pub fn tokenize(input: &str) -> Vec<Token> {
}
fn handle_identifier(identifier: String) -> Token {
match &identifier[..] {
"let" => Token::Keyword(Kw::Let),
"if" => Token::Keyword(Kw::If),
_ => Token::Identifier(identifier)
}
let keyword = match &identifier[..] {
"let" => Kw::Let,
"if" => Kw::If,
"then" => Kw::Then,
"else" => Kw::Else,
"while" => Kw::While,
"end" => Kw::End,
"fn" => Kw::Fn,
"null" => Kw::Null,
_ => return Token::Identifier(identifier)
};
return Token::Keyword(keyword);
}