Skip to content

Commit 793a876

Browse files
authored
Merge pull request github#690 from github/demo
Demo
2 parents c820de1 + d0cc22f commit 793a876

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

semantic-analysis/src/Analysis/Syntax.hs

Lines changed: 12 additions & 11 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 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)
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 path analyze = do
246-
(src, file) <- parseToTerm path
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 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)
252253
either (liftIO . throwIO . ErrorCall) pure parsed

0 commit comments

Comments
 (0)