M src/Data/CSS/Syntax/StyleSheet.hs => src/Data/CSS/Syntax/StyleSheet.hs +2 -1
@@ 52,7 52,8 @@ parse' stylesheet tokens = parse' (addRules stylesheet rule) tokens'
--------
parseProperties (LeftCurlyBracket:tokens) = parseProperties' tokens
parseProperties (Whitespace:tokens) = parseProperties tokens
-parseProperties (_:tokens) = ([], tokens)
+-- This error recovery is a bit overly conservative, but it's simple.
+parseProperties (_:tokens) = ([], skipAtRule tokens)
parseProperties [] = ([], [])
parseProperties' (Whitespace:tokens) = parseProperties' tokens
D src/Stylish.hs => src/Stylish.hs +0 -8
@@ 1,8 0,0 @@
-module Stylish(
- parse,
- StyleSheet, addRule, addAtRule,
- StyleRule,
- Selector, Combinator, SimpleSelector, AttrTest
- ) where
-
-import Stylish.Parse
M test/Test.hs => test/Test.hs +7 -0
@@ 270,6 270,13 @@ spec = do
let rules = parse queryable "a {color: red;}"
let TrivialPropertyParser style = cascade rules el [("color", [Ident "green"])] temp::TrivialPropertyParser
style ! "color" `shouldBe` [Ident "green"]
+ describe "Parser freezes" $ do
+ it "does not regress" $ do
+ -- TODO handle psuedoelements
+ parse emptyStyle "output::before {content: 'Output'; pitch: high}"
+ `shouldBe` TrivialStyleSheet [
+ StyleRule (Element [Tag "output"]) []
+ ]
styleIndex :: StyleIndex
styleIndex = new