more robustly parse empty bracketed lists
This commit is contained in:
parent
28fa06a85f
commit
efc5f91348
@ -1,3 +1,7 @@
|
|||||||
|
# TBD
|
||||||
|
|
||||||
|
- more robustly parse empty bracketed lists
|
||||||
|
|
||||||
# 0.9.2
|
# 0.9.2
|
||||||
|
|
||||||
- implement builtin functions `min` and `max`
|
- implement builtin functions `min` and `max`
|
||||||
|
@ -112,17 +112,6 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
IntermediateValue::Bracketed(t) => {
|
IntermediateValue::Bracketed(t) => {
|
||||||
last_was_whitespace = false;
|
last_was_whitespace = false;
|
||||||
if t.is_empty() {
|
|
||||||
space_separated.push(
|
|
||||||
HigherIntermediateValue::Literal(Value::List(
|
|
||||||
Vec::new(),
|
|
||||||
ListSeparator::Space,
|
|
||||||
Brackets::Bracketed,
|
|
||||||
))
|
|
||||||
.span(val.span),
|
|
||||||
);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
space_separated.push(
|
space_separated.push(
|
||||||
HigherIntermediateValue::Literal(
|
HigherIntermediateValue::Literal(
|
||||||
match iter.parser.parse_value_from_vec(t)?.node {
|
match iter.parser.parse_value_from_vec(t)?.node {
|
||||||
@ -509,6 +498,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
'[' => {
|
'[' => {
|
||||||
let mut span = self.toks.next().unwrap().pos();
|
let mut span = self.toks.next().unwrap().pos();
|
||||||
|
self.whitespace_or_comment();
|
||||||
let mut inner = match read_until_closing_square_brace(self.toks) {
|
let mut inner = match read_until_closing_square_brace(self.toks) {
|
||||||
Ok(v) => v,
|
Ok(v) => v,
|
||||||
Err(e) => return Some(Err(e)),
|
Err(e) => return Some(Err(e)),
|
||||||
@ -519,7 +509,16 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
span = span.merge(last_tok.pos());
|
span = span.merge(last_tok.pos());
|
||||||
}
|
}
|
||||||
IntermediateValue::Bracketed(inner).span(span)
|
if inner.is_empty() {
|
||||||
|
IntermediateValue::Value(HigherIntermediateValue::Literal(Value::List(
|
||||||
|
Vec::new(),
|
||||||
|
ListSeparator::Space,
|
||||||
|
Brackets::Bracketed,
|
||||||
|
)))
|
||||||
|
} else {
|
||||||
|
IntermediateValue::Bracketed(inner)
|
||||||
|
}
|
||||||
|
.span(span)
|
||||||
}
|
}
|
||||||
'$' => {
|
'$' => {
|
||||||
self.toks.next();
|
self.toks.next();
|
||||||
|
@ -314,6 +314,16 @@ test!(
|
|||||||
"a {\n color: 3;\n}\n"
|
"a {\n color: 3;\n}\n"
|
||||||
);
|
);
|
||||||
test!(empty_bracketed_list, "a {\n empty: [];\n}\n");
|
test!(empty_bracketed_list, "a {\n empty: [];\n}\n");
|
||||||
|
test!(
|
||||||
|
empty_bracketed_list_equality,
|
||||||
|
"a {\n color: []==[];\n}\n",
|
||||||
|
"a {\n color: true;\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
empty_bracketed_list_whitespace,
|
||||||
|
"a {\n color: [ /**/ ];\n}\n",
|
||||||
|
"a {\n color: [];\n}\n"
|
||||||
|
);
|
||||||
error!(
|
error!(
|
||||||
invalid_item_in_space_separated_list,
|
invalid_item_in_space_separated_list,
|
||||||
"a {\n color: red color * #abc;\n}\n", "Error: Undefined operation \"color * #abc\"."
|
"a {\n color: red color * #abc;\n}\n", "Error: Undefined operation \"color * #abc\"."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user