diff options
author | katherine <shmibs@airen-no-jikken.icu> | 2019-05-20 19:23:47 -0700 |
---|---|---|
committer | katherine <shmibs@airen-no-jikken.icu> | 2019-05-20 19:23:47 -0700 |
commit | 24eeb2825c9f755c92812ec3a257e6709ccb6576 (patch) | |
tree | ad7f22f0bf1865de584bd4e1244fc336233af279 /src/parse.c | |
parent | 326646d14100c43f8cb64e7673f36fcc2b01eb6d (diff) | |
download | confconf-24eeb2825c9f755c92812ec3a257e6709ccb6576.tar.gz |
implement analyse function
anlyises the parse results to build a tree for deterministic parser
generation
Diffstat (limited to 'src/parse.c')
-rw-r--r-- | src/parse.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/parse.c b/src/parse.c index ce255bb..16f6355 100644 --- a/src/parse.c +++ b/src/parse.c @@ -338,6 +338,17 @@ static bool sub_parse_rule(void) return true; } +static int sub_sort_deftypes(struct parse_deftype_s *d1, + struct parse_deftype_s *d2) +{ + return strcmp(d1->name, d2->name); +} + +static int sub_sort_vars(struct parse_var_s *v1, struct parse_var_s *v2) +{ + return strcmp(v1->name, v2->name); +} + struct parse_result_s parse(FILE *f, const char *fname) { size_t i, j; @@ -399,7 +410,7 @@ struct parse_result_s parse(FILE *f, const char *fname) for (i = j; fname[i] != '\0' && fname[i] != '.' && i - j < r.hkey_size; i++) { - if (!isalnum(fname[i])) { + if (!isalnum(fname[i]) && fname[i] != '_') { fprintf(stderr, "\e[1m%s:\e[0m ", fname); ERR("no function suffix specified, and could not generate one"); } @@ -417,6 +428,9 @@ struct parse_result_s parse(FILE *f, const char *fname) WARN("no function suffix specified. using `%s`...", r.fun_suf); } + HASH_SORT(r.deftypes, sub_sort_deftypes); + HASH_SORT(r.vars, sub_sort_vars); + return r; } |