From 6313244eacf992fb10a5091bee28582e84540809 Mon Sep 17 00:00:00 2001 From: krasimir Date: Mon, 19 Apr 2010 09:38:36 +0000 Subject: use the native unicode support from GHC 6.12 --- src/compiler/GF/Compile/Coding.hs | 10 ++++++---- src/compiler/GF/Compile/PGFtoHaskell.hs | 3 +-- src/compiler/GF/Compile/PGFtoJS.hs | 3 +-- src/compiler/GF/Compile/PGFtoProlog.hs | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src/compiler/GF/Compile') diff --git a/src/compiler/GF/Compile/Coding.hs b/src/compiler/GF/Compile/Coding.hs index b909aac7d..01285eef1 100644 --- a/src/compiler/GF/Compile/Coding.hs +++ b/src/compiler/GF/Compile/Coding.hs @@ -8,12 +8,14 @@ import GF.Infra.Option import GF.Data.Operations import Data.Char +import System.IO +import qualified Data.ByteString.Char8 as BS -encodeStringsInModule :: SourceModule -> SourceModule -encodeStringsInModule = codeSourceModule (encodeUnicode UTF_8) +encodeStringsInModule :: TextEncoding -> SourceModule -> SourceModule +encodeStringsInModule enc = codeSourceModule (BS.unpack . encodeUnicode enc) -decodeStringsInModule :: SourceModule -> SourceModule -decodeStringsInModule mo = codeSourceModule (decodeUnicode (flag optEncoding (flagsModule mo))) mo +decodeStringsInModule :: TextEncoding -> SourceModule -> SourceModule +decodeStringsInModule enc mo = codeSourceModule (decodeUnicode enc . BS.pack) mo codeSourceModule :: (String -> String) -> SourceModule -> SourceModule codeSourceModule co (id,mo) = (id,replaceJudgements mo (mapTree codj (jments mo))) diff --git a/src/compiler/GF/Compile/PGFtoHaskell.hs b/src/compiler/GF/Compile/PGFtoHaskell.hs index 252fc95ee..ecc70cb5e 100644 --- a/src/compiler/GF/Compile/PGFtoHaskell.hs +++ b/src/compiler/GF/Compile/PGFtoHaskell.hs @@ -22,7 +22,6 @@ import PGF.Macros import GF.Data.Operations import GF.Infra.Option -import GF.Text.UTF8 import Data.List --(isPrefixOf, find, intersperse) import qualified Data.Map as Map @@ -34,7 +33,7 @@ grammar2haskell :: Options -> String -- ^ Module name. -> PGF -> String -grammar2haskell opts name gr = encodeUTF8 $ foldr (++++) [] $ +grammar2haskell opts name gr = foldr (++++) [] $ pragmas ++ haskPreamble name ++ [types, gfinstances gId lexical gr'] where gr' = hSkeleton gr gadt = haskellOption opts HaskellGADT diff --git a/src/compiler/GF/Compile/PGFtoJS.hs b/src/compiler/GF/Compile/PGFtoJS.hs index bb29ff7c5..f6725bf4f 100644 --- a/src/compiler/GF/Compile/PGFtoJS.hs +++ b/src/compiler/GF/Compile/PGFtoJS.hs @@ -6,7 +6,6 @@ import qualified PGF.Macros as M import qualified GF.JavaScript.AbsJS as JS import qualified GF.JavaScript.PrintJS as JS -import GF.Text.UTF8 import GF.Data.ErrM import GF.Infra.Option @@ -21,7 +20,7 @@ import qualified Data.IntMap as IntMap pgf2js :: PGF -> String pgf2js pgf = - encodeUTF8 $ JS.printTree $ JS.Program [JS.ElStmt $ JS.SDeclOrExpr $ JS.Decl [JS.DInit (JS.Ident n) grammar]] + JS.printTree $ JS.Program [JS.ElStmt $ JS.SDeclOrExpr $ JS.Decl [JS.DInit (JS.Ident n) grammar]] where n = showCId $ absname pgf as = abstract pgf diff --git a/src/compiler/GF/Compile/PGFtoProlog.hs b/src/compiler/GF/Compile/PGFtoProlog.hs index 3a5df0256..9e390e87b 100644 --- a/src/compiler/GF/Compile/PGFtoProlog.hs +++ b/src/compiler/GF/Compile/PGFtoProlog.hs @@ -15,7 +15,6 @@ import PGF.Data import PGF.Macros import GF.Data.Operations -import GF.Text.UTF8 import qualified Data.Map as Map import Data.Char (isAlphaNum, isAsciiLower, isAsciiUpper, ord) -- cgit v1.2.3