diff options
-rw-r--r-- | src/main.c | 46 | ||||
-rw-r--r-- | src/parse.c | 16 |
2 files changed, 35 insertions, 27 deletions
@@ -4,25 +4,25 @@ #include "analyse.h" #include "gen.h" -static void print_tree(struct analyse_tree_s *t) -{ - unsigned i; - if (t->is_terminal) - printf("!"); - - if (t->branch_count > 1) - printf("("); - - for (i = 0; i < t->branch_count; i++) { - printf("%c", t->branch_chars[i]); - print_tree(t->branches[i]); - if (t->branch_count > 1 && i < t->branch_count - 1) - printf("|"); - } - - if (t->branch_count > 1) - printf(")"); -} +/* static void print_tree(struct analyse_tree_s *t) */ +/* { */ +/* unsigned i; */ +/* if (t->is_terminal) */ +/* printf("!"); */ +/* */ +/* if (t->branch_count > 1) */ +/* printf("("); */ +/* */ +/* for (i = 0; i < t->branch_count; i++) { */ +/* printf("%c", t->branch_chars[i]); */ +/* print_tree(t->branches[i]); */ +/* if (t->branch_count > 1 && i < t->branch_count - 1) */ +/* printf("|"); */ +/* } */ +/* */ +/* if (t->branch_count > 1) */ +/* printf(")"); */ +/* } */ int main(int argc, char **argv) { @@ -52,10 +52,10 @@ int main(int argc, char **argv) ar = analyse(pr); - print_tree(&ar.deftype_tree); - puts(""); - print_tree(&ar.var_tree); - puts(""); + /* print_tree(&ar.deftype_tree); */ + /* puts(""); */ + /* print_tree(&ar.var_tree); */ + /* puts(""); */ gen(fo, pr, ar); diff --git a/src/parse.c b/src/parse.c index 752e0b8..8b8f699 100644 --- a/src/parse.c +++ b/src/parse.c @@ -447,11 +447,13 @@ struct parse_result_s parse(FILE *f, const char *fname) ERR_AT(t.line, t.col, "unexpected token `%s`", t.val); } + /* err >0 rules */ if (r.vars == NULL) { fprintf(stderr, "\x1B[1m%s:\x1B[0m ", fname); ERR("config must specify at fewest one variable rule"); } + /* err undefined type */ HASH_ITER(hh, r.vars, vcur, vtmp) { switch (vcur->type) { case PARSE_TYPE_DEFTYPE: @@ -474,6 +476,7 @@ struct parse_result_s parse(FILE *f, const char *fname) } } + /* warn type use */ HASH_ITER(hh, r.deftypes, dcur, dtmp) { if (!dcur->is_used) { WARN_AT(dcur->line, dcur->col, @@ -482,12 +485,17 @@ struct parse_result_s parse(FILE *f, const char *fname) } } - if (!r.location_seen) { - fprintf(stderr, "\x1B[1m%s:\x1B[0m ", fname); - WARN("no uthash location header specified. using `<uthash.h>`"); - strcpy(r.location, "<uthash.h>"); + /* warn hash location */ + HASH_ITER(hh, r.vars, vcur, vtmp) { + if (vcur->type >= PARSE_TYPE_HASH_BOOL && !r.location_seen) { + fprintf(stderr, "\x1B[1m%s:\x1B[0m ", fname); + WARN("no uthash location header specified. using `<uthash.h>`"); + strcpy(r.location, "<uthash.h>"); + break; + } } + /* warn/err suffix */ if (!r.suffix_seen) { j = 0; |