16 @fields = split(/\|/, $_[3]);
17 foreach my $field (@fields) {
18 #remove heading and trailing spaces
23 #$tabular .= $field." \\\\";
27 return "Num of Fields not equal to Bits!";
30 @fieldnames = split(/\|/, $_[4]);
32 if(scalar(@fields) != scalar(@fieldnames)) {
33 return "Num of Fields != Num of Names";
37 foreach my $fieldn (@fieldnames) {
38 #remove heading and trailing spaces
42 if($fieldn =~ m/^[^\(.]*\(\s*([0-1]+)\s*\).*$/) {
43 if(length($1) == $fields[$count]) {
45 $fieldn =~ s/\s?\(\s*[0-1]+\s*\)//;
50 for($i = 1; $i <= $fields[$count]; $i++) {
58 for($i = 1; $i <= $fields[$count]; $i++) {
63 #$tabular .= $fieldn.": ". $bits." \\\\";
66 $bitlist = join("",@bitlist);
68 #$tabular .= "\\textbf{names:} @fieldnames \n";
69 #$tabular .= "\\textbf{bitlist:} $bitlist \n";
73 $tabular = "\\begin{center} \n \\resizebox{\\textwidth}{!}{\n";
74 $tabular .= "\\begin{tabular}{|l|";
75 for($i = $bits-1; $i >= 0; $i--) {
85 $bline .= "\\\\ \\hline \n";
89 $vline .= substr($bitlist,($bits-1)-$i,1);
94 $vline .= "\\\\ \\hline \n";
98 #because of multicolumn we need to limit execution
100 $nline .= "\\multicolumn{@fields[0]}{>{\\columncolor{names}}c|}{@fieldnames[0]}";
103 $count -= @fields[0];
106 $nline .= "\\\\ \\hline \n";
116 $tabular .= "} \\hline \n";
117 $tabular .= "\\multicolumn{".($bits+1)."}{|>{\\columncolor{title}}c|}{\\textbf{".$_[1]."} (".$_[2].")} \\\\ \\hline \n";
118 $tabular .= "\\rowcolor{bit} \\cellcolor{title} &". $bline;
120 $tabular .= "\\rowcolor{bitval} \\cellcolor{title}Values &". $vline;
122 $tabular .= "\\cellcolor{title}Field &". $nline;
123 $tabular .= "\\end{tabular}\n}\n \\end{center}\n";
130 die "Usage: gentex.pl <file.ptex>";
133 open(DATA, "<".$ARGV[0]) || die "Couldn't open file $ARGV[0] for read!";
137 $output =~ s/\.[^.]*$//;
140 open(OUTPUT, ">".$output) || die "Couldn't open file $output for output!";