Skip to content

Commit

Permalink
Updates test consumer tree-sitter version
Browse files Browse the repository at this point in the history
  • Loading branch information
BekaValentine authored and ahelwer committed Sep 28, 2024
1 parent 5424e1d commit b9e3978
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion test/consumers/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ edition = "2021"

[dependencies]
tree-sitter-tlaplus = {path = "../../.."}
tree-sitter = "0.22.5"
tree-sitter-language = "0.1.0"
tree-sitter = "0.23"

11 changes: 8 additions & 3 deletions test/consumers/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ use tree_sitter::{Parser, Query, QueryCursor};

fn main() {
let mut parser = Parser::new();
parser.set_language(&tree_sitter_tlaplus::language()).expect("Error loading TLA+ grammar");
parser
.set_language(&tree_sitter_tlaplus::LANGUAGE.into())
.expect("Error loading TLA+ grammar");
let source_code = r#"
---- MODULE Test ----
op ≜ ∀ n ∈ ℕ : n ≥ 0
===="#;
let tree = parser.parse(source_code, None).unwrap();
println!("{}", tree.root_node().to_sexp());

let query = Query::new(&tree_sitter_tlaplus::language(), "(def_eq \"\") @capture").unwrap();
let query = Query::new(
&tree_sitter_tlaplus::LANGUAGE.into(),
"(def_eq \"\") @capture",
)
.unwrap();
let mut cursor = QueryCursor::new();
for capture in cursor.matches(&query, tree.root_node(), "".as_bytes()) {
println!("{:?}", capture);
}
}

0 comments on commit b9e3978

Please sign in to comment.