GaBuZoMeu/Registry/registry2xml.hs
Stephane Bortzmeyer 2fc541c0a7 Initial import
2023-06-08 21:49:35 +02:00

33 lines
824 B
Haskell

import qualified System.IO
import qualified Text.ParserCombinators.Parsec as Parsec
import Registry.Utils
import Registry.Grammar (registry)
import Registry.Registry
infile = "./language-subtag-registry"
displayAll reg = "<registry>" ++
(foldr (++) "" (map toXML reg)) ++
"</registry>"
displayOne reg thistype thisvalue =
concat (map toXML
(filter (onlyThisValue thistype thisvalue) reg))
foreach [] func = return ()
foreach a func = do
func (head a)
foreach (tail a) func
main = do
f <- System.IO.openFile (infile) System.IO.ReadMode
input <- System.IO.hGetContents f
let theregistry = getRegistry input
let outfile = "language-subtag-registry.xml"
f <- System.IO.openFile (outfile) System.IO.WriteMode
System.IO.hPutStr f (displayAll theregistry)
System.IO.hClose f