1
0
forked from GitHub/gf-core

options for no-pmcfg compilation in lib/src/Make.hs (for library developers, rather than users); adding Thai to some demo and documentation

This commit is contained in:
aarne
2011-11-21 15:30:55 +00:00
parent 6bb1db51e7
commit b36a8fdc50
7 changed files with 51 additions and 31 deletions

View File

@@ -4,5 +4,8 @@ all:: Foods.pgf
Foods.pgf: Foods???.gf
gf -make -s -optimize-pgf Foods???.gf
exper: Foods???.gf
gf -make -s -optimize-pgf Foods???.gf FoodsThai.gf
clean:
rm -rf *.gfo Foods.pgf

View File

@@ -17,7 +17,7 @@ revealedLang = "Eng"
-- all languages shown
apiExxFiles = ["api-examples-" ++ lang ++ ".txt" | lang <- words
"Afr Bul Cat Dan Dut Eng Fin Fre Ger Ita Nep Nor Pes Pnb Pol Ron Rus Spa Swe Urd"]
"Afr Bul Cat Dan Dut Eng Fin Fre Ger Ita Nep Nor Pes Pnb Pol Ron Rus Spa Swe Tha Urd"]
main = do
xx <- getArgs
@@ -255,6 +255,7 @@ paradigmFiles = [
("Russian", srcPath "/russian/ParadigmsRus.gf"),
("Spanish", srcPath "/spanish/ParadigmsSpa.gf"),
("Swedish", srcPath "/swedish/ParadigmsSwe.gf"),
("Thai", srcPath "/urdu/ParadigmsTha.gf")
("Urdu", srcPath "/urdu/ParadigmsUrd.gf")
]

View File

@@ -8,7 +8,7 @@ import System.Environment
import System.Exit
-- Make commands for compiling and testing resource grammars.
-- usage: runghc Make ((present? OPT?) | (clone FILE))? LANGS?
-- usage: runghc Make (((present|alltenses)? OPT?) | (clone FILE))? LANGS?
-- where
-- - OPT = (lang | api | pgf | test | parse | clean | clone)
-- - LANGS has the form e.g. langs=Eng,Fin,Rus
@@ -72,13 +72,13 @@ langsLang = langs `except` langsIncomplete ---- []
langsPresent = langsLang `except` ["Lav","Nep","Pes","Tha"]
-- languages for which Lang can be compiled but which are incomplete
langsIncomplete = ["Amh","Ara","Hin","Lat","Tha","Tur"]
langsIncomplete = ["Amh","Ara","Hin","Lat","Tur"]
-- languages for which to compile Try
langsAPI = langsLang `except` langsIncomplete
-- languages for which to compile Symbolic
langsSymbolic = langsLang `except` (langsIncomplete ++ ["Afr","Ina","Lav","Nep","Pes","Pnb","Rus","Tha"])
langsSymbolic = langsLang `except` (langsIncomplete ++ ["Afr","Ina","Lav","Nep","Pes","Pnb","Rus"])
-- languages for which to compile minimal Syntax
langsMinimal = langs `only` ["Ara","Eng","Bul","Rus"]
@@ -109,13 +109,19 @@ make :: [String] -> IO ()
make xx = do
let ifx opt act = if null xx || elem opt xx then act >> return () else return ()
let ifxx opt act = if elem opt xx then act >> return () else return ()
let pres = elem "present" xx
let dir = if pres then "../present" else "../alltenses"
let pres
| elem "present" xx = 1
| elem "alltenses" xx = 2
| otherwise = 0
let dir = case pres of
1 -> "../present"
2 -> "../alltenses"
_ -> "../full"
let optl ls = maybe ls id $ getOptLangs xx
ifx "lang" $ do
let lans = optl $ if pres then langsPresent else langsLang
let lans = optl $ if (pres == 1) then langsPresent else langsLang
mapM_ (gfc pres [] . lang) lans
mapM_ (gfc pres presSymbolPath . symbol) lans ---- (optl langsAPI)
copyl lans "*.gfo" dir
@@ -148,7 +154,7 @@ make xx = do
mapM_ (gfc pres [] . parse) (optl langsParse)
copy "parse/*.gfo parse/oald/*.gfo" dir
ifxx "clean" $ do
system "rm -f */*.gfo ../alltenses/*.gfo ../present/*.gfo"
system "rm -f */*.gfo ../alltenses/*.gfo ../present/*.gfo ../prelude/*.gfo ../full/*.gfo"
ifxx "clone" $ do
let (pref,lang) = case getLangName xx of
Just pl -> pl
@@ -157,12 +163,15 @@ make xx = do
mapM_ (\la -> writeFile (pref ++ la ++ ".gf") (replaceLang lang la s)) (map snd (optl langs))
return ()
-- pres = 0 (full), 1 (present), 2 (alltenses)
gfc pres ppath file = do
let preproc = if pres then "-preproc=mkPresent" else ""
let path = if pres then ppath else ""
let preproc = if (pres==1) then "-preproc=mkPresent" else ""
let path = if (pres==1) then ppath else ""
putStrLn $ "Compiling " ++ file
---- run_gfc ["-s","-src","-no-pmcfg",preproc, path, file]
run_gfc ["-s","-src",preproc, path, file]
if pres == 0
then run_gfc ["-s","-src",preproc, path, file]
else run_gfc ["-s","-src","-no-pmcfg",preproc, path, file]
gfcmin path file = do
let preproc = "-preproc=mkMinimal"

