tree-sitter-cpp
repository·master·Indexed 19 days ago
https://github.com/tree-sitter/tree-sitter-cppA concrete syntax tree grammar for the C++ programming language designed for the tree-sitter incremental parsing engine. It enables syntax highlighting, code navigation, and structural analysis, and provides Node.js bindings including nodeTypeInfo for accessing grammar metadata.
What's inside tree-sitter-cpp
- tree-sitter-cpp provides a C++ grammar for the tree-sitter incremental parsing library. It allows developers to generate concrete syntax trees for C++ source code, enabling features like syntax highlighting, code navigation, and structural analysis in editors and tools.
Import the tree-sitter-cpp Node.js bindings
masterTo use the C++ grammar in a Node.js or Bun environment, require the
tree-sitter-cpppackage. The module automatically selects the correct prebuilt binary based on your platform and architecture. If you are using Bun withbun build --compile, the module is designed to be statically analyzable to locate the required.nodefile.Note that the module also exports
nodeTypeInfo, which provides metadata about the C++ node types defined in the grammar.const parser = require('tree-sitter-cpp'); // Access node type metadata if needed const nodeTypes = parser.nodeTypeInfo;Access C++ node type metadata via nodeTypeInfo
masterThetree-sitter-cppmodule exports an optional propertynodeTypeInfo. This property contains a JSON object mapping node types to their specific information, sourced from the grammar'ssrc/node-types.json. This is useful for inspecting the structure of the C++ grammar programmatically.