Skip to content

Commit f08a4cf

Browse files
committed
use tokens for css descriptors to avoid ambiguity
between list of selectors and enumerating descriptor (multiple values split by commas)
1 parent c366d0c commit f08a4cf

16 files changed

Lines changed: 2034 additions & 628 deletions

File tree

css-parser.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ library
4444
, CssParser.At.MediaQuery
4545
, CssParser.At.Page
4646
, CssParser.At.Supports
47+
, CssParser.Descriptor
4748
, CssParser.File
4849
, CssParser.FixRule
4950
, CssParser.Fun
@@ -62,6 +63,7 @@ library
6263
, CssParser.Utils
6364
other-modules:
6465
, CssParser.Lexer
66+
, CssParser.Lexer.Token
6567
, CssParser.Parser
6668
build-depends:
6769
, array >=0.5.2

src/CssParser/At/FontFeatureValues.hs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@ newtype IdentList = IdentList (NonEmpty Ident) deriving newtype (Eq, Ord, Show)
1010
instance CssShow IdentList where
1111
toCssText (IdentList l) = unwords (toCssText <$> toList l)
1212

13+
data FontFeatureEntry = FontFeatureEntry Ident (SslNe Unsigned)
14+
deriving (Eq, Ord, Show, Generic)
15+
instance CssShow FontFeatureEntry where
16+
toCssText (FontFeatureEntry i l)
17+
= toCssText i <> ": " <> toCssText l
18+
instance ShowSpaceBetween FontFeatureEntry FontFeatureEntry where
19+
cssSpace _ _ = ";"
1320
data FontFeatureValuesSubBlock
14-
= FontFeatureValuesSubBlock BrowserPrefix Ident [PropEntry]
21+
= FontFeatureValuesSubBlock BrowserPrefix Ident [FontFeatureEntry]
1522
deriving (Eq, Ord, Show, Generic)
1623

1724
instance CssShow FontFeatureValuesSubBlock where
1825
toCssText (FontFeatureValuesSubBlock bp i ps) =
19-
toCssText bp <> toCssText i <> " {" <> toCssText ps <> "}"
26+
"@" <> toCssText bp <> toCssText i <> " {" <> toCssText ps <> "}"
2027

2128
instance ShowSpaceBetween FontFeatureValuesSubBlock FontFeatureValuesSubBlock where
2229
cssSpace _ _ = ""

src/CssParser/At/Function.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ data Function r
9595
, args :: [FunArg]
9696
, returns :: Maybe CssType
9797
, localConsts :: [ ConstEntry ]
98-
, result :: PropVals
98+
, result :: NonEmpty PropVals
9999
, atRules :: [r]
100100
} deriving (Eq, Ord, Show, Generic)
101101

src/CssParser/At/Keyframe.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module CssParser.At.Keyframe where
22

3-
import CssParser.Ident
3+
import CssParser.Descriptor (Descriptor)
4+
import CssParser.Ident ( Ident(..) )
45
import CssParser.Rule.Value
56
import CssParser.Prelude
6-
import CssParser.Show
7+
import CssParser.Show ( CssShow(..), ShowSpaceBetween(..), CslNe )
78

89
data KeyframeAdr
910
= KeyframePercentAdr RawNum
@@ -17,12 +18,12 @@ instance CssShow KeyframeAdr where
1718
KeyframeStart -> "from"
1819
KeyframeEnd -> "to"
1920

20-
data PropEntry = PropEntry PropertyName PropVals deriving (Show, Eq, Ord, Generic)
21+
data PropEntry = PropEntry Descriptor PropVals deriving (Show, Eq, Ord, Generic)
2122
instance ShowSpaceBetween PropEntry PropEntry where
2223
cssSpace _ _ = ""
2324
instance CssShow PropEntry where
2425
toCssText (PropEntry pn pv) =
25-
toCssText pn <> ": " <> toCssText pv <> ";"
26+
toCssText pn <> toCssText pv <> ";"
2627

2728
data Keyframe = Keyframe (CslNe KeyframeAdr) [PropEntry] deriving (Show, Eq, Ord, Generic)
2829

0 commit comments

Comments
 (0)