summaryrefslogtreecommitdiff
path: root/web/yacco2/diagrams/o2mac.tex
blob: f4b040f89c0932512275dd4459d46e2d666df286 (plain)
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
% /yacco2/library/o2mac.tex --- defines common macros for TeX
\tolerance=10000
\hbadness=10000
%\tracingall
\def\Tex{\TeX}
\def\cweb{\Cweb}
\def\Cweb{{\prgstyle Cweb}}
\def\prgstyle{\tt \sl }


\def\Whereyacco2{/usr/local/yacco2}

\def\printlistinglineno{\hskip .7 in \llap{\the\lineno:\quad}}
\def\ptindent#1{\line{\hskip.5in{#1}\hfill}}
\def\threeasteric{$***$}
\def\Yacco2{Ya$c_2o_2$}
\def\yacco2{\Yacco2}
\def\O2{$O_2$}
\def\o2{\O2}
\def\Cpp{C\kern-.25em \raise.25ex\hbox{\tt $+\kern-0.2ex+$}}
\def\Olinker{$O_{2}^{linker}$}
\def\olinker{$O_{2}^{linker}$}
\def\TILDE{\catcode`\~=11{}~}
\def\INDENT#1#2{\line{\hskip#1{#2}\hfill}}
\def\fbreak{\hfill\break}
\def\emptyrule{
\ifmmode
 \epsilon
\else
$\epsilon$
\fi
}

\def\fnp{\vfill\eject}
\def\Alpha{$\alpha$}
\def\Beta{$\beta$}
\def\o2{\O2}
\def\prtobrace{$\{$}
\def\prtcbrace{$\}$}
\def\prtstartsr{$-$$>$}
\def\]{\leavevmode\hbox{\tt\char`\ }}
\def\derives{$\Rightarrow$}
\def\subrule{$\rightarrow$}
\def\braceo{\char`\{}
\def\BRACEOPEN{\tt \char`\{}
\def\bracec{\char`\}}
\def\BRACECLOSE{\tt \char`\}}
\newbox\ALLshiftbox %|+|
\setbox\ALLshiftbox=\hbox{$|$\kern.5pt\raise1pt\hbox{\kern-2pt\sevenrm+}\kern-2pt$|$}
\def\ALLshift{\.{|+|}}
\def\INVshift{\.{|.|}}
\def\PARshift{\.{|||}}
\def\REDshift{\.{|r|}}
\def\PROCshift{\.{|t|}}
\def\TRAshift{\.{|t|}}
\def\QUEshift{\.{|?|}}

