forked from sweirich/ott
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanual.tex
227 lines (197 loc) · 8.29 KB
/
manual.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
\documentclass{article}
\title{The Ott \LaTeX{} Layout Package \texttt{ottlayout.sty}}
\author{Rok Strni\v sa \and Matthew Parkinson}
% the un-wrapped (-tex_wrap false) generated LaTeX file for LJ
\include{lj_included}
% currently required by Ott-generated, un-wrapped LaTeX
\usepackage{amsmath}
% required by LJ's LaTeX
\usepackage{amssymb}
% the package that allows customized layout described in this document
\usepackage{ottlayout}
% the automatically generated file (with our Makefile) to link the generated
% LaTeX with the ottlayout package
\include{lj_override}
% supertabular package required if using the default grammar tabular
\usepackage{supertabular}
% only used in bibliography to link to LJ's webpage
\usepackage{url}
\begin{document}
\maketitle
\section{Introduction}
%
The Ott \LaTeX{} Layout Package, \texttt{ottlayout.sty}, provides a
range of options to tune the typesetting of
Ott-generated inductive definition rules and grammars, overriding the
default typesetting of the Ott-generated \LaTeX{} code.
This document illustrates the common-case usage of the package, using
Lightweight Java (LJ)~\cite{lj} as an example Ott project.
It should be read in conjunction with the source for this document (\verb+manual.tex+) and the \verb+Makefile+.
\section{Usage}
To use the package, one first uses Ott to generate \LaTeX{} code with
a chosen \verb+-tex_name_prefix+, by default \verb+ott+, but here
\verb+lj+, as in the example \verb+Makefile+:
\begin{verbatim}
lj_included.tex : $(lj)
ott $(INC_ARGS) -tex_name_prefix lj -tex $@ \
-merge true $(lj)
\end{verbatim}
Then one builds a file such as \verb+lj_override.tex+, e.g.~as below.
\begin{verbatim}
%_override.tex: override.tex empty.ott
ott $(INC_ARGS) -tex_name_prefix lj \
-tex_filter override.tex $@ empty.ott
\end{verbatim}
This file simply contains redefinitions of some default \LaTeX{}
commands generated by Ott (with the \verb+lj+ prefix) to use the
\texttt{ottlayout.sty} commands, e.g.
\begin{verbatim}
\renewcommand{\ljpremise}[1]{\premiseSTY{#1}}
\renewcommand{\ljusedrule}[1]{\usedruleSTY{#1}}
\renewcommand{\ljdrule}[4][]{\druleSTY[#1]{#2}{#3}{#4}}
\renewenvironment{ljdefnblock}[3][]{%
\defnblockSTY[#1]{#2}{#3}}{\enddefnblockSTY}
\end{verbatim}
Finally, in the user \LaTeX{} document (for example this
\texttt{manual.tex}), one:
(a) includes the generated \LaTeX{} for the user language, e.g.~with
\verb+\include{lj_included}+;
(b) uses the \texttt{ottlayout.sty} package, e.g.~with
\verb+\usepackage{ottlayout}+; and
(c) uses the generated override file to link the generated \LaTeX{}
with \verb+ottlayout.sty+, e.g.~with
\verb+\include{lj_override}+.
\section{Displaying grammar}
%
To display all Ott-generated \LaTeX{} for LJ, we would normally write the command
\verb+\ljall{}+. To output all the LJ's grammar, we would use the \LaTeX{}
command: \verb+\ljgrammar{}+. To show only selected parts of the grammar, we
would normally use the command \verb+\ljgrammartabular{}+. For example, to
display the grammar of LJ's statement ({\tt s}) and class definition ({\tt
cld}), we would write
\footnote{The automatically generated grammar tabular command, here \texttt{$\backslash{}$ljgrammartabular\{\}}, uses the {\tt supertabular} package. Therefore, if we use the
default grammar tabular, we have to explicitly import this package by writing
\texttt{$\backslash{}$usepackage\{supertabular\}} in our \LaTeX{} document's prelude.}
%
\begin{verbatim}
\ljgrammartabular{\ljs\ljinterrule\ljcld\ljafterlastrule}
\end{verbatim}
%
to produce:\\[2ex]
\ljgrammartabular{\ljs\ljinterrule\ljcld\ljafterlastrule}\\[2ex]
Alternatively, we can use the \texttt{ottlayout} package's
\verb+\grammartabularSTY{}+ to produce a slightly more compact output, usually
more suitable for publications. To display the same grammars, we would write
%
\begin{verbatim}
\grammartabularSTY{\ljs\\\ljcld}
\end{verbatim}
%
to produce:\\[2ex]
\grammartabularSTY{\ljs\\\ljcld}\\[2ex]
Note that in both cases the comments on the right are aligned according to the
longest production in the block. Therefore, if the length of productions varies
a lot, it is sometimes suitable to split them up into separate grammar
tabulars. We could split the above example by writing
%
\begin{verbatim}
\grammartabularSTY{\ljs}\\
\grammartabularSTY{\ljcld}
\end{verbatim}
%
to produce:\\[2ex]
\grammartabularSTY{\ljs}\\
\grammartabularSTY{\ljcld}\\[2ex]
\section{Displaying rules}
%
To display all the rules of LJ, we would normally use the Ott-generated \LaTeX{} command
\verb+\ljdefnss{}+. To show all the rules of the LJ's reduction relation, we
would use the command \verb+\ljdefnrXXstmt{}+ --- if you are not sure what the
name of the command you are looking for is, the easiest way to find out is to
check the Ott-generated \LaTeX{} file, which is in our case {\tt
lj\_included.tex}.
The \texttt{ottlayout} package gives many different options for displaying a
particular rule and groups of rules. The currently available display options
are:
%
\begin{center}
\begin{tabular}{|l|l|c|}
\hline
{\bf Setting name} & {\bf Possible values} & {\bf Default value}\\\hline
\hline
showruleschema & yes $|$ no & yes\\\hline
showcomment & yes $|$ no & yes\\\hline
rulelayout & oneperline $|$ nobreaks & oneperline\\\hline
premiselayout & oneperline $|$ oneline $|$ justify & justify\\\hline
premisenamelayout & right $|$ left $|$ topright $|$ none & right\\\hline
numberpremises & yes $|$ no & no\\\hline
numbercolour & {\it any dvips colour name} & \color{Gray}{Gray}\\\hline
\end{tabular}
\end{center}
%
The default settings result in the same output as if the \texttt{ottlayout}
package was not used.
We use LJ's (fairly complicated) reduction rule for methods to
demonstrate a few of the available display settings for an example. To
display the LJ rule {\tt r\_mcall} with default settings we write
%
\begin{verbatim}
\ljdrulerXXmcall{}
\end{verbatim}
%
which produces:\\[2ex]
\ljdrulerXXmcall{}\\[2ex]
%
Note that math mode is entered automatically, which means that we can use any
\LaTeX{} text layout utilities to layout our rules as we wish.
We can change the default setting with command \verb+\ottstyledefaults{}+ by
passing keys and values in the KeyVal style. For example, to make the premises
display more compactly in all rules from now on, we write
%
\begin{verbatim}
\ottstyledefaults{premiselayout=justify}
\end{verbatim}
\ottstyledefaults{premiselayout=justify}
%
Now the the command \verb+\ljdruleXXmcall{}+ produces the following instead:\\[2ex]
\ljdrulerXXmcall{}\\[2ex]
To use the non-default settings for a particular rule, we can write the same
KeyVal pairs inside as the parameter to the rule command. For example, to number
the premises in the rule, to make the numbers yellow-orange, and to place the
rule's name in top-right corner, we write
%
\begin{verbatim}
\ljdrulerXXmcall{numberpremises=yes,
numbercolour=YellowOrange,
premisenamelayout=topright}
\end{verbatim}
%
which produces:\\[2ex]
\ljdrulerXXmcall{numberpremises=yes,
numbercolour=YellowOrange,
premisenamelayout=topright}\\[2ex]
%
As you can see, the setting for compacting the premises was kept, because it was
set globally for all rules following the \verb+\ottstyledefaults{}+ command.
As with commands for individual rules, we can pass in KeyVal pairs to the
commands that display groups of rules, which will affect how the rules of that
particular group of rules is displayed. If we wanted to display LJ's
reduction rules for statements with current default display settings, we would
write \verb+\ljdefnrXXstmt{}+. To display the reduction rules with rule names on
the left side, and their premises numbered, we write
%
\begin{verbatim}
\ljdefnrXXstmt{numberpremises=yes, premisenamelayout=left}
\end{verbatim}
%
This produces\footnote{We set the font size to {\tt small} so that the rules
are not too wide.}:\\[2ex]
{\small\ljdefnrXXstmt{numberpremises=yes, premisenamelayout=left}}\\[2ex]
%
Therefore, Ott-generated \LaTeX{} commands for rules of a specific {\bf defn} in
the Ott source file can take KeyVal arguments. However, note that currently the
Ott-generated \LaTeX{} output does not allow for this package to allow the same
arguments being passed to commands for a group of {\bf defn}s, i.e.~{\bf defns}.
\bibliographystyle{acm}
\bibliography{manual}
\end{document}