save
authorOlivier Matz <zer0@droids-corp.org>
Thu, 15 Jun 2017 19:53:45 +0000 (21:53 +0200)
committerOlivier Matz <zer0@droids-corp.org>
Thu, 15 Jun 2017 19:53:45 +0000 (21:53 +0200)
20 files changed:
lib/ecoli_tk.c
lib/ecoli_tk.h
lib/ecoli_tk_cmd.c
lib/ecoli_tk_empty.c
lib/ecoli_tk_expr.c
lib/ecoli_tk_expr_test.c
lib/ecoli_tk_int.c
lib/ecoli_tk_many.c
lib/ecoli_tk_option.c
lib/ecoli_tk_or.c
lib/ecoli_tk_re.c
lib/ecoli_tk_re_lex.c
lib/ecoli_tk_seq.c
lib/ecoli_tk_sh_lex.c
lib/ecoli_tk_space.c
lib/ecoli_tk_str.c
lib/ecoli_tk_subset.c
lib/ecoli_tk_weakref.c
lib/main-readline.c
lib/todo.txt

index 7fed400..5867fbe 100644 (file)
@@ -56,6 +56,9 @@ int ec_tk_type_register(struct ec_tk_type *type)
 {
        if (ec_tk_type_lookup(type->name) != NULL)
                return -EEXIST;
+       if (type->size < sizeof(struct ec_tk))
+               return -EINVAL;
+
        TAILQ_INSERT_TAIL(&tk_type_list, type, next);
 
        return 0;
@@ -69,17 +72,14 @@ void ec_tk_type_dump(FILE *out)
                fprintf(out, "%s\n", type->name);
 }
 
