Changeset 12769

Show
Ignore:
Timestamp:
31.10.2009 15:48:41 (3 weeks ago)
Author:
maeder
Message:

replace ' ' char to avoid duplicate axioms

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Isabelle/Translate.hs

    r12021 r12769  
    1818    , getConstIsaToks ) where 
    1919 
     20import Common.AS_Annotation 
     21import Common.GlobalAnnotations 
    2022import Common.Id 
    2123import Common.ProofUtils 
    22 import Common.GlobalAnnotations 
    23 import Common.AS_Annotation 
     24import Common.Utils 
     25import qualified Common.Lib.Rel as Rel 
    2426 
    2527import qualified Data.Map as Map 
    2628import qualified Data.Set as Set 
    27 import qualified Common.Lib.Rel as Rel 
     29 
    2830import Data.Char 
     31import Data.Maybe 
    2932import Data.List 
    3033 
     
    100103    atoks@(hd : tl) = getAltTokenList newPlace over i thy 
    101104    compoundToks = map (: []) ",[]{}" 
    102     convert = \ Token { tokStr = s } -> 
     105    convert Token { tokStr = s } = 
    103106      if elem s $ newPlace : compoundToks then s else br ++ quote s 
    104107    tts = concatMap convert tl 
     
    146149mkIsaConstT :: Bool -> GlobalAnnos -> Int -> Id -> BaseSig -> Set.Set String 
    147150            -> VName 
    148 mkIsaConstT prd ga n ide = mkIsaConstVName 0 showIsaConstT prd ga n ide 
     151mkIsaConstT = mkIsaConstVName 0 showIsaConstT 
    149152 
    150153mkIsaConstVName :: Int -> (Id -> BaseSig -> String) -> Bool -> GlobalAnnos 
     
    180183 
    181184getConstIsaToksAux :: Id -> Int -> BaseSig -> Set.Set String 
    182 getConstIsaToksAux ide i thy = 
     185getConstIsaToksAux ide i = 
    183186   foldr (Set.insert . tokStr) 
    184              Set.empty $ getAltTokenList "" i ide thy 
     187             Set.empty . getAltTokenList "" i ide 
    185188 
    186189transIsaStringT :: Map.Map BaseSig (Set.Set String) -> BaseSig 
    187190                -> String -> String 
    188191transIsaStringT m i s = let t = transStringAux False s in 
    189   if Set.member t $ maybe (error "Isabelle.transIsaStringT") id 
     192  if Set.member t $ fromMaybe (error "Isabelle.transIsaStringT") 
    190193         $ Map.lookup i m 
    191   then transIsaStringT m i $ "_" ++ s else t 
     194  then transIsaStringT m i $ '_' : s else t 
    192195 
    193196transConstStringT :: BaseSig -> String -> String 
     
    217220    c : s -> let l = replaceChar1 c in 
    218221             (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) 
    220224 
    221225-- | injective replacement of special characters 
     
    224228replaceChar c = if isIsaChar c then [c] else let n = ord c in 
    225229    if n <= 32 || n >= 127 && n < 160 || n > 255 then "Slash_" ++ show n 
    226     else maybe (error "Isabelle.replaceChar") id $ Map.lookup c charMap 
     230    else fromMaybe (error "Isabelle.replaceChar") $ Map.lookup c charMap