Commit 255324a1 authored by fpottier's avatar fpottier
Browse files

Simplified the documentation by switching from pstricks to TikZ.

Simplified the documentation's Makefile.
A few documentation changes.


git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/menhir@332 0f8b5475-4b4e-0410-85a8-ee3154a6bfe7
parent 33084248
.PHONY: all clean
all: main.pdf
export TEXINPUTS=.:
%.pdf: %.tex
pdflatex $*
bibtex $*
pdflatex $*
clean:
rm -f *.log *.aux *.bbl *.blg *.out *.toc *~
# Dans ce fichier, on ne doit trouver que les réglages qui sont les
# mêmes pour tous mes articles.
# Les réglages qui dépendent de l'article courant sont dans Makefile.local.
include Makefile.local
PAPER := a4
DVIPS_COMMON_OPT := -Pcmz -Pamz -e 0
HREF_PDF := \def\fppdf{true}
clean::
rm -f *.out *.thm *~
This diff is collapsed.
# Dans ce fichier, on ne doit trouver que les réglages qui dépendent
# vraiment de l'article courant.
# Les réglages qui sont les mêmes pour tous mes articles sont dans
# Makefile.cfg.
# Ce fichier est également lu comme un script, donc doit être exprimé
# dans une syntaxe commune à bash et à make.
# Le nom du fichier source principal.
DOC=main
# Le nom des fichiers à exporter vers le site Web.
NAME=menhir
# Les imports TeX pour la compilation.
export TEXINPUTS=.:
This diff is collapsed.
% This tiny package invokes ``hyperref'' with appropriate options.
% Three modes are provided:
% if \fppdf is defined, we configure ``hyperref'' for producing nice PDF output via dvipdfm.
% if \fppdf is defined, we configure ``hyperref'' for PDF output.
% otherwise, if WhizzyTeX is active, we do configure ``softref'' for producing DVI output
% containing ``advi''-style hyperlinks.
% otherwise, we configure nothing.
......@@ -30,8 +30,8 @@
}
}{
% PDF output.
\typeout{Hyperlinks in dvipdfm style.}
\usepackage[dvipdfm,bookmarks=true,bookmarksopen=true,colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}
\typeout{Hyperlinks in pdflatex style.}
\usepackage[bookmarks=true,bookmarksopen=true,colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref}
\let\softlink\hyperlink
\let\softtarget\hypertarget
}
......@@ -97,34 +97,42 @@
% Command line options.
\newcommand{\obase}{\texttt{--base}\xspace}
\newcommand{\ocomment}{\texttt{--comment}\xspace}
\newcommand{\odepend}{\texttt{--depend}\xspace}
\newcommand{\orawdepend}{\texttt{--raw-depend}\xspace}
\newcommand{\odump}{\texttt{--dump}\xspace}
\newcommand{\oerrorrecovery}{\texttt{--error-recovery}\xspace}
\newcommand{\oexplain}{\texttt{--explain}\xspace}
\newcommand{\oexternaltokens}{\texttt{--external-tokens}\xspace}
\newcommand{\ofixedexc}{\texttt{--fixed-exception}\xspace}
\newcommand{\ograph}{\texttt{--graph}\xspace}
\newcommand{\oinfer}{\texttt{--infer}\xspace}
\newcommand{\ointerpret}{\texttt{--interpret}\xspace}
\newcommand{\ointerpretshowcst}{\texttt{--interpret-show-cst}\xspace}
\newcommand{\ologautomaton}{\texttt{--log-automaton}\xspace}
\newcommand{\ologcode}{\texttt{--log-code}\xspace}
\newcommand{\ologgrammar}{\texttt{--log-grammar}\xspace}
\newcommand{\onoinline}{\texttt{--no-inline}\xspace}
\newcommand{\onostdlib}{\texttt{--no-stdlib}\xspace}
\newcommand{\oocamlc}{\texttt{--ocamlc}\xspace}
\newcommand{\oocamldep}{\texttt{--ocamldep}\xspace}
\newcommand{\oonlypreprocess}{\texttt{--only-preprocess}\xspace}
\newcommand{\oonlytokens}{\texttt{--only-tokens}\xspace}
\newcommand{\ostrict}{\texttt{--strict}\xspace}
\newcommand{\osuggestcomp}{\texttt{--suggest-comp-flags}\xspace}
\newcommand{\osuggestlinkb}{\texttt{--suggest-link-flags-byte}\xspace}
\newcommand{\osuggestlinko}{\texttt{--suggest-link-flags-opt}\xspace}
\newcommand{\otable}{\texttt{--table}\xspace}
\newcommand{\otimings}{\texttt{--timings}\xspace}
\newcommand{\otrace}{\texttt{--trace}\xspace}
\newcommand{\ostdlib}{\texttt{--stdlib}\xspace}
\newcommand{\oversion}{\texttt{--version}\xspace}
\newcommand{\obase}{\texttt{-{}-base}\xspace}
\newcommand{\ocomment}{\texttt{-{}-comment}\xspace}
\newcommand{\odepend}{\texttt{-{}-depend}\xspace}
\newcommand{\orawdepend}{\texttt{-{}-raw-depend}\xspace}
\newcommand{\odump}{\texttt{-{}-dump}\xspace}
\newcommand{\oerrorrecovery}{\texttt{-{}-error-recovery}\xspace}
\newcommand{\oexplain}{\texttt{-{}-explain}\xspace}
\newcommand{\oexternaltokens}{\texttt{-{}-external-tokens}\xspace}
\newcommand{\ofixedexc}{\texttt{-{}-fixed-exception}\xspace}
\newcommand{\ograph}{\texttt{-{}-graph}\xspace}
\newcommand{\oinfer}{\texttt{-{}-infer}\xspace}
\newcommand{\ointerpret}{\texttt{-{}-interpret}\xspace}
\newcommand{\ointerpretshowcst}{\texttt{-{}-interpret-show-cst}\xspace}
\newcommand{\ologautomaton}{\texttt{-{}-log-automaton}\xspace}
\newcommand{\ologcode}{\texttt{-{}-log-code}\xspace}
\newcommand{\ologgrammar}{\texttt{-{}-log-grammar}\xspace}
\newcommand{\onoinline}{\texttt{-{}-no-inline}\xspace}
\newcommand{\onostdlib}{\texttt{-{}-no-stdlib}\xspace}
\newcommand{\oocamlc}{\texttt{-{}-ocamlc}\xspace}
\newcommand{\oocamldep}{\texttt{-{}-ocamldep}\xspace}
\newcommand{\oonlypreprocess}{\texttt{-{}-only-preprocess}\xspace}
\newcommand{\oonlytokens}{\texttt{-{}-only-tokens}\xspace}
\newcommand{\ostrict}{\texttt{-{}-strict}\xspace}
\newcommand{\osuggestcomp}{\texttt{-{}-suggest-comp-flags}\xspace}
\newcommand{\osuggestlinkb}{\texttt{-{}-suggest-link-flags-byte}\xspace}
\newcommand{\osuggestlinko}{\texttt{-{}-suggest-link-flags-opt}\xspace}
\newcommand{\otable}{\texttt{-{}-table}\xspace}
\newcommand{\otimings}{\texttt{-{}-timings}\xspace}
\newcommand{\otrace}{\texttt{-{}-trace}\xspace}
\newcommand{\ostdlib}{\texttt{-{}-stdlib}\xspace}
\newcommand{\oversion}{\texttt{-{}-version}\xspace}
% Adding mathstruts to ensure a common baseline.
\newcommand{\mycommonbaseline}{
\let\oldnt\nt
\renewcommand{\nt}[1]{$\mathstrut$\oldnt{##1}}
\let\oldbasic\basic
\renewcommand{\basic}[1]{$\mathstrut$\oldbasic{##1}}
}
......@@ -2,12 +2,12 @@
\let\fpacm\true
\documentclass[onecolumn,11pt,nocopyrightspace]{sigplanconf}
\usepackage{amstext}
\usepackage[OT1]{fontenc}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{type1cm}
\usepackage{tikz}
\usepackage{xspace}
\usepackage{mymacros}
\def\fppdf{true}
\usepackage{fppdf}
\input{macros}
\input{version}
......@@ -130,8 +130,10 @@ the user to define module $T$ and to make sure that it exports a suitable
out of a grammar specification using the \oonlytokens switch.
\docswitch{\ofixedexc} This switch causes the exception \texttt{Error} to be
declared equal to \texttt{Parsing.Parse\_error}. This helps increase Menhir's
compatibility with \ocamlyacc. There is otherwise no reason to use it.
internally defined as a synonym for \texttt{Parsing.Parse\_error}. This means
that an exception handler that catches \texttt{Parsing.Parse\_error} will also
catch the generated parser's \texttt{Error}. This helps increase Menhir's
compatibility with \ocamlyacc. There is otherwise no reason to use this switch.
\docswitch{\ograph} This switch causes a description of the grammar's
dependency graph to be written to the file \nt{basename}\dott. The graph's
......@@ -148,8 +150,9 @@ especially when advanced features such as \menhir's standard library or
compiler usually needs to consult a few \texttt{.cm[iox]} files. This means
that these files must have been created first, requiring \Makefile changes and
use of the \odepend switch. The file \distrib{demos/Makefile.shared} suggests
how to deal with this difficulty. Another option is to avoid \make altogether
and use \ocamlbuild, which has built-in knowledge of \menhir.
how to deal with this difficulty. A better option is to avoid \make altogether
and use \ocamlbuild, which has built-in knowledge of \menhir. Using
\ocamlbuild is also \textbf{strongly recommended}!
% There is a slight catch with \oinfer. The types inferred by \ocamlc are valid
% in the toplevel context, but can change meaning when inserted into a local
......@@ -1071,9 +1074,23 @@ fringe of some partial derivation tree is a \emph{sentential form}.
\paragraph{Why shifting is legal}
\begin{figure}
\vspace{5mm}
\mycommonbaseline
\begin{center}
\hskip -3mm\includegraphics{tree1}
\begin{tikzpicture}[level distance=12mm]
\node { \nt{expression} }
child { node {\basic{IF}} }
child { node {\nt{expression}} }
child { node {\basic{THEN}} }
child { node {\nt{expression}}
child { node {\basic{IF}} }
child { node {\nt{expression}} }
child { node {\basic{THEN}} }
child { node {\nt{expression}} }
child { node {\basic{ELSE}} }
child { node {\nt{expression}} }
}
;
\end{tikzpicture}
\end{center}
\caption{A partial derivation tree that justifies shifting}
\label{fig:shifting:tree}
......@@ -1114,9 +1131,23 @@ token, it makes sense for it to \emph{shift} that token.
\paragraph{Why reducing is legal}
\begin{figure}
\vspace{5mm}
\mycommonbaseline
\begin{center}
\hskip -3mm\includegraphics{tree2}
\begin{tikzpicture}[level distance=12mm]
\node { \nt{expression} }
child { node {\basic{IF}} }
child { node {\nt{expression}} }
child { node {\basic{THEN}} }
child { node {\nt{expression}}
child { node {\basic{IF}} }
child { node {\nt{expression}} }
child { node {\basic{THEN}} }
child { node {\nt{expression}} }
}
child { node {\basic{ELSE}} }
child { node {\nt{expression}} }
;
\end{tikzpicture}
\end{center}
\caption{A partial derivation tree that justifies reducing}
\label{fig:reducing:tree}
......@@ -1164,9 +1195,29 @@ the question: following \basic{UIDENT}, what's the next terminal symbol on the
fringe?
\begin{figure}
\vspace{5mm}
\mycommonbaseline
\begin{center}
\hskip -3mm\includegraphics{tree3}
\begin{tikzpicture}[level distance=12mm,level 1/.style={sibling distance=18mm},
level 2/.style={sibling distance=18mm},
level 4/.style={sibling distance=24mm}]]
\node { \nt{decls} }
child { node {\nt{decl}}
child { node {\basic{DATA}} }
child { node {\basic{UIDENT}} }
child { node {\basic{EQUALS}} }
child { node {\nt{tycon\_expr}}
child { node {\nt{tycon\_item}}
child { node {\basic{UIDENT}} }
child { node {\nt{opt\_type\_exprs}}
child { node {} edge from parent [dashed] }
}
}
}
}
child { node {\nt{opt\_semi}} }
child { node {\nt{decls}} }
;
\end{tikzpicture}
\end{center}
\caption{A partial derivation tree that justifies reducing}
\label{fig:xreducing:tree}
......@@ -1832,7 +1883,7 @@ of it into your own \Makefile, or submit suggestions for improvement.
\question{I am unable to write a correct \Makefile for \menhir, and so are
you.} True enough. Have a look at \ocamlbuild. It has built-in compilation
rules for \ocaml and \menhir. Maybe that will help.
rules for \ocaml and \menhir. That should help.
\question{\menhir reports \emph{more} shift/reduce conflicts than
\ocamlyacc! How come?} \ocamlyacc sometimes merges two states
......
\documentclass[onecolumn,11pt,nocopyrightspace]{sigplanconf}
\usepackage{pstricks,pst-node,pst-tree}
\usepackage[OT1]{fontenc}
\input{macros}
\begin{document}
\thispagestyle{empty}
\pstree[nodesep=3pt,levelsep=30pt]
{\TR{\nt{expression}}}
{
\TR{\basic{IF}}
\TR{\nt{expression}}
\TR{\basic{THEN}}
\pstree{\TR{\nt{expression}}}
{
\TR{\basic{IF}}
\TR{\nt{expression}}
\TR{\basic{THEN}}
\TR{\nt{expression}}
\TR{\basic{ELSE}}
\TR{\nt{expression}}
}
}
\end{document}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment