Expand description
This crate provides C++ language support for the tree-sitter parsing library.
Use willbooster-tree-sitter 20.0.0 or later in the 20.x series. The parser carries
WillBooster/tree-sitter ABI 0x5742000c, which upstream Tree-sitter runtimes reject, and omits
unused TSLanguage tables that pre-19.1.0 WillBooster runtimes (17.x and 18.x) dereference
despite sharing ABI 0x5742000c.
Typically, you will use the LANGUAGE constant to add this language to a
tree-sitter Parser, and then use the parser to parse some code:
let code = "#include <iostream>\n\nint main() {\n std::cout << \"Hello\\n\";\n}\n";
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_cpp::LANGUAGE;
parser
.set_language(&language.into())
.expect("Error loading C++ parser");
let tree = parser.parse(code).unwrap();
assert!(!tree.root_node().has_error());Constantsยง
- LANGUAGE
- The tree-sitter
LanguageFnfor this grammar. - NODE_
TYPES - The content of the
node-types.jsonfile for this grammar.