Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add create support to planner #4

Merged
merged 10 commits into from Feb 16, 2020
6 changes: 5 additions & 1 deletion src/backend/gram.rs
Expand Up @@ -45,6 +45,9 @@ impl GramBackend {
next_rel_index: 0,
state: ExpandState::NextNode
})),
LogicalPlan::Create { .. } => {
panic!("The gram backend does not yet support CREATE statements")
}
LogicalPlan::Return { src, projections } => {
let mut converted_projections = Vec::new();
for projection in projections {
Expand All @@ -65,6 +68,7 @@ impl GramBackend {
frontend::Expr::Lit(v) => Expr::Lit(v),
frontend::Expr::Prop(e, props) => Expr::Prop(Box::new(self.convert_expr(*e)), props),
frontend::Expr::Slot(s) => Expr::Slot(s),
_ => panic!("The gram backend does not support this expression type yet: {:?}", expr)
}
}
}
Expand Down Expand Up @@ -120,7 +124,7 @@ struct Context {
}

#[derive(Debug, Clone)]
pub enum Expr {
enum Expr {
Lit(Val),
// Lookup a property by id
Prop(Box<Expr>, Vec<Token>),
Expand Down
3 changes: 3 additions & 0 deletions src/backend/mod.rs
Expand Up @@ -40,6 +40,9 @@ pub struct Tokens {
}

impl Tokens {
pub fn new() -> Tokens {
Tokens{ table: Default::default() }
}
pub fn lookup(&self, tok: usize) -> Option<&str> {
for (content, candidate) in self.table.iter() {
if *candidate == tok {
Expand Down
4 changes: 3 additions & 1 deletion src/cypher.pest
Expand Up @@ -24,8 +24,10 @@ map_pair = { id ~ ":" ~ expr }
node = { "(" ~ id? ~ ( ":" ~ label )? ~ map? ~ ")" }
label = { id }

rel = { "<"? ~ "-" ~ ( "[" ~ id? ~ ( ":" ~ rel_type )? ~ map? ~ "]" )? ~ "-" ~ ">"? }
rel = { left_arrow? ~ "-" ~ ( "[" ~ id? ~ ( ":" ~ rel_type )? ~ map? ~ "]" )? ~ "-" ~ right_arrow? }
rel_type = { id }
left_arrow = { "<" }
right_arrow = { ">" }

pattern = { node ~ ( rel ~ node )* }

Expand Down