Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 098ffe1

Browse files
committed
Pass a path to read the source from.
1 parent 4d95c78 commit 098ffe1

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

semantic-analysis/src/Analysis/Syntax.hs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,12 @@ letrec n m = do
129129

130130
-- Parsing
131131

132-
parseFile :: (Has (Throw String) sig m, MonadIO m) => FilePath -> m (Source.Source, File Term)
133-
parseFile jsonPath = do
132+
parseFile :: (Has (Throw String) sig m, MonadIO m) => FilePath -> FilePath -> m (Source.Source, File Term)
133+
parseFile srcPath jsonPath = do
134134
contents <- liftIO (B.readFile jsonPath)
135135
let sourcePath = replaceExtensions jsonPath "py"
136136
-- FIXME: this is comprised of several terrible assumptions.
137-
sourceContents <- Source.fromUTF8 . B.toStrict <$> liftIO (B.readFile sourcePath)
137+
sourceContents <- Source.fromUTF8 . B.toStrict <$> liftIO (B.readFile srcPath)
138138
let span = decrSpan (Source.totalSpan sourceContents)
139139
case (A.eitherDecodeWith A.json' (A.iparse parseGraph) contents) of
140140
Left (_, err) -> throwError err
@@ -232,6 +232,7 @@ locate attrs p = do
232232
analyzeFile
233233
:: (Algebra sig m, MonadIO m)
234234
=> FilePath
235+
-> FilePath
235236
-> ( forall term
236237
. Ord term
237238
=> ( forall sig m
@@ -242,11 +243,11 @@ analyzeFile
242243
-> File term
243244
-> m b )
244245
-> m b
245-
analyzeFile jsonPath analyze = do
246-
(src, file) <- parseToTerm jsonPath
246+
analyzeFile srcPath jsonPath analyze = do
247+
(src, file) <- parseToTerm srcPath jsonPath
247248
analyze eval src file
248249

249-
parseToTerm :: (Algebra sig m, MonadIO m) => FilePath -> m (Source.Source, File Term)
250-
parseToTerm jsonPath = do
251-
parsed <- runThrow @String (parseFile jsonPath)
250+
parseToTerm :: (Algebra sig m, MonadIO m) => FilePath -> FilePath -> m (Source.Source, File Term)
251+
parseToTerm srcPath jsonPath = do
252+
parsed <- runThrow @String (parseFile srcPath jsonPath)
252253
either (liftIO . throwIO . ErrorCall) pure parsed

0 commit comments

Comments
 (0)