mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-27 13:32:51 -06:00
make for library browser
This commit is contained in:
2
lib/src/api/libraryBrowser/Makefile
Normal file
2
lib/src/api/libraryBrowser/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
gf -make LibraryBrowser???.gf
|
||||
23
lib/src/api/libraryBrowser/MkLinAPI.hs
Normal file
23
lib/src/api/libraryBrowser/MkLinAPI.hs
Normal file
@@ -0,0 +1,23 @@
|
||||
import Char
|
||||
import List
|
||||
|
||||
main = interact (unlines . map mkOne . lines)
|
||||
|
||||
mkOne line = case words line of
|
||||
fun : ":" : typ -> mkGF fun (init typ)
|
||||
_ -> []
|
||||
|
||||
mkGF fun typ = unwords $ case typ of
|
||||
[ty] -> ["lin",fun] ++ ["=","mkTerm"] ++ [quotes fun] ++ [";"]
|
||||
_ -> ["lin",fun] ++ args ++ ["=","mkTerm",lin] ++ args ++ [";"]
|
||||
where
|
||||
cats = filter (/="->") typ
|
||||
(src,target) = splitAt (length cats - 1) cats
|
||||
args = [x ++ "_" ++ show n | (x,n) <- zip (map unCap src) [1..]]
|
||||
lin = quotes ("mk" ++ head target)
|
||||
|
||||
unCap = map toLower
|
||||
|
||||
quotes s = "\"" ++ s ++ "\""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user