diff options
| author | aarne <aarne@cs.chalmers.se> | 2006-10-31 16:33:38 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2006-10-31 16:33:38 +0000 |
| commit | daccb10def9fced61db4ccf43589c594ef9d00a2 (patch) | |
| tree | b8b2eabe495f802b4bfe13b7c970c1ed8e862af2 /examples/big/extract2gf.hs | |
| parent | 8b753833b5858977138c9a622d187ddeec85135c (diff) | |
biglex experiment
Diffstat (limited to 'examples/big/extract2gf.hs')
| -rw-r--r-- | examples/big/extract2gf.hs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/examples/big/extract2gf.hs b/examples/big/extract2gf.hs new file mode 100644 index 000000000..6fbc1f5da --- /dev/null +++ b/examples/big/extract2gf.hs @@ -0,0 +1,28 @@ +import System +import Char + +-- usage: extract2gf <lang> <extracted> + +main = do + la:f:_ <- getArgs + let cnc = f ++ ".gf" + let abs = f ++ "Abs.gf" + s <- readFile f + writeFile abs $ "abstract " ++ f ++ "Abs = Cat ** {\n" + writeFile cnc $ "concrete " ++ f ++ " of " ++ f ++ + "Abs = Cat" ++ la ++ " ** open Paradigms" ++ la ++ " in {\n" + mapM_ (mkOne abs cnc . words) $ filter (not . empty) $ lines s + appendFile abs "}" + appendFile cnc "}" + +-- format: cat oper args + +mkOne abs cnc (cat : oper : args@(a1:_)) = do + appendFile abs $ " fun " ++ fun ++ " : " ++ cat ++ " ;\n" + appendFile cnc $ " lin " ++ fun ++ " = " ++ lin ++ " ;\n" + where + fun = a1 ++ "_" ++ cat ++ "_" ++ oper + lin = unwords $ oper:["\"" ++ s ++ "\"" | s <- args] +mkOne _ _ ws = putStrLn $ unwords ws + +empty s = all isSpace s || take 2 s == "--" |
