├── Makefile
├── README.md
├── manual
├── .cvsignore
├── .gitignore
├── Makefile
├── allfiles.etex
├── biblio.etex
├── cmds
│ ├── .cvsignore
│ ├── .gitignore
│ ├── Makefile
│ ├── browser.etex
│ ├── comp.etex
│ ├── debugger.etex
│ ├── depend.etex
│ ├── intf-c.etex
│ ├── lexyacc.etex
│ ├── native.etex
│ ├── ocamlbuild.etex
│ ├── ocamldoc.etex
│ ├── profil.etex
│ ├── runtime.etex
│ └── top.etex
├── foreword.etex
├── htmlman
│ ├── .cvsignore
│ ├── .gitignore
│ ├── contents_motif.gif
│ ├── libgraph.gif
│ ├── next_motif.gif
│ └── previous_motif.gif
├── index.tex
├── infoman
│ ├── .cvsignore
│ └── .gitignore
├── labltk.tex
├── library
│ ├── .cvsignore
│ ├── .gitignore
│ ├── Makefile
│ ├── builtin.etex
│ ├── compilerlibs.etex
│ ├── core.etex
│ ├── libbigarray.etex
│ ├── libdynlink.etex
│ ├── libgraph.etex
│ ├── libgraph.fig
│ ├── libgraph.png
│ ├── liblabltk.etex
│ ├── libnum.etex
│ ├── libstr.etex
│ ├── libthreads.etex
│ ├── libunix.etex
│ ├── stdlib.etex
│ └── tk.mli
├── macros.hva
├── macros.tex
├── manual.hva
├── manual.inf
├── manual.info.header
├── manual.tex
├── pdfmanual.tex
├── plaintext.tex
├── refman
│ ├── .cvsignore
│ ├── .gitignore
│ ├── Makefile
│ ├── classes.etex
│ ├── compunit.etex
│ ├── const.etex
│ ├── directive.etex
│ ├── expr.etex
│ ├── exten.etex
│ ├── impl.etex
│ ├── intf.etex
│ ├── lex.etex
│ ├── modtypes.etex
│ ├── modules.etex
│ ├── names.etex
│ ├── patterns.etex
│ ├── refman.etex
│ ├── typedecl.etex
│ ├── types.etex
│ └── values.etex
├── style.css
├── texstuff
│ ├── .cvsignore
│ └── .gitignore
├── textman
│ ├── .cvsignore
│ └── .gitignore
└── tutorials
│ ├── .cvsignore
│ ├── .gitignore
│ ├── Makefile
│ ├── advexamples.etex
│ ├── coreexamples.etex
│ ├── lablexamples.etex
│ ├── moduleexamples.etex
│ └── objectexamples.etex
├── styles
├── altindex.sty
├── caml-sl.sty
├── caml.sty
├── doc.tfm
├── docbf.tfm
├── docit.tfm
├── docmi.tfm
├── docrm.tfm
├── doctt.tfm
├── fullpage.sty
├── html.sty
├── isolatin.sty
├── multicols.sty
├── multind.sty
├── ocamldoc.hva
├── ocamldoc.sty
├── plaintext.sty
├── scroll.sty
├── syntaxdef.hva
├── syntaxdef.sty
└── syntaxdeftxt.sty
└── tools
├── .gitignore
├── .ignore
├── Makefile
├── caml-tex
├── caml_tex2.ml
├── dvi_to_txt
├── Makefile
├── dvi.h
├── interp.c
├── io.c
├── io.h
├── main.c
├── output.c
├── output.h
├── print.c
├── print_rtf.c
└── print_styl.c
├── fix_index.sh
├── format-intf
├── htmlcut
├── htmlquote.c
├── htmltbl
├── htmlthread
├── htmltransf.mll
├── latexmacros.ml
├── latexmacros.mli
├── latexmain.ml
├── latexscan.mll
├── texexpand
├── texquote2.c
├── transf.mll
└── transfmain.ml
/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | cd manual; ${MAKE} all
3 | # cd fpcl; ${MAKE} all
4 |
5 | clean:
6 | cd manual; ${MAKE} clean
7 | # cd fpcl; ${MAKE} clean
8 |
9 | release:
10 | cd manual; ${MAKE} release
11 | # cd fpcl; ${MAKE} release
12 |
13 | .PHONY: tools
14 | tools:
15 | cd tools; ${MAKE} clean; ${MAKE} all
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | THIS REPOSITORY IS OBSOLETE
2 | ===========================
3 |
4 | The sources of the OCaml manual are now in https://github.com/ocaml/ocaml/tree/trunk/manual.
5 |
--------------------------------------------------------------------------------
/manual/.cvsignore:
--------------------------------------------------------------------------------
1 | allfiles.tex
2 | biblio.tex
3 | foreword.tex
4 | version.tex
5 | warnings-help.etex
6 | foreword.htex
7 | manual.html
8 |
--------------------------------------------------------------------------------
/manual/.gitignore:
--------------------------------------------------------------------------------
1 | allfiles.tex
2 | biblio.tex
3 | foreword.tex
4 | version.tex
5 | warnings.etex
6 | warnings.tex
7 | foreword.htex
8 | manual.html
9 |
--------------------------------------------------------------------------------
/manual/Makefile:
--------------------------------------------------------------------------------
1 | # $Id$
2 |
3 | FILES=allfiles.tex biblio.tex foreword.tex version.tex warnings-help.etex
4 | TEXINPUTS=.:..:../refman:../library:../cmds:../tutorials:../../styles:
5 | TEXFONTS=../../styles:
6 | RELEASE=$$HOME/release/$${RELEASENAME}
7 | HEVEA=hevea
8 | HACHA=hacha
9 | INFO=-fix -exec xxdate.exe -info -w 79
10 | HTML=-fix -exec xxdate.exe -O
11 | TEXT=-fix -exec xxdate.exe -text -w 79
12 |
13 | ifeq ($(wildcard ../release/),)
14 | SRC = ../../release
15 | else
16 | SRC = ../release
17 | endif
18 |
19 | SRC2=../$(SRC)
20 | OCAMLDOC=$(SRC2)/byterun/ocamlrun $(SRC2)/ocamldoc/ocamldoc -hide Pervasives
21 | MLIS=$(SRC2)/stdlib/*.mli \
22 | $(SRC2)/utils/*.mli \
23 | $(SRC2)/parsing/*.mli \
24 | $(SRC2)/otherlibs/bigarray/bigarray.mli \
25 | $(SRC2)/otherlibs/dynlink/dynlink.mli \
26 | $(SRC2)/otherlibs/graph/graphics.mli \
27 | $(SRC2)/otherlibs/graph/graphicsX11.mli \
28 | $(SRC2)/otherlibs/num/num.mli \
29 | $(SRC2)/otherlibs/num/arith_status.mli \
30 | $(SRC2)/otherlibs/num/big_int.mli \
31 | $(SRC2)/otherlibs/num/ratio.mli \
32 | $(SRC2)/otherlibs/str/*.mli \
33 | $(SRC2)/otherlibs/systhreads/*.mli \
34 | $(SRC2)/otherlibs/unix/*.mli
35 |
36 | manual: files
37 | cd texstuff; \
38 | TEXINPUTS=$(TEXINPUTS) latex manual.tex
39 |
40 | labltk: cmds/browser.tex library/liblabltk.tex library/tk.mli
41 | cd library; $(MAKE) Tk.tex RELEASEDIR=$(SRC2)
42 | cd texstuff; \
43 | TEXINPUTS=$(TEXINPUTS) latex labltk.tex
44 |
45 | index::
46 | cd texstuff && \
47 | ../../tools/fix_index.sh manual.idx && \
48 | makeindex manual.idx
49 | cd texstuff; makeindex manual.kwd.idx
50 |
51 | pdfmanual: files
52 | cd texstuff; \
53 | TEXINPUTS=$(TEXINPUTS) pdflatex pdfmanual.tex
54 |
55 | index::
56 | cd texstuff && \
57 | ../../tools/fix_index.sh pdfmanual.idx && \
58 | makeindex pdfmanual.idx
59 | cd texstuff; makeindex pdfmanual.kwd.idx
60 |
61 | html: files
62 | cd htmlman; \
63 | mkdir -p libref ; \
64 | $(OCAMLDOC) -colorize-code -sort -html \
65 | -d libref \
66 | -I $(SRC2)/stdlib \
67 | -I $(SRC2)/utils \
68 | -I $(SRC2)/parsing \
69 | -I $(SRC2)/otherlibs/bigarray \
70 | -I $(SRC2)/otherlibs/dynlink \
71 | -I $(SRC2)/otherlibs/graph \
72 | -I $(SRC2)/otherlibs/num \
73 | -I $(SRC2)/otherlibs/str \
74 | -I $(SRC2)/otherlibs/systhreads \
75 | -I $(SRC2)/otherlibs/unix \
76 | $(MLIS) ; \
77 | cp -f ../style.css libref ; \
78 | ${HEVEA} ${HTML} -I .. -I ../refman -I ../library -I ../cmds \
79 | -I ../tutorials -I ../../styles -I ../texstuff manual.hva \
80 | -e macros.tex ../manual.tex ; \
81 | ${HACHA} -tocter manual.html ; \
82 |
83 |
84 | info: files
85 | cd infoman; rm -f ocaml.info*; \
86 | ${HEVEA} ${INFO} -o ocaml.info.body -I .. -I ../refman -I ../library \
87 | -I ../cmds -I ../tutorials -I ../../styles -I ../texstuff \
88 | ../manual.inf -e macros.tex ../manual.tex
89 | cat manual.info.header infoman/ocaml.info.body > infoman/ocaml.info
90 | cd infoman; rm -f ocaml.info.tmp; gzip -9 ocaml.info*
91 |
92 | text: files
93 | cd textman; \
94 | ${HEVEA} ${TEXT} -I .. -I ../refman -I ../library -I ../cmds \
95 | -I ../tutorials -I ../../styles -I ../texstuff \
96 | ../manual.inf -e macros.tex ../manual.tex
97 |
98 | files: $(FILES)
99 | cd refman; $(MAKE) all RELEASEDIR=$(SRC2)
100 | cd library; $(MAKE) all RELEASEDIR=$(SRC2)
101 | cd cmds; $(MAKE) all RELEASEDIR=$(SRC2)
102 | cd tutorials; $(MAKE) all RELEASEDIR=$(SRC2)
103 |
104 | all:
105 | $(MAKE) manual pdfmanual RELEASEDIR=$(SRC2)
106 | $(MAKE) manual pdfmanual RELEASEDIR=$(SRC2)
107 | $(MAKE) index RELEASEDIR=$(SRC2)
108 | $(MAKE) manual pdfmanual RELEASEDIR=$(SRC2)
109 | $(MAKE) html text info RELEASEDIR=$(SRC2)
110 |
111 | clean:
112 | rm -f $(FILES)
113 | cd refman; $(MAKE) clean
114 | cd library; $(MAKE) clean
115 | cd cmds; $(MAKE) clean
116 | cd tutorials; $(MAKE) clean
117 | -rm -f texstuff/*
118 | cd htmlman; rm -rf libref index.html manual*.html *.haux *.hind
119 | cd textman; rm -f manual.txt *.haux *.hind
120 | cd infoman; rm -f ocaml.info ocaml.info-* *.haux *.hind
121 | rm -f warnings-help.etex
122 |
123 | release:
124 | gzip < texstuff/manual.dvi > $(RELEASE)refman.dvi.gz
125 | dvips -o '!gzip > $(RELEASE)refman.ps.gz' texstuff/manual.dvi
126 | cp htmlman/manual.html $(RELEASE)refman.html
127 | rm -f htmlman/manual.{html,haux,hmanual*,htoc}
128 | tar zcf $(RELEASE)refman-html.tar.gz htmlman/*.* htmlman/libref
129 | zip -8 $(RELEASE)refman-html.zip htmlman/*.* htmlman/libref/*.*
130 | cp texstuff/pdfmanual.pdf $(RELEASE)refman.pdf
131 | cp textman/manual.txt $(RELEASE)refman.txt
132 | tar cf - infoman/ocaml.info* | gzip > $(RELEASE)refman.info.tar.gz
133 |
134 | .SUFFIXES:
135 | .SUFFIXES: .tex .etex .htex
136 |
137 | .etex.tex:
138 | ../tools/texquote2 < $*.etex > $*.tex
139 |
140 | version.tex: $(SRC)/VERSION
141 | sed -n -e '1s/^\([0-9]*\.[0-9]*\).*$$/\\def\\ocamlversion{\1}/p' \
142 | $(SRC)/VERSION > version.tex
143 |
144 | warnings-help.etex: $(SRC)/utils/warnings.ml $(SRC)/ocamlc
145 | $(SRC)/boot/ocamlrun $(SRC)/ocamlc -warn-help \
146 | | sed -e 's/^ *\([0-9A-Z][0-9]*\)\(.*\)/\\item[\1] \2/' >$@
147 |
--------------------------------------------------------------------------------
/manual/allfiles.etex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/allfiles.etex
--------------------------------------------------------------------------------
/manual/biblio.etex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/biblio.etex
--------------------------------------------------------------------------------
/manual/cmds/.cvsignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 |
--------------------------------------------------------------------------------
/manual/cmds/.gitignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 | warnings.etex
4 |
--------------------------------------------------------------------------------
/manual/cmds/Makefile:
--------------------------------------------------------------------------------
1 | FILES=comp.tex top.tex runtime.tex native.tex lexyacc.tex intf-c.tex \
2 | depend.tex profil.tex debugger.tex browser.tex ocamldoc.tex \
3 | warnings-help.tex ocamlbuild.tex
4 |
5 | TRANSF=../../tools/transf
6 | TEXQUOTE=../../tools/texquote2
7 | FORMAT=../../tools/format-intf
8 |
9 | all: $(FILES)
10 |
11 | clean::
12 | rm -f $(FILES)
13 | rm -f *~ #*#
14 |
15 | .SUFFIXES:
16 | .SUFFIXES: .tex .etex
17 |
18 | .etex.tex:
19 | $(TEXQUOTE) < $*.etex > $*.tex
20 |
21 | ocamldoc.tex: ocamldoc.etex $(TRANSF)
22 | $(TRANSF) < ocamldoc.etex | $(TEXQUOTE) > ocamldoc.tex
23 |
24 | top.tex: top.etex $(TRANSF)
25 | $(TRANSF) < top.etex | $(TEXQUOTE) > top.tex
26 |
27 | intf-c.tex: intf-c.etex $(TRANSF)
28 | $(TRANSF) < intf-c.etex | $(TEXQUOTE) > intf-c.tex
29 |
30 | lexyacc.tex: lexyacc.etex $(TRANSF)
31 | $(TRANSF) < lexyacc.etex | $(TEXQUOTE) > lexyacc.tex
32 |
33 | debugger.tex: debugger.etex $(TRANSF)
34 | $(TRANSF) < debugger.etex | $(TEXQUOTE) > debugger.tex
35 |
36 | warnings-help.etex: ../warnings-help.etex
37 | cp ../warnings-help.etex .
38 |
39 | clean::
40 | rm -f warnings-help.etex
41 |
--------------------------------------------------------------------------------
/manual/cmds/browser.etex:
--------------------------------------------------------------------------------
1 | \chapter{The browser/editor (ocamlbrowser)} \label{c:browser}
2 | \pdfchapter{The browser/editor (ocamlbrowser)}
3 | %HEVEA\cutname{browser.html}
4 |
5 | This chapter describes OCamlBrowser, a source and compiled interface
6 | browser, written using LablTk. This is a useful companion to the
7 | programmer.
8 |
9 | Its functions are:
10 | \begin{itemize}
11 | \item navigation through OCaml's modules (using compiled interfaces).
12 | \item source editing, type-checking, and browsing.
13 | \item integrated OCaml shell, running as a subprocess.
14 | \end{itemize}
15 |
16 | \section{Invocation} \label{s:browser-options}
17 |
18 | The browser is started by the command "ocamlbrowser", as follows:
19 | \begin{alltt}
20 | ocamlbrowser \var{options}
21 | \end{alltt}
22 |
23 | The following command-line options are recognized by "ocamlbrowser".
24 |
25 | \begin{options}
26 |
27 | \item["-I" \var{directory}]
28 | Add the given directory to the list of directories searched for
29 | source and compiled files. By default, only the standard library
30 | directory is searched. The standard library can also be changed by
31 | setting the "OCAMLLIB" environment variable.
32 |
33 | \item["-nolabels"]
34 | Ignore non-optional labels in types. Labels cannot be used in
35 | applications, and parameter order becomes strict.
36 |
37 | \item["-oldui"]
38 | Old multi-window interface. The default is now more like Smalltalk's
39 | class browser.
40 |
41 | \item["-rectypes"]
42 | Allow arbitrary recursive types during type-checking. By default,
43 | only recursive types where the recursion goes through an object type
44 | are supported.
45 |
46 | \item["-version"]
47 | Print version string and exit.
48 |
49 | \item["-vnum"]
50 | Print short version number and exit.
51 |
52 | \item["-w" \var{warning-list}]
53 | Enable or disable warnings according to the argument \var{warning-list}.
54 |
55 | \end{options}
56 |
57 | Most options can also be modified inside the application by the {\bf
58 | Modules - Path editor} and {\bf Compiler - Preferences} commands.
59 | They are inherited when you start a toplevel shell.
60 |
61 | \section{Viewer}
62 | This is the first window you get when you start OCamlBrowser.
63 | It displays a search window, and the list of modules in the load path.
64 | At the top a row of menus.
65 |
66 | \begin{itemize}
67 | \item {\bf File - Open} and {\bf File - Editor} give access to the
68 | editor.
69 |
70 | \item {\bf File - Shell} creates an OCaml subprocess in a shell.
71 |
72 | \item {\bf View - Show all defs} displays the signature of the currently
73 | selected module.
74 |
75 | \item {\bf View - Search entry} shows/hides the search entry just
76 | below the menu bar.
77 |
78 | \item {\bf Modules - Path editor} changes the load path. {\bf Modules
79 | - Reset cache} rescans the load path and resets the module cache.
80 | Do it if you recompile some interface, or get confused about what is
81 | in the cache.
82 |
83 | \item {\bf Modules - Search symbol} allows searching a symbol either
84 | by its name, like the bottom line of the viewer, or more
85 | interestingly, by its type. {\bf Exact type} searches for a type
86 | with exactly the same information as the pattern (variables match
87 | only variables). {\bf Included type} allows giving only partial
88 | information: the actual type may take more arguments and return more
89 | results, and variables in the pattern match anything. In both cases,
90 | argument and tuple order is irrelevant\footnote{To avoid
91 | combinatorial explosion of the search space, optional arguments in
92 | the actual type are ignored in the actual if (1) there are too many
93 | of them, and (2) they do not appear explicitly in the pattern.},
94 | and unlabeled arguments in the pattern match any label.
95 |
96 | \item The {\bf Search entry} just below the menu bar allows one to
97 | search for an identifier in all modules (wildcards ``?'' and ``*''
98 | allowed). If you choose the "type" option, the search is done by type
99 | inclusion ({\em cf.} Search Symbol - Included type).
100 |
101 | \item The {\bf Close all} button is there to dismiss the windows
102 | created by the Detach button.
103 | By double-clicking on it you will quit the browser.
104 |
105 | \end{itemize}
106 |
107 | \section{Module browsing}
108 |
109 | You select a module in the leftmost box by either clicking on it or
110 | pressing return when it is selected. Fast access is available in all
111 | boxes pressing the first few letter of the desired name.
112 | Double-clicking / double-return displays the whole signature for the
113 | module.
114 |
115 | Defined identifiers inside the module are displayed in a box to the
116 | right of the previous one. If you click on one, this will either
117 | display its contents in another box (if this is a sub-module) or
118 | display the signature for this identifier below.
119 |
120 | Signatures are clickable. Double clicking with the left mouse
121 | button on an identifier in a signature brings you to its signature.
122 | A single click on the right button pops up a menu displaying the
123 | type declaration for the selected identifier. Its title, when
124 | selectable, also brings you to its signature.
125 |
126 | At the bottom, a series of buttons, depending on the context.
127 | \begin{itemize}
128 | \item {\bf Detach} copies the currently displayed signature in a new window,
129 | to keep it.
130 | \item {\bf Impl} and {\bf Intf} bring you to the implementation or
131 | interface of the currently displayed signature, if it is available.
132 | \end{itemize}
133 |
134 | Control-S lets you search a string in the signature.
135 |
136 | \section{File editor}
137 | You can edit files with it, if you're not yet used to emacs. Otherwise
138 | you can use it as a browser, making occasional corrections.
139 |
140 | The {\bf Edit} menu contains commands for jump (C-g), search (C-s),
141 | and sending the current phrase (or selection if some text is selected)
142 | to a sub-shell (M-x). For this last option, you may choose the shell
143 | via a dialog.
144 |
145 | Essential functions are in the {\bf Compiler} menu.
146 |
147 | \begin{itemize}
148 | \item {\bf Preferences} opens a dialog to set internals of the editor
149 | and type-checker.
150 |
151 | \item {\bf Lex} adds colors according to lexical categories.
152 |
153 | \item {\bf Typecheck} verifies typing, and memorizes to let one see an
154 | expression's type by double-clicking on it. This is also valid for
155 | interfaces. If an error occurs, the part of the interface preceding
156 | the error is computed.
157 |
158 | After typechecking, pressing the right button pops up a menu that gives
159 | the type of the pointed expression and, where applicable, provides
160 | some links that can be followed.
161 |
162 | \item {\bf Clear errors} dismisses type-checker error messages and warnings.
163 |
164 | \item {\bf Signature} shows the signature of the current file
165 | (after type checking).
166 | \end{itemize}
167 |
168 | \section{Shell}
169 | When you create a shell, a dialog is presented to you, letting you
170 | choose which command you want to run, and the title of the shell (to
171 | choose it in the Editor).
172 |
173 | %You may change the default command by setting the "OCAML"
174 | %environment variable.
175 |
176 | The executed subshell is given the current load path.
177 |
178 | \begin{itemize}
179 | \item {\bf File} use a source file or load a bytecode file. You may
180 | also import the browser's path into the subprocess.
181 | \item {\bf History} M-p and M-n browse up and down.
182 | \item {\bf Signal} C-c interrupts, and you can also kill the subprocess.
183 | \end{itemize}
184 |
--------------------------------------------------------------------------------
/manual/cmds/depend.etex:
--------------------------------------------------------------------------------
1 | \chapter{Dependency generator (ocamldep)} \label{c:camldep}
2 | \pdfchapter{Dependency generator (ocamldep)}
3 | %HEVEA\cutname{depend.html}
4 |
5 | The "ocamldep" command scans a set of OCaml source files
6 | (".ml" and ".mli" files) for references to external compilation units,
7 | and outputs dependency lines in a format suitable for the "make"
8 | utility. This ensures that "make" will compile the source files in the
9 | correct order, and recompile those files that need to when a source
10 | file is modified.
11 |
12 | The typical usage is:
13 | \begin{alltt}
14 | ocamldep \var{options} *.mli *.ml > .depend
15 | \end{alltt}
16 | where "*.mli *.ml" expands to all source files in the current
17 | directory and ".depend" is the file that should contain the
18 | dependencies. (See below for a typical "Makefile".)
19 |
20 | Dependencies are generated both for compiling with the bytecode
21 | compiler "ocamlc" and with the native-code compiler "ocamlopt".
22 |
23 | The "ocamlbuild" compilation manager (see chapter~\ref{c:ocamlbuild})
24 | provide a higher-level, more automated alternative to the combination
25 | of "make" and "ocamldep".
26 |
27 | \section{Options}
28 |
29 | The following command-line options are recognized by "ocamldep".
30 |
31 | \begin{options}
32 |
33 | \item["-I" \var{directory}]
34 | Add the given directory to the list of directories searched for
35 | source files. If a source file "foo.ml" mentions an external
36 | compilation unit "Bar", a dependency on that unit's interface
37 | "bar.cmi" is generated only if the source for "bar" is found in the
38 | current directory or in one of the directories specified with "-I".
39 | Otherwise, "Bar" is assumed to be a module from the standard library,
40 | and no dependencies are generated. For programs that span multiple
41 | directories, it is recommended to pass "ocamldep" the same "-I" options
42 | that are passed to the compiler.
43 |
44 | \item["-ml-synonym" \var{.ext}]
45 | Consider the given extension (with leading dot) to be a synonym for .ml.
46 |
47 | \item["-mli-synonym" \var{.ext}]
48 | Consider the given extension (with leading dot) to be a synonym for .mli.
49 |
50 | \item["-modules"]
51 | Output raw dependencies of the form
52 | \begin{verbatim}
53 | filename: Module1 Module2 ... ModuleN
54 | \end{verbatim}
55 | where "Module1", \ldots, "ModuleN" are the names of the compilation
56 | units referenced within the file "filename", but these names are not
57 | resolved to source file names. Such raw dependencies cannot be used
58 | by "make", but can be post-processed by other tools such as "Omake".
59 |
60 | \item["-native"]
61 | Generate dependencies for a pure native-code program (no bytecode
62 | version). When an implementation file (".ml" file) has no explicit
63 | interface file (".mli" file), "ocamldep" generates dependencies on the
64 | bytecode compiled file (".cmo" file) to reflect interface changes.
65 | This can cause unnecessary bytecode recompilations for programs that
66 | are compiled to native-code only. The flag "-native" causes
67 | dependencies on native compiled files (".cmx") to be generated instead
68 | of on ".cmo" files. (This flag makes no difference if all source files
69 | have explicit ".mli" interface files.)
70 |
71 | \item["-pp" \var{command}]
72 | Cause "ocamldep" to call the given \var{command} as a preprocessor
73 | for each source file.
74 |
75 | \item["-slash"]
76 | Under Windows, use a forward slash (/) as the path separator instead
77 | of the usual backward slash ($\backslash$). Under Unix, this option does
78 | nothing.
79 |
80 | \item["-version"]
81 | Print version string and exit.
82 |
83 | \item["-vnum"]
84 | Print short version number and exit.
85 |
86 | \item["-help" or "--help"]
87 | Display a short usage summary and exit.
88 | %
89 | \end{options}
90 |
91 | \section{A typical Makefile}
92 |
93 | Here is a template "Makefile" for a OCaml program.
94 |
95 | \begin{verbatim}
96 | OCAMLC=ocamlc
97 | OCAMLOPT=ocamlopt
98 | OCAMLDEP=ocamldep
99 | INCLUDES= # all relevant -I options here
100 | OCAMLFLAGS=$(INCLUDES) # add other options for ocamlc here
101 | OCAMLOPTFLAGS=$(INCLUDES) # add other options for ocamlopt here
102 |
103 | # prog1 should be compiled to bytecode, and is composed of three
104 | # units: mod1, mod2 and mod3.
105 |
106 | # The list of object files for prog1
107 | PROG1_OBJS=mod1.cmo mod2.cmo mod3.cmo
108 |
109 | prog1: $(PROG1_OBJS)
110 | $(OCAMLC) -o prog1 $(OCAMLFLAGS) $(PROG1_OBJS)
111 |
112 | # prog2 should be compiled to native-code, and is composed of two
113 | # units: mod4 and mod5.
114 |
115 | # The list of object files for prog2
116 | PROG2_OBJS=mod4.cmx mod5.cmx
117 |
118 | prog2: $(PROG2_OBJS)
119 | $(OCAMLOPT) -o prog2 $(OCAMLFLAGS) $(PROG2_OBJS)
120 |
121 | # Common rules
122 | .SUFFIXES: .ml .mli .cmo .cmi .cmx
123 |
124 | .ml.cmo:
125 | $(OCAMLC) $(OCAMLFLAGS) -c $<
126 |
127 | .mli.cmi:
128 | $(OCAMLC) $(OCAMLFLAGS) -c $<
129 |
130 | .ml.cmx:
131 | $(OCAMLOPT) $(OCAMLOPTFLAGS) -c $<
132 |
133 | # Clean up
134 | clean:
135 | rm -f prog1 prog2
136 | rm -f *.cm[iox]
137 |
138 | # Dependencies
139 | depend:
140 | $(OCAMLDEP) $(INCLUDES) *.mli *.ml > .depend
141 |
142 | include .depend
143 | \end{verbatim}
144 |
145 |
--------------------------------------------------------------------------------
/manual/cmds/profil.etex:
--------------------------------------------------------------------------------
1 | \chapter{Profiling (ocamlprof)} \label{c:profiler}
2 | \pdfchapter{Profiling (ocamlprof)}
3 | %HEVEA\cutname{profil.html}
4 |
5 | This chapter describes how the execution of OCaml
6 | programs can be profiled, by recording how many times functions are
7 | called, branches of conditionals are taken, \ldots
8 |
9 | \section{Compiling for profiling}
10 |
11 | Before profiling an execution, the program must be compiled in
12 | profiling mode, using the "ocamlcp" front-end to the "ocamlc" compiler
13 | (see chapter~\ref{c:camlc}) or the "ocamloptp" front-end to the
14 | "ocamlopt" compiler (see chapter~\ref{c:nativecomp}). When compiling
15 | modules separately, "ocamlcp" or "ocamloptp" must be used when
16 | compiling the modules (production of ".cmo" or ".cmx" files), and can
17 | also be used (though this is not strictly necessary) when linking them
18 | together.
19 |
20 | \paragraph{Note} If a module (".ml" file) doesn't have a corresponding
21 | interface (".mli" file), then compiling it with "ocamlcp" will produce
22 | object files (".cmi" and ".cmo") that are not compatible with the ones
23 | produced by "ocamlc", which may lead to problems (if the ".cmi" or
24 | ".cmo" is still around) when switching between profiling and
25 | non-profiling compilations. To avoid this problem, you should always
26 | have a ".mli" file for each ".ml" file. The same problem exists with
27 | "ocamloptp".
28 |
29 | \paragraph{Note} To make sure your programs can be compiled in
30 | profiling mode, avoid using any identifier that begins with
31 | "__ocaml_prof".
32 |
33 | The amount of profiling information can be controlled through the "-P"
34 | option to "ocamlcp" or "ocamloptp", followed by one or several letters
35 | indicating which parts of the program should be profiled:
36 |
37 | %% description des options
38 | \begin{options}
39 | \item["a"] all options
40 | \item["f"] function calls : a count point is set at the beginning of
41 | each function body
42 | \item["i"] {\bf if \ldots then \ldots else \ldots} : count points are set in
43 | both {\bf then} branch and {\bf else} branch
44 | \item["l"] {\bf while, for} loops: a count point is set at the beginning of
45 | the loop body
46 | \item["m"] {\bf match} branches: a count point is set at the beginning of the
47 | body of each branch
48 | \item["t"] {\bf try \ldots with \ldots} branches: a count point is set at the
49 | beginning of the body of each branch
50 | \end{options}
51 |
52 | For instance, compiling with "ocamlcp -P film" profiles function calls,
53 | if\ldots then\ldots else\ldots, loops and pattern matching.
54 |
55 | Calling "ocamlcp" or "ocamloptp" without the "-P" option defaults to
56 | "-P fm", meaning that only function calls and pattern matching are
57 | profiled.
58 |
59 | \paragraph{Note} For compatibility with previous releases, "ocamlcp"
60 | also accepts the "-p" option, with the same arguments and behaviour as
61 | "-P".
62 |
63 | The "ocamlcp" and "ocamloptp" commands also accept all the options of
64 | the corresponding "ocamlc" or "ocamlopt" compiler, except the "-pp"
65 | (preprocessing) option.
66 |
67 |
68 | \section{Profiling an execution}
69 |
70 | Running an executable that has been compiled with "ocamlcp" or
71 | "ocamloptp" records the execution counts for the specified parts of
72 | the program and saves them in a file called "ocamlprof.dump" in the
73 | current directory.
74 |
75 | If the environment variable "OCAMLPROF_DUMP" is set when the program
76 | exits, its value is used as the file name instead of "ocamlprof.dump".
77 |
78 | The dump file is written only if the program terminates
79 | normally (by calling "exit" or by falling through). It is not written
80 | if the program terminates with an uncaught exception.
81 |
82 | If a compatible dump file already exists in the current directory, then the
83 | profiling information is accumulated in this dump file. This allows, for
84 | instance, the profiling of several executions of a program on
85 | different inputs. Note that dump files produced by byte-code
86 | executables (compiled with "ocamlcp") are compatible with the dump
87 | files produced by native executables (compiled with "ocamloptp").
88 |
89 | \section{Printing profiling information}
90 |
91 | The "ocamlprof" command produces a source listing of the program modules
92 | where execution counts have been inserted as comments. For instance,
93 | \begin{verbatim}
94 | ocamlprof foo.ml
95 | \end{verbatim}
96 | prints the source code for the "foo" module, with comments indicating
97 | how many times the functions in this module have been called. Naturally,
98 | this information is accurate only if the source file has not been modified
99 | after it was compiled.
100 |
101 | The following options are recognized by "ocamlprof":
102 |
103 | \begin{options}
104 |
105 | \item["-f" \var{dumpfile}]
106 | Specifies an alternate dump file of profiling information to be read.
107 |
108 | \item["-F" \var{string}]
109 | Specifies an additional string to be output with profiling information.
110 | By default, "ocamlprof" will annotate programs with comments of the form
111 | {\tt (* \var{n} *)} where \var{n} is the counter value for a profiling
112 | point. With option {\tt -F \var{s}}, the annotation will be
113 | {\tt (* \var{s}\var{n} *)}.
114 |
115 | \item["-impl" \var{filename}]
116 | Process the file \var{filename} as an implementation file, even if its
117 | extension is not ".ml".
118 |
119 | \item["-intf" \var{filename}]
120 | Process the file \var{filename} as an interface file, even if its
121 | extension is not ".mli".
122 |
123 | \item["-version"]
124 | Print version string and exit.
125 |
126 | \item["-vnum"]
127 | Print short version number and exit.
128 |
129 | \item["-help" or "--help"]
130 | Display a short usage summary and exit.
131 | %
132 | \end{options}
133 |
134 | \section{Time profiling}
135 |
136 | Profiling with "ocamlprof" only records execution counts, not the actual
137 | time spent within each function. There is currently no way to perform
138 | time profiling on bytecode programs generated by "ocamlc".
139 |
140 | Native-code programs generated by "ocamlopt" can be profiled for time
141 | and execution counts using the "-p" option and the standard Unix
142 | profiler "gprof". Just add the "-p" option when compiling and linking
143 | the program:
144 | \begin{alltt}
145 | ocamlopt -o myprog -p \var{other-options} \var{files}
146 | ./myprog
147 | gprof myprog
148 | \end{alltt}
149 | OCaml function names in the output of "gprof" have the following format:
150 | \begin{alltt}
151 | \var{Module-name}_\var{function-name}_\var{unique-number}
152 | \end{alltt}
153 | Other functions shown are either parts of the OCaml run-time system or
154 | external C functions linked with the program.
155 |
156 | The output of "gprof" is described in the Unix manual page for
157 | "gprof(1)". It generally consists of two parts: a ``flat'' profile
158 | showing the time spent in each function and the number of invocation
159 | of each function, and a ``hierarchical'' profile based on the call
160 | graph. Currently, only the Intel x86 ports of "ocamlopt" under
161 | Linux, BSD and MacOS X support the two profiles. On other platforms,
162 | "gprof" will report only the ``flat'' profile with just time
163 | information. When reading the output of "gprof", keep in mind that
164 | the accumulated times computed by "gprof" are based on heuristics and
165 | may not be exact.
166 |
167 | \paragraph{Note} The "ocamloptp" command also accepts the "-p"
168 | option. In that case, both kinds of profiling are performed by the
169 | program, and you can display the results with the "gprof" and "ocamlprof"
170 | commands, respectively.
171 |
--------------------------------------------------------------------------------
/manual/foreword.etex:
--------------------------------------------------------------------------------
1 | \chapter*{Foreword}
2 | \markboth{Foreword}{}
3 | %HEVEA\cutname{foreword.html}
4 |
5 | This manual documents the release \ocamlversion\ of the OCaml
6 | system. It is organized as follows.
7 | \begin{itemize}
8 | \item Part~\ref{p:tutorials}, ``An introduction to OCaml'',
9 | gives an overview of the language.
10 | \item Part~\ref{p:refman}, ``The OCaml language'', is the
11 | reference description of the language.
12 | \item Part~\ref{p:commands}, ``The OCaml tools'', documents
13 | the compilers, toplevel system, and programming utilities.
14 | \item Part~\ref{p:library}, ``The OCaml library'', describes the
15 | modules provided in the standard library.
16 | \begin{latexonly}
17 | \item Part~\ref{p:appendix}, ``Appendix'', contains an
18 | index of all identifiers defined in the standard library, and an
19 | index of keywords.
20 | \end{latexonly}
21 | \end{itemize}
22 |
23 | \section*{Conventions}
24 |
25 | OCaml runs on several operating systems. The parts of
26 | this manual that are specific to one operating system are presented as
27 | shown below:
28 |
29 | \begin{unix} This is material specific to the Unix family of operating
30 | systems, including Linux and \hbox{MacOS~X}.
31 | \end{unix}
32 |
33 | \begin{windows} This is material specific to Microsoft Windows (2000,
34 | XP, Vista, Seven).
35 | \end{windows}
36 |
37 | \section*{License}
38 |
39 | The OCaml system is copyright \copyright\ 1996--\number\year\
40 | Institut National de Recherche en Informatique et en
41 | Automatique (INRIA).
42 | INRIA holds all ownership rights to the OCaml system.
43 |
44 | The OCaml system is open source and can be freely
45 | redistributed. See the file "LICENSE" in the distribution for
46 | licensing information.
47 |
48 | The present documentation is copyright \copyright\ \number\year\
49 | Institut National de Recherche en Informatique et en
50 | Automatique (INRIA). The OCaml documentation and user's
51 | manual may be reproduced and distributed in whole or
52 | in part, subject to the following conditions:
53 | \begin{itemize}
54 | \item The copyright notice above and this permission notice must be
55 | preserved complete on all complete or partial copies.
56 | \item Any translation or derivative work of the OCaml
57 | documentation and user's manual must be approved by the authors in
58 | writing before distribution.
59 | \item If you distribute the OCaml
60 | documentation and user's manual in part, instructions for obtaining
61 | the complete version of this manual must be included, and a
62 | means for obtaining a complete version provided.
63 | \item Small portions may be reproduced as illustrations for reviews or
64 | quotes in other works without this permission notice if proper
65 | citation is given.
66 | \end{itemize}
67 |
68 | \section*{Availability}
69 |
70 | \begin{latexonly}
71 | The complete OCaml distribution can be accessed via the Web
72 | site \url{http://caml.inria.fr/}. This Web site contains a lot of
73 | additional information on OCaml.
74 | \end{latexonly}
75 |
76 | \begin{htmlonly}
77 | The complete OCaml distribution can be accessed via the
78 | \href{http://caml.inria.fr/}{Caml Web site}.
79 | The \href{http://caml.inria.fr/}{Caml Web site}
80 | contains a lot of additional information on OCaml.
81 | \end{htmlonly}
82 |
--------------------------------------------------------------------------------
/manual/htmlman/.cvsignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.haux
3 | *.hind
4 | libref
5 | manual.hmanual
6 | manual.hmanual.kwd
7 | manual.css
8 | *.htoc
9 |
--------------------------------------------------------------------------------
/manual/htmlman/.gitignore:
--------------------------------------------------------------------------------
1 | *.html
2 | *.haux
3 | *.hind
4 | libref
5 | manual.hmanual
6 | manual.hmanual.kwd
7 | manual.css
8 | *.htoc
9 |
--------------------------------------------------------------------------------
/manual/htmlman/contents_motif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/htmlman/contents_motif.gif
--------------------------------------------------------------------------------
/manual/htmlman/libgraph.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/htmlman/libgraph.gif
--------------------------------------------------------------------------------
/manual/htmlman/next_motif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/htmlman/next_motif.gif
--------------------------------------------------------------------------------
/manual/htmlman/previous_motif.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/htmlman/previous_motif.gif
--------------------------------------------------------------------------------
/manual/index.tex:
--------------------------------------------------------------------------------
1 | \ifouthtml
2 | \begin{rawhtml}
3 |
10 | \end{rawhtml}
11 | \else
12 | \chapter*{Index to the library}
13 | \markright{Index to the library}
14 | \addcontentsline{toc}{chapter}{Index to the library}
15 | \myprintindex{\jobname.ind}
16 | \fi
17 | \chapter*{Index of keywords}
18 | \markright{Index of keywords}
19 | \addcontentsline{toc}{chapter}{Index of keywords}
20 | \myprintindex{\jobname.kwd.ind}
21 |
--------------------------------------------------------------------------------
/manual/infoman/.cvsignore:
--------------------------------------------------------------------------------
1 | *.haux
2 | *.hind
3 | *.info*.gz
4 | ocaml.hocaml.kwd
5 |
--------------------------------------------------------------------------------
/manual/infoman/.gitignore:
--------------------------------------------------------------------------------
1 | *.haux
2 | *.hind
3 | *.info*.gz
4 | *.info.body*
5 | ocaml.hocaml.kwd
6 |
--------------------------------------------------------------------------------
/manual/labltk.tex:
--------------------------------------------------------------------------------
1 | \documentclass[11pt]{book}
2 | \usepackage[latin1]{inputenc}
3 | %HEVEA\@def@charset{US-ASCII}%
4 | \usepackage{alltt}
5 | \usepackage{fullpage}
6 | \usepackage{syntaxdef}
7 | \usepackage{multind}
8 | \usepackage{html}
9 | \usepackage{textcomp}
10 | \usepackage{caml-sl}
11 | \usepackage{ocamldoc}
12 | \usepackage{xspace}
13 | \newif\ifplaintext
14 | \plaintextfalse
15 | %\newif\ifpdf
16 | %\pdffalse
17 | \input{macros.tex}
18 |
19 | \usepackage{hyperref}
20 | %\makeatletter \def\@wrindex#1#2{\xdef \@indexfile{\csname #1@idxfile\endcsname}\@@wrindex#2||\\}\makeatother
21 | \def\th{^{\hbox{\scriptsize th}}}
22 |
23 | \raggedbottom
24 | \input{version.tex}
25 |
26 | \begin{document}
27 | \thispagestyle{empty}
28 | \begin{center}
29 | ~\vfill
30 | \Huge The LablTk library
31 | release 8.06.0 \\
32 | and \\
33 | The OCamlBrowser library explorer \\[1cm]
34 | \large Jacques Garrigue, Jun Furuse \\
35 | \today \\
36 | \vfill
37 | \end{center}
38 | \setcounter{page}{1}
39 |
40 | \input{library/liblabltk.tex}
41 | \input{cmds/browser.tex}
42 | \end{document}
43 |
--------------------------------------------------------------------------------
/manual/library/.cvsignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 | arithstatus.mli
4 | ocamldoc.out
5 | ocamldoc.sty
6 |
--------------------------------------------------------------------------------
/manual/library/.gitignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 | arithstatus.mli
4 | ocamldoc.out
5 | ocamldoc.sty
6 |
--------------------------------------------------------------------------------
/manual/library/Makefile:
--------------------------------------------------------------------------------
1 | CORE_INTF=Pervasives.tex
2 |
3 | STDLIB_INTF=Arg.tex Array.tex ArrayLabels.tex Char.tex Complex.tex \
4 | Digest.tex Filename.tex Format.tex \
5 | Gc.tex Genlex.tex Hashtbl.tex Int32.tex Int64.tex \
6 | Lazy.tex Lexing.tex List.tex ListLabels.tex Map.tex Marshal.tex \
7 | MoreLabels.tex Nativeint.tex Obj.tex Oo.tex \
8 | Parsing.tex Printexc.tex Printf.tex Queue.tex Random.tex Scanf.tex \
9 | Set.tex Sort.tex Stack.tex Stream.tex String.tex StringLabels.tex Sys.tex \
10 | Weak.tex Callback.tex Buffer.tex StdLabels.tex \
11 | Bytes.tex BytesLabels.tex
12 |
13 | COMPILER_LIBS_INTF=Asthelper.tex Astmapper.tex Asttypes.tex \
14 | Lexer.tex Location.tex Longident.tex Parse.tex Pprintast.tex Printast.tex
15 |
16 | OTHERLIB_INTF=Unix.tex UnixLabels.tex Str.tex \
17 | Num.tex Arithstatus.tex Bigint.tex \
18 | Graphics.tex GraphicsX11.tex \
19 | Thread.tex Mutex.tex Condition.tex Event.tex ThreadUnix.tex \
20 | Dynlink.tex Bigarray.tex
21 |
22 |
23 | INTF=$(CORE_INTF) $(STDLIB_INTF) $(COMPILER_LIBS_INTF) $(OTHERLIB_INTF)
24 |
25 | MLIS=$(CSLDIR)/stdlib/*.mli \
26 | $(CSLDIR)/utils/*.mli \
27 | $(CSLDIR)/parsing/*.mli \
28 | $(CSLDIR)/otherlibs/bigarray/bigarray.mli \
29 | $(CSLDIR)/otherlibs/dynlink/dynlink.mli \
30 | $(CSLDIR)/otherlibs/graph/graphics.mli \
31 | $(CSLDIR)/otherlibs/graph/graphicsX11.mli \
32 | $(CSLDIR)/otherlibs/num/num.mli \
33 | $(CSLDIR)/otherlibs/num/arith_status.mli \
34 | $(CSLDIR)/otherlibs/num/big_int.mli \
35 | $(CSLDIR)/otherlibs/str/*.mli \
36 | $(CSLDIR)/otherlibs/systhreads/*.mli \
37 | $(CSLDIR)/otherlibs/unix/*.mli
38 |
39 | BLURB=core.tex builtin.tex stdlib.tex compilerlibs.tex \
40 | libunix.tex libstr.tex libnum.tex libgraph.tex \
41 | libthreads.tex libdynlink.tex libbigarray.tex
42 |
43 | FILES=$(BLURB) $(INTF)
44 |
45 | FORMAT=../../tools/format-intf
46 | TEXQUOTE=../../tools/texquote2
47 |
48 | CSLDIR=$(RELEASEDIR)
49 |
50 | VPATH=.:$(CSLDIR)/stdlib:$(CSLDIR)/parsing:$(CSLDIR)/otherlibs/unix:$(CSLDIR)/otherlibs/str:$(CSLDIR)/otherlibs/num:$(CSLDIR)/otherlibs/graph:$(CSLDIR)/otherlibs/threads:$(CSLDIR)/otherlibs/dynlink:$(CSLDIR)/otherlibs/bigarray
51 |
52 | all: libs
53 |
54 | libs: $(FILES)
55 |
56 | $(INTF): $(MLIS)
57 | $(CSLDIR)/byterun/ocamlrun $(CSLDIR)/ocamldoc/ocamldoc -latex \
58 | -I $(CSLDIR)/utils \
59 | -I $(CSLDIR)/stdlib \
60 | -I $(CSLDIR)/parsing \
61 | -I $(CSLDIR)/otherlibs/bigarray \
62 | -I $(CSLDIR)/otherlibs/dynlink \
63 | -I $(CSLDIR)/otherlibs/graph \
64 | -I $(CSLDIR)/otherlibs/num \
65 | -I $(CSLDIR)/otherlibs/str \
66 | -I $(CSLDIR)/otherlibs/systhreads \
67 | -I $(CSLDIR)/otherlibs/unix \
68 | $(MLIS) \
69 | -sepfiles \
70 | -latextitle "6,subsection*" \
71 | -latextitle "7,subsubsection*" \
72 | -latex-type-prefix "TYP" \
73 | -latex-module-prefix "" \
74 | -latex-module-type-prefix "" \
75 | -latex-value-prefix ""
76 | mv -f Arith_status.tex Arithstatus.tex
77 | mv -f Big_int.tex Bigint.tex
78 | mv -f Ast_helper.tex Asthelper.tex
79 | mv -f Ast_mapper.tex Astmapper.tex
80 |
81 | Tk.tex: tk.mli
82 | $(CSLDIR)/byterun/ocamlrun $(CSLDIR)/ocamldoc/ocamldoc -latex \
83 | -I +labltk tk.mli \
84 | -sepfiles \
85 | -latextitle "6,subsection*" \
86 | -latextitle "7,subsubsection*" \
87 | -latex-type-prefix "TYP" \
88 | -latex-module-prefix "" \
89 | -latex-module-type-prefix "" \
90 | -latex-value-prefix ""
91 |
92 | clean:
93 | rm -f $(FILES)
94 |
95 |
96 | .SUFFIXES:
97 | .SUFFIXES: .tex .etex .mli
98 |
99 | .etex.tex: $(TEXQUOTE)
100 | $(TEXQUOTE) < $*.etex > $*.tex
101 |
102 | .mli.tex: $(FORMAT)
103 | $(FORMAT) $< > $*.tex < $<
104 |
--------------------------------------------------------------------------------
/manual/library/compilerlibs.etex:
--------------------------------------------------------------------------------
1 | \chapter{The compiler front-end} \label{c:parsinglib}\cutname{parsing.html}
2 | \pdfchapterfold{-1}{The compiler front-end}
3 |
4 | This chapter describes the OCaml front-end, which declares the abstract
5 | syntax tree used by the compiler, provides a way to parse, print
6 | and pretty-print OCaml code, and ultimately allows to write abstract
7 | syntax tree preprocessors invoked via the {\tt -ppx} flag (see chapters~\ref{c:camlc}
8 | and~\ref{c:nativecomp}).
9 |
10 | It is important to note that the exported front-end interface follows the evolution of the OCaml language and implementation, and thus does not provide {\bf any} backwards compatibility guarantees.
11 |
12 | The front-end is a part of "compiler-libs" library.
13 | Programs that use the "compiler-libs" library should be built as follows:
14 | \begin{alltt}
15 | ocamlfind ocamlc \var{other options} -package compiler-libs.common \var{other files}
16 | ocamlfind ocamlopt \var{other options} -package compiler-libs.common \var{other files}
17 | \end{alltt}
18 | Use of the {\tt ocamlfind} utility is recommended. However, if this is not possible, an alternative method may be used:
19 | \begin{alltt}
20 | ocamlc \var{other options} -I +compiler-libs ocamlcommon.cma \var{other files}
21 | ocamlopt \var{other options} -I +compiler-libs ocamlcommon.cmxa \var{other files}
22 | \end{alltt}
23 | For interactive use of the "compiler-libs" library, start "ocaml" and
24 | type\\*"#load \"compiler-libs/ocamlcommon.cma\";;".
25 |
26 | % Some of the files below are commented out as the documentation is too poor
27 | % or they are thought to be nonessential.
28 |
29 | \ifouthtml
30 | \begin{links}
31 | \item \ahref{libref/Ast\_helper.html}{Module \texttt{Ast_helper}: helper functions for AST construction}
32 | \item \ahref{libref/Ast\_mapper.html}{Module \texttt{Ast_mapper}: -ppx rewriter interface}
33 | \item \ahref{libref/Asttypes.html}{Module \texttt{Asttypes}: auxiliary types used by Parsetree}
34 | % \item \ahref{libref/Lexer.html}{Module \texttt{Lexer}: OCaml syntax lexing}
35 | \item \ahref{libref/Location.html}{Module \texttt{Location}: source code locations}
36 | \item \ahref{libref/Longident.html}{Module \texttt{Longident}: long identifiers}
37 | \item \ahref{libref/Parse.html}{Module \texttt{Parse}: OCaml syntax parsing}
38 | \item \ahref{libref/Parsetree.html}{Module \texttt{Parsetree}: OCaml syntax tree}
39 | \item \ahref{libref/Pprintast.html}{Module \texttt{Pprintast}: OCaml syntax printing}
40 | % \item \ahref{libref/Printast.html}{Module \texttt{Printast}: AST printing}
41 | \end{links}
42 |
43 | \else
44 | % Ast_helper is excluded from the PDF and text manuals.
45 | % It is over 20 pages long and does not have doc-comments. It is expected
46 | % that Ast_helper will be only useful in the HTML manual (to look up signatures).
47 | % \input{Asthelper.tex}
48 | \input{Astmapper.tex}
49 | \input{Asttypes.tex}
50 | % \input{Lexer.tex}
51 | \input{Location.tex}
52 | \input{Longident.tex}
53 | \input{Parse.tex}
54 | \input{Parsetree.tex}
55 | \input{Pprintast.tex}
56 | % \input{Printast.tex}
57 | \fi
58 |
59 |
--------------------------------------------------------------------------------
/manual/library/core.etex:
--------------------------------------------------------------------------------
1 | \chapter{The core library} \label{c:corelib}\cutname{core.html}
2 | \pdfchapterfold{-1}{The core library}
3 |
4 | This chapter describes the OCaml core library, which is
5 | composed of declarations for built-in types and exceptions, plus
6 | the module "Pervasives" that provides basic operations on these
7 | built-in types. The "Pervasives" module is special in two
8 | ways:
9 | \begin{itemize}
10 | \item It is automatically linked with the user's object code files by
11 | the "ocamlc" command (chapter~\ref{c:camlc}).
12 |
13 | \item It is automatically ``opened'' when a compilation starts, or
14 | when the toplevel system is launched. Hence, it is possible to use
15 | unqualified identifiers to refer to the functions provided by the
16 | "Pervasives" module, without adding a "open Pervasives" directive.
17 | \end{itemize}
18 |
19 | \section*{Conventions}
20 |
21 | The declarations of the built-in types and the components of module
22 | "Pervasives" are printed one by one in typewriter font, followed by a
23 | short comment. All library modules and the components they provide are
24 | indexed at the end of this report.
25 |
26 | \input{builtin.tex}
27 |
28 | \ifouthtml
29 | \section{Module {\tt Pervasives}: the initially opened module}
30 | \begin{links}
31 | \item \ahref{libref/Pervasives.html}{Module \texttt{Pervasives}: the initially opened module}
32 | \end{links}
33 | \else
34 | \input{Pervasives.tex}
35 | \fi
36 |
37 |
--------------------------------------------------------------------------------
/manual/library/libbigarray.etex:
--------------------------------------------------------------------------------
1 | \chapter{The bigarray library}
2 | \pdfchapterfold{-1}{The bigarray library}
3 | %HEVEA\cutname{libbigarray.html}
4 |
5 | The "bigarray" library implements large, multi-dimensional, numerical
6 | arrays. These arrays are called ``big arrays'' to distinguish them
7 | from the standard OCaml arrays described in
8 | \ifouthtml
9 | \ahref{libref/Array.html}{Module \texttt{Array}}.
10 | \else
11 | section~\ref{Array}.
12 | \fi
13 | The main differences between ``big arrays'' and standard OCaml arrays
14 | are as follows:
15 | \begin{itemize}
16 | \item Big arrays are not limited in size, unlike OCaml arrays
17 | ("float array" are limited to 2097151 elements on a 32-bit platform,
18 | other "array" types to 4194303 elements).
19 | \item Big arrays are multi-dimensional. Any number of dimensions
20 | between 1 and 16 is supported. In contrast, OCaml arrays are
21 | mono-dimensional and require encoding multi-dimensional arrays as
22 | arrays of arrays.
23 | \item Big arrays can only contain integers and floating-point
24 | numbers, while OCaml arrays can contain arbitrary OCaml data types.
25 | However, big arrays provide more space-efficient storage of integer
26 | and floating-point elements, in particular because they support
27 | ``small'' types such as single-precision floats and 8 and 16-bit
28 | integers, in addition to the standard OCaml types of double-precision
29 | floats and 32 and 64-bit integers.
30 | \item The memory layout of big arrays is entirely compatible with that
31 | of arrays in C and Fortran, allowing large arrays to be passed back
32 | and forth between OCaml code and C / Fortran code with no data copying
33 | at all.
34 | \item Big arrays support interesting high-level operations that normal
35 | arrays do not provide efficiently, such as extracting sub-arrays and
36 | ``slicing'' a multi-dimensional array along certain dimensions, all
37 | without any copying.
38 | \end{itemize}
39 | %
40 | Programs that use the "bigarray" library must be linked as follows:
41 | \begin{alltt}
42 | ocamlc \var{other options} bigarray.cma \var{other files}
43 | ocamlopt \var{other options} bigarray.cmxa \var{other files}
44 | \end{alltt}
45 | For interactive use of the "bigarray" library, do:
46 | \begin{alltt}
47 | ocamlmktop -o mytop bigarray.cma
48 | ./mytop
49 | \end{alltt}
50 | or (if dynamic linking of C libraries is supported on your platform),
51 | start "ocaml" and type "#load \"bigarray.cma\";;".
52 |
53 | \ifouthtml
54 | \section{Module {\tt Bigarray}: large, multi-dimensional, numerical arrays}
55 | \begin{links}
56 | \item \ahref{libref/Bigarray.html}{Module \texttt{Bigarray}}
57 | \end{links}
58 |
59 | \else
60 | \input{Bigarray.tex}
61 | \fi
62 |
63 | \section{Big arrays in the OCaml-C interface}
64 |
65 | C stub code that interface C or Fortran code with OCaml code, as
66 | described in chapter~\ref{c:intf-c}, can exploit big arrays as
67 | follows.
68 |
69 | \subsection{Include file}
70 |
71 | The include file "" must be included in the C stub
72 | file. It declares the functions, constants and macros discussed
73 | below.
74 |
75 | \subsection{Accessing an OCaml bigarray from C or Fortran}
76 |
77 | If \var{v} is a OCaml "value" representing a big array, the expression
78 | "Caml_ba_data_val("\var{v}")" returns a pointer to the data part of the array.
79 | This pointer is of type "void *" and can be cast to the appropriate C
80 | type for the array (e.g. "double []", "char [][10]", etc).
81 |
82 | Various characteristics of the OCaml big array can be consulted from C
83 | as follows:
84 | \begin{tableau}{|l|l|}{C expression}{Returns}
85 | \entree{"Caml_ba_array_val("\var{v}")->num_dims"}{number of dimensions}
86 | \entree{"Caml_ba_array_val("\var{v}")->dim["\var{i}"]"}{\var{i}-th dimension}
87 | \entree{"Caml_ba_array_val("\var{v}")->flags & BIGARRAY_KIND_MASK"}{kind of array elements}
88 | \end{tableau}
89 | The kind of array elements is one of the following constants:
90 | \begin{tableau}{|l|l|}{Constant}{Element kind}
91 | \entree{"CAML_BA_FLOAT32"}{32-bit single-precision floats}
92 | \entree{"CAML_BA_FLOAT64"}{64-bit double-precision floats}
93 | \entree{"CAML_BA_SINT8"}{8-bit signed integers}
94 | \entree{"CAML_BA_UINT8"}{8-bit unsigned integers}
95 | \entree{"CAML_BA_SINT16"}{16-bit signed integers}
96 | \entree{"CAML_BA_UINT16"}{16-bit unsigned integers}
97 | \entree{"CAML_BA_INT32"}{32-bit signed integers}
98 | \entree{"CAML_BA_INT64"}{64-bit signed integers}
99 | \entree{"CAML_BA_CAML_INT"}{31- or 63-bit signed integers}
100 | \entree{"CAML_BA_NATIVE_INT"}{32- or 64-bit (platform-native) integers}
101 | \end{tableau}
102 | %
103 | The following example shows the passing of a two-dimensional big array
104 | to a C function and a Fortran function.
105 | \begin{verbatim}
106 | extern void my_c_function(double * data, int dimx, int dimy);
107 | extern void my_fortran_function_(double * data, int * dimx, int * dimy);
108 |
109 | value caml_stub(value bigarray)
110 | {
111 | int dimx = Caml_ba_array_val(bigarray)->dim[0];
112 | int dimy = Caml_ba_array_val(bigarray)->dim[1];
113 | /* C passes scalar parameters by value */
114 | my_c_function(Caml_ba_data_val(bigarray), dimx, dimy);
115 | /* Fortran passes all parameters by reference */
116 | my_fortran_function_(Caml_ba_data_val(bigarray), &dimx, &dimy);
117 | return Val_unit;
118 | }
119 | \end{verbatim}
120 |
121 | \subsection{Wrapping a C or Fortran array as an OCaml big array}
122 |
123 | A pointer \var{p} to an already-allocated C or Fortran array can be
124 | wrapped and returned to OCaml as a big array using the "caml_ba_alloc"
125 | or "caml_ba_alloc_dims" functions.
126 | \begin{itemize}
127 | \item
128 | "caml_ba_alloc("\var{kind} "|" \var{layout}, \var{numdims}, \var{p}, \var{dims}")"
129 |
130 | Return an OCaml big array wrapping the data pointed to by \var{p}.
131 | \var{kind} is the kind of array elements (one of the "CAML_BA_"
132 | kind constants above). \var{layout} is "CAML_BA_C_LAYOUT" for an
133 | array with C layout and "CAML_BA_FORTRAN_LAYOUT" for an array with
134 | Fortran layout. \var{numdims} is the number of dimensions in the
135 | array. \var{dims} is an array of \var{numdims} long integers, giving
136 | the sizes of the array in each dimension.
137 |
138 | \item
139 | "caml_ba_alloc_dims("\var{kind} "|" \var{layout}, \var{numdims},
140 | \var{p}, "(long) "\nth{dim}{1}, "(long) "\nth{dim}{2}, \ldots, "(long) "\nth{dim}{numdims}")"
141 |
142 | Same as "caml_ba_alloc", but the sizes of the array in each dimension
143 | are listed as extra arguments in the function call, rather than being
144 | passed as an array.
145 | \end{itemize}
146 | %
147 | The following example illustrates how statically-allocated C and
148 | Fortran arrays can be made available to OCaml.
149 | \begin{verbatim}
150 | extern long my_c_array[100][200];
151 | extern float my_fortran_array_[300][400];
152 |
153 | value caml_get_c_array(value unit)
154 | {
155 | long dims[2];
156 | dims[0] = 100; dims[1] = 200;
157 | return caml_ba_alloc(CAML_BA_NATIVE_INT | CAML_BA_C_LAYOUT,
158 | 2, my_c_array, dims);
159 | }
160 |
161 | value caml_get_fortran_array(value unit)
162 | {
163 | return caml_ba_alloc_dims(CAML_BA_FLOAT32 | CAML_BA_FORTRAN_LAYOUT,
164 | 2, my_fortran_array_, 300L, 400L);
165 | }
166 | \end{verbatim}
167 |
168 |
169 |
--------------------------------------------------------------------------------
/manual/library/libdynlink.etex:
--------------------------------------------------------------------------------
1 | \chapter{The dynlink library: dynamic loading and linking of object files}
2 | \pdfchapterfold{-1}{The dynlink library: dynamic loading and linking of object files}
3 | %HEVEA\cutname{libdynlink.html}
4 |
5 | The "dynlink" library supports type-safe dynamic loading and linking
6 | of bytecode object files (".cmo" and ".cma" files) in a running
7 | bytecode program, or of native plugins (usually ".cmxs" files) in a
8 | running native program. Type safety is ensured by limiting the set of
9 | modules from the running program that the loaded object file can
10 | access, and checking that the running program and the loaded object
11 | file have been compiled against the same interfaces for these modules.
12 | In native code, there are also some compatibility checks on the
13 | implementations (to avoid errors with cross-module optimizations); it
14 | might be useful to hide ".cmx" files when building native plugins so
15 | that they remain independent of the implementation of modules in the
16 | main program.
17 |
18 | Programs that use the "dynlink" library simply need to link
19 | "dynlink.cma" or "dynlink.cmxa" with their object files and other libraries.
20 |
21 | \ifouthtml
22 | \begin{links}
23 | \item \ahref{libref/Dynlink.html}{Module \texttt{Dynlink}: dynamic loading of bytecode object files}
24 | \end{links}
25 |
26 | \else
27 | \input{Dynlink.tex}
28 | \fi
29 |
30 |
--------------------------------------------------------------------------------
/manual/library/libgraph.etex:
--------------------------------------------------------------------------------
1 | \chapter{The graphics library}
2 | \pdfchapterfold{-1}{The graphics library}
3 | %HEVEA\cutname{libgraph.html}
4 |
5 | The "graphics" library provides a set of portable drawing primitives.
6 | Drawing takes place
7 | in a separate window that is created when "Graphics.open_graph" is called.
8 |
9 | \begin{unix}
10 | This library is implemented under the X11 windows system.
11 | Programs that use the "graphics" library must be linked as follows:
12 | \begin{alltt}
13 | ocamlc \var{other options} graphics.cma \var{other files}
14 | \end{alltt}
15 | For interactive use of the "graphics" library, do:
16 | \begin{alltt}
17 | ocamlmktop -o mytop graphics.cma
18 | ./mytop
19 | \end{alltt}
20 | or (if dynamic linking of C libraries is supported on your platform),
21 | start "ocaml" and type "#load \"graphics.cma\";;".
22 |
23 | Here are the graphics mode specifications supported by
24 | "Graphics.open_graph" on
25 | the X11 implementation of this library:
26 | the argument to "Graphics.open_graph" has the format
27 | "\""{\it display-name} {\it geometry\/}"\"",
28 | where {\it display-name} is the name of the X-windows display to
29 | connect to, and {\it geometry} is a standard X-windows geometry
30 | specification. The two components are separated by a space. Either can
31 | be omitted, or both. Examples:
32 | \begin{options}
33 | \item["Graphics.open_graph \"foo:0\""]
34 | connects to the display "foo:0" and creates a window with the default geometry
35 | \item["Graphics.open_graph \"foo:0 300x100+50-0\""]
36 | connects to the display "foo:0" and creates a window 300 pixels wide
37 | by 100 pixels tall, at location $(50,0)$
38 | \item["Graphics.open_graph \" 300x100+50-0\""]
39 | connects to the default display and creates a window 300 pixels wide
40 | by 100 pixels tall, at location $(50,0)$
41 | \item["Graphics.open_graph \"\""]
42 | connects to the default display and creates a window with the default
43 | geometry.
44 | \end{options}
45 | \end{unix}
46 |
47 | \begin{windows}
48 | This library is available both for standalone compiled programs and
49 | under the toplevel application "ocamlwin.exe". For the latter, this
50 | library must be loaded in-core by typing
51 | \begin{verbatim}
52 | #load "graphics.cma";;
53 | \end{verbatim}
54 | \end{windows}
55 |
56 | The screen coordinates are interpreted as shown in the figure below.
57 | Notice that the coordinate system used is the same as in mathematics:
58 | $y$ increases from the bottom of the screen to the top of the screen,
59 | and angles are measured counterclockwise (in degrees).
60 | Drawing is clipped to the screen.
61 | %
62 | \begin{latexonly}
63 | \begin{center}
64 | \setlength{\unitlength}{0.5mm}
65 | \begin{picture}(130,100)(-10,-10)
66 | \thicklines
67 | \put(-10,0){\vector(1,0){130}}
68 | \put(125,0){\makebox(0,0)[l]{$x$}}
69 | \put(0,-10){\vector(0,1){100}}
70 | \put(0,95){\makebox(0,0){$y$}}
71 | \thinlines
72 | \put(100,80){\line(-1,0){105}}
73 | \put(100,80){\line(0,-1){85}}
74 | \put(95,75){\makebox(0,0)[tr]{Screen}}
75 | \put(100,-10){\makebox(0,0){\tt size\_x()}}
76 | \put(-10,80){\makebox(0,0)[r]{\tt size\_y()}}
77 | \put(30,40){\makebox(4,4){\rule{2mm}{2mm}}}
78 | \put(36,40){pixel at $(x,y)$}
79 | \put(30,40){\line(-1,0){35}}
80 | \put(30,-10){\makebox(0,0){$x$}}
81 | \put(30,40){\line(0,-1){45}}
82 | \put(-10,40){\makebox(0,0)[r]{$y$}}
83 | \end{picture}
84 | \end{center}
85 | \end{latexonly}
86 |
87 | \begin{htmlonly}
88 | \begin{center}
89 | \imgsrc{libgraph.gif}
90 | \end{center}
91 | \end{htmlonly}
92 | %
93 |
94 | \ifouthtml
95 | \begin{links}
96 | \item \ahref{libref/Graphics.html}{Module \texttt{Graphics}: machine-independent graphics primitives}
97 | \end{links}
98 | \else
99 | \input{Graphics.tex}
100 | \fi
101 |
--------------------------------------------------------------------------------
/manual/library/libgraph.fig:
--------------------------------------------------------------------------------
1 | #FIG 3.2
2 | Landscape
3 | Center
4 | Inches
5 | Letter
6 | 100.00
7 | Single
8 | -2
9 | 1200 2
10 | 2 1 0 1 0 7 0 0 -1 0.000 0 0 7 1 0 2
11 | 1 1 1.00 60.00 120.00
12 | 1050 3375 4575 3375
13 | 2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 1 0 2
14 | 1 1 1.00 60.00 120.00
15 | 1200 3525 1200 825
16 | 2 1 0 1 0 7 0 0 -1 0.000 0 0 7 0 0 3
17 | 1125 1200 3750 1200 3750 3450
18 | 2 1 0 1 0 7 0 0 -1 0.000 0 0 -1 0 0 3
19 | 1125 2400 2475 2400 2475 3450
20 | 2 2 0 1 0 0 0 0 20 0.000 0 0 7 0 0 5
21 | 2475 2400 2550 2400 2550 2325 2475 2325 2475 2400
22 | 4 0 0 0 0 0 12 0.0000 4 135 525 2325 1500 Screen\001
23 | 4 0 0 0 0 0 12 0.0000 4 180 990 2175 2250 point at (x,y)\001
24 | 4 0 0 0 0 0 12 0.0000 4 90 90 2400 3600 x\001
25 | 4 0 0 0 0 0 12 0.0000 4 135 90 975 2475 y\001
26 | 4 0 0 0 0 0 12 0.0000 4 180 450 1050 750 y axis\001
27 | 4 0 0 0 0 14 12 0.0000 4 180 840 225 1200 size_y()\001
28 | 4 0 0 0 0 14 12 0.0000 4 165 840 3375 3600 size_x()\001
29 | 4 0 0 0 0 0 12 0.0000 4 135 450 4650 3375 x axis\001
30 |
--------------------------------------------------------------------------------
/manual/library/libgraph.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/library/libgraph.png
--------------------------------------------------------------------------------
/manual/library/liblabltk.etex:
--------------------------------------------------------------------------------
1 | \chapter{The LablTk library: Tcl/Tk GUI interface}
2 | \pdfchapterfold{-1}{The LablTk library: Tcl/Tk GUI interface}
3 | %HEVEA\cutname{liblabltk.html}
4 |
5 | The "labltk" library provides access to the Tcl/Tk GUI from
6 | OCaml programs. This interface is generated in an automated way, and
7 | you should refer to Tcl/Tk books and man pages for detailed
8 | information on the behavior of the numerous functions. We also suggest
9 | to use "ocamlbrowser" to see the types of the various functions, that
10 | are the best documentation for the library itself.
11 |
12 | \smallskip\noindent
13 | Programs that use the "labltk" library must be linked as follows:
14 | \begin{alltt}
15 | ocamlc \var{other options} -I +labltk labltk.cma \var{other files}
16 | ocamlopt \var{other options} -I +labltk labltk.cmxa \var{other files}
17 | \end{alltt}
18 |
19 | \begin{unix}
20 | The "labltk" library is available for any system with Tcl/Tk installed,
21 | starting from Tcl/Tk 8.0 up to Tcl/Tk 8.6. Beware that some beta
22 | versions may have compatibility problems.
23 |
24 | If the library was not compiled correctly, try to run again the
25 | "configure" script with the option "-tkdefs" \var{switches},
26 | where \var{switches} is a list of C-style inclusion paths leading to
27 | the right "tcl.h" and "tk.h", for instance
28 | "\"-I/usr/local/include/tcl8.4 -I/usr/local/include/tk8.4\"".
29 |
30 | A script is installed, to make easier the use of the "labltk"
31 | library as toplevel.
32 | \begin{options}
33 | \item["labltk"]
34 | This is a toplevel including the "labltk" library, and the path is
35 | already set as to allow the use of the various modules. It also
36 | includes code for the Unix and Str libraries. You can use it
37 | in place of "ocaml".
38 | \end{options}
39 | \end{unix}
40 |
41 | \begin{windows}
42 | The "labltk" library has been precompiled for use with Tcl/Tk 8.5.
43 | You must first have it installed on your system.
44 | It can be downloaded from \\
45 | "http://www.activestate.com/products/ActiveTcl/".
46 | After installing it, you must put the dynamically loaded libraries
47 | "tcl85.dll" and "tk85.dll" (from the "bin" directory of the Tcl
48 | installation) in a directory included in you path.
49 |
50 | No toplevel is available, but you can load the library from the
51 | standard toplevel with the following commands.
52 | \begin{quote}
53 | \begin{verbatim}
54 | # #directory "+labltk";;
55 | # #load "labltk.cma";;
56 | \end{verbatim}
57 | \end{quote}
58 | You can also load it directly from the command line.
59 | \begin{quote}
60 | \begin{verbatim}
61 | C:\ocaml\bin> ocaml -I +labltk labltk.cma
62 | \end{verbatim}
63 | \end{quote}
64 | \end{windows}
65 |
66 | The "labltk" library is composed of a large number of modules.
67 | \begin{quote}
68 | \begin{verbatim}
69 | Bell Imagebitmap Place
70 | Button Imagephoto Radiobutton
71 | Canvas Label Scale
72 | Checkbutton Listbox Scrollbar
73 | Clipboard Menu Selection
74 | Dialog Menubutton Text
75 | Entry Message Tk
76 | Focus Option Tkwait
77 | Frame Optionmenu Toplevel
78 | Grab Pack Winfo
79 | Grid Palette Wm
80 | \end{verbatim}
81 | \end{quote}
82 |
83 | Giving a detailed account of each of these module would be impractical
84 | here. We will just present some of the basic functions in the module
85 | "Tk". Note that for most other modules information can be found in the
86 | Tcl "man" page of their name.
87 |
88 | \ifouthtml
89 | \begin{links}
90 | \item \ahref{libref/Tk.html}{The \texttt{Tk} library: Basic functions and types for LablTk}
91 | \end{links}
92 |
93 | \else
94 | \input{Tk.tex}
95 | \fi
96 |
97 |
--------------------------------------------------------------------------------
/manual/library/libnum.etex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/library/libnum.etex
--------------------------------------------------------------------------------
/manual/library/libstr.etex:
--------------------------------------------------------------------------------
1 | \chapter{The str library: regular expressions and string processing}
2 | \pdfchapterfold{-1}{The str library: regular expressions and string processing}
3 | %HEVEA\cutname{libstr.html}
4 |
5 | The "str" library provides high-level string processing functions,
6 | some based on regular expressions. It is intended to support the kind
7 | of file processing that is usually performed with scripting languages
8 | such as "awk", "perl" or "sed".
9 |
10 | Programs that use the "str" library must be linked as follows:
11 | \begin{alltt}
12 | ocamlc \var{other options} str.cma \var{other files}
13 | ocamlopt \var{other options} str.cmxa \var{other files}
14 | \end{alltt}
15 | For interactive use of the "str" library, do:
16 | \begin{alltt}
17 | ocamlmktop -o mytop str.cma
18 | ./mytop
19 | \end{alltt}
20 | or (if dynamic linking of C libraries is supported on your platform),
21 | start "ocaml" and type "#load \"str.cma\";;".
22 |
23 | \ifouthtml
24 | \begin{links}
25 | \item \ahref{libref/Str.html}{Module \texttt{Str}: regular expressions and string processing}
26 | \end{links}
27 |
28 | \else
29 | \input{Str.tex}
30 | \fi
31 |
32 |
33 |
--------------------------------------------------------------------------------
/manual/library/libthreads.etex:
--------------------------------------------------------------------------------
1 | \chapter{The threads library}
2 | \label{c:threads}\cutname{threads.html}
3 | \pdfchapterfold{-5}{The threads library}
4 | %HEVEA\cutname{libthreads.html}
5 |
6 | The "threads" library allows concurrent programming in OCaml.
7 | It provides multiple threads of control (also called lightweight
8 | processes) that execute concurrently in the same memory space. Threads
9 | communicate by in-place modification of shared data structures, or by
10 | sending and receiving data on communication channels.
11 |
12 | The "threads" library is implemented by time-sharing on a single
13 | processor. It will not take advantage of multi-processor machines.
14 | Using this library will therefore never make programs run
15 | faster. However, many programs are easier to write when structured as
16 | several communicating processes.
17 |
18 | Two implementations of the "threads" library are available, depending
19 | on the capabilities of the operating system:
20 | \begin{itemize}
21 | \item System threads. This implementation builds on the OS-provided threads
22 | facilities: POSIX 1003.1c threads for Unix, and Win32 threads for
23 | Windows. When available, system threads support both bytecode and
24 | native-code programs.
25 | \item VM-level threads. This implementation performs time-sharing and
26 | context switching at the level of the OCaml virtual machine (bytecode
27 | interpreter). It is available on Unix systems, and supports only
28 | bytecode programs. It cannot be used with native-code programs.
29 | \end{itemize}
30 | Programs that use system threads must be linked as follows:
31 | \begin{alltt}
32 | ocamlc -thread \var{other options} unix.cma threads.cma \var{other files}
33 | ocamlopt -thread \var{other options} unix.cmxa threads.cmxa \var{other files}
34 | \end{alltt}
35 | Compilation units that use the "threads" library must also be compiled with
36 | the "-thread" option (see chapter~\ref{c:camlc}).
37 |
38 | Programs that use VM-level threads must be compiled with the "-vmthread"
39 | option to "ocamlc" (see chapter~\ref{c:camlc}), and be linked as follows:
40 | \begin{alltt}
41 | ocamlc -vmthread \var{other options} threads.cma \var{other files}
42 | \end{alltt}
43 | Compilation units that use "threads" library must also be compiled with
44 | the "-vmthread" option (see chapter~\ref{c:camlc}).
45 |
46 | \ifouthtml
47 | \begin{links}
48 | \item \ahref{libref/Thread.html}{Module \texttt{Thread}: lightweight threads}
49 | \item \ahref{libref/Mutex.html}{Module \texttt{Mutex}: locks for mutual exclusion}
50 | \item \ahref{libref/Condition.html}{Module \texttt{Condition}: condition variables to synchronize between threads}
51 | \item \ahref{libref/Event.html}{Module \texttt{Event}: first-class synchronous communication}
52 | \item \ahref{libref/ThreadUnix.html}{Module \texttt{ThreadUnix}: thread-compatible system calls}
53 | \end{links}
54 | \else
55 | \input{Thread.tex}
56 | \input{Mutex.tex}
57 | \input{Condition.tex}
58 | \input{Event.tex}
59 | \input{ThreadUnix.tex}
60 | \fi
61 |
--------------------------------------------------------------------------------
/manual/library/libunix.etex:
--------------------------------------------------------------------------------
1 | \chapter{The unix library: Unix system calls}
2 | \pdfchapterfold{-1}{The unix library: Unix system calls}
3 | %HEVEA\cutname{libunix.html}
4 |
5 | The "unix" library makes many Unix
6 | system calls and system-related library functions available to
7 | OCaml programs. This chapter describes briefly the functions
8 | provided. Refer to sections 2~and~3 of the Unix manual for more
9 | details on the behavior of these functions.
10 |
11 | Not all functions are provided by all Unix variants. If some functions
12 | are not available, they will raise "Invalid_arg" when called.
13 |
14 | Programs that use the "unix" library must be linked as follows:
15 | \begin{alltt}
16 | ocamlc \var{other options} unix.cma \var{other files}
17 | ocamlopt \var{other options} unix.cmxa \var{other files}
18 | \end{alltt}
19 | For interactive use of the "unix" library, do:
20 | \begin{alltt}
21 | ocamlmktop -o mytop unix.cma
22 | ./mytop
23 | \end{alltt}
24 | or (if dynamic linking of C libraries is supported on your platform),
25 | start "ocaml" and type "#load \"unix.cma\";;".
26 |
27 | \begin{windows}
28 | A fairly complete emulation of the Unix system calls is provided in
29 | the Windows version of OCaml. The end of this chapter gives
30 | more information on the functions that are not supported under Windows.
31 | \end{windows}
32 |
33 | \ifouthtml
34 | \begin{links}
35 | \item \ahref{libref/Unix.html}{Module \texttt{Unix}: Unix system calls}
36 | \item \ahref{libref/UnixLabels.html}{Module \texttt{UnixLabels}: Labeled
37 | Unix system calls}
38 | \end{links}
39 | \else
40 | \input{Unix.tex}
41 |
42 | \section{Module \texttt{UnixLabels}: labelized version of the interface}
43 | \label{UnixLabels}
44 | \index{UnixLabels (module)@\verb~UnixLabels~ (module)}%
45 | \pdfsection{Module UnixLabels: labelized version of the interface}
46 |
47 | This module is identical to "Unix"~(\ref{Unix}), and only differs by
48 | the addition of labels. You may see these labels directly by looking
49 | at "unixLabels.mli", or by using the "ocamlbrowser" tool.
50 | \fi
51 |
52 | \newpage
53 | \begin{windows}
54 | The Cygwin port of OCaml fully implements all functions from
55 | the Unix module. The native Win32 ports implement a subset of them.
56 | Below is a list of the functions that are not implemented, or only
57 | partially implemented, by the Win32 ports. Functions not mentioned are
58 | fully implemented and behave as described previously in this chapter.
59 |
60 | \begin{tableau}{|l|p{8cm}|}{Functions}{Comment}
61 | \entree{"fork"}{not implemented, use "create_process" or threads}
62 | \entree{"wait"}{not implemented, use "waitpid"}
63 | \entree{"waitpid"}{can only wait for a given PID, not any child process}
64 | \entree{"getppid"}{not implemented (meaningless under Windows)}
65 | \entree{"nice"}{not implemented}
66 | \entree{"truncate", "ftruncate"}{not implemented}
67 | \entree{"link", "symlink", "readlink"}{not implemented (no links under
68 | Windows)}
69 | \entree{"access"}{execute permission "X_OK" cannot be tested,
70 | it just tests for read permission instead}
71 | \entree{"fchmod"}{not implemented}
72 | \entree{"chown", "fchown"}{not implemented (make no sense on a DOS
73 | file system)}
74 | \entree{"umask"}{not implemented}
75 | \entree{"mkfifo"}{not implemented}
76 | \entree{"kill", "pause"}{not implemented (no inter-process signals in Windows)}
77 | \entree{"alarm"}{not implemented}
78 | \entree{"times"}{partially implemented, will not report timings for child
79 | processes}
80 | \entree{"getitimer", "setitimer"}{not implemented}
81 | \entree{"getuid", "getgid"}{always return 1}
82 | \entree{"getgid", "getegid", "getgroups"}{not implemented}
83 | \entree{"setuid", "setgid"}{not implemented}
84 | \entree{"getpwnam", "getpwuid"}{always raise "Not_found"}
85 | \entree{"getgrnam", "getgrgid"}{always raise "Not_found"}
86 | \entree{type "socket_domain"}{the domains "PF_UNIX" and "PF_INET6"
87 | are not supported; "PF_INET" is fully supported}
88 | \entree{"establish_server"}{not implemented; use threads}
89 | \entree{terminal functions ("tc*")}{not implemented}
90 | \end{tableau}
91 |
92 | \end{windows}
93 |
--------------------------------------------------------------------------------
/manual/library/tk.mli:
--------------------------------------------------------------------------------
1 | (* $Id$ *)
2 |
3 | (** Basic functions and types for LablTk *)
4 |
5 | open Widget
6 |
7 | (** {6 Initialization and termination} *)
8 |
9 | val openTk : ?display:string -> ?clas:string -> unit -> toplevel widget
10 | (** Initialize LablTk and open a toplevel window.
11 | [display] is described according to the X11 conventions.
12 | [clas] is used for the X11 resource mechanism. *)
13 | val mainLoop : unit -> unit
14 | (** Start the main event loop *)
15 | val closeTk : unit -> unit
16 | (** Quit the main loop and close all open windows. *)
17 | val destroy : 'a Widget.widget -> unit
18 | (** Destroy an individual widget. *)
19 |
20 | (** {6 Application wide commands} *)
21 |
22 | val update : unit -> unit
23 | (** Synchronize display with internal state. *)
24 |
25 | val appname_get : unit -> string
26 | val appname_set : string -> unit
27 | (** Get or set the application name. *)
28 |
29 | (** {6 Dimensions} *)
30 |
31 | type units = [`Pix of int | `Cm of float | `In of float | `Mm of float | `Pt of float]
32 | val pixels : units -> int
33 | (** Converts various on-screen units to pixels,
34 | respective to the default display. Available units are
35 | pixels, centimeters, inches, millimeters and points *)
36 |
37 | (** {6 Widget layout commands} *)
38 |
39 | type anchor = [`Center|`E|`N|`Ne|`Nw|`S|`Se|`Sw|`W]
40 | type fillMode = [`Both|`None|`X|`Y]
41 | type side = [`Bottom|`Left|`Right|`Top]
42 | val pack :
43 | ?after:'a Widget.widget ->
44 | ?anchor:anchor ->
45 | ?before:'b Widget.widget ->
46 | ?expand:bool ->
47 | ?fill:fillMode ->
48 | ?inside:'c Widget.widget ->
49 | ?ipadx:int ->
50 | ?ipady:int ->
51 | ?padx:int ->
52 | ?pady:int ->
53 | ?side:side ->
54 | 'd Widget.widget list -> unit
55 | (** Pack a widget inside its parent,
56 | using the standard layout engine. *)
57 | val grid :
58 | ?column:int ->
59 | ?columnspan:int ->
60 | ?inside:'a Widget.widget ->
61 | ?ipadx:int ->
62 | ?ipady:int ->
63 | ?padx:int ->
64 | ?pady:int ->
65 | ?row:int ->
66 | ?rowspan:int ->
67 | ?sticky:string -> 'b Widget.widget list -> unit
68 | (** Pack a widget inside its parent, using the grid layout engine. *)
69 |
70 | type borderMode = [`Ignore|`Inside|`Outside]
71 | val place :
72 | ?anchor:anchor ->
73 | ?bordermode:borderMode ->
74 | ?height:int ->
75 | ?inside:'a Widget.widget ->
76 | ?relheight:float ->
77 | ?relwidth:float ->
78 | ?relx:float ->
79 | ?rely:float ->
80 | ?width:int ->
81 | ?x:int -> ?y:int -> 'b Widget.widget -> unit
82 | (** Pack a widget inside its parent, at absolute coordinates. *)
83 |
84 | val raise_window :
85 | ?above:'a Widget.widget -> 'b Widget.widget -> unit
86 | val lower_window :
87 | ?below:'a Widget.widget -> 'b Widget.widget -> unit
88 | (** Raise or lower the window associated to a widget. *)
89 |
90 | (** {6 Event handling} *)
91 |
92 | type modifier =
93 | [ `Control | `Shift | `Lock
94 | | `Button1 | `Button2 | `Button3 | `Button4 | `Button5
95 | | `Double | `Triple
96 | | `Mod1 | `Mod2 | `Mod3 | `Mod4 | `Mod5 | `Meta | `Alt ]
97 |
98 | type event =
99 | [ `ButtonPress | `ButtonPressDetail of int
100 | | `ButtonRelease | `ButtonReleaseDetail of int
101 | | `Circulate | `ColorMap | `Configure | `Destroy
102 | | `Enter | `Expose | `FocusIn | `FocusOut | `Gravity
103 | | `KeyPress | `KeyPressDetail of string
104 | | `KeyRelease | `KeyReleaseDetail of string
105 | | `Leave | `Map | `Motion | `Property
106 | | `Reparent | `Unmap | `Visibility
107 | | `Modified of modifier list * event ]
108 |
109 | (** An event can be either a basic X event, or modified by a
110 | key or mouse modifier. *)
111 |
112 | type eventInfo =
113 | { mutable ev_Above: int;
114 | mutable ev_ButtonNumber: int;
115 | mutable ev_Count: int;
116 | mutable ev_Detail: string;
117 | mutable ev_Focus: bool;
118 | mutable ev_Height: int;
119 | mutable ev_KeyCode: int;
120 | mutable ev_Mode: string;
121 | mutable ev_OverrideRedirect: bool;
122 | mutable ev_Place: string;
123 | mutable ev_State: string;
124 | mutable ev_Time: int;
125 | mutable ev_Width: int;
126 | mutable ev_MouseX: int;
127 | mutable ev_MouseY: int;
128 | mutable ev_Char: string;
129 | mutable ev_BorderWidth: int;
130 | mutable ev_SendEvent: bool;
131 | mutable ev_KeySymString: string;
132 | mutable ev_KeySymInt: int;
133 | mutable ev_RootWindow: int;
134 | mutable ev_SubWindow: int;
135 | mutable ev_Type: int;
136 | mutable ev_Widget: Widget.any Widget.widget;
137 | mutable ev_RootX: int;
138 | mutable ev_RootY: int }
139 |
140 | (** Event related information accessible in callbacks. *)
141 |
142 | type eventField =
143 | [ `Above | `ButtonNumber | `Count | `Detail | `Focus | `Height
144 | | `KeyCode | `Mode | `OverrideRedirect | `Place | `State
145 | | `Time | `Width | `MouseX | `MouseY | `Char | `BorderWidth
146 | | `SendEvent | `KeySymString | `KeySymInt | `RootWindow
147 | | `SubWindow | `Type | `Widget | `RootX | `RootY ]
148 |
149 | (** In order to access the above event information, one has to pass
150 | a list of required event fields to the [bind] function. *)
151 |
152 | val bind :
153 | events:event list ->
154 | ?extend:bool ->
155 | ?breakable:bool ->
156 | ?fields:eventField list ->
157 | ?action:(eventInfo -> unit) ->
158 | 'a Widget.widget -> unit
159 | (** Bind a succession of [events] on a widget to an [action].
160 | If [extend] is true then then binding is added after existing
161 | ones, otherwise it replaces them.
162 | [breakable] should be true when [break] is to be called inside
163 | the action.
164 | [action] is called with the [fields] required set in
165 | an [eventInfo] structure. Other fields should not be accessed.
166 | If [action] is omitted then existing bindings are removed. *)
167 |
168 | val bind_class :
169 | events:event list ->
170 | ?extend:bool ->
171 | ?breakable:bool ->
172 | ?fields:eventField list ->
173 | ?action:(eventInfo -> unit) ->
174 | ?on:'a Widget.widget ->
175 | string -> unit
176 | (** Same thing for all widgets of a given class. If a widget
177 | is given with label [~on:], the binding will be removed as
178 | soon as it is destroyed. *)
179 | val bind_tag :
180 | events:event list ->
181 | ?extend:bool ->
182 | ?breakable:bool ->
183 | ?fields:eventField list ->
184 | ?action:(eventInfo -> unit) ->
185 | ?on:'a Widget.widget ->
186 | string -> unit
187 | (** Same thing for all widgets having a given tag *)
188 |
189 | val break : unit -> unit
190 | (** Used inside a bound action, do not call other actions
191 | after this one. This is only possible if this action
192 | was bound with [~breakable:true]. *)
193 |
--------------------------------------------------------------------------------
/manual/macros.hva:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/macros.hva
--------------------------------------------------------------------------------
/manual/macros.tex:
--------------------------------------------------------------------------------
1 | \makeatletter
2 | % Pour hevea
3 | \newif\ifouthtml\outhtmlfalse
4 | \newcommand{\cutname}[1]{}
5 | % Notations pour les metavariables
6 | \def\var#1{{\it#1}}
7 | \def\nth#1#2{${\it#1}_{#2}$}
8 | \def\nmth#1#2#3{${\it#1}_{#2}^{#3}$}
9 | \def\optvar#1{\textrm{[}\var{#1}\/\textrm{]}}
10 | \def\event{$\bowtie$}
11 | \def\fromoneto#1#2{$#1 = 1, \ldots, #2$}
12 |
13 | % Pour avoir les exposants sur la ligne au-dessus (???)
14 |
15 | \ifplaintext
16 | \fontdimen14\tensy=12pt
17 | \fi
18 |
19 | % Numerotation
20 | \setcounter{secnumdepth}{2} % Pour numeroter les \subsection
21 | \setcounter{tocdepth}{1} % Pour ne pas mettre les \subsection
22 | % dans la table des matieres
23 |
24 | % Pour avoir "_" qui marche en mode math et en mode normal
25 | \catcode`\_=13
26 | \catcode`\=8
27 | \def\_{\hbox{\tt\char95}}
28 | \def_{\ifmmode\else\_\fi}
29 |
30 | \ifplaintext
31 | \def\ttstretch{\tt}
32 | \else
33 | \def\ttstretch{\tt\spaceskip=5.77pt plus 1.83pt minus 1.22pt}
34 | % La fonte cmr10 a normalement des espaces de 5.25pt non extensibles.
35 | % En 11 pt ca fait 5.77 pt. On lui ajoute la meme flexibilite que
36 | % cmr10 agrandie a 11 pt.
37 | \fi
38 |
39 | % Pour la traduction "xxxx" -> {\machine{xxxx}} faite par texquote2
40 | \def\machine#1{\mbox{\ttstretch{#1}}}
41 |
42 | % Pour la traduction "\begin{verbatim}...\end{verbatim}"
43 | % -> "\begin{machineenv}...\end{machineenv}"
44 | % faite aussi par texquote2.
45 | \newenvironment{machineenv}{\alltt}{\endalltt}
46 |
47 | % Environnements
48 |
49 | \newlength{\versionwidth}
50 | \setbox0=\hbox{\bf Windows:} \setlength{\versionwidth}{\wd0}
51 |
52 | \def\versionspecific#1{
53 | \begin{description}\item[#1:]~\\}
54 |
55 | \def\unix{\versionspecific{Unix}}
56 | \def\endunix{\end{description}}
57 | %\def\macos{\versionspecific{MacOS 9}}
58 | %\def\endmacos{\end{description}}
59 | \def\windows{\versionspecific{Windows}}
60 | \def\endwindows{\end{description}}
61 |
62 | \def\requirements{\trivlist \item[\hskip\labelsep {\bf Requirements.}]}
63 | \def\endrequirements{\endtrivlist}
64 | \def\installation{\trivlist \item[\hskip\labelsep {\bf Installation.}]}
65 | \def\endinstallation{\endtrivlist}
66 | \def\troubleshooting{\trivlist \item[\hskip\labelsep {\bf Troubleshooting.}]}
67 | \def\endtroubleshooting{\endtrivlist}
68 |
69 | \newtheorem{gcrule}{Rule}
70 |
71 | % Pour les tables de priorites et autres tableaux a deux colonnes, encadres
72 |
73 | \def\tableau#1#2#3{%
74 | \begin{center}
75 | \begin{tabular}{#1}
76 | \hline
77 | #2 & #3 \\
78 | \hline
79 | }
80 | \def\endtableau{\hline\end{tabular}\end{center}}
81 | \def\entree#1#2{#1 & #2 \\}
82 |
83 | % L'environnement option
84 |
85 | \def\optionitem[#1]{\if@noparitem \@donoparitem
86 | \else \if@inlabel \indent \par \fi
87 | \ifhmode \unskip\unskip \par \fi
88 | \if@newlist \if@nobreak \@nbitem \else
89 | \addpenalty\@beginparpenalty
90 | \addvspace\@topsep \addvspace{-\parskip}\fi
91 | \else \addpenalty\@itempenalty \addvspace\itemsep
92 | \fi
93 | \global\@inlabeltrue
94 | \fi
95 | \everypar{\global\@minipagefalse\global\@newlistfalse
96 | \if@inlabel\global\@inlabelfalse \hskip -\parindent \box\@labels
97 | \penalty\z@ \fi
98 | \everypar{}}\global\@nobreakfalse
99 | \if@noitemarg \@noitemargfalse \if@nmbrlist \refstepcounter{\@listctr}\fi \fi
100 | \setbox\@tempboxa\hbox{\makelabel{#1}}%
101 | \global\setbox\@labels
102 | \ifdim \wd\@tempboxa >\labelwidth
103 | \hbox{\unhbox\@labels
104 | \hskip -\leftmargin
105 | \box\@tempboxa}\hfil\break
106 | \else
107 | \hbox{\unhbox\@labels
108 | \hskip -\leftmargin
109 | \hbox to\leftmargin {\makelabel{#1}\hfil}}
110 | \fi
111 | \ignorespaces}
112 |
113 | \def\optionlabel#1{\bf #1}
114 | \def\options{\list{}{\let\makelabel\optionlabel\let\@item\optionitem}}
115 | \def\endoptions{\endlist}
116 |
117 | % L'environnement library (pour composer les descriptions des modules
118 | % de bibliotheque).
119 |
120 | \def\comment{\penalty200\list{}{}\item[]}
121 | \def\endcomment{\endlist\penalty-100}
122 |
123 | \def\library{
124 | \begingroup
125 | \raggedright
126 | \let\@savedlistI=\@listI%
127 | \def\@listI{\leftmargin\leftmargini\parsep 0pt plus 1pt\topsep 0pt plus 2pt}%
128 | \itemsep 0pt
129 | \topsep 0pt plus 2pt
130 | \partopsep 0pt
131 | }
132 |
133 | \def\endlibrary{
134 | \endgroup
135 | }
136 |
137 | \def\restoreindent{\begingroup\let\@listI=\@savedlistI}
138 | \def\endrestoreindent{\endgroup}
139 |
140 | % ^^A...^^A: compose l'interieur en \tt, comme \verb
141 |
142 | \catcode`\^^A=\active
143 | \def{%
144 | \begingroup\catcode``=13\@noligs\ttstretch\let\do\@makeother\dospecials%
145 | \def\@xobeysp{\leavevmode\penalty100\ }%
146 | \@vobeyspaces\frenchspacing\catcode`\^^A=\active\def{\endgroup}}
147 |
148 | % Pour l'index
149 |
150 | \let\indexentry=\index
151 | \def\index{\indexentry{\jobname}}
152 | \def\ikwd{\indexentry{\jobname.kwd}}
153 |
154 | % Les en-tetes personnalises
155 |
156 | \pagestyle{myheadings}
157 | \def\partmark#1{\markboth{Part \thepart. \ #1}{}}
158 | \def\chaptermark#1{\markright{Chapter \thechapter. \ #1}}
159 |
160 | % nth
161 |
162 | \def\th{^{\hbox{\scriptsize th}}}
163 |
164 | % Pour annuler l'espacement vertical qui suit un "verbatim"
165 | \def\cancelverbatim{\vspace{-\topsep}\vspace{-\parskip}}% exact.
166 |
167 | % Pour annuler l'espacement vertical entre deux \item consecutifs dans \options
168 | \def\cancelitemspace{\vspace{-8mm}}% determine empiriquement
169 |
170 | % Pour faire la cesure apres _ dans les identificateurs
171 | \def\={\discretionary{}{}{}}
172 | \def\cuthere{\discretionary{}{}{}}
173 |
174 | % Pour la coupure en petits documents
175 |
176 | \let\mysection=\section
177 |
178 | %%% Augmenter l'espace entre numero de section
179 | % et nom de section dans la table des matieres.
180 |
181 | \ifplaintext\else
182 | \def\l@section{\@dottedtocline{1}{1.5em}{2.8em}} % D'origine: 2.3
183 | \fi
184 |
185 | % Pour alltt
186 |
187 | \def\rminalltt#1{{\rm #1}}
188 |
189 | % redefinition de l'environnement alltt pour que les {} \ et % soient
190 | % dans la bonne fonte
191 |
192 | \let\@oldalltt=\alltt
193 | \let\@oldendalltt=\endalltt
194 | \renewenvironment{alltt}{%
195 | \begingroup%
196 | \renewcommand{\{}{\char`\{}%
197 | \renewcommand{\}}{\char`\}}%
198 | \renewcommand{\\}{\char`\\}%
199 | \renewcommand{\%}{\char`\%}%
200 | \@oldalltt%
201 | }{%
202 | \@oldendalltt%
203 | \endgroup%
204 | }
205 |
206 | % Index stuff -- cf multind.sty
207 |
208 | \def\printindex#1#2{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
209 | \columnseprule \z@ \columnsep 35pt
210 | \newpage \twocolumn[{\Large\bf #2 \vskip4ex}]
211 | \markright{\uppercase{#2}}
212 | \addcontentsline{toc}{section}{#2}
213 | \pdfsection{#2}
214 | \@input{#1.ind}}
215 |
216 | % PDF stuff -- no longer needed, Hyperref does the job
217 |
218 | \def\pdfchapterfold#1#2{}
219 | \def\pdfchapter#1{}
220 | \def\pdfsection#1{}
221 |
222 | %\ifpdf
223 | %\newcount\pdflabel
224 | %\pdflabel=1
225 | %\def\pdfchapterfold#1#2{
226 | %\pdfdest num \pdflabel fit
227 | %\pdfoutline goto num \pdflabel count #1 {\arabic{chapter}. #2}
228 | %\global\advance\pdflabel by 1
229 | %}
230 | %\def\pdfsection#1{
231 | %\pdfdest num \pdflabel fit
232 | %\pdfoutline goto num \pdflabel {#1}
233 | %\global\advance\pdflabel by 1
234 | %}
235 | %\else
236 | %\def\pdfchapterfold#1#2{}
237 | %\def\pdfsection#1{}
238 | %\fi
239 | %
240 | %\def\pdfchapter{\pdfchapterfold{0}}
241 |
242 | %%% Pour camlidl
243 |
244 | \def\transl#1{$[\![\mbox{#1}]\!]$}
245 |
246 | %%% Pour les references des modules
247 | \newcommand{\moduleref}[1]{\ref{#1}}
248 | %%% Fin des hacks
249 |
250 | \makeatother
251 |
252 | % Pour le chapitre ocamlbuild
253 | \newcommand{\mathscr}[1]{{\mathcal{#1}}}
254 | \newcommand{\ocb}{\texttt{ocamlbuild}\xspace}
255 | \newcommand{\tags}{\texttt{\_tags}\xspace}
256 |
--------------------------------------------------------------------------------
/manual/manual.hva:
--------------------------------------------------------------------------------
1 | \input{book.hva}
2 | \input{fancysection.hva}
3 | \input{macros.hva}
4 | \newif\ifouthtml\outhtmltrue
--------------------------------------------------------------------------------
/manual/manual.inf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/manual.inf
--------------------------------------------------------------------------------
/manual/manual.info.header:
--------------------------------------------------------------------------------
1 | INFO-DIR-SECTION OCaml Programming Language
2 | START-INFO-DIR-ENTRY
3 | * ocaml: (ocaml). OCaml Reference Manual
4 | END-INFO-DIR-ENTRY
5 |
--------------------------------------------------------------------------------
/manual/manual.tex:
--------------------------------------------------------------------------------
1 | \documentclass[11pt]{book}
2 | \usepackage[latin1]{inputenc}
3 | %HEVEA\@def@charset{US-ASCII}%
4 | \usepackage{alltt}
5 | \usepackage{fullpage}
6 | \usepackage{syntaxdef}
7 | \usepackage{multind}
8 | \usepackage{html}
9 | \usepackage{textcomp}
10 | \usepackage{caml-sl}
11 | \usepackage{ocamldoc}
12 | \usepackage{xspace}
13 | \newif\ifplaintext
14 | \plaintextfalse
15 | %\newif\ifpdf
16 | %\pdffalse
17 | \input{macros.tex}
18 |
19 | \usepackage{hyperref}
20 | %\makeatletter \def\@wrindex#1#2{\xdef \@indexfile{\csname #1@idxfile\endcsname}\@@wrindex#2||\\}\makeatother
21 | \def\th{^{\hbox{\scriptsize th}}}
22 |
23 | \raggedbottom
24 | \input{version.tex}
25 |
26 | %HEVEA\setcounter{cuttingdepth}{1}
27 | %HEVEA\title{The OCaml system, release \ocamlversion}
28 | \input{allfiles.tex}
29 |
30 |
31 |
--------------------------------------------------------------------------------
/manual/pdfmanual.tex:
--------------------------------------------------------------------------------
1 | %\pdfoutput=1
2 | \pdfpagewidth=21cm
3 | \pdfpageheight=11in
4 | \pdfcompresslevel=7
5 |
6 | \documentclass[11pt]{book}
7 |
8 | \usepackage[latin1]{inputenc}
9 | \usepackage{alltt}
10 | \usepackage{fullpage}
11 | \usepackage{syntaxdef}
12 | \usepackage{multind}
13 | \usepackage{html}
14 | \usepackage{textcomp}
15 | \usepackage{caml-sl}
16 | \usepackage{ocamldoc}
17 | \usepackage{xspace}
18 |
19 | \newif\ifplaintext
20 | \plaintextfalse
21 | %\newif\ifpdf
22 | %\pdftrue
23 | \input macros.tex
24 |
25 | \usepackage{hyperref}
26 | \def\th{^{\hbox{\scriptsize th}}}
27 |
28 | \raggedbottom
29 | \input{version.tex}
30 |
31 | \input allfiles.tex
32 |
--------------------------------------------------------------------------------
/manual/plaintext.tex:
--------------------------------------------------------------------------------
1 | \documentclass[11pt]{report}
2 |
3 | \usepackage{plaintext}
4 | \usepackage[latin1]{inputenc}
5 | \usepackage{alltt}
6 | \usepackage{fullpage}
7 | \usepackage{syntaxdef}
8 | \usepackage{multind}
9 | \usepackage{html}
10 | \usepackage{caml-sl}
11 |
12 | \newif\ifplaintext
13 | \plaintexttrue
14 | %\newif\ifpdf
15 | %\pdffalse
16 | \input macros.tex
17 | \input allfiles.tex
18 |
--------------------------------------------------------------------------------
/manual/refman/.cvsignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 |
--------------------------------------------------------------------------------
/manual/refman/.gitignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 |
--------------------------------------------------------------------------------
/manual/refman/Makefile:
--------------------------------------------------------------------------------
1 | FILES= refman.tex lex.tex names.tex values.tex const.tex types.tex \
2 | patterns.tex expr.tex typedecl.tex modtypes.tex modules.tex compunit.tex \
3 | exten.tex classes.tex
4 |
5 | TRANSF=../../tools/transf
6 | TEXQUOTE=../../tools/texquote2
7 |
8 | ALLFILES=$(FILES)
9 |
10 | all: $(ALLFILES)
11 |
12 | clean:
13 | rm -f $(ALLFILES)
14 |
15 | .SUFFIXES:
16 | .SUFFIXES: .etex .tex
17 |
18 | .etex.tex:
19 | $(TRANSF) < $*.etex | $(TEXQUOTE) > $*.tex
20 |
21 | $(ALLFILES): $(TRANSF) $(TEXQUOTE)
22 |
--------------------------------------------------------------------------------
/manual/refman/compunit.etex:
--------------------------------------------------------------------------------
1 | \section{Compilation units}
2 | \pdfsection{Compilation units}
3 | %HEVEA\cutname{compunit.html}
4 |
5 | \begin{syntax}
6 | unit-interface: { specification [';;'] }
7 | ;
8 | unit-implementation: [ module-items ]
9 | \end{syntax}
10 |
11 | Compilation units bridge the module system and the separate
12 | compilation system. A compilation unit is composed of two parts: an
13 | interface and an implementation. The interface contains a sequence of
14 | specifications, just as the inside of a @'sig' \ldots 'end'@
15 | signature expression. The implementation contains a sequence of
16 | definitions and expressions, just as the inside of a
17 | @'struct' \ldots 'end'@ module
18 | expression. A compilation unit also has a name @unit-name@, derived
19 | from the names of the files containing the interface and the
20 | implementation (see chapter~\ref{c:camlc} for more details). A
21 | compilation unit behaves roughly as the module definition
22 | \begin{center}
23 | @'module' unit-name ':' 'sig' unit-interface 'end' '='
24 | 'struct' unit-implementation 'end'@
25 | \end{center}
26 |
27 | A compilation unit can refer to other compilation units by their
28 | names, as if they were regular modules. For instance, if "U" is a
29 | compilation unit that defines a type "t", other compilation units can
30 | refer to that type under the name "U.t"; they can also refer to "U" as
31 | a whole structure. Except for names of other compilation units, a unit
32 | interface or unit implementation must not have any other free variables.
33 | In other terms, the type-checking and compilation of an interface or
34 | implementation proceeds in the initial environment
35 | \begin{center}
36 | @name_1 ':' 'sig' specification_1 'end' \ldots
37 | name_n ':' 'sig' specification_n 'end'@
38 | \end{center}
39 | where @name_1 \ldots name_n@ are the names of the other
40 | compilation units available in the search path (see
41 | chapter~\ref{c:camlc} for more details) and @specification_1 \ldots
42 | specification_n@ are their respective interfaces.
43 |
--------------------------------------------------------------------------------
/manual/refman/const.etex:
--------------------------------------------------------------------------------
1 | \section{Constants}
2 | \pdfsection{Constants}
3 | %HEVEA\cutname{const.html}
4 |
5 | \begin{syntax}
6 | constant:
7 | integer-literal
8 | | float-literal
9 | | char-literal
10 | | string-literal
11 | | constr
12 | | "false"
13 | | "true"
14 | | "("")"
15 | | "begin" "end"
16 | | "[""]"
17 | | "[|""|]"
18 | | "`"tag-name
19 | \end{syntax}
20 |
21 | The syntactic class of constants comprises literals from the four
22 | base types (integers, floating-point numbers, characters, character
23 | strings), and constant constructors from both normal and polymorphic
24 | variants, as well as the special constants @"false"@, @"true"@, @"("")"@,
25 | @"[""]"@, and @"[|""|]"@, which behave like constant constructors, and
26 | @"begin" "end"@, which is equivalent to @'('')'@.
27 |
--------------------------------------------------------------------------------
/manual/refman/directive.etex:
--------------------------------------------------------------------------------
1 | \section{Directives} \label{s:directives}
2 |
3 | \begin{syntax}
4 | directive:
5 | '#' 'open' string
6 | | '#' 'close' string
7 | | '#' ident string
8 | \end{syntax}
9 |
10 | Directives control the behavior of the compiler. They apply to the
11 | remainder of the current compilation unit.
12 |
13 | The two directives \verb"#open" and \verb"#close" modify the list of
14 | opened modules, that the compiler uses to complete unqualified
15 | identifiers, as described in section~\ref{s:names}. The directive
16 | @'#open' string@ adds the module whose name is given by the string
17 | constant @string@ to the list of opened modules, in first position.
18 | The directive @'#close' string@ removes the first occurrence of the
19 | module whose name is given by the string constant @string@ from the
20 | list of opened modules.
21 |
22 | Implementations can provide other directives, provided they follow the
23 | syntax @'#' ident string@, where @ident@ is the name of the directive,
24 | and the string constant @string@ is the argument to the directive. The
25 | behavior of these additional directives is implementation-dependent.
26 |
--------------------------------------------------------------------------------
/manual/refman/impl.etex:
--------------------------------------------------------------------------------
1 | \section{Module implementations}
2 |
3 | \begin{syntax}
4 | implementation:
5 | { impl-phrase ';;' }
6 | ;
7 | impl-phrase:
8 | expr
9 | | value-definition
10 | | type-definition
11 | | exception-definition
12 | | directive
13 | ;
14 | value-definition:
15 | 'let' ['rec'] let-binding { 'and' let-binding }
16 | \end{syntax}
17 |
18 | A module implementation consists in a sequence of implementation
19 | phrases, terminated by double semicolons. An implementation phrase is
20 | either an expression, a value definition, a type or exception
21 | definition, or a directive. At run-time, implementation phrases are
22 | evaluated sequentially, in the order in which they appear in the
23 | module implementation.
24 |
25 | Implementation phrases consisting in an expression are
26 | evaluated for their side-effects.
27 |
28 | Value definitions bind global value variables in the same way as a
29 | @'let' \ldots 'in' \ldots@ expression binds local variables. The
30 | expressions are evaluated, and their values are matched against the
31 | left-hand sides of the @'='@ sides, as explained in
32 | section~\ref{s:localdef}. If the matching succeeds, the bindings of
33 | identifiers to values performed during matching are interpreted as
34 | bindings to the global value variables whose local name is the
35 | identifier, and whose module name is the name of the module.
36 | If the matching fails, the exception \verb"Match_failure" is
37 | raised. The scope of these bindings is the phrases that follow the
38 | value definition in the module implementation.
39 |
40 | Type and exception definitions introduce type constructors, variant
41 | constructors and record fields as described in sections
42 | \ref{s:typdef}~and~\ref{s:excdef}.
43 | The scope of these definitions is the phrases that follow the value
44 | definition in the module implementation. The evaluation of an
45 | implementation phrase consisting in a type or exception definition
46 | produces no effect at run-time.
47 |
48 | Directives modify the behavior of the compiler on the subsequent
49 | phrases of the module implementation, as described in
50 | section~\ref{s:directives}. The evaluation of an implementation phrase
51 | consisting in a directive produces no effect at run-time. Directives
52 | apply only to the module currently being compiled; in particular, they
53 | have no effect on other modules that refer to globals exported by the
54 | module being compiled.
55 |
--------------------------------------------------------------------------------
/manual/refman/intf.etex:
--------------------------------------------------------------------------------
1 | \section{Module interfaces}
2 | \ikwd{value\@\texttt{value}}
3 | \ikwd{type\@\texttt{type}}
4 | \ikwd{exception\@\texttt{exception}}
5 |
6 | \begin{syntax}
7 | interface:
8 | { intf-phrase ';;' }
9 | ;
10 | intf-phrase:
11 | value-declaration
12 | | type-definition
13 | | exception-definition
14 | | directive
15 | ;
16 | value-declaration:
17 | 'value' ident ':' typexpr { 'and' ident ':' typexpr }
18 | \end{syntax}
19 |
20 | Module interfaces declare the global objects (value variables, type
21 | constructors, variant constructors, record fields) that a module
22 | exports, that is, makes available to other modules.
23 | Other modules can refer to these globals using qualified identifiers
24 | or the \verb"#open" directive, as explained in section~\ref{s:names}.
25 |
26 | A module interface consists in a sequence of interface
27 | phrases, terminated by double semicolons. An interface phrase is
28 | either a value declaration, a type definition, an exception
29 | definition, or a directive.
30 |
31 | Value declarations declare global value variables that are
32 | exported by the module implementation, and the types with which they are
33 | exported. The module implementation must define these variables, with
34 | types at least as general as the types declared in the interface. The
35 | scope of the bindings for these global variables extends from the
36 | module implementation itself to all modules that refer to those variables.
37 |
38 | Type or exception definitions introduce type constructors, variant
39 | constructors and record fields as described in sections
40 | \ref{s:typdef}~and~\ref{s:excdef}. Exception definitions and type
41 | definitions that are not abstract type declarations also take effect
42 | in the module implementation; that is, the type constructors, variant
43 | constructors and record fields they define are considered bound on
44 | entrance to the module implementation, and can be referred to by the
45 | implementation phrases. Type definitions that are not abstract type
46 | declarations must not be redefined in the module implementation. In
47 | contrast, the type constructors that are declared abstract in a module
48 | interface must be defined in the module implementation, with the same names.
49 |
50 | Directives modify the behavior of the compiler on the subsequent
51 | phrases of the module interface, as described in
52 | section~\ref{s:directives}. Directives apply only to the interface
53 | currently being compiled; in particular, they have no effect on other
54 | modules that refer to globals exported by the interface being
55 | compiled.
56 |
--------------------------------------------------------------------------------
/manual/refman/names.etex:
--------------------------------------------------------------------------------
1 | \section{Names} \label{s:names}
2 | \pdfsection{Names}
3 | %HEVEA\cutname{names.html}
4 |
5 | Identifiers are used to give names to several classes of language
6 | objects and refer to these objects by name later:
7 | \begin{itemize}
8 | \item value names (syntactic class @value-name@),
9 | \item value constructors and exception constructors (class @constr-name@),
10 | \item labels (@label-name@, defined in section~\ref{s:labelname}),
11 | \item polymorphic variant tags (@tag-name@),
12 | \item type constructors (@typeconstr-name@),
13 | \item record fields (@field-name@),
14 | \item class names (@class-name@),
15 | \item method names (@method-name@),
16 | \item instance variable names (@inst-var-name@),
17 | \item module names (@module-name@),
18 | \item module type names (@modtype-name@).
19 | \end{itemize}
20 | These eleven name spaces are distinguished both by the context and by the
21 | capitalization of the identifier: whether the first letter of the
22 | identifier is in lowercase (written @lowercase-ident@ below) or in
23 | uppercase (written @capitalized-ident@). Underscore is considered a
24 | lowercase letter for this purpose.
25 |
26 | \ikwd{false\@\texttt{false}}
27 | \ikwd{true\@\texttt{true}}
28 |
29 | \subsubsection*{Naming objects}
30 |
31 | \begin{syntax}
32 | value-name:
33 | lowercase-ident
34 | | '(' operator-name ')'
35 | ;
36 | operator-name:
37 | prefix-symbol || infix-op
38 | ;
39 | infix-op:
40 | infix-symbol
41 | | '*' || '+' || '-' || '-.' || '=' || '!=' || '<' || '>' || 'or' || '||'
42 | || '&' || '&&' || ':='
43 | | 'mod' || 'land' || 'lor' || 'lxor' || 'lsl' || 'lsr' || 'asr'
44 | ;
45 | constr-name:
46 | capitalized-ident
47 | ;
48 | tag-name:
49 | capitalized-ident
50 | ;
51 | typeconstr-name:
52 | lowercase-ident
53 | ;
54 | field-name:
55 | lowercase-ident
56 | ;
57 | module-name:
58 | capitalized-ident
59 | ;
60 | modtype-name:
61 | ident
62 | ;
63 | class-name:
64 | lowercase-ident
65 | ;
66 | inst-var-name:
67 | lowercase-ident
68 | ;
69 | method-name:
70 | lowercase-ident
71 | \end{syntax}
72 | As shown above, prefix and infix symbols as well as some keywords can
73 | be used as value names, provided they are written between parentheses.
74 | The capitalization rules are summarized in the table below.
75 |
76 | \begin{tableau}{|l|l|}{Name space}{Case of first letter}
77 | \entree{Values}{lowercase}
78 | \entree{Constructors}{uppercase}
79 | \entree{Labels}{lowercase}
80 | \entree{Polymorphic variant tags}{uppercase}
81 | \entree{Exceptions}{uppercase}
82 | \entree{Type constructors}{lowercase}
83 | \entree{Record fields}{lowercase}
84 | \entree{Classes}{lowercase}
85 | \entree{Instance variables}{lowercase}
86 | \entree{Methods}{lowercase}
87 | \entree{Modules}{uppercase}
88 | \entree{Module types}{any}
89 | \end{tableau}
90 |
91 | {\it Note on polymorphic variant tags:\/} the current implementation accepts
92 | lowercase variant tags in addition to capitalized variant tags, but we
93 | suggest you avoid lowercase variant tags for portability and
94 | compatibility with future OCaml versions.
95 |
96 | \subsubsection*{Referring to named objects}
97 |
98 | \begin{syntax}
99 | value-path:
100 | [ module-path '.' ] value-name
101 | ;
102 | constr:
103 | [ module-path '.' ] constr-name
104 | ;
105 | typeconstr:
106 | [ extended-module-path '.' ] typeconstr-name
107 | ;
108 | field:
109 | [ module-path '.' ] field-name
110 | ;
111 | modtype-path:
112 | [ extended-module-path '.' ] modtype-name
113 | ;
114 | class-path:
115 | [ module-path '.' ] class-name
116 | ;
117 | classtype-path:
118 | [ extended-module-path '.' ] class-name
119 | ;
120 | module-path:
121 | module-name { '.' module-name }
122 | ;
123 | extended-module-path:
124 | extended-module-name { '.' extended-module-name }
125 | ;
126 | extended-module-name:
127 | module-name { '(' extended-module-path ')' }
128 | \end{syntax}
129 |
130 | A named object can be referred to either by its name (following the
131 | usual static scoping rules for names) or by an access path @prefix '.' name@,
132 | where @prefix@ designates a module and @name@ is the name of an object
133 | defined in that module. The first component of the path, @prefix@, is
134 | either a simple module name or an access path @name_1 '.' name_2 \ldots@,
135 | in case the defining module is itself nested inside other modules.
136 | For referring to type constructors, module types, or class types,
137 | the @prefix@ can
138 | also contain simple functor applications (as in the syntactic class
139 | @extended-module-path@ above) in case the defining module is the
140 | result of a functor application.
141 |
142 | Label names, tag names, method names and instance variable names need
143 | not be qualified: the former three are global labels, while the latter
144 | are local to a class.
145 |
--------------------------------------------------------------------------------
/manual/refman/patterns.etex:
--------------------------------------------------------------------------------
1 | \section{Patterns}
2 | \pdfsection{Patterns}
3 | \ikwd{as\@\texttt{as}}
4 | %HEVEA\cutname{patterns.html}
5 | \begin{syntax}
6 | pattern:
7 | value-name
8 | | '_'
9 | | constant
10 | | pattern 'as' value-name
11 | | '(' pattern ')'
12 | | '(' pattern ':' typexpr ')'
13 | | pattern '|' pattern
14 | | constr pattern
15 | | "`"tag-name pattern
16 | | "#"typeconstr
17 | | pattern {{ ',' pattern }}
18 | | '{' field '=' pattern { ';' field '=' pattern } [ ';' ] '}'
19 | | '[' pattern { ';' pattern } [ ';' ] ']'
20 | | pattern '::' pattern
21 | | '[|' pattern { ';' pattern } [ ';' ] '|]'
22 | \end{syntax}
23 |
24 | The table below shows the relative precedences and associativity of
25 | operators and non-closed pattern constructions. The constructions with
26 | higher precedences come first.
27 | \ikwd{as\@\texttt{as}}
28 | \begin{tableau}{|l|l|}{Operator}{Associativity}
29 | \entree{".." (see section~\ref{s:range-patterns})}{--}
30 | \entree{"lazy" (see section~\ref{s:lazy})}{--}
31 | \entree{Constructor application, Tag application}{right}
32 | \entree{"::"}{right}
33 | \entree{","}{--}
34 | \entree{"|"}{left}
35 | \entree{"as"}{--}
36 | \end{tableau}
37 |
38 | Patterns are templates that allow selecting data structures of a
39 | given shape, and binding identifiers to components of the data
40 | structure. This selection operation is called pattern matching; its
41 | outcome is either ``this value does not match this pattern'', or
42 | ``this value matches this pattern, resulting in the following bindings
43 | of names to values''.
44 |
45 | \subsubsection*{Variable patterns}
46 |
47 | A pattern that consists in a value name matches any value,
48 | binding the name to the value. The pattern @"_"@ also matches
49 | any value, but does not bind any name.
50 |
51 | Patterns are {\em linear\/}: a variable cannot be bound several times by
52 | a given pattern. In particular, there is no way to test for equality
53 | between two parts of a data structure using only a pattern (but
54 | @"when"@ guards can be used for this purpose).
55 |
56 | \subsubsection*{Constant patterns}
57 |
58 | A pattern consisting in a constant matches the values that
59 | are equal to this constant.
60 |
61 | %% FIXME for negative numbers, blanks are allowed between the minus
62 | %% sign and the first digit.
63 |
64 | \subsubsection*{Alias patterns}
65 | \ikwd{as\@\texttt{as}}
66 |
67 | The pattern @pattern_1 "as" value-name@ matches the same values as
68 | @pattern_1@. If the matching against @pattern_1@ is successful,
69 | the name @value-name@ is bound to the matched value, in addition to the
70 | bindings performed by the matching against @pattern_1@.
71 |
72 | \subsubsection*{Parenthesized patterns}
73 |
74 | The pattern @"(" pattern_1 ")"@ matches the same values as
75 | @pattern_1@. A type constraint can appear in a
76 | parenthesized pattern, as in @"(" pattern_1 ":" typexpr ")"@. This
77 | constraint forces the type of @pattern_1@ to be compatible with
78 | @typexpr@.
79 |
80 | \subsubsection*{``Or'' patterns}
81 |
82 | The pattern @pattern_1 "|" pattern_2@ represents the logical ``or'' of
83 | the two patterns @pattern_1@ and @pattern_2@. A value matches
84 | @pattern_1 "|" pattern_2@ if it matches @pattern_1@ or
85 | @pattern_2@. The two sub-patterns @pattern_1@ and @pattern_2@
86 | must bind exactly the same identifiers to values having the same types.
87 | Matching is performed from left to right.
88 | More precisely,
89 | in case some value~$v$ matches @pattern_1 "|" pattern_2@, the bindings
90 | performed are those of @pattern_1@ when $v$ matches @pattern_1@.
91 | Otherwise, value~$v$ matches @pattern_2@ whose bindings are performed.
92 |
93 |
94 | \subsubsection*{Variant patterns}
95 |
96 | The pattern @constr '(' pattern_1 ',' \ldots ',' pattern_n ')'@ matches
97 | all variants whose
98 | constructor is equal to @constr@, and whose arguments match
99 | @pattern_1 \ldots pattern_n@. It is a type error if $n$ is not the
100 | number of arguments expected by the constructor.
101 |
102 | The pattern @constr '_'@ matches all variants whose constructor is
103 | @constr@.
104 |
105 | The pattern @pattern_1 "::" pattern_2@ matches non-empty lists whose
106 | heads match @pattern_1@, and whose tails match @pattern_2@.
107 |
108 | The pattern @"[" pattern_1 ";" \ldots ";" pattern_n "]"@ matches lists
109 | of length $n$ whose elements match @pattern_1@ \ldots @pattern_n@,
110 | respectively. This pattern behaves like
111 | @pattern_1 "::" \ldots "::" pattern_n "::" "[]"@.
112 |
113 | \subsubsection*{Polymorphic variant patterns}
114 |
115 | The pattern @"`"tag-name pattern_1@ matches all polymorphic variants
116 | whose tag is equal to @tag-name@, and whose argument matches
117 | @pattern_1@.
118 |
119 | \subsubsection*{Polymorphic variant abbreviation patterns}
120 |
121 | If the type @["('a,'b,"\ldots")"] typeconstr = "[" "`"tag-name_1 typexpr_1 "|"
122 | \ldots "|" "`"tag-name_n typexpr_n"]"@ is defined, then the pattern @"#"typeconstr@
123 | is a shorthand for the following or-pattern:
124 | @"(" "`"tag-name_1"(_" ":" typexpr_1")" "|" \ldots "|" "`"tag-name_n"(_"
125 | ":" typexpr_n"))"@. It matches all values of type @"[<" typeconstr "]"@.
126 |
127 | \subsubsection*{Tuple patterns}
128 |
129 | The pattern @pattern_1 "," \ldots "," pattern_n@ matches $n$-tuples
130 | whose components match the patterns @pattern_1@ through @pattern_n@. That
131 | is, the pattern matches the tuple values $(v_1, \ldots, v_n)$ such that
132 | @pattern_i@ matches $v_i$ for \fromoneto{i}{n}.
133 |
134 | \subsubsection*{Record patterns}
135 |
136 | The pattern @"{" field_1 "=" pattern_1 ";" \ldots ";" field_n "="
137 | pattern_n "}"@ matches records that define at least the fields
138 | @field_1@ through @field_n@, and such that the value associated to
139 | @field_i@ matches the pattern @pattern_i@, for \fromoneto{i}{n}.
140 | The record value can define more fields than @field_1@ \ldots
141 | @field_n@; the values associated to these extra fields are not taken
142 | into account for matching.
143 |
144 | \subsubsection*{Array patterns}
145 |
146 | The pattern @"[|" pattern_1 ";" \ldots ";" pattern_n "|]"@
147 | matches arrays of length $n$ such that the $i$-th array element
148 | matches the pattern @pattern_i@, for \fromoneto{i}{n}.
149 |
150 |
--------------------------------------------------------------------------------
/manual/refman/refman.etex:
--------------------------------------------------------------------------------
1 | \chapter{The OCaml language} \label{c:refman}
2 | \pdfchapterfold{-12}{Reference manual for the OCaml language}
3 | %HEVEA\cutname{language.html}
4 |
5 | %better html output that way, sniff.
6 | %HEVEA\subsection*{Foreword}
7 | %BEGIN LATEX
8 | \section*{Foreword}
9 | %END LATEX
10 |
11 | This document is intended as a reference manual for the OCaml
12 | language. It lists the language constructs, and gives their precise
13 | syntax and informal semantics. It is by no means a tutorial
14 | introduction to the language: there is not a single example. A good
15 | working knowledge of OCaml is assumed.
16 |
17 | No attempt has been made at mathematical rigor: words are employed
18 | with their intuitive meaning, without further definition. As a
19 | consequence, the typing rules have been left out, by lack of the
20 | mathematical framework required to express them, while they are
21 | definitely part of a full formal definition of the language.
22 |
23 |
24 | \subsection*{Notations}
25 |
26 | The syntax of the language is given in BNF-like notation. Terminal
27 | symbols are set in typewriter font (@'like' 'this'@).
28 | Non-terminal symbols are set in italic font (@like that@).
29 | Square brackets @[\ldots]@ denote optional components. Curly brackets
30 | @{\ldots}@ denotes zero, one or several repetitions of the enclosed
31 | components. Curly brackets with a trailing plus sign @{{\ldots}}@
32 | denote one or several repetitions of the enclosed components.
33 | Parentheses @(\ldots)@ denote grouping.
34 |
35 | %HEVEA\cutdef{section}
36 | \input{lex}
37 | \input{values}
38 | \input{names}
39 | \input{types}
40 | \input{const}
41 | \input{patterns}
42 | \input{expr}
43 | \input{typedecl}
44 | \input{classes}
45 | \input{modtypes}
46 | \input{modules}
47 | \input{compunit}
48 | %HEVEA\cutend
49 |
--------------------------------------------------------------------------------
/manual/refman/values.etex:
--------------------------------------------------------------------------------
1 | \section{Values}
2 | \pdfsection{Values}
3 | %HEVEA\cutname{values.html}
4 |
5 | This section describes the kinds of values that are manipulated by
6 | OCaml programs.
7 |
8 | \subsection{Base values}
9 |
10 | \subsubsection*{Integer numbers}
11 |
12 | Integer values are integer numbers from $-2^{30}$ to $2^{30}-1$, that
13 | is $-1073741824$ to $1073741823$. The implementation may support a
14 | wider range of integer values: on 64-bit platforms, the current
15 | implementation supports integers ranging from $-2^{62}$ to $2^{62}-1$.
16 |
17 | \subsubsection*{Floating-point numbers}
18 |
19 | Floating-point values are numbers in floating-point representation.
20 | The current implementation uses double-precision floating-point
21 | numbers conforming to the IEEE 754 standard, with 53 bits of mantissa
22 | and an exponent ranging from $-1022$ to $1023$.
23 |
24 | \subsubsection*{Characters}
25 |
26 | Character values are represented as 8-bit integers between 0 and 255.
27 | Character codes between 0 and 127 are interpreted following the ASCII
28 | standard. The current implementation interprets character codes
29 | between 128 and 255 following the ISO 8859-1 standard.
30 |
31 | \subsubsection*{Character strings} \label{s:string-val}
32 |
33 | String values are finite sequences of characters. The current
34 | implementation supports strings containing up to $2^{24} - 5$
35 | characters (16777211 characters); on 64-bit platforms, the limit is
36 | $2^{57} - 9$.
37 |
38 | \subsection{Tuples}
39 |
40 | Tuples of values are written @'('@v@_1',' \ldots',' @v@_n')'@, standing for the
41 | $n$-tuple of values @@v@_1@ to @@v@_n@. The current implementation
42 | supports tuple of up to $2^{22} - 1$ elements (4194303 elements).
43 |
44 | \subsection{Records}
45 |
46 | Record values are labeled tuples of values. The record value written
47 | @'{' field_1 '=' @v@_1';' \ldots';' field_n '=' @v@_n '}'@ associates the value
48 | @@v@_i@ to the record field @field_i@, for $i = 1 \ldots n$. The current
49 | implementation supports records with up to $2^{22} - 1$ fields
50 | (4194303 fields).
51 |
52 | \subsection{Arrays}
53 |
54 | Arrays are finite, variable-sized sequences of values of the same
55 | type. The current implementation supports arrays containing up to
56 | $2^{22} - 1$ elements (4194303 elements) unless the elements are
57 | floating-point numbers (2097151 elements in this case); on 64-bit
58 | platforms, the limit is $2^{54} - 1$ for all arrays.
59 |
60 | \subsection{Variant values}
61 |
62 | Variant values are either a constant constructor, or a non-constant
63 | constructor applied to a number of values. The former case is written
64 | @constr@; the latter case is written @constr '('@v@_1',' ... ',' @v@_n
65 | ')'@, where the @@v@_i@ are said to be the arguments of the non-constant
66 | constructor @constr@. The parentheses may be omitted if there is only
67 | one argument.
68 |
69 | The following constants are treated like built-in constant
70 | constructors:
71 | \begin{tableau}{|l|l|}{Constant}{Constructor}
72 | \entree{"false"}{the boolean false}
73 | \entree{"true"}{the boolean true}
74 | \entree{"()"}{the ``unit'' value}
75 | \entree{"[]"}{the empty list}
76 | \end{tableau}
77 |
78 | The current implementation limits each variant type to have at most
79 | 246 non-constant constructors and $2^{30}-1$ constant constructors.
80 |
81 | \subsection{Polymorphic variants}
82 |
83 | Polymorphic variants are an alternate form of variant values, not
84 | belonging explicitly to a predefined variant type, and following
85 | specific typing rules. They can be either constant, written
86 | @"`"tag-name@, or non-constant, written @"`"tag-name'('@v@')'@.
87 |
88 | \subsection{Functions}
89 |
90 | Functional values are mappings from values to values.
91 |
92 | \subsection{Objects}
93 |
94 | Objects are composed of a hidden internal state which is a
95 | record of instance variables, and a set of methods for accessing and
96 | modifying these variables. The structure of an object is described by
97 | the toplevel class that created it.
98 |
--------------------------------------------------------------------------------
/manual/style.css:
--------------------------------------------------------------------------------
1 | a:visited {color : #416DFF; text-decoration : none; }
2 | a:link {color : #416DFF; text-decoration : none;}
3 | a:hover {color : Red; text-decoration : none; background-color: #5FFF88}
4 | a:active {color : Red; text-decoration : underline; }
5 | .keyword { font-weight : bold ; color : Red }
6 | .keywordsign { color : #C04600 }
7 | .superscript { font-size : 4 }
8 | .subscript { font-size : 4 }
9 | .comment { color : Green }
10 | .constructor { color : Blue }
11 | .type { color : #5C6585 }
12 | .string { color : Maroon }
13 | .warning { color : Red ; font-weight : bold }
14 | .info { margin-left : 3em; margin-right : 3em }
15 | .code { color : #465F91 ; }
16 | h1 { font-size : 20pt ; text-align: center; }
17 | h2 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90BDFF ;padding: 2px; }
18 | h3 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90DDFF ;padding: 2px; }
19 | h4 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90EDFF ;padding: 2px; }
20 | h5 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90FDFF ;padding: 2px; }
21 | h6 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90BDFF ; padding: 2px; }
22 | div.h7 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #90DDFF ; padding: 2px; }
23 | div.h8 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #F0FFFF ; padding: 2px; }
24 | div.h9 { font-size : 20pt ; border: 1px solid #000000; margin-top: 5px; margin-bottom: 2px;text-align: center; background-color: #FFFFFF ; padding: 2px; }
25 | .typetable { border-style : hidden }
26 | .indextable { border-style : hidden }
27 | .paramstable { border-style : hidden ; padding: 5pt 5pt}
28 | body { background-color : White }
29 | tr { background-color : White }
30 | td.typefieldcomment { background-color : #FFFFFF }
31 | pre { margin-bottom: 4px }
32 | div.sig_block {margin-left: 2em}
--------------------------------------------------------------------------------
/manual/texstuff/.cvsignore:
--------------------------------------------------------------------------------
1 | *.aux
2 | *.dvi
3 | *.idx
4 | *.ilg
5 | *.ind
6 | *.log
7 | *.toc
8 | *.ipr
9 | *.txt
10 | *.pdf
11 | *.ps
12 | pdfmanual.out
13 | manual.out
14 |
--------------------------------------------------------------------------------
/manual/texstuff/.gitignore:
--------------------------------------------------------------------------------
1 | *.aux
2 | *.dvi
3 | *.idx
4 | *.ilg
5 | *.ind
6 | *.log
7 | *.toc
8 | *.ipr
9 | *.txt
10 | *.pdf
11 | *.ps
12 | pdfmanual.out
13 | manual.out
14 |
--------------------------------------------------------------------------------
/manual/textman/.cvsignore:
--------------------------------------------------------------------------------
1 | manual.txt
2 | manual.hmanual.kwd
3 | *.haux
4 | *.hind
5 | *.htoc
6 |
--------------------------------------------------------------------------------
/manual/textman/.gitignore:
--------------------------------------------------------------------------------
1 | manual.txt
2 | manual.hmanual.kwd
3 | *.haux
4 | *.hind
5 | *.htoc
6 |
--------------------------------------------------------------------------------
/manual/tutorials/.cvsignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 |
--------------------------------------------------------------------------------
/manual/tutorials/.gitignore:
--------------------------------------------------------------------------------
1 | *.tex
2 | *.htex
3 |
--------------------------------------------------------------------------------
/manual/tutorials/Makefile:
--------------------------------------------------------------------------------
1 | FILES= coreexamples.tex lablexamples.tex objectexamples.tex moduleexamples.tex advexamples.tex
2 |
3 | CAMLLATEX=../../tools/caml-tex2
4 | TEXQUOTE=../../tools/texquote2
5 |
6 | ALLFILES=$(FILES)
7 |
8 | all: $(ALLFILES)
9 |
10 | clean:
11 | rm -f $(ALLFILES)
12 |
13 | .SUFFIXES:
14 | .SUFFIXES: .etex .tex
15 |
16 | .etex.tex:
17 | $(CAMLLATEX) -n 80 -o - $*.etex | $(TEXQUOTE) > $*.tex
18 |
19 | $(ALLFILES): $(CAMLLATEX) $(TEXQUOTE)
20 |
--------------------------------------------------------------------------------
/manual/tutorials/advexamples.etex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/tutorials/advexamples.etex
--------------------------------------------------------------------------------
/manual/tutorials/objectexamples.etex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/manual/tutorials/objectexamples.etex
--------------------------------------------------------------------------------
/styles/altindex.sty:
--------------------------------------------------------------------------------
1 | %% An attempt to have several index files
2 | %%
3 | %% Defines \altindex{filename}{word to index}
4 | %% and \makealtindex{filename}
5 | %%
6 | %% It is possible to define a macro for each index as follows:
7 | %% \newcommand{\myindex}{\altindex{myindexfile}}
8 | %%
9 | %% This code is not really clean, there are still a number of things
10 | %% that I don't understand... but it works.
11 |
12 | %% \makealtindex{filename} opens filename.idx for writing.
13 |
14 | \def\makealtindex#1{\if@filesw
15 | \expandafter\newwrite\csname @#1altindexfile\endcsname
16 | \immediate\openout\expandafter\csname @#1altindexfile\endcsname=#1.idx
17 | \typeout{Writing alternate index file #1.idx}\fi}
18 |
19 | %% \@wraltindex makes the assumes that a trailing `\fi' will get bound
20 | %% to #2. So, it `eats' it as second parameter and reinserts it.
21 | %% Quick and dirty, I know...
22 | %% Writes the index entry #3 into #1.
23 |
24 | \def\@wraltindex#1#2#3{\let\thepage\relax
25 | \xdef\@gtempa{\write#1{\string
26 | \indexentry{#3}{\thepage}}}\fi\endgroup\@gtempa
27 | \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
28 |
29 | %% \altindex{filename}{index entry} does nothing if
30 | %% \@altindexfile is \relax (i.e. filename.idx not open).
31 | %% Otherwise, writes the index entry, and closes the whole stuff (some
32 | %% groups, and some \if).
33 |
34 | \def\altindex#1{\@bsphack\begingroup
35 | \def\protect##1{\string##1\space}\@sanitize
36 | \@ifundefined{@#1altindexfile}%
37 | {\endgroup\@esphack}%
38 | {\@wraltindex{\expandafter\csname @#1altindexfile\endcsname}}
39 | }
40 |
--------------------------------------------------------------------------------
/styles/caml-sl.sty:
--------------------------------------------------------------------------------
1 | % CAML style option, for use with the caml-latex filter.
2 |
3 | \typeout{Document Style option `caml-sl' <7 Apr 92>.}
4 |
5 | {\catcode`\^^M=\active %
6 | \gdef\@camlinputline#1^^M{\normalsize\tt\# #1\par} %
7 | \gdef\@camloutputline#1^^M{\small\ttfamily\slshape#1\par} } %
8 | \def\@camlblankline{\medskip}
9 | \chardef\@camlbackslash="5C
10 | \def\@bunderline{\setbox0\hbox\bgroup\let\par\@parinunderline}
11 |
12 | \def \@parinunderline {\futurelet \@next \@@parinunderline}
13 | \def \@@parinunderline {\ifx \@next \? \let \@do \@@par@inunderline \else \let \@do \@@@parinunderline \fi \@do}
14 | \def \@@par@inunderline #1{\@eunderline\@oldpar\?\@bunderline}
15 | \def \@@@parinunderline {\@eunderline\@oldpar\@bunderline}
16 | \def\@eunderline{\egroup\underline{\box0}}
17 | \def\@camlnoop{}
18 |
19 | \def\caml{
20 | \bgroup
21 | \flushleft
22 | \parindent 0pt
23 | \parskip 0pt
24 | \let\do\@makeother\dospecials
25 | \catcode13=\active % 13 = ^M = CR
26 | \catcode92=0 % 92 = \
27 | \catcode32=\active % 32 = SPC
28 | \frenchspacing
29 | \@vobeyspaces
30 | \let\@oldpar\par
31 | \let\?\@camlinputline
32 | \let\:\@camloutputline
33 | \let\;\@camlblankline
34 | \let\<\@bunderline
35 | \let\>\@eunderline
36 | \let\\\@camlbackslash
37 | \let\-\@camlnoop
38 | }
39 |
40 | \def\endcaml{
41 | \endflushleft
42 | \egroup\noindent
43 | }
44 |
--------------------------------------------------------------------------------
/styles/caml.sty:
--------------------------------------------------------------------------------
1 | % CAML style option, for use with the caml-latex filter.
2 |
3 | \typeout{Document Style option `caml' <7 Apr 92>.}
4 |
5 | {\catcode`\^^M=\active %
6 | \gdef\@camlinputline#1^^M{\tt\##1\par} %
7 | \gdef\@camloutputline#1^^M{\tt#1\par} } %
8 | \def\@camlblankline{\medskip}
9 | \chardef\@camlbackslash="5C
10 |
11 | \def\caml{
12 | \bgroup
13 | \flushleft
14 | \parindent 0pt
15 | \parskip 0pt
16 | \let\do\@makeother\dospecials
17 | \catcode`\^^M=\active
18 | \catcode`\\=0
19 | \catcode`\ \active
20 | \frenchspacing
21 | \@vobeyspaces
22 | \let\?\@camlinputline
23 | \let\:\@camloutputline
24 | \let\;\@camlblankline
25 | \let\\\@camlbackslash
26 | }
27 |
28 | \def\endcaml{
29 | \endflushleft
30 | \egroup\noindent
31 | }
32 |
--------------------------------------------------------------------------------
/styles/doc.tfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/styles/doc.tfm
--------------------------------------------------------------------------------
/styles/docbf.tfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/styles/docbf.tfm
--------------------------------------------------------------------------------
/styles/docit.tfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/styles/docit.tfm
--------------------------------------------------------------------------------
/styles/docmi.tfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/styles/docmi.tfm
--------------------------------------------------------------------------------
/styles/docrm.tfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/styles/docrm.tfm
--------------------------------------------------------------------------------
/styles/doctt.tfm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/styles/doctt.tfm
--------------------------------------------------------------------------------
/styles/fullpage.sty:
--------------------------------------------------------------------------------
1 | \marginparwidth 0pt \oddsidemargin 0pt \evensidemargin 0pt \marginparsep 0pt
2 | \topmargin 0pt \textwidth 6.5in \textheight 8.5 in
3 |
--------------------------------------------------------------------------------
/styles/isolatin.sty:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ocaml/ocaml-manual/e8c2daf53b7e72bb34e9f1b534853c004e66903b/styles/isolatin.sty
--------------------------------------------------------------------------------
/styles/multicols.sty:
--------------------------------------------------------------------------------
1 | % Save file as: MULTICOLS.STY Source: FILESERV@SHSU.BITNET
2 | % multicols.sty version 1.0
3 | % Allows for multiple column typesetting
4 | % From TUGboat, voulme 10 (1989), No. 3
5 | %
6 | % Frank Mittelback
7 | % Electronic Data Systems
8 | % (Deutschland) GmbH
9 | % Eisenstrasse 56
10 | % D-6090 Russelsheim
11 | % Federal Republic of Germany
12 | % Bitnet: pzf5hz@drueds2
13 | %
14 | % Variables:
15 | % \premulticols - If the space left on the page is less than this, a new
16 | % page is started before the multiple columns. Otherwise, a \vskip
17 | % of \multicolsep is added.
18 | % \postmulticols - analogous to \premulticols
19 | % \columnseprule - the width of the rule separating the columns.
20 | %
21 | % Commands:
22 | % \raggedcolumns - don't align bottom lines of columns
23 | % \flushcolumns - align bottom lines (default)
24 | %
25 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
26 | \@ifundefined{mult@cols}{}{\endinput}
27 |
28 | \def\multicols#1{\col@number#1\relax
29 | \ifnum\col@number<\@ne
30 | \@warning{Using '\number\col@number' columns doesn't seem a good idea.^^J
31 | I therefore use two columns instead}%
32 | \col@number\tw@ \fi
33 | \@ifnextchar[\mult@cols{\mult@cols[]}}
34 |
35 | \def\mult@cols[#1]{\@ifnextchar[%
36 | {\mult@@cols{#1}}%
37 | {\mult@@cols{#1}[\premulticols]}}
38 |
39 | \def\mult@@cols#1[#2]{%
40 | \enough@room#2%
41 | #1\par\addvspace\multicolsep
42 | \begingroup
43 | \prepare@multicols\ignorespaces}
44 |
45 | \def\enough@room#1{\par \penalty\z@
46 | \page@free \pagegoal
47 | \advance \page@free -\pagetotal
48 | \ifdim \page@free <#1\newpage \fi}
49 |
50 | \def\prepare@multicols{%
51 | \output{\global\setbox\partial@page
52 | \vbox{\unvbox\@cclv}}\eject
53 | \vbadness9999 \hbadness5000
54 | \tolerance\multicoltolerance
55 | \doublecol@number\col@number
56 | \multiply\doublecol@number\tw@
57 | \advance\baselineskip\multicolbaselineskip
58 | \advance\@colroom-\ht\partial@page
59 | \vsize\col@number\@colroom
60 | \advance\vsize\c@collectmore\baselineskip
61 | \hsize\columnwidth \advance\hsize\columnsep
62 | \advance\hsize-\col@number\columnsep
63 | \divide\hsize\col@number
64 | \linewidth\hsize
65 | \output{\multi@columnout}%
66 | \multiply\count\footins\col@number
67 | \multiply\skip \footins\col@number
68 | \reinsert@footnotes}
69 |
70 | \def\endmulticols{\par\penalty\z@
71 | \output{\balance@columns}\eject
72 | \endgroup \reinsert@footnotes
73 | \global\c@unbalance\z@
74 | \enough@room\postmulticols
75 | \addvspace\multicolsep}
76 |
77 | \newcount\c@unbalance \c@unbalance = 0
78 | \newcount\c@collectmore \c@collectmore = 0
79 | \newcount\col@number
80 | \newcount\doublecol@number
81 | \newcount\multicoltolerance \multicoltolerance = 9999
82 | \newdimen\page@free
83 | \newdimen\premulticols \premulticols = 50pt
84 | \newdimen\postmulticols \postmulticols = 20pt
85 | \newskip\multicolsep \multicolsep = 12pt plus 4pt minus 3pt
86 | \newskip\multicolbaselineskip \multicolbaselineskip=0pt
87 | \newbox\partial@page
88 |
89 | \def\process@cols#1#2{\count@#1\relax
90 | \loop #2%
91 | \advance\count@\tw@
92 | \ifnum\count@<\doublecol@number
93 | \repeat}
94 |
95 | \def\page@sofar{\unvbox\partial@page
96 | \process@cols\z@{\wd\count@\hsize}%
97 | \hbox to\textwidth{%
98 | \process@cols\tw@{\box\count@
99 | \hss\vrule\@width\columnseprule\hss}%
100 | \box\z@}}
101 |
102 | \def\reinsert@footnotes{\ifvoid\footins\else
103 | \insert\footins{\unvbox\footins}\fi}
104 |
105 | \def\multi@columnout{%
106 | \ifnum\outputpenalty <-\@Mi
107 | \speci@ls \else
108 | \splittopskip\topskip
109 | \splitmaxdepth\maxdepth
110 | \dimen@\@colroom
111 | \divide\skip\footins\col@number
112 | \ifvoid\footins \else
113 | \advance\dimen@-\skip\footins
114 | \advance\dimen@-\ht\footins \fi
115 | \process@cols\tw@{\setbox\count@
116 | \vsplit\@cclv to\dimen@}%
117 | \setbox\z@\vsplit\@cclv to\dimen@
118 | \ifvoid\@cclv \else
119 | \unvbox\@cclv
120 | \penalty\outputpenalty
121 | \fi
122 | \setbox\@cclv\vbox{\page@sofar}%
123 | \@makecol\@outputpage
124 | \global\@colroom\@colht
125 | \process@deferreds
126 | \global\vsize\col@number\@colroom
127 | \global\advance\vsize
128 | \c@collectmore\baselineskip
129 | \multiply\skip\footins\col@number\fi}
130 |
131 | \def\speci@ls{%
132 | \typeout{floats and marginpars not allowed inside `multicols' environment}%
133 | \unvbox\@cclv\reinsert@footnotes
134 | \gdef\@currlist{}}
135 |
136 | \def\process@deferreds{%
137 | \@floatplacement
138 | \begingroup
139 | \let\@tempb\@deferlist
140 | \gdef\@deferlist{}%
141 | \let\@elt\@scolelt
142 | \@tempb \endgroup}
143 |
144 | \newif\ifshr@nking
145 |
146 | \def\raggedcolumns{%
147 | \@bsphack\shr@nkingtrue\@esphack}
148 | \def\flushcolumns{%
149 | \@bsphack\shr@nkingfale\@esphack}
150 |
151 | \def\balance@columns{%
152 | \splittopskip\topskip
153 | \splitmaxdepth\maxdepth
154 | \setbox\z@\vbox{\unvbox\@cclv}\dimen@\ht\z@
155 | \advance\dimen@\col@number\topskip
156 | \advance\dimen@-\col@number\baselineskip
157 | \divide\dimen@\col@number
158 | \advance\dimen@\c@unbalance\baselineskip
159 | {\vbadness\@M \loop
160 | {\process@cols\@ne{\global\setbox\count@\box\voidb@x}}%
161 | \global\setbox\@ne\copy\z@
162 | {\process@cols\thr@@{\global\setbox\count@\vsplit\@ne to\dimen@}}%
163 | \ifshr@nking \global\setbox\thr@@\vbox{\unvbox\thr@@}%
164 | \fi
165 | \ifdim\ht\@ne >\ht\thr@@
166 | \global\advance\dimen@\p@
167 | \repeat}%
168 | \dimen@\ht\thr@@
169 | \process@cols\z@{\@tempcnta\count@
170 | \advance\@tempcnta\@ne
171 | \setbox\count@\vtop to\dimen@
172 | {\unvbox\@tempcnta
173 | \ifshr@nking\vfill\fi}}%
174 | \global\vsize\@colroom
175 | \global\advance\vsize\ht\partial@page
176 | \page@sofar}
177 |
--------------------------------------------------------------------------------
/styles/multind.sty:
--------------------------------------------------------------------------------
1 | % indexes document style option for producing multiple indexes
2 | % for use with the modified bbok style, CHbook.sty
3 | % Written by F.W. Long, Version 1.1, 12 August 1991.
4 |
5 | % Modified by F.W. Long, Version 1.1a, 29 August 1991
6 | % to get the index heading correctly spaced.
7 |
8 | % Modified by F.W. Long, Version 1.1b, 31 August 1991
9 | % to remove the abbreviation \ix (which should be in the document, not here).
10 |
11 | % Modified \makeindex and \index commands to allow multiple indexes
12 | % in both cases the first parameter is the index name.
13 | % They now work more like \@starttoc and \addcontentsline.
14 | % \index is no longer defined inside \makeindex but determines
15 | % whether the appropriate file is defined before writing to it.
16 |
17 | \def\makeindex#1{\begingroup
18 | \makeatletter
19 | \if@filesw \expandafter\newwrite\csname #1@idxfile\endcsname
20 | \expandafter\immediate\openout \csname #1@idxfile\endcsname #1.idx\relax
21 | \typeout{Writing index file #1.idx }\fi \endgroup}
22 |
23 | \def\index#1{\@bsphack\begingroup
24 | \def\protect##1{\string##1\space}\@sanitize
25 | \@wrindex{#1}}
26 |
27 | % \@wrindex now checks that the appropriate file is defined.
28 |
29 | \def\@wrindex#1#2{\let\thepage\relax
30 | \xdef\@gtempa{\@ifundefined{#1@idxfile}{}{\expandafter
31 | \write\csname #1@idxfile\endcsname{\string
32 | \indexentry{#2}{\thepage}}}}\endgroup\@gtempa
33 | \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
34 |
35 | % Modified \printindex command to allow multiple indexes.
36 | % This now takes over much of the work of \theindex.
37 | % Again, the first parameter is the index name.
38 | % The second parameter is the index title (as printed).
39 |
40 | \newif\if@restonecol
41 | \def\printindex#1#2{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
42 | \columnseprule \z@ \columnsep 35pt
43 | \newpage \twocolumn[{\Large\bf #2 \vskip4ex}]
44 | \markright{\uppercase{#2}}
45 | \addcontentsline{toc}{section}{#2}
46 | \@input{#1.ind}}
47 |
48 | % The following index commands are taken from book.sty.
49 | % \theindex is modified to not start a chapter.
50 |
51 | \def\theindex{\parindent\z@
52 | \parskip\z@ plus .3pt\relax\let\item\@idxitem}
53 | \def\@idxitem{\par\hangindent 40pt}
54 | \def\subitem{\par\hangindent 40pt \hspace*{20pt}}
55 | \def\subsubitem{\par\hangindent 40pt \hspace*{30pt}}
56 | \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
57 | \def\indexspace{\par \vskip 10pt plus 5pt minus 3pt\relax}
58 |
59 | % the command \ix allows an abbreviation for the general index
60 |
61 | %\def\ix#1{#1\index{general}{#1}}
62 |
63 | % define the \see command from makeidx.sty
64 |
65 | \def\see#1#2{{\em see\/} #1}
66 |
--------------------------------------------------------------------------------
/styles/ocamldoc.hva:
--------------------------------------------------------------------------------
1 | \usepackage{alltt}
2 | \newenvironment{ocamldoccode}{\begin{alltt}}{\end{alltt}}
3 | \newenvironment{ocamldocdescription}{\begin{quote}}{\end{quote}}
4 | \newenvironment{ocamldoccomment}{\begin{quote}}{\end{quote}}
5 |
6 |
7 | \newenvironment{ocamldocindent}{\list{}{}\item\relax}{\endlist}
8 | \newenvironment{ocamldocsigend}
9 | {\noindent\quad\texttt{sig}\ocamldocindent}
10 | {\endocamldocindent
11 | \noindent\quad\texttt{end}\medskip}
12 | \newenvironment{ocamldocobjectend}
13 | {\noindent\quad\texttt{object}\ocamldocindent}
14 | {\endocamldocindent
15 | \noindent\quad\texttt{end}\medskip}
16 |
17 | \newcommand{\moduleref}[1]{\ifhtml\ahref{libref/#1.html}{\texttt{#1}}\fi}
18 |
19 | # For processing .tex generated by ocamldoc (for text manual)
20 | \newcommand{\ocamldocvspace}[1]{\vspace{#1}}
--------------------------------------------------------------------------------
/styles/ocamldoc.sty:
--------------------------------------------------------------------------------
1 |
2 | %% Support macros for LaTeX documentation generated by ocamldoc.
3 | %% This file is in the public domain; do what you want with it.
4 |
5 | \NeedsTeXFormat{LaTeX2e}
6 | \ProvidesPackage{ocamldoc}
7 | [2001/12/04 v1.0 ocamldoc support]
8 |
9 | \newenvironment{ocamldoccode}{%
10 | \bgroup
11 | \leftskip\@totalleftmargin
12 | \rightskip\z@skip
13 | \parindent\z@
14 | \parfillskip\@flushglue
15 | \parskip\z@skip
16 | %\noindent
17 | \@@par\smallskip
18 | \@tempswafalse
19 | \def\par{%
20 | \if@tempswa
21 | \leavevmode\null\@@par\penalty\interlinepenalty
22 | \else
23 | \@tempswatrue
24 | \ifhmode\@@par\penalty\interlinepenalty\fi
25 | \fi}
26 | \obeylines
27 | \verbatim@font
28 | \let\org@prime~%
29 | \@noligs
30 | \let\org@dospecials\dospecials
31 | \g@remfrom@specials{\\}
32 | \g@remfrom@specials{\{}
33 | \g@remfrom@specials{\}}
34 | \let\do\@makeother
35 | \dospecials
36 | \let\dospecials\org@dospecials
37 | \frenchspacing\@vobeyspaces
38 | \everypar \expandafter{\the\everypar \unpenalty}}
39 | {\egroup\par}
40 |
41 | \def\g@remfrom@specials#1{%
42 | \def\@new@specials{}
43 | \def\@remove##1{%
44 | \ifx##1#1\else
45 | \g@addto@macro\@new@specials{\do ##1}\fi}
46 | \let\do\@remove\dospecials
47 | \let\dospecials\@new@specials
48 | }
49 |
50 | \newenvironment{ocamldocdescription}
51 | {\list{}{\rightmargin0pt \topsep0pt}\raggedright\item\noindent\relax\ignorespaces}
52 | {\endlist\medskip}
53 |
54 | \newenvironment{ocamldoccomment}
55 | {\list{}{\leftmargin 2\leftmargini \rightmargin0pt \topsep0pt}\raggedright\item\noindent\relax}
56 | {\endlist}
57 |
58 | \let \ocamldocparagraph \paragraph
59 | \def \paragraph #1{\ocamldocparagraph {#1}\noindent}
60 | \let \ocamldocsubparagraph \subparagraph
61 | \def \subparagraph #1{\ocamldocsubparagraph {#1}\noindent}
62 |
63 | \let\ocamldocvspace\vspace
64 |
65 | \newenvironment{ocamldocindent}{\list{}{}\item\relax}{\endlist}
66 | \newenvironment{ocamldocsigend}
67 | {\noindent\quad\texttt{sig}\ocamldocindent}
68 | {\endocamldocindent\vskip -\lastskip
69 | \noindent\quad\texttt{end}\medskip}
70 | \newenvironment{ocamldocobjectend}
71 | {\noindent\quad\texttt{object}\ocamldocindent}
72 | {\endocamldocindent\vskip -\lastskip
73 | \noindent\quad\texttt{end}\medskip}
74 |
75 | \endinput
76 |
--------------------------------------------------------------------------------
/styles/plaintext.sty:
--------------------------------------------------------------------------------
1 | % Plain text style file.
2 |
3 | \typeout{Style option Plaintext}
4 |
5 | % Version from John Pavel's dvidoc.sty, March 1987
6 | % Heavily hacked by Xavier Leroy, June 1993.
7 |
8 | % Redefine all fonts to be the "doc" pseudo-font, with fixed spacing.
9 | % Since rm, tt and mi have different character encodings, we keep
10 | % several copies of the doc font, with different names, so that dvi2txt
11 | % can select the right encoding according to the name. Also, we use
12 | % different names for boldface and italics, so that dvi2txt can select
13 | % the right style whenever possible.
14 |
15 | \def\sl{\rm}
16 | \def\sc{\rm}
17 |
18 | \def\vpt{}
19 | \def\vipt{}
20 | \def\viipt{}
21 | \def\viiipt{}
22 | \def\ixpt{}
23 | \def\xipt{}
24 | \def\xiipt{}
25 | \def\xivpt{}
26 | \def\xviipt{}
27 | \def\xxpt{}
28 | \def\xxvpt{}
29 |
30 | %%% for i in fiv six sev egt nin ten elv twl frtn svnt twty twfv; do
31 | %%% echo "\\font\\${i}rm = docrm"
32 | %%% echo "\\font\\${i}mi = docmi"
33 | %%% echo "\\font\\${i}sy = cmsy10"
34 | %%% echo "\\font\\${i}it = docit"
35 | %%% echo "\\font\\${i}bf = docbf"
36 | %%% echo "\\font\\${i}tt = doctt"
37 | %%% echo "\\font\\${i}sf = docrm"
38 | %%% done
39 |
40 | \font\fivrm = docrm
41 | \font\fivmi = docmi
42 | \font\fivsy = cmsy10
43 | \font\fivit = docit
44 | \font\fivbf = docbf
45 | \font\fivtt = doctt
46 | \font\fivsf = docrm
47 | \font\sixrm = docrm
48 | \font\sixmi = docmi
49 | \font\sixsy = cmsy10
50 | \font\sixit = docit
51 | \font\sixbf = docbf
52 | \font\sixtt = doctt
53 | \font\sixsf = docrm
54 | \font\sevrm = docrm
55 | \font\sevmi = docmi
56 | \font\sevsy = cmsy10
57 | \font\sevit = docit
58 | \font\sevbf = docbf
59 | \font\sevtt = doctt
60 | \font\sevsf = docrm
61 | \font\egtrm = docrm
62 | \font\egtmi = docmi
63 | \font\egtsy = cmsy10
64 | \font\egtit = docit
65 | \font\egtbf = docbf
66 | \font\egttt = doctt
67 | \font\egtsf = docrm
68 | \font\ninrm = docrm
69 | \font\ninmi = docmi
70 | \font\ninsy = cmsy10
71 | \font\ninit = docit
72 | \font\ninbf = docbf
73 | \font\nintt = doctt
74 | \font\ninsf = docrm
75 | \font\tenrm = docrm
76 | \font\tenmi = docmi
77 | \font\tensy = cmsy10
78 | \font\tenit = docit
79 | \font\tenbf = docbf
80 | \font\tentt = doctt
81 | \font\tensf = docrm
82 | \font\elvrm = docrm
83 | \font\elvmi = docmi
84 | \font\elvsy = cmsy10
85 | \font\elvit = docit
86 | \font\elvbf = docbf
87 | \font\elvtt = doctt
88 | \font\elvsf = docrm
89 | \font\twlrm = docrm
90 | \font\twlmi = docmi
91 | \font\twlsy = cmsy10
92 | \font\twlit = docit
93 | \font\twlbf = docbf
94 | \font\twltt = doctt
95 | \font\twlsf = docrm
96 | \font\frtnrm = docrm
97 | \font\frtnmi = docmi
98 | \font\frtnsy = cmsy10
99 | \font\frtnit = docit
100 | \font\frtnbf = docbf
101 | \font\frtntt = doctt
102 | \font\frtnsf = docrm
103 | \font\svtnrm = docrm
104 | \font\svtnmi = docmi
105 | \font\svtnsy = cmsy10
106 | \font\svtnit = docit
107 | \font\svtnbf = docbf
108 | \font\svtntt = doctt
109 | \font\svtnsf = docrm
110 | \font\twtyrm = docrm
111 | \font\twtymi = docmi
112 | \font\twtysy = cmsy10
113 | \font\twtyit = docit
114 | \font\twtybf = docbf
115 | \font\twtytt = doctt
116 | \font\twtysf = docrm
117 | \font\twfvrm = docrm
118 | \font\twfvmi = docmi
119 | \font\twfvsy = cmsy10
120 | \font\twfvit = docit
121 | \font\twfvbf = docbf
122 | \font\twfvtt = doctt
123 | \font\twfvsf = docrm
124 |
125 | \rm
126 |
127 | % Dimensions
128 |
129 | \hsize 78 em % 78 characters per line so fit any screen
130 | \textwidth 78 em
131 | \raggedright % Do not try to align on the right
132 | \parindent=2em % Two blanks for paragraph indentation
133 | \def\enspace{\kern 1em} \def\enskip{\hskip 1em\relax}
134 |
135 | % Vertical skips may best be multiples of \baselineskip
136 | \baselineskip=12pt % 6 lines per inch
137 | \normalbaselineskip=\baselineskip
138 | \vsize 58\baselineskip % 58 lines per page
139 | \textheight 58\baselineskip
140 | \voffset=0pt
141 | \parskip=0pt
142 | \smallskipamount=0pt
143 | \medskipamount= \baselineskip
144 | \bigskipamount=2\baselineskip
145 | \raggedbottom % do not try to align the page bottom
146 |
147 | % By default itemize is done with bullets, which don't look good.
148 |
149 | \def\labelitemi{-}
150 | \def\labelitemii{-}
151 | \def\labelitemiii{-}
152 | \def\labelitemiv{-}
153 |
154 | % Fix up table of contents. Default latex uses fractional spacing between
155 | % the section number and title. This comes out as no space in the doc file
156 | % so we add a space to numberline, and expand tempdima by one em to allow
157 | % for it. Also, go out of math mode for the dot in the leader. Dots in
158 | % math mode turn out to be colons!
159 | %
160 | \def\@dottedtocline#1#2#3#4#5{\ifnum #1>\c@tocdepth \else
161 | \vskip \z@ plus .2pt
162 | {\hangindent #2\relax \rightskip \@tocrmarg \parfillskip -\rightskip
163 | \parindent #2\relax\@afterindenttrue
164 | \interlinepenalty\@M
165 | \leavevmode
166 | \@tempdima #3\relax
167 | \addtolength\@tempdima{1em}
168 | #4\nobreak\leaders\hbox to 2em{\hss.\hss}\hfill \nobreak \hbox to\@pnumwidth{\hfil\rm #5}\par}\fi}
169 | \def\numberline#1{\advance\hangindent\@tempdima \hbox to\@tempdima{#1\hfil}\ }
170 | %
171 | % Can't really do superscripts, so do footnotes with []
172 | %
173 | \def\@makefnmark{\hbox{(\@thefnmark)}}
174 | \long\def\@makefntext#1{\parindent 1em\noindent
175 | \hbox to 3em{\hss\@thefnmark.}\ #1}
176 | \skip\footins 24pt plus 4pt minus 2pt
177 | \def\footnoterule{\kern-12\p@
178 | \hbox to .4\columnwidth{\leaders\hbox{-}\hfill}}
179 | %
180 | % \arrayrulewidth 1em \doublerulesep 1em
181 | %
182 | % Some fairly obvious hacks. No odd/even pages in doc files. Can't do the
183 | % fancy TeX symbols.
184 | %
185 | \oddsidemargin 0pt \evensidemargin 0pt
186 | \def\TeX{TeX}
187 | \def\LaTeX{LaTeX}
188 | \def\SliTeX{SliTeX}
189 | \def\BibTeX{BibTeX}
190 | %
191 | % special versions of stuff from xxx10.sty, since only one font size
192 | %
193 | \def\@normalsize{\@setsize\normalsize{12pt}\xpt\@xpt
194 | \abovedisplayskip 12pt
195 | \belowdisplayskip 12pt
196 | \abovedisplayshortskip 12pt
197 | \belowdisplayshortskip 12pt
198 | \let\@listi\@listI} % Setting of \@listi added 9 Jun 87
199 | \let\small\@normalsize
200 | \let\footnotesize\@normalsize
201 | \normalsize
202 | \footnotesep 12pt
203 | \labelsep 10pt
204 | \def\@listI{\leftmargin\leftmargini \parsep 12pt%
205 | \topsep 12pt%
206 | \partopsep 0pt%
207 | \itemsep 0pt}
208 | \let\@listi\@listI
209 | \let\@listii\@listI
210 | \let\@listiii\@listI
211 | \let\@listiv\@listI
212 | \let\@listv\@listI
213 | \let\@listvi\@listI
214 | \@listI
215 |
216 | % We had sort of random numbers of blank lines around section numbers.
217 | % Turns out they used various fractional spacing. Rather than depend
218 | % upon the definition of startsection, just wrap something around it
219 | % that normalizes the arguments to 12pt. Negative args have special
220 | % meanings.
221 | \let\@oldstartsec\@startsection
222 | \def\@startsection#1#2#3#4#5#6{
223 | \@tempskipa #4\relax
224 | \@tempskipb #5\relax
225 | \ifdim \@tempskipa <\z@ \@tempskipa -12pt \else \@tempskipa 12pt \fi
226 | \ifdim \@tempskipb >\z@ \@tempskipb 12pt \fi
227 | \@oldstartsec{#1}{#2}{#3}{\@tempskipa}{\@tempskipb}{#6}
228 | }
229 |
230 | % To get even spacing in the table of contents
231 |
232 | \def\@pnumwidth{3em}
233 |
234 | \def\l@part#1#2{\addpenalty{-\@highpenalty}%
235 | \addvspace{12pt}% space above part line
236 | \begingroup
237 | \@tempdima 3em
238 | \parindent \z@ \rightskip \@pnumwidth
239 | \parfillskip -\@pnumwidth
240 | {\large \bf
241 | \leavevmode
242 | #1\hfil \hbox to\@pnumwidth{\hss #2}}\par
243 | \nobreak
244 | \global\@nobreaktrue
245 | \everypar{\global\@nobreakfalse\everypar{}}%% suggested by
246 |
247 | \endgroup}
248 |
249 | \def\l@chapter#1#2{\addpenalty{-\@highpenalty}%
250 | \vskip 12pt
251 | \@tempdima 2em
252 | \begingroup
253 | \parindent \z@ \rightskip \@pnumwidth
254 | \parfillskip -\@pnumwidth
255 | \bf
256 | \leavevmode
257 | \advance\leftskip\@tempdima
258 | \hskip -\leftskip
259 | #1\nobreak\hfil \nobreak\hbox to\@pnumwidth{\hss #2}\par
260 | \penalty\@highpenalty
261 | \endgroup}
262 |
263 | \def\l@section{\@dottedtocline{1}{2em}{3em}}
264 | \def\l@subsection{\@dottedtocline{2}{4em}{3em}}
265 | \def\l@subsubsection{\@dottedtocline{3}{7em}{4em}}
266 | \def\l@paragraph{\@dottedtocline{4}{10em}{5em}}
267 | \def\l@subparagraph{\@dottedtocline{5}{12em}{6em}}
268 |
269 |
--------------------------------------------------------------------------------
/styles/scroll.sty:
--------------------------------------------------------------------------------
1 | % Modification to plaintext.sty to suppress page headings
2 | % and make pages contiguous when processed with dvi2txt
3 |
4 | \pagestyle{empty}
5 | \advance\voffset by -2\baselineskip
6 |
--------------------------------------------------------------------------------
/styles/syntaxdef.hva:
--------------------------------------------------------------------------------
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 | % Hevea code for syntax definitions of the ocaml manual %
3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 | % Important commands
5 | % \token, for typesetting grammar terminals
6 | % \nonterm, for typesetting grammar non-terminals
7 | %
8 | % Beware: \nonterm introduces either a local anchor or a local reference
9 | % -Anchors are introduced when \nonterm occurs in the first column of
10 | % syntax definitions (environment 'syntax')
11 | % - References are introduced everywhere else
12 | %
13 | % For pure typesetting effect without links (eg. to typeset 'e' as 'expr')
14 | % use the \nt command (eg. \nt{e}).
15 | % In syntax definitions, the tool 'transf' translates @word@ into \nt{word}.
16 | %
17 | % Warnings are produced
18 | % - For references to non-defined non terminals
19 | % - For multiple definitions of the same non-terminal
20 | % Warnings can be avoided for a given non-terminal 'expr' by issuing
21 | % the command \stx@silent{'expr'}
22 | %
23 | %It is also possible to alias a nonterminal:
24 | %\stx@alias{name}{othername}
25 | %will make reference to 'name' point to the definition of non-terminal
26 | %'othername'
27 | \newif\ifspace
28 | \def\addspace{\ifspace\;\spacefalse\fi}
29 | \ifhtml
30 | \newcommand{\token}[1]{\texttt{\blue#1}}
31 | \else
32 | \newcommand{\token}[1]{\texttt{#1}}
33 | \fi
34 | %%% warnings
35 | \def\stx@warning#1#2{\@ifundefined{stx@#1@silent}{\hva@warn{#2}}{}}
36 | \def\stx@silent#1{\def\csname stx@#1@silent\endcsname{}}
37 | %%% Do not warn about those
38 | %initial example
39 | \stx@silent{like}\stx@silent{that}%
40 | %Not defined
41 | \stx@silent{regular-char}%
42 | \stx@silent{regular-string-char}%
43 | %\stx@silent{regular-char-str}%
44 | \stx@silent{lowercase-ident}%
45 | \stx@silent{capitalized-ident}%
46 | \stx@silent{space}%
47 | \stx@silent{tab}%
48 | \stx@silent{newline}%
49 | %Used in many places
50 | \stx@silent{prefix}%
51 | \stx@silent{name}%
52 | \stx@silent{xname}%
53 | %Not defined
54 | \stx@silent{external-declaration}%
55 | \stx@silent{unit-name}%
56 | %%Redefined in exten.etex
57 | \stx@silent{parameter}%
58 | \stx@silent{pattern}%
59 | \stx@silent{constr-decl}%
60 | \stx@silent{type-param}%
61 | \stx@silent{let-binding}%
62 | \stx@silent{expr}%
63 | \stx@silent{typexpr}%
64 | \stx@silent{module-expr}%
65 | \stx@silent{type-representation}%
66 | \stx@silent{definition}%
67 | \stx@silent{specification}%
68 | \stx@silent{type-equation}%
69 | \stx@silent{class-field}%
70 | \stx@silent{mod-constraint}%
71 | \stx@silent{module-type}%
72 | \stx@silent{constant}%
73 | %%Redefined in names.etex
74 | \stx@silent{label-name}%
75 | %%Not really defined in lexyacc.etex
76 | \stx@silent{character-set}%
77 | \stx@silent{symbol}%
78 | %%Not defined in debugger.etex
79 | \stx@silent{integer}
80 | %%Not defined in ocamldoc.etex
81 | \stx@silent{string}
82 | \stx@silent{id}
83 | \stx@silent{Exc}
84 | \stx@silent{URL}
85 | %%%%%%%%%%%%%
86 | %% Aliases %%
87 | %%%%%%%%%%%%%
88 | \newcommand{\stx@alias}[2]{\def\csname stx@#1@alias\endcsname{#2}}
89 | \stx@alias{typ}{typexpr}%
90 | \stx@alias{met}{method-name}%
91 | \stx@alias{tag}{tag-name}%
92 | \stx@alias{lab}{label-name}%
93 | \stx@alias{C}{constr-name}
94 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 | %%special anchor
96 | \newstyle{a.syntax:link}{color:maroon;text-decoration:underline}
97 | \newstyle{a.syntax:visited}{color:maroon;text-decoration:underline}
98 | \newstyle{a.syntax:hover}{color:black;text-decoration:none;background-color:\#FF6060}
99 | %compatibility for hevea-1.1?/heeva-2.??
100 | \ifu\@tr@url
101 | \providecommand{\@tr@url}[1]{#1}\def\stx@id{NAME}\else
102 | \def\stx@id{id}\fi
103 | \newcommand{\@syntaxlocref}[2]
104 | {\@aelement{href="\@print{#}\@tr@url{#1}" class="syntax"}{#2}}
105 | \newcommand{\@syntaxaname}[2]
106 | {\@aelement{\stx@id="#1" class="syntax"}{#2}}
107 | %%Refer to anchor, internal :
108 | %#1 -> anchor #2 -> visible tag
109 | \def\@ref@anchor#1#2{%
110 | \@ifundefined{stx@#1@exists}
111 | {\stx@warning{#1}{Undefined non-terminal: '#1'}#2}
112 | {\@syntaxlocref{#1}{#2}}}
113 | %%Refer to anchor
114 | \def\ref@anchor#1{%
115 | \ifu\csname stx@#1@alias\endcsname
116 | \@ref@anchor{#1}{#1}\else
117 | \@ref@anchor{\csname stx@#1@alias\endcsname}{#1}\fi}
118 | \def\stx@exists#1{\def\csname stx@#1@exists\endcsname{}}
119 | %%Define anachor
120 | \def\def@anchor#1{%
121 | \@ifundefined{stx@#1}
122 | {{\@nostyle\@auxdowrite{\string\stx@exists\{#1\}}}%
123 | \gdef\csname stx@#1\endcsname{}\@syntaxaname{#1}{#1}}
124 | {\@ifundefined{stx@#1@silent}
125 | {\hva@warn{Redefinition of non-terminal '#1'}#1}
126 | {\ref@anchor{#1}}}}
127 | %%%Change \@anchor and initial definition, for html only, of course!
128 | \ifhtml
129 | \def\set@name{\let\@anchor\def@anchor}
130 | \let\@anchor\ref@anchor
131 | \else
132 | \def\set@name{}
133 | \def\@anchor{}
134 | \fi
135 | %%%Format non-terminal
136 | \def\nt#1{\textit{\maroon#1}}
137 | %%%Link for non-terminal and format
138 | \def\nonterm#1{\addspace\nt{\@anchor{#1}}\spacetrue}
139 | \def\brepet{\addspace\{}
140 | \def\erepet{\}}
141 | \def\boption{\addspace[}
142 | \def\eoption{]}
143 | \def\brepets{\addspace\{}
144 | \def\erepets{\}^+}
145 | \def\bparen{\addspace(}
146 | \def\eparen{)}
147 | \def\orelse{\mid \spacefalse}
148 | \def\is{ & ::= & \spacefalse }
149 | \def\alt{ \\ & \mid & \spacefalse }
150 | \def\sep{ \\ \\ \spacefalse }
151 | \def\cutline{}
152 | \def\emptystring{\epsilon}
153 | \def\syntax{$$\begin{array}{>{\set@name}rcl}\spacefalse}
154 | \def\endsyntax{\end{array}$$}
155 | \def\syntaxleft{$\begin{array}{>{\set@name}rcl}\spacefalse}
156 | \def\endsyntaxleft{\end{array}$}
157 | \def\synt#1{$\spacefalse#1$}
158 |
--------------------------------------------------------------------------------
/styles/syntaxdef.sty:
--------------------------------------------------------------------------------
1 | \newif\ifspace
2 | \def\addspace{\ifspace \; \spacefalse \fi}
3 | \def\token#1{\addspace\hbox{\tt #1} \spacetrue}
4 | \def\nonterm#1{\addspace\nt{#1} \spacetrue}
5 | \def\nt#1{\hbox{\sl #1\/}}
6 | \def\brepet{\addspace\{}
7 | \def\erepet{\}}
8 | \def\boption{\addspace[}
9 | \def\eoption{]}
10 | \def\brepets{\addspace\{}
11 | \def\erepets{\}^+}
12 | \def\bparen{\addspace(}
13 | \def\eparen{)}
14 | \def\orelse{\mid \spacefalse}
15 | \def\is{ & ::= & \spacefalse }
16 | \def\alt{ \\ & \mid & \spacefalse }
17 | \def\cutline{ \\ & & \spacefalse }
18 | \def\sep{ \\[2mm] \spacefalse }
19 | \def\emptystring{\epsilon}
20 | \def\syntax{$$\begin{array}{rrl}\spacefalse}
21 | \def\endsyntax{\end{array}$$}
22 | \def\syntaxleft{$\begin{array}{rrl}\spacefalse}
23 | \def\endsyntaxleft{\end{array}$}
24 | \let\oldldots=\ldots
25 | \def\ldots{\spacefalse\oldldots}
26 | \def\synt#1{$\spacefalse#1$}
27 |
--------------------------------------------------------------------------------
/styles/syntaxdeftxt.sty:
--------------------------------------------------------------------------------
1 | \newif\ifspace
2 | \def\addspace{\ifspace\ \spacefalse\fi}
3 | \def\token#1{\addspace\hbox{\tt #1}\spacetrue\ignorespaces}
4 | %%% \def\nonterm#1{\addspace\hbox{\tt <#1>}\spacetrue\ignorespaces}
5 | \def\nonterm#1{\addspace\hbox{\it #1}\spacetrue\ignorespaces}
6 | \def\brepet{\addspace\hbox to1em{$\{$\hfil}\ignorespaces}
7 | \def\erepet{\hbox to1em{$\}$\hfil}\ignorespaces}
8 | \def\boption{\addspace[\ignorespaces}
9 | \def\eoption{]\ignorespaces}
10 | \def\brepets{\brepet\ignorespaces}
11 | \def\erepets{\erepet+\ignorespaces}
12 | \def\bparen{\addspace(\ignorespaces}
13 | \def\eparen{)\ignorespaces}
14 | \def\orelse{~\hbox to1em{$|$\hfil}~\spacefalse\ignorespaces}
15 | \def\is{& ::= & \spacefalse\ignorespaces}
16 | \def\alt{\\ & \hbox to1em{$|$\hfil} & \spacefalse }
17 | \def\sep{\\[\baselineskip] \spacefalse}
18 | \def\emptystring{nothing}
19 | \def\syntax{\begin{center}\begin{tabular}{rrl}\spacefalse\ignorespaces}
20 | \def\endsyntax{\end{tabular}\end{center}}
21 | \def\ldots{\spacefalse...\ignorespaces}
22 | \def\synt#1{$\spacefalse#1$}
23 |
--------------------------------------------------------------------------------
/tools/.gitignore:
--------------------------------------------------------------------------------
1 | transf.ml
2 | texquote2
3 | htmltransf.ml
4 | transf
5 | htmlgen
6 | htmlquote
7 | latexscan.ml
8 | dvi2txt
9 | caml-tex2
10 | *.dSYM
11 | *.cm[io]
12 | *.o
13 |
--------------------------------------------------------------------------------
/tools/.ignore:
--------------------------------------------------------------------------------
1 | transf.ml
2 | texquote2
3 | htmltransf.ml
4 | transf
5 | htmlgen
6 | htmlquote
7 | latexscan.ml
8 | dvi2txt
9 | caml-tex2
10 | *.dSYM
11 | *.cm[io]
12 |
--------------------------------------------------------------------------------
/tools/Makefile:
--------------------------------------------------------------------------------
1 | CFLAGS=-g -O
2 |
3 | all: texquote2 transf htmlquote htmlgen dvi2txt caml-tex2
4 |
5 | dvi2txt:
6 | cd dvi_to_txt; ${MAKE}
7 |
8 | transf: transf.cmo htmltransf.cmo transfmain.cmo
9 | ocamlc -o transf -g transf.cmo htmltransf.cmo transfmain.cmo
10 |
11 | transf.ml: transf.mll
12 | ocamllex transf.mll
13 |
14 | htmltransf.ml: htmltransf.mll
15 | ocamllex htmltransf.mll
16 |
17 | htmlgen: latexmacros.cmo latexscan.cmo latexmain.cmo
18 | ocamlc -o htmlgen -g latexmacros.cmo latexscan.cmo latexmain.cmo
19 |
20 | latexscan.ml: latexscan.mll
21 | ocamllex latexscan.mll
22 |
23 | caml-tex2: caml_tex2.cmo
24 | ocamlc -o caml-tex2 str.cma unix.cma caml_tex2.cmo
25 | # ocamlc -custom -o caml-tex2 str.cma unix.cma caml-tex2.cmo \
26 | # -cclib -lunix -cclib -lstr
27 |
28 | .SUFFIXES:
29 | .SUFFIXES: .ml .cmo .mli .cmi .c
30 |
31 | .ml.cmo:
32 | ocamlc -c $<
33 |
34 | .mli.cmi:
35 | ocamlc -c $<
36 |
37 | .c:
38 | $(CC) $(CFLAGS) -o $@ $<
39 |
40 | clean:
41 | rm -f transf.ml latexscan.ml htmltransf.ml
42 | rm -f texquote2 transf htmlquote htmlgen dvi2txt
43 | rm -f transf.ml latex.ml
44 | rm -f *.o *.cm? *.cmxa
45 | rm -f *~ #*#
46 | cd dvi_to_txt; ${MAKE} clean
47 |
48 | latexmacros.cmo: latexmacros.cmi
49 | latexmain.cmo: latexscan.cmo
50 | latexscan.cmo: latexmacros.cmi
51 | transfmain.cmo: transf.cmo htmltransf.cmo
52 |
--------------------------------------------------------------------------------
/tools/caml-tex:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | $camllight = "TERM=dumb ocaml";
4 | $camlbegin = "\\caml\n";
5 | $camlend = "\\endcaml\n";
6 | $camlin = "\\?";
7 | $camlout = "\\:";
8 | $camlblank = "\\;\n";
9 |
10 | $linelen = 72;
11 | $output = "";
12 | $cut_at_blanks = 0;
13 |
14 | while ($#ARGV >= 0) {
15 | $_ = $ARGV[0];
16 | last unless (/^-/);
17 | $linelen = $ARGV[1], shift, shift, next if (/^-n$/);
18 | $output = $ARGV[1], shift, shift, next if (/^-o$/);
19 | $camllight = $ARGV[1], shift, shift, next if (/^-caml$/);
20 | $cut_at_blanks = 1, shift, next if (/^-w$/);
21 | printf STDERR ("Unknown option '%s', ignored\n", $_);
22 | shift;
23 | }
24 |
25 | # First pass: extract the Caml phrases to evaluate
26 |
27 | open(ML, "> .input.ml") || die("Cannot create .input.ml : $!");
28 |
29 | foreach $infile (@ARGV) {
30 | open(IN, $infile) || die("Cannot open $infile : $!");
31 | while() {
32 | if (m/^\\begin{caml_(example|example\*|eval)}\s*$/) {
33 | while() {
34 | last if m/^\\end{caml_(example|example\*|eval)}\s*$/;
35 | print ML $_;
36 | }
37 | }
38 | }
39 | close(IN);
40 | }
41 |
42 | close(ML);
43 |
44 | # Feed the phrases to a Caml toplevel
45 |
46 | open(TOPLEVEL, "$camllight 2>&1 < .input.ml |") ||
47 | die("Cannot start camllight : $!");
48 |
49 | ; ; # skip the banner
50 | $lastread = ;
51 | $lastread =~ s/^# //;
52 |
53 | # Second pass: shuffle the TeX source and the output of the toplevel
54 |
55 | if ($output) {
56 | if ($output eq "-") {
57 | open(OUT, ">&STDOUT");
58 | } else {
59 | open(OUT, ">$output") || die("Cannot create $output: $!");
60 | }
61 | }
62 |
63 | foreach $infile (@ARGV) {
64 | open(IN, $infile) || die("Cannot open $infile: $!");
65 | if (! $output) {
66 | $outfile = $infile;
67 | $outfile =~ s/\.tex$//;
68 | open(OUT, "> $outfile.ml.tex") || die("Cannot create $outfile.ml.tex: $!");
69 | }
70 | while() {
71 | if (m/^\\begin{caml_example(\*?)}\s*$/) {
72 | $omit_answer = $1; # true if caml_example*, false if caml_example
73 | print OUT $camlbegin;
74 | $severalphrases = 0;
75 | while() {
76 | last if m/\\end{caml_example\*?}\s*$/;
77 | print OUT $camlblank if ($severalphrases);
78 | while(1) {
79 | s/\\/\\\\/g;
80 | print OUT $camlin, $_;
81 | last if m/;; *$/;
82 | $_ = ;
83 | }
84 | while ($lastread =~ s/^ //) { }
85 | while($lastread) {
86 | last if $lastread =~ s/^# //;
87 | print STDERR $lastread;
88 | if (! $omit_answer) {
89 | while (length($lastread) > $linelen) {
90 | if ($cut_at_blanks) {
91 | $cutpos = rindex($lastread, ' ', $linelen);
92 | if ($cutpos == -1) { $cutpos = $linelen; } else { $cutpos++; }
93 | } else {
94 | $cutpos = $linelen;
95 | }
96 | $line = substr($lastread, 0, $cutpos);
97 | $line =~ s/\\/\\\\/g;
98 | print OUT $camlout, $line, "\n";
99 | $lastread = substr($lastread, $cutpos,
100 | length($lastread) - $cutpos);
101 | }
102 | $lastread =~ s/\\/\\\\/g;
103 | print OUT $camlout, $lastread;
104 | }
105 | $lastread = ;
106 | }
107 | $severalphrases = 1;
108 | }
109 | print OUT $camlend;
110 | }
111 | elsif (m/^\\begin{caml_eval}\s*$/) {
112 | while() {
113 | last if m/^\\end{caml_eval}\s*$/;
114 | if (m/;; *$/) {
115 | while ($lastread =~ s/^ //) { }
116 | while($lastread) {
117 | last if $lastread =~ s/^#//;
118 | print STDERR $lastread;
119 | $lastread = ;
120 | }
121 | }
122 | }
123 | }
124 | else {
125 | print OUT $_;
126 | }
127 | }
128 | close(IN);
129 | }
130 |
131 | close(TOPLEVEL);
132 |
--------------------------------------------------------------------------------
/tools/caml_tex2.ml:
--------------------------------------------------------------------------------
1 | (* $Id$ *)
2 |
3 | open StdLabels
4 | open Printf
5 | open Str
6 |
7 | let camlbegin = "\\caml\n"
8 | let camlend = "\\endcaml\n"
9 | let camlin = "\\\\?\\1"
10 | let camlout = "\\\\:\\1"
11 | let camlbunderline = "\\<"
12 | let camleunderline = "\\>"
13 |
14 | let camllight = ref "TERM=norepeat ocaml"
15 | let linelen = ref 72
16 | let outfile = ref ""
17 | let cut_at_blanks = ref false
18 | let files = ref []
19 |
20 | let _ =
21 | Arg.parse ["-n", Arg.Int (fun n -> linelen := n), "line length";
22 | "-o", Arg.String (fun s -> outfile := s), "output";
23 | "-caml", Arg.String (fun s -> camllight := s), "toplevel";
24 | "-w", Arg.Set cut_at_blanks, "cut at blanks"]
25 | (fun s -> files := s :: !files)
26 | "caml-tex2: "
27 |
28 | let (~!) =
29 | let memo = ref [] in
30 | fun key ->
31 | try List.assq key !memo
32 | with Not_found ->
33 | let data = Str.regexp key in
34 | memo := (key, data) :: !memo;
35 | data
36 |
37 | let caml_input, caml_output =
38 | let cmd = !camllight ^ " 2>&1" in
39 | try Unix.open_process cmd with _ -> failwith "Cannot start toplevel"
40 | let () =
41 | at_exit (fun () -> ignore (Unix.close_process (caml_input, caml_output)));
42 | ignore (input_line caml_input);
43 | ignore (input_line caml_input)
44 |
45 | let read_output () =
46 | let input = ref (input_line caml_input) in
47 | input := replace_first ~!"^# *" "" !input;
48 | let underline =
49 | if string_match ~!"Characters *\\([0-9]+\\)-\\([0-9]+\\):$" !input 0
50 | then
51 | let b = int_of_string (matched_group 1 !input)
52 | and e = int_of_string (matched_group 2 !input) in
53 | input := input_line caml_input;
54 | b, e
55 | else 0, 0
56 | in
57 | let output = Buffer.create 256 in
58 | while not (string_match ~!".*\"end_of_input\"$" !input 0) do
59 | prerr_endline !input;
60 | Buffer.add_string output !input;
61 | Buffer.add_char output '\n';
62 | input := input_line caml_input;
63 | done;
64 | Buffer.contents output, underline
65 |
66 | let escape_specials s =
67 | let s1 = global_replace ~!"\\\\" "\\\\\\\\" s in
68 | let s2 = global_replace ~!"'" "\\\\textquotesingle\\\\-" s1 in
69 | let s3 = global_replace ~!"`" "\\\\textasciigrave\\\\-" s2 in
70 | s3
71 |
72 | let process_file file =
73 | prerr_endline ("Processing " ^ file);
74 | let ic = try open_in file with _ -> failwith "Cannot read input file" in
75 | let oc =
76 | try if !outfile = "-" then
77 | stdout
78 | else if !outfile = "" then
79 | open_out (replace_first ~!"\\.tex$" "" file ^ ".ml.tex")
80 | else
81 | open_out_gen [Open_wronly; Open_creat; Open_append; Open_text]
82 | 0x666 !outfile
83 | with _ -> failwith "Cannot open output file" in
84 | try while true do
85 | let input = ref (input_line ic) in
86 | if string_match ~!"\\\\begin{caml_example\\(\\*?\\)}[ \t]*$"
87 | !input 0
88 | then begin
89 | let omit_answer = matched_group 1 !input = "*" in
90 | output_string oc camlbegin;
91 | let first = ref true in
92 | let read_phrase () =
93 | let phrase = Buffer.create 256 in
94 | while
95 | let input = input_line ic in
96 | if string_match ~!"\\\\end{caml_example\\*?}[ \t]*$"
97 | input 0
98 | then raise End_of_file;
99 | if Buffer.length phrase > 0 then Buffer.add_char phrase '\n';
100 | Buffer.add_string phrase input;
101 | not (string_match ~!".*;;[ \t]*$" input 0)
102 | do
103 | ()
104 | done;
105 | Buffer.contents phrase
106 | in
107 | try while true do
108 | let phrase = read_phrase () in
109 | fprintf caml_output "%s\n" phrase;
110 | flush caml_output;
111 | output_string caml_output "\"end_of_input\";;\n";
112 | flush caml_output;
113 | let output, (b, e) = read_output () in
114 | let phrase =
115 | if b < e then begin
116 | let start = String.sub phrase ~pos:0 ~len:b
117 | and underlined = String.sub phrase ~pos:b ~len:(e-b)
118 | and rest =
119 | String.sub phrase ~pos:e ~len:(String.length phrase - e)
120 | in
121 | String.concat ""
122 | [escape_specials start; "\\<";
123 | escape_specials underlined; "\\>";
124 | escape_specials rest]
125 | end else
126 | escape_specials phrase in
127 | (* Special characters may also appear in output strings -Didier *)
128 | let output = escape_specials output in
129 | let phrase = global_replace ~!"^\\(.\\)" camlin phrase
130 | and output = global_replace ~!"^\\(.\\)" camlout output in
131 | if not !first then output_string oc "\\;\n";
132 | fprintf oc "%s\n" phrase;
133 | if not omit_answer then fprintf oc "%s" output;
134 | flush oc;
135 | first := false
136 | done
137 | with End_of_file -> output_string oc camlend
138 | end
139 | else if string_match ~!"\\\\begin{caml_eval}[ \t]*$" !input 0
140 | then begin
141 | while input := input_line ic;
142 | not (string_match ~!"\\\\end{caml_eval}[ \t]*$" !input 0)
143 | do
144 | fprintf caml_output "%s\n" !input;
145 | if string_match ~!".*;;[ \t]*$" !input 0 then begin
146 | flush caml_output;
147 | output_string caml_output "\"end_of_input\";;\n";
148 | flush caml_output;
149 | ignore (read_output ())
150 | end
151 | done
152 | end else begin
153 | fprintf oc "%s\n" !input;
154 | flush oc
155 | end
156 | done with
157 | End_of_file -> close_in ic; close_out oc
158 |
159 | let _ =
160 | if !outfile <> "-" && !outfile <> "" then begin
161 | try close_out (open_out !outfile)
162 | with _ -> failwith "Cannot open output file"
163 | end;
164 | List.iter process_file (List.rev !files)
165 |
166 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/Makefile:
--------------------------------------------------------------------------------
1 | OBJS=io.o interp.o output.o main.o print.o print_rtf.o print_styl.o
2 | CFLAGS=-g
3 |
4 | ../dvi2txt: $(OBJS)
5 | $(CC) $(CFLAGS) -o ../dvi2txt $(OBJS)
6 |
7 | clean:
8 | rm -f ../dvi2txt *.o *~ #*#
9 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/dvi.h:
--------------------------------------------------------------------------------
1 | enum {
2 | SET_CHAR_0=0, SET_CHAR_127=127, SET1=128, SET2, SET3, SET4, SET_RULE,
3 | PUT1, PUT2, PUT3, PUT4, PUT_RULE, NOP, BOP, EOP, PUSH, POP, RIGHT1,
4 | RIGHT2, RIGHT3, RIGHT4, W0, W1, W2, W3, W4, X0, X1, X2, X3, X4, DOWN1,
5 | DOWN2, DOWN3, DOWN4, Y0, Y1, Y2, Y3, Y4, Z0, Z1, Z2, Z3, Z4,
6 | FNT_NUM_0=171, FNT_NUM_63=234, FNT1=235, FNT2, FNT3, FNT4, XXX1, XXX2,
7 | XXX3, XXX4, FNT_DEF1, FNT_DEF2, FNT_DEF3, FNT_DEF4, PRE, POST, POST_POST
8 | };
9 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/io.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "io.h"
3 |
4 | int get16u(input)
5 | FILE * input;
6 | {
7 | int b1 = getc(input);
8 | int b2 = getc(input);
9 | return (b1 << 8) + b2;
10 | }
11 | int get16s(input)
12 | FILE * input;
13 | {
14 | int b1 = (schar) getc(input);
15 | int b2 = getc(input);
16 | return (b1 << 8) + b2;
17 | }
18 | int get24u(input)
19 | FILE * input;
20 | {
21 | int b1 = getc(input);
22 | int b2 = getc(input);
23 | int b3 = getc(input);
24 | return (b1 << 16) + (b2 << 8) + b3;
25 | }
26 | int get24s(input)
27 | FILE * input;
28 | {
29 | int b1 = (schar) getc(input);
30 | int b2 = getc(input);
31 | int b3 = getc(input);
32 | return (b1 << 16) + (b2 << 8) + b3;
33 | }
34 | int get32s(input)
35 | FILE * input;
36 | {
37 | int b1 = (schar) getc(input);
38 | int b2 = getc(input);
39 | int b3 = getc(input);
40 | int b4 = getc(input);
41 | return (b1 << 24) + (b2 << 16) + (b3 << 8) + b4;
42 | }
43 |
44 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/io.h:
--------------------------------------------------------------------------------
1 | #ifdef __STDC__
2 | typedef signed char schar;
3 | #else
4 | typedef char schar;
5 | #endif
6 |
7 | #define get8u(input) getc(input)
8 | #define get8s(input) (schar) getc(input)
9 |
10 | int get16u(), get16s(), get24u(), get24s(), get32u(), get32s();
11 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "output.h"
3 |
4 | void interprete(FILE *input);
5 |
6 | char * input_name;
7 |
8 | int main(argc, argv)
9 | int argc;
10 | char ** argv;
11 | {
12 | FILE * f;
13 | int i;
14 |
15 | output_device = OUTPUT_PLAIN;
16 | standout_tt = 0;
17 | for (i = 1; i < argc && argv[i][0] == '-'; i++) {
18 | switch(argv[i][1]) {
19 | case 'p':
20 | output_device = OUTPUT_PRINTER; break;
21 | case 'r':
22 | output_device = OUTPUT_RTF; break;
23 | case 's':
24 | output_device = OUTPUT_STYL; break;
25 | case 't':
26 | standout_tt = 1; break;
27 | default:
28 | fprintf(stderr, "Unknown option `%s', ignored\n", argv[i]);
29 | }
30 | }
31 | if (i >= argc) {
32 | input_name = "unknown.dvi";
33 | interprete(stdin);
34 | } else {
35 | for (/*nothing*/; i < argc; i++) {
36 | f = fopen(argv[i], "r");
37 | if (f == NULL) {
38 | perror(argv[i]);
39 | continue;
40 | }
41 | input_name = argv[i];
42 | interprete(f);
43 | fclose(f);
44 | }
45 | }
46 | return 0;
47 | }
48 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/output.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "output.h"
5 |
6 | void null(), print_FF(), plain_line(), printer_line();
7 | void begin_rtf_document(), end_rtf_document(), end_rtf_page(), rtf_line();
8 | void begin_styl_page(), end_styl_page(), styl_line();
9 |
10 | struct output_device {
11 | void (*begin_document)();
12 | void (*end_document)();
13 | void (*begin_page)();
14 | void (*end_page)();
15 | void (*line)();
16 | } device[] = {
17 | null, null, null, print_FF, plain_line,
18 | null, null, null, print_FF, printer_line,
19 | begin_rtf_document, end_rtf_document, null, end_rtf_page, rtf_line,
20 | null, null, begin_styl_page, end_styl_page, styl_line
21 | };
22 |
23 | #define SIZEX 160
24 |
25 | struct line {
26 | int ypos;
27 | int len;
28 | char * contents;
29 | char * styles;
30 | struct line * next_in_bucket;
31 | };
32 |
33 | #define NBUCKETS 101
34 |
35 | struct line * screenlines[NBUCKETS];
36 |
37 | int numlines;
38 |
39 | char * xmalloc(size)
40 | int size;
41 | {
42 | char * res = (char *) malloc(size);
43 | if (res == NULL) {
44 | fprintf(stderr, "Out of memory\n");
45 | exit(2);
46 | }
47 | return res;
48 | }
49 |
50 | char * xrealloc(ptr, size)
51 | char * ptr;
52 | int size;
53 | {
54 | char * res = (char *) realloc(ptr, size);
55 | if (res == NULL) {
56 | fprintf(stderr, "Out of memory\n");
57 | exit(2);
58 | }
59 | return res;
60 | }
61 |
62 | void begin_document()
63 | {
64 | device[output_device].begin_document();
65 | }
66 |
67 | void end_document()
68 | {
69 | device[output_device].end_document();
70 | }
71 |
72 | void clear_page()
73 | {
74 | int i;
75 |
76 | for (i = 0; i < NBUCKETS; i++) screenlines[i] = NULL;
77 | numlines = 0;
78 | }
79 |
80 | void out(x, y, c, style)
81 | int x, y;
82 | char c;
83 | char style;
84 | {
85 | unsigned int h;
86 | struct line * line;
87 |
88 | h = ((unsigned int) y) % NBUCKETS;
89 | line = screenlines[h];
90 | while (line != NULL && line->ypos != y) line = line->next_in_bucket;
91 | if (line == NULL) {
92 | line = (struct line *) xmalloc(sizeof(struct line));
93 | line->ypos = y;
94 | line->len = 80;
95 | line->contents = (char *) xmalloc(line->len);
96 | memset(line->contents, ' ', line->len);
97 | line->styles = (char *) xmalloc(line->len);
98 | memset(line->styles, PLAIN, line->len);
99 | line->next_in_bucket = screenlines[h];
100 | screenlines[h] = line;
101 | numlines++;
102 | }
103 | x = x / scalex;
104 | if (x < 0) return;
105 | while (x >= line->len) {
106 | int newlen = 2 * line->len;
107 | line->contents = (char *) xrealloc(line->contents, newlen);
108 | memset(line->contents + line->len, ' ', newlen - line->len);
109 | line->styles = (char *) xrealloc(line->styles, newlen);
110 | memset(line->styles + line->len, PLAIN, newlen - line->len);
111 | line->len = newlen;
112 | }
113 | line->contents[x] = c;
114 | line->styles[x] = style;
115 | }
116 |
117 | static void free_bucket(l)
118 | struct line * l;
119 | {
120 | if (l != NULL) {
121 | free(l->contents);
122 | free(l->styles);
123 | free_bucket(l->next_in_bucket);
124 | free(l);
125 | }
126 | }
127 |
128 | static void free_buckets()
129 | {
130 | int i;
131 | for (i = 0; i < NBUCKETS; i++) free_bucket(screenlines[i]);
132 | }
133 |
134 | static int compare_lines(l1, l2)
135 | struct line ** l1, ** l2;
136 | {
137 | return (**l1).ypos - (**l2).ypos;
138 | }
139 |
140 | void output_page()
141 | {
142 | struct line ** lines;
143 | struct line * l;
144 | int i, j, k, y;
145 | char * p, * q, * style_p, * style_q, * s;
146 |
147 | device[output_device].begin_page();
148 |
149 | /* First, sort the lines by y coordinate */
150 | lines = (struct line **) malloc(numlines * sizeof(struct line *));
151 | if (lines == NULL) {
152 | printf("*** Out of memory ***\n\014");
153 | free_buckets();
154 | return;
155 | }
156 | j = 0;
157 | for (i = 0; i < NBUCKETS; i++)
158 | for (l = screenlines[i]; l != NULL; l = l->next_in_bucket)
159 | lines[j++] = l;
160 | qsort(lines, numlines, sizeof(struct line *), compare_lines);
161 |
162 | /* Output the lines */
163 |
164 | y = 0;
165 | for (i = 0; i < numlines; i++) {
166 | /* Emit blank lines to reach the current line ypos */
167 | while (lines[i]->ypos - y >= 3 * scaley / 2) {
168 | device[output_device].line(NULL, NULL, 0);
169 | y += scaley;
170 | }
171 | /* If next line is close to current line, attempt to merge them */
172 | while (i + 1 < numlines &&
173 | lines[i+1]->ypos - lines[i]->ypos < scaley) {
174 | p = lines[i]->contents;
175 | q = lines[i+1]->contents;
176 | style_p = lines[i]->styles;
177 | style_q = lines[i+1]->styles;
178 | for (j = lines[i]->len; j < lines[i+1]->len; j++)
179 | if (q[j] != ' ') goto cannot_merge;
180 | for (j = lines[i+1]->len; j < lines[i]->len; j++)
181 | if (p[j] != ' ') goto cannot_merge;
182 | k = lines[i]->len;
183 | if (k > lines[i+1]->len) k = lines[i+1]->len;
184 | for (j = 0; j < k; j++)
185 | if (p[j] != ' ' && q[j] != ' ') goto cannot_merge;
186 | /* Seems OK, do the merging */
187 | for (j = 0; j < k; j++)
188 | if (p[j] != ' ') {
189 | q[j] = p[j];
190 | style_q[j] = style_p[j];
191 | }
192 | /* Now consider next line */
193 | i++;
194 | }
195 | cannot_merge:
196 | /* Now print the current line */
197 | p = lines[i]->contents;
198 | q = p + lines[i]->len;
199 | while (q >= p && *--q == ' ') /*nothing*/;
200 | device[output_device].line(p, lines[i]->styles, q-p+1);
201 | /* Go on with next line */
202 | y = lines[i]->ypos;
203 | }
204 |
205 | device[output_device].end_page();
206 | free(lines);
207 | free_buckets();
208 | }
209 |
210 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/output.h:
--------------------------------------------------------------------------------
1 | #define SCALEX 404685
2 | #define SCALEY 786432
3 |
4 | int scalex;
5 | int scaley;
6 |
7 | #define PLAIN 0
8 | #define ITALICS 1
9 | #define BOLD 2
10 | #define MONOSPACED 3
11 |
12 | void begin_document();
13 | void end_document();
14 | void clear_page();
15 | void output_page();
16 | void out();
17 |
18 | int output_device;
19 | int standout_tt;
20 |
21 | #define OUTPUT_PLAIN 0
22 | #define OUTPUT_PRINTER 1
23 | #define OUTPUT_RTF 2
24 | #define OUTPUT_STYL 3
25 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/print.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "output.h"
3 |
4 | /* Low-level output functions */
5 |
6 | void null()
7 | {
8 | }
9 |
10 | void print_FF()
11 | {
12 | putchar('\014');
13 | }
14 |
15 | void plain_line(txt, style, len)
16 | char * txt, * style;
17 | int len;
18 | {
19 | fwrite(txt, 1, len, stdout);
20 | putchar('\n');
21 | }
22 |
23 | void printer_line(txt, style, len)
24 | char * txt, * style;
25 | int len;
26 | {
27 | for (/*nothing*/; len > 0; len--, txt++, style++) {
28 | putchar(*txt);
29 | switch(*style) {
30 | case ITALICS:
31 | putchar('\b'); putchar('_'); break;
32 | case BOLD:
33 | putchar('\b'); putchar(*txt); break;
34 | case MONOSPACED:
35 | if (standout_tt) { putchar('\b'); putchar(*txt); }
36 | break;
37 | }
38 | }
39 | putchar('\n');
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/print_rtf.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "output.h"
3 |
4 | /* Rich Text Format */
5 |
6 | void begin_rtf_document()
7 | {
8 | printf("{\\rtf1\\ansi\\deff0\n");
9 | printf("{\\fonttbl{\\f0\\fmodern Courier;}}\n");
10 | printf("\\f0\\fs20\n");
11 | }
12 |
13 | void end_rtf_document()
14 | {
15 | printf("}\n");
16 | }
17 |
18 | void end_rtf_page()
19 | {
20 | printf("\\page\n");
21 | }
22 |
23 | void rtf_line(txt, style, len)
24 | char * txt, * style;
25 | int len;
26 | {
27 | int currstyle;
28 |
29 | for (currstyle = PLAIN; len > 0; len--, txt++, style++) {
30 | if (*txt != ' ') {
31 | switch(*style) {
32 | case PLAIN:
33 | if (currstyle != PLAIN) {
34 | putchar('}');
35 | currstyle = PLAIN;
36 | }
37 | break;
38 | case ITALICS:
39 | if (currstyle != ITALICS) {
40 | if (currstyle != PLAIN) putchar('}');
41 | printf("{\\i ");
42 | currstyle = ITALICS;
43 | }
44 | break;
45 | case BOLD:
46 | if (currstyle != BOLD) {
47 | if (currstyle != PLAIN) putchar('}');
48 | printf("{\\b ");
49 | currstyle = BOLD;
50 | }
51 | break;
52 | case MONOSPACED:
53 | if (standout_tt) {
54 | if (currstyle != BOLD) {
55 | if (currstyle != PLAIN) putchar('}');
56 | printf("{\\b ");
57 | currstyle = BOLD;
58 | }
59 | } else {
60 | if (currstyle != PLAIN) {
61 | putchar('}');
62 | currstyle = PLAIN;
63 | }
64 | }
65 | break;
66 | }
67 | }
68 | switch(*txt) {
69 | case '\\':
70 | case '{':
71 | case '}':
72 | putchar('\\'); putchar(*txt); break;
73 | default:
74 | putchar(*txt); break;
75 | }
76 | }
77 | if (currstyle != PLAIN) putchar('}');
78 | printf("\\par\n");
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/tools/dvi_to_txt/print_styl.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "output.h"
5 |
6 | /* Macintosh STYL tables */
7 |
8 | extern char * input_name;
9 |
10 | static FILE * text;
11 | static FILE * styl;
12 | static int partnum = 0;
13 | static int currstyle;
14 | static int currstart;
15 | static int currpos;
16 |
17 | static void output_current_style()
18 | {
19 | int style_code;
20 |
21 | switch(currstyle) {
22 | case PLAIN:
23 | style_code = 0; break;
24 | case ITALICS:
25 | style_code = 2; break;
26 | case BOLD:
27 | style_code = 1 + 32; break; /* bold condensed */
28 | case MONOSPACED:
29 | style_code = standout_tt ? 1 + 32 : 0; break;
30 | }
31 | fprintf(styl, "%d %d Monaco %d 9 0 0 0\n", currstart, currpos, style_code);
32 | }
33 |
34 |
35 | static void output_style_change(newstyle)
36 | int newstyle;
37 | {
38 | if (!standout_tt && (newstyle == PLAIN && currstyle == MONOSPACED ||
39 | newstyle == MONOSPACED && currstyle == PLAIN)) {
40 | currstyle = newstyle;
41 | return;
42 | }
43 | output_current_style();
44 | currstyle = newstyle;
45 | currstart = currpos;
46 | }
47 |
48 | void begin_styl_page()
49 | {
50 | char name[1024], buffer[1024];
51 | int n;
52 |
53 | strcpy(name, input_name);
54 | n = strlen(name);
55 | if (n >= 4 && strcmp(name + n - 4, ".dvi") == 0) name[n - 4] = 0;
56 | partnum++;
57 | sprintf(buffer, "%s.%03d.txt", name, partnum);
58 | text = fopen(buffer, "w");
59 | if (text == NULL) { perror(buffer); exit(2); }
60 | sprintf(buffer, "%s.%03d.stl", name, partnum);
61 | styl = fopen(buffer, "w");
62 | if (styl == NULL) { perror(buffer); exit(2); }
63 | currstyle = PLAIN;
64 | currstart = 0;
65 | currpos = 0;
66 | }
67 |
68 | void end_styl_page()
69 | {
70 | output_current_style();
71 | fclose(text);
72 | fclose(styl);
73 | }
74 |
75 | void styl_line(txt, style, len)
76 | char * txt, * style;
77 | int len;
78 | {
79 | for (/*nothing*/; len > 0; len--, txt++, style++, currpos++) {
80 | putc(*txt, text);
81 | if (*txt != ' ' && *style != currstyle) {
82 | output_style_change(*style);
83 | }
84 | }
85 | putc('\n', text);
86 | currpos++;
87 | }
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/tools/fix_index.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # usage: fix_index.sh .idx
4 |
5 | # This script works around a hyperref bug: hyperref does not handle
6 | # quotes in \index arguments properly.
7 | #
8 | # Symptom:
9 | # When \index{-pipe-pipe@\verb`("|"|)`} appears in your .tex, the hyperref
10 | # package mangles it and produces this line in your .idx:
11 | # \indexentry{(-pipe-pipe)@\verb`("|hyperindexformat{\"}}{292}
12 | # instead of the expected:
13 | # \indexentry{(-pipe-pipe)@\verb`("|"|)`|hyperpage}{292}
14 | #
15 | # This is because it fails to handle quoted characters correctly.
16 | #
17 | # The workaround:
18 | # Look for the buggy line in the given .idx file and change it.
19 |
20 | # Note: this bug will happen every time you have a | (pipe) character
21 | # in an index entry (properly quoted with a " (double-quote) before it).
22 | # We fix only the one case that appears in the OCaml documentation.
23 | # We do not attempt a general solution because hyperref erases part
24 | # of the argument, so we cannot recover the correct string from its
25 | # output.
26 |
27 | # Note 2013-06-19:
28 | # The above was for the || operator in the stdlib's Pervasives module.
29 | # Now we have the same problem with the |> operator that was added
30 | # to the same module in commit 13739, hence the second special case.
31 |
32 | usage(){
33 | echo "usage: fix_index.sh .idx" >&2
34 | exit 2
35 | }
36 |
37 | case $# in
38 | 1) ;;
39 | *) usage;;
40 | esac
41 |
42 | ed "$1" <<'EOF'
43 | /-pipe-pipe/s/verb`("|hyperindexformat{\\"}/verb`("|"|)`|hyperpage/
44 | /-pipe-gt/s/verb`("|hyperindexformat{\\>)`}/verb`("|>)`|hyperpage/
45 | w
46 | q
47 | EOF
48 |
49 | case $? in
50 | 0) echo "fix_index.sh: fixed $1 successfully.";;
51 | *) echo "fix_index.sh: some error occurred."; exit 2;;
52 | esac
53 |
--------------------------------------------------------------------------------
/tools/format-intf:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 |
3 | $sep = "\246";
4 |
5 | $html = 0;
6 | if ($ARGV[0] eq "-html") {
7 | $html = 1;
8 | shift;
9 | }
10 |
11 | # Skip initial junk
12 |
13 | while(($_ = <>) && ! m/^\(\* Module \[(.*)\]:/) { }
14 | m/^\(\* Module \[(.*)\]:/;
15 | $modname = $1;
16 | chop;
17 | s/^\(\* *//;
18 | s/ *\*\) *$//;
19 | s/\[/{\\tt /g;
20 | s/\]/}/g;
21 | print "\\section{$_}\n\n";
22 | $label = $modname; $label =~ s/[^A-Za-z0-9]//g;
23 | print "\\label{s:$label}\n";
24 | print "\\index{$modname (module)@\\verb~$modname~ (module)}%\n\n";
25 | s/{\\tt //g;
26 | s/}//g;
27 | s/_//g;
28 | print "\\pdfsection{$_}\n\n";
29 |
30 | $incomment = 0;
31 | $inverbatim = 0;
32 |
33 | line:
34 | while(<>) {
35 | chop;
36 | last line if /^\s*\(\*--/;
37 | if (s/^\(\*- //) {
38 | s/ *\*\)$//;
39 | }
40 | if (m/^\s*\(\*\*\*\s*(.*)\*\)\s*$/) {
41 | if ($inverbatim) {
42 | do end_verbatim();
43 | }
44 | print "\\subsection*{", $1, "}\n";
45 | next line;
46 | }
47 | if (m/^\s*\(\*\*\s*(.*)\*\)\s*$/) {
48 | if ($inverbatim) {
49 | do end_verbatim();
50 | }
51 | print "\\subsubsection*{", $1, "}\n";
52 | next line;
53 | }
54 | if (s/^\s*\(\*//) {
55 | if ($inverbatim) {
56 | do end_verbatim();
57 | }
58 | print "\\begin{comment}\n";
59 | $incomment = 1;
60 | }
61 | if ($incomment) {
62 | $endcomment = s/\*\)\s*$//;
63 | if (m/^\s*\[\s*$/) {
64 | print "\\begin{restoreindent}\n" unless $html;
65 | print "\\begin{verbatim}\n";
66 | while (($_ = <>) && ! m/^\s*\]\s*$/) {
67 | print $_;
68 | }
69 | print "\\end{verbatim}\n";
70 | print "\\end{restoreindent}\n" unless $html;
71 | } else {
72 | if (s/^-//) {
73 | print "\\\\";
74 | print "[\\smallskipamount]" unless $html;
75 | }
76 | s/^\s*//;
77 | $count = 0;
78 | foreach $part (split(/(\\?[\[\]])/, $_)) {
79 | if ($part eq "[") {
80 | print ($count == 0 ? "\\verb$sep" : "[");
81 | $count++;
82 | } elsif ($part eq "]") {
83 | $count--;
84 | print ($count == 0 ? "$sep" : "]");
85 | } elsif ($part =~ m/^\\([\[\]])$/) {
86 | print $1;
87 | } else {
88 | print $part;
89 | }
90 | }
91 | }
92 | if ($endcomment) {
93 | print "\n\\end{comment}";
94 | $incomment = 0;
95 | $inverbatim = 0;
96 | }
97 | } else {
98 | next line if /^$/;
99 | if (! $inverbatim) {
100 | print "\\begin{verbatim}\n";
101 | $inverbatim = 1;
102 | }
103 | s/^external /val /;
104 | s/ = ("[^"]*"\s*)+$//;
105 | next line if /^\s*$/;
106 | s/^val \( ([^ )]+) \)/val (\1)/;
107 | {
108 | do indexentry($1, " (operator)"), last
109 | if (m/^val \(([^)]*)\)/);
110 | do indexentry($1, ""), last
111 | if (m/^val ([a-zA-Z0-9_']*)/);
112 | do indexentry($1, " (type)"), last
113 | if (m/^type\s.*([a-zA-Z0-9_']*)\s*=/);
114 | do indexentry($1, " (exception)"), last
115 | if (m/^exception ([a-zA-Z0-9_']*)/);
116 | do indexentry($1, " (module type)"), last
117 | if (m/^module type ([a-zA-Z0-9_']*)/);
118 | do indexentry($1, " (functor)"), last
119 | if (m/^module ([a-zA-Z0-9_']*)\s*\(/);
120 | do indexentry($1, " (module)"), last
121 | if (m/^module ([a-zA-Z0-9_']*)/);
122 | }
123 | print $_;
124 | }
125 | print "\n";
126 | }
127 | do end_verbatim() if $inverbatim;
128 | print "\\end{comment}\n" if $incomment;
129 |
130 | sub indexentry {
131 | local ($_, $comment) = @_;
132 | return if m/^$/ || m/^[a-zA-Z]$/;
133 | s/([@|!])/"$1/g;
134 | if (! m|`|) {
135 | $s = "`";
136 | } elsif (! m|~|) {
137 | $s = "~";
138 | } elsif (! m/\|/) {
139 | $s = "|";
140 | } else {
141 | die("Can't find quote character for $_");
142 | }
143 | push (@index, "\\index{$_$comment@\\verb$s$_$s$comment}");
144 | }
145 |
146 | sub end_verbatim {
147 | print "\\end{verbatim}\n";
148 | foreach $idx (@index) {
149 | print $idx, "%\n";
150 | }
151 | undef(@index);
152 | $inverbatim = 0;
153 | }
154 |
--------------------------------------------------------------------------------
/tools/htmlcut:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/perl
2 | # Split an HTML file into smaller nodes.
3 | # Split at headers and also at some headers.
4 |
5 | $h0 = "H0";
6 | $h1 = "H1";
7 | $h2 = "H2";
8 |
9 | # Parse options
10 |
11 | option:
12 | while(1) {
13 | $_ = $ARGV[0];
14 | if (/^-([0-9]+)$/) {
15 | $split2[$1] = 1;
16 | }
17 | elsif (/^-article/) {
18 | $h0 = "H1";
19 | $h1 = "H2";
20 | $h2 = "H3";
21 | }
22 | else {
23 | last option;
24 | }
25 | shift(@ARGV);
26 | }
27 |
28 | $infile = $ARGV[0];
29 |
30 | # Find URL's for the links
31 |
32 | $level0 = 0;
33 | $level1 = 0;
34 | $uselabel = 1;
35 | open(INPUT, $infile);
36 | while( ) {
37 | if (m|^<$h0>(.*)$h0>|o) {
38 | $level0++;
39 | $currfile = "node" . ($level1 + 1) . ".html";
40 | $lblnum = $level0;
41 | $uselabel = 0;
42 | }
43 | if (m|^<$h1>(.*)$h1>|o) {
44 | $level1++;
45 | $level2 = 0;
46 | $currfile = "node$level1.html";
47 | $lblnum = $level1;
48 | $uselabel = 1;
49 | }
50 | if (m|^<$h2>(.*)$h2>|o) {
51 | $level2++;
52 | if ($split2[$level1]) { $currfile = "node$level1.$level2.html"; }
53 | $lblnum = "$level1.$level2";
54 | }
55 | s| |do set_url($1)|ige;
56 | }
57 |
58 | sub set_url {
59 | local ($lbl) = @_;
60 | if ($uselabel) {
61 | $url{$lbl} = "$currfile#$lbl";
62 | } else {
63 | $url{$lbl} = $currfile;
64 | }
65 | $label{$lbl} = $lblnum;
66 | }
67 |
68 | # Cut the file
69 |
70 | $level1 = 0;
71 | open(INPUT, $infile);
72 | while( ) {
73 | if (m|^<$h0>(.*)$h0>|o) {
74 | if ($level2 > 0) { print FILE1 "\n"; }
75 | select(STDOUT);
76 | if ($level1 >= 1) { print ""; }
77 | print "<$h2>$1$h2>\n";
78 | if ($level1 >= 1) { print ""; }
79 | next;
80 | }
81 | if (m|^<$h1>(.*)$h1>|o) {
82 | if ($level2 > 0) { print FILE1 " \n"; }
83 | $level1++;
84 | $level2 = 0;
85 | select(STDOUT);
86 | if ($level1 == 1) { print "\n"; }
87 | print "$1 \n";
88 | open(FILE1, "> node$level1.html");
89 | select(FILE1);
90 | &print_title($1);
91 | }
92 | if ($split2[$level1] && m|^<$h2>(.*)$h2>|o) {
93 | $level2++;
94 | select(FILE1);
95 | if ($level2 == 1) { print "\n"; }
96 | print "$1 \n";
97 | open(FILE2, "> node$level1.$level2.html");
98 | select(FILE2);
99 | &print_title($1);
100 | }
101 | s|X |'' . $label{$1} . ' '|ige;
102 | print $_;
103 | }
104 | select(STDOUT);
105 | if ($level1 >= 1) { print " \n"; }
106 |
107 | sub print_title {
108 | local ($title) = @_;
109 | $title =~ s|<[a-zA-Z/]+>||g;
110 | print "$title \n";
111 | }
112 |
--------------------------------------------------------------------------------
/tools/htmlquote.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #define LINE_LENGTH 1024
5 |
6 | char line[LINE_LENGTH];
7 |
8 | int isprefix(s, pref)
9 | char * s;
10 | char * pref;
11 | {
12 | while (1) {
13 | if (*pref == 0) return 1;
14 | if (*s == 0) return 0;
15 | if (*s != *pref) return 0;
16 | s++;
17 | pref++;
18 | }
19 | }
20 |
21 | int main(argc, argv)
22 | int argc;
23 | char * argv [];
24 | {
25 | unsigned char * p;
26 | int c;
27 | int inquote;
28 | int inverb;
29 | int inverbatim;
30 |
31 | inverbatim = 0;
32 | inquote = 0;
33 |
34 | while(fgets(line, LINE_LENGTH, stdin) != NULL) {
35 | if (inverbatim) {
36 | fputs(line, stdout);
37 | if (isprefix(line, "\\end{verbatim")
38 | || isprefix(line, "\\end{alltt}")) inverbatim = 0;
39 | continue;
40 | }
41 | if (isprefix(line, "\\begin{verbatim")
42 | || isprefix(line, "\\begin{alltt}")) {
43 | fputs(line, stdout);
44 | inverbatim = 1;
45 | continue;
46 | }
47 | inverb = 0;
48 | for (p = (unsigned char *) line; *p != 0; p++) {
49 | c = *p;
50 | if (inverb) {
51 | if (c == inverb) inverb = 0;
52 | putchar(c);
53 | continue;
54 | }
55 | switch(c) {
56 | case '"':
57 | if (inquote) {
58 | fputs("\001", stdout);
59 | inquote = 0;
60 | } else {
61 | fputs("\\verb\001", stdout);
62 | inquote = 1;
63 | }
64 | break;
65 | case '\\':
66 | if (isprefix(p, "\\verb") && p[5] != 0 && !isalpha(p[5])) {
67 | inverb = p[5];
68 | p = p + 5;
69 | fputs("\\verb", stdout);
70 | putchar(inverb);
71 | } else if (inquote) {
72 | if (p[1] == '"' || p[1] == '\\') {
73 | c = p[1];
74 | p++;
75 | }
76 | putchar(c);
77 | } else {
78 | putchar('\\');
79 | }
80 | break;
81 | default:
82 | putchar(c);
83 | }
84 | }
85 | }
86 | return 0;
87 | }
88 |
--------------------------------------------------------------------------------
/tools/htmltbl:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/perl
2 |
3 | while (<>) {
4 | if (m|^ ]|) {
5 | while (! m| $|) { $_ .= <>; }
6 | s/\n//g;
7 | print "\n";
8 | do format_table($_);
9 | print " \n";
10 | } else {
11 | print $_;
12 | }
13 | }
14 |
15 | sub format_table {
16 | # On input, $_ contains:
17 | # Header 1 Header2 ... Header M
18 | # Data11 Data12 ... Data1M
19 | # ...
20 | # DataN1 DataN2 ... DataNM
21 | #
22 |
23 | # Extract the entries and compute the number of lines and columns
24 |
25 | $numlines = 0;
26 | $numcols = 0;
27 | $border = 0;
28 | $header = 0;
29 | $x = 0;
30 | $y = 0;
31 | foreach $_ (split(/(|| | |<\/tbl>)/, $_)) {
32 | if (/^$/) { next; }
33 | elsif (//) { $border = 1; }
34 | elsif (//i) {
35 | if ($x > $numcols) { $numcols = $x; }
36 | $x = 0;
37 | $y++;
38 | }
39 | elsif (//) { $header = 1; }
40 | elsif (!/(|| | |<\/tbl>)/) {
41 | s|?[a-zA-Z]*>||g; # Remove embedded tags
42 | s/^\s*//; # and initial blanks
43 | s/\s*$//; # and final blanks
44 | s/\s\s\s*/ /g; # and extra blanks
45 | s/<//g;
47 | s/&/&/g;
48 | $entry{$x, $y} = $_;
49 | $x++;
50 | }
51 | }
52 | $numlines = $y;
53 |
54 | # Compute the max width of each column
55 |
56 | $totalwidth = 0;
57 |
58 | for ($x = 0; $x < $numcols; $x++) {
59 | $max = 0;
60 | for ($y = 0; $y < $numlines; $y++) {
61 | $len = length($entry{$x, $y});
62 | if ($len > $max) { $max = $len; }
63 | }
64 | $width[$x] = $max;
65 | $totalwidth += $max;
66 | }
67 |
68 | # If it does not fit in one line, turn wide fields into multi-line fields
69 |
70 | if ($totalwidth >= 65) {
71 | $totalwidth = 0;
72 | $maxwidth = 65 / $numcols;
73 | for ($x = 0; $x < $numcols; $x++) {
74 | if ($width[$x] > $maxwidth) {
75 | if ($x < $numcols - 1) {
76 | $width[$x] = $maxwidth;
77 | } else {
78 | $width[$x] = 70 - $totalwidth;
79 | }
80 | }
81 | $totalwidth += $width[$x];
82 | }
83 | }
84 |
85 | # Compute the separators
86 |
87 | if ($border) {
88 | $horsep = '+-';
89 | for ($x = 0; $x < $numcols; $x++) {
90 | if ($x > 0) { $horsep .= '-+-'; }
91 | $horsep .= '-' x $width[$x];
92 | }
93 | $horsep .= '-+';
94 | $verleft = '| ';
95 | $versep = ' | ';
96 | $verright = ' |';
97 | } else {
98 | $horsep = '';
99 | $verleft = ' ';
100 | $versep = ' ';
101 | $verright = ' ';
102 | }
103 |
104 | # Print the table
105 | print $horsep, "\n";
106 | for ($y = 0; $y < $numlines; $y++) {
107 | do {
108 | $overflow = 0;
109 | print $verleft;
110 | for ($x = 0; $x < $numcols; $x++) {
111 | if ($x > 0) { print $versep; }
112 | $_ = $entry{$x, $y};
113 | if (length($_) > $width[$x]) {
114 | $pos = rindex($_, ' ', $width[$x]);
115 | if ($pos < 0) { $pos = $width[$x]; } else { $pos++; }
116 | $entry{$x, $y} = substr($_, $pos);
117 | $_ = substr($_, 0, $pos - 1);
118 | $overflow = 1;
119 | } else {
120 | $entry{$x, $y} = '';
121 | }
122 | $len = length($_);
123 | s/&/&/g;
124 | s/</g;
125 | s/>/>/g;
126 | print $_, ' ' x ($width[$x] - $len);
127 | }
128 | print $verright, "\n";
129 | } while($overflow);
130 | if ($header && $y == 0) { print $horsep, "\n"; }
131 | }
132 | print $horsep, "\n";
133 | }
134 |
135 |
--------------------------------------------------------------------------------
/tools/htmlthread:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/perl
2 | # Insert Next/Previous/Contents buttons in a set of pages.
3 |
4 | @pages = sort fragmentorder @ARGV;
5 |
6 | sub fragmentorder {
7 | $a =~ /^node([0-9]+)/; $na = $1;
8 | if ($a =~ /^node[0-9]+\.([0-9]+)\.html/) { $fa = $1; } else { $fa = 0; }
9 | $b =~ /^node([0-9]+)/; $nb = $1;
10 | if ($b =~ /^node[0-9]+\.([0-9]+)\.html/) { $fb = $1; } else { $fb = 0; }
11 | return (($na <=> $nb) || ($fa <=> $fb));
12 | }
13 |
14 | for ($i = 0; $i <= $#pages; $i++) {
15 | open(SRC, $pages[$i]);
16 | open(DST, "> newpage.html");
17 | select(DST);
18 | $_ = ; # Title line
19 | print "\n";
20 | print $_;
21 | do links();
22 | print "\n";
23 | print "\n";
24 | do buttons();
25 | print " \n";
26 | $numlines = 0;
27 | while () {
28 | $numlines++;
29 | print $_;
30 | }
31 | if ($numlines >= 40) {
32 | print " \n";
33 | do buttons();
34 | }
35 | close(SRC);
36 | close(DST);
37 | rename("newpage.html", $pages[$i]);
38 | }
39 |
40 | sub links {
41 | if ($i > 0) {
42 | print ' \n";
43 | }
44 | if ($i < $#pages) {
45 | print ' \n";
46 | }
47 | print " \n";
48 | }
49 |
50 | sub buttons {
51 | if ($i > 0) {
52 | print ' ', "\n";
53 | }
54 | if ($i < $#pages) {
55 | print ' ', "\n";
56 | }
57 | print ' ', "\n";
58 | }
59 |
--------------------------------------------------------------------------------
/tools/htmltransf.mll:
--------------------------------------------------------------------------------
1 | {
2 | open Lexing;;
3 |
4 | let need_space =
5 | ref false;;
6 |
7 | let addspace () =
8 | if !need_space then begin print_char ' '; need_space := false end;;
9 | }
10 |
11 | rule main = parse
12 | "\\begin{syntax}" {
13 | print_string "\\begin{rawhtml}\n\n";
14 | need_space := false;
15 | syntax lexbuf;
16 | print_string " \n\\end{rawhtml}\n";
17 | main lexbuf }
18 | | "\\@" {
19 | print_string "@";
20 | main lexbuf }
21 | | "@" {
22 | print_string "%\n\\begin{rawhtml}";
23 | need_space := false;
24 | syntax lexbuf;
25 | print_string "\\end{rawhtml}%\n";
26 | main lexbuf }
27 | | _ {
28 | print_char (lexeme_char lexbuf 0); main lexbuf }
29 | | eof {
30 | () }
31 |
32 | and syntax = parse
33 | "\\end{syntax}" { () }
34 | | "@" { () }
35 | | '\'' {
36 | addspace();
37 | print_string "";
38 | inquote lexbuf;
39 | print_string "
";
40 | need_space := true;
41 | syntax lexbuf }
42 | | '\"' {
43 | addspace();
44 | print_string "";
45 | indoublequote lexbuf;
46 | print_string "
";
47 | need_space := true;
48 | syntax lexbuf }
49 | | ['a'-'z'] ['a'-'z' '0'-'9' '-'] * {
50 | addspace();
51 | print_string "";
52 | print_string (lexeme lexbuf);
53 | print_string " ";
54 | need_space := true;
55 | syntax lexbuf }
56 | | '\\' ['a'-'z''A'-'Z'] + {
57 | begin match lexeme lexbuf with
58 | "\\ldots" -> print_string "..."; need_space := false
59 | | s -> Printf.eprintf "Warning: %s ignored.\n" s
60 | end;
61 | syntax lexbuf }
62 | | '_' _ {
63 | print_string "";
64 | print_char(lexeme_char lexbuf 1);
65 | print_string " ";
66 | syntax lexbuf }
67 | | '^' _ {
68 | print_string "";
69 | print_char(lexeme_char lexbuf 1);
70 | print_string " ";
71 | syntax lexbuf }
72 | | ":" {
73 | print_string ":\n ";
74 | need_space := false;
75 | syntax lexbuf }
76 | | "|" {
77 | print_string "\n | ";
78 | need_space := false;
79 | syntax lexbuf }
80 | | ";" {
81 | print_string "\n\n";
82 | need_space := false;
83 | syntax lexbuf }
84 | | [ '{' '[' '('] {
85 | addspace(); print_string (lexeme lexbuf); syntax lexbuf }
86 | | [ '}' ']' ')'] {
87 | print_string (lexeme lexbuf); syntax lexbuf }
88 | | "{{" {
89 | addspace(); print_string "{"; syntax lexbuf }
90 | | "}}" {
91 | print_string "}+"; syntax lexbuf }
92 | | "||" {
93 | print_string " | "; need_space := false; syntax lexbuf }
94 | | [ ' ' '\n' '\t' '~'] {
95 | syntax lexbuf }
96 | | [ ',' ] {
97 | print_char(lexeme_char lexbuf 0); syntax lexbuf }
98 | | _ {
99 | Printf.eprintf "Warning: %s ignored at char %d.\n"
100 | (lexeme lexbuf) (lexeme_start lexbuf);
101 | syntax lexbuf }
102 |
103 | and inquote = parse
104 | '\'' { () }
105 | | '&' { print_string "&"; inquote lexbuf }
106 | | '<' { print_string "<"; inquote lexbuf }
107 | | '>' { print_string ">"; inquote lexbuf }
108 | | _ { print_char (lexeme_char lexbuf 0); inquote lexbuf }
109 |
110 | and indoublequote = parse
111 | '"' { () }
112 | | '&' { print_string "&"; indoublequote lexbuf }
113 | | '<' { print_string "<"; indoublequote lexbuf }
114 | | '>' { print_string ">"; indoublequote lexbuf }
115 | | _ { print_char (lexeme_char lexbuf 0); indoublequote lexbuf }
116 |
117 |
118 |
--------------------------------------------------------------------------------
/tools/latexmacros.ml:
--------------------------------------------------------------------------------
1 | type action =
2 | Print of string
3 | | Print_arg
4 | | Skip_arg;;
5 |
6 | let cmdtable = (Hashtbl.create 19 : (string, action list) Hashtbl.t);;
7 |
8 | let def_macro name action =
9 | Hashtbl.add cmdtable name action;;
10 |
11 | let find_macro name =
12 | try
13 | Hashtbl.find cmdtable name
14 | with Not_found ->
15 | prerr_string "Unknown macro: "; prerr_endline name; [];;
16 |
17 | (* General LaTeX macros *)
18 |
19 | def_macro "\\part"
20 | [Print ""; Print_arg; Print " \n"];
21 | def_macro "\\chapter"
22 | [Print ""; Print_arg; Print " \n"];
23 | def_macro "\\chapter*"
24 | [Print ""; Print_arg; Print " \n"];
25 | def_macro "\\section"
26 | [Print ""; Print_arg; Print " \n"];
27 | def_macro "\\section*"
28 | [Print ""; Print_arg; Print " \n"];
29 | def_macro "\\subsection"
30 | [Print ""; Print_arg; Print " \n"];
31 | def_macro "\\subsection*"
32 | [Print ""; Print_arg; Print " \n"];
33 | def_macro "\\subsubsection"
34 | [Print ""; Print_arg; Print " \n"];
35 | def_macro "\\subsubsection*"
36 | [Print ""; Print_arg; Print " \n"];
37 | def_macro "\\paragraph"
38 | [Print ""; Print_arg; Print " \n"];
39 | def_macro "\\begin{alltt}" [Print ""];
40 | def_macro "\\end{alltt}" [Print " "];
41 | def_macro "\\begin{itemize}" [Print "
"];
42 | def_macro "\\end{itemize}" [Print " "];
43 | def_macro "\\begin{enumerate}" [Print "
"];
44 | def_macro "\\end{enumerate}" [Print " "];
45 | def_macro "\\begin{description}" [Print "
"];
46 | def_macro "\\end{description}" [Print " "];
47 | def_macro "\\begin{center}" [Print ""];
48 | def_macro "\\end{center}" [Print " "];
49 | def_macro "\\begin{quote}" [Print ""];
50 | def_macro "\\end{quote}" [Print " "];
51 | def_macro "\\begin{quotation}" [Print ""];
52 | def_macro "\\end{quotation}" [Print " "];
53 | def_macro "\\smallskip" [];
54 | def_macro "\\medskip" [];
55 | def_macro "\\bigskip" [];
56 | def_macro "\\markboth" [Skip_arg; Skip_arg];
57 | def_macro "\\ldots" [Print "..."];
58 | def_macro "\\ " [Print " "];
59 | def_macro "\\{" [Print "{"];
60 | def_macro "\\}" [Print "}"];
61 | def_macro "\\%" [Print "%"];
62 | def_macro "\\$" [Print "$"];
63 | def_macro "\\#" [Print "#"];
64 | def_macro "\\/" [];
65 | def_macro "\\newpage" [];
66 | def_macro "\\label" [Print " "];
67 | def_macro "\\ref" [Print "X "];
68 | def_macro "\\pageref" [Print "X "];
69 | def_macro "\\index" [Skip_arg];
70 | def_macro "\\oe" [Print "oe"];
71 | def_macro "\\&" [Print "&"];
72 | def_macro "\\_" [Print "_"];
73 | def_macro "\\leq" [Print "<="];
74 | def_macro "\\geq" [Print ">="];
75 | def_macro "\\hbox" [Print_arg];
76 | def_macro "\\copyright" [Print "\169"];
77 | def_macro "\\noindent" [];
78 | def_macro "\\begin{flushleft}" [Print ""];
79 | def_macro "\\end{flushleft}" [Print " "];
80 | def_macro "\\\\" [Print " "];
81 | def_macro "\\begin{htmlonly}" [];
82 | def_macro "\\end{htmlonly}" [];
83 | ();;
84 |
85 | (* Macros specific to the Caml manual *)
86 |
87 | def_macro "\\begin{options}" [Print "
"];
88 | def_macro "\\end{options}" [Print " "];
89 | def_macro "\\var" [Print ""; Print_arg; Print " "];
90 | def_macro "\\optvar" [Print "["; Print_arg; Print " ]"];
91 | def_macro "\\nth" [Print ""; Print_arg;
92 | Print " "; Print_arg; Print " "];
93 | def_macro "\\nmth" [Print ""; Print_arg;
94 | Print " "; Print_arg;
95 | Print " "; Print_arg;
96 | Print " "];
97 | def_macro "\\begin{unix}" [Print "Unix: "];
98 | def_macro "\\end{unix}" [Print " "];
99 | def_macro "\\begin{macos}" [Print "MacOS: "];
100 | def_macro "\\end{macos}" [Print " "];
101 | def_macro "\\begin{windows}" [Print "Windows: "];
102 | def_macro "\\end{windows}" [Print " "];
103 | def_macro "\\begin{requirements}" [Print "Requirements: "];
104 | def_macro "\\end{requirements}" [Print " "];
105 | def_macro "\\begin{troubleshooting}" [Print "Troubleshooting: "];
106 | def_macro "\\end{troubleshooting}" [Print " "];
107 | def_macro "\\begin{installation}" [Print "Installation: "];
108 | def_macro "\\end{installation}" [Print " "];
109 | def_macro "\\index" [Skip_arg];
110 | def_macro "\\ikwd" [Skip_arg];
111 | def_macro "\\th" [Print "-th"];
112 | def_macro "\\begin{library}" [];
113 | def_macro "\\end{library}" [];
114 | def_macro "\\begin{comment}" [Print ""];
115 | def_macro "\\end{comment}" [Print " "];
116 | def_macro "\\begin{tableau}"
117 | [Skip_arg;
118 | Print "\n";
119 | Print_arg;
120 | Print " ";
121 | Print_arg;
122 | Print " "];
123 | def_macro "\\entree"
124 | [Print ""; Print_arg;
125 | Print " "; Print_arg; Print " "];
126 | def_macro "\\end{tableau}" [Print "
"];
127 | def_macro "\\begin{gcrule}" [Print "Rule: "];
128 | def_macro "\\end{gcrule}" [Print " "];
129 | def_macro "\\begin{tableauoperateurs}"
130 | [Print "\nOperator Associated ident Behavior in the default environment "];
131 | def_macro "\\end{tableauoperateurs}" [Print "
\n"];
132 | def_macro "\\entreeoperateur"
133 | [Print ""; Print_arg; Print " "; Print_arg;
134 | Print " "; Print_arg; Print " "];
135 | def_macro "\\fromoneto"
136 | [Print ""; Print_arg; Print " = 1, ..., ";
137 | Print_arg; Print " "];
138 | def_macro "\\caml" [Print ""];
139 | def_macro "\\endcaml" [Print " "];
140 | def_macro "\\<" [Print ""];
141 | def_macro "\\>" [Print " "];
142 | def_macro "\\rminalltt" [Print_arg];
143 | def_macro "\\event" [Print "* "];
144 | def_macro "\\pdfchapter" [Skip_arg];
145 | def_macro "\\pdfchapterfold" [Skip_arg; Skip_arg];
146 | def_macro "\\pdfsection" [Skip_arg];
147 | def_macro "\\transl" [Print "<"; Print_arg; Print ">"];
148 | ();;
149 |
150 |
--------------------------------------------------------------------------------
/tools/latexmacros.mli:
--------------------------------------------------------------------------------
1 | type action =
2 | Print of string
3 | | Print_arg
4 | | Skip_arg;;
5 |
6 | val find_macro: string -> action list;;
7 |
8 | val def_macro: string -> action list -> unit;;
9 |
--------------------------------------------------------------------------------
/tools/latexmain.ml:
--------------------------------------------------------------------------------
1 | let main () =
2 | Latexscan.main (Lexing.from_channel stdin);;
3 |
4 | Printexc.print main (); exit 0;;
5 |
--------------------------------------------------------------------------------
/tools/latexscan.mll:
--------------------------------------------------------------------------------
1 | {
2 | open Lexing;;
3 | open Latexmacros;;
4 |
5 | let delimiter = ref (char_of_int 0);;
6 |
7 | let upto delim lexfun lexbuf =
8 | let old_delim = !delimiter in
9 | delimiter := delim;
10 | lexfun lexbuf;
11 | delimiter := old_delim;;
12 |
13 | let verb_delim = ref (char_of_int 0);;
14 |
15 | let brace_nesting = ref 0;;
16 |
17 | let rindex c s =
18 | let rec find i =
19 | if i < 0 then raise Not_found else
20 | if s.[i] = c then i else find (i-1) in
21 | find (String.length s - 1);;
22 |
23 | let first_caml_line = ref true;;
24 | let in_caml = ref false;;
25 | }
26 |
27 | rule main = parse
28 | (* Comments *)
29 | '%' [^ '\n'] * '\n' { main lexbuf }
30 | (* Paragraphs *)
31 | | "\n\n" '\n' *
32 | { print_string "\n"; main lexbuf }
33 | (* Font changes *)
34 | | "{\\it" " "* | "{\\em" " "*
35 | { print_string ""; upto '}' main lexbuf;
36 | print_string " "; main lexbuf }
37 | | "{\\bf" " "* { print_string ""; upto '}' main lexbuf;
38 | print_string " "; main lexbuf }
39 | | "{\\rm" " "* { print_string ""; upto '}' main lexbuf;
40 | print_string " "; main lexbuf }
41 | | "{\\tt" " "* { print_string ""; upto '}' main lexbuf;
42 | print_string " "; main lexbuf }
43 | | '"' { print_string ""; indoublequote lexbuf;
44 | print_string " "; main lexbuf }
45 | (* Verb, verbatim *)
46 | | "\\verb" _ { verb_delim := lexeme_char lexbuf 5;
47 | print_string ""; inverb lexbuf; print_string " ";
48 | main lexbuf }
49 | | "\\begin{verbatim}"
50 | { print_string "
"; inverbatim lexbuf;
51 | print_string " "; main lexbuf }
52 | (* Caml programs *)
53 | | "\\caml"
54 | { print_string "";
55 | first_caml_line := true; in_caml := false;
56 | camlprog lexbuf; print_string " "; main lexbuf }
57 | (* Raw html, latex only *)
58 | | "\\begin{rawhtml}"
59 | { rawhtml lexbuf; main lexbuf }
60 | | "\\begin{latexonly}"
61 | { latexonly lexbuf; main lexbuf }
62 | (* Itemize and similar environments *)
63 | | "\\item[" { print_string ""; upto ']' main lexbuf;
64 | print_string " "; main lexbuf }
65 | | "\\item" { print_string ""; main lexbuf }
66 | (* Math mode (hmph) *)
67 | | "$" { main lexbuf }
68 | (* Special characters *)
69 | | "\\char" ['0'-'9']+
70 | { let lxm = lexeme lexbuf in
71 | let code = String.sub lxm 5 (String.length lxm - 5) in
72 | print_char(char_of_int(int_of_string code));
73 | main lexbuf }
74 | | "<" { print_string "<"; main lexbuf }
75 | | ">" { print_string ">"; main lexbuf }
76 | | "~" { print_string " "; main lexbuf }
77 | (* Definitions of very simple macros *)
78 | | "\\def\\" (['A'-'Z' 'a'-'z']+ | [^ 'A'-'Z' 'a'-'z']) "{" [^ '{' '}']* "}"
79 | { let s = lexeme lexbuf in
80 | let l = String.length s in
81 | let p = rindex '{' s in
82 | let name = String.sub s 4 (p - 4) in
83 | let expansion = String.sub s (p + 1) (l - p - 2) in
84 | def_macro name [Print expansion];
85 | main lexbuf }
86 | (* General case for environments and commands *)
87 | | ("\\begin{" | "\\end{") ['A'-'Z' 'a'-'z']+ "}" |
88 | "\\" (['A'-'Z' 'a'-'z']+ '*'? | [^ 'A'-'Z' 'a'-'z'])
89 | { let exec_action = function
90 | Print str -> print_string str
91 | | Print_arg -> print_arg lexbuf
92 | | Skip_arg -> skip_arg lexbuf in
93 | List.iter exec_action (find_macro(lexeme lexbuf));
94 | main lexbuf }
95 | (* Default rule for other characters *)
96 | | eof { () }
97 | | _ { let c = lexeme_char lexbuf 0 in
98 | if c == !delimiter then () else (print_char c; main lexbuf) }
99 |
100 | and indoublequote = parse
101 | '"' { () }
102 | | "<" { print_string "<"; indoublequote lexbuf }
103 | | ">" { print_string ">"; indoublequote lexbuf }
104 | | "&" { print_string "&"; indoublequote lexbuf }
105 | | "\\\"" { print_string "\""; indoublequote lexbuf }
106 | | "\\\\" { print_string "\\"; indoublequote lexbuf }
107 | | _ { print_char(lexeme_char lexbuf 0); indoublequote lexbuf }
108 |
109 | and inverb = parse
110 | "<" { print_string "<"; inverb lexbuf }
111 | | ">" { print_string ">"; inverb lexbuf }
112 | | "&" { print_string "&"; inverb lexbuf }
113 | | _ { let c = lexeme_char lexbuf 0 in
114 | if c == !verb_delim then ()
115 | else (print_char c; inverb lexbuf) }
116 | and inverbatim = parse
117 | "<" { print_string "<"; inverbatim lexbuf }
118 | | ">" { print_string ">"; inverbatim lexbuf }
119 | | "&" { print_string "&"; inverbatim lexbuf }
120 | | "\\end{verbatim}" { () }
121 | | _ { print_char(lexeme_char lexbuf 0); inverbatim lexbuf }
122 |
123 | and camlprog = parse
124 | "<" { print_string "<"; camlprog lexbuf }
125 | | ">" { print_string ">"; camlprog lexbuf }
126 | | "&" { print_string "&"; camlprog lexbuf }
127 | | "\\?" { if !first_caml_line then begin
128 | print_string "# ";
129 | first_caml_line := false
130 | end else
131 | print_string " ";
132 | in_caml := true;
133 | camlprog lexbuf }
134 | | "\\:" { print_string "";
135 | in_caml := true;
136 | camlprog lexbuf }
137 | | "\\;" { first_caml_line := true; camlprog lexbuf }
138 | | "\\\\" { print_string "\\"; camlprog lexbuf }
139 | | "\\endcaml" { () }
140 | | "\n" { if !in_caml then begin
141 | print_string " ";
142 | in_caml := false
143 | end;
144 | print_char '\n';
145 | camlprog lexbuf }
146 | | _ { print_char(lexeme_char lexbuf 0); camlprog lexbuf }
147 |
148 | and rawhtml = parse
149 | "\\end{rawhtml}" { () }
150 | | _ { print_char(lexeme_char lexbuf 0); rawhtml lexbuf }
151 |
152 | and latexonly = parse
153 | "\\end{latexonly}" { () }
154 | | _ { latexonly lexbuf }
155 |
156 | and print_arg = parse
157 | [' ' '\n'] * "{" { upto '}' main lexbuf }
158 | | _ { print_char(lexeme_char lexbuf 0); rawhtml lexbuf }
159 |
160 | and skip_arg = parse
161 | "{" { incr brace_nesting; skip_arg lexbuf }
162 | | "}" { decr brace_nesting;
163 | if !brace_nesting > 0 then skip_arg lexbuf }
164 | | _ { skip_arg lexbuf }
165 |
166 |
167 |
--------------------------------------------------------------------------------
/tools/texexpand:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/perl
2 | # Expand \input commands
3 |
4 | @path = split(/:/, $ENV{'TEXINPUTS'});
5 |
6 | while(<>) {
7 | if (/^\\input\s*([^\s]*)/) {
8 | do expand($1);
9 | } else {
10 | print $_;
11 | }
12 | }
13 |
14 | sub expand {
15 | local ($filename) = @_;
16 | local (*INPUT);
17 | $filename =~ s/\.tex$//;
18 | $filename = do find_in_path($filename);
19 | open(INPUT, $filename) || (warn("cannot find $filename"), return);
20 | print "%%% $filename\n";
21 | while( ) {
22 | if (/^\\input\s*([^\s]*)/) {
23 | do expand($1);
24 | } else {
25 | print $_;
26 | }
27 | }
28 | close(INPUT);
29 | }
30 |
31 | sub find_in_path {
32 | local ($name) = @_;
33 | local ($dir);
34 | foreach $dir (@path) {
35 | return "$dir/$name.htex" if (-f "$dir/$name.htex");
36 | return "$dir/$name.tex" if (-f "$dir/$name.tex");
37 | }
38 | return $name;
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/tools/texquote2.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | char * transl[256];
5 |
6 | #define LINE_LENGTH 1024
7 |
8 | char line[LINE_LENGTH];
9 |
10 | int isprefix(s, pref)
11 | char * s;
12 | char * pref;
13 | {
14 | while (1) {
15 | if (*pref == 0) return 1;
16 | if (*s == 0) return 0;
17 | if (*s != *pref) return 0;
18 | s++;
19 | pref++;
20 | }
21 | }
22 |
23 | int main(argc, argv)
24 | int argc;
25 | char * argv [];
26 | {
27 | unsigned char * p;
28 | int c;
29 | int inquote;
30 | int inverb;
31 | int inverbatim_like;
32 | int incaml;
33 | int inverbatim = 0;
34 | char *verbatim_end_in = "";
35 | char *verbatim_end_out = "";
36 |
37 | for (c = 0; c < 256; c++) transl[c] = NULL;
38 | #ifdef TIE_BLANKS
39 | transl[' '] = "~";
40 | transl['\n'] = "~";
41 | #else
42 | transl[' '] = "\\ ";
43 | transl['\n'] = "\\ ";
44 | #endif
45 | transl['{'] = "{\\char123}";
46 | transl['}'] = "{\\char125}";
47 | transl['^'] = "{\\char94}";
48 | transl['_'] = "{\\char95}";
49 | transl['\\'] = "{\\char92}";
50 | transl['~'] = "{\\char126}";
51 | transl['$'] = "\\$";
52 | transl['&'] = "{\\char38}";
53 | transl['#'] = "\\#";
54 | transl['%'] = "\\%";
55 | transl['\''] = "{\\textquotesingle}";
56 | transl['`'] = "{\\textasciigrave}";
57 | inverbatim_like = 0;
58 | incaml = 0;
59 | inquote = 0;
60 | inverbatim = 0;
61 |
62 | puts ("% THIS FILE IS GENERATED.\n");
63 |
64 | while(fgets(line, LINE_LENGTH, stdin) != NULL) {
65 | if (inverbatim_like) {
66 | fputs(line, stdout);
67 | if (isprefix(line, "\\end{caml_")
68 | || isprefix(line, "\\end{rawhtml}")) inverbatim_like = 0;
69 | continue;
70 | }
71 | if (incaml) {
72 | fputs(line, stdout);
73 | if (isprefix(line, "\\endcaml")) incaml = 0;
74 | continue;
75 | }
76 | if (inverbatim){
77 | if (isprefix (line, verbatim_end_in)){
78 | fputs (verbatim_end_out, stdout);
79 | inverbatim = 0;
80 | }else{
81 | for (p = (unsigned char *) line; *p != 0; p++){
82 | c = *p;
83 | if (c == ' ' || c == '\n' || transl[c] == NULL){
84 | putchar (c);
85 | }else{
86 | fputs (transl[c], stdout);
87 | }
88 | }
89 | }
90 | continue;
91 | }
92 | if (isprefix(line, "\\begin{caml_")
93 | || isprefix(line, "\\begin{rawhtml}")) {
94 | fputs(line, stdout);
95 | inverbatim_like = 1;
96 | continue;
97 | }
98 | if (isprefix(line, "\\caml")) {
99 | fputs(line, stdout);
100 | incaml = 1;
101 | continue;
102 | }
103 | if (isprefix (line, "\\begin{verbatim}")){
104 | fputs ("\\begin{machineenv}", stdout);
105 | inverbatim = 1;
106 | verbatim_end_in = "\\end{verbatim}";
107 | verbatim_end_out = "\\end{machineenv}";
108 | continue;
109 | }
110 | if (isprefix (line, "\\begin{ocamldoccode}")){
111 | fputs ("\\begin{ocamldoccode}", stdout);
112 | inverbatim = 1;
113 | verbatim_end_in = "\\end{ocamldoccode}";
114 | verbatim_end_out = "\\end{ocamldoccode}";
115 | continue;
116 | }
117 | inverb = 0;
118 | for (p = (unsigned char *) line; *p != 0; p++) {
119 | c = *p;
120 | if (inverb) {
121 | if (c == inverb){
122 | inverb = 0;
123 | }else if (c == '\'' || c == '`'){
124 | fprintf (stderr, "Warning: %c found in \\verb\n", c);
125 | }
126 | putchar(c);
127 | continue;
128 | }
129 | switch(c) {
130 | case '"':
131 | if (inquote) {
132 | fputs("}}", stdout);
133 | inquote = 0;
134 | } else {
135 | fputs("{\\machine{", stdout);
136 | inquote = 1;
137 | }
138 | break;
139 | case '\\':
140 | if (inquote) {
141 | if (p[1] == '"' || p[1] == '\\') {
142 | c = p[1];
143 | p++;
144 | }
145 | if (transl[c] != NULL)
146 | fputs(transl[c], stdout);
147 | else
148 | putchar(c);
149 | } else if (isprefix(p, "\\verb") && p[5] != 0 && !isalpha(p[5])) {
150 | inverb = p[5];
151 | p = p + 5;
152 | fputs("\\verb", stdout);
153 | putchar(inverb);
154 | } else {
155 | putchar('\\');
156 | }
157 | break;
158 | default:
159 | if (inquote && transl[c] != NULL)
160 | fputs(transl[c], stdout);
161 | else
162 | putchar(c);
163 | }
164 | }
165 | }
166 | return 0;
167 | }
168 |
--------------------------------------------------------------------------------
/tools/transf.mll:
--------------------------------------------------------------------------------
1 | {
2 | open Lexing;;
3 | open Printf;;
4 |
5 | let print_char_repr c =
6 | match c with
7 | | '\'' -> printf "{\\textquotesingle}"
8 | | '`' -> printf "{\\textasciigrave}"
9 | | _ -> printf "\\char%d" (int_of_char c);
10 | ;;
11 | }
12 |
13 | rule main = parse
14 | "\\begin{syntax}" {
15 | print_string "\\begin{syntax}";
16 | syntax lexbuf }
17 | | "\\begin{verbatim}" {
18 | print_string "\\begin{verbatim}";
19 | verbatim lexbuf }
20 | | "\\@" {
21 | print_string "@";
22 | main lexbuf }
23 | | "@" {
24 | print_string "\\synt{";
25 | syntax lexbuf }
26 | | _ {
27 | print_char (lexeme_char lexbuf 0); main lexbuf }
28 | | eof {
29 | () }
30 |
31 | and syntax = parse
32 | "\\end{syntax}" {
33 | print_string "\\end{syntax}";
34 | main lexbuf }
35 | | "@" {
36 | print_string "}";
37 | main lexbuf }
38 | | '\'' {
39 | print_string "\\token{";
40 | inquote lexbuf }
41 | | '\"' {
42 | print_string "\\token{";
43 | indoublequote lexbuf }
44 | | "epsilon" { print_string "\\emptystring"; syntax lexbuf }
45 | | ['a'-'z' 'A'-'Z'] ['a'-'z' 'A'-'Z' '0'-'9' '-'] * as lxm {
46 | print_string "\\nonterm{";
47 | print_string lxm ;
48 | print_string"}";
49 | syntax lexbuf }
50 | | '@' (['a'-'z' 'A'-'Z'] ['a'-'z' 'A'-'Z' '0'-'9' '-'] * as lxm) '@' {
51 | print_string "\\nt{";
52 | print_string lxm ;
53 | print_string"}";
54 | syntax lexbuf }
55 |
56 | | '\\' ['a'-'z''A'-'Z'] + {
57 | print_string (lexeme lexbuf);
58 | syntax lexbuf }
59 | | ['_' '^'] _ {
60 | print_string (lexeme lexbuf);
61 | syntax lexbuf }
62 | | "{" { print_string "\\brepet{}"; syntax lexbuf }
63 | | "}" { print_string "\\erepet{}"; syntax lexbuf }
64 | | "{{" { print_string "\\brepets{}"; syntax lexbuf }
65 | | "}}" { print_string "\\erepets{}"; syntax lexbuf }
66 | | "[" { print_string "\\boption{}"; syntax lexbuf }
67 | | "]" { print_string "\\eoption{}"; syntax lexbuf }
68 | | "(" { print_string "\\bparen{}"; syntax lexbuf }
69 | | ")" { print_string "\\eparen{}"; syntax lexbuf }
70 | | "||" { print_string "\\orelse{}"; syntax lexbuf }
71 | | ":" { print_string "\\is{}"; syntax lexbuf }
72 | | "|" { print_string "\\alt{}"; syntax lexbuf }
73 | | ";" { print_string "\\sep{}"; syntax lexbuf }
74 | | "\\\\" { print_string "\\cutline{}"; syntax lexbuf }
75 | | _ {
76 | print_char (lexeme_char lexbuf 0);
77 | syntax lexbuf }
78 |
79 | and inquote = parse
80 | ['A'-'Z' 'a'-'z' '0'-'9'] {
81 | print_char (lexeme_char lexbuf 0);
82 | inquote lexbuf }
83 | | '\'' {
84 | print_string "}";
85 | syntax lexbuf }
86 | | _ {
87 | print_char_repr (lexeme_char lexbuf 0);
88 | inquote lexbuf }
89 |
90 | and indoublequote = parse
91 | ['A'-'Z' 'a'-'z' '0'-'9'] {
92 | print_char (lexeme_char lexbuf 0);
93 | indoublequote lexbuf }
94 | | '"' {
95 | print_string "}";
96 | syntax lexbuf }
97 | | _ {
98 | print_char_repr (lexeme_char lexbuf 0);
99 | indoublequote lexbuf }
100 |
101 | and verbatim = parse
102 | "\n\\end{verbatim}" {
103 | print_string "\n\\end{verbatim}";
104 | main lexbuf }
105 | | _ {
106 | print_char (lexeme_char lexbuf 0);
107 | verbatim lexbuf }
108 |
--------------------------------------------------------------------------------
/tools/transfmain.ml:
--------------------------------------------------------------------------------
1 | let main() =
2 | let lexbuf = Lexing.from_channel stdin in
3 | if Array.length Sys.argv >= 2 && Sys.argv.(1) = "-html"
4 | then Htmltransf.main lexbuf
5 | else Transf.main lexbuf;
6 | exit 0;;
7 |
8 | Printexc.print main ();;
9 |
--------------------------------------------------------------------------------