parse comma separated lists (somewhat) properly
This commit is contained in:
parent
ef480ad1f8
commit
fb84361fae
@ -92,8 +92,14 @@ impl Value {
|
|||||||
Ok(x) => x,
|
Ok(x) => x,
|
||||||
Err(_) => return Ok(left),
|
Err(_) => return Ok(left),
|
||||||
};
|
};
|
||||||
|
if let Value::List(v, ListSeparator::Comma) = right {
|
||||||
|
let mut v2 = vec![left];
|
||||||
|
v2.extend(v);
|
||||||
|
Ok(Value::List(v2, ListSeparator::Comma))
|
||||||
|
} else {
|
||||||
Ok(Value::List(vec![left, right], ListSeparator::Comma))
|
Ok(Value::List(vec![left, right], ListSeparator::Comma))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
TokenKind::Symbol(Symbol::Plus)
|
TokenKind::Symbol(Symbol::Plus)
|
||||||
| TokenKind::Symbol(Symbol::Minus)
|
| TokenKind::Symbol(Symbol::Minus)
|
||||||
| TokenKind::Op(_)
|
| TokenKind::Op(_)
|
||||||
|
20
tests/list.rs
Normal file
20
tests/list.rs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#![cfg(test)]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod macros;
|
||||||
|
|
||||||
|
test!(
|
||||||
|
length_of_list_as_var,
|
||||||
|
"$a: 1 2 3 4 5;a {\n color: length($a);\n}\n",
|
||||||
|
"a {\n color: 5;\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
length_of_list,
|
||||||
|
"a {\n color: length(1 2 3 4 5);\n}\n",
|
||||||
|
"a {\n color: 5;\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
length_of_comma_list,
|
||||||
|
"a {\n color: length((1, 2, 3, 4, 5));\n}\n",
|
||||||
|
"a {\n color: 5;\n}\n"
|
||||||
|
);
|
@ -463,13 +463,3 @@ test!(
|
|||||||
"a {\n color: (a b) - (1 2);\n}\n",
|
"a {\n color: (a b) - (1 2);\n}\n",
|
||||||
"a {\n color: a b-1 2;\n}\n"
|
"a {\n color: a b-1 2;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
|
||||||
length_of_list_as_var,
|
|
||||||
"$a: 1 2 3 4 5;a {\n color: length($a);\n}\n",
|
|
||||||
"a {\n color: 5;\n}\n"
|
|
||||||
);
|
|
||||||
test!(
|
|
||||||
length_of_list,
|
|
||||||
"a {\n color: length(1 2 3 4 5);\n}\n",
|
|
||||||
"a {\n color: 5;\n}\n"
|
|
||||||
);
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user