Skip to main content

Crate decypher

Crate decypher 

Source
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:

  1. CST – a lossless concrete syntax tree built on rowan, available via parse_cst and the cst module.
  2. AST – a typed, high-level abstract syntax tree, available via parse and the ast module.
  3. HIR – a lowered, scope-resolved high-level intermediate representation, available via analyze and the hir module (requires the hir feature, 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.
hirhir
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.
ParseOptions
Options that control the behaviour of parse_with_options.

Functions§

analyzehir
Parse and lower a Cypher query into a hir::HirQuery.
analyze_with_confighir
Parse and lower a Cypher query with a custom hir::LowerConfig.
parse
Parse a Cypher query into a typed Query AST.
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 Query AST with an explicit source label used in diagnostics.
parse_with_options
Parse a Cypher query string with explicit ParseOptions.