diff --git a/src/Juvix/Compiler/Concrete/Translation/FromSource.hs b/src/Juvix/Compiler/Concrete/Translation/FromSource.hs index dcf835ddde..ea2ff0c2fa 100644 --- a/src/Juvix/Compiler/Concrete/Translation/FromSource.hs +++ b/src/Juvix/Compiler/Concrete/Translation/FromSource.hs @@ -175,7 +175,7 @@ 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)) @@ -183,12 +183,11 @@ 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 = @@ -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'. @@ -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) => diff --git a/src/Juvix/Compiler/Concrete/Translation/ImportScanner.hs b/src/Juvix/Compiler/Concrete/Translation/ImportScanner.hs index 4f926a4d91..89e5d47762 100644 --- a/src/Juvix/Compiler/Concrete/Translation/ImportScanner.hs +++ b/src/Juvix/Compiler/Concrete/Translation/ImportScanner.hs @@ -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