From 90f7023896beaf79f2f2bed77b3ba7f28eead8e1 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 23 May 2020 16:36:11 -0400 Subject: [PATCH] handle ( and ) at toplevel --- src/stylesheet.rs | 5 ++++- tests/error.rs | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/stylesheet.rs b/src/stylesheet.rs index dcd58f2..550a19b 100644 --- a/src/stylesheet.rs +++ b/src/stylesheet.rs @@ -334,9 +334,12 @@ 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()); } + '{' => { + return Err(("expected \"}\".", self.lexer.next().unwrap().pos).into()); + } '`' | '\'' | '"' => { return Err(("expected selector.", self.lexer.next().unwrap().pos).into()); } diff --git a/tests/error.rs b/tests/error.rs index e184276..d4ea7a6 100644 --- a/tests/error.rs +++ b/tests/error.rs @@ -87,7 +87,15 @@ error!(toplevel_exclamation, "! {}", "Error: expected \"{\"."); error!(toplevel_backtick, "` {}", "Error: expected selector."); error!( toplevel_open_curly_brace, - "{ {color: red;}", "Error: expected \"{\"." + "{ {color: red;}", "Error: expected \"}\"." +); +error!( + toplevel_open_paren, + "(", "Error: expected \"{\"." +); +error!( + toplevel_close_paren, + "(", "Error: expected \"{\"." ); error!( backtick_in_value,