-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6649209
commit 8f9f5f4
Showing
4 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
module Commands.Dev.Nockma where | ||
|
||
import Commands.Base | ||
import Commands.Dev.Nockma.Eval as FromAsm | ||
import Commands.Dev.Nockma.Eval as Eval | ||
import Commands.Dev.Nockma.Format as Format | ||
import Commands.Dev.Nockma.Options | ||
import Commands.Dev.Nockma.Repl as Repl | ||
|
||
runCommand :: forall r. (Members '[Embed IO, App] r) => NockmaCommand -> Sem r () | ||
runCommand = \case | ||
NockmaRepl opts -> Repl.runCommand opts | ||
NockmaEval opts -> FromAsm.runCommand opts | ||
NockmaEval opts -> Eval.runCommand opts | ||
NockmaFormat opts -> Format.runCommand opts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Commands.Dev.Nockma.Format where | ||
|
||
import Commands.Base hiding (Atom) | ||
import Commands.Dev.Nockma.Format.Options | ||
import Juvix.Compiler.Nockma.Pretty | ||
import Juvix.Compiler.Nockma.Translation.FromSource qualified as Nockma | ||
|
||
runCommand :: forall r. (Members '[Embed IO, App] r) => NockmaFormatOptions -> Sem r () | ||
runCommand opts = do | ||
afile <- fromAppPathFile file | ||
parsedTerm <- Nockma.parseTermFile (toFilePath afile) | ||
case parsedTerm of | ||
Left err -> exitJuvixError (JuvixError err) | ||
Right t -> putStrLn (ppPrint t) | ||
where | ||
file :: AppPath File | ||
file = opts ^. nockmaFormatFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module Commands.Dev.Nockma.Format.Options where | ||
|
||
import CommonOptions | ||
|
||
newtype NockmaFormatOptions = NockmaFormatOptions | ||
{ _nockmaFormatFile :: AppPath File | ||
} | ||
deriving stock (Data) | ||
|
||
makeLenses ''NockmaFormatOptions | ||
|
||
parseNockmaFormatOptions :: Parser NockmaFormatOptions | ||
parseNockmaFormatOptions = do | ||
_nockmaFormatFile <- parseInputFile FileExtNockma | ||
pure NockmaFormatOptions {..} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters