diff --git a/src/GF/API.hs b/src/GF/API.hs index 2fc562c1c..f8006032d 100644 --- a/src/GF/API.hs +++ b/src/GF/API.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/03/08 15:31:22 $ +-- > CVS $Date: 2005/03/08 15:49:24 $ -- > CVS $Author: bringert $ --- > CVS $Revision: 1.28 $ +-- > CVS $Revision: 1.29 $ -- -- Application Programmer's Interface to GF; also used by Shell. AR 10/11/2001 ----------------------------------------------------------------------------- @@ -298,20 +298,21 @@ optPrintGrammar :: Options -> StateGrammar -> String optPrintGrammar opts = customOrDefault opts grammarPrinter customGrammarPrinter optPrintMultiGrammar :: Options -> CanonGrammar -> String -optPrintMultiGrammar opts = pmg . encodeId . encode +optPrintMultiGrammar opts = encodeId . pmg . encode where pmg = customOrDefault opts grammarPrinter customMultiGrammarPrinter -- if -utf8 was given, convert from language specific codings encode = if oElem useUTF8 opts then mapModules moduleToUTF8 else id -- if -utf8id was given, convert identifiers to UTF8 - encodeId = if oElem useUTF8id opts then grammarIdentsToUTF8 else id +-- encodeId = if oElem useUTF8id opts then grammarIdentsToUTF8 else id + encodeId = if oElem useUTF8id opts then nonLiteralsToUTF8 else id moduleToUTF8 m = m{ jments = mapTree (onSnd (mapInfoTerms code)) (jments m), flags = setFlag "coding" "utf8" (flags m) } where code = onTokens (anyCodingToUTF8 (moduleOpts m)) moduleOpts = Opts . okError . mapM CG.redFlag . flags - grammarIdentsToUTF8 mgr - = MGrammar [ (identToUTF8 i, mapIdents identToUTF8 mi) | (i,mi) <- modules mgr] +-- grammarIdentsToUTF8 mgr +-- = MGrammar [ (identToUTF8 i, mapIdents identToUTF8 mi) | (i,mi) <- modules mgr] optPrintSyntax :: Options -> GF.Grammar -> String optPrintSyntax opts = customOrDefault opts grammarPrinter customSyntaxPrinter @@ -370,20 +371,24 @@ anyCodingToUTF8 :: Options -> String -> String anyCodingToUTF8 opts = encodeUTF8 . customOrDefault opts uniCoding customUniCoding -{- + -- | Convert all text not inside double quotes to UTF8 nonLiteralsToUTF8 :: String -> String nonLiteralsToUTF8 "" = "" nonLiteralsToUTF8 ('"':cs) = '"' : l ++ nonLiteralsToUTF8 rs - where (l,rs) = takeStringLit cs -nonLiteralsToUTF8 (c:cs) = encodeUTF8 [c] : nonLiteralsToUTF8 cs - where - -- | Split off an initial string ended by double quotes - takeStringLit :: String -> (String,String) - takeStringLit "" = ("","") - takeStringLit --} + where + (l,rs) = takeStringLit cs + -- | Split off an initial string ended by double quotes + takeStringLit :: String -> (String,String) + takeStringLit "" = ("","") + takeStringLit ('"':cs) = (['"'],cs) + takeStringLit ('\\':'"':cs) = ('\\':'"':xs,ys) + where (xs,ys) = takeStringLit cs + takeStringLit (c:cs) = (c:xs,ys) + where (xs,ys) = takeStringLit cs +nonLiteralsToUTF8 (c:cs) = encodeUTF8 [c] ++ nonLiteralsToUTF8 cs +{- -- | Convert an identifier in unicode to UTF8 encoding identToUTF8 :: I.Ident -> I.Ident identToUTF8 i = case i of @@ -392,3 +397,4 @@ identToUTF8 i = case i of I.IV (i,s) -> I.IV (i, encodeUTF8 s) I.IA (s,i) -> I.IA (encodeUTF8 s, i) I.IAV (s,i1,i2) -> I.IAV (encodeUTF8 s, i2, i2) +-} \ No newline at end of file diff --git a/src/GF/Canon/GFC.hs b/src/GF/Canon/GFC.hs index c29e77c73..54b905ca5 100644 --- a/src/GF/Canon/GFC.hs +++ b/src/GF/Canon/GFC.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/03/08 15:31:22 $ +-- > CVS $Date: 2005/03/08 15:49:24 $ -- > CVS $Author: bringert $ --- > CVS $Revision: 1.8 $ +-- > CVS $Revision: 1.9 $ -- -- canonical GF. AR 10\/9\/2002 -- 9\/5\/2003 -- 21\/9 ----------------------------------------------------------------------------- @@ -20,8 +20,8 @@ module GFC (Context, Info(..), Printname, mapInfoTerms, - setFlag, - mapIdents + setFlag +-- , mapIdents ) where import AbsGFC @@ -71,6 +71,7 @@ mapInfoTerms f i = case i of setFlag :: String -> String -> [Flag] -> [Flag] setFlag n v fs = Flg (IC n) (IC v):[f | f@(Flg (IC n') _) <- fs, n' /= n] +{- -- | Apply a function to all identifiers in a module mapIdents :: (Ident -> Ident) -> M.ModInfo Ident Flag Info -> M.ModInfo Ident Flag Info mapIdents f mi = case mi of @@ -156,6 +157,7 @@ mapIdents f mi = case mi of fav av = case av of A i x -> A (f i) x AB i x y -> AB (f i) x y +-} {- fat :: A.Term -> A.Term fat t = case t of