|
294
|
0 |
16 |
0 |
$utils{join $;, sort(@wanted)} //= do {
my %wanted;
@wanted{@wanted} = @wanted;
croak "no parse flags specified" unless my(@parse_flags) = grep(defined($_), delete @wanted{keys %mask});
croak "illegal combination of flags: ", join(", ", @parse_flags) unless defined(my $between_template = $between_template{&sum0(@mask{@parse_flags})});
my $want_trim = !!delete $wanted{'-trim'};
my($coord, @extra) = grep(defined(delete $wanted{$_}), keys %comp);
croak 'too many coordinate systems specified: ' . join(", ", $coord, @extra) if @extra;
croak "unrecognized options: ", join(", ", keys %wanted) if keys %wanted;
$coord //= "-any";
my(@comp) = ($comp{$coord}, "[0-5]?[0-9]", $CXC::Types::Astro::Coords::Util::RE{'num'}{'decimal'});
my(@units) = ($unit{$coord}, "[m]", "[s]");
my $qr = '^' . join("", $want_trim ? "\\h*" : (), map({my($template, $comp, $units) = @$_;
join "", "(", $comp, ")", strinterp($template, {"units", $units, "sep", ":", "ws", "\\h+", "ows", "\\h*"});} zip($between_template, \@comp, \@units)), $want_trim ? "\\h*" : ()) . '$';
my(%_utils) = ("qr", $qr, "constraint", sprintf(' ($_ =~ /%s/) && (%s) ', $qr, $bounds_check{$coord}), "StrMatch_toArrayRef", $StrMatch_toArrayRef{$coord}, "ArrayRef_toDegrees", $ArrayRef_toDegrees{$coord});
$_utils{'Str_toArrayRef'} = sprintf(' ( (%s) ? (%s) : $_ ) ', $_utils{'constraint'}, $StrMatch_toArrayRef{$coord});
$_utils{'Str_toDegrees'} = sprintf(' ( (%s) ? do { local $_ = %s; %s; } : $_ ) ', $_utils{'constraint'}, $_utils{'StrMatch_toArrayRef'}, $_utils{'ArrayRef_toDegrees'});
\%_utils
} |