2022-09-14 17:16:15 +03:00
|
|
|
module Commands.Dev.Core.Read where
|
|
|
|
|
|
|
|
import Commands.Base
|
|
|
|
import Commands.Dev.Core.Read.Options
|
|
|
|
import Juvix.Compiler.Core.Pretty qualified as Core
|
|
|
|
import Juvix.Compiler.Core.Transformation qualified as Core
|
|
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
|
|
|
|
|
|
runCommand :: forall r. Members '[Embed IO, App] r => CoreReadOptions -> Sem r ()
|
|
|
|
runCommand opts = do
|
|
|
|
s' <- embed (readFile f)
|
2022-10-19 17:55:16 +03:00
|
|
|
tab <- getRight (fst <$> mapLeft JuvixError (Core.runParser f Core.emptyInfoTable s'))
|
2022-09-14 17:16:15 +03:00
|
|
|
let tab' = Core.applyTransformations (opts ^. coreReadTransformations) tab
|
|
|
|
renderStdOut (Core.ppOut opts tab')
|
|
|
|
where
|
|
|
|
f :: FilePath
|
|
|
|
f = opts ^. coreReadInputFile . pathPath
|