X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=blobdiff_plain;f=src%2Finclude%2Fparser%2Fast.h;h=80b5a533a539ed57b0c656458b7bf6d6f7b42690;hp=2ae2912b741884ed7ee2db8e7fa42f077756f8f5;hb=f1975b0bdc00eff623288b34961b9de7d83e7ba1;hpb=85fa98410c3ef44c2b4ce4e5b2902a70b5932689 diff --git a/src/include/parser/ast.h b/src/include/parser/ast.h index 2ae2912..80b5a53 100644 --- a/src/include/parser/ast.h +++ b/src/include/parser/ast.h @@ -139,6 +139,15 @@ typedef enum { : ((op) == SDB_AST_ANY) ? "ANY" \ : "UNKNOWN") +#define SDB_AST_OP_TO_DATA_OP(op) \ + (((op) == SDB_AST_ADD) ? SDB_DATA_ADD \ + : ((op) == SDB_AST_SUB) ? SDB_DATA_SUB \ + : ((op) == SDB_AST_MUL) ? SDB_DATA_MUL \ + : ((op) == SDB_AST_DIV) ? SDB_DATA_DIV \ + : ((op) == SDB_AST_MOD) ? SDB_DATA_MOD \ + : ((op) == SDB_AST_CONCAT) ? SDB_DATA_CONCAT \ + : -1) + #define SDB_AST_TYPE_TO_STRING(n) \ (((n)->type == SDB_AST_TYPE_FETCH) ? "FETCH" \ : ((n)->type == SDB_AST_TYPE_LIST) ? "LIST" \ @@ -166,6 +175,9 @@ typedef struct { /* type describes the type of the actual node */ int type; + + /* data-type describes the type of the result value */ + int data_type; } sdb_ast_node_t; #define SDB_AST_NODE(obj) ((sdb_ast_node_t *)(obj)) @@ -181,7 +193,7 @@ typedef struct { } sdb_ast_op_t; #define SDB_AST_OP(obj) ((sdb_ast_op_t *)(obj)) #define SDB_AST_OP_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_OPERATOR }, -1, NULL, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_OPERATOR, -1 }, -1, NULL, NULL } /* * sdb_ast_iter_t represents an iterator. @@ -196,7 +208,7 @@ typedef struct { } sdb_ast_iter_t; #define SDB_AST_ITER(obj) ((sdb_ast_iter_t *)(obj)) #define SDB_AST_ITER_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_ITERATOR }, -1, NULL, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_ITERATOR, -1 }, -1, NULL, NULL } /* * sdb_ast_typed_t represents a typed value. @@ -208,7 +220,7 @@ typedef struct { } sdb_ast_typed_t; #define SDB_AST_TYPED(obj) ((sdb_ast_typed_t *)(obj)) #define SDB_AST_TYPED_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_TYPED }, -1, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_TYPED, -1 }, -1, NULL } /* * sdb_ast_const_t represents a constant value. @@ -219,10 +231,10 @@ typedef struct { } sdb_ast_const_t; #define SDB_AST_CONST(obj) ((sdb_ast_const_t *)(obj)) #define SDB_AST_CONST_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_CONST }, SDB_DATA_INIT } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_CONST, -1 }, SDB_DATA_INIT } /* - * sdb_ast_value_t represents an object-specific value: sibling nodes, + * sdb_ast_value_t represents an object-specific value: * attributes, or field values. */ typedef struct { @@ -232,7 +244,7 @@ typedef struct { } sdb_ast_value_t; #define SDB_AST_VALUE(obj) ((sdb_ast_value_t *)(obj)) #define SDB_AST_VALUE_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_VALUE }, -1, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_VALUE, -1 }, -1, NULL } /* * sdb_ast_fetch_t represents a FETCH command. @@ -246,7 +258,7 @@ typedef struct { } sdb_ast_fetch_t; #define SDB_AST_FETCH(obj) ((sdb_ast_fetch_t *)(obj)) #define SDB_AST_FETCH_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_FETCH }, -1, NULL, NULL, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_FETCH, -1 }, -1, NULL, NULL, NULL } /* * sdb_ast_list_t represents a LIST command. @@ -258,7 +270,7 @@ typedef struct { } sdb_ast_list_t; #define SDB_AST_LIST(obj) ((sdb_ast_list_t *)(obj)) #define SDB_AST_LIST_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_LIST }, -1, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_LIST, -1 }, -1, NULL } /* * sdb_ast_lookup_t represents a LOOKUP command. @@ -271,7 +283,7 @@ typedef struct { } sdb_ast_lookup_t; #define SDB_AST_LOOKUP(obj) ((sdb_ast_lookup_t *)(obj)) #define SDB_AST_LOOKUP_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_LOOKUP }, -1, NULL, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_LOOKUP, -1 }, -1, NULL, NULL } /* * sdb_ast_store_t represents a STORE command. @@ -294,7 +306,7 @@ typedef struct { } sdb_ast_store_t; #define SDB_AST_STORE(obj) ((sdb_ast_store_t *)(obj)) #define SDB_AST_STORE_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_STORE }, \ + { { SDB_OBJECT_INIT, SDB_AST_TYPE_STORE, -1 }, \ -1, NULL, -1, NULL, NULL, 0, NULL, NULL, SDB_DATA_INIT } /* @@ -309,7 +321,7 @@ typedef struct { } sdb_ast_timeseries_t; #define SDB_AST_TIMESERIES(obj) ((sdb_ast_timeseries_t *)(obj)) #define SDB_AST_TIMESERIES_INIT \ - { { SDB_OBJECT_INIT, SDB_AST_TYPE_TIMESERIES }, NULL, NULL, 0, 0 } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_TIMESERIES, -1 }, NULL, NULL, 0, 0 } /* * AST constructors: