1
1
mirror of https://github.com/github/semantic.git synced 2024-12-25 07:55:12 +03:00

Handle the allocation within parseTreeSitterFile.

This commit is contained in:
Rob Rix 2015-11-26 16:09:16 -05:00
parent be6dc5e627
commit 54e931eabe

View File

@ -70,17 +70,15 @@ parseTreeSitterFile file = do
source <- newCString contents
ts_document_set_input_string document source
ts_document_parse document
term <- parse document contents
term <- alloca $ parse document contents
ts_document_free document
free source
putStrLn $ "hooray"
parse :: Ptr TSDocument -> String -> IO (Term String Info)
parse document contents = do
alloca unpack where
unpack root = do
parse :: Ptr TSDocument -> String -> Ptr TSNode -> IO (Term String Info)
parse document contents root = do
ts_document_root_node_p document root
toTerm root
toTerm root where
toTerm :: Ptr TSNode -> IO (Term String Info)
toTerm node = do
name <- ts_node_p_name node document