mirror of
https://github.com/anoma/juvix.git
synced 2024-12-15 10:03:22 +03:00
32449e1212
The problem with readFile and writeFile from text [Data.Text.IO](https://hackage.haskell.org/package/text-2.0.2/docs/Data-Text-IO.html) is that they use the system locale to determine the text encoding format. Our assumption is that all Juvix source files are UTF-8 encoded. I cannot reproduce the issue with using the old APIs on my machine, it can be reproduced on Arch linux. I'm not sure how to write a specific test for this. * Closes https://github.com/anoma/juvix/issues/2472
29 lines
1.0 KiB
Haskell
29 lines
1.0 KiB
Haskell
module Commands.Dev.Asm.Validate where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Asm.Validate.Options
|
|
import Juvix.Compiler.Asm.Pretty qualified as Asm
|
|
import Juvix.Compiler.Asm.Transformation.Validate qualified as Asm
|
|
import Juvix.Compiler.Asm.Translation.FromSource qualified as Asm
|
|
|
|
runCommand :: forall r. (Members '[Embed IO, App] r) => AsmValidateOptions -> Sem r ()
|
|
runCommand opts = do
|
|
afile :: Path Abs File <- fromAppPathFile file
|
|
s <- readFile (toFilePath afile)
|
|
case Asm.runParser (toFilePath afile) s of
|
|
Left err -> exitJuvixError (JuvixError err)
|
|
Right tab -> do
|
|
case Asm.validate' tab of
|
|
Just err ->
|
|
exitJuvixError (JuvixError err)
|
|
Nothing ->
|
|
if
|
|
| opts ^. asmValidateNoPrint ->
|
|
exitMsg ExitSuccess "validation succeeded"
|
|
| otherwise -> do
|
|
renderStdOut (Asm.ppOutDefault tab tab)
|
|
exitMsg ExitSuccess ""
|
|
where
|
|
file :: AppPath File
|
|
file = opts ^. asmValidateInputFile
|