1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//! Semantic analysis for Cypher queries.
//!
//! The semantic analyzer performs name resolution, scope tracking, and
//! aggregation-rule validation over a parsed [`Query`] AST.
//!
//! # Phases
//!
//! 1. **Name resolution** ([`resolve_names`]) — walks the query and verifies
//! that every variable reference is bound in the visible scope. Reports
//! [`SemaError::UnresolvedVariable`] and [`SemaError::RedeclaredVariable`]
//! diagnostics.
//!
//! 2. **Aggregation validation** ([`check_aggregation`]) — checks that `WITH`
//! and `RETURN` projections do not mix aggregate and non-aggregate
//! (non-grouping) expressions, and that `DISTINCT` is used in valid
//! positions.
pub use ;
pub use SemaError;
pub use ;
pub use ;
use crateQuery;
use crateDiagnostics;
/// Perform full semantic analysis on `query`.
///
/// Runs all semantic analysis phases in order:
/// 1. Name resolution
/// 2. Aggregation validation
///
/// Returns `Ok(())` when no errors were found, or `Err(Diagnostics)` with
/// all semantic issues discovered.
///
/// # Example
///
/// ```
/// use decypher::{parse, sema};
///
/// let query = parse("MATCH (n) RETURN n").unwrap();
/// assert!(sema::analyze(&query).is_ok());
/// ```
/// Perform full semantic analysis on `query`, returning all diagnostics.
///
/// Unlike [`analyze`], this function always succeeds and returns the
/// diagnostics as a [`Diagnostics`] value rather than a `Result`. The
/// returned [`Diagnostics`] is empty when the query is semantically valid.
///
/// # Example
///
/// ```
/// use decypher::{parse, sema};
///
/// let query = parse("MATCH (n) RETURN n").unwrap();
/// let diags = sema::analyze_all(&query);
/// assert!(diags.is_empty());
/// ```