summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8092b50)
raw | patch | inline | side by side (parent: 8092b50)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 5 May 2015 22:15:09 +0000 (00:15 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 5 May 2015 22:15:09 +0000 (00:15 +0200) |
src/include/parser/ast.h | patch | blob | history | |
src/parser/analyzer.c | patch | blob | history |
index 41fb2179e805e5c1bbd9ea1e3a591b1a685735ae..6a86d06890d70d42c4de3773307b3ff04d489677 100644 (file)
--- a/src/include/parser/ast.h
+++ b/src/include/parser/ast.h
: ((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" \
diff --git a/src/parser/analyzer.c b/src/parser/analyzer.c
index 79c99e3e23e159ae8217a7dec323bf946c8d7e9b..7193fea90bf4281eea185cc862c8014b6108430b 100644 (file)
--- a/src/parser/analyzer.c
+++ b/src/parser/analyzer.c
return -1;
if (analyze_node(context, op->right, errbuf))
return -1;
- SDB_AST_NODE(op)->data_type = sdb_data_expr_type(op->kind,
+ SDB_AST_NODE(op)->data_type = sdb_data_expr_type(SDB_AST_OP_TO_DATA_OP(op->kind),
op->left->data_type, op->right->data_type);
/* TODO: replace constant arithmetic operations with a constant value */