refactor how to value in @for is parsed

This commit is contained in:
Connor Skees 2020-07-08 09:25:35 -04:00
parent b42ae61435
commit 978984ae15
2 changed files with 17 additions and 3 deletions

View File

@ -720,9 +720,7 @@ impl<'a> Parser<'a> {
}
};
let to_toks = read_until_open_curly_brace(self.toks)?;
self.toks.next();
let to_val = self.parse_value_from_vec(to_toks)?;
let to_val = self.parse_value()?;
let to = match to_val.node {
Value::Dimension(n, _) => match n.to_integer().to_isize() {
Some(v) => v,
@ -736,6 +734,13 @@ impl<'a> Parser<'a> {
.into())
}
};
// consume the open curly brace
match self.toks.next() {
Some(Token { kind: '{', pos }) => pos,
Some(..) | None => return Err(("expected \"{\".", to_val.span).into()),
};
let body = read_until_closing_curly_brace(self.toks)?;
self.toks.next();

View File

@ -79,3 +79,12 @@ test!(
}",
"a {\n color: red;\n}\n"
);
test!(
to_crazy_interpolation,
"a {
@for $i from 0 to length(#{\"#{\"\\\\}}}{{{\"}#\"}) {
color: #{\"#{\"\\\\}}}{{{\"}#\"};
}
}",
"a {\n color: \\}}}{{{#;\n}\n"
);