Improved output.

This commit is contained in:
Neil 2023-05-09 23:05:11 -07:00
parent d08047d4db
commit 4b905ccefa
2 changed files with 34 additions and 6 deletions

View File

@ -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;

View File

@ -227,6 +227,7 @@ static int scan_day(struct scan *const scan, union date32 date,
<bracket> "movie: " :=> movie
<bracket> "idea: " :=> idea
<bracket> "vaccine: " :=> vaccine
<bracket> "medication: " :=> medication
<bracket> "tax: " :=> tax
<bracket> "in: " :=> income
<bracket> "mail: " :=> mail
@ -377,6 +378,22 @@ static int scan_day(struct scan *const scan, union date32 date,
continue;
}
<medication> * { fail = "medication unrecognized"; goto catch; }
<medication> @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;
}
<tax> * { fail = "tax unrecognized"; goto catch; }
<tax> @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 <inttypes.h>
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");
}