2023-03-14 18:24:07 +03:00
|
|
|
module Commands.Eval.Options where
|
|
|
|
|
|
|
|
import CommonOptions
|
|
|
|
import Evaluator qualified as Eval
|
|
|
|
import Juvix.Compiler.Core.Pretty.Options qualified as Core
|
|
|
|
|
|
|
|
data EvalOptions = EvalOptions
|
2023-06-06 13:35:01 +03:00
|
|
|
{ _evalInputFile :: AppPath File,
|
2023-03-14 18:24:07 +03:00
|
|
|
_evalSymbolName :: Maybe Text
|
|
|
|
}
|
|
|
|
deriving stock (Data)
|
|
|
|
|
|
|
|
makeLenses ''EvalOptions
|
|
|
|
|
|
|
|
instance CanonicalProjection EvalOptions Core.Options where
|
2023-06-06 13:35:01 +03:00
|
|
|
project _ =
|
2023-03-14 18:24:07 +03:00
|
|
|
Core.defaultOptions
|
2023-06-06 13:35:01 +03:00
|
|
|
{ Core._optShowDeBruijnIndices = False
|
2023-03-14 18:24:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
instance CanonicalProjection EvalOptions Eval.EvalOptions where
|
|
|
|
project c =
|
|
|
|
Eval.EvalOptions
|
|
|
|
{ _evalInputFile = c ^. evalInputFile,
|
2023-06-06 13:35:01 +03:00
|
|
|
_evalNoIO = False,
|
|
|
|
_evalNoDisambiguate = False,
|
|
|
|
_evalPrintValues = True
|
2023-03-14 18:24:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
parseEvalOptions :: Parser EvalOptions
|
|
|
|
parseEvalOptions = do
|
|
|
|
_evalInputFile <- parseInputJuvixFile
|
|
|
|
_evalSymbolName <-
|
|
|
|
optional $
|
|
|
|
strOption
|
|
|
|
( long "symbol-name"
|
|
|
|
<> short 's'
|
|
|
|
<> help "Evaluate a specific function identifier (default: main)"
|
|
|
|
<> metavar "NAME"
|
|
|
|
)
|
|
|
|
pure EvalOptions {..}
|