From 11b4704d996b032996d776e341bb9ae309c107aa Mon Sep 17 00:00:00 2001 From: ElBe-Plaq <90863907+ElBe-Plaq@users.noreply.github.com> Date: Thu, 21 Mar 2024 07:57:53 +0100 Subject: [PATCH] del(language): Removed `default` keyword Tracking issue: #119 --- crates/lexer/src/tokens/keyword.rs | 10 +--------- crates/lexer/tests/tokens/keyword.rs | 2 -- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/crates/lexer/src/tokens/keyword.rs b/crates/lexer/src/tokens/keyword.rs index dc39601..dce1c5a 100644 --- a/crates/lexer/src/tokens/keyword.rs +++ b/crates/lexer/src/tokens/keyword.rs @@ -52,8 +52,6 @@ pub enum Keyword { Const, /// The `continue` keyword. Used to continue a loop before all of it's code is executed. Continue, - /// The `default` keyword. Used in combination with the [`match`](`Keyword::Match`) and [`case`](`Keyword::Case`) keywords to match the default case. - Default, /// The `else` keyword. Used to define the "otherwise" block of an [`if`](`Keyword::If`) statement. Else, /// The `finally` keyword. Used in combination with the [`try`](`Keyword::Try`) keyword to execute code even after an exception has been raised. @@ -66,7 +64,7 @@ pub enum Keyword { If, /// The `import` keyword. Used to import code from other modules. Import, - /// The `match` keyword. Used in combination with the [`case`](`Keyword::Case`) and [`default`](`Keyword::Default`) keywords. + /// The `match` keyword. Used in combination with the [`case`](`Keyword::Case`) keyword. Match, /// The `pub` keyword. Used to export an item out of the current scope. Pub, @@ -96,7 +94,6 @@ impl core::fmt::Display for Keyword { &Self::Class => write!(formatter, "class"), &Self::Const => write!(formatter, "const"), &Self::Continue => write!(formatter, "continue"), - &Self::Default => write!(formatter, "default"), &Self::Else => write!(formatter, "else"), &Self::Finally => write!(formatter, "finally"), &Self::For => write!(formatter, "for"), @@ -157,11 +154,6 @@ impl GetToken for Keyword { content: "continue".to_owned(), token_type: TokenType::Keyword(Keyword::Continue), }), - "default" => Some(Token { - location, - content: "default".to_owned(), - token_type: TokenType::Keyword(Keyword::Default), - }), "else" => Some(Token { location, content: "else".to_owned(), diff --git a/crates/lexer/tests/tokens/keyword.rs b/crates/lexer/tests/tokens/keyword.rs index 2db1437..dbb9fb2 100644 --- a/crates/lexer/tests/tokens/keyword.rs +++ b/crates/lexer/tests/tokens/keyword.rs @@ -48,7 +48,6 @@ mod tests { assert_eq!(&format!("{}", Keyword::Class), "class"); assert_eq!(&format!("{}", Keyword::Const), "const"); assert_eq!(&format!("{}", Keyword::Continue), "continue"); - assert_eq!(&format!("{}", Keyword::Default), "default"); assert_eq!(&format!("{}", Keyword::Else), "else"); assert_eq!(&format!("{}", Keyword::Finally), "finally"); assert_eq!(&format!("{}", Keyword::For), "for"); @@ -81,7 +80,6 @@ mod tests { assert!(generate_test(&location, "class", Keyword::Class)); assert!(generate_test(&location, "const", Keyword::Const)); assert!(generate_test(&location, "continue", Keyword::Continue)); - assert!(generate_test(&location, "default", Keyword::Default)); assert!(generate_test(&location, "else", Keyword::Else)); assert!(generate_test(&location, "finally", Keyword::Finally)); assert!(generate_test(&location, "for", Keyword::For));