2022-09-14 17:16:15 +03:00
|
|
|
module Commands.Dev.Highlight where
|
|
|
|
|
|
|
|
import Commands.Base
|
|
|
|
import Commands.Dev.Highlight.Options
|
|
|
|
import Juvix.Compiler.Concrete.Data.Highlight qualified as Highlight
|
|
|
|
import Juvix.Compiler.Concrete.Data.InfoTable qualified as Scoper
|
|
|
|
import Juvix.Compiler.Concrete.Translation.FromParsed.Analysis.Scoping qualified as Scoper
|
|
|
|
import Juvix.Compiler.Concrete.Translation.FromSource qualified as Parser
|
|
|
|
|
|
|
|
runCommand :: Members '[Embed IO, App] r => HighlightOptions -> Sem r ()
|
|
|
|
runCommand HighlightOptions {..} = do
|
|
|
|
res <- runPipelineEither _highlightInputFile upToScoping
|
|
|
|
case res of
|
|
|
|
Left err -> do
|
|
|
|
genOpts <- askGenericOptions
|
|
|
|
say (Highlight.goError (run $ runReader genOpts $ errorIntervals err))
|
|
|
|
Right r -> do
|
2022-11-07 16:47:56 +03:00
|
|
|
let tbl = r ^. _2 . Scoper.resultParserTable
|
2022-09-14 17:16:15 +03:00
|
|
|
items = tbl ^. Parser.infoParsedItems
|
2022-11-07 16:47:56 +03:00
|
|
|
names = r ^. _2 . (Scoper.resultScoperTable . Scoper.infoNames)
|
2022-09-14 17:16:15 +03:00
|
|
|
inputFile = _highlightInputFile ^. pathPath
|
|
|
|
hinput =
|
|
|
|
Highlight.filterInput
|
|
|
|
inputFile
|
|
|
|
Highlight.HighlightInput
|
|
|
|
{ _highlightNames = names,
|
|
|
|
_highlightParsed = items
|
|
|
|
}
|
|
|
|
raw (Highlight.go _highlightBackend hinput)
|