mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
generating example file
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
Eng:
|
||||
gf -nocpu ExxEng.gf <exx.gfs >exxEng.txt
|
||||
Fin:
|
||||
gf -nocpu ExxFin.gf <exx.gfs >exxFin.txt
|
||||
Swe:
|
||||
gf -nocpu ExxSwe.gf <exx.gfs >exxSwe.txt
|
||||
all: html gfs exx links
|
||||
|
||||
links:
|
||||
runghc MkLinks
|
||||
|
||||
gfs:
|
||||
runghc mkgfs.hs
|
||||
|
||||
exx:
|
||||
gf ExxSwe.gf ExGer.gf ExFre.gf ExFin.gf ExxEng.gf <exx.gfs
|
||||
|
||||
html:
|
||||
cp ../Constructors.gf .
|
||||
gfdoc -txthtml Constructors.gf
|
||||
|
||||
20
lib/resource-1.0/api/examples/MkLinks.hs
Normal file
20
lib/resource-1.0/api/examples/MkLinks.hs
Normal file
@@ -0,0 +1,20 @@
|
||||
src = "Constructors.html"
|
||||
tgt = "Cons.html"
|
||||
linkfile ex = "links/" ++ ex ++ ".txt"
|
||||
|
||||
|
||||
main = do
|
||||
writeFile tgt ""
|
||||
readFile src >>= (mapM_ mkLink . lines)
|
||||
|
||||
mkLink line = case break (=="--") (words (takeWhile (/='#')line)) of
|
||||
(fun : ":" : typ, _ : num : ex) ->
|
||||
appendFile tgt ("\n" ++ takeInit line ++ " " ++ link ex typ num)
|
||||
_ -> appendFile tgt ("\n" ++ line)
|
||||
where
|
||||
takeInit line = init (init (takeWhile (/='.') line))
|
||||
link ex typ num =
|
||||
"<a href=\"" ++ linkfile (example typ num) ++ "\">" ++ unwords ex ++ "</a>"
|
||||
example typ num = case reverse typ of
|
||||
";":val:_ -> "ex" ++ init num ++ "_" ++ val
|
||||
val:_ -> "ex" ++ init num ++ "_" ++ val
|
||||
@@ -4,6 +4,7 @@ main = mkgfs
|
||||
|
||||
src = "ExxI.gf"
|
||||
script = "exx.gfs"
|
||||
linkfile ex = "links/" ++ ex ++ ".txt"
|
||||
|
||||
mkgfs = do
|
||||
writeFile script ""
|
||||
@@ -11,7 +12,11 @@ mkgfs = do
|
||||
|
||||
|
||||
addLin s = case words s of
|
||||
c@('e':'x':_):_ -> appendFile script ("l " ++ cc ++ "\n") where
|
||||
c@('e':'x':_):"=":def -> do
|
||||
appendFile script ("ps \"" ++ unwords (init def) ++ "\\n\\n\" | wf " ++ linkfile c ++ "\n")
|
||||
appendFile script ("l -multi " ++ cc ++ " | af " ++ linkfile c ++ "\n")
|
||||
|
||||
where
|
||||
cc = case take 2 (reverse c) of
|
||||
"PV" -> "utt " ++ c
|
||||
_ -> c
|
||||
|
||||
Reference in New Issue
Block a user