| 2225 | /* ── Convenience: lex + parse ───────────────────────────────────── */ |
| 2226 | |
| 2227 | int cbm_cypher_parse(const char *query, cbm_query_t **out, char **error) { |
| 2228 | *out = NULL; |
| 2229 | *error = NULL; |
| 2230 | |
| 2231 | cbm_lex_result_t lr = {0}; |
| 2232 | if (cbm_lex(query, &lr) < 0 || lr.error) { |
| 2233 | *error = heap_strdup(lr.error ? lr.error : "lex error"); |
| 2234 | cbm_lex_free(&lr); |
| 2235 | return CBM_NOT_FOUND; |
| 2236 | } |
| 2237 | |
| 2238 | cbm_parse_result_t pr = {0}; |
| 2239 | if (cbm_parse(lr.tokens, lr.count, &pr) < 0) { |
| 2240 | *error = heap_strdup(pr.error ? pr.error : "parse error"); |
| 2241 | cbm_parse_free(&pr); |
| 2242 | cbm_lex_free(&lr); |
| 2243 | return CBM_NOT_FOUND; |
| 2244 | } |
| 2245 | |
| 2246 | *out = pr.query; |
| 2247 | pr.query = NULL; |
| 2248 | cbm_parse_free(&pr); |
| 2249 | cbm_lex_free(&lr); |
| 2250 | return 0; |
| 2251 | } |
| 2252 | |
| 2253 | /* ══════════════════════════════════════════════════════════════════ |
| 2254 | * EXECUTOR |
no test coverage detected