Commit eab027ca authored by Michael Hanus 's avatar Michael Hanus

Option `optFrontendParams` added which is used to read FlatCurry programs

parent a8c641f0
......@@ -13,6 +13,7 @@
"execpath" : ">= 3.0.0, < 4.0.0",
"filepath" : ">= 3.0.0, < 4.0.0",
"flatcurry" : ">= 3.0.0, < 4.0.0",
"frontend-exec": ">= 3.0.0, < 4.0.0",
"graphviz" : ">= 3.0.0, < 4.0.0",
"io-extra" : ">= 3.0.0, < 4.0.0",
"process" : ">= 3.0.0, < 4.0.0",
......@@ -20,10 +21,6 @@
"transformers" : ">= 3.0.0, < 4.0.0",
"wl-pprint" : ">= 3.0.0, < 4.0.0"
},
"compilerCompatibility": {
"pakcs": ">= 3.0.0, < 4.0.0",
"kics2": ">= 3.0.0, < 4.0.0"
},
"exportedModules": [ "ICurry.Types", "ICurry.Files", "ICurry.Pretty",
"ICurry.Compiler", "ICurry.Interpreter",
"ICurry.Options" ],
......
......@@ -6,7 +6,7 @@
--- * remove declarations/assignments of unused variables in ICurry code
---
--- @author Michael Hanus
--- @version January 2021
--- @version March 2021
------------------------------------------------------------------------------
module ICurry.Compiler
......@@ -17,7 +17,7 @@ module ICurry.Compiler
import Control.Monad ( when )
import Data.List ( elemIndex, maximum )
import FlatCurry.Files ( readFlatCurry )
import FlatCurry.Files ( readFlatCurryWithParseOptions )
import FlatCurry.Goodies ( allVars, consName, funcName, funcVisibility
, progFuncs, progImports, progTypes )
import FlatCurry.Pretty ( defaultOptions, ppProg )
......@@ -44,7 +44,7 @@ test p = do
icCompile :: ICOptions -> String -> IO IProg
icCompile opts p = do
printStatus opts $ "Reading FlatCurry program '" ++ p ++ "'..."
prog <- readFlatCurry p
prog <- readFlatCurryWithParseOptions p (optFrontendParams opts)
flatCurry2ICurry opts prog
--- Translates a FlatCurry program into an ICurry program.
......@@ -54,7 +54,9 @@ flatCurry2ICurry :: ICOptions -> Prog -> IO IProg
flatCurry2ICurry opts prog = do
let impmods = progImports prog
printStatus opts $ "Reading imported FlatCurry modules: " ++ unwords impmods
impprogs <- mapM readFlatCurry impmods
impprogs <- mapM (\p -> readFlatCurryWithParseOptions p
(optFrontendParams opts))
impmods
let datadecls = concatMap dataDeclsOf (prog : impprogs)
ccprog = completeProg (CaseOptions datadecls) prog
clprog = if optLift opts
......
......@@ -2,7 +2,7 @@
--- Definition and processing of options for the ICurry compiler.
---
--- @author Michael Hanus
--- @version January 2021
--- @version March 2021
------------------------------------------------------------------------------
module ICurry.Options
......@@ -16,6 +16,7 @@ import FlatCurry.Types ( QName )
import ICurry.Types ( IArity )
import System.CurryPath ( currySubdir )
import System.Directory ( getAbsolutePath )
import System.FrontendExec ( FrontendParams, defaultParams, setQuiet )
import System.Process ( exitWith )
------------------------------------------------------------------------------
......@@ -33,6 +34,7 @@ data ICOptions = ICOptions
, optViewPDF :: String -- command to view graph PDF
, optInteractive :: Bool -- interactive execution?
, optVarDecls :: Bool -- optimize variable declarations?
, optFrontendParams :: FrontendParams
-- internal options
, optConsMap :: [(QName,(IArity,Int))] -- map: cons names to arity/position
, optFunMap :: [(QName,Int)] -- map: func names to module indices
......@@ -41,7 +43,8 @@ data ICOptions = ICOptions
defaultICOptions :: ICOptions
defaultICOptions =
ICOptions 1 False True "" "" False "evince" False False [] [] ("","")
ICOptions 1 False True "" "" False "evince" False False
(setQuiet True defaultParams) [] [] ("","")
-- Lookup arity and position index of a constructor.
arityPosOfCons :: ICOptions -> QName -> (IArity,Int)
......
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