fix panics related to toplevel hash and quotes
This commit is contained in:
parent
67091115db
commit
b94a2403d0
18
src/lib.rs
18
src/lib.rs
@ -369,11 +369,21 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
|
||||
}));
|
||||
}
|
||||
'#' => {
|
||||
values.push(toks.next().unwrap());
|
||||
if toks.peek().unwrap().kind == '{' {
|
||||
values.push(toks.next().unwrap());
|
||||
let next = toks.next().unwrap();
|
||||
values.push(next);
|
||||
match toks.peek() {
|
||||
Some(Token { kind: '{', .. }) => {
|
||||
let next = toks.next().unwrap();
|
||||
values.push(next);
|
||||
values.extend(read_until_closing_curly_brace(toks));
|
||||
values.push(toks.next().unwrap());
|
||||
if let Some(tok) = toks.next() {
|
||||
values.push(tok);
|
||||
} else {
|
||||
return Err(("expected \"}\".", next.pos).into());
|
||||
}
|
||||
}
|
||||
Some(..) => {}
|
||||
None => return Err(("expected \"{\".", next.pos).into()),
|
||||
}
|
||||
}
|
||||
'\\' => {
|
||||
|
@ -298,7 +298,7 @@ impl<'a> StyleSheetParser<'a> {
|
||||
',' | '!' | '{' => {
|
||||
return Err(("expected \"{\".", self.lexer.next().unwrap().pos()).into());
|
||||
}
|
||||
'`' => {
|
||||
'`' | '\'' | '"' => {
|
||||
return Err(("expected selector.", self.lexer.next().unwrap().pos()).into());
|
||||
}
|
||||
_ => todo!("unexpected toplevel token: {:?}", kind),
|
||||
|
@ -97,10 +97,7 @@ error!(
|
||||
comma_begins_value,
|
||||
"a {color:,red;}", "Error: Expected expression."
|
||||
);
|
||||
error!(
|
||||
nothing_after_hyphen,
|
||||
"a {-}", "Error: Expected \":\"."
|
||||
);
|
||||
error!(nothing_after_hyphen, "a {-}", "Error: Expected \":\".");
|
||||
error!(
|
||||
nothing_after_hyphen_variable,
|
||||
"a {$-", "Error: expected \":\"."
|
||||
@ -109,3 +106,20 @@ error!(
|
||||
closing_brace_after_hyphen_variable,
|
||||
"a {$-}", "Error: Expected identifier."
|
||||
);
|
||||
error!(
|
||||
dbl_quoted_selector,
|
||||
"\"a\" {color: red;}", "Error: expected selector."
|
||||
);
|
||||
error!(
|
||||
sgl_quoted_selector,
|
||||
"'a' {color: red;}", "Error: expected selector."
|
||||
);
|
||||
error!(
|
||||
toplevel_hash_no_closing_curly_brace_has_value,
|
||||
"#{f", "Error: expected \"}\"."
|
||||
);
|
||||
error!(
|
||||
toplevel_hash_no_closing_curly_brace_no_value,
|
||||
"#{", "Error: expected \"}\"."
|
||||
);
|
||||
error!(toplevel_hash, "#", "Error: expected \"{\".");
|
||||
|
Loading…
x
Reference in New Issue
Block a user