broken: fixed circular import (File -> Import -> File)

This commit is contained in:
vegowotenks 2025-02-19 23:33:20 +01:00
parent a4cd711574
commit 6990c3f759
2 changed files with 13 additions and 5 deletions

View file

@ -1,4 +1,5 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE DerivingStrategies #-}
module Ubc.Parse.Syntax.Import
( parse
, Import(..)
@ -37,6 +38,7 @@ data Import = Import
{ file :: File.File
, alias :: String
}
deriving stock (Show)
importPath :: Monad m => ParsecT String u m (NonEmpty String)
importPath = UbcLanguage.angles (many importChar `sepBy1` char '/')
@ -84,7 +86,7 @@ notFoundMessage relFile searchedLocations = "Could not locate import file path"
<> "Searched locations were:"
<> (unlines . List.map (('\t':) . Path.fromAbsFile) $ searchedLocations)
parseFile :: MonadIO m => Path Abs File -> String -> ParsecT String u m Import
parseFile :: Path Abs File -> String -> ParsecT String u Transformer Import
parseFile path importAs = do
let stringPath = Path.fromAbsFile path
contents <- liftIO . readFile $ stringPath