mirror of
https://github.com/github/semantic.git
synced 2024-12-23 06:41:45 +03:00
Return the Source alongside the AST.
This makes for easier chaining.
This commit is contained in:
parent
9a0361d74d
commit
a29b7b6f2b
@ -46,7 +46,7 @@ treeSitterParser language grammar blob = do
|
|||||||
pure term
|
pure term
|
||||||
|
|
||||||
|
|
||||||
parseRubyToAST :: Source -> IO (A.Rose Ruby.Grammar)
|
parseRubyToAST :: Source -> IO (Source, A.Rose Ruby.Grammar)
|
||||||
parseRubyToAST source = do
|
parseRubyToAST source = do
|
||||||
document <- ts_document_new
|
document <- ts_document_new
|
||||||
ts_document_set_language document Ruby.tree_sitter_ruby
|
ts_document_set_language document Ruby.tree_sitter_ruby
|
||||||
@ -60,7 +60,7 @@ parseRubyToAST source = do
|
|||||||
ast <- anaM toAST root
|
ast <- anaM toAST root
|
||||||
|
|
||||||
ts_document_free document
|
ts_document_free document
|
||||||
pure ast
|
pure (source, ast)
|
||||||
where toAST :: Node -> IO (A.RoseF Ruby.Grammar Node)
|
where toAST :: Node -> IO (A.RoseF Ruby.Grammar Node)
|
||||||
toAST Node{..} = do
|
toAST Node{..} = do
|
||||||
let count = fromIntegral nodeChildCount
|
let count = fromIntegral nodeChildCount
|
||||||
|
Loading…
Reference in New Issue
Block a user