scan place in progress
This commit is contained in:
parent
bfd8d797f9
commit
fd2b3afc70
@ -128,14 +128,16 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
re2c:define:YYSETCONDITION:naked = 1;
|
re2c:define:YYSETCONDITION:naked = 1;
|
||||||
|
|
||||||
ws = [ \t];
|
ws = [ \t];
|
||||||
glyph = [^\x00-\x20\x7f]; // [^\x00\n\t ] + all weird
|
glyph = [^\x00-\x20\x7f] | [\x80-\xff]; // [^\x00\n\t ] + all weird
|
||||||
semitext = glyph \ ";";
|
semitext = glyph \ ";";
|
||||||
natural = [1-9][0-9]*;
|
natural = [1-9][0-9]*;
|
||||||
zero_natural = [0-9]+;
|
zero_natural = [0-9]+;
|
||||||
decimal = "-"? zero_natural ("." zero_natural?)?;
|
decimal = "-"? zero_natural ("." zero_natural?)?;
|
||||||
uint = [0-9]+;
|
uint = [0-9]+;
|
||||||
keyword = [A-Za-z0-9][A-Za-z0-9_-]*;
|
keyword = [A-Za-z0-9][A-Za-z0-9_-]*;
|
||||||
label = semitext+ (" " semitext+)*; // perhaps??? do we want to include ;?
|
labelchar = glyph \ [;]; // perhaps?
|
||||||
|
labelchar0 = labelchar \ [()]; // because conflicts
|
||||||
|
label = (labelchar0 labelchar*) (" " labelchar+)*;
|
||||||
date = natural "-" [0-1][0-9] "-" [0-3][0-9];
|
date = natural "-" [0-1][0-9] "-" [0-3][0-9];
|
||||||
minutes = [0-5][0-9];
|
minutes = [0-5][0-9];
|
||||||
airport = [A-Z0-9]{4,4};
|
airport = [A-Z0-9]{4,4};
|
||||||
@ -159,20 +161,45 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
|
|
||||||
|
|
||||||
<place> * { fail = "place unrecognized"; goto catch; }
|
<place> * { fail = "place unrecognized"; goto catch; }
|
||||||
|
<place> @s0 label @s1 / "\n" => skip { also_place: {
|
||||||
|
const struct pair keyword = pair(s0, s1);
|
||||||
|
const union line64 key = { { (uint32_t)line, date } };
|
||||||
|
size_t i, *pi;
|
||||||
|
if(line > UINT32_MAX)
|
||||||
|
{ errno = ERANGE; fail = "too many lines of text"; goto catch; }
|
||||||
|
/*fprintf(stderr, "map: <<%.*s>> out of %s\n", (int)(s1 - s0), s0,
|
||||||
|
pair_map_table_to_string(&scan->places.map));*/
|
||||||
|
if(!(i = pair_map_table_get(&scan->places.map, keyword)))
|
||||||
|
{ fail = "keyword not introduced"; /*goto catch;*/ continue; }
|
||||||
|
switch(linemap_tree_bulk_assign(&scan->places.dates, key, &pi)) {
|
||||||
|
case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch;
|
||||||
|
case TREE_ABSENT: *pi = i; break;
|
||||||
|
}
|
||||||
|
fprintf(stderr, "%s[%zu]: place <<%.*s>>\n",
|
||||||
|
datestr, line, (int)(s1 - s0), s0);
|
||||||
|
} continue; }
|
||||||
<place> "(" @t0 decimal "," @t1 decimal ")"
|
<place> "(" @t0 decimal "," @t1 decimal ")"
|
||||||
ws+ @s0 label @s1 / "\n" => skip {
|
ws+ @s0 label @s1 / "\n" => skip {
|
||||||
const struct pair keyword = pair(s0, s1);
|
const struct pair keyword = pair(s0, s1);
|
||||||
const double x = strtod(t0, 0), y = strtod(t1, 0); /* Safe? */
|
const double x = strtod(t0, 0), y = strtod(t1, 0); /* Safe? */
|
||||||
fprintf(stderr, "%s: new place: (%.*s)(%f,%f) <<%.*s>>\n",
|
size_t *idx;
|
||||||
datestr, (int)(s0 - t0), t0 - 1, x, y, (int)(s1-s0), s0);
|
struct place *place;
|
||||||
continue;
|
switch(pair_map_table_assign(&scan->places.map, keyword, &idx)) {
|
||||||
}
|
case TABLE_PRESENT: errno = EDOM; fail = "new keyword already used";
|
||||||
<place> @s0 label @s1 / "\n" => skip {
|
case TABLE_ERROR: goto catch; /* /\ _Sic_. */
|
||||||
const struct pair keyword = pair(s0, s1);
|
case TABLE_ABSENT: *idx = 0; break; /* Good. */
|
||||||
fprintf(stderr, "place: <<%.*s>>\n", (int)(s1-s0), s0);
|
}
|
||||||
continue;
|
if(!(place = place_array_new(&scan->places.array))) goto catch;
|
||||||
|
*idx = (size_t)(place - scan->places.array.data);
|
||||||
|
place->name.a = s0, place->name.b = s1;
|
||||||
|
place->x = x, place->y = y;
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s[%zu]: new place: <<%.*s>> at (%f,%f) stored at %zu.\n",
|
||||||
|
datestr, line, (int)(s1 - s0), s0, x, y, *idx);
|
||||||
|
goto also_place;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<source> * { fail = "source unrecognized"; goto catch; }
|
<source> * { fail = "source unrecognized"; goto catch; }
|
||||||
<source> @s0 keyword @s1 / "\n" => skip { also_source: {
|
<source> @s0 keyword @s1 / "\n" => skip { also_source: {
|
||||||
const struct pair keyword = pair(s0, s1);
|
const struct pair keyword = pair(s0, s1);
|
||||||
@ -186,8 +213,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch;
|
case TREE_PRESENT: fail = "duplicate"; case TREE_ERROR: goto catch;
|
||||||
case TREE_ABSENT: *pi = i; break;
|
case TREE_ABSENT: *pi = i; break;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%s: source <<%.*s>>\n",
|
fprintf(stderr, "%s[%zu]: source <<%.*s>>\n",
|
||||||
datestr, (int)(s1 - s0), s0);
|
datestr, line, (int)(s1 - s0), s0);
|
||||||
} continue; }
|
} continue; }
|
||||||
/* New source. fixme: desc not set. */
|
/* New source. fixme: desc not set. */
|
||||||
<source> @s0 keyword @s1 ":" [^\x00\n]+ / "\n" => skip {
|
<source> @s0 keyword @s1 ":" [^\x00\n]+ / "\n" => skip {
|
||||||
@ -202,9 +229,9 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
if(!(source = source_array_new(&scan->sources.array))) goto catch;
|
if(!(source = source_array_new(&scan->sources.array))) goto catch;
|
||||||
*idx = (size_t)(source - scan->sources.array.data);
|
*idx = (size_t)(source - scan->sources.array.data);
|
||||||
source->name.a = s0, source->name.b = s1;
|
source->name.a = s0, source->name.b = s1;
|
||||||
source->desc.a = 0, source->desc.b = 0;
|
source->desc.a = 0, source->desc.b = 0; /* fixme */
|
||||||
fprintf(stderr, "%s: new source <<%.*s>> stored in list at %zu.\n",
|
fprintf(stderr, "%s[%zu]: new source <<%.*s>> stored at %zu.\n",
|
||||||
datestr, (int)(s1 - s0), s0, *idx);
|
datestr, line, (int)(s1 - s0), s0, *idx);
|
||||||
goto also_source;
|
goto also_source;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,7 +255,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
case TREE_ERROR: goto catch;
|
case TREE_ERROR: goto catch;
|
||||||
case TREE_ABSENT: *pidx = idx; break;
|
case TREE_ABSENT: *pidx = idx; break;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%s: score <%.*s>\n", datestr, (int)(s1 - s0), s0);
|
fprintf(stderr, "%s[%zu]: score <%.*s>\n",
|
||||||
|
datestr, line, (int)(s1 - s0), s0);
|
||||||
} continue; }
|
} continue; }
|
||||||
/* New score. */
|
/* New score. */
|
||||||
<score> @s0 keyword @s1 ":" => score_name {
|
<score> @s0 keyword @s1 ":" => score_name {
|
||||||
@ -249,8 +277,8 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
new_score->name.a = 0, new_score->name.b = 0;
|
new_score->name.a = 0, new_score->name.b = 0;
|
||||||
new_score->date.u32 = new_score->last.u32 = 0;
|
new_score->date.u32 = new_score->last.u32 = 0;
|
||||||
new_score->edges = 0, new_score->score = 0;
|
new_score->edges = 0, new_score->score = 0;
|
||||||
fprintf(stderr, "%s: new score <%.*s> stored in list at %zu.\n",
|
fprintf(stderr, "%s[%zu]: new score <%.*s> stored at %zu.\n",
|
||||||
datestr, (int)(s1 - s0), s0, *idx);
|
datestr, line, (int)(s1 - s0), s0, *idx);
|
||||||
goto new_score;
|
goto new_score;
|
||||||
}
|
}
|
||||||
<score_name> * { fail = "name unrecognized"; goto catch; }
|
<score_name> * { fail = "name unrecognized"; goto catch; }
|
||||||
@ -295,10 +323,9 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
<glider_launch> * { fail = "glider launch"; goto catch; }
|
<glider_launch> * { fail = "glider launch"; goto catch; }
|
||||||
<glider_launch> ws* @s0 airport @s1 ws* ";" => glider_how {
|
<glider_launch> ws* @s0 airport @s1 ws* ";" => glider_how {
|
||||||
new_glider->launch.a = s0, new_glider->launch.b = s1;
|
new_glider->launch.a = s0, new_glider->launch.b = s1;
|
||||||
fprintf(stderr, "%s: glider <%.*s> at <%.*s>\n", datestr,
|
fprintf(stderr, "%s[%zu]: glider <<%.*s>> at <<%.*s>>\n",
|
||||||
(int)(new_glider->reg.b - new_glider->reg.a),
|
datestr, line, (int)(new_glider->reg.b - new_glider->reg.a),
|
||||||
new_glider->reg.a,
|
new_glider->reg.a, (int)(s1 - s0), s0);
|
||||||
(int)(s1 - s0), s0);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
<glider_how> * { fail = "glider how"; goto catch; }
|
<glider_how> * { fail = "glider how"; goto catch; }
|
||||||
@ -370,10 +397,9 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
ws* @t0 airport @t1 ws* ";" => flight_pic {
|
ws* @t0 airport @t1 ws* ";" => flight_pic {
|
||||||
new_flight->launch.a = s0, new_flight->launch.b = s1;
|
new_flight->launch.a = s0, new_flight->launch.b = s1;
|
||||||
new_flight->landing.a = t0, new_flight->landing.b = t1;
|
new_flight->landing.a = t0, new_flight->landing.b = t1;
|
||||||
fprintf(stderr, "%s: flight <%.*s> at <%.*s>\n", datestr,
|
fprintf(stderr, "%s[%zu]: flight <<%.*s>> at <<%.*s>>\n",
|
||||||
(int)(new_flight->reg.b - new_flight->reg.a),
|
datestr, line, (int)(new_flight->reg.b - new_flight->reg.a),
|
||||||
new_flight->reg.a,
|
new_flight->reg.a, (int)(s1 - s0), s0);
|
||||||
(int)(s1 - s0), s0);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
<flight_pic> * { fail = "flight pic"; goto catch; }
|
<flight_pic> * { fail = "flight pic"; goto catch; }
|
||||||
@ -537,12 +563,10 @@ static int scan_day(struct scan *const scan, union date32 date,
|
|||||||
value->verse_end = verse_end;
|
value->verse_end = verse_end;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "%s: KJV %s %" PRIu32 ":%" PRIu32,
|
fprintf(stderr, "%s[%zu]: KJV %s %" PRIu32 ":%" PRIu32,
|
||||||
datestr, kjv_book_string[book], chapter, verse);
|
datestr, line, kjv_book_string[book], chapter, verse);
|
||||||
if(verse_end) fprintf(stderr, "-%u", verse_end);
|
if(verse_end) fprintf(stderr, "-%u", verse_end);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
fprintf(stderr, "");
|
|
||||||
book = Revelation, chapter = 0, verse = 0, verse_end = 0;
|
book = Revelation, chapter = 0, verse = 0, verse_end = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user