diff --git a/semantic-python/app/Main.hs b/semantic-python/app/Main.hs index ae5a88ce3..c79d2a49d 100644 --- a/semantic-python/app/Main.hs +++ b/semantic-python/app/Main.hs @@ -2,15 +2,21 @@ module Main (main) where import qualified Data.ByteString as ByteString -import Language.Python.ScopeGraph +import qualified Data.ScopeGraph as ScopeGraph +import qualified Data.ScopeGraph as ScopeGraph +import qualified Language.Python () import qualified TreeSitter.Python.AST as Py import qualified TreeSitter.Python as TSP import qualified TreeSitter.Unmarshal as TS +import qualified Source.Source as Source import Source.Span import Source.Range +import Source.Loc +import System.Exit (die) main :: IO () main = do file <- ByteString.readFile "semantic-python/test/fixtures/1-01-empty-module.py" - tree <- TS.parseByteString @Py.Module @(Range, Span) TSP.tree_sitter_python file - print (show tree) + tree <- TS.parseByteString @Py.Module @Loc TSP.tree_sitter_python file + pyModule <- either die pure tree + print =<< (ScopeGraph.runScopeGraph (Source.fromUTF8 file) pyModule) diff --git a/semantic-scope-graph/src/Data/ScopeGraph.hs b/semantic-scope-graph/src/Data/ScopeGraph.hs index 8ae90b737..19bc73073 100644 --- a/semantic-scope-graph/src/Data/ScopeGraph.hs +++ b/semantic-scope-graph/src/Data/ScopeGraph.hs @@ -23,11 +23,18 @@ data Node a = Node instance Eq (Node a) where (==) = (==) `on` ident -data ScopeGraph a = ScopeGraph (Graph (Node a)) +instance Show a => Show (Node a) where + -- TODO: This is dropping ident field in Node + show = show . contents + + +newtype ScopeGraph a = ScopeGraph (Graph (Node a)) + deriving (Show) data Info = Ref Text | Scope | Root + deriving (Show) type SGM = ( ReaderC (ScopeGraph Info)