allow != in variables
This commit is contained in:
parent
bf0665bbcd
commit
1ef93c082b
@ -155,19 +155,25 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
'!' => {
|
'!' => {
|
||||||
let pos = tok.pos();
|
let pos = tok.pos();
|
||||||
if self.toks.peek_forward(1).is_none() {
|
match self.toks.peek_forward(1) {
|
||||||
return Err(("Expected identifier.", pos).into());
|
Some(Token { kind: '=', .. }) => {
|
||||||
|
self.toks.reset_cursor();
|
||||||
|
val_toks.push(self.toks.next().unwrap());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Some(..) => {}
|
||||||
|
None => return Err(("Expected identifier.", pos).into()),
|
||||||
}
|
}
|
||||||
// todo: it should not be possible to declare the same flag more than once
|
// todo: it should not be possible to declare the same flag more than once
|
||||||
let mut ident = peek_ident_no_interpolation(self.toks, false, pos)?;
|
let mut ident = peek_ident_no_interpolation(self.toks, false, pos)?;
|
||||||
ident.node.make_ascii_lowercase();
|
ident.node.make_ascii_lowercase();
|
||||||
match ident.node.as_str() {
|
match ident.node.as_str() {
|
||||||
"global" => {
|
"global" => {
|
||||||
self.toks.take(7).for_each(drop);
|
self.toks.truncate_iterator_to_cursor();
|
||||||
global = true;
|
global = true;
|
||||||
}
|
}
|
||||||
"default" => {
|
"default" => {
|
||||||
self.toks.take(8).for_each(drop);
|
self.toks.truncate_iterator_to_cursor();
|
||||||
default = true;
|
default = true;
|
||||||
}
|
}
|
||||||
"important" => {
|
"important" => {
|
||||||
|
@ -133,6 +133,11 @@ test!(
|
|||||||
"$a: red;\n\na {\n $a: green !\\67 lobal;\n}\n\na {\n color: $a;\n}\n",
|
"$a: red;\n\na {\n $a: green !\\67 lobal;\n}\n\na {\n color: $a;\n}\n",
|
||||||
"a {\n color: green;\n}\n"
|
"a {\n color: green;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
not_equal_in_variable_decl,
|
||||||
|
"$a: red != blue;\n\na {\n color: $a;\n}\n",
|
||||||
|
"a {\n color: true;\n}\n"
|
||||||
|
);
|
||||||
error!(ends_with_bang, "$a: red !;", "Error: Expected identifier.");
|
error!(ends_with_bang, "$a: red !;", "Error: Expected identifier.");
|
||||||
error!(unknown_flag, "$a: red !foo;", "Error: Invalid flag name.");
|
error!(unknown_flag, "$a: red !foo;", "Error: Invalid flag name.");
|
||||||
error!(
|
error!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user