Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Dec 28, 2024
1 parent c0bc373 commit 5c4e48e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
25 changes: 8 additions & 17 deletions src/Juvix/Compiler/Concrete/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -175,20 +175,19 @@ runModuleParser fileName input_
Right r -> return $ Right r

runMarkdownModuleParser ::
(Members '[ParserResultBuilder] r) =>
(Members '[TopModuleNameChecker, ParserResultBuilder] r) =>
Path Abs File ->
Mk ->
Sem r (Either ParserError (Module 'Parsed 'ModuleTop))
runMarkdownModuleParser fpath mk =
runError $ case nonEmpty (MK.extractJuvixCodeBlock mk) of
Nothing ->
throw
( ErrMarkdownBackend $
ErrNoJuvixCodeBlocks
NoJuvixCodeBlocksError
{ _noJuvixCodeBlocksErrorFilepath = fpath
}
)
. ErrMarkdownBackend
$ ErrNoJuvixCodeBlocks
NoJuvixCodeBlocksError
{ _noJuvixCodeBlocksErrorFilepath = fpath
}
Just (firstBlock :| restBlocks) -> do
m0 <- parseFirstBlock firstBlock
let iniBuilder =
Expand Down Expand Up @@ -261,10 +260,10 @@ runMarkdownModuleParser fpath mk =
Right m -> return m

parseFirstBlock ::
(Members '[ParserResultBuilder, Error ParserError] r') =>
(Members '[TopModuleNameChecker, ParserResultBuilder, Error ParserError] r') =>
MK.JuvixCodeBlock ->
Sem r' (Module 'Parsed 'ModuleTop)
parseFirstBlock x = parseHelper topMarkdownModuleDef x
parseFirstBlock x = parseHelper topModuleDef x

parseRestBlocks ::
forall r'.
Expand Down Expand Up @@ -379,14 +378,6 @@ juvixCodeBlockParser = do
(t ^. withLocParam)
(Just $ t ^. withLocInt)

topMarkdownModuleDef ::
(Members '[ParserResultBuilder, Error ParserError, PragmasStash, Error ParserError, JudocStash] r) =>
ParsecS r (Module 'Parsed 'ModuleTop)
topMarkdownModuleDef = do
optional_ stashJudoc
optional_ stashPragmas
top moduleDef

parseTopStatements ::
forall r.
(Members '[ParserResultBuilder, Error ParserError, PragmasStash, Error ParserError, JudocStash] r) =>
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Concrete/Translation/ImportScanner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ scanBSImports fp inputBS = do
logWarn (mkAnsiText ("The FlatParse parser failed to scan the file " <> toFilePath @Text fp <> ". Falling back to MegaParsec."))
Megaparsec.scanBSImports fp inputBS
ImportScanStrategyFlatParse -> case FlatParse.scanBSImports fp inputBS of
Just r -> return r
Nothing ->
throw $
ErrFlatParseError
FlatParseError
{ _flatParseErrorLoc = fileLoc
}
Just r -> return r
ImportScanStrategyMegaparsec -> Megaparsec.scanBSImports fp inputBS
where
adaptStrategy :: ImportScanStrategy -> ImportScanStrategy
Expand Down

0 comments on commit 5c4e48e

Please sign in to comment.