diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index 14586e4..8788682 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -104,6 +104,8 @@ pub enum TokenKind { StarEqual, /// "/=" SlashEqual, + /// "=>" + ArrowRight, /// "(" BraceOpen, /// ")" @@ -145,6 +147,8 @@ pub enum Keyword { Boolean, Struct, New, + Match, + Default, Unknown, } @@ -244,6 +248,10 @@ impl Cursor<'_> { self.bump(); Equals } + '>' => { + self.bump(); + ArrowRight + } _ => Assign, }, ':' => Colon, @@ -368,6 +376,8 @@ impl Cursor<'_> { c if c == "continue" => Keyword::Continue, c if c == "struct" => Keyword::Struct, c if c == "new" => Keyword::New, + c if c == "match" => Keyword::Match, + c if c == "default" => Keyword::Default, _ => Keyword::Unknown, } } diff --git a/tests/match_statements.sb b/tests/match_statements.sb new file mode 100644 index 0000000..1bcb7e4 --- /dev/null +++ b/tests/match_statements.sb @@ -0,0 +1,12 @@ +fn test_basic_match() { + let x = true + + match x { + true => assert(true) + false => assert(false) + } +} + +fn main() { + test_basic_match() +}