mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-12-17 21:11:35 +03:00
Add support for comments; panic on completely bogus inputs.
Note that we still do not check for errors in commands, perhaps we should?
This commit is contained in:
parent
affcc25156
commit
b5d6715b21
@ -45,6 +45,7 @@ import MonadLib
|
|||||||
import Data.Maybe ( fromMaybe )
|
import Data.Maybe ( fromMaybe )
|
||||||
import Data.Map (Map)
|
import Data.Map (Map)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
|
import Data.Char(isSpace)
|
||||||
import Data.Foldable ( any, all )
|
import Data.Foldable ( any, all )
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import Data.IORef ( IORef, newIORef, readIORef, modifyIORef',
|
import Data.IORef ( IORef, newIORef, readIORef, modifyIORef',
|
||||||
@ -287,11 +288,20 @@ data Solver = Solver
|
|||||||
loadFile :: Solver -> FilePath -> IO ()
|
loadFile :: Solver -> FilePath -> IO ()
|
||||||
loadFile s file = do -- txt <- readFile file
|
loadFile s file = do -- txt <- readFile file
|
||||||
-- mapM_ putStrLn (lines txt)
|
-- mapM_ putStrLn (lines txt)
|
||||||
go =<< readFile file
|
go . dropComments =<< readFile file
|
||||||
where
|
where
|
||||||
go txt = case SMT.readSExpr txt of
|
go txt
|
||||||
Just (e,rest) -> SMT.command (solver s) e >> go rest
|
| all isSpace txt = return ()
|
||||||
Nothing -> return ()
|
| otherwise = case SMT.readSExpr txt of
|
||||||
|
Just (e,rest) -> SMT.command (solver s) e >> go rest
|
||||||
|
Nothing -> panic "loadFile" [ "Failed to parse SMT file."
|
||||||
|
, txt
|
||||||
|
]
|
||||||
|
|
||||||
|
dropComments = unlines . map dropComment . lines
|
||||||
|
dropComment xs = case break (== ';') xs of
|
||||||
|
(as,_:_) -> as
|
||||||
|
_ -> xs
|
||||||
|
|
||||||
rawSolver :: Solver -> SMT.Solver
|
rawSolver :: Solver -> SMT.Solver
|
||||||
rawSolver = solver
|
rawSolver = solver
|
||||||
|
Loading…
Reference in New Issue
Block a user