diff options
| author | peb <unknown> | 2005-02-18 18:21:06 +0000 |
|---|---|---|
| committer | peb <unknown> | 2005-02-18 18:21:06 +0000 |
| commit | 9568d7a844ba6a1872a8e8f6ef002860057e62ab (patch) | |
| tree | 9e25c6ed62e48101a2782d5fb8dcba68462dc613 /src/GF/CF/CFIdent.hs | |
| parent | 1c4f025320900897ae3acdab6982f7d595b98dd1 (diff) | |
"Committed_by_peb"
Diffstat (limited to 'src/GF/CF/CFIdent.hs')
| -rw-r--r-- | src/GF/CF/CFIdent.hs | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/src/GF/CF/CFIdent.hs b/src/GF/CF/CFIdent.hs index 11748203a..c94678880 100644 --- a/src/GF/CF/CFIdent.hs +++ b/src/GF/CF/CFIdent.hs @@ -1,18 +1,35 @@ ---------------------------------------------------------------------- -- | --- Module : (Module) --- Maintainer : (Maintainer) +-- Module : CFIdent +-- Maintainer : AR -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date $ --- > CVS $Author $ --- > CVS $Revision $ +-- > CVS $Date: 2005/02/18 19:21:07 $ +-- > CVS $Author: peb $ +-- > CVS $Revision: 1.10 $ -- -- symbols (categories, functions) for context-free grammars. ----------------------------------------------------------------------------- -module CFIdent where +module CFIdent (-- * Tokens and categories + CFTok(..), CFCat(..), + tS, tC, tL, tI, tV, tM, tInt, + prCFTok, + -- * Function names and profiles + CFFun(..), Profile, + wordsCFTok, + -- * CF Functions + mkCFFun, varCFFun, consCFFun, string2CFFun, stringCFFun, intCFFun, dummyCFFun, + cfFun2String, cfFun2Ident, cfFun2Profile, metaCFFun, + -- * CF Categories + mkCIdent, ident2CFCat, string2CFCat, catVarCF, cat2CFCat, cfCatString, cfCatInt, + moduleOfCFCat, cfCat2Cat, cfCat2Ident, lexCFCat, + -- * CF Tokens + string2CFTok, str2cftoks, + -- * Comparisons + compatToks, compatTok, compatCFFun, compatCF + ) where import Operations import GFC @@ -37,7 +54,13 @@ data CFTok = -- | this type should be abstract newtype CFCat = CFCat (CIdent,Label) deriving (Eq, Ord, Show) -tS, tC, tL, tI, tV, tM :: String -> CFTok +tS :: String -> CFTok +tC :: String -> CFTok +tL :: String -> CFTok +tI :: String -> CFTok +tV :: String -> CFTok +tM :: String -> CFTok + tS = TS tC = TC tL = TL @@ -91,8 +114,9 @@ stringCFFun = mkCFFun . AS intCFFun :: Int -> CFFun intCFFun = mkCFFun . AI . toInteger +-- | used in lexer-by-need rules dummyCFFun :: CFFun -dummyCFFun = varCFFun $ identC "_" --- used in lexer-by-need rules +dummyCFFun = varCFFun $ identC "_" cfFun2String :: CFFun -> String cfFun2String (CFFun (f,_)) = prt f @@ -134,7 +158,10 @@ cat2CFCat :: (Ident,Ident) -> CFCat cat2CFCat = uncurry idents2CFCat -- | literals +cfCatString :: CFCat cfCatString = string2CFCat (prt cPredefAbs) "String" + +cfCatInt :: CFCat cfCatInt = string2CFCat (prt cPredefAbs) "Int" @@ -170,6 +197,7 @@ str2cftoks = map tS . words . sstr compatToks :: [CFTok] -> [CFTok] -> Bool compatToks ts us = and [compatTok t u | (t,u) <- zip ts us] +compatTok :: CFTok -> CFTok -> Bool compatTok (TM _ _) _ = True --- hack because metas are renamed compatTok _ (TM _ _) = True compatTok t u = any (`elem` (alts t)) (alts u) where |
