Bump version to 1.2.0.2
[packages/text.git] / scripts / Arsec.hs
1 module Arsec
2 (
3 Comment
4 , comment
5 , semi
6 , showC
7 , unichar
8 , unichars
9 , module Control.Applicative
10 , module Control.Monad
11 , module Data.Char
12 , module Text.ParserCombinators.Parsec.Char
13 , module Text.ParserCombinators.Parsec.Combinator
14 , module Text.ParserCombinators.Parsec.Error
15 , module Text.ParserCombinators.Parsec.Prim
16 ) where
17
18 import Control.Monad
19 import Control.Applicative
20 import Data.Char
21 import Numeric
22 import Text.ParserCombinators.Parsec.Char hiding (lower, upper)
23 import Text.ParserCombinators.Parsec.Combinator hiding (optional)
24 import Text.ParserCombinators.Parsec.Error
25 import Text.ParserCombinators.Parsec.Prim hiding ((<|>), many)
26
27 type Comment = String
28
29 unichar :: Parser Char
30 unichar = chr . fst . head . readHex <$> many1 hexDigit
31
32 unichars :: Parser [Char]
33 unichars = manyTill (unichar <* spaces) semi
34
35 semi :: Parser ()
36 semi = char ';' *> spaces *> pure ()
37
38 comment :: Parser Comment
39 comment = (char '#' *> manyTill anyToken (char '\n')) <|> string "\n"
40
41 showC :: Char -> String
42 showC c = "'\\x" ++ d ++ "'"
43 where h = showHex (ord c) ""
44 d = replicate (4 - length h) '0' ++ h