Changeset 12769
- Timestamp:
- 31.10.2009 15:48:41 (3 weeks ago)
- Files:
-
- 1 modified
-
trunk/Isabelle/Translate.hs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Isabelle/Translate.hs
r12021 r12769 18 18 , getConstIsaToks ) where 19 19 20 import Common.AS_Annotation 21 import Common.GlobalAnnotations 20 22 import Common.Id 21 23 import Common.ProofUtils 22 import Common. GlobalAnnotations23 import Common.AS_Annotation24 import Common.Utils 25 import qualified Common.Lib.Rel as Rel 24 26 25 27 import qualified Data.Map as Map 26 28 import qualified Data.Set as Set 27 import qualified Common.Lib.Rel as Rel 29 28 30 import Data.Char 31 import Data.Maybe 29 32 import Data.List 30 33 … … 100 103 atoks@(hd : tl) = getAltTokenList newPlace over i thy 101 104 compoundToks = map (: []) ",[]{}" 102 convert = \ Token { tokStr = s } ->105 convert Token { tokStr = s } = 103 106 if elem s $ newPlace : compoundToks then s else br ++ quote s 104 107 tts = concatMap convert tl … … 146 149 mkIsaConstT :: Bool -> GlobalAnnos -> Int -> Id -> BaseSig -> Set.Set String 147 150 -> VName 148 mkIsaConstT prd ga n ide = mkIsaConstVName 0 showIsaConstT prd ga n ide151 mkIsaConstT = mkIsaConstVName 0 showIsaConstT 149 152 150 153 mkIsaConstVName :: Int -> (Id -> BaseSig -> String) -> Bool -> GlobalAnnos … … 180 183 181 184 getConstIsaToksAux :: Id -> Int -> BaseSig -> Set.Set String 182 getConstIsaToksAux ide i thy=185 getConstIsaToksAux ide i = 183 186 foldr (Set.insert . tokStr) 184 Set.empty $ getAltTokenList "" i ide thy187 Set.empty . getAltTokenList "" i ide 185 188 186 189 transIsaStringT :: Map.Map BaseSig (Set.Set String) -> BaseSig 187 190 -> String -> String 188 191 transIsaStringT m i s = let t = transStringAux False s in 189 if Set.member t $ maybe (error "Isabelle.transIsaStringT") id192 if Set.member t $ fromMaybe (error "Isabelle.transIsaStringT") 190 193 $ Map.lookup i m 191 then transIsaStringT m i $ "_" ++s else t194 then transIsaStringT m i $ '_' : s else t 192 195 193 196 transConstStringT :: BaseSig -> String -> String … … 217 220 c : s -> let l = replaceChar1 c in 218 221 (if isDigit c || elem c "_'" then [x, c] 219 else l) ++ concatMap replaceChar1 s 222 else l) ++ concatMap replaceChar1 223 (if b then replace "' '" "'Space'" s else s) 220 224 221 225 -- | injective replacement of special characters … … 224 228 replaceChar c = if isIsaChar c then [c] else let n = ord c in 225 229 if n <= 32 || n >= 127 && n < 160 || n > 255 then "Slash_" ++ show n 226 else maybe (error "Isabelle.replaceChar") id$ Map.lookup c charMap230 else fromMaybe (error "Isabelle.replaceChar") $ Map.lookup c charMap