refactor @ warn and @ debug parsing

This commit is contained in:
ConnorSkees 2020-04-06 00:13:15 -04:00
parent 44ff1c99b3
commit f0c1d508e6

View File

@ -62,21 +62,28 @@ impl AtRule {
return Err(message.to_string().into()); return Err(message.to_string().into());
} }
AtRuleKind::Warn => { AtRuleKind::Warn => {
let message = toks let message = Value::from_vec(
.take_while(|x| x.kind != ';') read_until_semicolon_or_closing_curly_brace(toks),
.map(|x| x.kind.to_string()) scope,
.collect::<String>(); super_selector,
)?;
if toks.peek().unwrap().kind == ';' {
toks.next();
}
devour_whitespace(toks); devour_whitespace(toks);
AtRule::Warn(pos, message) AtRule::Warn(pos, message.to_string())
} }
AtRuleKind::Debug => { AtRuleKind::Debug => {
let message = toks let message = Value::from_vec(
.by_ref() read_until_semicolon_or_closing_curly_brace(toks),
.take_while(|x| x.kind != ';') scope,
.map(|x| x.kind.to_string()) super_selector,
.collect::<String>(); )?;
if toks.peek().unwrap().kind == ';' {
toks.next();
}
devour_whitespace(toks); devour_whitespace(toks);
AtRule::Debug(pos, message) AtRule::Debug(pos, message.to_string())
} }
AtRuleKind::Mixin => { AtRuleKind::Mixin => {
let (name, mixin) = Mixin::decl_from_tokens(toks, scope, super_selector)?; let (name, mixin) = Mixin::decl_from_tokens(toks, scope, super_selector)?;