Tree-sitter grammar for Cypher, the graph query language used by Neo4j and other graph databases.
Node.js
npm install tree-sitter-cypher tree-sitterRust
cargo add tree-sitter-cypherNode.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());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 |
- tree-sitter-cypherdoc — Grammar for structured
/** */doc comments in.cypherfiles - cypher — CLI linter for
.cypherfiles
MIT