From 8756adaaaf129d6d9273693ad8d36f8d4499e1a6 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Jan 2020 12:34:04 -0500 Subject: [PATCH] Truncate keywords (some of them probably shouldn't be keywords) --- src/common.rs | 80 +++++++++++++++++++++++++-------------------------- tests/main.rs | 3 ++ 2 files changed, 43 insertions(+), 40 deletions(-) diff --git a/src/common.rs b/src/common.rs index 97fab5b..a09875a 100644 --- a/src/common.rs +++ b/src/common.rs @@ -215,38 +215,38 @@ impl Display for Op { #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub enum Keyword { Important, - Infinity, - NaN, - Auto, - Inherit, - Initial, - Unset, True, False, - Not, - And, - Or, Null, - In, + // Infinity, + // NaN, + // Auto, + // Inherit, + // Initial, + // Unset, + // Not, + // And, + // Or, + // In, } impl Display for Keyword { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { Self::Important => write!(f, "!important"), - Self::Infinity => write!(f, "Infinity"), - Self::NaN => write!(f, "NaN"), - Self::Auto => write!(f, "auto"), - Self::Inherit => write!(f, "inherit"), - Self::Initial => write!(f, "initial"), - Self::Unset => write!(f, "unset"), Self::True => write!(f, "true"), Self::False => write!(f, "false"), - Self::Not => write!(f, "not"), - Self::And => write!(f, "and"), - Self::Or => write!(f, "or"), Self::Null => write!(f, "null"), - Self::In => write!(f, "in"), + // Self::Infinity => write!(f, "Infinity"), + // Self::NaN => write!(f, "NaN"), + // Self::Auto => write!(f, "auto"), + // Self::Inherit => write!(f, "inherit"), + // Self::Initial => write!(f, "initial"), + // Self::Unset => write!(f, "unset"), + // Self::Not => write!(f, "not"), + // Self::And => write!(f, "and"), + // Self::Or => write!(f, "or"), + // Self::In => write!(f, "in"), } } } @@ -255,19 +255,19 @@ impl Into<&'static str> for Keyword { fn into(self) -> &'static str { match self { Self::Important => "!important", - Self::Infinity => "Infinity", - Self::NaN => "NaN", - Self::Auto => "auto", - Self::Inherit => "inherit", - Self::Initial => "initial", - Self::Unset => "unset", Self::True => "true", Self::False => "false", - Self::Not => "not", - Self::And => "and", - Self::Or => "or", Self::Null => "null", - Self::In => "in", + // Self::Infinity => "Infinity", + // Self::NaN => "NaN", + // Self::Auto => "auto", + // Self::Inherit => "inherit", + // Self::Initial => "initial", + // Self::Unset => "unset", + // Self::Not => "not", + // Self::And => "and", + // Self::Or => "or", + // Self::In => "in", } } } @@ -279,19 +279,19 @@ impl TryFrom<&str> for Keyword { // todo: case insensitive? match kw { "important" => Ok(Self::Important), - "infinity" => Ok(Self::Infinity), - "nan" => Ok(Self::NaN), - "auto" => Ok(Self::Auto), - "inherit" => Ok(Self::Inherit), - "initial" => Ok(Self::Initial), - "unset" => Ok(Self::Unset), "true" => Ok(Self::True), "false" => Ok(Self::False), - "not" => Ok(Self::Not), - "and" => Ok(Self::And), - "or" => Ok(Self::Or), "null" => Ok(Self::Null), - "in" => Ok(Self::In), + // "infinity" => Ok(Self::Infinity), + // "nan" => Ok(Self::NaN), + // "auto" => Ok(Self::Auto), + // "inherit" => Ok(Self::Inherit), + // "initial" => Ok(Self::Initial), + // "unset" => Ok(Self::Unset), + // "not" => Ok(Self::Not), + // "and" => Ok(Self::And), + // "or" => Ok(Self::Or), + // "in" => Ok(Self::In), _ => Err("invalid keyword"), } } diff --git a/tests/main.rs b/tests/main.rs index c3cfbc1..08aa63e 100644 --- a/tests/main.rs +++ b/tests/main.rs @@ -653,6 +653,9 @@ mod test_values { test!(comma_list_number, "a {\n color: 1, 2, 3;\n}\n"); test!(space_list_number, "a {\n color: 1 2 3;\n}\n"); test!(comma_space_list_number, "a {\n color: 1 1, 2 2, 3 3;\n}\n"); + test!(preserves_keyword_true, "a {\n color: true;\n}\n"); + test!(preserves_keyword_false, "a {\n color: false;\n}\n"); + test!(preserves_keyword_null, "a {\n color: null;\n}\n"); test!( whitespace_space_list_number, "a {\n color: 1 2 3 ;\n}\n",