summaryrefslogtreecommitdiff
path: root/src/tools
diff options
context:
space:
mode:
authoraarne <unknown>2003-12-04 12:08:29 +0000
committeraarne <unknown>2003-12-04 12:08:29 +0000
commit15f94710f0403c760ed4ec1a8328c89400c4d94c (patch)
tree93e1c81f180685a8a2afc4837aea511f48e312ca /src/tools
parent6a9dc9e5f5ddea8130b88a88d1e07f489d0906f9 (diff)
Added French for new API. Started alpha conv. Fixed bugs.
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/AlphaConvGF.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/tools/AlphaConvGF.hs b/src/tools/AlphaConvGF.hs
new file mode 100644
index 000000000..707ad8721
--- /dev/null
+++ b/src/tools/AlphaConvGF.hs
@@ -0,0 +1,30 @@
+module 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