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

27 lines
886 B
Haskell

import qualified IO
import Text.ParserCombinators.Parsec as Parsec
import qualified Data.List as List
import Grammar
import Registry.Grammar
import Registry.Types
infile = "./language-subtag-registry"
onlyIrregularGF (GF r) = isLeft (Grammar.getTag (gf'tag r))
onlyIrregularGF _ = False
displayTag (GF r) = "\"" ++ (gf'tag r) ++ "\" / "
run parser input
= case (Parsec.parse parser "" input) of
Left err -> error ("Registry \"" ++ infile ++ "\" is not legal: " ++ (show err) ++ "\n")
Right x -> IO.putStr ("-- AUTOMATICALLY GENERATED! Do *not* edit!!! \n" ++
(foldr (++) "" (List.intersperse "\n" (map displayTag (filter onlyIrregularGF (map fromRight x))))) ++
"\n")
main = do
f <- IO.openFile (infile) IO.ReadMode
input <- IO.hGetContents f
run registry input