mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 17:12:50 -06:00
SimpleEditor.Convert: adapt to recent character encoding changes
Things got simpler!
This commit is contained in:
@@ -8,16 +8,10 @@ import qualified Data.Map as Map
|
|||||||
import Text.JSON(makeObj) --encode
|
import Text.JSON(makeObj) --encode
|
||||||
import Text.PrettyPrint(render,text,(<+>))
|
import Text.PrettyPrint(render,text,(<+>))
|
||||||
|
|
||||||
-- 4 extra imports just to deal with the ByteString mess...
|
import qualified Data.ByteString.UTF8 as UTF8(fromString)
|
||||||
import qualified Data.ByteString.Char8 as BS(pack)
|
|
||||||
import Codec.Binary.UTF8.String(encodeString)
|
|
||||||
import GF.Compile.Coding(decodeStringsInModule)
|
|
||||||
import System.IO(utf8)
|
|
||||||
|
|
||||||
--import GF.Compile.GetGrammar (getSourceModule)
|
|
||||||
import GF.Infra.Option(optionsGFO)
|
import GF.Infra.Option(optionsGFO)
|
||||||
import GF.Infra.Ident(showIdent)
|
import GF.Infra.Ident(showIdent)
|
||||||
--import GF.Infra.UseIO(appIOE)
|
|
||||||
import GF.Grammar.Grammar
|
import GF.Grammar.Grammar
|
||||||
import GF.Grammar.Printer(ppParams,ppTerm,getAbs,TermPrintQual(..))
|
import GF.Grammar.Printer(ppParams,ppTerm,getAbs,TermPrintQual(..))
|
||||||
import GF.Grammar.Parser(runP,pModDef)
|
import GF.Grammar.Parser(runP,pModDef)
|
||||||
@@ -31,10 +25,10 @@ import SimpleEditor.JSON
|
|||||||
|
|
||||||
parseModule (path,source) =
|
parseModule (path,source) =
|
||||||
(path.=) $
|
(path.=) $
|
||||||
case runP pModDef (BS.pack (encodeString source)) of
|
case runP pModDef (UTF8.fromString source) of
|
||||||
Left (Pn l c,msg) ->
|
Left (Pn l c,msg) ->
|
||||||
makeObj ["error".=msg, "location".= show l++":"++show c]
|
makeObj ["error".=msg, "location".= show l++":"++show c]
|
||||||
Right mod -> case convModule (decodeStringsInModule utf8 mod) of
|
Right mod -> case convModule mod of
|
||||||
Ok g -> makeObj ["converted".=g]
|
Ok g -> makeObj ["converted".=g]
|
||||||
Bad msg -> makeObj ["parsed".=msg]
|
Bad msg -> makeObj ["parsed".=msg]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user