diff --git a/src/scan.h b/src/scan.h index 3e43af7..961cbdf 100644 --- a/src/scan.h +++ b/src/scan.h @@ -134,7 +134,8 @@ struct scan { struct pairmap_table map; struct linemap_tree dates; } edits; - struct linekvpair_tree contacts, books, tvs, movies, ideas, vaccines; + struct linekvpair_tree contacts, books, tvs, movies, ideas, vaccines, + medications; struct linekvmoney_tree taxes, incomes; struct glider_tree gliders; struct flight_tree flights; diff --git a/src/scan.re.c b/src/scan.re.c index 80ec2c6..901d629 100644 --- a/src/scan.re.c +++ b/src/scan.re.c @@ -227,6 +227,7 @@ static int scan_day(struct scan *const scan, union date32 date, "movie: " :=> movie "idea: " :=> idea "vaccine: " :=> vaccine + "medication: " :=> medication "tax: " :=> tax "in: " :=> income "mail: " :=> mail @@ -377,6 +378,22 @@ static int scan_day(struct scan *const scan, union date32 date, continue; } + * { fail = "medication unrecognized"; goto catch; } + @s0 bralabel @s1 "]" => input_text { + const union line64 key = { { (uint32_t)line, date } }; + struct kvpair *pair; + switch(linekvpair_tree_bulk_assign(&scan->medications, key, &pair)){ + case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch; + case TREE_ABSENT: break; + } + pair->key.a = s0, pair->key.b = s1; + pair->value.a = pair->value.b = 0; + input.future = yycnewline, input.pair = &pair->value; + fprintf(stderr, "%s[%zu]: new medication <<%.*s>>.\n", + datestr, line, (int)(s1 - s0), s0); + continue; + } + * { fail = "tax unrecognized"; goto catch; } @s0 bralabel @s1 "]" => input_money { const union line64 key = { { (uint32_t)line, date } }; @@ -892,6 +909,7 @@ void scan_(struct scan *const scan) { glider_tree_(&scan->gliders); linekvmoney_tree_(&scan->incomes); linekvmoney_tree_(&scan->taxes); + linekvpair_tree_(&scan->medications); linekvpair_tree_(&scan->vaccines); linekvpair_tree_(&scan->ideas); linekvpair_tree_(&scan->movies); @@ -969,6 +987,7 @@ struct scan scan(struct journal *const jrnl) { || !linekvpair_tree_bulk_finish(&scan.movies) || !linekvpair_tree_bulk_finish(&scan.ideas) || !linekvpair_tree_bulk_finish(&scan.vaccines) + || !linekvpair_tree_bulk_finish(&scan.medications) || !linekvmoney_tree_bulk_finish(&scan.taxes) || !linekvmoney_tree_bulk_finish(&scan.incomes) || !glider_tree_bulk_finish(&scan.gliders) @@ -1006,6 +1025,9 @@ void scan_score_graph(struct scan *const scan) { struct score *score; assert(scan); + fprintf(stderr, "*** Score graph %s.\n", + linemap_tree_to_string(&scan->scores.dates)); + /* Set score to zero to verify count with paper journal. */ for(struct score *i = scan->scores.array.data, *const z = i + scan->scores.array.size; i < z; i++) i->score = 0; @@ -1068,13 +1090,15 @@ void scan_score_graph(struct scan *const scan) { " (total/2.): \\\n" " (getIndex(strcol(2))) w boxxy lc var lw 1, \\\n" " for [i=1:words(Uniqs)] keyentry w boxxy lc i ti Uniq(i)\n"); + fprintf(stderr, "\n"); } #include void scan_glider_graph(struct scan *const scan) { assert(scan); - fprintf(stderr, "Glider: %s.\n", glider_tree_to_string(&scan->gliders)); + fprintf(stderr, "*** Glider graph %s.\n", + glider_tree_to_string(&scan->gliders)); printf("set terminal pngcairo dashed transparent truecolor" " size 840, 480 fontscale 1\n" "set output \"glider.png\"\n"); @@ -1141,11 +1165,13 @@ void scan_glider_graph(struct scan *const scan) { /*"set xrange [*:'2001-09-11']\n"*/ /*"#set style fill solid 0.1 #pattern 5 (better, but restarts)\n" "plot $Data using 1:($6/60) with fillsteps lw 2\n"*/); + fprintf(stderr, "\n"); } void scan_flight_graph(struct scan *const scan) { assert(scan); - fprintf(stderr, "Flight: %s.\n", flight_tree_to_string(&scan->flights)); + fprintf(stderr, "*** Flight graph: %s.\n", + flight_tree_to_string(&scan->flights)); printf("set terminal pngcairo dashed transparent truecolor" " size 840, 480 fontscale 1\n" "set output \"glider.png\"\n"); @@ -1197,6 +1223,7 @@ void scan_flight_graph(struct scan *const scan) { "(dy=($3+$4)*60,total=total+dy,total/2.): \\\n" " (43200):(total/2.):(getIndex(strcol(2))) w boxxy lc var, \\\n" " for [i=1:words(Uniqs)] keyentry w boxxy lc i ti Uniq(i)\n"); + fprintf(stderr, "\n"); } void scan_kjv_graph(struct scan *const scan) { @@ -1206,11 +1233,10 @@ void scan_kjv_graph(struct scan *const scan) { const char *reason = 0; count = kjv_count(&no_total); - fprintf(stderr, "KJV count: %s.\n", kjv_count_to_string(&count)); + fprintf(stderr, "*** KJV graph, count: %s; lines: %s.\n", + kjv_count_to_string(&count), kjv_tree_to_string(&scan->kjvs)); if(!no_total) { reason = "kjv failed to load"; goto catch; } - fprintf(stderr, "KJV lines: %s.\n", kjv_tree_to_string(&scan->kjvs)); - struct kjv_tree_iterator it = kjv_tree_iterator(&scan->kjvs); /* https://stackoverflow.com/a/12601553 */ @@ -1295,4 +1321,5 @@ catch: perror(reason); finally: kjv_count_(&count); + fprintf(stderr, "\n"); }