From eca952b2014dc272abbbb6aca317dd156c4e8114 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 23 May 2020 11:59:04 -0400 Subject: [PATCH] handle toplevel closing curly brace --- src/stylesheet.rs | 7 ++++--- tests/error.rs | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/stylesheet.rs b/src/stylesheet.rs index 78baa47..93bcc10 100644 --- a/src/stylesheet.rs +++ b/src/stylesheet.rs @@ -332,14 +332,15 @@ impl<'a> StyleSheetParser<'a> { .into()) } c if c.is_control() => { - return Err(("expected selector.", self.lexer.next().unwrap().pos()).into()); + 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()); + return Err(("expected selector.", self.lexer.next().unwrap().pos).into()); } + '}' => return Err(("unmatched \"}\".", self.lexer.next().unwrap().pos).into()), _ => todo!("unexpected toplevel token: {:?}", kind), }; } diff --git a/tests/error.rs b/tests/error.rs index db0362d..3e2fe0e 100644 --- a/tests/error.rs +++ b/tests/error.rs @@ -123,6 +123,7 @@ error!( "#{", "Error: expected \"}\"." ); error!(toplevel_hash, "#", "Error: expected \"{\"."); +error!(toplevel_closing_brace, "}", "Error: unmatched \"}\"."); error!(toplevel_at, "@", "Error: Expected identifier."); error!( toplevel_ampersand,