HACK: parse interpolations into values then tokens
This commit is contained in:
parent
c7f34f573f
commit
6faebf5105
12
src/utils.rs
12
src/utils.rs
@ -48,9 +48,6 @@ pub(crate) fn parse_interpolation<I: Iterator<Item = Token>>(
|
||||
while let Some(tok) = tokens.next() {
|
||||
match tok.kind {
|
||||
TokenKind::Symbol(Symbol::CloseCurlyBrace) => break,
|
||||
TokenKind::Symbol(Symbol::SingleQuote) | TokenKind::Symbol(Symbol::DoubleQuote) => {
|
||||
continue
|
||||
}
|
||||
TokenKind::Symbol(Symbol::OpenCurlyBrace) => {
|
||||
todo!("invalid character in interpolation")
|
||||
}
|
||||
@ -61,7 +58,14 @@ pub(crate) fn parse_interpolation<I: Iterator<Item = Token>>(
|
||||
_ => val.push(tok),
|
||||
}
|
||||
}
|
||||
val
|
||||
Lexer::new(
|
||||
&Value::from_tokens(&mut val.into_iter().peekable(), scope)
|
||||
.unwrap()
|
||||
.to_string()
|
||||
.replace("\"", "")
|
||||
.replace("'", ""),
|
||||
)
|
||||
.collect::<Vec<Token>>()
|
||||
}
|
||||
|
||||
pub(crate) struct VariableDecl {
|
||||
|
10
src/value.rs
10
src/value.rs
@ -220,8 +220,11 @@ impl Value {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub fn unquote(&mut self) -> &mut Self {
|
||||
todo!()
|
||||
pub fn unquote(self) -> Self {
|
||||
match self {
|
||||
Self::Ident(s1, _) => Self::Ident(s1, QuoteKind::None),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_tokens<I: Iterator<Item = Token>>(
|
||||
@ -327,6 +330,9 @@ impl Value {
|
||||
);
|
||||
Some(Value::Paren(Box::new(val)))
|
||||
}
|
||||
TokenKind::Symbol(Symbol::BitAnd) => {
|
||||
Some(Value::Ident(String::from("&"), QuoteKind::None))
|
||||
}
|
||||
TokenKind::Ident(mut s) => {
|
||||
while let Some(tok) = toks.peek() {
|
||||
match tok.kind.clone() {
|
||||
|
@ -175,11 +175,16 @@ test!(
|
||||
"a {\n&--b {\n color: red;\n}\n}\n",
|
||||
"a--b {\n color: red;\n}\n"
|
||||
);
|
||||
// test!(
|
||||
// bem_underscore_selector,
|
||||
// "a {\n&__b {\n color: red;\n}\n}\n",
|
||||
// "a__b {\n color: red;\n}\n"
|
||||
// );
|
||||
test!(
|
||||
bem_underscore_selector,
|
||||
"a {\n&__b {\n color: red;\n}\n}\n",
|
||||
"a__b {\n color: red;\n}\n"
|
||||
);
|
||||
test!(
|
||||
selector_interpolation_addition,
|
||||
"#{\"foo\" + \" bar\"}baz {color: red;}",
|
||||
"foo barbaz {\n color: red;\n}\n"
|
||||
);
|
||||
test!(
|
||||
selector_interpolation_start,
|
||||
"#{a}bc {\n color: red;\n}\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user