summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Compile/Compute/AppPredefined.hs
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2011-06-02 16:10:46 +0000
committeraarne <aarne@chalmers.se>2011-06-02 16:10:46 +0000
commita3924abece87303a26ab8066cbf0509976864a48 (patch)
tree05ca8bcb9b2269cac04fa265854fc3b92ca2f4e3 /src/compiler/GF/Compile/Compute/AppPredefined.hs
parentd9ccb26c9891f296e95af531ec2473c3f4dd732a (diff)
Predef functions toUpper, toLower, isUpper
Diffstat (limited to 'src/compiler/GF/Compile/Compute/AppPredefined.hs')
-rw-r--r--src/compiler/GF/Compile/Compute/AppPredefined.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/compiler/GF/Compile/Compute/AppPredefined.hs b/src/compiler/GF/Compile/Compute/AppPredefined.hs
index bbc28a05e..8cde4e39e 100644
--- a/src/compiler/GF/Compile/Compute/AppPredefined.hs
+++ b/src/compiler/GF/Compile/Compute/AppPredefined.hs
@@ -26,6 +26,7 @@ import GF.Grammar.Predef
import qualified Data.Map as Map
import qualified Data.ByteString.Char8 as BS
import Text.PrettyPrint
+import Data.Char (isUpper,toUpper,toLower)
-- predefined function type signatures and definitions. AR 12/3/2003.
@@ -67,6 +68,11 @@ primitives = Map.fromList
, (cEqStr , ResOper (Just (noLoc (mkFunType [typeTok,typeTok] typePBool))) Nothing)
, (cOccur , ResOper (Just (noLoc (mkFunType [typeTok,typeTok] typePBool))) Nothing)
, (cOccurs , ResOper (Just (noLoc (mkFunType [typeTok,typeTok] typePBool))) Nothing)
+
+ , (cToUpper , ResOper (Just (noLoc (mkFunType [typeTok] typeTok))) Nothing)
+ , (cToLower , ResOper (Just (noLoc (mkFunType [typeTok] typeTok))) Nothing)
+ , (cIsUpper , ResOper (Just (noLoc (mkFunType [typeTok] typePBool))) Nothing)
+
---- "read" ->
, (cRead , ResOper (Just (noLoc (mkProd -- (P : Type) -> Tok -> P
[(Explicit,varP,typePType),(Explicit,identW,typeStr)] (Vr varP) []))) Nothing)
@@ -94,7 +100,11 @@ appPredefined t = case t of
-- one-place functions
Q (mod,f) | mod == cPredef ->
case x of
- (K s) | f == cLength -> retb $ EInt $ length s
+ (K s) | f == cLength -> retb $ EInt $ length s
+ (K s) | f == cIsUpper -> retb $ if (all isUpper s) then predefTrue else predefFalse
+ (K s) | f == cToUpper -> retb $ K $ map toUpper s
+ (K s) | f == cToLower -> retb $ K $ map toLower s
+
_ -> retb t
-- two-place functions