Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-frontend
Commits
7ba3efd7
Commit
7ba3efd7
authored
May 16, 2011
by
Björn Peemöller
Browse files
Compiler option handling refactored
parent
46b35559
Changes
4
Hide whitespace changes
Inline
Side-by-side
curry-frontend.cabal
View file @
7ba3efd7
...
...
@@ -12,9 +12,10 @@ Description: The Curry Frontend consists of the executable program "cymake".
Category: Language
License: OtherLicense
License-File: LICENSE
Author: Wolfgang Lux, Martin Engelke, Bernd Brassel, Holger Siegel
Maintainer: Holger Siegel
Bug-Reports: mailto:hsi@informatik.uni-kiel.de
Author: Wolfgang Lux, Martin Engelke, Bernd Brassel, Holger Siegel,
Bjoern Peemoeller
Maintainer: Bjoern Peemoeller
Bug-Reports: mailto:bjp@informatik.uni-kiel.de
Homepage: http://curry-language.org
Build-Type: Simple
Stability: experimental
...
...
src/CurryCompilerOpts.hs
View file @
7ba3efd7
...
...
@@ -6,13 +6,14 @@
May 2011 , refinements by Björn Peemöller (bjp@informatik.uni-kiel.de)
-}
module
CurryCompilerOpts
(
Options
(
..
),
Dump
(
..
),
parseOpts
,
printUsage
,
printVersion
,
defaultOptions
)
where
(
Options
(
..
),
Dump
(
..
),
defaultOptions
,
compilerOpts
,
usage
)
where
import
Data.List
(
nub
)
import
Data.Maybe
(
isJust
)
import
System.Console.GetOpt
import
System.Environment
(
getArgs
,
getProgName
)
import
Curry.Files.Filenames
(
currySubdir
)
import
Files.CymakePath
(
cymakeGreeting
)
-- |Data type for recording compiler options
data
Options
=
Options
...
...
@@ -167,12 +168,22 @@ parseOpts :: [String] -> (Options, [String], [String])
parseOpts
args
=
(
foldl
(
flip
(
$
))
defaultOptions
opts
,
files
,
errs
)
where
(
opts
,
files
,
errs
)
=
getOpt
Permute
options
args
-- |Check options and files and return a list of error messages
checkOpts
::
Options
->
[
String
]
->
[
String
]
checkOpts
opts
files
|
isJust
(
output
opts
)
&&
length
files
>
1
=
[
"cannot specify -o with multiple targets"
]
|
otherwise
=
[]
-- |Print the usage information of the command line tool.
printU
sage
::
String
->
IO
()
printU
sage
prog
=
putStrLn
$
usageInfo
header
options
u
sage
::
String
->
String
u
sage
prog
=
usageInfo
header
options
where
header
=
"usage: "
++
prog
++
" [OPTION] ... MODULE ..."
-- |Print the program greeting
printVersion
::
IO
()
printVersion
=
putStrLn
cymakeGreeting
compilerOpts
::
IO
(
String
,
Options
,
[
String
],
[
String
])
compilerOpts
=
do
args
<-
getArgs
prog
<-
getProgName
let
(
opts
,
files
,
errs
)
=
parseOpts
args
return
(
prog
,
opts
,
files
,
errs
++
checkOpts
opts
files
)
src/Gen/GenFlatCurry.hs
View file @
7ba3efd7
...
...
@@ -25,7 +25,7 @@ import Base (ModuleEnv, TCEnv, ValueEnv, TypeInfo (..), ValueInfo (..)
,
lookupValue
,
qualLookupTC
,
qualLookupValue
,
ArityEnv
,
ArityInfo
(
..
)
,
lookupArity
,
qualLookupArity
)
import
CurryCompilerOpts
import
CurryCompilerOpts
(
Options
(
..
))
import
qualified
CurryToIL
as
IL
import
Env.TopEnv
(
topEnvMap
)
import
Env.CurryEnv
(
CurryEnv
)
...
...
src/cymake.hs
View file @
7ba3efd7
...
...
@@ -8,49 +8,43 @@
-}
module
Main
(
main
)
where
import
Data.Maybe
(
isJust
)
import
System.Environment
(
getArgs
,
getProgName
)
import
CurryBuilder
(
buildCurry
)
import
CurryCompilerOpts
(
Options
(
..
),
parseOpts
,
printUsage
,
printVersion
)
import
CurryCompilerOpts
(
Options
(
..
),
compilerOpts
,
usage
)
import
Files.CymakePath
(
cymakeGreeting
)
import
Html.CurryHtml
(
source2html
)
import
Messages
(
info
,
putErrsLn
,
abortWith
)
import
Messages
(
putErrsLn
,
abortWith
)
-- |The command line tool cymake
main
::
IO
()
main
=
do
prog
<-
getProgName
args
<-
getArgs
cymake
prog
(
parseOpts
args
)
main
=
compilerOpts
>>=
cymake
-- |Check the command line arguments and invoke the curry builder
cymake
::
String
->
(
Options
,
[
String
],
[
String
])
->
IO
()
cymake
prog
(
opts
,
files
,
errs
)
|
help
opts
=
printUsage
prog
|
version
opts
=
printVersion
|
null
files
=
printUsage
prog
|
not
(
null
errs'
)
=
badUsage
prog
errs'
|
html
opts
=
mapM_
(
source2html
opts
)
files
|
otherwise
=
info
opts
cymakeGreeting
>>
mapM_
(
buildCurry
opts'
)
files
cymake
::
(
String
,
Options
,
[
String
],
[
String
])
->
IO
()
cymake
(
prog
,
opts
,
files
,
errs
)
|
help
opts
=
printUsage
prog
|
version
opts
=
printVersion
|
null
files
=
printUsage
prog
|
not
(
null
errs
)
=
badUsage
prog
errs
|
html
opts
=
mapM_
(
source2html
opts
)
files
|
otherwise
=
mapM_
(
buildCurry
opts'
)
files
where
opts'
=
if
or
[
flat
opts
,
flatXml
opts
,
abstract
opts
,
untypedAbstract
opts
,
parseOnly
opts
]
then
opts
else
opts
{
flat
=
True
}
errs'
=
errs
++
check
opts'
files
opts'
=
if
or
[
flat
opts
,
flatXml
opts
,
abstract
opts
,
untypedAbstract
opts
,
parseOnly
opts
]
then
opts
else
opts
{
flat
=
True
}
-- ---------------------------------------------------------------------------
-- |Print the program greeting
printVersion
::
IO
()
printVersion
=
putStrLn
cymakeGreeting
-- |Print errors
-- |Print the usage information of the command line tool.
printUsage
::
String
->
IO
()
printUsage
prog
=
putStrLn
$
usage
prog
-- |Print errors and abort execution
badUsage
::
String
->
[
String
]
->
IO
()
badUsage
prog
errs
=
do
putErrsLn
$
map
(
\
err
->
prog
++
": "
++
err
)
errs
abortWith
[
"Try '"
++
prog
++
" --help' for more information"
]
-- |Check options and files and return a list of error messages
check
::
Options
->
[
String
]
->
[
String
]
check
opts
files
|
isJust
(
output
opts
)
&&
length
files
>
1
=
[
"cannot specify -o with multiple targets"
]
|
otherwise
=
[]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment