mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
GFI: adapt to character encoding changes
GF.Compile.Coding is not used any more.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
module GF.Compile.Coding where
|
module GF.Compile.Coding where
|
||||||
|
{-
|
||||||
import GF.Grammar.Grammar
|
import GF.Grammar.Grammar
|
||||||
import GF.Grammar.Macros
|
import GF.Grammar.Macros
|
||||||
import GF.Text.Coding
|
import GF.Text.Coding
|
||||||
@@ -61,3 +61,4 @@ codeStringLiterals co ('"':cs) = '"' : inStringLiteral cs
|
|||||||
inStringLiteral ('\\':d:ds) = '\\' : co [d] ++ inStringLiteral ds
|
inStringLiteral ('\\':d:ds) = '\\' : co [d] ++ inStringLiteral ds
|
||||||
inStringLiteral (d:ds) = co [d] ++ inStringLiteral ds
|
inStringLiteral (d:ds) = co [d] ++ inStringLiteral ds
|
||||||
codeStringLiterals co (c:cs) = c : codeStringLiterals co cs
|
codeStringLiterals co (c:cs) = c : codeStringLiterals co cs
|
||||||
|
-}
|
||||||
@@ -24,9 +24,9 @@ import GF.Infra.UseIO(ioErrorText)
|
|||||||
import GF.Infra.SIO
|
import GF.Infra.SIO
|
||||||
import GF.Infra.Option
|
import GF.Infra.Option
|
||||||
import qualified System.Console.Haskeline as Haskeline
|
import qualified System.Console.Haskeline as Haskeline
|
||||||
import GF.Text.Coding(decodeUnicode,encodeUnicode)
|
--import GF.Text.Coding(decodeUnicode,encodeUnicode)
|
||||||
|
|
||||||
import GF.Compile.Coding(codeTerm)
|
--import GF.Compile.Coding(codeTerm)
|
||||||
|
|
||||||
import PGF
|
import PGF
|
||||||
import PGF.Data
|
import PGF.Data
|
||||||
@@ -35,9 +35,10 @@ import PGF.Macros
|
|||||||
import Data.Char
|
import Data.Char
|
||||||
import Data.List(nub,isPrefixOf,isInfixOf,partition)
|
import Data.List(nub,isPrefixOf,isInfixOf,partition)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import qualified Data.ByteString.Char8 as BS
|
--import qualified Data.ByteString.Char8 as BS
|
||||||
|
import qualified Data.ByteString.UTF8 as UTF8(fromString)
|
||||||
import qualified Text.ParserCombinators.ReadP as RP
|
import qualified Text.ParserCombinators.ReadP as RP
|
||||||
import System.IO(utf8)
|
--import System.IO(utf8)
|
||||||
--import System.CPUTime(getCPUTime)
|
--import System.CPUTime(getCPUTime)
|
||||||
import System.Directory({-getCurrentDirectory,-}getAppUserDataDirectory)
|
import System.Directory({-getCurrentDirectory,-}getAppUserDataDirectory)
|
||||||
import Control.Exception(SomeException,fromException,evaluate,try)
|
import Control.Exception(SomeException,fromException,evaluate,try)
|
||||||
@@ -183,18 +184,18 @@ execute1 opts gfenv0 s0 =
|
|||||||
"-old":ws' -> (False,ws')
|
"-old":ws' -> (False,ws')
|
||||||
_ -> (flag optNewComp opts,ws)
|
_ -> (flag optNewComp opts,ws)
|
||||||
|
|
||||||
case runP pExp (encodeUnicode utf8 s) of
|
case runP pExp (UTF8.fromString s) of
|
||||||
Left (_,msg) -> putStrLn msg
|
Left (_,msg) -> putStrLn msg
|
||||||
Right t -> putStrLn . err id (showTerm sgr style q)
|
Right t -> putStrLn . err id (showTerm sgr style q)
|
||||||
. checkComputeTerm' new sgr
|
. checkComputeTerm' new sgr
|
||||||
$ codeTerm (decodeUnicode utf8 . BS.pack) t
|
$ {-codeTerm (decodeUnicode utf8 . BS.pack)-} t
|
||||||
continue gfenv
|
continue gfenv
|
||||||
|
|
||||||
show_deps ws = do
|
show_deps ws = do
|
||||||
let (os,xs) = partition (isPrefixOf "-") ws
|
let (os,xs) = partition (isPrefixOf "-") ws
|
||||||
ops <- case xs of
|
ops <- case xs of
|
||||||
_:_ -> do
|
_:_ -> do
|
||||||
let ts = [t | Right t <- map (runP pExp . encodeUnicode utf8) xs]
|
let ts = [t | Right t <- map (runP pExp . UTF8.fromString) xs]
|
||||||
err error (return . nub . concat) $ mapM (constantDepsTerm sgr) ts
|
err error (return . nub . concat) $ mapM (constantDepsTerm sgr) ts
|
||||||
_ -> error "expected one or more qualified constants as argument"
|
_ -> error "expected one or more qualified constants as argument"
|
||||||
let prTerm = showTerm sgr TermPrintDefault Qualified
|
let prTerm = showTerm sgr TermPrintDefault Qualified
|
||||||
@@ -217,7 +218,7 @@ execute1 opts gfenv0 s0 =
|
|||||||
let isRaw = elem "-raw" os
|
let isRaw = elem "-raw" os
|
||||||
ops <- case ts of
|
ops <- case ts of
|
||||||
_:_ -> do
|
_:_ -> do
|
||||||
let Right t = runP pExp (encodeUnicode utf8 (unwords ts))
|
let Right t = runP pExp (UTF8.fromString (unwords ts))
|
||||||
ty <- err error return $ checkComputeTerm sgr t
|
ty <- err error return $ checkComputeTerm sgr t
|
||||||
return $ allOpersTo sgr ty
|
return $ allOpersTo sgr ty
|
||||||
_ -> return $ allOpers sgr
|
_ -> return $ allOpers sgr
|
||||||
|
|||||||
Reference in New Issue
Block a user