index c5fb4ab1207f399d5429923faa3c8181a39b66d2..b451ed5b6e88504980c008a42d132d871d50838c 100644 (file)
#define SDB_FRONTEND_PARSER_H 1
#include "core/store.h"
+#include "frontend/connection.h"
#include "utils/llist.h"
+#include "utils/strbuf.h"
#ifdef __cplusplus
extern "C" {
/* parser modes */
enum {
SDB_PARSE_DEFAULT = 0,
- SDB_PARSE_COND,
+ SDB_PARSE_COND = 1 << 1,
+ SDB_PARSE_EXPR = 1 << 2,
};
/* YY_EXTRA data */
/* parser mode */
int mode;
+
+ /* buffer for parser error messages */
+ sdb_strbuf_t *errbuf;
} sdb_fe_yyextra_t;
/* see yyscan_t */
sdb_fe_yyparse(sdb_fe_yyscan_t scanner);
sdb_store_matcher_t *
-sdb_fe_parse_matcher(const char *cond, int len);
+sdb_fe_parse_matcher(const char *cond, int len, sdb_strbuf_t *errbuf);
+
+sdb_store_expr_t *
+sdb_fe_parse_expr(const char *expr, int len, sdb_strbuf_t *errbuf);
+
+/*
+ * sdb_fe_analyze:
+ * Analyze a parsed node, checking for semantical errors. Error messages will
+ * be written to the string buffer, if provided.
+ *
+ * Returns:
+ * - 0 if the node is semantically correct
+ * - a negative value else
+ */
+int
+sdb_fe_analyze(sdb_conn_node_t *node, sdb_strbuf_t *errbuf);
#ifdef __cplusplus
} /* extern "C" */