Tree-Sitter
Contents
To use the library #include <tree_. Everything lives in the namespace ts.
Usage Examples
First you have to define the ts:: you want to use:
extern "C" const TSLanguage* tree_sitter_lua(); const ts::Language LUA_LANGUAGE{tree_sitter_lua()};
Now you can create and use a ts:: in a function:
void use_parser() { ts::Parser parser(LUA_LANGUAGE); ts::Tree tree = parser.parse_string("print('Hello, World!')"); }
As you can see parsing returns a ts::. You can walk this tree with a ts:: or query it using ts:: or manually walk the nodes by calling ts::. Additionally you can edit the tree using ts:: (editing is currently relatively limited).