40 Remove Non-API Text

This Perl script comments out non-documentation lines. (It is not (yet) in use.)

536aglobal variables 294a+   (293 474b 503 536b)  508b  537a
@LineBuffer=();
536b* 21+   534  539
#------------------------------------------------------------------
#---
#--- ALLPROSE
#--- Copyright (C) Ralf Hemmecke (ralf@hemmecke.de)
#--- http://www.hemmecke.de/aldor
#---
#------------------------------------------------------------------

global variables 294a
my($lineNumber, $line);
while (<>) {chomp; push @LineBuffer, $_;}
for($lineNumber = 0; $lineNumber < scalar(@LineBuffer); $lineNumber++) {
    do something for one line 475a
}
for $line (@LineBuffer) {print $line, "\n";}

Now, depending on the line that is currently considered, several things have to be done. First of all, to shorten the following code, the current line is remembered.

536cdo something for one line 475a+   (474b 536b)  475c  537b
$line = @LineBuffer[$lineNumber];

The script remembers also in which state it currently is. In particular, whether it is inside a +++ environment or inside a code chunk. The line number of the \begin{+++} is remembered in the variable beginDocIndex in order to be able to add information there when it is found in the lines that follow.

537aglobal variables 294a+   (293 474b 503 536b)  536a
my($inDocEnvironment)=0;
my($inCodeChunk)=0;
537bdo something for one line 475a+   (474b 536b)  536c
if ($line =~ /^\\begin{\+\+\+}/) {
    $inDocEnvironment=1;
} elsif ($inDocEnvironment) {
    if ($line =~ /^\\end{\+\+\+}/) {
        $inDocEnvironment=0;
    }
} elsif ($line =~ /^<<.*>>=/) {
    $inCodeChunk=1;
} elsif ($inCodeChunk) {
    if ($line =~ /^\@(\s*$|\s+%def)/) {
        $inCodeChunk=0;
    }
} else { # we are not in a code chunk and not in a DocEnvironment.
    @LineBuffer[$lineNumber] = ’%’.$line;
}

Uses code 432.