aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/lexer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexer.rs')
-rw-r--r--src/lexer.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/lexer.rs b/src/lexer.rs
index fdab5b4..365b8bf 100644
--- a/src/lexer.rs
+++ b/src/lexer.rs
@@ -9,6 +9,8 @@ pub enum Token {
If,
Then,
Else,
+ For,
+ In,
}
pub struct Lexer<I>
@@ -68,6 +70,8 @@ where
"if" => return Token::If,
"then" => return Token::Then,
"else" => return Token::Else,
+ "for" => return Token::For,
+ "in" => return Token::In,
_ => {}
}
@@ -192,4 +196,11 @@ mod test {
assert_eq!(Token::Then, lex.gettok());
assert_eq!(Token::Else, lex.gettok());
}
+
+ #[test]
+ fn test_for() {
+ let mut lex = Lexer::new("for in".chars());
+ assert_eq!(Token::For, lex.gettok());
+ assert_eq!(Token::In, lex.gettok());
+ }
}