started a grammar for grammatical terms, covering the cats of the RGL

This commit is contained in:
aarne
2011-03-14 18:48:08 +00:00
parent b9ebd48a2c
commit a59df6b495
4 changed files with 368 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
main = interact (unlines . map (mkTerm . words) . lines)
mkTerm ws = case ws of
"==":cat:"-":expl -> unlines [
mkFun "Cat" cat,
mkLin "Cat" "mkN" cat (unwords (takeWhile (/= "==") expl))
]
mkFun pref s = unwords ["fun", pref ++ s, ":", pref, ";"]
---mkLin pref p s e = unwords ["lin", pref ++ s, "=", p, quoted e, ";"]
mkLin pref p s e = unwords ["lin", pref ++ s, "=", quoted s, ";"]
quoted s = "\"" ++ s ++ "\""