summaryrefslogtreecommitdiff
path: root/src/parse/tokens.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-01-04 17:19:49 +0100
committerLaurenz <laurmaedje@gmail.com>2021-01-04 17:23:52 +0100
commit77c06ebc24ab3a43dc2268763ff8f10963f875b4 (patch)
tree344636fbd070f9e62946c22083cb4364958af64e /src/parse/tokens.rs
parent32af3095f810c25d402b8d00917051cc832d63f6 (diff)
None literal 🕳
Diffstat (limited to 'src/parse/tokens.rs')
-rw-r--r--src/parse/tokens.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/parse/tokens.rs b/src/parse/tokens.rs
index ff7f11bd..74ec47e9 100644
--- a/src/parse/tokens.rs
+++ b/src/parse/tokens.rs
@@ -294,6 +294,7 @@ impl<'s> Tokens<'s> {
self.s.eat_while(is_id_continue);
let string = self.s.eaten_from(start);
match string {
+ "none" => Token::None,
"true" => Token::Bool(true),
"false" => Token::Bool(false),
_ => Token::Ident(string),
@@ -377,6 +378,7 @@ mod tests {
use super::*;
use crate::parse::tests::check;
+ use Option::None;
use Token::{
BlockComment as BC, Ident as Id, LeftBrace as LB, LeftBracket as L,
LeftParen as LP, LineComment as LC, RightBrace as RB, RightBracket as R,
@@ -679,7 +681,11 @@ mod tests {
}
#[test]
- fn test_tokenize_bools() {
+ fn test_tokenize_keywords() {
+ // Test none.
+ t!(Header[" /"]: "none" => Token::None);
+ t!(Header[" /"]: "None" => Id("None"));
+
// Test valid bools.
t!(Header[" /"]: "false" => Bool(false));
t!(Header[" /"]: "true" => Bool(true));