Code

frontend: Added basic support for semantic AST analysis.
[sysdb.git] / src / include / frontend / parser.h
index 5491e9cac7778c24047ebb71896cdedf44b5781a..e1c9c6fa81e5d3b4e2b6eef91d14b8ed0fc3b3f9 100644 (file)
 #ifndef SDB_FRONTEND_PARSER_H
 #define SDB_FRONTEND_PARSER_H 1
 
+#include "core/store.h"
+#include "frontend/connection.h"
+#include "utils/llist.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+/* parser modes */
+enum {
+       SDB_PARSE_DEFAULT = 0,
+       SDB_PARSE_COND    = 1 << 1,
+       SDB_PARSE_EXPR    = 1 << 2,
+};
+
+/* YY_EXTRA data */
+typedef struct {
+       /* list of sdb_conn_node_t objects */
+       sdb_llist_t *parsetree;
+
+       /* parser mode */
+       int mode;
+} sdb_fe_yyextra_t;
+
 /* see yyscan_t */
 typedef void *sdb_fe_yyscan_t;
 
 sdb_fe_yyscan_t
-sdb_fe_scanner_init(const char *str);
+sdb_fe_scanner_init(const char *str, int len, sdb_fe_yyextra_t *yyext);
 
 void
 sdb_fe_scanner_destroy(sdb_fe_yyscan_t scanner);
@@ -44,6 +64,23 @@ sdb_fe_scanner_destroy(sdb_fe_yyscan_t scanner);
 int
 sdb_fe_yyparse(sdb_fe_yyscan_t scanner);
 
+sdb_store_matcher_t *
+sdb_fe_parse_matcher(const char *cond, int len);
+
+sdb_store_expr_t *
+sdb_fe_parse_expr(const char *expr, int len);
+
+/*
+ * sdb_fe_analyze:
+ * Analyze a parsed node, checking for semantical errors.
+ *
+ * Returns:
+ *  - 0 if the node is semantically correct
+ *  - a negative value else
+ */
+int
+sdb_fe_analyze(sdb_conn_node_t *node);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif