File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ library
78
78
, filepath
79
79
, fused-effects ^>= 1.1
80
80
, hashable
81
+ , language-python
81
82
, semantic-source ^>= 0.2
82
83
, text ^>= 1.2.3.1
83
84
, transformers ^>= 0.5
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ module Analysis.Syntax.Python
9
9
-- * Abstract interpretation
10
10
, eval0
11
11
, eval
12
+ -- * Parsing
13
+ , parse
12
14
) where
13
15
14
16
import Analysis.Effect.Domain hiding ((:>>>) )
@@ -22,7 +24,11 @@ import Control.Effect.Reader
22
24
import Data.Function (fix )
23
25
import Data.List.NonEmpty (NonEmpty )
24
26
import Data.Text (Text )
27
+ import qualified Language.Python.Common.AST as Py
28
+ import qualified Language.Python.Common.SrcLocation as Py
29
+ import Language.Python.Version3.Parser
25
30
import Source.Span (Span )
31
+ import System.FilePath (takeBaseName )
26
32
27
33
-- Syntax
28
34
@@ -80,3 +86,13 @@ eval eval = \case
80
86
Locate s t -> local (setSpan s) (eval t)
81
87
where
82
88
setSpan s r = r{ refSpan = s }
89
+
90
+
91
+ -- Parsing
92
+
93
+ parse :: FilePath -> IO (Py. Module Py. SrcSpan )
94
+ parse path = do
95
+ src <- readFile path
96
+ case parseModule src (takeBaseName path) of
97
+ Left err -> fail (show err)
98
+ Right (m, _) -> pure m
You can’t perform that action at this time.
0 commit comments