home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-04 | 3.0 KB | 155 lines | [TEXT/MPS ] |
- Perl -Sx "{0}" {"Parameters"}>"{TempFolder}"noweb.run
- "{TempFolder}"noweb.run
- Exit
-
- #!perl
- # Copyright 1991 by Norman Ramsey. All rights reserved.
- # See file COPYRIGHT for more information.
- # set -x
-
- $markup = "markup";
- $width = 72;
- $subst = '$s =~ s|\\*/|* /|g;';
- $format = '/* %%-%ds */';
-
- while ($arg = shift @ARGV) {
- if ($arg =~ /^-(ml|m3)$/) {
- $format = '(* %%-%ds *)';
- $subst = '$s =~ s|\\*([()])|* $1|g;';
- } elsif ($arg =~ /^-(awk|perl|icn|icon|make)$/) {
- $format = '# %%-%ds';
- $subst = '';
- } elsif ($arg =~ /^-(lisp|scm)$/) {
- $format = ';;; %%-%ds';
- $subst = '';
- } elsif ($arg =~ /^-c\+\+$/) {
- $format = '// %%-%ds';
- $subst = '';
- } elsif ($arg =~ /^-f77$/) {
- $format = 'C %%-%ds';
- $subst = '';
- } elsif ($arg =~ /^-f90$/) {
- $format = '! %%-%ds';
- $subst = '';
- } elsif ($arg =~ /^-tex$/) {
- $format = '%%%% %%-%ds';
- $subst = '';
- } elsif ($arg =~ /^-c$/) {
- $format = '/* %%-%ds */';
- $subst = '$s =~ s|\\*/|* /|g;';
- } elsif ($arg =~ /^-pascal$/) {
- $format = '{ %%-%ds }';
- $subst = '$s =~ s|{}|-|g;';
- } elsif ($arg =~ /^-L/) {
- # deliberately ignore requests for #line
- } elsif ($arg =~ /^-w(\d+)$/) {
- $width = $1;
- } elsif ($arg eq "-filter) {
- $filters .= "| " . shift @ARGV;
- } elsif ($arg eq "-markup) {
- $markup = shift @ARGV;
- } elsif ($arg =~ /^-t/) {
- $opt .= " '$arg'";
- $args .= " '-t'";
- } elsif ($arg eq "-") {
- $args .= " '$arg'";
- } elsif ($arg =~ /^-/) {
- $opt .= " '$arg'";
- } else {
- $args .= " '$arg'";
- }
- }
-
- print "Set Commands \"||LIB||," . $ENV{"Commands"} . "\"; Export Commands\n";
- print "$markup $args $filters | Perl -Sx \"{0}\" | nt $opt; Exit\n\n";
- $format = sprintf($format, $width);
-
- print <<PERL_SCRIPT_DYNAMIC;
- #!perl
-
- \$line = 0;
- \$capture = 0;
-
- sub comment {
- local(\$s) = \@_;
-
- $subst
- return sprintf("$format",\$s)
- }
- PERL_SCRIPT_DYNAMIC
-
- print <<'PERL_SCRIPT_STATIC';
- $[ = 1; # set array base to 1
- $, = ' '; # set output field separator
- $\ = "\n"; # set output record separator
-
- line: while (<>) {
- chop; # strip record separator
-
- if (/^\@end doc/) {
- $capture = 0;
- $holding{++$line} = '';
- next line;
- }
- if (/^\@begin doc/) {
- $capture = 1;
- next line;
- }
-
- if (/^\@text /) {
- &grab(substr($_, 7, 999999));
- next line;
- }
- if (/^\@quote$/) {
- &grab('[[');
- next line;
- }
- if (/^\@endquote$/) {
- &grab(']]');
- next line;
- }
-
- if (/^\@nl$/) {
- if ($capture != 0) {
- $holding{++$line} = '';
- }
- elsif ($defn_pending != 0) {
- print '@nl';
- for ($i = 0; $i <= $line && $holding{$i} =~ /^ *$/; $i++) {
- $i = $i;
- }
- for (; $i <= $line; $i++) {
- printf "\@text %s\n\@nl\n", &comment($holding{$i});
- }
- $line = 0;
- $holding{0} = '';
- $defn_pending = 0;
- }
- else {
- print $_;
- }
- next line;
- }
-
- if (/^\@defn /) {
- $holding{$line} = $holding{$line} . '<' . substr($_, 7,
-
- 999999) . '>=';# (line should be blank)
- print $_;
- $defn_pending = 1;
- next line;
- }
- print $_;
- }
-
- sub grab {
- local($S) = @_;
- if ($capture == 0) {
- print $_;
- }
- else {
- $holding{$line} = $holding{$line} . $S;
- }
- }
- PERL_SCRIPT_STATIC
-