From 64d3a1226da712bcf3c2744bcc141ebd40acac27 Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 29 May 2008 10:55:34 +0000 Subject: simplify the Profile type and remove the NameProfile type --- src-3.0/GF/Formalism/FCFG.hs | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) (limited to 'src-3.0/GF/Formalism/FCFG.hs') diff --git a/src-3.0/GF/Formalism/FCFG.hs b/src-3.0/GF/Formalism/FCFG.hs index 2f3994b6c..96e88c8cf 100644 --- a/src-3.0/GF/Formalism/FCFG.hs +++ b/src-3.0/GF/Formalism/FCFG.hs @@ -22,11 +22,8 @@ module GF.Formalism.FCFG , FIndex , FSymbol(..) - -- * Name - , FName - , isCoercionF - -- * Grammar + , Profile , FPointPos , FGrammar , FRule(..) @@ -38,7 +35,7 @@ import Data.Array import qualified Data.Map as Map import GF.Formalism.Utilities -import qualified GF.GFCC.CId as AbsGFCC +import GF.GFCC.CId import GF.Infra.PrintClass ------------------------------------------------------------ @@ -66,27 +63,19 @@ data FSymbol | FSymTok FToken ------------------------------------------------------------- --- Name -type FName = NameProfile AbsGFCC.CId - -isCoercionF :: FName -> Bool -isCoercionF (Name fun [Unify [0]]) = fun == AbsGFCC.wildCId -isCoercionF _ = False - - ------------------------------------------------------------ -- Grammar +type Profile = [Int] type FPointPos = Int -type FGrammar = ([FRule], Map.Map AbsGFCC.CId [FCat]) -data FRule = FRule FName [FCat] FCat (Array FIndex (Array FPointPos FSymbol)) +type FGrammar = ([FRule], Map.Map CId [FCat]) +data FRule = FRule CId [Profile] [FCat] FCat (Array FIndex (Array FPointPos FSymbol)) ------------------------------------------------------------ -- pretty-printing -instance Print AbsGFCC.CId where - prt = AbsGFCC.prCId +instance Print CId where + prt = prCId instance Print FSymbol where prt (FSymCat c l n) = "($" ++ prt n ++ "!" ++ prt l ++ ")" @@ -100,6 +89,11 @@ instance Print FSymbol where prtList = prtSep " " instance Print FRule where - prt (FRule name args res lins) = prt name ++ " : " ++ (if null args then "" else prtSep " " args ++ " -> ") ++ prt res ++ - " =\n [" ++ prtSep "\n " ["("++prtSep " " [prt sym | (_,sym) <- assocs syms]++")" | (_,syms) <- assocs lins]++"]" + prt (FRule fun profile args res lins) = + prt fun ++ prtProf profile ++ " : " ++ (if null args then "" else prtSep " " args ++ " -> ") ++ prt res ++ + " =\n [" ++ prtSep "\n " ["("++prtSep " " [prt sym | (_,sym) <- assocs syms]++")" | (_,syms) <- assocs lins]++"]" + where + prtProf [] = "?" + prtProf args = prtSep "=" args + prtList = prtSep "\n" -- cgit v1.2.3