aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkatherine <k@airen-no-jikken.icu>2019-05-30 20:38:25 -0700
committerkatherine <k@airen-no-jikken.icu>2019-05-30 20:38:25 -0700
commit233bac703ee5849cb18d02330ccb97038ffc6439 (patch)
treee76ac7321b6051c082790934a18808f627747684
parent85456307365f470378df2f5e7fc3a355bc3d4ace (diff)
downloadconfconf-233bac703ee5849cb18d02330ccb97038ffc6439.tar.gz
uthash location header warning
-rw-r--r--src/main.c46
-rw-r--r--src/parse.c16
2 files changed, 35 insertions, 27 deletions
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 `<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;