Commit 96d5f45a authored by Michael Hanus 's avatar Michael Hanus

Merge branch 'version3' into 'master'

Migrate to version 3

See merge request !2
parents 749300ce f6c58bb3
......@@ -17,6 +17,7 @@
module CPP.Contracts ( main, translateContracts )
where
import Control.Monad ( when, unless )
import Data.Char
import Language.Curry.Distribution ( installDir )
import System.Directory
......@@ -35,7 +36,9 @@ import Contract.Usage ( checkContractUsage )
import FlatCurry.Files ( readFlatCurry )
import qualified FlatCurry.Goodies as FCG
import System.CurryPath ( lookupModuleSourceInLoadPath, modNameToPath
, stripCurrySuffix)
, stripCurrySuffix )
import System.Environment ( getArgs )
import System.Process ( system )
-- in order to use the determinism analysis:
import Analysis.ProgInfo ( ProgInfo, lookupProgInfo )
......@@ -132,9 +135,9 @@ transformStandalone opts modname outfile = do
"Source code of module '"++modname++"' not found!"
Just (_,progname) -> readFile progname
let acyfile = abstractCurryFileName modname
doesFileExist acyfile >>= \b -> if b then removeFile acyfile else done
doesFileExist acyfile >>= \b -> if b then removeFile acyfile else return ()
prog <- readCurry modname
doesFileExist acyfile >>= \b -> if b then done
doesFileExist acyfile >>= \b -> if b then return ()
else error "Source program incorrect"
let outmodname = transformedModName modname
newprog <- transformCProg 1 opts modname srcprog prog outmodname
......@@ -151,7 +154,7 @@ loadIntoCurry :: String -> IO ()
loadIntoCurry m = do
putStrLn $ "\nStarting Curry system and loading module '"++m++"'..."
system $ installDir++"/bin/curry :l "++m
done
return ()
------------------------------------------------------------------------
--- The main transformation operation with parameters:
......
......@@ -42,6 +42,7 @@
module CPP.DefaultRules ( translateDefaultRulesAndDetOps )
where
import Control.Monad ( when, unless )
import Language.Curry.Distribution ( curryCompiler )
import System.FilePath ( takeDirectory )
import Data.List ( partition )
......@@ -137,7 +138,7 @@ printProofObligation :: [QName] -> IO ()
printProofObligation qfs = unless (null qfs) $ do
putStrLn line
putStrLn "PROOF OBLIGATIONS:"
mapIO_ (\qn -> putStrLn $ showQName qn ++" is a deterministic operation.") qfs
mapM_ (\qn -> putStrLn $ showQName qn ++" is a deterministic operation.") qfs
putStrLn line
where
line = take 70 (repeat '=')
......
......@@ -28,8 +28,11 @@
------------------------------------------------------------------------------
module FormatParser ( parse ) where
import Prelude hiding ( empty, (<*>) )
import Parser
import Data.Char
import Numeric ( readNat )
import Control.AllSolutions ( getOneSolution )
......
......@@ -22,7 +22,7 @@ module SQLConsistency(checkConsistency) where
import Data.Char ( toLower, toUpper )
import Data.List ( delete )
import Data.Map
import qualified Data.Map as Map
import ParseTypes
......
......@@ -15,6 +15,7 @@
module SQLConverter(parseSQL, readParserInfo, ParserInfo) where
import Control.Monad (when)
import System.IO (openFile, IOMode(..), hGetContents)
import ReadShowTerm (readsQTerm)
......
......@@ -21,7 +21,7 @@ where
import Data.Char ( toLower )
import Data.List ( partition )
import Data.Map
import qualified Data.Map as Map
--- Type synonyms for all parts of the parser information
type RelationFM = Map.Map String (Map.Map String [(String, RelationType)])
......
......@@ -7,9 +7,10 @@ module SQLScanner(scan) where
import Data.Char (isDigit, isAlpha, isAlphaNum, toLower)
import Data.List (splitOn)
import Data.Time (CalendarTime (..))
import ReadShowTerm (readsQTerm)
import Data.Map
import qualified Data.Map as Map
import SQLToken
......
......@@ -24,7 +24,7 @@ import Data.Char ( toLower, toUpper )
import Data.List ( isInfixOf )
import Data.Time
import Data.Map
import qualified Data.Map as Map
import ParseTypes
......
......@@ -8,7 +8,7 @@
module Symboltab where
import Data.Map
import qualified Data.Map as Map
--- A Symboltable consists of at least one pair of Maps.
--- There can be another table representing a surrounding scope.
......
......@@ -70,9 +70,9 @@ parsers = maybe iden pars
"format" -> FormatParser.parse "" p
"printf" -> FormatParser.parse "putStr" p
"regex" -> RegexParser.parse p
"html" -> liftIO (mapWarnsPM (addRealFname (getFilename p))) .
"html" -> fmap (mapWarnsPM (addRealFname (getFilename p))) .
MLTranslate.translate l p
"xml" -> liftIO (mapWarnsPM (addRealFname (getFilename p))) .
"xml" -> fmap (mapWarnsPM (addRealFname (getFilename p))) .
MLTranslate.translate l p
_ -> (\_ -> return $ throwPM p ("Bad langtag: " ++ l))
......@@ -242,7 +242,7 @@ applyLangParsers :: Either String ParserInfo
-> IO (PM [StandardToken])
applyLangParsers model iotks = do
prtks <- iotks
prpr <- swapIOPM (liftPM (mapIO (applyLangParser model)) prtks)
prpr <- swapIOPM (liftPM (mapM (applyLangParser model)) prtks)
return (crumplePM (liftPM (\prpt -> sequencePM prpt) prpr))
--- Select the right translator and apply it to a single StandardToken
......
......@@ -10,17 +10,20 @@
--- @version October 2019
------------------------------------------------------------------------------
import Control.Monad ( when )
import Data.Char ( isDigit, digitToInt, isSpace )
import Data.List
import System.Directory ( copyFile, renameFile )
import System.FilePath
import System
import AbstractCurry.Types
import AbstractCurry.Files
import AbstractCurry.Pretty ( showCProg )
import AbstractCurry.Select ( progName )
import System.CurryPath ( stripCurrySuffix )
import System.CPUTime ( getCPUTime )
import System.Environment ( getEnv, getArgs )
import System.Process ( exitWith )
import CPP.DefaultRules ( translateDefaultRulesAndDetOps )
import CPP.Contracts ( translateContracts )
......@@ -224,7 +227,7 @@ callPreprocessors opts optlines modname srcprog orgfile
let newsrcprog = maybe srcprog showCProg mbdefprog
if Contracts `elem` pptargets
then do
maybe done
maybe (return ())
(\defprog -> writeFile orgfile (optlines ++ showCProg defprog))
mbdefprog
readCurry modname >>= translateContracts verb contopts modname
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment