From d49eb7e18bd333dd2d2c0ff9bab33d61d8617a7a Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sun, 26 Apr 2020 01:37:51 -0400 Subject: [PATCH] explicitly enumerate missing at rule kinds --- src/atrule/kind.rs | 11 ++++++++--- src/atrule/mod.rs | 11 ++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/atrule/kind.rs b/src/atrule/kind.rs index fbd587f..c0af25e 100644 --- a/src/atrule/kind.rs +++ b/src/atrule/kind.rs @@ -12,6 +12,10 @@ pub enum AtRuleKind { Forward, /// Extends the CSS at-rule to load styles, mixins, functions, /// and variables from other stylesheets + /// + /// The definition inside `grass` however differs in that + /// the @import rule refers to a plain css import + /// e.g. `@import url(foo);` Import, Mixin, Content, @@ -31,7 +35,10 @@ pub enum AtRuleKind { /// Prints a message for debugging purposes Debug, If, - Else, + // @else is considered a part of @each, and so is not parsed individually + // TODO: give proper error message for encountering @else? right now + // it is parsed as an unknown at rule + // Else, Each, For, While, @@ -66,7 +73,6 @@ impl From<&str> for AtRuleKind { "warn" => Self::Warn, "debug" => Self::Debug, "if" => Self::If, - "else" => Self::Else, "each" => Self::Each, "for" => Self::For, "while" => Self::While, @@ -95,7 +101,6 @@ impl Display for AtRuleKind { Self::Warn => write!(f, "@warn"), Self::Debug => write!(f, "@debug"), Self::If => write!(f, "@if"), - Self::Else => write!(f, "@else"), Self::Each => write!(f, "@each"), Self::For => write!(f, "@for"), Self::While => write!(f, "@while"), diff --git a/src/atrule/mod.rs b/src/atrule/mod.rs index e7a8547..de84405 100644 --- a/src/atrule/mod.rs +++ b/src/atrule/mod.rs @@ -144,7 +144,6 @@ impl AtRule { span: kind_span, } } - AtRuleKind::Use => todo!("@use not yet implemented"), AtRuleKind::AtRoot => { let mut selector = &Selector::replace( super_selector, @@ -210,18 +209,15 @@ impl AtRule { node: parse_each(toks, scope, super_selector, kind_span)?, span: kind_span, }, - AtRuleKind::Extend => todo!("@extend not yet implemented"), AtRuleKind::If => Spanned { node: AtRule::If(If::from_tokens(toks)?), span: kind_span, }, - AtRuleKind::Else => todo!("@else not yet implemented"), AtRuleKind::For => Spanned { node: for_rule::parse_for(toks, scope, super_selector, kind_span)?, span: kind_span, }, AtRuleKind::While => parse_while(toks, kind_span)?, - AtRuleKind::Keyframes => todo!("@keyframes not yet implemented"), AtRuleKind::Unknown(name) => Spanned { node: AtRule::Unknown(UnknownAtRule::from_tokens( toks, @@ -240,7 +236,12 @@ impl AtRule { node: AtRule::Include(eat_include(toks, scope, super_selector)?), span: kind_span, }, - _ => todo!("encountered unimplemented at rule"), + AtRuleKind::Import => todo!("@import not yet implemented"), + AtRuleKind::Forward => todo!("@forward not yet implemented"), + AtRuleKind::Supports => todo!("@supports not yet implemented"), + AtRuleKind::Keyframes => todo!("@keyframes not yet implemented"), + AtRuleKind::Extend => todo!("@extend not yet implemented"), + AtRuleKind::Use => todo!("@use not yet implemented"), }) } }