forked from GitHub/gf-core
isOldFile should use the real lexer instead of "words" this avoids the need for custom unComm function
This commit is contained in:
@@ -37,6 +37,7 @@ import Data.List
|
|||||||
import System.Directory
|
import System.Directory
|
||||||
import qualified Data.ByteString.Char8 as BS
|
import qualified Data.ByteString.Char8 as BS
|
||||||
import GF.Source.AbsGF hiding (FileName)
|
import GF.Source.AbsGF hiding (FileName)
|
||||||
|
import GF.Source.LexGF
|
||||||
import GF.Source.ParGF
|
import GF.Source.ParGF
|
||||||
|
|
||||||
|
|
||||||
@@ -287,17 +288,6 @@ importsOfFile bs = do
|
|||||||
modName (PIdent (_,s)) = s
|
modName (PIdent (_,s)) = s
|
||||||
|
|
||||||
|
|
||||||
unComm s = case s of
|
|
||||||
'-':'-':cs -> unComm $ dropWhile (/='\n') cs
|
|
||||||
'{':'-':cs -> dpComm cs
|
|
||||||
c:cs -> c : unComm cs
|
|
||||||
_ -> s
|
|
||||||
|
|
||||||
dpComm s = case s of
|
|
||||||
'-':'}':cs -> unComm cs
|
|
||||||
c:cs -> dpComm cs
|
|
||||||
_ -> s
|
|
||||||
|
|
||||||
-- | options can be passed to the compiler by comments in @--#@, in the main file
|
-- | options can be passed to the compiler by comments in @--#@, in the main file
|
||||||
getOptionsFromFile :: FilePath -> IO Options
|
getOptionsFromFile :: FilePath -> IO Options
|
||||||
getOptionsFromFile file = do
|
getOptionsFromFile file = do
|
||||||
@@ -309,10 +299,10 @@ getOptionsFromFile file = do
|
|||||||
isOldFile :: FilePath -> IO Bool
|
isOldFile :: FilePath -> IO Bool
|
||||||
isOldFile f = do
|
isOldFile f = do
|
||||||
s <- readFileIfStrict f
|
s <- readFileIfStrict f
|
||||||
let s' = unComm (BS.unpack s)
|
let toks = myLexer s
|
||||||
return $ not (null s') && old (head (words s'))
|
return $ not (null toks) && old (head toks)
|
||||||
where
|
where
|
||||||
old = flip elem $ words
|
old (PT _ (TS t)) = elem t $ words
|
||||||
"cat category data def flags fun include lin lincat lindef lintype oper param pattern printname rule"
|
"cat category data def flags fun include lin lincat lindef lintype oper param pattern printname rule"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user