-
Notifications
You must be signed in to change notification settings - Fork 57
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
6a36eef
commit dd3b1d0
Showing
4 changed files
with
145 additions
and
136 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
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,111 +1,35 @@ | ||
module Commands.Dev | ||
( module Commands.Dev, | ||
module Commands.Dev.Core.Options, | ||
module Commands.Dev.Internal, | ||
module Commands.Dev.Parse.Options, | ||
module Commands.Dev.Highlight.Options, | ||
module Commands.Dev.Scope.Options, | ||
module Commands.Dev.Doc.Options, | ||
module Commands.Dev.Termination.Options, | ||
module Commands.Dev.Options, | ||
) | ||
where | ||
|
||
import Commands.Dev.Core.Options | ||
import Commands.Dev.Doc.Options | ||
import Commands.Dev.Highlight.Options | ||
import Commands.Dev.Internal | ||
import Commands.Dev.Parse.Options | ||
import Commands.Dev.Scope.Options | ||
import Commands.Dev.Termination.Options | ||
import Juvix.Prelude | ||
import Options.Applicative | ||
|
||
data DevCommand | ||
= DisplayRoot | ||
| Highlight HighlightOptions | ||
| Internal MicroCommand | ||
| Core CoreCommand | ||
| MiniC | ||
| Parse ParseOptions | ||
| Scope ScopeOptions | ||
| Termination TerminationCommand | ||
| Doc DocOptions | ||
|
||
parseDevCommand :: Parser DevCommand | ||
parseDevCommand = | ||
hsubparser | ||
( mconcat | ||
[ commandHighlight, | ||
commandInternal, | ||
commandCore, | ||
commandMiniC, | ||
commandParse, | ||
commandDoc, | ||
commandScope, | ||
commandShowRoot, | ||
commandTermination | ||
] | ||
) | ||
|
||
commandDoc :: Mod CommandFields DevCommand | ||
commandDoc = | ||
command "doc" $ | ||
info | ||
(Doc <$> parseDoc) | ||
(progDesc "Generate documentation") | ||
|
||
commandHighlight :: Mod CommandFields DevCommand | ||
commandHighlight = | ||
command "highlight" $ | ||
info | ||
(Highlight <$> parseHighlight) | ||
(progDesc "Highlight a Juvix file") | ||
|
||
commandMiniC :: Mod CommandFields DevCommand | ||
commandMiniC = | ||
command "minic" $ | ||
info | ||
(pure MiniC) | ||
(progDesc "Translate a Juvix file to MiniC") | ||
|
||
commandInternal :: Mod CommandFields DevCommand | ||
commandInternal = | ||
command "internal" $ | ||
info | ||
(Internal <$> parseMicroCommand) | ||
(progDesc "Subcommands related to Internal") | ||
|
||
commandCore :: Mod CommandFields DevCommand | ||
commandCore = | ||
command "core" $ | ||
info | ||
(Core <$> parseCoreCommand) | ||
(progDesc "Subcommands related to JuvixCore") | ||
|
||
commandParse :: Mod CommandFields DevCommand | ||
commandParse = | ||
command "parse" $ | ||
info | ||
(Parse <$> parseParse) | ||
(progDesc "Parse a Juvix file") | ||
|
||
commandScope :: Mod CommandFields DevCommand | ||
commandScope = | ||
command "scope" $ | ||
info | ||
(Scope <$> parseScope) | ||
(progDesc "Parse and scope a Juvix file") | ||
|
||
commandShowRoot :: Mod CommandFields DevCommand | ||
commandShowRoot = | ||
command "root" $ | ||
info | ||
(pure DisplayRoot) | ||
(progDesc "Show the root path for a Juvix project") | ||
|
||
commandTermination :: Mod CommandFields DevCommand | ||
commandTermination = | ||
command "termination" $ | ||
info | ||
(Termination <$> parseTerminationCommand) | ||
(progDesc "Subcommands related to termination checking") | ||
import Commands.Base | ||
import Commands.Dev.Doc qualified as Doc | ||
import Commands.Dev.Highlight qualified as Highlight | ||
import Commands.Dev.Internal.Arity qualified as Arity | ||
import Commands.Dev.Internal.Pretty qualified as InternalPretty | ||
import Commands.Dev.Internal.Typecheck qualified as InternalTypecheck | ||
import Commands.Dev.MiniC qualified as MiniC | ||
import Commands.Dev.Options | ||
import Commands.Dev.Parse qualified as Parse | ||
import Commands.Dev.Scope qualified as Scope | ||
import Commands.Dev.Termination.CallGraph qualified as TerminationCallGraph | ||
import Commands.Dev.Termination.Calls qualified as TerminationCalls | ||
|
||
runCommand :: Members '[Embed IO, App] r => EntryPoint -> DevCommand -> Sem r () | ||
runCommand entryPoint cmd = do | ||
case cmd of | ||
Highlight localOpts -> Highlight.runCommand entryPoint localOpts | ||
Parse localOpts -> Parse.runCommand entryPoint localOpts | ||
Scope localOpts -> Scope.runCommand entryPoint localOpts | ||
Doc localOpts -> Doc.runCommand entryPoint localOpts | ||
Internal i -> case i of | ||
Pretty -> InternalPretty.runCommand entryPoint | ||
Arity -> Arity.runCommand entryPoint | ||
TypeCheck localOpts -> InternalTypecheck.runCommand entryPoint localOpts | ||
MiniC -> MiniC.runCommand entryPoint | ||
Termination t -> case t of | ||
Calls localOpts -> TerminationCalls.runCommand entryPoint localOpts | ||
CallGraph localOpts -> TerminationCallGraph.runCommand entryPoint localOpts | ||
_ -> impossible -- do not require entrypoint |
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,111 @@ | ||
module Commands.Dev.Options | ||
( module Commands.Dev.Options, | ||
module Commands.Dev.Core.Options, | ||
module Commands.Dev.Internal, | ||
module Commands.Dev.Parse.Options, | ||
module Commands.Dev.Highlight.Options, | ||
module Commands.Dev.Scope.Options, | ||
module Commands.Dev.Doc.Options, | ||
module Commands.Dev.Termination.Options, | ||
) | ||
where | ||
|
||
import Commands.Dev.Core.Options | ||
import Commands.Dev.Doc.Options | ||
import Commands.Dev.Highlight.Options | ||
import Commands.Dev.Internal | ||
import Commands.Dev.Parse.Options | ||
import Commands.Dev.Scope.Options | ||
import Commands.Dev.Termination.Options | ||
import Juvix.Prelude | ||
import Options.Applicative | ||
|
||
data DevCommand | ||
= DisplayRoot | ||
| Highlight HighlightOptions | ||
| Internal MicroCommand | ||
| Core CoreCommand | ||
| MiniC | ||
| Parse ParseOptions | ||
| Scope ScopeOptions | ||
| Termination TerminationCommand | ||
| Doc DocOptions | ||
|
||
parseDevCommand :: Parser DevCommand | ||
parseDevCommand = | ||
hsubparser | ||
( mconcat | ||
[ commandHighlight, | ||
commandInternal, | ||
commandCore, | ||
commandMiniC, | ||
commandParse, | ||
commandDoc, | ||
commandScope, | ||
commandShowRoot, | ||
commandTermination | ||
] | ||
) | ||
|
||
commandDoc :: Mod CommandFields DevCommand | ||
commandDoc = | ||
command "doc" $ | ||
info | ||
(Doc <$> parseDoc) | ||
(progDesc "Generate documentation") | ||
|
||
commandHighlight :: Mod CommandFields DevCommand | ||
commandHighlight = | ||
command "highlight" $ | ||
info | ||
(Highlight <$> parseHighlight) | ||
(progDesc "Highlight a Juvix file") | ||
|
||
commandMiniC :: Mod CommandFields DevCommand | ||
commandMiniC = | ||
command "minic" $ | ||
info | ||
(pure MiniC) | ||
(progDesc "Translate a Juvix file to MiniC") | ||
|
||
commandInternal :: Mod CommandFields DevCommand | ||
commandInternal = | ||
command "internal" $ | ||
info | ||
(Internal <$> parseMicroCommand) | ||
(progDesc "Subcommands related to Internal") | ||
|
||
commandCore :: Mod CommandFields DevCommand | ||
commandCore = | ||
command "core" $ | ||
info | ||
(Core <$> parseCoreCommand) | ||
(progDesc "Subcommands related to JuvixCore") | ||
|
||
commandParse :: Mod CommandFields DevCommand | ||
commandParse = | ||
command "parse" $ | ||
info | ||
(Parse <$> parseParse) | ||
(progDesc "Parse a Juvix file") | ||
|
||
commandScope :: Mod CommandFields DevCommand | ||
commandScope = | ||
command "scope" $ | ||
info | ||
(Scope <$> parseScope) | ||
(progDesc "Parse and scope a Juvix file") | ||
|
||
commandShowRoot :: Mod CommandFields DevCommand | ||
commandShowRoot = | ||
command "root" $ | ||
info | ||
(pure DisplayRoot) | ||
(progDesc "Show the root path for a Juvix project") | ||
|
||
commandTermination :: Mod CommandFields DevCommand | ||
commandTermination = | ||
command "termination" $ | ||
info | ||
(Termination <$> parseTerminationCommand) | ||
(progDesc "Subcommands related to termination checking") |
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