refactor parser return

This commit is contained in:
Ivan Tham 2020-08-01 16:51:07 +08:00 committed by Connor Skees
parent 7fe3abc625
commit 00aeacbc74

View File

@ -330,17 +330,13 @@ impl<'a> Parser<'a> {
} }
// check for named colors // check for named colors
if let Some(c) = NAMED_COLORS.get_by_name(lower.as_str()) { Ok(if let Some(c) = NAMED_COLORS.get_by_name(lower.as_str()) {
return Ok(
IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Color(Box::new( IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Color(Box::new(
Color::new(c[0], c[1], c[2], c[3], s), Color::new(c[0], c[1], c[2], c[3], s),
)))) ))))
.span(span), } else {
);
}
// check for keywords // check for keywords
Ok(match s.as_str() { match s.as_str() {
"true" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::True)), "true" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::True)),
"false" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::False)), "false" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::False)),
"null" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Null)), "null" => IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Null)),
@ -352,6 +348,7 @@ impl<'a> Parser<'a> {
QuoteKind::None, QuoteKind::None,
))), ))),
} }
}
.span(span)) .span(span))
} }