forked from GitHub/gf-core
Fixed several things, e.g. tokenizer.
This commit is contained in:
@@ -56,23 +56,17 @@ type Profile = [([[Int]],[Int])]
|
||||
mkCFFun :: Atom -> CFFun
|
||||
mkCFFun t = CFFun (t,[])
|
||||
|
||||
{- ----
|
||||
getCFLiteral :: String -> Maybe (CFCat, CFFun)
|
||||
getCFLiteral s = case lookupLiteral' s of
|
||||
Ok (c, lit) -> Just (cat2CFCat c, mkCFFun lit)
|
||||
_ -> Nothing
|
||||
-}
|
||||
|
||||
varCFFun :: Ident -> CFFun
|
||||
varCFFun = mkCFFun . AV
|
||||
|
||||
consCFFun :: CIdent -> CFFun
|
||||
consCFFun = mkCFFun . AC
|
||||
|
||||
{- ----
|
||||
string2CFFun :: String -> CFFun
|
||||
string2CFFun = consCFFun . Ident
|
||||
-}
|
||||
stringCFFun :: String -> CFFun
|
||||
stringCFFun = mkCFFun . AS
|
||||
|
||||
intCFFun :: Int -> CFFun
|
||||
intCFFun = mkCFFun . AI . toInteger
|
||||
|
||||
cfFun2String :: CFFun -> String
|
||||
cfFun2String (CFFun (f,_)) = prt f
|
||||
@@ -110,6 +104,11 @@ catVarCF = ident2CFCat (mkCIdent "_" "#Var") (identC "_") ----
|
||||
cat2CFCat :: (Ident,Ident) -> CFCat
|
||||
cat2CFCat = uncurry idents2CFCat
|
||||
|
||||
---- literals
|
||||
cfCatString = string2CFCat "Predef" "String"
|
||||
cfCatInt = string2CFCat "Predef" "Int"
|
||||
|
||||
|
||||
|
||||
{- ----
|
||||
uCFCat :: CFCat
|
||||
|
||||
@@ -27,8 +27,9 @@ canon2cf opts gr c = do
|
||||
let mms = [(a, tree2list (M.jments m)) | m <- cncs]
|
||||
rules0 <- liftM concat $ mapM (uncurry (cnc2cfCond opts)) mms
|
||||
let rules = filter (not . isCircularCF) rules0 ---- temporarily here
|
||||
let predef = const [] ---- mkCFPredef cfcats
|
||||
return $ CF (groupCFRules rules, predef)
|
||||
let grules = groupCFRules rules
|
||||
let predef = mkCFPredef $ map fst grules
|
||||
return $ CF (grules, predef)
|
||||
|
||||
cnc2cfCond :: Options -> Ident -> [(Ident,Info)] -> Err [CFRule]
|
||||
cnc2cfCond opts m gr =
|
||||
@@ -144,14 +145,9 @@ term2CFItems m t = errIn "forming cf items" $ case t of
|
||||
---- ??
|
||||
_ -> prtBad "cannot extract record field from" arg
|
||||
|
||||
{- Proof + 1 @ 4 catVarCF :: CFCat
|
||||
PNonterm CIdent Integer Label Bool -- cat, position, part/bind, whether arg
|
||||
|
||||
|
||||
mkCFPredef :: [CFCat] -> CFPredef
|
||||
mkCFPredef cats s =
|
||||
[(cat, metaCFFun) | TM _ _ <- [s], cat <- cats] ++
|
||||
[(cat, varCFFun x) | TV x <- [s], cat <- cats] ++
|
||||
[(cat, lit) | TL t <- [s], Just (cat,lit) <- [getCFLiteral t]] ++
|
||||
[(cat, lit) | TI i <- [s], Just (cat,lit) <- [getCFLiteral (show i)]] ---
|
||||
-}
|
||||
[(cat, metaCFFun) | TM _ _ <- [s], cat <- cats] ++
|
||||
[(cat, varCFFun x) | TV x <- [s], cat <- cats] ++
|
||||
[(cfCatString, stringCFFun t) | TL t <- [s]] ++
|
||||
[(cfCatInt, intCFFun t) | TI t <- [s]]
|
||||
|
||||
Reference in New Issue
Block a user