summaryrefslogtreecommitdiff
path: root/src/GF/Formalism/GCFG.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF/Formalism/GCFG.hs')
-rw-r--r--src/GF/Formalism/GCFG.hs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/GF/Formalism/GCFG.hs b/src/GF/Formalism/GCFG.hs
index 407b85bc5..32ba2cedb 100644
--- a/src/GF/Formalism/GCFG.hs
+++ b/src/GF/Formalism/GCFG.hs
@@ -4,17 +4,18 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/04/11 13:52:50 $
+-- > CVS $Date: 2005/04/20 12:49:44 $
-- > CVS $Author: peb $
--- > CVS $Revision: 1.1 $
+-- > CVS $Revision: 1.2 $
--
-- Basic GCFG formalism (derived from Pollard 1984)
-----------------------------------------------------------------------------
-module GF.Formalism.GCFG
- ( Grammar, Rule(..), Abstract(..), Concrete(..)
- ) where
+module GF.Formalism.GCFG where
+import GF.Formalism.Utilities (SyntaxChart)
+import GF.Data.Assoc (assocMap, accumAssoc)
+import GF.Data.SortedList (nubsort, groupPairs)
import GF.Infra.Print
----------------------------------------------------------------------
@@ -28,6 +29,10 @@ data Abstract cat name = Abs cat [cat] name
data Concrete lin term = Cnc lin [lin] term
deriving (Eq, Ord, Show)
+abstract2chart :: (Ord n, Ord e) => [Abstract e n] -> SyntaxChart n e
+abstract2chart rules = accumAssoc groupPairs $
+ [ (e, (n, es)) | Abs e es n <- rules ]
+
----------------------------------------------------------------------
instance (Print c, Print n, Print l, Print t) => Print (Rule n c l t) where