diff options
| author | krasimir <krasimir@chalmers.se> | 2010-06-18 12:55:58 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2010-06-18 12:55:58 +0000 |
| commit | 992a7ffb381190ffa67f59f33d0dfadf41f84e78 (patch) | |
| tree | f76a7b6120f4bcc92b41a17651efb51717c8f7bb /src/compiler/GF/Grammar/Macros.hs | |
| parent | 5dfc9bbc0b87d27b4ef8848a36520605fa868fe3 (diff) | |
Yay!! Direct generation of PMCFG from GF grammar
Diffstat (limited to 'src/compiler/GF/Grammar/Macros.hs')
| -rw-r--r-- | src/compiler/GF/Grammar/Macros.hs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/GF/Grammar/Macros.hs b/src/compiler/GF/Grammar/Macros.hs index 3380a55c0..9b9c45ba7 100644 --- a/src/compiler/GF/Grammar/Macros.hs +++ b/src/compiler/GF/Grammar/Macros.hs @@ -166,6 +166,12 @@ unzipR r = (ls, map snd ts) where (ls,ts) = unzip r mkAssign :: [(Label,Term)] -> [Assign] mkAssign lts = [assign l t | (l,t) <- lts] +projectRec :: Label -> [Assign] -> Term +projectRec l rs = + case lookup l rs of + Just (_,t) -> t + Nothing -> error (render (text "no value for label" <+> ppLabel l)) + zipAssign :: [Label] -> [Term] -> [Assign] zipAssign ls ts = [assign l t | (l,t) <- zip ls ts] @@ -199,7 +205,7 @@ typeTok = Sort cTok typeStrs = Sort cStrs typeString, typeFloat, typeInt :: Term -typeInts :: Integer -> Term +typeInts :: Int -> Term typePBool :: Term typeError :: Term @@ -210,7 +216,7 @@ typeInts i = App (cnPredef cInts) (EInt i) typePBool = cnPredef cPBool typeError = cnPredef cErrorType -isTypeInts :: Term -> Maybe Integer +isTypeInts :: Term -> Maybe Int isTypeInts (App c (EInt i)) | c == cnPredef cInts = Just i isTypeInts _ = Nothing @@ -299,7 +305,7 @@ freshAsTerm s = Vr (varX (readIntArg s)) string2term :: String -> Term string2term = K -int2term :: Integer -> Term +int2term :: Int -> Term int2term = EInt float2term :: Double -> Term |
