mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-04 16:52:50 -06:00
GF/src is now for 2.9, and the new sources are in src-3.0 - keep it this way until the release of GF 3
This commit is contained in:
56
src-3.0/GF/Translate/GFT.hs
Normal file
56
src-3.0/GF/Translate/GFT.hs
Normal file
@@ -0,0 +1,56 @@
|
||||
----------------------------------------------------------------------
|
||||
-- |
|
||||
-- Maintainer : AR
|
||||
-- Stability : (stable)
|
||||
-- Portability : (portable)
|
||||
--
|
||||
-- > CVS $Date: 2005/04/21 16:23:43 $
|
||||
-- > CVS $Author: bringert $
|
||||
-- > CVS $Revision: 1.7 $
|
||||
--
|
||||
-- (Description of the module)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
module GF.Translate.GFT (main) where
|
||||
|
||||
import GF.Compile.ShellState
|
||||
import GF.Canon.GetGFC
|
||||
import GF.API
|
||||
|
||||
import GF.Text.Unicode
|
||||
import GF.Text.UTF8
|
||||
import GF.Infra.UseIO
|
||||
import GF.Infra.Option
|
||||
import GF.Infra.Modules (emptyMGrammar) ----
|
||||
import GF.Data.Operations
|
||||
|
||||
import System
|
||||
import Data.List
|
||||
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
file:_ <- getArgs
|
||||
let opts = noOptions
|
||||
can <- useIOE (error "no grammar file") $ getCanonGrammar file
|
||||
st <- err error return $
|
||||
grammar2shellState opts (can, emptyMGrammar)
|
||||
let grs = allStateGrammars st
|
||||
let cat = firstCatOpts opts (firstStateGrammar st)
|
||||
|
||||
---- interact (doTranslate grs cat)
|
||||
s <- getLine
|
||||
putStrLnFlush $ doTranslate grs cat $ drop 2 s -- to remove "n="
|
||||
|
||||
doTranslate grs cat s =
|
||||
let ss = [l +++ ":" +++ s | (l,s) <- zip (map (prIdent . cncId) grs)
|
||||
(translateBetweenAll grs cat s)]
|
||||
in mkHTML ss
|
||||
|
||||
mkHTML = unlines . htmlDoc . intersperse "<p>" . map (encodeUTF8 . mkUnicode) . sort
|
||||
|
||||
htmlDoc ss = "<html>":metaHead:"<body>": ss ++ ["</body>","</html>"]
|
||||
|
||||
metaHead =
|
||||
"<HEAD><META http-equiv=Content-Type content=\"text/html; charset=utf-8\"></HEAD>"
|
||||
|
||||
Reference in New Issue
Block a user