From: Sebastian Harl Date: Tue, 5 May 2015 21:36:14 +0000 (+0200) Subject: parser: Fixed setup of iterator nodes. X-Git-Tag: sysdb-0.8.0~108 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=85fa98410c3ef44c2b4ce4e5b2902a70b5932689 parser: Fixed setup of iterator nodes. The iterator value was supposed to be an "incomplete operator" node, that is, one of the operands should be NULL. This is actually the case now and this also means we don't have to store the operator type separately. --- diff --git a/src/include/parser/ast.h b/src/include/parser/ast.h index 665caf5..2ae2912 100644 --- a/src/include/parser/ast.h +++ b/src/include/parser/ast.h @@ -189,7 +189,6 @@ typedef struct { typedef struct { sdb_ast_node_t super; int kind; - int op; sdb_ast_node_t *iter; /* exactly one operand of the expression has to be unset and will be * filled in by the iterator value */ @@ -197,7 +196,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, -1, NULL, NULL } + { { SDB_OBJECT_INIT, SDB_AST_TYPE_ITERATOR }, -1, NULL, NULL } /* * sdb_ast_typed_t represents a typed value. @@ -336,8 +335,7 @@ sdb_ast_op_create(int kind, sdb_ast_node_t *left, sdb_ast_node_t *right); * ownership of the iter and expr nodes. */ sdb_ast_node_t * -sdb_ast_iter_create(int kind, int op, - sdb_ast_node_t *iter, sdb_ast_node_t *expr); +sdb_ast_iter_create(int kind, sdb_ast_node_t *iter, sdb_ast_node_t *expr); /* * sdb_ast_typed_create: diff --git a/src/parser/ast.c b/src/parser/ast.c index a64178b..81a4c34 100644 --- a/src/parser/ast.c +++ b/src/parser/ast.c @@ -223,8 +223,7 @@ sdb_ast_op_create(int kind, sdb_ast_node_t *left, sdb_ast_node_t *right) } /* sdb_ast_op_create */ sdb_ast_node_t * -sdb_ast_iter_create(int kind, int op, - sdb_ast_node_t *iter, sdb_ast_node_t *expr) +sdb_ast_iter_create(int kind, sdb_ast_node_t *iter, sdb_ast_node_t *expr) { sdb_ast_iter_t *i; i = SDB_AST_ITER(sdb_object_create(SDB_AST_OP_TO_STRING(kind), iter_type)); @@ -234,7 +233,6 @@ sdb_ast_iter_create(int kind, int op, i->super.type = SDB_AST_TYPE_ITERATOR; i->kind = kind; - i->op = op; i->iter = iter; i->expr = expr; return SDB_AST_NODE(i); diff --git a/src/parser/grammar.y b/src/parser/grammar.y index ed2b070..8014626 100644 --- a/src/parser/grammar.y +++ b/src/parser/grammar.y @@ -453,13 +453,17 @@ comparison: | ANY expression cmp expression { - $$ = sdb_ast_iter_create(SDB_AST_ANY, $3, $2, $4); + sdb_ast_node_t *n = sdb_ast_op_create($3, NULL, $4); + CK_OOM(n); + $$ = sdb_ast_iter_create(SDB_AST_ANY, $2, n); CK_OOM($$); } | ALL expression cmp expression { - $$ = sdb_ast_iter_create(SDB_AST_ALL, $3, $2, $4); + sdb_ast_node_t *n = sdb_ast_op_create($3, NULL, $4); + CK_OOM(n); + $$ = sdb_ast_iter_create(SDB_AST_ALL, $2, n); CK_OOM($$); } |