From 66a3c1752f4a374c5a4f4c64223bf1fe314de9eb Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 19 May 2023 03:08:29 -0700 Subject: [PATCH] couch --- src/scan.h | 2 +- src/scan.re.c | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/scan.h b/src/scan.h index b09ed0f..1cd9010 100644 --- a/src/scan.h +++ b/src/scan.h @@ -141,7 +141,7 @@ struct scan { } edits; struct linepair_tree dreams; struct linekvpair_tree contacts, books, tvs, movies, ideas, - vaccines, medications; + vaccines, medications, mails, couches; 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 60eb370..4626afa 100644 --- a/src/scan.re.c +++ b/src/scan.re.c @@ -245,6 +245,7 @@ static int scan_day(struct scan *const scan, union date32 date, "tax: " :=> tax "in: " :=> income "mail: " :=> mail + "couch: " :=> couch "- " => input_text { const union line64 key = { { (uint32_t)line, date } }; @@ -441,14 +442,14 @@ static int scan_day(struct scan *const scan, union date32 date, @s0 bralabel @s1 "]" => input_money { const union line64 key = { { (uint32_t)line, date } }; struct kvmoney *pair; - switch(linekvmoney_tree_bulk_assign(&scan->taxes, key, &pair)) { + switch(linekvmoney_tree_bulk_assign(&scan->incomes, 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 = (struct money){0, CAD}; input.future = yycline, input.money = &pair->value; - fprintf(stderr, "%s[%zu]: new money <<%.*s>>.\n", + fprintf(stderr, "%s[%zu]: new income <<%.*s>>.\n", datestr, line, (int)(s1 - s0), s0); continue; } @@ -457,7 +458,7 @@ static int scan_day(struct scan *const scan, union date32 date, @s0 bralabel @s1 "]" => input_text { const union line64 key = { { (uint32_t)line, date } }; struct kvpair *pair; - switch(linekvpair_tree_bulk_assign(&scan->vaccines, key, &pair)) { + switch(linekvpair_tree_bulk_assign(&scan->mails, key, &pair)) { case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch; case TREE_ABSENT: break; } @@ -469,6 +470,22 @@ static int scan_day(struct scan *const scan, union date32 date, continue; } + * { fail = "couch 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->couches, 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 couch <<%.*s>>.\n", + datestr, line, (int)(s1 - s0), s0); + continue; + } + * { fail = "place unrecognized"; goto catch; } @s0 parlabel @s1 / "\n" => skip { also_place: { const struct pair keyword = pair(s0, s1); @@ -936,6 +953,7 @@ void scan_(struct scan *const scan) { glider_tree_(&scan->gliders); linekvmoney_tree_(&scan->incomes); linekvmoney_tree_(&scan->taxes); + linekvpair_tree_(&scan->couches); linekvpair_tree_(&scan->medications); linekvpair_tree_(&scan->vaccines); linekvpair_tree_(&scan->ideas); @@ -1017,6 +1035,7 @@ struct scan scan(struct journal *const jrnl) { || !linekvpair_tree_bulk_finish(&scan.ideas) || !linekvpair_tree_bulk_finish(&scan.vaccines) || !linekvpair_tree_bulk_finish(&scan.medications) + || !linekvpair_tree_bulk_finish(&scan.couches) || !linekvmoney_tree_bulk_finish(&scan.taxes) || !linekvmoney_tree_bulk_finish(&scan.incomes) || !glider_tree_bulk_finish(&scan.gliders)