summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8c60138)
raw | patch | inline | side by side (parent: 8c60138)
author | Sebastian Harl <sh@tokkee.org> | |
Tue, 5 May 2015 21:36:14 +0000 (23:36 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Tue, 5 May 2015 21:36:14 +0000 (23:36 +0200) |
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.
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.
src/include/parser/ast.h | patch | blob | history | |
src/parser/ast.c | patch | blob | history | |
src/parser/grammar.y | patch | blob | history |
index 665caf50f174118efb3bd1d30590d301d43e098e..2ae2912b741884ed7ee2db8e7fa42f077756f8f5 100644 (file)
--- a/src/include/parser/ast.h
+++ b/src/include/parser/ast.h
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 */
} 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.
* 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 a64178bdd6e35e6fce4f43b2db4dace1d899806a..81a4c343e37e4d2edf5e80e2f9398c510d6da1c1 100644 (file)
--- a/src/parser/ast.c
+++ b/src/parser/ast.c
} /* 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));
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 ed2b070dbb23fef9b2af493286ba3fea4653ac97..801462617755d305739e4ef28ac237dd8ce4d5cd 100644 (file)
--- a/src/parser/grammar.y
+++ b/src/parser/grammar.y
|
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($$);
}
|