#include <ecoli_test.h>
#include <ecoli_strvec.h>
#include <ecoli_node.h>
+#include <ecoli_parsed.h>
+#include <ecoli_completed.h>
#include <ecoli_node_seq.h>
#include <ecoli_node_many.h>
#include <ecoli_node_or.h>
unsigned int paren_len;
};
-static struct ec_parsed *ec_node_expr_parse(const struct ec_node *gen_node,
- const struct ec_strvec *strvec)
+static int ec_node_expr_parse(const struct ec_node *gen_node,
+ struct ec_parsed *state,
+ const struct ec_strvec *strvec)
{
struct ec_node_expr *node = (struct ec_node_expr *)gen_node;
- return ec_node_parse_strvec(node->child, strvec);
+ return ec_node_parse_child(node->child, state, strvec);
}
-static struct ec_completed *ec_node_expr_complete(const struct ec_node *gen_node,
- const struct ec_strvec *strvec)
+static int
+ec_node_expr_complete(const struct ec_node *gen_node,
+ struct ec_completed *completed,
+ struct ec_parsed *parsed,
+ const struct ec_strvec *strvec)
{
struct ec_node_expr *node = (struct ec_node_expr *)gen_node;
- return ec_node_complete_strvec(node->child, strvec);
+ return ec_node_complete_child(node->child, completed, parsed, strvec);
}
static void ec_node_expr_free_priv(struct ec_node *gen_node)
/* create the object, we will initialize it later: this is
* needed because we have a circular dependency */
ret = -ENOMEM;
- weak = ec_node_new("weakref", "weak");
+ weak = ec_node("weakref", "weak");
if (weak == NULL)
return -1;
/* prefix unary operators */
- pre_op = ec_node_new("or", "pre-op");
+ pre_op = ec_node("or", "pre-op");
if (pre_op == NULL)
goto fail;
for (i = 0; i < node->pre_ops_len; i++) {
}
/* suffix unary operators */
- post_op = ec_node_new("or", "post-op");
+ post_op = ec_node("or", "post-op");
if (post_op == NULL)
goto fail;
for (i = 0; i < node->post_ops_len; i++) {
goto fail;
}
- post = ec_node_new("or", "post");
+ post = ec_node("or", "post");
if (post == NULL)
goto fail;
if (ec_node_or_add(post, ec_node_clone(node->val_node)) < 0)
weak = NULL;
node->child = expr;
+ ec_node_dump(stdout, node->child); //XXX
return 0;
return 0;
}
- if (x->has_val && x->op == NULL && y->has_val && y->op != NULL) {
- ret = ops->eval_bin_op(&x->val, userctx, x->val, y->op, y->val);
- if (ret < 0)
- return ret;
+ if (x->has_val && y->has_val && y->op != NULL) {
+ if (y->op_type == BIN_OP) {
+ ret = ops->eval_bin_op(&x->val, userctx, x->val,
+ y->op, y->val);
+ if (ret < 0)
+ return ret;
- return 0;
+ return 0;
+ }
}
if (x->has_val == 0 && x->op != NULL && y->has_val && y->op == NULL) {
return 0;
}
- assert(true); /* we should not get here */
+ assert(false); /* we should not get here */
return -EINVAL;
}