@@ -129,12 +129,12 @@ letrec n m = do
129
129
130
130
-- Parsing
131
131
132
- parseFile :: (Has (Throw String ) sig m , MonadIO m ) => FilePath -> m (Source. Source , File Term )
133
- parseFile path = do
134
- contents <- liftIO (B. readFile path )
135
- let sourcePath = replaceExtensions path " py "
136
- -- FIXME: this is comprised of several terrible assumptions.
137
- sourceContents <- Source. fromUTF8 . B. toStrict <$> liftIO (B. readFile sourcePath )
132
+ parseFile :: (Has (Throw String ) sig m , MonadIO m ) => FilePath -> FilePath -> m (Source. Source , File Term )
133
+ parseFile srcPath jsonPath = do
134
+ contents <- liftIO (B. readFile jsonPath )
135
+ -- FIXME: get this from the JSON itself (cf https://github.com/tree-sitter/tree-sitter-graph/issues/69)
136
+ let sourcePath = replaceExtensions jsonPath " py "
137
+ sourceContents <- Source. fromUTF8 . B. toStrict <$> liftIO (B. readFile srcPath )
138
138
let span = decrSpan (Source. totalSpan sourceContents)
139
139
case (A. eitherDecodeWith A. json' (A. iparse parseGraph) contents) of
140
140
Left (_, err) -> throwError err
@@ -232,6 +232,7 @@ locate attrs p = do
232
232
analyzeFile
233
233
:: (Algebra sig m , MonadIO m )
234
234
=> FilePath
235
+ -> FilePath
235
236
-> ( forall term
236
237
. Ord term
237
238
=> ( forall sig m
@@ -242,11 +243,11 @@ analyzeFile
242
243
-> File term
243
244
-> m b )
244
245
-> m b
245
- analyzeFile path analyze = do
246
- (src, file) <- parseToTerm path
246
+ analyzeFile srcPath jsonPath analyze = do
247
+ (src, file) <- parseToTerm srcPath jsonPath
247
248
analyze eval src file
248
249
249
- parseToTerm :: (Algebra sig m , MonadIO m ) => FilePath -> m (Source. Source , File Term )
250
- parseToTerm path = do
251
- parsed <- runThrow @ String (parseFile path )
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 )
252
253
either (liftIO . throwIO . ErrorCall ) pure parsed
0 commit comments