mirror of
https://github.com/anoma/juvix.git
synced 2024-12-22 06:11:36 +03:00
447f2f1dcf
- Fixes #1723 - It refactors parsing/scoping so that the scoper does not need to read files or parse any module. Instead, the parser takes care of parsing all the imported modules transitively.
27 lines
1021 B
Haskell
27 lines
1021 B
Haskell
module Commands.Dev.Scope where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Scope.Options
|
|
import Juvix.Compiler.Concrete.Language
|
|
import Juvix.Compiler.Concrete.Pretty qualified as Scoper
|
|
import Juvix.Compiler.Concrete.Print qualified as Print
|
|
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping qualified as Scoper
|
|
import Juvix.Prelude.Pretty
|
|
|
|
runCommand :: (Members '[Embed IO, App] r) => ScopeOptions -> Sem r ()
|
|
runCommand opts = do
|
|
globalOpts <- askGlobalOptions
|
|
res :: Scoper.ScoperResult <- runPipeline (opts ^. scopeInputFile) upToScoping
|
|
let modules :: NonEmpty (Module 'Scoped 'ModuleTop) = res ^. Scoper.resultModules
|
|
forM_ modules $ \s ->
|
|
if
|
|
| opts ^. scopeWithComments ->
|
|
renderStdOut (Print.ppOut (globalOpts, opts) (res ^. Scoper.comments) s)
|
|
| otherwise ->
|
|
renderStdOut (Scoper.ppOut (globalOpts, opts) s)
|
|
when (opts ^. scopeListComments) $ do
|
|
newline
|
|
newline
|
|
say "Comments:"
|
|
say (prettyText (res ^. Scoper.comments))
|