| Rev | Line | |
|---|
| [25ae32e] | 1 | #!/usr/bin/perl |
|---|
| 2 | |
|---|
| 3 | my $currstate=-1; |
|---|
| 4 | my @states; |
|---|
| 5 | my @final; |
|---|
| 6 | my $tn=0; |
|---|
| 7 | |
|---|
| 8 | while(<>) |
|---|
| 9 | { |
|---|
| 10 | if(/^\s*([0-9]+)\s+([0-9]+)\s+(.)(\s*)?$/) |
|---|
| 11 | { |
|---|
| 12 | push @{$states[$1]}, ($3, $2); |
|---|
| 13 | $#states=$2 if $#states<$2; |
|---|
| 14 | $tn++; |
|---|
| 15 | } |
|---|
| 16 | elsif(/^\s*([0-9]+)\s*$/) |
|---|
| 17 | { |
|---|
| 18 | $final[$1]=1; |
|---|
| 19 | $#states=$1 if $#states<$1; |
|---|
| 20 | } |
|---|
| 21 | else |
|---|
| 22 | { |
|---|
| 23 | die("Input error."); |
|---|
| 24 | } |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | print scalar(@states)," ",$tn," char void\n"; |
|---|
| 28 | |
|---|
| 29 | my $i=0; |
|---|
| 30 | my $width=int(log(@states+1)/log(10)); |
|---|
| 31 | foreach $stateref (@states) |
|---|
| 32 | { |
|---|
| 33 | $f = ($final[$i]?"+":"-"); |
|---|
| 34 | printf "%${width}d %s",$i++,$f; |
|---|
| 35 | while(@$stateref) |
|---|
| 36 | { |
|---|
| 37 | $c=shift @$stateref; |
|---|
| 38 | $s=shift @$stateref; |
|---|
| 39 | print " $c $s"; |
|---|
| 40 | } |
|---|
| 41 | print "\n"; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.