From: ian Date: Tue, 24 Aug 2004 20:13:39 +0000 (+0000) Subject: allow : stuff things : syntax X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=77fc4411546bfc7f4294c9a0df71ddc5798e3914;p=trains.git allow : stuff things : syntax --- diff --git a/pcb/netlist-expand b/pcb/netlist-expand index 6a3196d..7950e24 100755 --- a/pcb/netlist-expand +++ b/pcb/netlist-expand @@ -35,7 +35,7 @@ # # 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 @@ -50,6 +50,12 @@ # 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/^\-/; @@ -98,8 +104,11 @@ sub unpack_iter_list ($$@) { 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; @@ -115,13 +124,25 @@ sub unpack_iter_list ($$@) { 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)" @@ -134,6 +155,9 @@ sub unpack_iter_list ($$@) { $done[$usepin]= $_; } $counter++; + if (length $limitcounter && $counter == $limitcounter) { + unshift @toprocess, ":$afterlimit"; + } } } if ($options !~ m/p/) {