This repository was archived by the owner on Apr 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ library
7878 , filepath
7979 , fused-effects ^>= 1.1
8080 , hashable
81+ , language-python
8182 , semantic-source ^>= 0.2
8283 , text ^>= 1.2.3.1
8384 , transformers ^>= 0.5
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ module Analysis.Syntax.Python
99 -- * Abstract interpretation
1010, eval0
1111, eval
12+ -- * Parsing
13+ , parse
1214) where
1315
1416import Analysis.Effect.Domain hiding ((:>>>) )
@@ -22,7 +24,11 @@ import Control.Effect.Reader
2224import Data.Function (fix )
2325import Data.List.NonEmpty (NonEmpty )
2426import 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
2530import Source.Span (Span )
31+ import System.FilePath (takeBaseName )
2632
2733-- Syntax
2834
@@ -80,3 +86,13 @@ eval eval = \case
8086 Locate s t -> local (setSpan s) (eval t)
8187 where
8288 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