fixmes generated
This commit is contained in:
parent
f31a7a9810
commit
31f41f6ced
@ -201,6 +201,8 @@ struct journal journal(const char *const dir_journal) {
|
||||
/* Because it's in a flat array, the pointers are not stable
|
||||
while we are loading it, and we need to store the offsets. */
|
||||
*v.offset = (uintptr_t)(contents - j.backing.data);
|
||||
/* fixme: not representing with int should be a lazy error,
|
||||
since we use `printf`. */
|
||||
}
|
||||
d = 0, int_array_clear(&days);
|
||||
if(chdir("..") == -1) goto catch;
|
||||
|
15
src/scan.h
15
src/scan.h
@ -33,6 +33,16 @@ struct score {
|
||||
#define ARRAY_HEAD
|
||||
#include "../src/array.h"
|
||||
|
||||
/* Edit array. */
|
||||
struct edit {
|
||||
union date32 edit;
|
||||
struct pair desc;
|
||||
};
|
||||
#define ARRAY_NAME edit
|
||||
#define ARRAY_TYPE struct edit
|
||||
#define ARRAY_HEAD
|
||||
#include "../src/array.h"
|
||||
|
||||
|
||||
/* Glider array. */
|
||||
#define LAUNCH_TYPE \
|
||||
@ -96,6 +106,11 @@ struct scan {
|
||||
struct pairmap_table map;
|
||||
struct linemap_tree dates;
|
||||
} scores;
|
||||
struct {
|
||||
struct edit_array array;
|
||||
struct pairmap_table map;
|
||||
struct linemap_tree dates;
|
||||
} edits;
|
||||
struct glider_tree gliders;
|
||||
struct flight_tree flights;
|
||||
struct kjv_tree kjvs;
|
||||
|
@ -60,6 +60,15 @@ static void score_to_string(const struct score *const s,
|
||||
#define ARRAY_BODY
|
||||
#include "../src/array.h"
|
||||
|
||||
/* Array of edits. */
|
||||
static void edit_to_string(const struct edit *const e,
|
||||
char (*const z)[12]) { pair_to_string(&e->desc, z); }
|
||||
#define ARRAY_NAME edit
|
||||
#define ARRAY_TYPE struct edit
|
||||
#define ARRAY_TO_STRING
|
||||
#define ARRAY_BODY
|
||||
#include "../src/array.h"
|
||||
|
||||
/* Glider tree. */
|
||||
static void glider_to_string(const union line64 line, const struct glider *g,
|
||||
char (*const a)[12]) { (void)g; date32_to_string(line.date, a); }
|
||||
@ -174,10 +183,11 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
|
||||
/* ^"[" ... */
|
||||
<bracket> * { fail = "bracket unrecognized"; goto catch; }
|
||||
<bracket> "document: " :=> document_title
|
||||
<bracket> "document: " :=> document
|
||||
<bracket> "ed: " :=> edit //change to "rem"
|
||||
|
||||
<document_title> * { fail = "document title"; goto catch; }
|
||||
<document_title> @s0 bralabel @s1 "]" => future {
|
||||
<document> * { fail = "document title"; goto catch; }
|
||||
<document> @s0 bralabel @s1 "]" => future {
|
||||
const union line64 key = { { (uint32_t)line, date } };
|
||||
size_t *pi;
|
||||
struct source *doc;
|
||||
@ -195,6 +205,27 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
continue;
|
||||
}
|
||||
|
||||
<edit> * { fail = "edit"; goto catch; }
|
||||
<edit> @s0 date "]" => future {
|
||||
const union line64 key = { { (uint32_t)line, date } };
|
||||
size_t *pi;
|
||||
struct edit *ed;
|
||||
if(!(ed = edit_array_new(&scan->edits.array))) goto catch;
|
||||
ed->edit.u32 = 0;
|
||||
ed->desc.a = 0, ed->desc.b = 0;
|
||||
assert(!future), future = &ed->desc;
|
||||
if(!pair_to_date(s0, &ed->edit)) goto catch;
|
||||
switch(linemap_tree_bulk_assign(&scan->edits.dates, key, &pi)) {
|
||||
case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch;
|
||||
case TREE_ABSENT:
|
||||
*pi = (size_t)(ed - scan->edits.array.data); break;
|
||||
}
|
||||
fprintf(stderr, "%s[%zu]: new edit from %"
|
||||
PRIu32 "-%" PRIu32 "-%" PRIu32 " stored at %zu.\n",
|
||||
datestr, line, ed->edit.year, ed->edit.month, ed->edit.day, *pi);
|
||||
continue;
|
||||
}
|
||||
|
||||
<place> * { fail = "place unrecognized"; goto catch; }
|
||||
<place> @s0 parlabel @s1 / "\n" => skip { also_place: {
|
||||
const struct pair keyword = pair(s0, s1);
|
||||
@ -429,8 +460,7 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
single engine day dual; pilot; instrument simulated; actual; remarks */
|
||||
<flight_type> * { fail = "flight type"; goto catch; }
|
||||
<flight_type> ws* @s0 semilabel @s1 ";" => flight_reg {
|
||||
const union line64 key
|
||||
= {{ (uint32_t)line, {{ date.day, date.month, date.year }} }};
|
||||
const union line64 key = {{ (uint32_t)line, date }};
|
||||
assert(!new_flight);
|
||||
if(line > UINT32_MAX) { fail = "line overflow"; goto catch; }
|
||||
switch(flight_tree_bulk_assign(&scan->flights, key, &new_flight)) {
|
||||
@ -623,6 +653,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
||||
}
|
||||
|
||||
|
||||
/* fixme: This is a cool way of doing things. Avoid repetition, make
|
||||
all the things this way. */
|
||||
/* "<<\ntext\n>>" or "text\n" used by several. Must have pointers to
|
||||
future input. */
|
||||
<future, future_multi> * { fail = "text input"; goto catch; }
|
||||
@ -682,6 +714,10 @@ void scan_(struct scan *const scan) {
|
||||
pair_map_table_(&scan->places.map);
|
||||
place_array_(&scan->places.array);
|
||||
|
||||
linemap_tree_(&scan->edits.dates);
|
||||
pair_map_table_(&scan->edits.map);
|
||||
edit_array_(&scan->edits.array);
|
||||
|
||||
linemap_tree_(&scan->documents.dates);
|
||||
pair_map_table_(&scan->documents.map);
|
||||
source_array_(&scan->documents.array);
|
||||
@ -707,6 +743,11 @@ struct scan scan(struct journal *const jrnl) {
|
||||
if(!(nul = source_array_new(&scan.documents.array))) goto catch;
|
||||
*nul = (struct source){0};
|
||||
}
|
||||
{
|
||||
struct edit *nul;
|
||||
if(!(nul = edit_array_new(&scan.edits.array))) goto catch;
|
||||
*nul = (struct edit){0};
|
||||
}
|
||||
{
|
||||
struct place *nul;
|
||||
if(!(nul = place_array_new(&scan.places.array))) goto catch;
|
||||
|
Loading…
Reference in New Issue
Block a user