diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2007-10-12 16:00:37 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2007-10-12 16:00:37 +0000 |
| commit | 873a160537bf72ead6cfcd6b739d4c7821eb4c85 (patch) | |
| tree | 88a65bddef3808f591015d9a62fa9e39e4427d32 /src/GF/Formalism | |
| parent | 96ed0bf4ac7e2898f6f8de82cacecb69d1e94684 (diff) | |
FCat is just a plain integer now
Diffstat (limited to 'src/GF/Formalism')
| -rw-r--r-- | src/GF/Formalism/FCFG.hs | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/src/GF/Formalism/FCFG.hs b/src/GF/Formalism/FCFG.hs index f8e3b6509..be0398fa3 100644 --- a/src/GF/Formalism/FCFG.hs +++ b/src/GF/Formalism/FCFG.hs @@ -14,11 +14,9 @@ module GF.Formalism.FCFG -- * Category , FPath - , FCat(..) + , FCat - , initialFCat , fcatString, fcatInt, fcatFloat - , fcat2cid -- * Symbol , FIndex @@ -37,6 +35,7 @@ module GF.Formalism.FCFG import Control.Monad (liftM) import Data.List (groupBy) import Data.Array +import qualified Data.Map as Map import GF.Formalism.Utilities import qualified GF.GFCC.AbsGFCC as AbsGFCC @@ -51,30 +50,18 @@ type FToken = String ------------------------------------------------------------ -- Category type FPath = [FIndex] -data FCat = FCat {-# UNPACK #-} !Int AbsGFCC.CId [FPath] [(FPath,FIndex)] - -initialFCat :: AbsGFCC.CId -> FCat -initialFCat cat = FCat 0 cat [] [] - -fcatString = FCat (-1) (AbsGFCC.CId "String") [[0]] [] -fcatInt = FCat (-2) (AbsGFCC.CId "Int") [[0]] [] -fcatFloat = FCat (-3) (AbsGFCC.CId "Float") [[0]] [] - -fcat2cid :: FCat -> AbsGFCC.CId -fcat2cid (FCat _ c _ _) = c - -instance Eq FCat where - (FCat id1 _ _ _) == (FCat id2 _ _ _) = id1 == id2 - -instance Ord FCat where - compare (FCat id1 _ _ _) (FCat id2 _ _ _) = compare id1 id2 +type FCat = Int +fcatString, fcatInt, fcatFloat :: Int +fcatString = (-1) +fcatInt = (-2) +fcatFloat = (-3) ------------------------------------------------------------ -- Symbol type FIndex = Int data FSymbol - = FSymCat FCat {-# UNPACK #-} !FIndex {-# UNPACK #-} !Int + = FSymCat {-# UNPACK #-} !FCat {-# UNPACK #-} !FIndex {-# UNPACK #-} !Int | FSymTok FToken @@ -89,23 +76,17 @@ isCoercionF _ = False ------------------------------------------------------------ -- Grammar -type FGrammar = [FRule] + type FPointPos = Int +type FGrammar = ([FRule], Map.Map AbsGFCC.CId [FCat]) data FRule = FRule FName [FCat] FCat (Array FIndex (Array FPointPos FSymbol)) - ------------------------------------------------------------ -- pretty-printing instance Print AbsGFCC.CId where prt (AbsGFCC.CId s) = s -instance Print FCat where - prt (FCat _ (AbsGFCC.CId cat) rcs tcs) = cat ++ "{" ++ - prtSep ";" ([prt path | path <- rcs] ++ - [prt path ++ "=" ++ prt term | (path,term) <- tcs]) - ++ "}" - instance Print FSymbol where prt (FSymCat c l n) = "($" ++ prt n ++ "!" ++ prt l ++ ")" prt (FSymTok t) = simpleShow (prt t) |
