1
1
mirror of https://github.com/github/semantic.git synced 2025-01-01 19:55:34 +03:00

Add an inner category mapping function

This commit is contained in:
Matt Diephouse 2016-02-10 14:56:21 -08:00
parent b3458e8ac6
commit bc95b7c86c

View File

@ -51,6 +51,9 @@ treeSitterParser language = parserForGrammar <$> grammar
JavaScript -> Just ts_language_javascript
_ -> Nothing
-- | Given a node name from TreeSitter, return the correct category.
categoryMapping = categoryForNodeName
-- | Returns a parser for the given TreeSitter language.
parserForGrammar :: Ptr TSLanguage -> Parser
parserForGrammar language contents = do
@ -59,7 +62,7 @@ treeSitterParser language = parserForGrammar <$> grammar
withCString (toList contents) (\source -> do
ts_document_set_input_string document source
ts_document_parse document
term <- documentToTerm (termConstructor categoryForNodeName) document contents
term <- documentToTerm (termConstructor categoryMapping) document contents
ts_document_free document
return term)