1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! VFCC17-specific parser for astrometric error model rule lines.
//!
//! This sub-module implements the parser for the Vereš, Farnocchia, Chesley &
//! Chamberlin (2017) rule file format. Each non-comment line encodes an
//! observatory code, observation type, catalog codes, parallax flag, date
//! constraints, and RMS values in a fixed positional format:
//!
//! ```text
//! <station> t=<obs_type> c=<catalogs> p=<parallax> > <date> < <date> @ rms_ra, rms_dec
//! ```
//!
//! Only the station code, catalog codes (`c=…`), and RMS values (`@ …`) are
//! extracted; all other fields are consumed and discarded. The public entry
//! point is [`parse_vfcc17_line`].
use ;
use crateParseResult;
/// Returns `true` for alphanumeric characters and `*`.
///
/// Used by [`parse_word`] and [`parse_catalog_codes`] to delimit tokens
/// in the VFCC17 rule format.
///
/// # Arguments
///
/// - `c` — the character to test.
///
/// # Returns
///
/// `true` if `c` is alphanumeric or `'*'`, `false` otherwise.
/// Parse a contiguous word token consisting of alphanumeric characters and `*`.
///
/// # Arguments
///
/// - `input` — the parser input slice positioned at the start of a word token.
///
/// # Returns
///
/// The matched slice on success together with the unconsumed input tail, or a
/// `nom` error if the input does not start with at least one word character.
/// Parse the `c=<chars>` catalog-code field and expand each character into
/// its own [`CatalogCode`](crate::observer::error_model::CatalogCode) string.
///
/// The `c=` prefix is required; this parser will fail if it is absent.
/// Each ASCII character in the run following `c=` becomes a separate element
/// in the returned vector (e.g. `c=tU` yields `["t", "U"]`).
///
/// # Arguments
///
/// - `input` — the parser input slice positioned at the `c=` prefix.
///
/// # Returns
///
/// A `Vec<String>` where each element is a single-character catalog code,
/// together with the unconsumed input tail.
/// Parse `@ rms_ra, rms_dec`, skipping everything before the `@`.
///
/// All text between the current position and the `@` marker is consumed and
/// discarded (date range and parallax fields).
///
/// # Arguments
///
/// - `input` — the parser input slice positioned at the `t=…` field or any
/// text that precedes the `@` marker.
///
/// # Returns
///
/// A tuple `(rms_ra, rms_dec)` as `f32` values, together with the unconsumed
/// input tail.
/// Parse one VFCC17 rule line, stripping the inline `! comment` if present.
///
/// The expected line format is:
///
/// ```text
/// <station> t=<obs_type> c=<catalogs> p=<parallax> > <date> < <date> @ rms_ra, rms_dec
/// ```
///
/// Date and parallax fields are consumed and discarded; only the station code,
/// catalog codes, and RMS values are extracted.
///
/// # Arguments
///
/// - `input` — a single rule line, with or without a trailing `! comment`.
///
/// # Returns
///
/// On success, returns a residual input slice (typically empty) and a
/// `Vec<((station, catalog), (rms_ra, rms_dec))>` with one entry per catalog
/// character in the `c=…` field.
///
/// # Errors
///
/// Returns a `nom` error if the line does not match the expected format (e.g.
/// missing `c=` field or `@` marker).