MinGrammar compilation more robust

This commit is contained in:
aarne
2011-11-24 12:44:36 +00:00
parent 1f174fe04f
commit dfb8e39933
5 changed files with 58 additions and 5 deletions

45
lib/src/mini/Compile.hs Normal file
View File

@@ -0,0 +1,45 @@
import List
import System
-- (c) Aarne Ranta 2010 under GNU LGPL
-- Compile files into pgf, in chosen combinations.
-- Usage: runghc Compile (-make | -link)? Eng Fre Fin ...
-- The -make option links all pgf files to one in the end
-- The -link option only links, without first compiling
-- Arguments whose length are 3 characters are prefixed with mainmodu.
-- Other arguments are passed literally.
-- Thus, for instance, to produce an English-Swedish-Romanian phrasebook with English
-- disambiguation, the command is
--
-- runghc Compile -link Eng Swe Ron DisambPhrasebookEng
-- change this to apply to another project; alternatively, just use full file names
mainmodu = "MiniGrammar"
main = do
(opts,langs) <- getArgs >>= return . partition ((=='-') . head)
let modus = [mkFile la | la <- langs]
putStrLn $ unwords modus
if notElem "-link" opts
then mapM_ compileOne modus >> return ()
else return ()
case opts of
_ | elem "-make" opts || elem "-link" opts -> do
let comm = "gf -make -s " ++ unwords (map (++ ".pgf") modus)
putStrLn comm
system comm
return ()
_ -> return ()
compileOne modu = do
let comm = "gf -make -s -optimize-pgf -name=" ++
modu ++ " " ++ modu ++ ".gf" ++
" +RTS -K32M"
putStrLn comm
system comm
mkFile la = if length la == 3 then mainmodu ++ la else la

View File

@@ -1,3 +1,5 @@
compile = runghc Compile
all: src pgf
src:
@@ -8,3 +10,9 @@ pgf: src
gf: src
gf -batch MiniGrammar???.gf
compdemo:
$(compile) Afr Bul Cat Dan Dut Eng Fin Fre Ger Ita Nep Nor Pnb Pes Pol Rus Spa Swe Tha Urd
linkdemo:
$(compile) -link Afr Bul Cat Dan Dut Eng Fin Fre Ger Ita Nep Nor Pnb Pes Pol Rus Spa Swe Tha Urd

View File

@@ -108,7 +108,7 @@ abstract MiniGrammar = Lexicon, Grammar [
here_Adv, -- Adv,
by_Prep, in_Prep, of_Prep, with_Prep, -- Prep,
can_VV, must_VV, want_VV, -- VV,
although_Subj, because_Subj, when_Subj, -- Subj,
although_Subj, because_Subj, when_Subj, if_Subj, -- Subj,
when_IAdv, where_IAdv, why_IAdv-- IAdv,
] ** {
@@ -128,7 +128,7 @@ 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 : Subj -> S -> S -> Utt ; -- if she walks we run
CompAdv : Adv -> VP ; -- be here
-- SlashV2 : NP -> V2 -> ClSlash ; -- she loves
SlashPrep : Cl -> Prep -> ClSlash ; -- she walks with

View File

@@ -112,7 +112,7 @@ concrete MiniGrammarEng of MiniGrammar = LexiconEng, GrammarEng [
here_Adv, -- Adv,
by_Prep, in_Prep, of_Prep, with_Prep, -- Prep,
can_VV, must_VV, want_VV, -- VV,
although_Subj, because_Subj, when_Subj, -- Subj,
although_Subj, because_Subj, when_Subj, if_Subj, -- Subj,
when_IAdv, where_IAdv, why_IAdv-- IAdv,
] ** open SyntaxEng, (S = SyntaxEng) in {
@@ -139,7 +139,7 @@ lin
we_NP = S.we_NP ;
youPl_NP = S.youPl_NP ;
they_NP = S.they_NP ;
-- SubjS s subj s = mkS s (mkAdv subj s) ;
SubjS subj a b = mkUtt (mkS (S.mkAdv <subj : Subj> <a : S>) b) ;
CompAdv adv = mkVP (lin Adv adv) ;
-- SlashV2 np v2 = mkClSlash np v2 ;
SlashPrep cl p = mkClSlash (lin Cl cl) <p : Prep> ;