#!/usr/local/bin/perl -w # database.p # reads ascii database entries and creates html # # database.p data.asc > data.html # (done in pub/codes) # # comments "#...." are ignored # # any lines starting "<" e.g., #

headings

are transcribed direct. # # blank lines and lines that are not in entries' fields are ignored. # # each entry starts with # # code-- name of code # # other fields may then follow: # N-- # K-- # M-- # MT-- true value of M (may be smaller than M) # KT-- true value of K (may be smaller than K) # # t-- column weight # tr-- row weight # # R-- rate # AWGNasc-- file containing performance on gaussian channel (ascii) # AWGNps-- file containing performance on gaussian channel (postscript) # au-- Author of code # created-- how the code was created (construction name or command) # ref-- information about this code, where published etc. # paper-- link to paper # comment-- # afile-- file with alist matrix # gfile-- file with generator matrix # # the symbol "--" is reserved to denote a new field $changingspace[0] = " " ; $changingspace[1] = " " ; $endchangingspace[1] = " " ; $endchangingspace[0] = " " ; $counter = 0 ; $endrow = "\n" ; $head = "" ; $bulk = "
Here are the details of individual codes:
\n" ; $section = 0 ; $prehead = "" ; do { do { $_ = <> ; } while ( /^#/ ) ; $prehead .= $_ ; } while ( !/end_head/ ) ; $prehead .= "
\n" ; &readline(); $currentlevel = 0 ; do { if ( /^#/ ) { &readline(); } elsif ( /^".$_."\n" ; while ( $level < $currentlevel ) { $currentlevel -- ; $prehead .= "" ; } while ( $level > $currentlevel ) { $currentlevel ++ ; $prehead .= "" ; } print $prehead ; print "
\n" ; print $head ; print $bulk ; exit 0 ; sub open_item { $writing = 1 ; $item = "" ; $item .= "\n
REPLACE
\n" ; $item .= "\n" ; $N = "" ; $K = "" ; $M = "" ; $t = "" ; $tr = "" ; $R = "" ; $trueK = "" ; $trueM = "" ; } sub close_item { if ( $writing ) { $writing = 0 ; if ( !$K && $N && $M ) { $K = $N - $M ; } elsif ( !$M && $N && $K ) { $M = $N - $K ; } if ( !$trueK && $N && $trueM ) { $trueK = $N - $trueM ; } elsif ( !$trueM && $N && $trueK ) { $trueM = $N - $trueK ; } if ( !$R ) { # print STDERR "computing R from N = $N, K = $K , $trueK = trueK\n" ; if ( $N && $trueK ) { $R = sprintf ( "%9.4g" , $trueK / $N ) ; } elsif ( $N && $K ) { $R = sprintf ( "%9.4g" , $K / $N ) ; } } $codesummary = "$code (N=$N,K=$K,M=$M,R=$R)" ; $codenumber ++ ; $pointtocode = "$changingspace[$counter]$codesummary$endchangingspace[$counter]\n" ; $counter = 1 - $counter ; $codesummary = "$codesummary" ; $head .= $pointtocode ; $item =~ s/REPLACE/$codesummary/ ; $item .= "
\n" ; # this ends the table describing the code $bulk .= $item ; } } sub continue_item { $item .= " " ; } sub do_title { s/^\s*// ; $code = $_ ; } sub do_author { s/\s*[Aa][Uu]\-\-/ author: / ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_t { s/\s*[tT]\-\-\s*(.*)/ t:\t\t$1/ ; $t = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_tr { s/\s*[tT][rR]\-\-\s*(.*)/ tr:\t\t$1/ ; $tr = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_n { s/\s*[nN]\-\-\s*(.*)/ N:\t\t$1/ ; $N = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_m { s/\s*[mM]\-\-\s*(.*)/ M:\t\t$1/ ; $M = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_d { s/\s*[dD]\-\-\s*(.*)/ d:\t\t$1/ ; $d = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_kt { if ( s/\s*[kK][tT]\-\-\s*(.*)/ Ktrue:\t\t$1/ < 1 ) { print STDERR "failed to do subst of kt in string $_ \n" ; } $trueK = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_mt { s/\s*[mM][tT]\-\-\s*(.*)/ Mtrue:\t\t$1/ ; $trueM = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_r { s/\s*[rR]\-\-\s*(.*)/ R:\t\t$1/ ; $R = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_k { s/\s*[Kk]\-\-\s*(.*)/ K:\t\t$1/ ; $K = $1 ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_afile { s/\s*afile\-\-\s*(.*)/ Alist file:\t\tparity check matrix<\/a>/ ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_gfile { s/\s*gfile\-\-\s*(.*)/ Generator matrix:\t\tbinary file<\/a>/ ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_gcps { s/\s*AWGNps\-\-\s*(.*)/ Gaussian channel:\t\tpostscript<\/a>/ ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_gcasc { s/\s*AWGNasc\-\-\s*(.*)/ Gaussian channel:\t\tascii<\/a>/ ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_created { s/\s*created\-\-\s*(.*)/ created:\t\t$1/ ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub do_comment { s/\s*comment\-\-\s*(.*)/ comment:\t\t$1/ ; do { $item .= $_ ; } while ( &readline() ) ; $item .= "$endrow" ; } sub readline { $ans = 0 ; if ( $_ = <> ) { s/\n// ; $stillgoing = 1 ; if ( !( (/^\s*\w+\-\-/) || /^\s*$/ ) ) { $ans = 1 ; } # blank line ends a field } else { $stillgoing = 0 ; } return ( $ans ) ; }