summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GF/Canon/MkGFC.hs6
-rw-r--r--src/GF/Grammar/PrGrammar.hs5
-rw-r--r--src/GF/Shell/HelpFile.hs5
-rw-r--r--src/GF/UseGrammar/Custom.hs8
-rw-r--r--src/GF/UseGrammar/Statistics.hs44
-rw-r--r--src/HelpFile1
6 files changed, 59 insertions, 10 deletions
diff --git a/src/GF/Canon/MkGFC.hs b/src/GF/Canon/MkGFC.hs
index 81706e9b7..69ccc3034 100644
--- a/src/GF/Canon/MkGFC.hs
+++ b/src/GF/Canon/MkGFC.hs
@@ -5,16 +5,16 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/05/30 21:08:14 $
+-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.15 $
+-- > CVS $Revision: 1.16 $
--
-- (Description of the module)
-----------------------------------------------------------------------------
module GF.Canon.MkGFC (prCanonModInfo, prCanon, prCanonMGr,
canon2grammar, grammar2canon, -- buildCanonGrammar,
- info2mod,
+ info2mod,info2def,
trExp, rtExp, rtQIdent) where
import GF.Canon.GFC
diff --git a/src/GF/Grammar/PrGrammar.hs b/src/GF/Grammar/PrGrammar.hs
index a5471d6ea..905eb39f4 100644
--- a/src/GF/Grammar/PrGrammar.hs
+++ b/src/GF/Grammar/PrGrammar.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/05/30 18:39:44 $
+-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.15 $
+-- > CVS $Revision: 1.16 $
--
-- AR 7\/12\/1999 - 1\/4\/2000 - 10\/5\/2003
--
@@ -107,6 +107,7 @@ instance Print A.Case where prt = C.printTree
instance Print A.CType where prt = C.printTree
instance Print A.Label where prt = C.printTree
instance Print A.Module where prt = C.printTree
+instance Print A.Def where prt = C.printTree
instance Print A.Canon where prt = C.printTree
instance Print A.Sort where prt = C.printTree
diff --git a/src/GF/Shell/HelpFile.hs b/src/GF/Shell/HelpFile.hs
index 8d427753a..c530e459f 100644
--- a/src/GF/Shell/HelpFile.hs
+++ b/src/GF/Shell/HelpFile.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/07/01 19:54:09 $
+-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.9 $
+-- > CVS $Revision: 1.10 $
--
-- Help on shell commands. Generated from HelpFile by 'make help'.
-- PLEASE DON'T EDIT THIS FILE.
@@ -523,6 +523,7 @@ txtHelpFile =
"\n -printer=fullform full-form lexicon, short format" ++
"\n *-printer=xml XML: DTD for the pg command, object for st" ++
"\n -printer=old old GF: file readable by GF 1.2" ++
+ "\n -printer=stat show some statistics of generated GFC" ++
"\n" ++
"\n-startcat, like -cat, but used in grammars (to avoid clash with keyword cat)" ++
"\n" ++
diff --git a/src/GF/UseGrammar/Custom.hs b/src/GF/UseGrammar/Custom.hs
index 2e54bcb18..c952bcd5c 100644
--- a/src/GF/UseGrammar/Custom.hs
+++ b/src/GF/UseGrammar/Custom.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/09/01 09:53:19 $
--- > CVS $Author: peb $
--- > CVS $Revision: 1.69 $
+-- > CVS $Date: 2005/09/04 11:45:38 $
+-- > CVS $Author: aarne $
+-- > CVS $Revision: 1.70 $
--
-- A database for customizable GF shell commands.
--
@@ -61,6 +61,7 @@ import GF.Speech.PrSLF (slfPrinter)
import GF.Data.Zipper
+import GF.UseGrammar.Statistics
import GF.UseGrammar.Morphology
import GF.API.GrammarToHaskell
-----import GrammarToCanon (showCanon, showCanonOpt)
@@ -249,6 +250,7 @@ customGrammarPrinter =
,(strCI "opts", prOpts . stateOptions)
,(strCI "words", unwords . stateGrammarWords)
,(strCI "printnames", C.prPrintnamesGrammar . stateGrammarST)
+ ,(strCI "stat", prStatistics . stateGrammarST)
{- ----
(strCI "gf", prt . st2grammar . stateGrammarST) -- DEFAULT
,(strCI "canon", showCanon "Lang" . stateGrammarST)
diff --git a/src/GF/UseGrammar/Statistics.hs b/src/GF/UseGrammar/Statistics.hs
new file mode 100644
index 000000000..46e4fcc3b
--- /dev/null
+++ b/src/GF/UseGrammar/Statistics.hs
@@ -0,0 +1,44 @@
+----------------------------------------------------------------------
+-- |
+-- Module : Statistics
+-- Maintainer : AR
+-- Stability : (stable)
+-- Portability : (portable)
+--
+-- > CVS $Date: 2005/09/04 11:45:38 $
+-- > CVS $Author: aarne $
+-- > CVS $Revision: 1.1 $
+--
+-- statistics on canonical grammar: amounts of generated code
+-- AR 4\/9\/2005.
+-- uses canonical grammar
+-----------------------------------------------------------------------------
+
+module GF.UseGrammar.Statistics (prStatistics) where
+
+import GF.Infra.Modules
+import GF.Infra.Option
+import GF.Grammar.PrGrammar
+import GF.Canon.GFC
+import GF.Canon.MkGFC
+
+import GF.Data.Operations
+
+import Data.List (sortBy)
+
+-- | the top level function
+prStatistics :: CanonGrammar -> String
+prStatistics can = unlines $ [
+ show (length mods) ++ "\t\t modules",
+ show chars ++ "\t\t gfc size",
+ "",
+ "Top 40 definitions"
+ ] ++
+ [show d ++ "\t\t " ++ f | (d,f) <- tops]
+ where
+ tops = take 40 $ reverse $ sortBy (\ (i,_) (j,_) -> compare i j) defs
+ defs = [(length (prt (info2def j)), name m j) | (m,j) <- infos]
+ infos = [(m,j) | (m,ModMod mo) <- mods, j <- tree2list (jments mo)]
+ name m (f,_) = prt m ++ "." ++ prt f
+ mods = modules can
+ chars = length $ prCanon can
diff --git a/src/HelpFile b/src/HelpFile
index 299655688..edc5bef9c 100644
--- a/src/HelpFile
+++ b/src/HelpFile
@@ -494,6 +494,7 @@ q, quit: q
-printer=fullform full-form lexicon, short format
*-printer=xml XML: DTD for the pg command, object for st
-printer=old old GF: file readable by GF 1.2
+ -printer=stat show some statistics of generated GFC
-startcat, like -cat, but used in grammars (to avoid clash with keyword cat)