X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Finclude%2Ffrontend%2Fparser.h;h=766570157e426cfdab440db1b10be8ac958d8147;hp=738071b75da0344a9b09e48cdc3e2d4226ea6135;hb=5ced2b9eb4d4def7d3ad5b1172004293e7a68e0e;hpb=e7edc6432f63f36a2508b4c426876593678c8434 diff --git a/src/include/frontend/parser.h b/src/include/frontend/parser.h index 738071b..7665701 100644 --- a/src/include/frontend/parser.h +++ b/src/include/frontend/parser.h @@ -29,7 +29,9 @@ #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" { @@ -37,8 +39,14 @@ extern "C" { /* parser modes */ enum { + /* parser accepts any command statement */ SDB_PARSE_DEFAULT = 0, - SDB_PARSE_EXPR, + + /* parser accepts any conditional statement */ + SDB_PARSE_COND = 1 << 1, + + /* parser accepts any arithmetic expression */ + SDB_PARSE_ARITH = 1 << 2, }; /* YY_EXTRA data */ @@ -48,6 +56,9 @@ typedef struct { /* parser mode */ int mode; + + /* buffer for parser error messages */ + sdb_strbuf_t *errbuf; } sdb_fe_yyextra_t; /* see yyscan_t */ @@ -63,7 +74,22 @@ int sdb_fe_yyparse(sdb_fe_yyscan_t scanner); sdb_store_matcher_t * -sdb_fe_parse_matcher(const char *expr, 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" */