1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

case over format

This commit is contained in:
Ayman Nadeem 2019-10-18 11:14:56 -04:00
parent e0c60bf166
commit b0fb726d4d

View File

@ -37,13 +37,16 @@ main :: IO ()
main = generateAST =<< execParser opts
generateAST :: SemanticAST -> IO ()
generateAST (SemanticAST _ source) = do
generateAST (SemanticAST format source) = do
bytestring <- case source of
Left filePath -> do
Data.ByteString.readFile filePath
Right source -> do
pure $ Data.ByteString.Char8.pack source
print =<< parseByteString @TreeSitter.Python.AST.Module @(Range, Span) tree_sitter_python bytestring
ast <- parseByteString @TreeSitter.Python.AST.Module @(Range, Span) tree_sitter_python bytestring
case format of
Show -> print ast
opts :: ParserInfo SemanticAST
opts = info (parseAST <**> helper)