View File

@@ -3,9 +3,9 @@ RUNMAKE=$(RUNGHC) Make.hs
GF_LIB_PATH=..
.PHONY: all present alltenses lang api math prelude test demo parse synopsis link compiled constructX clean
.PHONY: all present alltenses full lang api math prelude test demo parse synopsis link compiled constructX clean
all: link prelude constructX present alltenses
all: link prelude constructX present alltenses full
present:
$(RUNMAKE) present lang
@@ -13,15 +13,18 @@ present:
$(RUNMAKE) present symbolic
alltenses:
$(RUNMAKE) alltenses lang
$(RUNMAKE) alltenses api
$(RUNMAKE) alltenses symbolic
full:
$(RUNMAKE) lang
$(RUNMAKE) api
$(RUNMAKE) symbolic
lang:
$(RUNMAKE) lang
$(RUNMAKE) alltenses lang
api:
$(RUNMAKE) api
$(RUNMAKE) alltenses api
compatibility:
$(RUNMAKE) present compat

View File

@@ -1,5 +1,3 @@
--# -path=.:alltenses
abstract MiniGrammar = Lexicon, Grammar [
-- the "mini" resource of GF book, chapter 9
@@ -130,9 +128,9 @@ fun
this_Det, these_Det : Det ;
that_Det, those_Det : Det ;
i_NP, youSg_NP, he_NP, she_NP, we_NP, youPl_NP, they_NP : NP ;
SubjS : S -> Subj -> S -> S ; -- she walks because we run
-- SubjS : S -> Subj -> S -> S ; -- she walks because we run
CompAdv : Adv -> VP ; -- be here
SlashV2 : NP -> V2 -> ClSlash ; -- she loves
-- SlashV2 : NP -> V2 -> ClSlash ; -- she loves
SlashPrep : Cl -> Prep -> ClSlash ; -- she walks with
AdvCN : CN -> Prep -> NP -> CN ; -- man in the city

View File

@@ -1,4 +1,4 @@
--# -path=.:alltenses
--# -path=.:full:alltenses
concrete MiniGrammarEng of MiniGrammar = LexiconEng, GrammarEng [
@@ -49,6 +49,7 @@ concrete MiniGrammarEng of MiniGrammar = LexiconEng, GrammarEng [
TTAnt, -- Tense -> Ant -> Temp ;
PPos, PNeg, -- Pol,
TPres, TPast, TFut, TCond, -- Tense,
STense, SCond, SFut, SPast, SPres, -- scand tense
ASimul, AAnter,
and_Conj, or_Conj, -- Conj,
@@ -122,7 +123,7 @@ lin
ComplV2 v np = mkVP v np ;
ModCN ap cn = lin CN (mkCN <lin AP ap : AP> <lin CN cn : CN>) ;
CompAP ap = mkVP (lin AP ap) ;
ConjS co x y = mkS co x y ;
ConjS co x y = mkS (lin Conj co) (lin S x) (lin S y) ;
ConjAP co x y = mkAP co x y ;
ConjNP co x y = mkNP co x y ;
a_Det = mkDet a_Quant ;
@@ -139,9 +140,8 @@ lin
youPl_NP = S.youPl_NP ;
they_NP = S.they_NP ;
-- SubjS s subj s = mkS s (mkAdv subj s) ;
CompAdv adv = mkVP adv ;
CompAdv adv = mkVP (lin Adv adv) ;
-- SlashV2 np v2 = mkClSlash np v2 ;
SlashPrep cl p = mkClSlash cl p ;
AdvCN cn p pp = mkCN <lin CN cn : CN> (mkAdv p pp) ;
SlashPrep cl p = mkClSlash (lin Cl cl) <p : Prep> ;
AdvCN cn p pp = mkCN <lin CN cn : CN> (mkAdv <p : Prep> <pp : NP>) ;
}

View File

@@ -1,6 +1,12 @@
src = "Eng"
langs = ["Afr","Bul","Cat","Dan","Dut","Fin","Fre","Ger","Ita",
"Nep","Nor","Pes","Pol","Pnb","Ron","Rus","Spa","Swe","Urd"]
langs = [
"Afr", "Bul", "Cat","Dan","Dut",
"Fin","Fre","Ger","Ita", -- "Lav",
"Nep","Nor","Pes","Pol","Pnb",
--- "Ron",
"Rus","Spa","Swe","Tha",
"Urd"
]
file lng = "MiniGrammar" ++ lng ++ ".gf"