Done flights parsing?

This commit is contained in:
Neil 2023-02-14 21:08:19 -08:00
parent d027ad2b21
commit a617ddf11c

View File

@ -45,12 +45,12 @@ static int scan(struct flights *const f,
re2c:define:YYGETCONDITION:naked = 1;
re2c:define:YYSETCONDITION:naked = 1;
//unix_control = [\x01-\x08\x0b-\x1f\x7f];
ws = [ \t];
glyph = [^\x00-\x20\x7f]; // [^\x00\n\t ] + all weird
semitext = glyph \ ";";
natural = [1-9][0-9]*;
minutes = [0-5][0-9];
zero_natural = natural | "0";
airport = [A-Z0-9]{4,4};
*/
for( ; ; ) { /*!re2c /**/
@ -126,12 +126,12 @@ static int scan(struct flights *const f,
=> glider_remarks { if(!pair_hours_to_minutes(s0, s1, t0, t1,
&flight->glider.instr_min)) { why = "instr time"; goto catch; }
continue; }
<glider_remarks> ws* @s0 glyph+ (ws+ glyph+)* @s1 "\n" => line
{ flight->glider.remarks.a = s0, flight->glider.remarks.b = s1;
flight = 0; line++; continue; }
<glider_remarks> ws* "\n" => line
{ flight->glider.remarks.a = flight->glider.remarks.b = 0;
flight = 0; line++; continue; }
<glider_remarks> ws* @s0 glyph+ (ws+ glyph+)* @s1 "\n" => line
{ flight->glider.remarks.a = s0, flight->glider.remarks.b = s1;
flight = 0; line++; continue; }
/* And this . . . */
<line> "[flight]" :=> flight_type
@ -179,16 +179,34 @@ static int scan(struct flights *const f,
flight->power.copilot.b = s1; continue; }
<flight_dual> ws* ";" => flight_pilot
{ flight->power.dual_min = 0; continue; }
<flight_dual> ws* @s0 natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";"
<flight_dual> ws* @s0 zero_natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";"
=> flight_pilot { if(!pair_hours_to_minutes(s0, s1, t0, t1,
&flight->power.dual_min)) { why = "dual time"; goto catch; }
continue; }
<flight_pilot> ws* ";" => flight_ifrsim
{ flight->power.pilot_min = 0; continue; }
<flight_pilot> ws* @s0 natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";"
<flight_pilot> ws* @s0 zero_natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";"
=> flight_ifrsim { if(!pair_hours_to_minutes(s0, s1, t0, t1,
&flight->power.pilot_min)) { why = "pilot time"; goto catch; }
continue; }
<flight_ifrsim> ws* ";" => flight_ifr
{ flight->power.ifrsim_min = 0; continue; }
<flight_ifrsim> ws* @s0 zero_natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";"
=> flight_ifr { if(!pair_hours_to_minutes(s0, s1, t0, t1,
&flight->power.ifrsim_min)) { why = "simulated ifr time";
goto catch; } continue; }
<flight_ifr> ws* ";" => flight_remarks
{ flight->power.ifr_min = 0; continue; }
<flight_ifr> ws* @s0 zero_natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";"
=> flight_remarks { if(!pair_hours_to_minutes(s0, s1, t0, t1,
&flight->power.ifr_min)) { why = "pilot time"; goto catch; }
continue; }
<flight_remarks> ws* "\n" => line
{ flight->power.remarks.a = flight->power.remarks.b = 0;
flight = 0; line++; continue; }
<flight_remarks> ws* @s0 glyph+ (ws+ glyph+)* @s1 "\n" => line
{ flight->power.remarks.a = s0, flight->power.remarks.b = s1;
flight = 0; line++; continue; }
*/ }
assert(0); /* Never gets here. */
catch: