From af0dfe0921c2249988b878e38e6d8f134c828c70 Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 24 Feb 2006 15:49:14 +0000 Subject: [PATCH] bronzeage README ; topological sorting of abstract modules --- examples/bronzeage/README | 44 +++++++++++++++++++++++++++++++++++++++ src/GF/Infra/Modules.hs | 9 ++++---- 2 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 examples/bronzeage/README diff --git a/examples/bronzeage/README b/examples/bronzeage/README new file mode 100644 index 000000000..3d647a047 --- /dev/null +++ b/examples/bronzeage/README @@ -0,0 +1,44 @@ +(AR 24/2/2006) + +(c) Björn Bringert and Aarne Ranta 2005-2006 + +Based on grammars and lexicon in GF/examples/stoneage by Björn Bringert. +These grammars use a more varying syntax, with negation, questions, +imperatives, adverbs, and adjectival predication added. + + +To build the run-time grammar: + + echo "s ;; pm | wf bronzeage.gfcm" | gf -nocf Bronzeage???.gf + +Before this, you have to have compiled the libraries: + + cd GF/lib/resource-1.0 + make langs + make install + +To work with the grammar + + gf bronzeage.gfcm + +Once in GF, you can do translation, + + p -mcfg -lang=BronzeageEng "Don't eat that thick snake!" | tb + +random generation, + + gr | tb + +translation quiz lists + + tl -number=5 -cat=CN BronzeageEng BronzeageFre + +morphological quiz lists + + ml -number=5 -cat=V -lang=BronzeageSpa + +sentence transformation quiz lists + + ml -number=5 -cat=Sent -lang=BronzeageEng + + diff --git a/src/GF/Infra/Modules.hs b/src/GF/Infra/Modules.hs index 723cf7f3d..e8f372896 100644 --- a/src/GF/Infra/Modules.hs +++ b/src/GF/Infra/Modules.hs @@ -368,15 +368,16 @@ isCompleteModule :: (Eq i) => Module i f a -> Bool isCompleteModule m = mstatus m == MSComplete && mtype m /= MTInterface --- | all abstract modules +-- | all abstract modules sorted from least to most dependent allAbstracts :: Eq i => MGrammar i f a -> [i] -allAbstracts gr = [i | (i,ModMod m) <- modules gr, mtype m == MTAbstract] +allAbstracts gr = topoSort + [(i,extends m) | (i,ModMod m) <- modules gr, mtype m == MTAbstract] -- | the last abstract in dependency order (head of list) greatestAbstract :: Eq i => MGrammar i f a -> Maybe i greatestAbstract gr = case allAbstracts gr of - [] -> Nothing - a:_ -> return a + [] -> Nothing + as -> return $ last as -- | all resource modules allResources :: MGrammar i f a -> [i]