mirror of
https://github.com/github/semantic.git
synced 2024-12-25 07:55:12 +03:00
Either makes this easier
This commit is contained in:
parent
be5f00ee50
commit
c9219f71c3
@ -41,17 +41,15 @@ main :: IO ()
|
||||
main = generateAST =<< execParser opts
|
||||
|
||||
generateAST :: SemanticAST -> IO ()
|
||||
generateAST (SemanticAST _ filePath sourceString) = do
|
||||
case filePath of
|
||||
Just filePath -> do
|
||||
generateAST (SemanticAST _ source) = do
|
||||
case source of
|
||||
Left filePath -> do
|
||||
bytestring <- Data.ByteString.readFile filePath
|
||||
print =<< parseByteString @TreeSitter.Python.AST.Module @(Range, Span) tree_sitter_python bytestring
|
||||
Nothing -> do
|
||||
case sourceString of
|
||||
Just sourceString -> do
|
||||
bytestring <- Data.ByteString.Char8.pack . Prelude.head <$> getArgs
|
||||
Right source -> do
|
||||
let bytestring = Data.ByteString.Char8.pack source
|
||||
print =<< parseByteString @TreeSitter.Python.AST.Module @(Range, Span) tree_sitter_python bytestring
|
||||
Nothing -> print "please provide a file path or source string to parse"
|
||||
|
||||
|
||||
opts :: ParserInfo SemanticAST
|
||||
opts = info (parseAST <**> helper)
|
||||
|
Loading…
Reference in New Issue
Block a user