diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-05-21 09:26:44 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-05-21 09:26:44 +0000 |
| commit | 055c0d0d5a5bb0dc75904fe53df7f2e4f5732a8f (patch) | |
| tree | 0e63fb68c69c8f6ad0f78893c63420f0a3600e1c /src-3.0/tools/AlphaConvGF.hs | |
| parent | 915a1de71783ab8446b1af9e72c7ba7dfbc12d3f (diff) | |
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
Diffstat (limited to 'src-3.0/tools/AlphaConvGF.hs')
| -rw-r--r-- | src-3.0/tools/AlphaConvGF.hs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src-3.0/tools/AlphaConvGF.hs b/src-3.0/tools/AlphaConvGF.hs new file mode 100644 index 000000000..0e87bdb7a --- /dev/null +++ b/src-3.0/tools/AlphaConvGF.hs @@ -0,0 +1,43 @@ +---------------------------------------------------------------------- +-- | +-- Maintainer : AR +-- Stability : (stable) +-- Portability : (portable) +-- +-- > CVS $Date: 2005/04/16 05:40:50 $ +-- > CVS $Author: peb $ +-- > CVS $Revision: 1.4 $ +-- +-- (Description of the module) +----------------------------------------------------------------------------- + +module Main (main) where + +import LexGF +import Alex +import System + +main :: IO () +main = do + file1:file2:_ <- getArgs + s <- readFile file1 + ts <- tokens s + if file1==file2 then print (length ts) else return () -- make sure file1 is in mem + writeFile file2 [] -- create file2 or remove its old contents + alphaConv file2 ts (Pn 1 1 1) + +alphaConv :: FilePath -> [Token] -> Posn -> IO () +alphaConv file (t:ts) p0 = case t of + PT p (TV s) -> changeId file p0 p s ts + _ -> putToken file p0 t >>= alphaConv file ts +alphaConv _ _ = putStrLn "Ready." + +putToken :: FilePath -> Posn -> Token -> IO Posn +putToken file (Pn _ l0 c0) t@(PT (Pn a l c) _) = do + let s = prToken t + ns = l - l0 + ls = length s + replicate ns $ appendFile file '\n' + replicate (if ns == 0 then c - c0 else c-1) $ putChar ' ' + putStr s + return $ Pn (a + ls) l (c + ls) ts |
