summaryrefslogtreecommitdiff
path: root/src/GF/CF/CFIdent.hs
diff options
context:
space:
mode:
authoraarne <unknown>2003-11-17 15:17:53 +0000
committeraarne <unknown>2003-11-17 15:17:53 +0000
commit70c9f7b365b07044c07837a04223a11dfa3b7140 (patch)
treeb39c484dd86d6226f716f241da0b4a85a630a6a0 /src/GF/CF/CFIdent.hs
parent9d55f72d7a97658faa6ebc890535fa0c6e665a05 (diff)
Lexer by need.
Diffstat (limited to 'src/GF/CF/CFIdent.hs')
-rw-r--r--src/GF/CF/CFIdent.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/GF/CF/CFIdent.hs b/src/GF/CF/CFIdent.hs
index 02343bfb7..99ab711e4 100644
--- a/src/GF/CF/CFIdent.hs
+++ b/src/GF/CF/CFIdent.hs
@@ -3,7 +3,9 @@ module CFIdent where
import Operations
import GFC
import Ident
+import Values (cPredefAbs)
import AbsGFC
+import Macros (ident2label)
import PrGrammar
import Str
import Char (toLower, toUpper)
@@ -48,6 +50,10 @@ newtype CFFun = CFFun (Atom, Profile) deriving (Eq,Show)
type Profile = [([[Int]],[Int])]
+wordsCFTok :: CFTok -> [String]
+wordsCFTok t = case t of
+ TC (c:cs) -> [c':cs | c' <- [toUpper c, toLower c]]
+ _ -> [prCFTok t]
-- the following functions should be used instead of constructors
@@ -68,6 +74,9 @@ stringCFFun = mkCFFun . AS
intCFFun :: Int -> CFFun
intCFFun = mkCFFun . AI . toInteger
+dummyCFFun :: CFFun
+dummyCFFun = varCFFun $ identC "_" --- used in lexer-by-need rules
+
cfFun2String :: CFFun -> String
cfFun2String (CFFun (f,_)) = prt f
@@ -105,8 +114,8 @@ cat2CFCat :: (Ident,Ident) -> CFCat
cat2CFCat = uncurry idents2CFCat
---- literals
-cfCatString = string2CFCat "Predef" "String"
-cfCatInt = string2CFCat "Predef" "Int"
+cfCatString = string2CFCat (prt cPredefAbs) "String"
+cfCatInt = string2CFCat (prt cPredefAbs) "Int"
@@ -122,6 +131,9 @@ moduleOfCFCat (CFCat (CIQ m _, _)) = m
cfCat2Cat :: CFCat -> (Ident,Ident)
cfCat2Cat (CFCat (CIQ m c,_)) = (m,c)
+lexCFCat :: CFCat -> CFCat
+lexCFCat cat = ident2CFCat (uncurry CIQ (cfCat2Cat cat)) (identC "*")
+
-- to construct CF tokens
string2CFTok :: String -> CFTok