Translator.hs

Plain text version of Translator.hs

import PGF

main :: IO ()
main = do pgf <- readPGF "Foods.pgf"
          interact (unlines . map (translate pgf) . lines)

translate :: PGF -> String -> String
translate pgf s =
  case parseAllLang pgf (startCat pgf) s of
     (from,tree:_):_ ->
         unlines [linearize pgf to tree | to <- languages pgf, to/=from]
     _ -> "NO PARSE"