% /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 }