-
Notifications
You must be signed in to change notification settings - Fork 0
/
Args.hs
105 lines (99 loc) · 3.12 KB
/
Args.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
module Args where
import Options.Applicative
import Data.Semigroup ((<>))
data Solver = Simple | Graph | Indexed | LMS deriving (Eq, Ord, Show)
data Args = Args
{ sourceFile :: String
, verbose :: Bool
, skipInference :: Bool
, skipSpecialisation :: Bool
, skipVerification :: Bool
, skipEvaluation :: Bool
, optIdentity :: Bool
, solver :: Solver
, dumpPretty :: Maybe String
, dumpIR :: Maybe String
, dumpScheme :: Maybe String
, dumpSchemeIR :: Maybe String
, dumpNF :: Maybe String
, dumpNFScheme :: Maybe String
, dumpMalfunction :: Maybe String
, dumpStats :: Maybe String
, rtsSchemePath :: String
}
deriving (Show)
args :: Parser Args
args = Args
<$> strArgument
( metavar "source.tt"
<> help "File with TTstar code")
<*> switch
( long "verbose"
<> short 'v'
<> help "Print detailed report of compilation")
<*> switch
( long "skip-inference"
<> help "Annotate everything as R")
<*> switch
( long "skip-specialisation"
<> help "Do not specialise erasure-polymorphic functions")
<*> switch
( long "skip-verification"
<> help "Do not run the verification checker")
<*> switch
( long "skip-evaluation"
<> help "Do not reduce program to NF")
<*> switch
( long "opt-identity"
<> help "Enable identity optimisation")
<*> (option . maybeReader) (`lookup` solvers)
( long "solver"
<> metavar "simple|graph|indexed|lms"
<> value Indexed
<> help "Constraint solver to use")
<*> optional (strOption
( metavar "file.tt"
<> long "dump-pretty"
<> help "Pretty-print final program"))
<*> optional (strOption
( metavar "file.ir"
<> long "dump-ir"
<> help "Pretty-print the IR"))
<*> optional (strOption
( metavar "file.scm"
<> long "dump-scheme"
<> help "Generate Scheme source from final program"))
<*> optional (strOption
( metavar "file.scm"
<> long "dump-scheme-ir"
<> help "Generate Scheme source from IR"))
<*> optional (strOption
( metavar "fileNF.tt"
<> long "dump-nf"
<> help "Pretty-print normal form"))
<*> optional (strOption
( metavar "fileNF.scm"
<> long "dump-nf-scheme"
<> help "Generate Scheme source from normal form"))
<*> optional (strOption
( metavar "file.mlf"
<> long "dump-mlf"
<> long "dump-malfunction"
<> help "Generate Malfunction source"))
<*> optional (strOption
( metavar "stats.json"
<> long "dump-stats"
<> help "Information about the number of constraints/evars"))
<*> strOption
( metavar "rts.scm"
<> long "rts-scm"
<> value "rts.scm"
<> help "Embed Scheme RTS from this file")
where
solvers = [("simple",Simple),("graph",Graph),("indexed",Indexed),("lms",LMS)]
parse :: IO Args
parse = execParser opts
where
opts = info (args <**> helper)
(fullDesc
<> header "TTstar -- a dependent language with erasure")