summaryrefslogtreecommitdiff
path: root/src/GF/CF
diff options
context:
space:
mode:
authorpeb <unknown>2005-02-18 18:21:06 +0000
committerpeb <unknown>2005-02-18 18:21:06 +0000
commit9568d7a844ba6a1872a8e8f6ef002860057e62ab (patch)
tree9e25c6ed62e48101a2782d5fb8dcba68462dc613 /src/GF/CF
parent1c4f025320900897ae3acdab6982f7d595b98dd1 (diff)
"Committed_by_peb"
Diffstat (limited to 'src/GF/CF')
-rw-r--r--src/GF/CF/CF.hs36
-rw-r--r--src/GF/CF/CFIdent.hs44
-rw-r--r--src/GF/CF/CFtoGrammar.hs10
-rw-r--r--src/GF/CF/CFtoSRG.hs6
-rw-r--r--src/GF/CF/CanonToCF.hs10
-rw-r--r--src/GF/CF/ChartParser.hs6
-rw-r--r--src/GF/CF/EBNF.hs10
-rw-r--r--src/GF/CF/PPrCF.hs10
-rw-r--r--src/GF/CF/PrLBNF.hs10
-rw-r--r--src/GF/CF/Profile.hs10
10 files changed, 100 insertions, 52 deletions
diff --git a/src/GF/CF/CF.hs b/src/GF/CF/CF.hs
index 962a7d8c7..5c126ef35 100644
--- a/src/GF/CF/CF.hs
+++ b/src/GF/CF/CF.hs
@@ -1,18 +1,38 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : CF
+-- 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.5 $
--
--- context-free grammars. AR 15/12/1999 -- 30/3/2000 -- 2/6/2001 -- 3/12/2001
+-- context-free grammars. AR 15\/12\/1999 -- 30\/3\/2000 -- 2\/6\/2001 -- 3\/12\/2001
-----------------------------------------------------------------------------
-module CF where
+module CF (-- * Types
+ CF(..), CFRule, CFRuleGroup,
+ CFItem(..), CFTree(..), CFPredef, CFParser,
+ RegExp(..), CFWord,
+ -- * Functions
+ cfParseResults,
+ -- ** to construct CF grammars
+ emptyCF, emptyCFPredef, rules2CF, groupCFRules,
+ -- ** to construct rules
+ atomCFRule, atomCFTerm, atomRegExp, altsCFTerm,
+ -- ** to construct trees
+ atomCFTree, buildCFTree,
+ -- ** to decide whether a token matches a terminal item
+ matchCFTerm, satRegExp,
+ -- ** to analyse a CF grammar
+ catsOfCF, rulesOfCF, ruleGroupsOfCF, rulesForCFCat,
+ valCatCF, valItemsCF, valFunCF,
+ startCat, predefOfCF, appCFPredef, valCFItem,
+ cfTokens, wordsOfRegExp, forCFItem,
+ isCircularCF, predefRules
+ ) where
import Operations
import Str
@@ -182,10 +202,10 @@ forCFItem :: CFTok -> CFRule -> Bool
forCFItem a (_,(_, CFTerm r : _)) = satRegExp r a
forCFItem _ _ = False
+-- | we should make a test of circular chains, too
isCircularCF :: CFRule -> Bool
isCircularCF (_,(c', CFNonterm c:[])) = compatCF c' c
isCircularCF _ = False
---- we should make a test of circular chains, too
-- | coercion to the older predef cf type
predefRules :: CFPredef -> CFTok -> [CFRule]
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
diff --git a/src/GF/CF/CFtoGrammar.hs b/src/GF/CF/CFtoGrammar.hs
index 14f11b52c..5ccbd7c1a 100644
--- a/src/GF/CF/CFtoGrammar.hs
+++ b/src/GF/CF/CFtoGrammar.hs
@@ -1,13 +1,13 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : CFtoGrammar
+-- 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.5 $
--
-- 26\/1\/2000 -- 18\/4 -- 24\/3\/2004
-----------------------------------------------------------------------------
diff --git a/src/GF/CF/CFtoSRG.hs b/src/GF/CF/CFtoSRG.hs
index f8c7bddd5..9fe35b3ab 100644
--- a/src/GF/CF/CFtoSRG.hs
+++ b/src/GF/CF/CFtoSRG.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date $
--- > CVS $Author $
--- > CVS $Revision $
+-- > CVS $Date: 2005/02/18 19:21:07 $
+-- > CVS $Author: peb $
+-- > CVS $Revision: 1.5 $
--
-- This module prints a CF as a SRG (Speech Recognition Grammar).
-- Created : 21 January, 2001.
diff --git a/src/GF/CF/CanonToCF.hs b/src/GF/CF/CanonToCF.hs
index 41306c002..6b5f35488 100644
--- a/src/GF/CF/CanonToCF.hs
+++ b/src/GF/CF/CanonToCF.hs
@@ -1,13 +1,13 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : CanonToCF
+-- 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.11 $
--
-- AR 27\/1\/2000 -- 3\/12\/2001 -- 8\/6\/2003
-----------------------------------------------------------------------------
diff --git a/src/GF/CF/ChartParser.hs b/src/GF/CF/ChartParser.hs
index 4b2f2ceb1..71b25730c 100644
--- a/src/GF/CF/ChartParser.hs
+++ b/src/GF/CF/ChartParser.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date $
--- > CVS $Author $
--- > CVS $Revision $
+-- > CVS $Date: 2005/02/18 19:21:07 $
+-- > CVS $Author: peb $
+-- > CVS $Revision: 1.5 $
--
-- Bottom-up Kilbury chart parser from "Pure Functional Parsing", chapter 5.
-- OBSOLETE -- should use new MCFG parsers instead
diff --git a/src/GF/CF/EBNF.hs b/src/GF/CF/EBNF.hs
index bf54c59c2..773a2117d 100644
--- a/src/GF/CF/EBNF.hs
+++ b/src/GF/CF/EBNF.hs
@@ -1,13 +1,13 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : EBNF
+-- 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.4 $
--
-- (Description of the module)
-----------------------------------------------------------------------------
diff --git a/src/GF/CF/PPrCF.hs b/src/GF/CF/PPrCF.hs
index 5f00e4b7e..cd91fa4da 100644
--- a/src/GF/CF/PPrCF.hs
+++ b/src/GF/CF/PPrCF.hs
@@ -1,13 +1,13 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : PPrCF
+-- 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.9 $
--
-- printing and parsing CF grammars, rules, and trees AR 26/1/2000 -- 9/6/2003
--
diff --git a/src/GF/CF/PrLBNF.hs b/src/GF/CF/PrLBNF.hs
index b86609a70..fbd9dba98 100644
--- a/src/GF/CF/PrLBNF.hs
+++ b/src/GF/CF/PrLBNF.hs
@@ -1,13 +1,13 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : PrLBNF
+-- Maintainer : AR
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date $
--- > CVS $Author $
--- > CVS $Revision $
+-- > CVS $Date: 2005/02/18 19:21:08 $
+-- > CVS $Author: peb $
+-- > CVS $Revision: 1.8 $
--
-- Printing CF grammars generated from GF as LBNF grammar for BNFC.
-- AR 26/1/2000 -- 9/6/2003 (PPrCF) -- 8/11/2003 -- 27/9/2004.
diff --git a/src/GF/CF/Profile.hs b/src/GF/CF/Profile.hs
index 8d5b79777..12aa5c385 100644
--- a/src/GF/CF/Profile.hs
+++ b/src/GF/CF/Profile.hs
@@ -1,13 +1,13 @@
----------------------------------------------------------------------
-- |
--- Module : (Module)
--- Maintainer : (Maintainer)
+-- Module : Profile
+-- Maintainer : AR
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date $
--- > CVS $Author $
--- > CVS $Revision $
+-- > CVS $Date: 2005/02/18 19:21:08 $
+-- > CVS $Author: peb $
+-- > CVS $Revision: 1.7 $
--
-- restoring parse trees for discontinuous constituents, bindings, etc. AR 25/1/2001
-- revised 8/4/2002 for the new profile structure