Expand description
A Rust library for parsing Cypher queries into a typed AST.
§Overview
This crate exposes three levels of representation for a Cypher query string:
- CST – a lossless concrete syntax tree built on rowan, available
via
parse_cstand thecstmodule. - AST – a typed, high-level abstract syntax tree, available via
parseand theastmodule. - HIR – a lowered, scope-resolved high-level intermediate
representation, available via
analyzeand thehirmodule (requires thehirfeature, enabled by default).
§Quick start
use decypher::parse;
let query = parse("MATCH (n:Person) RETURN n.name").unwrap();
println!("{} statement(s)", query.statements.len());For multi-error recovery use parse_all:
use decypher::parse_all;
let (query, diagnostics) = parse_all("RETURN;");
assert!(query.is_none());
assert!(!diagnostics.is_empty());Re-exports§
pub use crate::ast::query::Query;pub use crate::error::CypherError;pub use crate::error::Diagnostics;pub use crate::error::ErrorKind;pub use crate::error::Expected;pub use crate::error::Note;pub use crate::error::Result;pub use crate::error::Span;
Modules§
- ast
- Typed abstract syntax tree (AST) for Cypher queries.
- cst
- Typed CST/AST wrappers over the lossless rowan CST.
- error
- Rich error types and diagnostics for Cypher parsing.
- hir
hir - High-level intermediate representation (HIR) for Cypher queries.
- sema
- Semantic analysis for Cypher queries.
- syntax
- Syntactic vocabulary for the Cypher lossless CST.
Structs§
- Parse
- Result of parsing: a CST and any diagnostics.
- Parse
Options - Options that control the behaviour of
parse_with_options.
Functions§
- analyze
hir - Parse and lower a Cypher query into a
hir::HirQuery. - analyze_
with_ config hir - Parse and lower a Cypher query with a custom
hir::LowerConfig. - parse
- Parse a Cypher query into a typed
QueryAST. - parse_
all - Parse a Cypher query string in error-recovery mode, returning all diagnostics discovered during parsing.
- parse_
cst - Parse a Cypher query string into the lossless rowan CST.
- parse_
with_ label - Parse a Cypher query into a typed
QueryAST with an explicit source label used in diagnostics. - parse_
with_ options - Parse a Cypher query string with explicit
ParseOptions.