mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-02 07:42:50 -06:00
restored a parsing grammar api/Browse
This commit is contained in:
26
lib/src/api/MkBrowse.hs
Normal file
26
lib/src/api/MkBrowse.hs
Normal 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
|
||||
|
||||
Reference in New Issue
Block a user