| 51 | } |
| 52 | |
| 53 | pub fn parse_cosql_statement(input: &str) -> IResult<&str, CosQLStatement> { |
| 54 | alt(( |
| 55 | preceded( |
| 56 | ws_tag("define"), |
| 57 | alt(( |
| 58 | preceded( |
| 59 | ws_tag("entity"), |
| 60 | map(parse_entity_definition, |ed| { |
| 61 | CosQLStatement::EntityDefinition(ed) |
| 62 | }), |
| 63 | ), |
| 64 | preceded( |
| 65 | ws_tag("relationship"), |
| 66 | map(parse_relationship_definition, |rd| { |
| 67 | CosQLStatement::RelationshipDefinition(rd) |
| 68 | }), |
| 69 | ), |
| 70 | preceded(ws_tag("rule"), map(parse_rule, CosQLStatement::Rule)), |
| 71 | )), |
| 72 | ), |
| 73 | preceded( |
| 74 | ws_tag("insert"), |
| 75 | alt(( |
| 76 | map(parse_entity_insertion, |ei| { |
| 77 | CosQLStatement::EntityInsertion(ei) |
| 78 | }), |
| 79 | map(parse_relationship_insertion, |ri| { |
| 80 | CosQLStatement::RelationshipInsertion(ri) |
| 81 | }), |
| 82 | )), |
| 83 | ), |
| 84 | preceded(ws_tag("match"), map(parse_query, CosQLStatement::Query)), |
| 85 | ))(input) |
| 86 | } |
| 87 | |
| 88 | #[cfg(test)] |
| 89 | mod tests { |