-struct ec_tk *ec_tk_new(const char *id, const struct ec_tk_type *type,
-       size_t size)
+struct ec_tk *__ec_tk_new(const struct ec_tk_type *type, const char *id)
 {
        struct ec_tk *tk = NULL;
        char buf[256]; // XXX
 
-       assert(size >= sizeof(*tk));
-
        ec_log(EC_LOG_DEBUG, "create node type=%s id=%s\n", type->name, id);
 
-       tk = ec_calloc(1, size);
+       tk = ec_calloc(1, type->size);
        if (tk == NULL)
                goto fail;
 
@@ -109,6 +109,19 @@ struct ec_tk *ec_tk_new(const char *id, const struct ec_tk_type *type,
        return NULL;
 }
 
+struct ec_tk *ec_tk_new(const char *typename, const char *id)
+{
+       struct ec_tk_type *type;
+
+       type = ec_tk_type_lookup(typename);
+       if (type == NULL) {
+               ec_log(EC_LOG_ERR, "type=%s does not exist\n", typename);
+               return NULL;
+       }
+
+       return __ec_tk_new(type, id);
+}
+
 void ec_tk_free(struct ec_tk *tk)
 {
        if (tk == NULL)
index 6aa1c77..cdcf625 100644 (file)
@@ -47,6 +47,7 @@ typedef struct ec_parsed_tk *(*ec_tk_parse_t)(const struct ec_tk *tk,
 typedef struct ec_completed_tk *(*ec_tk_complete_t)(const struct ec_tk *tk,
        const struct ec_strvec *strvec);
 typedef const char * (*ec_tk_desc_t)(const struct ec_tk *);
+typedef void (*ec_tk_init_priv_t)(struct ec_tk *);
 typedef void (*ec_tk_free_priv_t)(struct ec_tk *);
 
 #define EC_TK_TYPE_REGISTER(t)                                         \
@@ -70,6 +71,8 @@ struct ec_tk_type {
        ec_tk_parse_t parse;
        ec_tk_complete_t complete;
        ec_tk_desc_t desc;
+       size_t size;
+       ec_tk_init_priv_t init_priv;
        ec_tk_free_priv_t free_priv;
 };
 
@@ -116,8 +119,12 @@ struct ec_tk {
        struct ec_tk_list children;
 };
 
-struct ec_tk *ec_tk_new(const char *id, const struct ec_tk_type *type,
-       size_t priv_size);
+/* create a new token when the type is known, typically called from the node
+ * code */
+struct ec_tk *__ec_tk_new(const struct ec_tk_type *type, const char *id);
+
+/* create a_new token node */
+struct ec_tk *ec_tk_new(const char *typename, const char *id);
 
 void ec_tk_free(struct ec_tk *tk);
 
index 2f702ee..03ccb60 100644 (file)
@@ -273,7 +273,7 @@ static int ec_tk_cmd_build(struct ec_tk *gen_tk)
 
        /* build the expression parser */
        ret = -ENOMEM;
-       expr = ec_tk_expr("expr");
+       expr = ec_tk_new("expr", "expr");
        if (expr == NULL)
                goto fail;
        ret = ec_tk_expr_set_val_tk(expr, ec_tk_re(NULL, "[a-zA-Z0-9]+"));
@@ -338,7 +338,7 @@ static int ec_tk_cmd_build(struct ec_tk *gen_tk)
                goto fail;
 
        ret = -ENOMEM;
-       cmd = ec_tk_seq(NULL);
+       cmd = ec_tk_new("seq", NULL);
        if (cmd == NULL)
                goto fail;
 
@@ -375,6 +375,7 @@ static struct ec_tk_type ec_tk_cmd_type = {
        .build = ec_tk_cmd_build,
        .parse = ec_tk_cmd_parse,
        .complete = ec_tk_cmd_complete,
+       .size = sizeof(struct ec_tk_cmd),
        .free_priv = ec_tk_cmd_free_priv,
 };
 
@@ -416,7 +417,7 @@ struct ec_tk *ec_tk_cmd(const char *id, const char *cmd_str)
        struct ec_tk *gen_tk = NULL;
        struct ec_tk_cmd *tk = NULL;
 
-       gen_tk = ec_tk_new(id, &ec_tk_cmd_type, sizeof(*tk));
+       gen_tk = __ec_tk_new(&ec_tk_cmd_type, id);
        if (gen_tk == NULL)
                goto fail;
 
index be487d0..a2b366c 100644 (file)
@@ -69,22 +69,17 @@ static struct ec_tk_type ec_tk_empty_type = {
        .name = "empty",
        .parse = ec_tk_empty_parse,
        .complete = ec_tk_default_complete,
+       .size = sizeof(struct ec_tk_empty),
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_empty_type);
 
-struct ec_tk *ec_tk_empty(const char *id)
-{
-       return ec_tk_new(id, &ec_tk_empty_type,
-               sizeof(struct ec_tk_empty));
-}
-
 static int ec_tk_empty_testcase(void)
 {
        struct ec_tk *tk;
        int ret = 0;
 
-       tk = ec_tk_empty(NULL);
+       tk = ec_tk_new("empty", NULL);
        if (tk == NULL) {
                ec_log(EC_LOG_ERR, "cannot create tk\n");
                return -1;
@@ -95,7 +90,7 @@ static int ec_tk_empty_testcase(void)
        ec_tk_free(tk);
 
        /* never completes */
-       tk = ec_tk_empty(NULL);
+       tk = ec_tk_new("empty", NULL);
        if (tk == NULL) {
                ec_log(EC_LOG_ERR, "cannot create tk\n");
                return -1;
index 40dbd1b..661e756 100644 (file)
@@ -125,12 +125,12 @@ static int ec_tk_expr_build(struct ec_tk *gen_tk)
        /* create the object, we will initialize it later: this is
         * needed because we have a circular dependency */
        ret = -ENOMEM;
-       weak = ec_tk_weakref_empty("weak");
+       weak = ec_tk_new("weakref", "weak");
        if (weak == NULL)
                return -1;
 
        /* prefix unary operators */
-       pre_op = ec_tk_or("pre-op");
+       pre_op = ec_tk_new("or", "pre-op");
        if (pre_op == NULL)
                goto fail;
        for (i = 0; i < tk->pre_ops_len; i++) {
@@ -139,7 +139,7 @@ static int ec_tk_expr_build(struct ec_tk *gen_tk)
        }
 
        /* suffix unary operators */
-       post_op = ec_tk_or("post-op");
+       post_op = ec_tk_new("or", "post-op");
        if (post_op == NULL)
                goto fail;
        for (i = 0; i < tk->post_ops_len; i++) {
@@ -147,7 +147,7 @@ static int ec_tk_expr_build(struct ec_tk *gen_tk)
                        goto fail;
        }
 
-       post = ec_tk_or("post");
+       post = ec_tk_new("or", "post");
        if (post == NULL)
                goto fail;
        if (ec_tk_or_add(post, ec_tk_clone(tk->val_tk)) < 0)
@@ -224,24 +224,12 @@ static struct ec_tk_type ec_tk_expr_type = {
        .build = ec_tk_expr_build,
        .parse = ec_tk_expr_parse,
        .complete = ec_tk_expr_complete,
+       .size = sizeof(struct ec_tk_expr),
        .free_priv = ec_tk_expr_free_priv,
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_expr_type);
 
-struct ec_tk *ec_tk_expr(const char *id)
-{
-       struct ec_tk_expr *tk = NULL;
-       struct ec_tk *gen_tk = NULL;
-
-       gen_tk = ec_tk_new(id, &ec_tk_expr_type, sizeof(*tk));
-       if (gen_tk == NULL)
-               return NULL;
-       tk = (struct ec_tk_expr *)gen_tk;
-
-       return gen_tk;
-}
-
 int ec_tk_expr_set_val_tk(struct ec_tk *gen_tk, struct ec_tk *val_tk)
 {
        struct ec_tk_expr *tk = (struct ec_tk_expr *)gen_tk;
index be28797..4a00cdf 100644 (file)
@@ -219,7 +219,7 @@ static int ec_tk_expr_testcase(void)
        struct ec_tk *tk = NULL, *lex_tk = NULL;
        int ret = 0;
 
-       tk = ec_tk_expr("expr");
+       tk = ec_tk_new("expr", "my_expr");
        if (tk == NULL)
                return -1;
 
index a3510b3..905f516 100644 (file)
@@ -28,6 +28,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
 #include <limits.h>
 #include <ctype.h>
 #include <errno.h>
@@ -41,7 +43,9 @@
 
 struct ec_tk_int {
        struct ec_tk gen;
+       bool check_min;
        long long int min;
+       bool check_max;
        long long int max;
        unsigned int base;
 };
@@ -59,7 +63,10 @@ static int parse_llint(struct ec_tk_int *tk, const char *str,
                        (errno != 0 && *val == 0))
                return -1;
 
-       if (*val < tk->min || *val > tk->max)
+       if (tk->check_min && *val < tk->min)
+               return -1;
+
+       if (tk->check_max && *val > tk->max)
                return -1;
 
        if (*endptr != 0)
@@ -105,6 +112,7 @@ static struct ec_tk_type ec_tk_int_type = {
        .name = "int",
        .parse = ec_tk_int_parse,
        .complete = ec_tk_default_complete,
+       .size = sizeof(struct ec_tk_int),
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_int_type);
@@ -115,12 +123,14 @@ struct ec_tk *ec_tk_int(const char *id, long long int min,
        struct ec_tk *gen_tk = NULL;
        struct ec_tk_int *tk = NULL;
 
-       gen_tk = ec_tk_new(id, &ec_tk_int_type, sizeof(*tk));
+       gen_tk = __ec_tk_new(&ec_tk_int_type, id);
        if (gen_tk == NULL)
                return NULL;
        tk = (struct ec_tk_int *)gen_tk;
 
+       tk->check_min = true;
        tk->min = min;
+       tk->check_max = true;
        tk->max = max;
        tk->base = base;
 
index 09e5b51..235f22a 100644 (file)
@@ -177,6 +177,7 @@ static struct ec_tk_type ec_tk_many_type = {
        .parse = ec_tk_many_parse,
        .complete = ec_tk_default_complete,
 //XXX  .complete = ec_tk_many_complete,
+       .size = sizeof(struct ec_tk_many),
        .free_priv = ec_tk_many_free_priv,
 };
 
@@ -190,8 +191,7 @@ struct ec_tk *ec_tk_many(const char *id, struct ec_tk *child,
        if (child == NULL)
                return NULL;
 
-       tk = (struct ec_tk_many *)ec_tk_new(id, &ec_tk_many_type,
-               sizeof(*tk));
+       tk = (struct ec_tk_many *)__ec_tk_new(&ec_tk_many_type, id);
        if (tk == NULL) {
                ec_tk_free(child);
                return NULL;
index 0038a52..080ca37 100644 (file)
@@ -98,6 +98,7 @@ static struct ec_tk_type ec_tk_option_type = {
        .name = "option",
        .parse = ec_tk_option_parse,
        .complete = ec_tk_option_complete,
+       .size = sizeof(struct ec_tk_option),
        .free_priv = ec_tk_option_free_priv,
 };
 
@@ -111,7 +112,7 @@ struct ec_tk *ec_tk_option_new(const char *id, struct ec_tk *child)
        if (child == NULL)
                return NULL;
 
-       gen_tk = ec_tk_new(id, &ec_tk_option_type, sizeof(*tk));
+       gen_tk = __ec_tk_new(&ec_tk_option_type, id);
        if (gen_tk == NULL) {
                ec_tk_free(child);
                return NULL;
index 30e2de4..0debd9c 100644 (file)
@@ -150,30 +150,15 @@ int ec_tk_or_add(struct ec_tk *gen_tk, struct ec_tk *child)
 }
 
 static struct ec_tk_type ec_tk_or_type = {
-       .name = "tk_or",
+       .name = "or",
        .parse = ec_tk_or_parse,
        .complete = ec_tk_or_complete,
+       .size = sizeof(struct ec_tk_or),
        .free_priv = ec_tk_or_free_priv,
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_or_type);
 
-struct ec_tk *ec_tk_or(const char *id)
-{
-       struct ec_tk *gen_tk = NULL;
-       struct ec_tk_or *tk = NULL;
-
-       gen_tk = ec_tk_new(id, &ec_tk_or_type, sizeof(*tk));
-       if (gen_tk == NULL)
-               return NULL;
-
-       tk = (struct ec_tk_or *)gen_tk;
-       tk->table = NULL;
-       tk->len = 0;
-
-       return gen_tk;
-}
-
 struct ec_tk *__ec_tk_or(const char *id, ...)
 {
        struct ec_tk *gen_tk = NULL;
@@ -184,7 +169,7 @@ struct ec_tk *__ec_tk_or(const char *id, ...)
 
        va_start(ap, id);
 
-       gen_tk = ec_tk_or(id);
+       gen_tk = __ec_tk_new(&ec_tk_or_type, id);
        tk = (struct ec_tk_or *)gen_tk;
        if (tk == NULL)
                fail = 1;;
index e5aec25..fc5c184 100644 (file)
@@ -91,22 +91,12 @@ static struct ec_tk_type ec_tk_re_type = {
        .name = "re",
        .parse = ec_tk_re_parse,
        .complete = ec_tk_default_complete,
+       .size = sizeof(struct ec_tk_re),
        .free_priv = ec_tk_re_free_priv,
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_re_type);
 
-struct ec_tk *ec_tk_re_new(const char *id)
-{
-       struct ec_tk *gen_tk = NULL;
-
-       gen_tk = ec_tk_new(id, &ec_tk_re_type, sizeof(struct ec_tk_re));
-       if (gen_tk == NULL)
-               return NULL;
-
-       return gen_tk;
-}
-
 int ec_tk_re_set_regexp(struct ec_tk *gen_tk, const char *str)
 {
        struct ec_tk_re *tk = (struct ec_tk_re *)gen_tk;
@@ -137,7 +127,7 @@ struct ec_tk *ec_tk_re(const char *id, const char *re_str)
 {
        struct ec_tk *gen_tk = NULL;
 
-       gen_tk = ec_tk_re_new(id);
+       gen_tk = __ec_tk_new(&ec_tk_re_type, id);
        if (gen_tk == NULL)
                goto fail;
 
index fb1d73c..984ec3f 100644 (file)
@@ -156,6 +156,7 @@ static struct ec_tk_type ec_tk_re_lex_type = {
        .name = "re_lex",
        .parse = ec_tk_re_lex_parse,
        //.complete = ec_tk_re_lex_complete, //XXX
+       .size = sizeof(struct ec_tk_re_lex),
        .free_priv = ec_tk_re_lex_free_priv,
 };
 
@@ -210,8 +211,7 @@ struct ec_tk *ec_tk_re_lex(const char *id, struct ec_tk *child)
        if (child == NULL)
                return NULL;
 
-       tk = (struct ec_tk_re_lex *)ec_tk_new(id, &ec_tk_re_lex_type,
-               sizeof(*tk));
+       tk = (struct ec_tk_re_lex *)__ec_tk_new(&ec_tk_re_lex_type, id);
        if (tk == NULL) {
                ec_tk_free(child);
                return NULL;
index 91bb91c..17673d6 100644 (file)
@@ -167,6 +167,7 @@ static struct ec_tk_type ec_tk_seq_type = {
        .name = "seq",
        .parse = ec_tk_seq_parse,
        .complete = ec_tk_seq_complete,
+       .size = sizeof(struct ec_tk_seq),
        .free_priv = ec_tk_seq_free_priv,
 };
 
@@ -202,22 +203,6 @@ int ec_tk_seq_add(struct ec_tk *gen_tk, struct ec_tk *child)
        return 0;
 }
 
-struct ec_tk *ec_tk_seq(const char *id)
-{
-       struct ec_tk *gen_tk = NULL;
-       struct ec_tk_seq *tk = NULL;
-
-       gen_tk = ec_tk_new(id, &ec_tk_seq_type, sizeof(*tk));
-       if (gen_tk == NULL)
-               return NULL;
-
-       tk = (struct ec_tk_seq *)gen_tk;
-       tk->table = NULL;
-       tk->len = 0;
-
-       return gen_tk;
-}
-
 struct ec_tk *__ec_tk_seq(const char *id, ...)
 {
        struct ec_tk *gen_tk = NULL;
@@ -228,7 +213,7 @@ struct ec_tk *__ec_tk_seq(const char *id, ...)
 
        va_start(ap, id);
 
-       gen_tk = ec_tk_seq(id);
+       gen_tk = __ec_tk_new(&ec_tk_seq_type, id);
        tk = (struct ec_tk_seq *)gen_tk;
        if (tk == NULL)
                fail = 1;;
index add0186..204ed79 100644 (file)
@@ -375,6 +375,7 @@ static struct ec_tk_type ec_tk_sh_lex_type = {
        .name = "sh_lex",
        .parse = ec_tk_sh_lex_parse,
        .complete = ec_tk_sh_lex_complete,
+       .size = sizeof(struct ec_tk_sh_lex),
        .free_priv = ec_tk_sh_lex_free_priv,
 };
 
@@ -387,8 +388,7 @@ struct ec_tk *ec_tk_sh_lex_new(const char *id, struct ec_tk *child)
        if (child == NULL)
                return NULL;
 
-       tk = (struct ec_tk_sh_lex *)ec_tk_new(id, &ec_tk_sh_lex_type,
-               sizeof(*tk));
+       tk = (struct ec_tk_sh_lex *)__ec_tk_new(&ec_tk_sh_lex_type, id);
        if (tk == NULL) {
                ec_tk_free(child);
                return NULL;
index 8b26d99..2162afe 100644 (file)
@@ -79,21 +79,17 @@ static struct ec_tk_type ec_tk_space_type = {
        .name = "space",
        .parse = ec_tk_space_parse,
        .complete = ec_tk_default_complete,
+       .size = sizeof(struct ec_tk_space),
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_space_type);
 
-struct ec_tk *ec_tk_space_new(const char *id)
-{
-       return ec_tk_new(id, &ec_tk_space_type, sizeof(struct ec_tk_space));
-}
-
 static int ec_tk_space_testcase(void)
 {
        struct ec_tk *tk;
        int ret = 0;
 
-       tk = ec_tk_space_new(NULL);
+       tk = ec_tk_new("space", NULL);
        if (tk == NULL) {
                ec_log(EC_LOG_ERR, "cannot create tk\n");
                return -1;
@@ -106,7 +102,7 @@ static int ec_tk_space_testcase(void)
        ec_tk_free(tk);
 
        /* test completion */
-       tk = ec_tk_space_new(NULL);
+       tk = ec_tk_new("space", NULL);
        if (tk == NULL) {
                ec_log(EC_LOG_ERR, "cannot create tk\n");
                return -1;
index e4b78de..997f717 100644 (file)
@@ -132,22 +132,12 @@ static struct ec_tk_type ec_tk_str_type = {
        .parse = ec_tk_str_parse,
        .complete = ec_tk_str_complete,
        .desc = ec_tk_str_desc,
+       .size = sizeof(struct ec_tk_str),
        .free_priv = ec_tk_str_free_priv,
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_str_type);
 
-struct ec_tk *ec_tk_str_new(const char *id)
-{
-       struct ec_tk *gen_tk = NULL;
-
-       gen_tk = ec_tk_new(id, &ec_tk_str_type, sizeof(struct ec_tk_str));
-       if (gen_tk == NULL)
-               return NULL;
-
-       return gen_tk;
-}
-
 int ec_tk_str_set_str(struct ec_tk *gen_tk, const char *str)
 {
        struct ec_tk_str *tk = (struct ec_tk_str *)gen_tk;
@@ -170,7 +160,7 @@ struct ec_tk *ec_tk_str(const char *id, const char *str)
 {
        struct ec_tk *gen_tk = NULL;
 
-       gen_tk = ec_tk_str_new(id);
+       gen_tk = __ec_tk_new(&ec_tk_str_type, id);
        if (gen_tk == NULL)
                goto fail;
 
index b73eb04..6762eee 100644 (file)
@@ -342,30 +342,15 @@ int ec_tk_subset_add(struct ec_tk *gen_tk, struct ec_tk *child)
 }
 
 static struct ec_tk_type ec_tk_subset_type = {
-       .name = "tk_subset",
+       .name = "subset",
        .parse = ec_tk_subset_parse,
        .complete = ec_tk_subset_complete,
+       .size = sizeof(struct ec_tk_subset),
        .free_priv = ec_tk_subset_free_priv,
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_subset_type);
 
-struct ec_tk *ec_tk_subset(const char *id)
-{
-       struct ec_tk *gen_tk = NULL;
-       struct ec_tk_subset *tk = NULL;
-
-       gen_tk = ec_tk_new(id, &ec_tk_subset_type, sizeof(*tk));
-       if (gen_tk == NULL)
-               return NULL;
-
-       tk = (struct ec_tk_subset *)gen_tk;
-       tk->table = NULL;
-       tk->len = 0;
-
-       return gen_tk;
-}
-
 struct ec_tk *__ec_tk_subset(const char *id, ...)
 {
        struct ec_tk *gen_tk = NULL;
@@ -376,7 +361,7 @@ struct ec_tk *__ec_tk_subset(const char *id, ...)
 
        va_start(ap, id);
 
-       gen_tk = ec_tk_subset(id);
+       gen_tk = __ec_tk_new(&ec_tk_subset_type, id);
        tk = (struct ec_tk_subset *)gen_tk;
        if (tk == NULL)
                fail = 1;;
index cd68d25..6ce9a32 100644 (file)
@@ -66,24 +66,11 @@ static struct ec_tk_type ec_tk_weakref_type = {
        .name = "weakref",
        .parse = ec_tk_weakref_parse,
        .complete = ec_tk_weakref_complete,
+       .size = sizeof(struct ec_tk_weakref),
 };
 
 EC_TK_TYPE_REGISTER(ec_tk_weakref_type);
 
-struct ec_tk *ec_tk_weakref_empty(const char *id)
-{
-       struct ec_tk_weakref *tk = NULL;
-
-       tk = (struct ec_tk_weakref *)ec_tk_new(id,
-               &ec_tk_weakref_type, sizeof(*tk));
-       if (tk == NULL)
-               return NULL;
-
-       tk->child = NULL;
-
-       return &tk->gen;
-}
-
 int ec_tk_weakref_set(struct ec_tk *gen_tk, struct ec_tk *child)
 {
        struct ec_tk_weakref *tk = (struct ec_tk_weakref *)gen_tk;
@@ -112,7 +99,7 @@ struct ec_tk *ec_tk_weakref(const char *id, struct ec_tk *child)
        if (child == NULL)
                return NULL;
 
-       gen_tk = ec_tk_weakref_empty(id);
+       gen_tk = __ec_tk_new(&ec_tk_weakref_type, id);
        if (gen_tk == NULL)
                return NULL;
 
index e797953..241d2c9 100644 (file)
@@ -173,7 +173,7 @@ static int create_commands(void)
 {
        struct ec_tk *cmdlist = NULL, *cmd = NULL;
 
-       cmdlist = ec_tk_or(NULL);
+       cmdlist = ec_tk_new("or", NULL);
        if (cmdlist == NULL)
                goto fail;
 
index f90f008..6791965 100644 (file)
@@ -10,19 +10,26 @@ cleanup
 =======
 
 - check XXX in code
-- remove the _new() functions
+X remove the _new() functions
 - add a tk vector type: will be used in several nodes (ex: or, seq, ...)
 - check allocation model everywhere
 - checkpatch?
 - use linux style (update .emacs)
 - better logs
 - return values
+- use errno when returning pointers
 - missing static / const
 - license: "s/neither the name...may/the names of its contributors may not/"
 - check all completion nodes
 - split ecoli_tk.h
 - cache results when appropriate?
 - size_t or unsigned int?
+- rename:
+  - ec_tk -> ec_node
+  - ec_parsed_tk -> ec_parsed
+  - ec_completed_tk -> ec_completed
+  - tk, gen_tk, token, ... -> node
+  - tokens -> input_str / input_strvec ?
 
 logs
 ====