forked from GitHub/gf-core
Some more ByteString related chandes in GF2
This commit is contained in:
@@ -44,6 +44,7 @@ import GF.Infra.ReadFiles ----
|
|||||||
|
|
||||||
import Data.Char (toUpper)
|
import Data.Char (toUpper)
|
||||||
import Data.List (nub)
|
import Data.List (nub)
|
||||||
|
import qualified Data.ByteString.Char8 as BS
|
||||||
import Control.Monad (foldM)
|
import Control.Monad (foldM)
|
||||||
import System (system)
|
import System (system)
|
||||||
|
|
||||||
@@ -61,14 +62,14 @@ getSourceModule opts file0 = do
|
|||||||
let string = case getOptVal opts uniCoding of
|
let string = case getOptVal opts uniCoding of
|
||||||
Just "utf8" -> decodeUTF8 string0
|
Just "utf8" -> decodeUTF8 string0
|
||||||
_ -> string0
|
_ -> string0
|
||||||
let tokens = myLexer string
|
let tokens = myLexer (BS.pack string)
|
||||||
mo1 <- ioeErr $ err2err $ pModDef tokens
|
mo1 <- ioeErr $ err2err $ pModDef tokens
|
||||||
ioeErr $ transModDef mo1
|
ioeErr $ transModDef mo1
|
||||||
|
|
||||||
getSourceGrammar :: Options -> FilePath -> IOE SourceGrammar
|
getSourceGrammar :: Options -> FilePath -> IOE SourceGrammar
|
||||||
getSourceGrammar opts file = do
|
getSourceGrammar opts file = do
|
||||||
string <- readFileIOE file
|
string <- readFileIOE file
|
||||||
let tokens = myLexer string
|
let tokens = myLexer (BS.pack string)
|
||||||
gr1 <- ioeErr $ err2err $ pGrammar tokens
|
gr1 <- ioeErr $ err2err $ pGrammar tokens
|
||||||
ioeErr $ transGrammar gr1
|
ioeErr $ transGrammar gr1
|
||||||
|
|
||||||
@@ -117,7 +118,7 @@ ioeEErr = ioeErr . err2err
|
|||||||
-- change them by turning the final letter to upper case.
|
-- change them by turning the final letter to upper case.
|
||||||
--- There is a risk of clash.
|
--- There is a risk of clash.
|
||||||
oldLexer :: String -> [L.Token]
|
oldLexer :: String -> [L.Token]
|
||||||
oldLexer = map change . L.tokens where
|
oldLexer = map change . L.tokens . BS.pack where
|
||||||
change t = case t of
|
change t = case t of
|
||||||
(L.PT p (L.TS s)) | elem s newReservedWords ->
|
(L.PT p (L.TS s)) | elem s newReservedWords ->
|
||||||
(L.PT p (L.TV (init s ++ [toUpper (last s)])))
|
(L.PT p (L.TV (init s ++ [toUpper (last s)])))
|
||||||
|
|||||||
@@ -29,10 +29,11 @@ import GF.Grammar.Macros
|
|||||||
import GF.Grammar.MMacros
|
import GF.Grammar.MMacros
|
||||||
|
|
||||||
import GF.Data.Operations
|
import GF.Data.Operations
|
||||||
|
import qualified Data.ByteString.Char8 as BS
|
||||||
|
|
||||||
pTerm :: String -> Err Term
|
pTerm :: String -> Err Term
|
||||||
pTerm s = do
|
pTerm s = do
|
||||||
e <- err2err $ pExp $ myLexer s
|
e <- err2err $ pExp $ myLexer (BS.pack s)
|
||||||
transExp e
|
transExp e
|
||||||
|
|
||||||
pTrm :: String -> Term
|
pTrm :: String -> Term
|
||||||
|
|||||||
Reference in New Issue
Block a user