#!/usr/bin/perl
+use strict;
sub ins {
my $bits = $_[0];
my $pvline;
my @bitlist;
my $tabular;
+ my $count = 0;
+ my @fields;
+ my $i;
+ my $x;
+ my @fieldnames;
+ my @flagnames = ('SF', 'CF', 'OF', 'ZF');
+
- $count = 0;
@fields = split(/\|/, $_[3]);
foreach my $field (@fields) {
#remove heading and trailing spaces
#$tabular .= $fieldn.": ". $bits." \\\\";
$count++;
}
- $bitlist = join("",@bitlist);
+ my $bitlist = join("",@bitlist);
#$tabular .= "\\textbf{names:} @fieldnames \n";
#$tabular .= "\\textbf{bitlist:} $bitlist \n";
$count = $bits-1;
- $tabular = "\\begin{center} \n \\resizebox{\\textwidth}{!}{\n";
+ $tabular = "\\subsubsection{".$_[1]."}\n";
+ $tabular .= "\\begin{center} \n \\resizebox{\\textwidth}{!}{\n";
$tabular .= "\\begin{tabular}{|l|";
for($i = $bits-1; $i >= 0; $i--) {
#build table
$tabular .= "\\cellcolor{title}Field &". $nline;
$tabular .= "\\end{tabular}\n}\n \\end{center}\n";
+ if($_[5]) {
+ $tabular .= "\\paragraph{Description:}~\\\\ \n ".$_[5]. "\n";
+ }
+
+ if($_[6]) {
+ $count = 0;
+ my @flags = split(/\|/, $_[6]);
+
+ if(scalar(@flags) == scalar(@flagnames)) {
+ $tabular .= "\\paragraph{Flags:} \n";
+
+ foreach my $flag (@flags) {
+ #remove heading and trailing spaces
+ $flag =~ s/^\s+//;
+ $flag =~ s/\s+$//;
+ if(length($flag) > 0 ) {
+ $tabular .= "\\subparagraph{".$flagnames[$count].":} ".$flag." \n";
+ }
+ $count++;
+ }
+ }
+
+ }
+
+ if($_[7]) {
+ $tabular .= "\\paragraph{Example:}~\\\\ \n \\begin{lstlisting} \n ".$_[7]. " \\end{lstlisting}\n";
+ }
- return $tabular;
+ print $tabular;
}
if($#ARGV != 0) {
die "Usage: gentex.pl <file.ptex>";
}
-open(DATA, "<".$ARGV[0]) || die "Couldn't open file $ARGV[0] for read!";
-
-$output = $ARGV[0];
+my $output = $ARGV[0];
+my $input = $ARGV[0];
$output =~ s/\.[^.]*$//;
$output .= ".tex";
-open(OUTPUT, ">".$output) || die "Couldn't open file $output for output!";
-
-while(<DATA>)
-{
- $res = eval "$_";
- print OUTPUT $res;
-}
+open STDOUT, '>', $output or die "Can't redirect STDOUT: $!";
-close(DATA);
-close(OUTPUT);
+do $input;