diff options
| author | aarne <aarne@chalmers.se> | 2010-04-10 08:18:03 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2010-04-10 08:18:03 +0000 |
| commit | 50a2e2ea93e7280ae6063a1cbf0e8cb29fa78a09 (patch) | |
| tree | 201d3812073143a0aa30684f9fcb0fe2a30940b5 /examples/phrasebook/Clone.hs | |
| parent | d505fa5b6737b6b78fb65161cea3c2ac175494ab (diff) | |
regenerated clones with complete abstract and ready-maked Lexicon-based words in Phrasebook
Diffstat (limited to 'examples/phrasebook/Clone.hs')
| -rw-r--r-- | examples/phrasebook/Clone.hs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/examples/phrasebook/Clone.hs b/examples/phrasebook/Clone.hs index 7e146731d..4619c13ed 100644 --- a/examples/phrasebook/Clone.hs +++ b/examples/phrasebook/Clone.hs @@ -2,6 +2,7 @@ module Main where import Control.Monad import Data.Maybe +import Data.Char import System.Cmd import System.Directory import System.Environment @@ -10,17 +11,21 @@ import System.Exit -- To clone a project from one language to another: -- --- 1. for each Module in modules, copy ModuleFROM to ModuleTO +-- 1. for each Module in 'modules', copy ModuleFROM to ModuleTO -- 2. in each ModuleTO, replace substrings FROM by TO, if not prefixes of an Ident --- 3. in each ModuleTO in specifics, comment out every line in the body +-- 3. in each ModuleTO in 'specifics', comment out every line in the body, except +-- those whose first word is in 'commons'. -- -- Syntax: runghc Clone FROM TO -- Example: runhugs Clone Swe Nor --- The following lines are for the phrasebook project, but can be modified to other projects. +-- The following lines are for the phrasebook project, and can be changed +-- to fit other projects. modules = "Phrasebook":"Sentences":specifics specifics = ["Words","Greetings"] +commons = ["Apple","Beer","Bread","Fish","Milk","Salt","Water","Wine", + "Bad","Cold","Good","Warm","AHasChildren"] main = do @@ -42,7 +47,9 @@ replaceLang s1 s2 = repl where lgs = 3 -- length s1 -- the file name has the form p....pLLL.gf, i.e. 3-letter lang name, suffix .gf -getLangName fi = let (nal,ferp) = splitAt 3 (drop 3 (reverse fi)) in (reverse ferp,reverse nal) +getLangName fi = + let (nal,ferp) = splitAt 3 (drop 3 (reverse fi)) in + (reverse ferp,reverse nal) commentIf c = if c then (unlines . commentBody . lines) else id @@ -51,4 +58,8 @@ commentBody ss = header ++ map comment body ++ ["}"] where isJment ws = case ws of k:_ | elem k ["flags","lin","lincat","oper","param"] -> True _ -> False - comment l = if take 2 l == "--" then l else "-- " ++ l + comment l = case l of + _ | take 2 l == "--" -> l -- already commented + _ | all isSpace l -> l -- empty line + _ | elem (head (words l)) commons -> l -- in 'commons' + _ -> "--" ++ l |
