#[derive(Debug, Clone, PartialEq)]
pub enum Literal {
Int(i64),
Float(f64),
String(String),
Bool(bool),
Null,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PropAccess {
pub var: String,
pub prop: String,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CompareOp {
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
}
#[derive(Debug, Clone)]
pub enum Expr {
And(Box<Expr>, Box<Expr>),
Or(Box<Expr>, Box<Expr>),
Not(Box<Expr>),
Compare(PropAccess, CompareOp, Literal),
}
#[derive(Debug, Clone)]
pub enum ReturnExpr {
Var(String),
Prop(PropAccess),
Lit(Literal),
}
#[derive(Debug, Clone)]
pub struct ReturnItem {
pub expr: ReturnExpr,
pub alias: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RelDirection {
Right,
Left,
}
#[derive(Debug, Clone)]
pub struct NodePattern {
pub var: Option<String>,
pub label: Option<String>,
pub props: Vec<(String, Literal)>,
}
#[derive(Debug, Clone)]
pub struct RelPattern {
pub var: Option<String>,
pub rel_type: Option<String>,
#[allow(dead_code)] pub props: Vec<(String, Literal)>,
pub direction: RelDirection,
}
#[derive(Debug, Clone)]
pub struct Pattern {
pub start: NodePattern,
pub hops: Vec<(RelPattern, NodePattern)>,
}
#[derive(Debug, Clone)]
pub enum Tail {
Return(Vec<ReturnItem>),
Delete(Vec<String>),
DetachDelete(Vec<String>),
Set(Vec<(PropAccess, Literal)>),
}
#[derive(Debug, Clone)]
pub enum Statement {
Create(Vec<Pattern>),
Match {
pattern: Pattern,
where_clause: Option<Expr>,
tail: Tail,
limit: Option<i64>,
},
}