\def\Verticalbar{\tt \char`|}
\def\allshift{\ALLshift}
\def\invisibleshift{\INVshift}
\def\paralleloperator{\PARshift}
\def\procedurecalloperator{\PROCshift}
\def\transienceoperator{\TRAshift}
\def\questionableoperator{\QUEshift}
\def\reduceoperator{\REDshift}
\def\rrrr{\REDshift}
\def\ATsign{\char`@}
%\def\NOsign{
%\ifmmode
% \char`\#
%\else
%$\char`\#$
%\fi
%}
\def\NOsign{
{\tt \char`\#}
}
\def\LTsign{
\ifmmode
 <
\else
$<$
\fi
}
\def\GTsign{
\ifmmode
 >
\else
$>$
\fi
}
\def\PLUSsign{$+$}
\def\MINUSsign{$-$}
\def\AMPERsign{\char`&}
\def\ASTERICsign{\char`*}
\def\PERCENTsign{\char`\%}
\def\DOLLARsign{\char`$}
\def\DBLQUOTEsign{\char`\"}
\def\LFTQUOTEsign{\char`\`}
\def\RTQUOTEsign{\char`\'}

%\def\BKSLASHsign{
%\ifmmode \char`\\\else $\backslash$ \fi
%}
\def\BKSLASHsign{
{\tt \char`\\}
}

\def\UPARROWsign{\char`^}
\def\UNDERSCOREsign{\char`_}
\def\Shiftonly{$^s$}
\def\Reduceonly{$^r$}
\def\ShiftReduce{$^{s/r}$}
\def\MultipleReduces{$^{r{^2}}$}
\def\ShiftandMultipleReduces{$^{s/r{^2}}$}
\def\Derivedstatessym{$\triangleright$}
\def\Mergedsym{$^\nearrow$}
\def\Mergedstate#1{$^\nearrow{^{#1}}$}
\def\Subrulestartsymstrindent#1{\item{#1}}
\def\Subrulederivedstatesindent{\item\item{\Derivedstatessym\ }}
\def\Reducedstatelist{\item\item{$\subset$\ }}
\def\Linkeridxentry#1{{\par\parindent=2pc{\narrower#1}\smallskip}}
\def\Linkeridxentryk#1{{\par\parindent=3pc{\item\item{#1}\smallskip}}}
\def\Linkercalledthreads#1#2{{\par\parindent=#2pc{\narrower#1}\smallskip}}
\def\Linkercalledthreadstitle{{\par\parindent=0pc{\narrower %
First set of called threads list.}\smallskip}}

\def\IDXdoctitle#1#2{% p1 banner p2 file name
	\global\def\title{#1}
	\global\def\topofcontents{\null\vfill 
	  \centerline{\ttitlefont #1}
	  \vskip 15pt
	  \hbox{\ttitlefont Date: \today \ at \hours \hfil}
	  \vskip 15pt
	  \hbox{\ttitlefont File: #2 \hfil}
	  \vfill
       }
}
\def\IDXlinkerdoctitle#1#2#3{% p1 banner p2 file name p3 fsc source file
	\global\def\title{#1}
	\global\def\topofcontents{\null\vfill 
	  \centerline{\ttitlefont #1}
	  \vskip 15pt
	  \hbox{\ttitlefont Date: \today \ at \hours \hfil}
	  \vskip 15pt
	  \hbox{\ttitlefont File: #2 \hfil}
	  \vskip 15pt
	  \hbox{\ttitlefont Fsc\ : #3 \hfil}
	  \vfill
       }
}
\def\DOCtitle#1#2#3#4{% 1 banner, 2 file name, 3 NS, 4 # T
	\global\def\title{#1}
	\global\def\topofcontents{\null\vfill 
	  \centerline{\ttitlefont #1}
	  \vskip 15pt
	  \centerline{\ttitlefont Date: \today \ at \hours }
	  \vskip 15pt
	  \centerline{\ttitlefont File: #2 \hfil Namespace: #3}
	  \vskip 15pt
	  \centerline{\ttitlefont Number of terminals: #4}
	  \vfill
       }
}

\def\GRAMMARtitle#1#2#3#4#5#6{% p1 fn noext, p2 filename.ext, p3 NS, p4 version
	\global\def\title{#1 Grammar} %p5 debug, p6 comments
	\global\def\topofcontents{\null\vfill 
	  \centerline{\ttitlefont #1 Grammar}
	  \vskip 15pt
	  \centerline{\ttitlefont Date: \today \ at \hours \hfil}
	  \vskip 15pt
	  \centerline{\ttitlefont File: #2}
	  \vskip 15pt
	  \centerline{\ttitlefont Ns: #3}
	  \vskip 15pt
	  \centerline{Version: #4 \hfil Debug: #5}
	  \vskip 15pt
	  \centerline{Grammar Comments:  \hfil Type: Monolithic}
	  \vskip 15pt
	  \centerline{#6}
	  \vfill
       }
}

\def\THREADtitle#1#2#3#4#5#6#7#8{% 1 filename noext, 2 file name.lex, 3 NS
  \global\def\title{#1  Grammar} % 4 vers 5 debug, 6 comments, 7 # T in la, 8 la expr
	\global\def\topofcontents{\null\vfill 
	  \centerline{\ttitlefont #1 Grammar}
	  \vskip 15pt
	  \centerline{\ttitlefont Date: \today \ at \hours \hfil}
	  \vskip 15pt
	  \centerline{\ttitlefont File: #2 \hfil Ns: #3}
	  \vskip 15pt
	  \centerline{Version: #4 \hfil Debug: #5}
	  \vskip 15pt
	  \centerline{Grammar Comments:  \hfil Type: Thread}
	  \vskip 15pt
	  \centerline{#6}
	  \vskip 15pt
          \centerline{\ttitlefont #7 element(s) in Lookahead Expression below}
	  \vskip 10pt
          \centerline{#8}
	  \vfill
        }
}


%
% state no macros to generate the lr1 state report
%
\def \statecolumnspace{
\tabskip=.5em plus1em minus.25em
}

\def\stateno#1#2#3{%1-state no, 2-vectored into literal symbol, 3-confict state 
\fbreak\noindent
\hbox{\hbox to 8cm{$\Rightarrow^{\eightrm #2}$ \hfil} State: #1 state type: {#3} \hfil}
}

\def\statetemplate{
##&
\eightrm##\hfil&
##&
##&
##&
\sevenrm##\hfil&
##&
##&
##&
##\cr  %LA set no template
}

\def\statetitle{
{\ }&
\statetitlerule&
\statetitlerulecoordinates&
\statetitlesubrule& 
\statetitlesubrulebirth\cr
}

\def\statetitleintro{
\fbreak
\hbox to .5cm{}
}
\def\statetitlerule{
\hbox to 3.5cm{\tt{$\leftarrow$}\hfil rule \hfil{$\rightarrow$}}
}
\def\statetitlerulecoordinates{
{\tt R\#\ }&{\tt sr\#}&{\tt Po}
}
\def\statetitlesubrule{
\hbox to 7.5cm{\tt{$\leftarrow$}\hfil subrule element\hfil{$\rightarrow$}}
}
\def\statetitlesubrulebirth{
{\tt Brn}&{\tt Gto}&{\tt Red}&{\tt LA}
}

\def\LRstatenetwork{
List of productions with their derived LR state lists.
Their subrule number and symbol string indicates the specific
production being derived.
The ``\Derivedstatessym'' symbol indicates the production's list of
derived states from its closured state.
Multiple lists within a production indicate 1 of 2 things:\fbreak
\ptindent{1) derived string that could not be merged due to a lr(1) conflict}
\ptindent{2) partially derived string merged into another derived lr states}
A partially derived string is indicated by the ``merged into'' symbol \Mergedsym
used as a superscript along with the merged into state number.\fbreak
}
\def\Listofreducingstates{
The following legend indicates the type of reducing state.\fbreak
Points 2--4 are states that must meet the lr(1) condition:\fbreak
\ptindent{1) r --- only 1 production reducing}
\ptindent{2) r$^2$ --- 2 or more reducing productions}
\ptindent{3) s$/$r --- shift and 1 reducing production}
\ptindent{4) s$/r^2$ --- shift and multiple reducing productions}
\fbreak
}

%
% Follow set info per state and possible reducing subrules lookahead set 
%
\def\FollSetnotesintro{
Notes on Follow set expressions:\fbreak
1) The ``follow set'' for rule uses its literal name 
and tags its grammar rule rank number as a superscript.
Due to space limitations, part of the follow set information 
uses the  rule's literal name 
while the follow set expressions refers to the rule's rank number.
This \LTsign{}rule name, rule rank number\GTsign tupple allows
you the reader to decifer the expressions.
Transitions are represented by S{$_{x}$}R{$_{z}$} whereby
 S is the LR1 state identified by its ``x'' subscript where 
other transient calculations occur within the LR1 state network. 
R indicates the follow set rule with the subscript ``z'' as its grammar rank number
that contributes to the follow set.
\fbreak
\fbreak
The \Mergedstate{x} symbol indicates that a merge into state ``x'' has taken place.
That is, the reduced subrule that depends on this follow set
finds its follow set in 2 places: 
its birthing state that generated the sequence up to the merged into state, 
and the birthing state that generated the ``merged into'' state.
So the rule's ``follow set'' calculation must also continue 
its calculation within the birth state generating
the ``x merged into'' state.
\fbreak
\raggedright
}

\def\FollSettemplate{
##\hfil& %rule name
##\hfil\cr % list of contributors template
}

\def\FollSettitle{
\FollSettitlerule&
\FollSettitlecontributors\cr
}

\def\FollSettitlerule{
\hbox to 4cm{\tt{$\leftarrow$}\hfil Follow set Rule \hfil{$\rightarrow$}}
}

\def\FollSettitlecontributors{
\hbox to 11cm{\tt{$\leftarrow$}\hfil follow set symbols contributors\hfil{$\rightarrow$}}
}

\def\FollSetlocalyield{
\hbox{Local follow set yield: $\sum$ first-set(follow symbols)}
\item{}
\raggedright
}

\def\FollSetstateno#1{%1-state no 
\fbreak\noindent
\hbox{\hbox to 11cm{State: #1 \hfil Follow Set contributors, merges, and transitions \hfil}}
}
\def\rulenameno#1{{\sevenrm$^{#1}$}}
\def\FollSetcreators#1#2#3{R$_{#1}._{#2}._{#3}$}
\def\FollSetmerges#1{\Mergedstate{#1}}
\def\FollSettransition#1#2{S$_{#1}R_{#2}$}

\def\FollSetreducinglocalyield{
\hbox{Local follow set yield: }
\item{}
\raggedright
}

%
% Reducing subrule's look ahead set
%
\def\FollSetreducingsrs{
\fbreak
\hbox{Reducing Subrule:}
}

\def\FollSetreducingsrtemplate{
##& %R#
##& %SR
##\hfil& % list of contributors template
\quad##\cr % lookahead set index no
}
\def\FollSetreducingsubruletitle{
\FollSetreducingsrtitle&
\FollSetreducingsrcontributorstitle&
\FollSetreducingsrlasettitle\cr
}
\def\FollSetreducingsrtitle{
{\tt R\#\ }&{\tt sr\#}
}
\def\FollSetreducingsrcontributorstitle{
\hbox to 13.75cm{\tt{$\leftarrow$}\hfil subrule's reducing symbol position and any right bounded transitions\hfil{$\rightarrow$}}
}
\def\FollSetreducingsrlasettitle{
\hbox {\tt LA\#}
}
\def\FollSetreducingsrtotalyield{
\hbox{Total follow set yield:}
\item{}
\raggedright
}
\def\LASettotalyield#1{
\hbox{Lookahead set #1 yield:}
\item{}
\raggedright
}