summaryrefslogtreecommitdiff
path: root/manual/styles
diff options
context:
space:
mode:
authorLuc Maranget <luc.maranget@inria.fr>2005-11-09 09:40:47 +0000
committerLuc Maranget <luc.maranget@inria.fr>2005-11-09 09:40:47 +0000
commitaf38d546dfa242974f1ac15a9cf20cd65c7e9cd4 (patch)
treee5ff024412dcb2d53a8c082e3426add22c56ee73 /manual/styles
parent8aca05cb97d43e72109a3a340e5d7d2d68600dd9 (diff)
downloadocaml-af38d546dfa242974f1ac15a9cf20cd65c7e9cd4.tar.gz
grammars with links (html only)
git-svn-id: http://caml.inria.fr/svn/ocamldoc/trunk@10114 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'manual/styles')
-rw-r--r--manual/styles/ocamldoc.hva13
-rw-r--r--manual/styles/syntaxdef.hva100
-rw-r--r--manual/styles/syntaxdef.sty3
3 files changed, 109 insertions, 7 deletions
diff --git a/manual/styles/ocamldoc.hva b/manual/styles/ocamldoc.hva
index 902834265d..58b7bb1219 100644
--- a/manual/styles/ocamldoc.hva
+++ b/manual/styles/ocamldoc.hva
@@ -2,18 +2,19 @@
\newenvironment{ocamldoccode}{\begin{alltt}}{\end{alltt}}
\newenvironment{ocamldocdescription}{\begin{quote}}{\end{quote}}
\newenvironment{ocamldoccomment}{\begin{quote}}{\end{quote}}
-\newcommand\textbar{|}
-\newcommand\textbackslash{\begin{rawhtml}\\end{rawhtml}}
-\newcommand\textasciicircum{\^{}}
-\newcommand\sharp{#}
\newenvironment{ocamldocindent}{\list{}{}\item\relax}{\endlist}
\newenvironment{ocamldocsigend}
{\noindent\quad\texttt{sig}\ocamldocindent}
- {\endocamldocindent\vskip -\lastskip
+ {\endocamldocindent
\noindent\quad\texttt{end}\medskip}
\newenvironment{ocamldocobjectend}
{\noindent\quad\texttt{object}\ocamldocindent}
- {\endocamldocindent\vskip -\lastskip
+ {\endocamldocindent
\noindent\quad\texttt{end}\medskip}
+
+\newcommand{\moduleref}[1]{\ifhtml\ahref{libref/#1.html}{\texttt{#1}}\fi}
+
+# For processing .tex generated by ocamldoc (for text manual)
+\newcommand{\ocamldocvspace}[1]{\vspace{#1}} \ No newline at end of file
diff --git a/manual/styles/syntaxdef.hva b/manual/styles/syntaxdef.hva
new file mode 100644
index 0000000000..828dda7e15
--- /dev/null
+++ b/manual/styles/syntaxdef.hva
@@ -0,0 +1,100 @@
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Hevea code for syntax definitions of the ocaml manual %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Important commands
+% \token, for typesetting grammar terminals
+% \nonterm, for typesetting grammar non-terminals
+%
+% Beware: \nonterm introduces either a local anchor or a local reference
+% -Anchors are introduced when \nonterm occurs in the first column of
+% syntax definitions (environment 'syntax')
+% - References are introduced everywhere else
+%
+% For pure typesetting effect without links (eg. to typeset 'e' as 'expr')
+% use the \nt command (eg. \nt{e}).
+% In syntax definitions, the tool 'transf' translates @word@ into \nt{word}.
+%
+% Warnings are produced
+% - For references to non-defined non terminals
+% - For multiple definitions of the same non-terminal
+% Warnings can be avoided for a given non-terminal 'expr' by issuing
+% the command \stx@silent{'expr'}
+\newif\ifspace
+\def\addspace{\ifspace\;\spacefalse\fi}
+\ifhtml
+\newcommand{\token}[1]{\texttt{\blue#1}}
+\else
+\newcommand{\token}[1]{\texttt{#1}}
+\fi
+%%% warnings
+\def\stx@warning#1#2{\@ifundefined{stx@#1@silent}{\warning{#2}}{}}
+\def\stx@silent#1{\def\csname stx@#1@silent\endcsname{}}
+%%% Do not warn about those
+%Not defined
+\stx@silent{regular-char}%
+\stx@silent{regular-char-str}%
+\stx@silent{lowercase-ident}%
+\stx@silent{capitalized-ident}%
+%utilities used in many places
+\stx@silent{prefix}%
+\stx@silent{name}%
+\stx@silent{xname}%
+\stx@silent{cond}%
+%Not defined
+\stx@silent{external-declaration}%
+\stx@silent{unit-name}%
+%%Redefined in exten.etex
+\stx@silent{expr}%
+\stx@silent{type-representation}%
+\stx@silent{definition}%
+\stx@silent{specification}%
+\stx@silent{type-equation}%
+%%Not really defined in lexyacc.etex
+\stx@silent{character-set}%
+\stx@silent{symbol}%
+%%Not defined in debugger.etex
+\stx@silent{integer}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%Refer to anchor
+\def\ref@anchor#1{%
+\@ifundefined{stx@#1@exists}
+{\stx@warning{#1}{Undefined non-terminal: '#1'}#1}
+{\ahrefloc{#1}{#1}}}
+\def\stx@exists#1{\def\csname stx@#1@exists\endcsname{}}
+%%Define anachor
+\def\def@anchor#1{%
+\@ifundefined{stx@#1}
+{{\@nostyle\@auxdowrite{\string\stx@exists\{#1\}}}%
+\gdef\csname stx@#1\endcsname{}\aname{#1}{#1}}
+{\@ifundefined{stx@#1@silent}
+{\warning{Redefinition of non-terminal '#1'}#1}
+{\ref@anchor{#1}}}}
+%%%Change \@anchor and initial definition, for html only, of course!
+\ifhtml
+\def\set@name{\let\@anchor\def@anchor}
+\let\@anchor\ref@anchor
+\else
+\def\set@name{}
+\def\@anchor{}
+\fi
+%%%Format non-terminal
+\def\nt#1{\textit{\maroon#1}}
+%%%Link for non-terminal and format
+\def\nonterm#1{\addspace\nt{\@anchor{#1}}\spacetrue}
+\def\brepet{\addspace\{}
+\def\erepet{\}}
+\def\boption{\addspace[}
+\def\eoption{]}
+\def\brepets{\addspace\{}
+\def\erepets{\}^+}
+\def\bparen{\addspace(}
+\def\eparen{)}
+\def\orelse{\mid \spacefalse}
+\def\is{ & ::= & \spacefalse }
+\def\alt{ \\ & \mid & \spacefalse }
+\def\sep{ \\ \\ \spacefalse }
+\def\cutline{}
+\def\emptystring{\epsilon}
+\def\syntax{$$\begin{array}{>{\set@name}rcl}\spacefalse}
+\def\endsyntax{\end{array}$$}
+\def\synt#1{$\spacefalse#1$}
diff --git a/manual/styles/syntaxdef.sty b/manual/styles/syntaxdef.sty
index bb17b94a7d..216c5ed2a4 100644
--- a/manual/styles/syntaxdef.sty
+++ b/manual/styles/syntaxdef.sty
@@ -1,7 +1,8 @@
\newif\ifspace
\def\addspace{\ifspace \; \spacefalse \fi}
\def\token#1{\addspace\hbox{\tt #1} \spacetrue}
-\def\nonterm#1{\addspace\hbox{\sl #1\/} \spacetrue}
+\def\nonterm#1{\addspace\nt{#1} \spacetrue}
+\def\nt#1{\hbox{\sl #1\/}}
\def\brepet{\addspace\{}
\def\erepet{\}}
\def\boption{\addspace[}