#! /usr/bin/perl -w # # This filter works with the internal noweb(1) representation and marks # definitions of symbols in ocaml(1) source code. $code = 0; while (defined($line = <>)) { print $line; $code = ($line =~ /^\@begin code/) ? 1 : $code; $code = ($line =~ /^\@end code/) ? 0 : $code; # make sure we only index code we know how to deal with # *.ml if ($line =~ /^\@text (let|and|external)\s+(rec\s+)?([-a-zA-Z0-9_']+)/) { $id = $3; printf "\@index localdefn %s\n", $id; next ; } if ($line =~ /^\@text (let|and)\s+(rec\s+)?\(\s*([-!$%&*+\/<=>?@^|~:.a-zA-Z0-9_']+)\s*\)/) { $id = $3; printf "\@index localdefn %s\n", $id; next ; } # *.mli - symbols are externally visible if ($line =~ /^\@text \s{0,10}(val|external)\s+(rec\s+)?([a-zA-Z0-9_'-]+)/) { $id = $3; printf "\@index defn %s\n", $id; next ; } if ($line =~ /^\@text \s{0,10}val\s+\(\s*([-!$%&*+\/<=>?@^|~:.a-zA-Z0-9_']+)\s*\)/) { $id = $1; printf "\@index localdefn %s\n", $id; next ; } # *.mly - non terminals if ($line =~ /^\@text ([a-zA-Z0-9]+)\s*:/) { $id = $1; printf "\@index localdefn %s\n", $id; next ; } # *.mll - scanner contexts if ($line =~ /^\@text (rule|and)\s+([a-zA-Z0-9]+)\s*=/) { $id = $2; printf "\@index localdefn %s\n", $id; next ; } }