#
# pin asserts that next pin number to assign would be pin
#
-# :start[step][%jump/modulo]
+# :start[step][%jump/modulo][,number,:start[step]...]
# specifies that the next pin to assign will be start,
# and what the following pin will be to assign, and so
# on in arithmetic sequence indefinitely until the
# start, start+jump, ... start+(modulo-1)*jump
# and then interleave the sequences to
# generate the sequence of pins to assign
+# :number:start...
+# means to assign only number pins in this
+# way and then to start with a new (set of)
+# sequences as defined by :start etc.
+# : stuff things etc ... :
+# is as if you wrote :stuff:things:etc...
die if $ARGV[0] =~ m/^\-/;
my $jump= 0;
my $modulo= '';
my $counter= 0;
- my ($usepin, $remainder, $quotient);
- foreach $_ (@expanded) {
+ my $limitcounter= '';
+ my ($usepin, $remainder, $quotient, $afterlimit);
+ my (@toprocess) = @expanded;
+ while (@toprocess) {
+ $_= shift @toprocess;
if (!length $modulo) {
$remainder= 0;
$quotient= $counter;
die "$_ != $usepin $max (@in) (@expanded)"
if $usepin ne $&;
} elsif (
- m/^\:(\-?)(\d+)(?:([-+]\d+)|([-+])|)(?:\%(\-?\d+)\/(\d+))?$/
+ m/^\:(\-?)(\d+)(?:([-+]\d+)|([-+])|)(?:\%(\-?\d+)\/(\d+))?(?:\:(\d+)\:(.*))?$/
) {
my ($back,$base,$stepval,$sign)=($1,$2,$3,$4);
- ($jump,$modulo)=($5,$6);
+ ($jump,$modulo,$limitcounter,$afterlimit)=($5,$6,$7,$8);
$start= length $back ? $max-$base : $base;
$step= length $stepval ? $stepval : length $sign ? $sign.'1' : 1;
$counter= 0;
+ } elsif (m/^\:$/) {
+ my ($accum) = '';
+ for (;;) {
+ die "end (@in) (@expanded)" unless @toprocess;
+ $_= shift @toprocess;
+ last if m/^\:$/ && length $accum;
+ die "$_ (@in) (@expanded)" if m/\:/;
+ $accum .= ':'.$_;
+ }
+ unshift @toprocess, $accum;
+ } elsif (m/^\:/) {
+ die "$_ (@in) (@expanded)";
} else {
if ($_ ne '-') {
die "$usepin<1 $_ $max (@in) (@expanded)"
$done[$usepin]= $_;
}
$counter++;
+ if (length $limitcounter && $counter == $limitcounter) {
+ unshift @toprocess, ":$afterlimit";
+ }
}
}
if ($options !~ m/p/) {