docs.rs failed to build tree-sitter-c2rust-0.25.2
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
tree-sitter-c2rust-0.24.7
Rust Tree-sitter
Rust bindings to the Tree-sitter parsing library.
Basic Usage
First, create a parser:
use ;
let mut parser = new;
Add the cc
crate to your Cargo.toml
under [build-dependencies]
:
[]
="*"
Then, add a language as a dependency:
[]
= "0.24"
= "0.23"
To then use a language, you assign them to the parser.
parser.set_language.expect;
Now you can parse source code:
let source_code = "fn test() {}";
let mut tree = parser.parse.unwrap;
let root_node = tree.root_node;
assert_eq!;
assert_eq!;
assert_eq!;
Editing
Once you have a syntax tree, you can update it when your source code changes.
Passing in the previous edited tree makes parse
run much more quickly:
let new_source_code = "fn test(a: u32) {}";
tree.edit;
let new_tree = parser.parse;
Text Input
The source code to parse can be provided either as a string, a slice, a vector, or as a function that returns a slice. The text can be encoded as either UTF8 or UTF16:
// Store some source code in an array of lines.
let lines = &;
// Parse the source code using a custom callback. The callback is called
// with both a byte offset and a row/column offset.
let tree = parser.parse_with.unwrap;
assert_eq!;
Features
- std - This feature is enabled by default and allows
tree-sitter
to use the standard library.- Error types implement the
std::error:Error
trait. regex
performance optimizations are enabled.- The DOT graph methods are enabled.
- Error types implement the
- wasm - This feature allows
tree-sitter
to be built for Wasm targets using thewasmtime-c-api
crate.