forked from bortzmeyer/GaBuZoMeu
27 lines
886 B
Haskell
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
|