1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-21 05:41:49 +03:00
juvix/app/Commands/Dev/Core/Options.hs

109 lines
3.2 KiB
Haskell
Raw Normal View History

2022-09-14 17:16:15 +03:00
module Commands.Dev.Core.Options where
import Commands.Dev.Core.Asm.Options
import Commands.Dev.Core.Compile.Options
2022-09-14 17:16:15 +03:00
import Commands.Dev.Core.Eval.Options
import Commands.Dev.Core.FromConcrete.Options
import Commands.Dev.Core.Normalize.Options
2022-09-14 17:16:15 +03:00
import Commands.Dev.Core.Read.Options
import Commands.Dev.Core.Repl.Options
import Commands.Dev.Core.Strip.Options
2022-09-14 17:16:15 +03:00
import CommonOptions
data CoreCommand
= Repl CoreReplOptions
| Eval CoreEvalOptions
| Normalize CoreNormalizeOptions
2022-09-14 17:16:15 +03:00
| Read CoreReadOptions
| FromConcrete CoreFromConcreteOptions
| Strip CoreStripOptions
| CoreAsm CoreAsmOptions
| CoreCompile CompileOptions
2022-09-14 17:16:15 +03:00
deriving stock (Data)
parseCoreCommand :: Parser CoreCommand
parseCoreCommand =
hsubparser $
mconcat
[ commandRepl,
commandEval,
commandNormalize,
commandRead,
commandStrip,
commandFromConcrete,
commandAsm,
commandCompile
2022-09-14 17:16:15 +03:00
]
where
commandRepl :: Mod CommandFields CoreCommand
commandRepl = command "repl" replInfo
commandEval :: Mod CommandFields CoreCommand
commandEval = command "eval" evalInfo
commandNormalize :: Mod CommandFields CoreCommand
commandNormalize = command "normalize" normalizeInfo
2022-09-14 17:16:15 +03:00
commandRead :: Mod CommandFields CoreCommand
commandRead = command "read" readInfo
commandStrip :: Mod CommandFields CoreCommand
commandStrip = command "strip" stripInfo
commandAsm :: Mod CommandFields CoreCommand
commandAsm = command "asm" asmInfo
commandFromConcrete :: Mod CommandFields CoreCommand
commandFromConcrete = command "from-concrete" fromSourceInfo
commandCompile :: Mod CommandFields CoreCommand
commandCompile = command "compile" compileInfo
2022-09-14 17:16:15 +03:00
replInfo :: ParserInfo CoreCommand
replInfo =
info
(Repl <$> parseCoreReplOptions)
(progDesc "Start an interactive session of the JuvixCore evaluator")
fromSourceInfo :: ParserInfo CoreCommand
fromSourceInfo =
info
(FromConcrete <$> parseCoreFromConcreteOptions)
(progDesc "Read a Juvix file and compile it to core")
2022-09-14 17:16:15 +03:00
evalInfo :: ParserInfo CoreCommand
evalInfo =
info
(Eval <$> parseCoreEvalOptions)
(progDesc "Evaluate a JuvixCore file and pretty print the result")
normalizeInfo :: ParserInfo CoreCommand
normalizeInfo =
info
(Normalize <$> parseCoreNormalizeOptions)
(progDesc "Normalize the main definition from a JuvixCore file and pretty print the result")
2022-09-14 17:16:15 +03:00
readInfo :: ParserInfo CoreCommand
readInfo =
info
(Read <$> parseCoreReadOptions)
(progDesc "Read a JuvixCore file, transform it, and pretty print it")
stripInfo :: ParserInfo CoreCommand
stripInfo =
info
(Strip <$> parseCoreStripOptions)
(progDesc "Translate a JuvixCore file to Core.Stripped and pretty print the result")
asmInfo :: ParserInfo CoreCommand
asmInfo =
info
(CoreAsm <$> parseCoreAsmOptions)
(progDesc "Translate a JuvixCore file to JuvixAsm and run the result")
compileInfo :: ParserInfo CoreCommand
compileInfo =
info
(CoreCompile <$> parseCoreCompileOptions)
(progDesc "Compile a JuvixCore file to native code, WebAssembly, GEB or VampIR")