1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Return the Source alongside the AST.

This makes for easier chaining.
This commit is contained in:
Rob Rix 2017-04-21 09:43:29 -04:00
parent 9a0361d74d
commit a29b7b6f2b

View File

@ -46,7 +46,7 @@ treeSitterParser language grammar blob = do
pure term
parseRubyToAST :: Source -> IO (A.Rose Ruby.Grammar)
parseRubyToAST :: Source -> IO (Source, A.Rose Ruby.Grammar)
parseRubyToAST source = do
document <- ts_document_new
ts_document_set_language document Ruby.tree_sitter_ruby
@ -60,7 +60,7 @@ parseRubyToAST source = do
ast <- anaM toAST root
ts_document_free document
pure ast
pure (source, ast)
where toAST :: Node -> IO (A.RoseF Ruby.Grammar Node)
toAST Node{..} = do
let count = fromIntegral nodeChildCount