Project to add index of syntactic categories
BNF syn defining occur:
<I><A NAME="ident"><FONT COLOR=maroon>ident</FONT></A></I>
BNF syn applied occur:
<I><A HREF="^#letter"><FONT COLOR=maroon>letter</FONT></A></I>
The caret above is either the null string or a local file name.

<FONT COLOR=maroon>letter</FONT>

in terminal say:
ocaml str.cma
open Str;;
let s = regexp "&\\|<";;

Replace each defining occurrence:
<I><A NAME="ident"><FONT COLOR=maroon>ident</FONT></A></I>
by
<I><A NAME="ident" href=i.html#ident><FONT COLOR=maroon>ident</FONT></A></I>

and keep a record of which file defined ,indent.

For each applied occurrence
<I><A HREF="#letter"><FONT COLOR=maroon>letter</FONT></A></I>
note which defining occurrence it follows and collect such pairs.
See Module Str, file IO, directory access
(Unix.stat "man").Unix.st_kind = Unix.S_DIR;; tests whether ‘man’ is a directory.

Routine zf ff pn applies function ff to the name of each html file in the directory whose local name is “man/pn”. When z finds a directory it calls itself recursively.

The program creates a list ndx of records: {file: string; ident: string; tO: string}.
The definition defines category tO.
The definition occurs in file file.
The definition refers to category ident.

Empirical:

open Str;;
let t = "abc#de";;
search_forward (regexp "\\(.*\\)#") t 0;;
matched_group 1 t;; => string = "abc"
match_end ();; => int = 4

perl -pi -w -e 's/libref/http:\/\/caml.inria.fr\/pub\/docs\/manual-ocaml\/libref/g' *.html
in order not to have to include the big libref subdirectory. Thanks! I usually hate perl.

Modularizing

The OrderedType.
module CS = (String : sig type t val compare : t -> t -> int end);;
better:
module CS = (String : Map.OrderedType);;
module Ndx = Map.Make (CS);;
better:
module Ndx = Map.Make ((String : Map.OrderedType));;
Best:
module Ndx = Map.Make ((String));;
module SS  = Set.Make ((String));;
let m1 = Ndx.singleton "first" (SS.empty);;
SS.is_empty SS.empty;;  => true
SS.is_empty (Ndx.find "first" m1);;  => true
let m2 = Ndx.add "second" (SS.union (SS.singleton "Ein") (SS.singleton "zwei"));;