explicitly enumerate missing at rule kinds

This commit is contained in:
ConnorSkees 2020-04-26 01:37:51 -04:00
parent 4a2503b04c
commit d49eb7e18b
2 changed files with 14 additions and 8 deletions

View File

@ -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"),

View File

@ -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"),
})
}
}