Skip to content

Commit

Permalink
sct: fix parsing of empty sections
Browse files Browse the repository at this point in the history
  • Loading branch information
globin committed Mar 3, 2024
1 parent 23cb874 commit 4f6b6ae
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/sct.pest
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ line = _{ broken ~ NL }

section_header = _{ "[" ~ header_name ~ "]" }

vor_section = { "[VOR]" ~ NL ~ (location ~ NL)+ }
ndb_section = { "[NDB]" ~ NL ~ (location ~ NL)+ }
fixes_section = { "[FIXES]" ~ NL ~ ((fix | broken) ~ NL)+ }
airport_section = { "[AIRPORT]" ~ NL ~ (location ~ NL)+ }
runway_section = { "[RUNWAY]" ~ NL ~ (runway ~ NL)+ }
high_airway_section = { "[HIGH AIRWAY]" ~ NL ~ (airway ~ NL)+ }
low_airway_section = { "[LOW AIRWAY]" ~ NL ~ (airway ~ NL)+ }
unparsed_section = { (section_header ~ NL ~ line+) }
vor_section = { "[VOR]" ~ NL ~ (location ~ NL)* }
ndb_section = { "[NDB]" ~ NL ~ (location ~ NL)* }
fixes_section = { "[FIXES]" ~ NL ~ ((fix | broken) ~ NL)* }
airport_section = { "[AIRPORT]" ~ NL ~ (location ~ NL)* }
runway_section = { "[RUNWAY]" ~ NL ~ (runway ~ NL)* }
high_airway_section = { "[HIGH AIRWAY]" ~ NL ~ (airway ~ NL)* }
low_airway_section = { "[LOW AIRWAY]" ~ NL ~ (airway ~ NL)* }
unparsed_section = { (section_header ~ NL ~ line*) }

fix = { fix_designator ~ coordinate }
location = { designator ~ frequency ~ coordinate ~ "D"? }
location = { designator ~ frequency ~ coordinate ~ ("A" | "B" | "C" | "D" | "E" | "F" | "G")? }
runway = { runway_designator ~ runway_designator ~ degrees ~ degrees ~ coordinate ~ coordinate ~ designator }
airway = { designator ~ coordinate ~ coordinate }
// EDGG has invalid WPT with spaces
Expand Down
37 changes: 37 additions & 0 deletions src/sct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -605,4 +605,41 @@ A4 N048.42.56.998 E017.23.09.999 N048.51.11.520 E017.10.04.238
);
// TODO GEO, REGIONS, ARTCC, SID, STAR, AIRWAY
}

#[test]
fn test_empty_section() {
let sct_bytes = b"
;=========================================================================================================================;
[INFO]
AeroNav M\xfcnchen 2401/1-1 EDMM 20240125
AERO_NAV
ZZZZ
N048.21.13.618
E011.47.09.909
60
39
-3
1
#define COLOR_APP 16711680
#define COLOR_AirspaceA 8421376
[SID]
[STAR]
EDDM TRAN RNP26R LANDU26 N048.35.46.899 E012.16.26.140 N048.32.16.501 E011.30.05.529 COLOR_APP
N048.32.16.501 E011.30.05.529 N048.25.44.061 E011.31.15.931 COLOR_APP
N048.25.44.061 E011.31.15.931 N048.29.36.319 E012.22.42.409 COLOR_APP
N048.29.36.319 E012.22.42.409 N048.30.47.361 E012.37.38.952 COLOR_APP
EDDN TRAN ILS10 DN430 N049.33.11.289 E010.30.33.379 N049.32.37.168 E010.36.38.149 COLOR_APP
N049.32.37.168 E010.36.38.149 N049.32.02.731 E010.42.42.681 COLOR_APP
EDQD STAR ALL LONLIxZ N050.04.29.060 E011.13.34.989 N049.53.50.819 E011.24.28.540
";
let sct = Sct::parse(sct_bytes);

assert!(sct.is_ok())
}
}

0 comments on commit 4f6b6ae

Please sign in to comment.