restored a parsing grammar api/Browse

This commit is contained in:
aarne
2009-11-20 15:14:41 +00:00
parent 16c7420410
commit 29406fa916
6 changed files with 691 additions and 13 deletions

26
lib/src/api/MkBrowse.hs Normal file
View File

@@ -0,0 +1,26 @@
main = interact mkBrowse
mkBrowse = unlines . map mkJment . zip [1..] . jments
jments = chop ';'
mkJment (i,j) = case words j of
f:":":ws -> toJment f i (break (=="=") ws)
_ -> []
toJment f0 i (ty,de) = let f = f0 ++ "_" ++ show i in unlines $ map unwords [
["fun",f,":",unwords ty,";"],
["lin",f,"=",unwords de,";"]
]
chop c s = case break (==c) s of
(j,_:cs) -> j : chop c cs
(j,_) -> [j]
uncomm = unlines . map unc . lines
unc l = case l of
'-':'-':_ -> []
c : cs -> c : unc cs
_ -> l