1
0
forked from GitHub/gf-core

gfse: initial support for grammars in the cloud

This lets the user access the same set of grammars from multiple devices.

Sharing grammars between multiple users is possible but discouraged at the
moment. There is no version handling, so concurrent editing of the same grammar
by different users might result in one user overwriting changes made by
another user. (The same goes for cuncurrent editing on multiple devices by
a single user, of course.)
This commit is contained in:
hallgren
2011-06-08 15:29:50 +00:00
parent a7fede8ee4
commit e4e5ca23d3
6 changed files with 277 additions and 56 deletions

View File

@@ -1,12 +1,17 @@
import Monad(zipWithM_)
import Monad(zipWithM)
import System(getArgs)
main = save =<< getArgs
save [dir] =
do fs@[ns,_] <- readIO =<< getContents
save_all fs
putStrLn $ unwords [n++".gf"|n<-ns]
nes <- save_all fs
putStrLn $ unwords nes
where
save_all [ns,cs] = zipWithM_ write1 ns cs
write1 n = writeFile (dir++"/"++n++".gf")
save_all [ns,cs] = zipWithM write1 ns cs
write1 n c =
do writeFile (dir++"/"++ne) c
return ne
where
ne=if '.' `elem` n then n else n++".gf"