| 2013 | /* ── Convenience: lex + parse ───────────────────────────────────── */ |
| 2014 | |
| 2015 | int cbm_cypher_parse(const char *query, cbm_query_t **out, char **error) { |
| 2016 | *out = NULL; |
| 2017 | *error = NULL; |
| 2018 | |
| 2019 | cbm_lex_result_t lr = {0}; |
| 2020 | if (cbm_lex(query, &lr) < 0 || lr.error) { |
| 2021 | *error = heap_strdup(lr.error ? lr.error : "lex error"); |
| 2022 | cbm_lex_free(&lr); |
| 2023 | return CBM_NOT_FOUND; |
| 2024 | } |
| 2025 | |
| 2026 | cbm_parse_result_t pr = {0}; |
| 2027 | if (cbm_parse(lr.tokens, lr.count, &pr) < 0) { |
| 2028 | *error = heap_strdup(pr.error ? pr.error : "parse error"); |
| 2029 | cbm_parse_free(&pr); |
| 2030 | cbm_lex_free(&lr); |
| 2031 | return CBM_NOT_FOUND; |
| 2032 | } |
| 2033 | |
| 2034 | *out = pr.query; |
| 2035 | pr.query = NULL; |
| 2036 | cbm_parse_free(&pr); |
| 2037 | cbm_lex_free(&lr); |
| 2038 | return 0; |
| 2039 | } |
| 2040 | |
| 2041 | /* ══════════════════════════════════════════════════════════════════ |
| 2042 | * EXECUTOR |
no test coverage detected