#!/usr/misc/bin/perl
# Nicolas Rouquette <rouquett@ai-cyclops.Jpl.Nasa.Gov>
# AI group, Jet Propulsion Laboratory
# Oct 22, 1992
#
# Converts a Lisp file to a form suitable for inclusion in a tex document,
# such as
#   \begin{lisp}
#   \include program.tex
#   \end{lisp}
#
# To produce program.tex from program.lisp do:
#   lisp2tex program.tex program.lisp
#   lisp2tex < program.tex > program.lisp
#

$in = STDIN;
$out = STDOUT;
if ($#ARGV >= 0) {
  open (INFILE, "$ARGV[0]") 
    || die "Cannot open input file: $ARGV[0]: $!\n";
  $in = INFILE;

  if ($#ARGV == 1) {
      open (OUTFILE, ">$ARGV[1]") 
        || die "Cannot open output file: $ARGV[1]\n";
      $out = OUTFILE;
  }
}

while (<$in>) {
 study;
 while (s/^(\s*)\s/\1~/g) {};
 s/#/\\#/g;
 s/&/\\&/g;
 s/$/\\\\/;
 print $out $_;
}


