validate that allShortestPaths is in a supported place
| 36 | |
| 37 | // validate that allShortestPaths is in a supported place |
| 38 | static bool _ValidateAllShortestPaths |
| 39 | ( |
| 40 | const cypher_astnode_t *root // root to validate |
| 41 | ) { |
| 42 | ASSERT(root != NULL); |
| 43 | |
| 44 | cypher_astnode_type_t t = cypher_astnode_type(root); |
| 45 | // if we found allShortestPaths in invalid parent return true |
| 46 | if(t == CYPHER_AST_SHORTEST_PATH && |
| 47 | !cypher_ast_shortest_path_is_single(root)) { |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | // allShortestPaths is invalid in the MATCH predicate |
| 52 | if(t == CYPHER_AST_MATCH) { |
| 53 | const cypher_astnode_t *predicate = cypher_ast_match_get_predicate(root); |
| 54 | return predicate == NULL || _ValidateAllShortestPaths(predicate); |
| 55 | } |
| 56 | |
| 57 | // recursively traverse all children |
| 58 | uint nchildren = cypher_astnode_nchildren(root); |
| 59 | for(uint i = 0; i < nchildren; i ++) { |
| 60 | const cypher_astnode_t *child = cypher_astnode_get_child(root, i); |
| 61 | if(!_ValidateAllShortestPaths(child)) { |
| 62 | return false; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | return true; |
| 67 | } |
| 68 | |
| 69 | // validate that shortestPaths is in a supported place |
| 70 | static bool _ValidateShortestPaths |
no outgoing calls
no test coverage detected