Commit 39775165 authored by Michael Hanus 's avatar Michael Hanus
Browse files

Option processing for CASS improved, the server mode now requires the explicit...

Option processing for CASS improved, the server mode now requires the explicit option -s or --server
parent dfa36144
......@@ -5,10 +5,10 @@
--- to use the analysis system in another Curry program.
---
--- @author Heiko Hoffmann, Michael Hanus
--- @version May 2015
--- @version June 2016
--------------------------------------------------------------------------
module AnalysisServer(main, initializeAnalysisSystem, analyzeModuleAsText,
module AnalysisServer(mainServer, initializeAnalysisSystem, analyzeModuleAsText,
analyzeModuleForBrowser, analyzeFunctionForBrowser,
analyzeGeneric, analyzePublic, analyzeInterface)
where
......@@ -38,60 +38,10 @@ data AnalysisServerMessage =
| SetCurryPath String
| ParseError
--- Main function to start the server.
--- Without any program arguments, the server is started on a socket.
--- Otherwise, it is started in batch mode to analyze a module.
main :: IO ()
main = do
debugMessage 1 systemBanner
initializeAnalysisSystem
args <- getArgs
processArgs False args
processArgs :: Bool -> [String] -> IO ()
processArgs enforce args = case args of
[] -> mainServer Nothing
["-p",port] -> maybe showError
(\ (p,r) -> if all isSpace r
then mainServer (Just p)
else showError )
(readNat port)
["-h"] -> showHelp
["-?"] -> showHelp
["--help"] -> showHelp
("-r":rargs) -> processArgs True rargs
(('-':'D':kvs):rargs) -> let (key,eqvalue) = break (=='=') kvs
in if null eqvalue
then showError
else do updateCurrentProperty key (tail eqvalue)
processArgs enforce rargs
[ananame,mname] ->
if ananame `elem` registeredAnalysisNames
then analyzeModuleAsText ananame (stripSuffix mname) enforce >>= putStrLn
else showError
_ -> showError
where
showError =
error ("Illegal arguments (use '--help' for description):\n"++unwords args)
--- Initializations to be done when the system is started.
initializeAnalysisSystem :: IO ()
initializeAnalysisSystem = updateRCFile
showHelp :: IO ()
showHelp = putStrLn $
"Usage: cass <options> [-p <port>] :\n" ++
" start analysis system in server mode\n\n"++
" <port>: port number for communication\n" ++
" (if omitted, a free port number is selected)\n\n"++
"Usage: cass <options> <analysis name> <module name> :\n"++
" analyze a module with a given analysis\n\n"++
"where <options> can contain:\n"++
"-Dname=val : set property (of ~/.curryanalysisrc) 'name' as 'val'\n"++
"-r : force re-analysis (i.e., ignore old analysis information)\n"++
"\nRegistered analyses names:\n" ++
unlines registeredAnalysisNames
--- Start the analysis server on a socket.
mainServer :: Maybe Int -> IO ()
mainServer mbport = do
......
......@@ -29,7 +29,7 @@ import Char(isSpace)
systemBanner :: String
systemBanner =
let bannerText = "CASS: Curry Analysis Server System ("++
"version of 20/01/2015 for "++curryCompiler++")"
"version of 17/06/2016 for "++curryCompiler++")"
bannerLine = take (length bannerText) (repeat '=')
in bannerLine ++ "\n" ++ bannerText ++ "\n" ++ bannerLine
......
......@@ -10,11 +10,7 @@ ANADIR = ../analysis
TOOL = $(BINDIR)/cass
# Source modules of CASS:
DEPS = Analysis.curry AnalysisCollection.curry AnalysisDependencies.curry \
AnalysisServer.curry AnalysisWorker.curry Configuration.curry \
CurryFiles.curry FlatCurryDependency.curry GenericProgInfo.curry \
LoadAnalysis.curry ServerFormats.curry \
ServerFunctions.curry WorkerFunctions.curry \
DEPS = *.curry \
$(LIBDIR)/Distribution.curry $(LIBDIR)/PropertyFile.curry \
$(LIBDIR)/FlatCurry/*.curry $(LIBDIR)/SCC.curry $(ANADIR)/*.curry
......@@ -42,8 +38,8 @@ cass_worker: $(DEPS)
# generate executable for analysis server program:
cass: $(DEPS)
$(REPL) $(REPL_OPTS) :set path $(ANADIR) :l AnalysisServer :save :q
mv AnalysisServer $@
$(REPL) $(REPL_OPTS) :set path $(ANADIR) :l Main :save :q
mv Main $@
# load the analysis server program into the Curry system:
.PHONY: load
......
......@@ -39,8 +39,8 @@ lub Top _ = Top
demandAnalysis :: Analysis DemandedArgs
demandAnalysis = dependencyFuncAnalysis "Demand" [1..] daFunc
-- An operation is non-deterministic if it has an overlapping definition.
-- or if it calls a non-deterministic operation.
-- We define the demanded arguments of some primitive prelude operations.
-- Otherwise, we analyse the right-hand sides of the rule.
daFunc :: FuncDecl -> [(QName,DemandedArgs)] -> DemandedArgs
daFunc (Func (m,f) _ _ _ rule) calledFuncs
| f `elem` prelude2s && m==prelude = [1,2]
......
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