aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbcode/src/Text/BBCode/Lexer.hs20
1 files changed, 1 insertions, 19 deletions
diff --git a/bbcode/src/Text/BBCode/Lexer.hs b/bbcode/src/Text/BBCode/Lexer.hs
index 8060ed0..01f47f0 100644
--- a/bbcode/src/Text/BBCode/Lexer.hs
+++ b/bbcode/src/Text/BBCode/Lexer.hs
@@ -25,25 +25,7 @@ import GHC.Generics (Generic)
25data BBToken = BBOpen Text -- ^ Tag open 25data BBToken = BBOpen Text -- ^ Tag open
26 | BBClose Text -- ^ Tag close 26 | BBClose Text -- ^ Tag close
27 | BBStr Text -- ^ Content of a tag 27 | BBStr Text -- ^ Content of a tag
28 deriving (Generic, Eq, Show, CoArbitrary) 28 deriving (Generic, Eq, Show)
29
30-- | This instance does not produce:
31--
32-- * opening and closing tags whose 'Text' ends in @\\@
33-- * empty 'BBStr's
34instance Arbitrary BBToken where
35 shrink = genericShrink
36 arbitrary = oneof [ BBOpen <$> tagText
37 , BBClose <$> tagText
38 , BBStr <$> nonEmpty
39 ]
40 where
41 tagText = arbitrary `suchThat` (not . lastIsEscape)
42 lastIsEscape t
43 | T.null t = False
44 | T.last t == '\\' = True
45 | otherwise = False
46 nonEmpty = (arbitrary `suchThat` (not . T.null))
47 29
48token :: Parser BBToken 30token :: Parser BBToken
49-- ^ Tokenizer 31-- ^ Tokenizer