%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 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'} % %It is also possible to alias a nonterminal: %\stx@alias{name}{othername} %will make reference to 'name' point to the definition of non-terminal %'othername' \ifhtml \newcommand{\token}[1]{\textnormal{\@span{class=syntax-token}#1}} \newstyle{.syntax-token}{color:blue;font-family:monospace} \else \newcommand{\token}[1]{\texttt{#1}} \fi %%% warnings \def\stx@warning#1#2{\@ifundefined{stx@#1@silent}{\hva@warn{#2}}{}} \def\stx@silent#1{\def\csname stx@#1@silent\endcsname{}} %%% Do not warn about those %initial example \stx@silent{like}\stx@silent{that}% %Not defined \stx@silent{regular-char}% \stx@silent{regular-string-char}% %\stx@silent{regular-char-str}% \stx@silent{lowercase-ident}% \stx@silent{capitalized-ident}% \stx@silent{space}% \stx@silent{tab}% \stx@silent{newline}% %Used in many places \stx@silent{prefix}% \stx@silent{name}% \stx@silent{xname}% %Not defined \stx@silent{external-declaration}% \stx@silent{unit-name}% %%Redefined in exten.etex \stx@silent{parameter}% \stx@silent{pattern}% \stx@silent{constr-decl}% \stx@silent{type-param}% \stx@silent{let-binding}% \stx@silent{expr}% \stx@silent{typexpr}% \stx@silent{module-expr}% \stx@silent{type-representation}% \stx@silent{definition}% \stx@silent{specification}% \stx@silent{type-equation}% \stx@silent{class-field}% \stx@silent{mod-constraint}% \stx@silent{module-type}% \stx@silent{constant}% %%Redefined in names.etex \stx@silent{label-name}% %%Not really defined in lexyacc.etex \stx@silent{character-set}% \stx@silent{symbol}% %%Not defined in debugger.etex \stx@silent{integer} %%Not defined in ocamldoc.etex \stx@silent{string} \stx@silent{id} \stx@silent{Exc} \stx@silent{URL} %%%%%%%%%%%%% %% Aliases %% %%%%%%%%%%%%% \newcommand{\stx@alias}[2]{\def\csname stx@#1@alias\endcsname{#2}} \stx@alias{typ}{typexpr}% \stx@alias{met}{method-name}% \stx@alias{tag}{tag-name}% \stx@alias{lab}{label-name}% \stx@alias{C}{constr-name} %%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%special anchor \newstyle{a.syntax:link}{color:maroon;text-decoration:underline} \newstyle{a.syntax:visited}{color:maroon;text-decoration:underline} \newstyle{a.syntax:hover}{color:black;text-decoration:none;background-color:\#FF6060} %compatibility for hevea-1.1?/heeva-2.?? \ifu\@tr@url \providecommand{\@tr@url}[1]{#1}\def\stx@id{NAME}\else \def\stx@id{id}\fi \newcommand{\@syntaxlocref}[2] {\@aelement{href="\@print{#}\@tr@url{#1}" class="syntax"}{#2}} \newcommand{\@syntaxaname}[2] {\@aelement{\stx@id="#1" class="syntax"}{#2}} %%Refer to anchor, internal : %#1 -> anchor #2 -> visible tag \def\@ref@anchor#1#2{% \@ifundefined{stx@#1@exists} {\stx@warning{#1}{Undefined non-terminal: '#1'}#2} {\@syntaxlocref{#1}{#2}}} %%Refer to anchor \def\ref@anchor#1{% \ifu\csname stx@#1@alias\endcsname \@ref@anchor{#1}{#1}\else \@ref@anchor{\csname stx@#1@alias\endcsname}{#1}\fi} \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{}\@syntaxaname{#1}{#1}} {\@ifundefined{stx@#1@silent} {\hva@warn{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{\textnormal{\@span{class=nonterminal}#1}} \newstyle{.nonterminal}{color:maroon;font-style:oblique} %%%Link for non-terminal and format \def\nonterm#1{\nt{\@anchor{#1}}} \def\brepet{\{} \def\erepet{\}} \def\boption{[} \def\eoption{]} \def\brepets{\{} \def\erepets{\}^+} \def\bparen{(} \def\eparen{)} \def\orelse{\mid} \def\is{&::=&} \def\alt{\\&\mid&} \def\sep{\\\\} \def\cutline{} \def\emptystring{\epsilon} \def\syntax{\@open{div}{class="syntax"}$$\begin{array}{>{\set@name}rcl}} \def\endsyntax{\end{array}$$\@close{div}} \def\syntaxleft{\@open{div}{class="syntaxleft"}$\begin{array}{>{\set@name}rcl}} \def\endsyntaxleft{\end{array}$\@close{div}} \def\synt#1{$#1$}