2022-09-14 17:16:15 +03:00
|
|
|
module Commands.Dev.Core.Options where
|
|
|
|
|
2023-01-09 20:21:30 +03:00
|
|
|
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
|
2023-02-10 14:37:28 +03:00
|
|
|
import Commands.Dev.Core.FromConcrete.Options
|
2023-05-15 19:01:40 +03:00
|
|
|
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
|
2023-01-09 20:21:30 +03:00
|
|
|
import Commands.Dev.Core.Strip.Options
|
2022-09-14 17:16:15 +03:00
|
|
|
import CommonOptions
|
|
|
|
|
|
|
|
data CoreCommand
|
|
|
|
= Repl CoreReplOptions
|
|
|
|
| Eval CoreEvalOptions
|
2023-05-15 19:01:40 +03:00
|
|
|
| Normalize CoreNormalizeOptions
|
2022-09-14 17:16:15 +03:00
|
|
|
| Read CoreReadOptions
|
2023-02-10 14:37:28 +03:00
|
|
|
| FromConcrete CoreFromConcreteOptions
|
2023-01-09 20:21:30 +03:00
|
|
|
| Strip CoreStripOptions
|
|
|
|
| CoreAsm CoreAsmOptions
|
2023-03-14 18:24:07 +03:00
|
|
|
| CoreCompile CompileOptions
|
2022-09-14 17:16:15 +03:00
|
|
|
deriving stock (Data)
|
|
|
|
|
|
|
|
parseCoreCommand :: Parser CoreCommand
|
|
|
|
parseCoreCommand =
|
|
|
|
hsubparser $
|
|
|
|
mconcat
|
|
|
|
[ commandRepl,
|
|
|
|
commandEval,
|
2023-05-15 19:01:40 +03:00
|
|
|
commandNormalize,
|
2023-01-09 20:21:30 +03:00
|
|
|
commandRead,
|
|
|
|
commandStrip,
|
2023-02-10 14:37:28 +03:00
|
|
|
commandFromConcrete,
|
2023-01-09 20:21:30 +03:00
|
|
|
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
|
|
|
|
|
2023-05-15 19:01:40 +03:00
|
|
|
commandNormalize :: Mod CommandFields CoreCommand
|
|
|
|
commandNormalize = command "normalize" normalizeInfo
|
|
|
|
|
2022-09-14 17:16:15 +03:00
|
|
|
commandRead :: Mod CommandFields CoreCommand
|
|
|
|
commandRead = command "read" readInfo
|
|
|
|
|
2023-01-09 20:21:30 +03:00
|
|
|
commandStrip :: Mod CommandFields CoreCommand
|
|
|
|
commandStrip = command "strip" stripInfo
|
|
|
|
|
|
|
|
commandAsm :: Mod CommandFields CoreCommand
|
|
|
|
commandAsm = command "asm" asmInfo
|
|
|
|
|
2023-02-10 14:37:28 +03:00
|
|
|
commandFromConcrete :: Mod CommandFields CoreCommand
|
|
|
|
commandFromConcrete = command "from-concrete" fromSourceInfo
|
|
|
|
|
2023-01-09 20:21:30 +03:00
|
|
|
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")
|
|
|
|
|
2023-02-10 14:37:28 +03:00
|
|
|
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")
|
|
|
|
|
2023-05-15 19:01:40 +03:00
|
|
|
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")
|
2023-01-09 20:21:30 +03:00
|
|
|
|
|
|
|
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
|
2023-04-13 15:16:07 +03:00
|
|
|
(CoreCompile <$> parseCoreCompileOptions)
|
2023-05-19 15:43:45 +03:00
|
|
|
(progDesc "Compile a JuvixCore file to native code, WebAssembly, GEB or VampIR")
|