on format-real-float help sign in
text/scripts/CaseMapping.hs
38 lines 1.4 kB history raw
1import System.Environment
2import System.IO
4import Arsec
5import CaseFolding
6import SpecialCasing
8main = do
9 args <- getArgs
10 let oname = case args of
11 [] -> "../Data/Text/Internal/Fusion/CaseMapping.hs"
12 [o] -> o
13 psc <- parseSC "SpecialCasing.txt"
14 pcf <- parseCF "CaseFolding.txt"
15 scs <- case psc of
16 Left err -> print err >> return undefined
17 Right ms -> return ms
18 cfs <- case pcf of
19 Left err -> print err >> return undefined
20 Right ms -> return ms
21 h <- openFile oname WriteMode
22 let comments = map ("--" ++) $
23 take 2 (cfComments cfs) ++ take 2 (scComments scs)
24 mapM_ (hPutStrLn h) $
25 ["{-# LANGUAGE Rank2Types #-}"
26 ,"-- AUTOMATICALLY GENERATED - DO NOT EDIT"
27 ,"-- Generated by scripts/CaseMapping.hs"] ++
28 comments ++
29 [""
30 ,"module Data.Text.Internal.Fusion.CaseMapping where"
31 ,"import Data.Char"
32 ,"import Data.Text.Internal.Fusion.Types"
33 ,""]
34 mapM_ (hPutStrLn h) (mapSC "upper" upper toUpper scs)
35 mapM_ (hPutStrLn h) (mapSC "lower" lower toLower scs)
36 mapM_ (hPutStrLn h) (mapSC "title" title toTitle scs)
37 mapM_ (hPutStrLn h) (mapCF cfs)
38 hClose h