Now the two halves meet - split a line into five fields, parse each into its set of allowed values, and store the result in one Expr. This is the parsed representation every later lesson reads from, so you give it its full shape today.
Parse a whole expression into an Expr holding five value sets plus two day-restriction flags.
An Expr is the compiled form of a cron line: five sets of allowed values, one
per field. Parse is the front door of the whole library - it calls SplitFields
to get the five strings, runs each through parseField with its FieldSpec, and
drops the resulting sets into the struct. Any field error bubbles up so a bad line
never produces a half-built Expr.
Give the struct its whole shape now, even the two fields you will not use for a
while: DomRestricted and DowRestricted. A day field is “restricted” when it
is anything other than * - a real constraint on which days fire. Recording that
here, on the lesson where fields first come together, means the tricky
day-of-month / day-of-week matching rule later has the flags it needs without
reshaping Expr. For now every field is a single number, so both flags are true.
type Expr struct {Minute, Hour, Dom, Month, Dow map[int]boolDomRestricted, DowRestricted bool // set later when matching days}// Parse: SplitFields, then parseField for each of the five specs.// Record DomRestricted = (dom text != "*"), same for dow.