Enable splitting emitted tokens by new lines
This commit is contained in:
12
app/Util.hs
12
app/Util.hs
@@ -4,7 +4,8 @@ module Util (
|
||||
bytesStr,
|
||||
head,
|
||||
unescape,
|
||||
controlChar
|
||||
controlChar,
|
||||
explode
|
||||
) where
|
||||
|
||||
import Prelude hiding (head)
|
||||
@@ -57,4 +58,11 @@ controlChar x = case x of
|
||||
'"' -> Just 34
|
||||
'\'' -> Just 39
|
||||
'0' -> Just 0
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
|
||||
explode :: (Foldable f) => (a -> Bool) -> f a -> [[a]]
|
||||
explode pred xs = filter (not . null) $ foldr split [[]] xs
|
||||
where
|
||||
split y (ys:yss)
|
||||
| pred y = []:ys:yss
|
||||
| otherwise = (y:ys):yss
|
||||
Reference in New Issue
Block a user