better handle - at the start of idents

This commit is contained in:
ConnorSkees 2020-05-21 12:06:42 -04:00
parent 709b95d035
commit 67091115db
4 changed files with 26 additions and 1 deletions

View File

@ -295,7 +295,7 @@ impl<'a> StyleSheetParser<'a> {
c if c.is_control() => {
return Err(("expected selector.", self.lexer.next().unwrap().pos()).into());
}
',' | '!' => {
',' | '!' | '{' => {
return Err(("expected \"{\".", self.lexer.next().unwrap().pos()).into());
}
'`' => {

View File

@ -166,6 +166,9 @@ pub(crate) fn peek_ident_no_interpolation<I: Iterator<Item = Token>>(
if toks.peek().unwrap().kind == '-' {
toks.peek_forward(1);
text.push('-');
if toks.peek().is_none() {
return Ok(Spanned { node: text, span });
}
if toks.peek().unwrap().kind == '-' {
toks.peek_forward(1);
text.push('-');

View File

@ -179,6 +179,9 @@ pub(crate) fn eat_ident<I: Iterator<Item = Token>>(
if toks.peek().unwrap().kind == '-' {
toks.next();
text.push('-');
if toks.peek().is_none() {
return Ok(Spanned { node: text, span });
}
if toks.peek().unwrap().kind == '-' {
toks.next();
text.push('-');
@ -235,6 +238,9 @@ pub(crate) fn eat_ident_no_interpolation<I: Iterator<Item = Token>>(
if toks.peek().unwrap().kind == '-' {
toks.next();
text.push('-');
if toks.peek().is_none() {
return Ok(Spanned { node: text, span });
}
if toks.peek().unwrap().kind == '-' {
toks.next();
text.push('-');

View File

@ -85,6 +85,10 @@ error!(
error!(toplevel_comma, "a {},", "Error: expected \"{\".");
error!(toplevel_exclamation, "! {}", "Error: expected \"{\".");
error!(toplevel_backtick, "` {}", "Error: expected selector.");
error!(
toplevel_open_curly_brace,
"{ {color: red;}", "Error: expected \"{\"."
);
error!(
backtick_in_value,
"a {color:`red;}", "Error: Expected expression."
@ -93,3 +97,15 @@ error!(
comma_begins_value,
"a {color:,red;}", "Error: Expected expression."
);
error!(
nothing_after_hyphen,
"a {-}", "Error: Expected \":\"."
);
error!(
nothing_after_hyphen_variable,
"a {$-", "Error: expected \":\"."
);
error!(
closing_brace_after_hyphen_variable,
"a {$-}", "Error: Expected identifier."
);