binding: Make parse methods more convenient

* Rename parse_str to parse and make it polymorphic.
* Rename parse_utf8 to parse_with, since it is now the callback-based
  version of parse
* Add a parse_utf16 method analogous to parse
* Rename existing parse_utf16 method to parse_utf16_with

This brings in the changes from tree-sitter/rust-tree-sitter#5
This commit is contained in:
Max Brunsfeld 2019-02-05 10:59:31 -08:00
parent 49392c8502
commit 50281637d7
10 changed files with 89 additions and 169 deletions

View file

@ -33,7 +33,7 @@ pub fn parse_file_at_path(
let time = Instant::now();
let tree = parser
.parse_utf8(&mut |byte, _| &source_code[byte..], None)
.parse(&source_code, None)
.expect("Incompatible language version");
let duration = time.elapsed();
let duration_ms = duration.as_secs() * 1000 + duration.subsec_nanos() as u64 / 1000000;