save
[protos/libecoli.git] / lib / ecoli_node_int.c
index 8c7be7c..a7bd057 100644 (file)
@@ -38,6 +38,8 @@
 #include <ecoli_malloc.h>
 #include <ecoli_strvec.h>
 #include <ecoli_node.h>
+#include <ecoli_parsed.h>
+#include <ecoli_completed.h>
 #include <ecoli_node_int.h>
 #include <ecoli_test.h>
 
@@ -75,43 +77,37 @@ static int parse_llint(struct ec_node_int *node, const char *str,
        return 0;
 }
 
-static struct ec_parsed *ec_node_int_parse(const struct ec_node *gen_node,
-       const struct ec_strvec *strvec)
+static int ec_node_int_parse(const struct ec_node *gen_node,
+                       struct ec_parsed *state,
+                       const struct ec_strvec *strvec)
 {
        struct ec_node_int *node = (struct ec_node_int *)gen_node;
-       struct ec_parsed *parsed;
-       struct ec_strvec *match_strvec;
        const char *str;
        long long val;
 
-       parsed = ec_parsed();
-       if (parsed == NULL)
-               goto fail;
+       (void)state;
 
        if (ec_strvec_len(strvec) == 0)
-               return parsed;
+               return EC_PARSED_NOMATCH;
 
        str = ec_strvec_val(strvec, 0);
        if (parse_llint(node, str, &val) < 0)
-               return parsed;
+               return EC_PARSED_NOMATCH;
 
-       match_strvec = ec_strvec_ndup(strvec, 0, 1);
-       if (match_strvec == NULL)
-               goto fail;
-
-       ec_parsed_set_match(parsed, gen_node, match_strvec);
-
-       return parsed;
+       return 1;
+}
 
- fail:
-       ec_parsed_free(parsed);
-       return NULL;
+static size_t ec_node_int_get_max_parse_len(const struct ec_node *gen_node)
+{
+       (void)gen_node;
+       return 1;
 }
 
 static struct ec_node_type ec_node_int_type = {
        .name = "int",
        .parse = ec_node_int_parse,
        .complete = ec_node_default_complete,
+       .get_max_parse_len = ec_node_int_get_max_parse_len,
        .size = sizeof(struct ec_node_int),
 };
 
@@ -150,6 +146,7 @@ long long ec_node_int_getval(struct ec_node *gen_node, const char *str)
        return val;
 }
 
+/* LCOV_EXCL_START */
 static int ec_node_int_testcase(void)
 {
        struct ec_parsed *p;
@@ -231,6 +228,7 @@ static int ec_node_int_testcase(void)
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 static struct ec_test ec_node_int_test = {
        .name = "node_int",