tree-sitter-cypher
v0.2.6
Published
Graph query language
Downloads
827
Maintainers
Readme
tree-sitter-cypher
Tree-sitter grammar for Cypher, the graph query language used by Neo4j and other graph databases.
Install
Node.js
npm install tree-sitter-cypher tree-sitterRust
cargo add tree-sitter-cypherUsage
Node.js
import Parser from "tree-sitter";
import Cypher from "tree-sitter-cypher";
const parser = new Parser();
parser.setLanguage(Cypher);
const tree = parser.parse("MATCH (n:Person {name: $name}) RETURN n");
console.log(tree.rootNode.toString());Rust
let mut parser = tree_sitter::Parser::new();
parser
.set_language(&tree_sitter_cypher::LANGUAGE.into())
.expect("Error loading Cypher parser");
let tree = parser.parse("MATCH (n:Person {name: $name}) RETURN n", None).unwrap();
assert!(!tree.root_node().has_error());Queries
The queries/ directory contains Tree-sitter query files for editor integration:
| File | Purpose |
|------|---------|
| highlights.scm | Syntax highlighting |
| injections.scm | Injects tree-sitter-cypherdoc into /** */ doc comments |
| tags.scm | Symbol tagging for code navigation |
| locals.scm | Variable scope tracking |
Related Packages
- tree-sitter-cypherdoc — Grammar for structured
/** */doc comments in.cypherfiles - cypher — CLI linter for
.cypherfiles
License
MIT
