chiark / gitweb /
allow : stuff things : syntax
authorian <ian>
Tue, 24 Aug 2004 20:13:39 +0000 (20:13 +0000)
committerian <ian>
Tue, 24 Aug 2004 20:13:39 +0000 (20:13 +0000)
pcb/netlist-expand

index 6a3196dd0b57ab16c323570ce129e0f7da738017..7950e2449bb15944f4c8a643af835ca307fddf82 100755 (executable)
@@ -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
 #                            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/) {