From 233bac703ee5849cb18d02330ccb97038ffc6439 Mon Sep 17 00:00:00 2001 From: katherine Date: Thu, 30 May 2019 20:38:25 -0700 Subject: uthash location header warning --- src/main.c | 46 +++++++++++++++++++++++----------------------- src/parse.c | 16 ++++++++++++---- 2 files changed, 35 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 16fd3d7..aca8ce4 100644 --- a/src/main.c +++ b/src/main.c @@ -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 ``"); - strcpy(r.location, ""); + /* 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 ``"); + strcpy(r.location, ""); + break; + } } + /* warn/err suffix */ if (!r.suffix_seen) { j = 0; -- cgit v1.2.3