From a617ddf11cd54ecabf4241d7244b668c2aae6497 Mon Sep 17 00:00:00 2001 From: Neil Date: Tue, 14 Feb 2023 21:08:19 -0800 Subject: [PATCH] Done flights parsing? --- src/flight.re.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/flight.re.c b/src/flight.re.c index 81c1dd5..57160e4 100644 --- a/src/flight.re.c +++ b/src/flight.re.c @@ -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; } - ws* @s0 glyph+ (ws+ glyph+)* @s1 "\n" => line - { flight->glider.remarks.a = s0, flight->glider.remarks.b = s1; - flight = 0; line++; continue; } ws* "\n" => line { flight->glider.remarks.a = flight->glider.remarks.b = 0; flight = 0; line++; continue; } + ws* @s0 glyph+ (ws+ glyph+)* @s1 "\n" => line + { flight->glider.remarks.a = s0, flight->glider.remarks.b = s1; + flight = 0; line++; continue; } /* And this . . . */ "[flight]" :=> flight_type @@ -179,16 +179,34 @@ static int scan(struct flights *const f, flight->power.copilot.b = s1; continue; } ws* ";" => flight_pilot { flight->power.dual_min = 0; continue; } - ws* @s0 natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";" + 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; } ws* ";" => flight_ifrsim { flight->power.pilot_min = 0; continue; } - ws* @s0 natural? @s1 "." @t0 [0-9] @t1 "h" ws* ";" + 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; } + ws* ";" => flight_ifr + { flight->power.ifrsim_min = 0; continue; } + 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; } + ws* ";" => flight_remarks + { flight->power.ifr_min = 0; continue; } + 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; } + ws* "\n" => line + { flight->power.remarks.a = flight->power.remarks.b = 0; + flight = 0; line++; continue; } + 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: