From dea5158cbf1c11d45f2ed91d9975fbc77245e652 Mon Sep 17 00:00:00 2001 From: aarne Date: Fri, 2 Dec 2005 13:13:14 +0000 Subject: floats in GF and GFC (parsing user input still doesn't work) --- src/GF/Compile/CheckGrammar.hs | 4 ++++ src/GF/Compile/GrammarToCanon.hs | 6 ++++-- src/GF/Compile/Rename.hs | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/GF/Compile') diff --git a/src/GF/Compile/CheckGrammar.hs b/src/GF/Compile/CheckGrammar.hs index c46c51af7..14d4f9b93 100644 --- a/src/GF/Compile/CheckGrammar.hs +++ b/src/GF/Compile/CheckGrammar.hs @@ -279,6 +279,7 @@ computeLType gr t = do App (Q (IC "Predef") (IC "Ints")) _ -> return ty ---- shouldn't be needed Q (IC "Predef") (IC "Int") -> return ty ---- shouldn't be needed + Q (IC "Predef") (IC "Float") -> return ty ---- shouldn't be needed Q m c | elem c [cPredef,cPredefAbs] -> return ty @@ -416,6 +417,8 @@ inferLType gr trm = case trm of EInt i -> return (trm, typeInt) + EFloat i -> return (trm, typeFloat) + Empty -> return (trm, typeTok) C s1 s2 -> @@ -508,6 +511,7 @@ inferLType gr trm = case trm of PT _ p -> isConstPatt p PString _ -> True PInt _ -> True + PFloat _ -> True _ -> False inferPatt p = case p of diff --git a/src/GF/Compile/GrammarToCanon.hs b/src/GF/Compile/GrammarToCanon.hs index d5b52d062..de6427e82 100644 --- a/src/GF/Compile/GrammarToCanon.hs +++ b/src/GF/Compile/GrammarToCanon.hs @@ -231,7 +231,8 @@ redCTerm t = case t of return $ G.V ty' ts' S u v -> liftM2 G.S (redCTerm u) (redCTerm v) K s -> return $ G.K (G.KS s) - EInt i -> return $ G.EInt $ toInteger i + EInt i -> return $ G.EInt i + EFloat i -> return $ G.EFloat i C u v -> liftM2 G.C (redCTerm u) (redCTerm v) FV ts -> liftM G.FV $ mapM redCTerm ts --- Ready ss -> return $ G.Ready [redStr ss] --- obsolete @@ -259,7 +260,8 @@ redPatt p = case p of ts <- mapM redPatt tts return $ G.PR $ map (uncurry G.PAss) $ zip ls' ts PT _ q -> redPatt q - PInt i -> return $ G.PI (toInteger i) + PInt i -> return $ G.PI i + PFloat i -> return $ G.PF i PV x -> liftM G.PV $ redIdent x --- for parametrize optimization _ -> prtBad "cannot reduce pattern" p diff --git a/src/GF/Compile/Rename.hs b/src/GF/Compile/Rename.hs index d38b897a7..70451a25a 100644 --- a/src/GF/Compile/Rename.hs +++ b/src/GF/Compile/Rename.hs @@ -94,6 +94,7 @@ renameIdentTerm env@(act,imps) t = -- this facility is mainly for BWC with GF1: you need not import PredefAbs predefAbs c s = case c of IC "Int" -> return $ const $ Q cPredefAbs cInt + IC "Float" -> return $ const $ Q cPredefAbs cFloat IC "String" -> return $ const $ Q cPredefAbs cString _ -> Bad s -- cgit v1.2.3