X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Finclude%2Fparser%2Fparser.h;h=2830663f03d8f13843eaa7543e1c18c50ebeccc5;hp=9235ef5820267789cdb77005a6db04dafd602334;hb=24dce6d59414125f1f0fbe8434f5ed9f280d6872;hpb=c8d51914ef24f01f935d2853d57f05d0b0a0af9e diff --git a/src/include/parser/parser.h b/src/include/parser/parser.h index 9235ef5..2830663 100644 --- a/src/include/parser/parser.h +++ b/src/include/parser/parser.h @@ -28,9 +28,6 @@ #ifndef SDB_PARSER_PARSER_H #define SDB_PARSER_PARSER_H 1 -/* TODO: move SDB_PARSE_* constants here as well */ -#include "frontend/parser.h" - #include "core/store.h" #include "parser/ast.h" #include "utils/llist.h" @@ -40,6 +37,18 @@ extern "C" { #endif +/* parser modes */ +enum { + /* parser accepts any command statement */ + SDB_PARSE_DEFAULT = 0, + + /* parser accepts any conditional statement */ + SDB_PARSE_COND = 1 << 1, + + /* parser accepts any arithmetic expression */ + SDB_PARSE_ARITH = 1 << 2, +}; + /* * sdb_parser_parse: * Parse the specified query of the specified length. If len is a negative @@ -72,6 +81,42 @@ sdb_parser_parse_conditional(const char *cond, int len, sdb_strbuf_t *errbuf); sdb_ast_node_t * sdb_parser_parse_arith(const char *expr, int len, sdb_strbuf_t *errbuf); +/* + * sdb_parser_analyze: + * Semantical analysis of a parse-tree. + * + * Returns: + * - 0 on success + * - a negative value else; an error message will be written to the provided + * error buffer + */ +int +sdb_parser_analyze(sdb_ast_node_t *node, sdb_strbuf_t *errbuf); + +/* + * sdb_parser_analyze_conditional: + * Semantical analysis of a conditional node. + * + * Returns: + * - 0 on success + * - a negative value else; an error message will be written to the provided + * error buffer + */ +int +sdb_parser_analyze_conditional(sdb_ast_node_t *node, sdb_strbuf_t *errbuf); + +/* + * sdb_parser_analyze_arith: + * Semantical analysis of an arithmetic node. + * + * Returns: + * - 0 on success + * - a negative value else; an error message will be written to the provided + * error buffer + */ +int +sdb_parser_analyze_arith(sdb_ast_node_t *node, sdb_strbuf_t *errbuf); + /* * Low-level interface. */