allow variables named to
and through
in @for
This commit is contained in:
parent
e9f2cdbe4d
commit
125c85a69c
@ -631,17 +631,29 @@ impl<'a> Parser<'a> {
|
|||||||
match ident.node.to_ascii_lowercase().as_str() {
|
match ident.node.to_ascii_lowercase().as_str() {
|
||||||
"through" => {
|
"through" => {
|
||||||
through = 1;
|
through = 1;
|
||||||
// todo: it should take more if there were escapes
|
self.toks.truncate_iterator_to_cursor();
|
||||||
self.toks.take(7).for_each(drop);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
"to" => {
|
"to" => {
|
||||||
// todo: it should take more if there were escapes
|
self.toks.truncate_iterator_to_cursor();
|
||||||
self.toks.take(2).for_each(drop);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(("Invalid flag name.", ident.span).into());
|
from_toks.push(tok);
|
||||||
|
self.toks.next();
|
||||||
|
self.toks.reset_cursor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'$' => {
|
||||||
|
from_toks.push(tok);
|
||||||
|
self.toks.next();
|
||||||
|
while let Some(tok) = self.toks.peek() {
|
||||||
|
if matches!(tok.kind, '0'..='9' | 'a'..='z' | 'A'..='Z' | '\\' | '-' | '_')
|
||||||
|
{
|
||||||
|
from_toks.push(self.toks.next().unwrap());
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
tests/for.rs
11
tests/for.rs
@ -68,3 +68,14 @@ test!(
|
|||||||
"@for $i from -1 to -3 {\n a {\n color: red;\n }\n}\n",
|
"@for $i from -1 to -3 {\n a {\n color: red;\n }\n}\n",
|
||||||
"a {\n color: red;\n}\n\na {\n color: red;\n}\n"
|
"a {\n color: red;\n}\n\na {\n color: red;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
variable_named_to_as_value,
|
||||||
|
"$to: 0;
|
||||||
|
|
||||||
|
@for $i from $to to 1 {
|
||||||
|
a {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
}",
|
||||||
|
"a {\n color: red;\n}\n"
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user