doc-src/rail.sty
author berghofe
Fri, 02 May 1997 16:21:04 +0200
changeset 3097 ae362c99a635
parent 2658 13ba951a4572
child 8591 9d660fc42916
permissions -rw-r--r--
New version of rail.sty for LaTeX 2e
wenzelm@2658
     1
% rail.sty - style file to support railroad diagrams
wenzelm@2658
     2
%
wenzelm@2658
     3
% 09-Jul-90 L. Rooijakkers
wenzelm@2658
     4
% 08-Oct-90 L. Rooijakkers	fixed centering bug when \rail@tmpc<0.
wenzelm@2658
     5
% 07-Feb-91 L. Rooijakkers	added \railoptions command, indexing
wenzelm@2658
     6
% 08-Feb-91 L. Rooijakkers	minor fixes
berghofe@3097
     7
% 28-Jun-94 K. Barthelmann	turned into LaTeX2e package
berghofe@3097
     8
% 08-Dec-96 K. Barthelmann	replaced \@writefile
berghofe@3097
     9
% 13-Dec-96 K. Barthelmann	cleanup
wenzelm@2658
    10
%
wenzelm@2658
    11
% This style file needs to be used in conjunction with the 'rail'
wenzelm@2658
    12
% program. Running LaTeX as 'latex file' produces file.rai, which should be
wenzelm@2658
    13
% processed by Rail with 'rail file'. This produces file.rao, which will
wenzelm@2658
    14
% be picked up by LaTeX on the next 'latex file' run.
wenzelm@2658
    15
%
wenzelm@2658
    16
% LaTeX will warn if there is no file.rao or it's out of date.
wenzelm@2658
    17
%
wenzelm@2658
    18
% The macros in this file thus consist of two parts: those that read and
wenzelm@2658
    19
% write the .rai and .rao files, and those that do the actual formatting
wenzelm@2658
    20
% of the railroad diagrams.
wenzelm@2658
    21
berghofe@3097
    22
\NeedsTeXFormat{LaTeX2e}
berghofe@3097
    23
\ProvidesPackage{rail}[1996/12/13]
wenzelm@2658
    24
wenzelm@2658
    25
% railroad diagram formatting parameters (user level)
wenzelm@2658
    26
% all of these are copied into their internal versions by \railinit
wenzelm@2658
    27
%
wenzelm@2658
    28
% \railunit : \unitlength within railroad diagrams
wenzelm@2658
    29
% \railextra : extra length at outside of diagram
wenzelm@2658
    30
% \railboxheight : height of ovals and frames
wenzelm@2658
    31
% \railboxskip : vertical space between lines
wenzelm@2658
    32
% \railboxleft : space to the left of a box
wenzelm@2658
    33
% \railboxright : space to the right of a box
wenzelm@2658
    34
% \railovalspace : extra space around contents of oval
wenzelm@2658
    35
% \railframespace : extra space around contents of frame
wenzelm@2658
    36
% \railtextleft : space to the left of text
wenzelm@2658
    37
% \railtextright : space to the right of text
wenzelm@2658
    38
% \railtextup : space to lift text up
wenzelm@2658
    39
% \railjoinsize : circle size of join/split arcs
wenzelm@2658
    40
% \railjoinadjust : space to adjust join
wenzelm@2658
    41
%
wenzelm@2658
    42
% \railnamesep : separator between name and rule body
wenzelm@2658
    43
berghofe@3097
    44
\newlength\railunit
berghofe@3097
    45
\newlength\railextra
berghofe@3097
    46
\newlength\railboxheight
berghofe@3097
    47
\newlength\railboxskip
berghofe@3097
    48
\newlength\railboxleft
berghofe@3097
    49
\newlength\railboxright
berghofe@3097
    50
\newlength\railovalspace
berghofe@3097
    51
\newlength\railframespace
berghofe@3097
    52
\newlength\railtextleft
berghofe@3097
    53
\newlength\railtextright
berghofe@3097
    54
\newlength\railtextup
berghofe@3097
    55
\newlength\railjoinsize
berghofe@3097
    56
\newlength\railjoinadjust
berghofe@3097
    57
\newlength\railnamesep
berghofe@3097
    58
berghofe@3097
    59
% initialize the parameters
berghofe@3097
    60
berghofe@3097
    61
\setlength\railunit{1sp}
berghofe@3097
    62
\setlength\railextra{4ex}
berghofe@3097
    63
\setlength\railboxleft{1ex}
berghofe@3097
    64
\setlength\railboxright{1ex}
berghofe@3097
    65
\setlength\railovalspace{2ex}
berghofe@3097
    66
\setlength\railframespace{2ex}
berghofe@3097
    67
\setlength\railtextleft{1ex}
berghofe@3097
    68
\setlength\railtextright{1ex}
berghofe@3097
    69
\setlength\railjoinadjust{0pt}
berghofe@3097
    70
\setlength\railnamesep{1ex}
berghofe@3097
    71
berghofe@3097
    72
\DeclareOption{10pt}{
berghofe@3097
    73
  \setlength\railboxheight{16pt}
berghofe@3097
    74
  \setlength\railboxskip{24pt}
berghofe@3097
    75
  \setlength\railtextup{5pt}
berghofe@3097
    76
  \setlength\railjoinsize{16pt}
berghofe@3097
    77
}
berghofe@3097
    78
\DeclareOption{11pt}{
berghofe@3097
    79
  \setlength\railboxheight{16pt}
berghofe@3097
    80
  \setlength\railboxskip{24pt}
berghofe@3097
    81
  \setlength\railtextup{5pt}
berghofe@3097
    82
  \setlength\railjoinsize{16pt}
berghofe@3097
    83
}
berghofe@3097
    84
\DeclareOption{12pt}{
berghofe@3097
    85
  \setlength\railboxheight{20pt}
berghofe@3097
    86
  \setlength\railboxskip{28pt}
berghofe@3097
    87
  \setlength\railtextup{6pt}
berghofe@3097
    88
  \setlength\railjoinsize{20pt}
berghofe@3097
    89
}
berghofe@3097
    90
berghofe@3097
    91
\ExecuteOptions{10pt}
berghofe@3097
    92
\ProcessOptions
wenzelm@2658
    93
wenzelm@2658
    94
% internal versions of the formatting parameters
wenzelm@2658
    95
%
wenzelm@2658
    96
% \rail@extra   : \railextra
wenzelm@2658
    97
% \rail@boxht   : \railboxheight
wenzelm@2658
    98
% \rail@boxsp   : \railboxskip
wenzelm@2658
    99
% \rail@boxlf   : \railboxleft
wenzelm@2658
   100
% \rail@boxrt   : \railboxright
wenzelm@2658
   101
% \rail@boxhht  : \railboxheight / 2
wenzelm@2658
   102
% \rail@ovalsp  : \railovalspace
wenzelm@2658
   103
% \rail@framesp : \railframespace
wenzelm@2658
   104
% \rail@textlf	: \railtextleft
wenzelm@2658
   105
% \rail@textrt	: \railtextright
wenzelm@2658
   106
% \rail@textup	: \railtextup
wenzelm@2658
   107
% \rail@joinsz  : \railjoinsize
wenzelm@2658
   108
% \rail@joinhsz : \railjoinsize / 2
wenzelm@2658
   109
% \rail@joinadj : \railjoinadjust
wenzelm@2658
   110
%
wenzelm@2658
   111
% \railinit : internalize all of the parameters.
wenzelm@2658
   112
wenzelm@2658
   113
\newcount\rail@extra
wenzelm@2658
   114
\newcount\rail@boxht
wenzelm@2658
   115
\newcount\rail@boxsp
wenzelm@2658
   116
\newcount\rail@boxlf
wenzelm@2658
   117
\newcount\rail@boxrt
wenzelm@2658
   118
\newcount\rail@boxhht
wenzelm@2658
   119
\newcount\rail@ovalsp
wenzelm@2658
   120
\newcount\rail@framesp
wenzelm@2658
   121
\newcount\rail@textlf
wenzelm@2658
   122
\newcount\rail@textrt
wenzelm@2658
   123
\newcount\rail@textup
wenzelm@2658
   124
\newcount\rail@joinsz
wenzelm@2658
   125
\newcount\rail@joinhsz
wenzelm@2658
   126
\newcount\rail@joinadj
wenzelm@2658
   127
berghofe@3097
   128
\newcommand\railinit{
wenzelm@2658
   129
\rail@extra=\railextra
wenzelm@2658
   130
\divide\rail@extra by \railunit
wenzelm@2658
   131
\rail@boxht=\railboxheight
wenzelm@2658
   132
\divide\rail@boxht by \railunit
wenzelm@2658
   133
\rail@boxsp=\railboxskip
wenzelm@2658
   134
\divide\rail@boxsp by \railunit
wenzelm@2658
   135
\rail@boxlf=\railboxleft
wenzelm@2658
   136
\divide\rail@boxlf by \railunit
wenzelm@2658
   137
\rail@boxrt=\railboxright
wenzelm@2658
   138
\divide\rail@boxrt by \railunit
wenzelm@2658
   139
\rail@boxhht=\railboxheight
wenzelm@2658
   140
\divide\rail@boxhht by \railunit
wenzelm@2658
   141
\divide\rail@boxhht by 2
wenzelm@2658
   142
\rail@ovalsp=\railovalspace
wenzelm@2658
   143
\divide\rail@ovalsp by \railunit
wenzelm@2658
   144
\rail@framesp=\railframespace
wenzelm@2658
   145
\divide\rail@framesp by \railunit
wenzelm@2658
   146
\rail@textlf=\railtextleft
wenzelm@2658
   147
\divide\rail@textlf by \railunit
wenzelm@2658
   148
\rail@textrt=\railtextright
wenzelm@2658
   149
\divide\rail@textrt by \railunit
wenzelm@2658
   150
\rail@textup=\railtextup
wenzelm@2658
   151
\divide\rail@textup by \railunit
wenzelm@2658
   152
\rail@joinsz=\railjoinsize
wenzelm@2658
   153
\divide\rail@joinsz by \railunit
wenzelm@2658
   154
\rail@joinhsz=\railjoinsize
wenzelm@2658
   155
\divide\rail@joinhsz by \railunit
wenzelm@2658
   156
\divide\rail@joinhsz by 2
wenzelm@2658
   157
\rail@joinadj=\railjoinadjust
wenzelm@2658
   158
\divide\rail@joinadj by \railunit
wenzelm@2658
   159
}
wenzelm@2658
   160
berghofe@3097
   161
\AtBeginDocument{\railinit}
wenzelm@2658
   162
berghofe@3097
   163
% \rail@param : declarations for list environment
berghofe@3097
   164
%
berghofe@3097
   165
% \railparam{TEXT} : sets \rail@param to TEXT
wenzelm@2658
   166
berghofe@3097
   167
\def\rail@param{}
berghofe@3097
   168
berghofe@3097
   169
\newcommand\railparam[1]{
berghofe@3097
   170
\def\rail@param{#1}
berghofe@3097
   171
}
berghofe@3097
   172
berghofe@3097
   173
% \rail@tokenfont : format setup for \railtoken identifiers
berghofe@3097
   174
%
berghofe@3097
   175
% \rail@termfont : format setup for terminals
berghofe@3097
   176
%
berghofe@3097
   177
% \rail@nontfont : format setup for nonterminals
berghofe@3097
   178
%
berghofe@3097
   179
% \rail@annofont : format setup for annotations
berghofe@3097
   180
%
berghofe@3097
   181
% \rail@rulefont : format setup for rule names
berghofe@3097
   182
%
berghofe@3097
   183
% \rail@indexfont : format setup for index entry
berghofe@3097
   184
%
berghofe@3097
   185
% \railtermfont{TEXT} : set terminal format setup to TEXT
berghofe@3097
   186
%
berghofe@3097
   187
% \railnontermfont{TEXT} : set nonterminal format setup to TEXT
berghofe@3097
   188
%
berghofe@3097
   189
% \railannotatefont{TEXT} : set annotation format setup to TEXT
berghofe@3097
   190
%
berghofe@3097
   191
% \railnamefont{TEXT} : set rule name format setup to TEXT
berghofe@3097
   192
%
berghofe@3097
   193
% \railindexfont{TEXT} : set index entry format setup to TEXT
berghofe@3097
   194
berghofe@3097
   195
\def\rail@termfont{\ttfamily\upshape}
berghofe@3097
   196
\def\rail@nontfont{\rmfamily\upshape}
berghofe@3097
   197
\def\rail@annofont{\rmfamily\itshape}
berghofe@3097
   198
\def\rail@namefont{\rmfamily\itshape}
berghofe@3097
   199
\def\rail@indexfont{\rmfamily\itshape}
berghofe@3097
   200
berghofe@3097
   201
\newcommand\railtermfont[1]{
berghofe@3097
   202
\def\rail@termfont{#1}
berghofe@3097
   203
}
berghofe@3097
   204
berghofe@3097
   205
\newcommand\railnontermfont[1]{
berghofe@3097
   206
\def\rail@nontfont{#1}
berghofe@3097
   207
}
berghofe@3097
   208
berghofe@3097
   209
\newcommand\railannotatefont[1]{
berghofe@3097
   210
\def\rail@annofont{#1}
berghofe@3097
   211
}
berghofe@3097
   212
berghofe@3097
   213
\newcommand\railnamefont[1]{
berghofe@3097
   214
\def\rail@namefont{#1}
berghofe@3097
   215
}
berghofe@3097
   216
berghofe@3097
   217
\newcommand\railindexfont[1]{
berghofe@3097
   218
\def\rail@indexfont{#1}
berghofe@3097
   219
}
berghofe@3097
   220
berghofe@3097
   221
% railroad read/write macros
berghofe@3097
   222
%
berghofe@3097
   223
% \begin{rail} TEXT \end{rail} : TEXT is written out to the .rai file,
berghofe@3097
   224
%                                as \rail@i{NR}{TEXT}. Then the matching
berghofe@3097
   225
%                                \rail@o{NR}{FMT} from the .rao file is
berghofe@3097
   226
%                                executed (if defined).
berghofe@3097
   227
%
berghofe@3097
   228
% \railoptions{OPTIONS} : OPTIONS are written out to the .rai file,
berghofe@3097
   229
%                         as \rail@p{OPTIONS}.
berghofe@3097
   230
%
berghofe@3097
   231
% \railterm{IDENT,IDENT,...} : format IDENT as terminals. writes out
berghofe@3097
   232
%                              \rail@t{IDENT} to the .rai file
berghofe@3097
   233
%
berghofe@3097
   234
% \railalias{IDENT}{TEXT} : format IDENT as TEXT. defines \rail@t@IDENT as
berghofe@3097
   235
%                           TEXT.
berghofe@3097
   236
%
berghofe@3097
   237
% \rail@nr : railroad diagram counter
berghofe@3097
   238
%
berghofe@3097
   239
% \ifrail@match : current \rail@i{NR}{TEXT} matches
berghofe@3097
   240
%
berghofe@3097
   241
% \rail@first :	actions to be done first. read in .rao file,
berghofe@3097
   242
%               open .rai file if \@filesw true, undefine \rail@first.
berghofe@3097
   243
%               executed from \begin{rail} and \railtoken.
berghofe@3097
   244
%
berghofe@3097
   245
% \rail@i{NR}{TEXT} : defines \rail@i@NR as TEXT. written to the .rai
berghofe@3097
   246
%                     file by \rail, read from the .rao file by
berghofe@3097
   247
%                     \rail@first
berghofe@3097
   248
%
berghofe@3097
   249
% \rail@t{IDENT} : tells Rail that IDENT is to be custom formatted,
berghofe@3097
   250
%                  written to the .rai file by \railterm.
berghofe@3097
   251
%
berghofe@3097
   252
% \rail@o{NR}{TEXT} : defines \rail@o@NR as TEXT, read from the .rao
berghofe@3097
   253
%                     file by \rail@first.
berghofe@3097
   254
%
berghofe@3097
   255
% \rail@p{OPTIONS} : pass options to rail, written to the .rai file by
berghofe@3097
   256
%                    \railoptions
berghofe@3097
   257
%
berghofe@3097
   258
% \rail@write{TEXT} : write TEXT to the .rai file
berghofe@3097
   259
%
berghofe@3097
   260
% \rail@warn : warn user for mismatching diagrams
berghofe@3097
   261
%
berghofe@3097
   262
% \rail@endwarn : either \relax or \rail@warn
berghofe@3097
   263
%
berghofe@3097
   264
% \ifrail@all : checked at the end of the document
berghofe@3097
   265
berghofe@3097
   266
\newcount\rail@nr
berghofe@3097
   267
berghofe@3097
   268
\newif\ifrail@all
berghofe@3097
   269
\rail@alltrue
berghofe@3097
   270
berghofe@3097
   271
\newif\ifrail@match
berghofe@3097
   272
berghofe@3097
   273
\def\rail@first{
berghofe@3097
   274
\makeatletter
berghofe@3097
   275
\InputIfFileExists{\jobname.rao}{}{\PackageInfo{rail}{No file \jobname.rao}}
berghofe@3097
   276
\makeatother
berghofe@3097
   277
\if@filesw
berghofe@3097
   278
\newwrite\tf@rai
berghofe@3097
   279
\immediate\openout\tf@rai=\jobname.rai
wenzelm@2658
   280
\fi
berghofe@3097
   281
\global\let\rail@first=\relax
berghofe@3097
   282
}
wenzelm@2658
   283
berghofe@3097
   284
\long\def\rail@body#1\end{
berghofe@3097
   285
\begingroup
berghofe@3097
   286
\let\\=\relax
berghofe@3097
   287
\xdef\rail@i@{#1}
berghofe@3097
   288
\rail@write{\string\rail@i{\number\rail@nr}{\rail@i@}}
berghofe@3097
   289
\endgroup
berghofe@3097
   290
\end
berghofe@3097
   291
}
berghofe@3097
   292
berghofe@3097
   293
\newenvironment{rail}{
berghofe@3097
   294
\global\advance\rail@nr by 1
berghofe@3097
   295
\rail@first
berghofe@3097
   296
\rail@body
berghofe@3097
   297
}{
berghofe@3097
   298
\rail@matchtrue
berghofe@3097
   299
\@ifundefined{rail@o@\number\rail@nr}{\rail@matchfalse}{}
berghofe@3097
   300
\expandafter\ifx\csname rail@i@\number\rail@nr\endcsname\rail@i@
berghofe@3097
   301
\else
berghofe@3097
   302
\rail@matchfalse
berghofe@3097
   303
\fi
berghofe@3097
   304
\ifrail@match
berghofe@3097
   305
\csname rail@o@\number\rail@nr\endcsname
berghofe@3097
   306
\else
berghofe@3097
   307
\PackageWarning{rail}{Railroad diagram {\number\rail@nr} doesn't match}
berghofe@3097
   308
\global\let\rail@endwarn=\rail@warn
berghofe@3097
   309
\begin{list}{}{\rail@param}
berghofe@3097
   310
\rail@begin{1}{}
berghofe@3097
   311
\rail@setbox{\bfseries ???}
berghofe@3097
   312
\rail@oval
berghofe@3097
   313
\rail@end
berghofe@3097
   314
\end{list}
berghofe@3097
   315
\fi
berghofe@3097
   316
}
berghofe@3097
   317
berghofe@3097
   318
\newcommand\railoptions[1]{
berghofe@3097
   319
\rail@first
berghofe@3097
   320
\rail@write{\string\rail@p{#1}}
berghofe@3097
   321
}
berghofe@3097
   322
berghofe@3097
   323
\newcommand\railterm[1]{
berghofe@3097
   324
\rail@first
berghofe@3097
   325
\@for\rail@@:=#1\do{
berghofe@3097
   326
\rail@write{\string\rail@t{\rail@@}}
berghofe@3097
   327
}
berghofe@3097
   328
}
berghofe@3097
   329
berghofe@3097
   330
\newcommand\railalias[2]{
berghofe@3097
   331
\expandafter\def\csname rail@t@#1\endcsname{#2}
berghofe@3097
   332
}
berghofe@3097
   333
berghofe@3097
   334
\long\def\rail@i#1#2{
berghofe@3097
   335
\expandafter\gdef\csname rail@i@#1\endcsname{#2}
berghofe@3097
   336
}
berghofe@3097
   337
berghofe@3097
   338
\def\rail@o#1#2{
berghofe@3097
   339
\expandafter\gdef\csname rail@o@#1\endcsname{
berghofe@3097
   340
\begin{list}{}{\rail@param}#2\end{list}
berghofe@3097
   341
}
berghofe@3097
   342
}
berghofe@3097
   343
berghofe@3097
   344
\def\rail@t#1{}
berghofe@3097
   345
berghofe@3097
   346
\def\rail@p#1{}
berghofe@3097
   347
berghofe@3097
   348
\def\rail@write#1{\@ifundefined{tf@rai}{}{\immediate\write\tf@rai{#1}}}
berghofe@3097
   349
berghofe@3097
   350
\def\rail@warn{
berghofe@3097
   351
\PackageWarningNoLine{rail}{Railroad diagram(s) may have changed.
berghofe@3097
   352
                            Use 'rail' and rerun}
berghofe@3097
   353
}
berghofe@3097
   354
berghofe@3097
   355
\let\rail@endwarn=\relax
berghofe@3097
   356
berghofe@3097
   357
\AtEndDocument{\rail@endwarn}
berghofe@3097
   358
berghofe@3097
   359
% index entry macro
berghofe@3097
   360
%
berghofe@3097
   361
% \rail@index{IDENT} : add index entry for IDENT
berghofe@3097
   362
berghofe@3097
   363
\def\rail@index#1{
berghofe@3097
   364
\index{\rail@indexfont#1}
berghofe@3097
   365
}
wenzelm@2658
   366
wenzelm@2658
   367
% railroad formatting primitives
wenzelm@2658
   368
%
wenzelm@2658
   369
% \rail@x : current x
wenzelm@2658
   370
% \rail@y : current y
wenzelm@2658
   371
% \rail@ex : current end x
wenzelm@2658
   372
% \rail@sx : starting x for \rail@cr
wenzelm@2658
   373
% \rail@rx : rightmost previous x for \rail@cr
wenzelm@2658
   374
%
wenzelm@2658
   375
% \rail@tmpa : temporary count
wenzelm@2658
   376
% \rail@tmpb : temporary count
wenzelm@2658
   377
% \rail@tmpc : temporary count
wenzelm@2658
   378
%
wenzelm@2658
   379
% \rail@put : put at (\rail@x,\rail@y)
wenzelm@2658
   380
%
wenzelm@2658
   381
% \rail@eline : end line by drawing from \rail@ex to \rail@x
wenzelm@2658
   382
%
wenzelm@2658
   383
% \rail@sety{LEVEL} : set \rail@y to level LEVEL
wenzelm@2658
   384
wenzelm@2658
   385
\newcount\rail@x
wenzelm@2658
   386
\newcount\rail@y
wenzelm@2658
   387
\newcount\rail@ex
wenzelm@2658
   388
\newcount\rail@sx
wenzelm@2658
   389
\newcount\rail@rx
wenzelm@2658
   390
wenzelm@2658
   391
\newcount\rail@tmpa
wenzelm@2658
   392
\newcount\rail@tmpb
wenzelm@2658
   393
\newcount\rail@tmpc
wenzelm@2658
   394
wenzelm@2658
   395
\def\rail@put{\put(\number\rail@x,\number\rail@y)}
wenzelm@2658
   396
wenzelm@2658
   397
\def\rail@eline{
wenzelm@2658
   398
\rail@tmpb=\rail@x
wenzelm@2658
   399
\advance\rail@tmpb by -\rail@ex
wenzelm@2658
   400
\rail@put{\line(-1,0){\number\rail@tmpb}}
wenzelm@2658
   401
}
wenzelm@2658
   402
wenzelm@2658
   403
\def\rail@sety#1{
wenzelm@2658
   404
\rail@y=#1
wenzelm@2658
   405
\multiply\rail@y by -\rail@boxsp
wenzelm@2658
   406
\advance\rail@y by -\rail@boxht
wenzelm@2658
   407
}
wenzelm@2658
   408
wenzelm@2658
   409
% \rail@begin{HEIGHT}{NAME} : begin a railroad diagram of height HEIGHT
wenzelm@2658
   410
%
wenzelm@2658
   411
% \rail@end : end a railroad diagram
berghofe@3097
   412
%
berghofe@3097
   413
% \rail@expand{IDENT} : expand IDENT
wenzelm@2658
   414
wenzelm@2658
   415
\def\rail@begin#1#2{
wenzelm@2658
   416
\item[]
berghofe@3097
   417
\begin{minipage}[t]{\linewidth}
wenzelm@2658
   418
\ifx\@empty#2\else
berghofe@3097
   419
{\rail@namefont \rail@expand{#2}}\\*[\railnamesep]
wenzelm@2658
   420
\fi
wenzelm@2658
   421
\unitlength=\railunit
wenzelm@2658
   422
\rail@tmpa=#1
wenzelm@2658
   423
\multiply\rail@tmpa by \rail@boxsp
wenzelm@2658
   424
\begin{picture}(0,\number\rail@tmpa)(0,-\number\rail@tmpa)
wenzelm@2658
   425
\rail@ex=0
wenzelm@2658
   426
\rail@rx=0
wenzelm@2658
   427
\rail@x=\rail@extra
wenzelm@2658
   428
\rail@sx=\rail@x
wenzelm@2658
   429
\rail@sety{0}
wenzelm@2658
   430
}
wenzelm@2658
   431
wenzelm@2658
   432
\def\rail@end{
wenzelm@2658
   433
\advance\rail@x by \rail@extra
wenzelm@2658
   434
\rail@eline
wenzelm@2658
   435
\end{picture}
berghofe@3097
   436
\end{minipage}
wenzelm@2658
   437
}
wenzelm@2658
   438
berghofe@3097
   439
\def\rail@expand#1{\@ifundefined{rail@t@#1}{#1}{\csname rail@t@#1\endcsname}}
berghofe@3097
   440
berghofe@3097
   441
% \rail@token{TEXT}[ANNOT] : format token TEXT with annotation
wenzelm@2658
   442
%
berghofe@3097
   443
% \rail@ctoken{TEXT}[ANNOT] : format token TEXT centered with annotation
wenzelm@2658
   444
%
berghofe@3097
   445
% \rail@nont{TEXT}[ANNOT] : format nonterminal TEXT with annotation
wenzelm@2658
   446
%
berghofe@3097
   447
% \rail@cnont{TEXT}[ANNOT] : format nonterminal TEXT centered with annotation
wenzelm@2658
   448
%
berghofe@3097
   449
% \rail@term{TEXT}[ANNOT] : format terminal TEXT with annotation
wenzelm@2658
   450
%
berghofe@3097
   451
% \rail@cterm{TEXT}[ANNOT] : format terminal TEXT centered with annotation
wenzelm@2658
   452
%
wenzelm@2658
   453
% \rail@annote[TEXT] : format TEXT as annotation
wenzelm@2658
   454
berghofe@3097
   455
\def\rail@token#1[#2]{
berghofe@3097
   456
\rail@setbox{%
berghofe@3097
   457
{\rail@termfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
wenzelm@2658
   458
}
wenzelm@2658
   459
\rail@oval
wenzelm@2658
   460
}
wenzelm@2658
   461
berghofe@3097
   462
\def\rail@ctoken#1[#2]{
berghofe@3097
   463
\rail@setbox{%
berghofe@3097
   464
{\rail@termfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   465
}
wenzelm@2658
   466
\rail@coval
wenzelm@2658
   467
}
wenzelm@2658
   468
berghofe@3097
   469
\def\rail@nont#1[#2]{
berghofe@3097
   470
\rail@setbox{%
berghofe@3097
   471
{\rail@nontfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   472
}
wenzelm@2658
   473
\rail@frame
wenzelm@2658
   474
}
wenzelm@2658
   475
berghofe@3097
   476
\def\rail@cnont#1[#2]{
berghofe@3097
   477
\rail@setbox{%
berghofe@3097
   478
{\rail@nontfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   479
}
wenzelm@2658
   480
\rail@cframe
wenzelm@2658
   481
}
wenzelm@2658
   482
berghofe@3097
   483
\def\rail@term#1[#2]{
berghofe@3097
   484
\rail@setbox{%
berghofe@3097
   485
{\rail@termfont #1}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   486
}
wenzelm@2658
   487
\rail@oval
wenzelm@2658
   488
}
wenzelm@2658
   489
berghofe@3097
   490
\def\rail@cterm#1[#2]{
berghofe@3097
   491
\rail@setbox{%
berghofe@3097
   492
{\rail@termfont #1}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   493
}
wenzelm@2658
   494
\rail@coval
wenzelm@2658
   495
}
wenzelm@2658
   496
wenzelm@2658
   497
\def\rail@annote[#1]{
wenzelm@2658
   498
\rail@setbox{\rail@annofont #1}
wenzelm@2658
   499
\rail@text
wenzelm@2658
   500
}
wenzelm@2658
   501
wenzelm@2658
   502
% \rail@box : temporary box for \rail@oval and \rail@frame
wenzelm@2658
   503
%
wenzelm@2658
   504
% \rail@setbox{TEXT} : set \rail@box to TEXT, set \rail@tmpa to width
wenzelm@2658
   505
%
wenzelm@2658
   506
% \rail@oval : format \rail@box of width \rail@tmpa inside an oval
wenzelm@2658
   507
%
wenzelm@2658
   508
% \rail@coval : same as \rail@oval, but centered between \rail@x and
wenzelm@2658
   509
%               \rail@mx
wenzelm@2658
   510
%
wenzelm@2658
   511
% \rail@frame : format \rail@box of width \rail@tmpa inside a frame
wenzelm@2658
   512
%
wenzelm@2658
   513
% \rail@cframe : same as \rail@frame, but centered between \rail@x and
wenzelm@2658
   514
%                \rail@mx
wenzelm@2658
   515
%
wenzelm@2658
   516
% \rail@text : format \rail@box of width \rail@tmpa above the line
wenzelm@2658
   517
wenzelm@2658
   518
\newbox\rail@box
wenzelm@2658
   519
wenzelm@2658
   520
\def\rail@setbox#1{
wenzelm@2658
   521
\setbox\rail@box\hbox{\strut#1}
wenzelm@2658
   522
\rail@tmpa=\wd\rail@box
wenzelm@2658
   523
\divide\rail@tmpa by \railunit
wenzelm@2658
   524
}
wenzelm@2658
   525
wenzelm@2658
   526
\def\rail@oval{
wenzelm@2658
   527
\advance\rail@x by \rail@boxlf
wenzelm@2658
   528
\rail@eline
wenzelm@2658
   529
\advance\rail@tmpa by \rail@ovalsp
wenzelm@2658
   530
\ifnum\rail@tmpa<\rail@boxht\rail@tmpa=\rail@boxht\fi
wenzelm@2658
   531
\rail@tmpb=\rail@tmpa
wenzelm@2658
   532
\divide\rail@tmpb by 2
wenzelm@2658
   533
\advance\rail@y by -\rail@boxhht
wenzelm@2658
   534
\rail@put{\makebox(\number\rail@tmpa,\number\rail@boxht){\box\rail@box}}
wenzelm@2658
   535
\advance\rail@y by \rail@boxhht
wenzelm@2658
   536
\advance\rail@x by \rail@tmpb
wenzelm@2658
   537
\rail@put{\oval(\number\rail@tmpa,\number\rail@boxht)}
wenzelm@2658
   538
\advance\rail@x by \rail@tmpb
wenzelm@2658
   539
\rail@ex=\rail@x
wenzelm@2658
   540
\advance\rail@x by \rail@boxrt
wenzelm@2658
   541
}
wenzelm@2658
   542
wenzelm@2658
   543
\def\rail@coval{
wenzelm@2658
   544
\rail@tmpb=\rail@tmpa
wenzelm@2658
   545
\advance\rail@tmpb by \rail@ovalsp
wenzelm@2658
   546
\ifnum\rail@tmpb<\rail@boxht\rail@tmpb=\rail@boxht\fi
wenzelm@2658
   547
\advance\rail@tmpb by \rail@boxlf
wenzelm@2658
   548
\advance\rail@tmpb by \rail@boxrt
wenzelm@2658
   549
\rail@tmpc=\rail@mx
wenzelm@2658
   550
\advance\rail@tmpc by -\rail@x
wenzelm@2658
   551
\advance\rail@tmpc by -\rail@tmpb
wenzelm@2658
   552
\divide\rail@tmpc by 2
wenzelm@2658
   553
\ifnum\rail@tmpc>0
wenzelm@2658
   554
\advance\rail@x by \rail@tmpc
wenzelm@2658
   555
\fi
wenzelm@2658
   556
\rail@oval
wenzelm@2658
   557
}
wenzelm@2658
   558
wenzelm@2658
   559
\def\rail@frame{
wenzelm@2658
   560
\advance\rail@x by \rail@boxlf
wenzelm@2658
   561
\rail@eline
wenzelm@2658
   562
\advance\rail@tmpa by \rail@framesp
wenzelm@2658
   563
\ifnum\rail@tmpa<\rail@boxht\rail@tmpa=\rail@boxht\fi
wenzelm@2658
   564
\advance\rail@y by -\rail@boxhht
wenzelm@2658
   565
\rail@put{\framebox(\number\rail@tmpa,\number\rail@boxht){\box\rail@box}}
wenzelm@2658
   566
\advance\rail@y by \rail@boxhht
wenzelm@2658
   567
\advance\rail@x by \rail@tmpa
wenzelm@2658
   568
\rail@ex=\rail@x
wenzelm@2658
   569
\advance\rail@x by \rail@boxrt
wenzelm@2658
   570
}
wenzelm@2658
   571
wenzelm@2658
   572
\def\rail@cframe{
wenzelm@2658
   573
\rail@tmpb=\rail@tmpa
wenzelm@2658
   574
\advance\rail@tmpb by \rail@framesp
wenzelm@2658
   575
\ifnum\rail@tmpb<\rail@boxht\rail@tmpb=\rail@boxht\fi
wenzelm@2658
   576
\advance\rail@tmpb by \rail@boxlf
wenzelm@2658
   577
\advance\rail@tmpb by \rail@boxrt
wenzelm@2658
   578
\rail@tmpc=\rail@mx
wenzelm@2658
   579
\advance\rail@tmpc by -\rail@x
wenzelm@2658
   580
\advance\rail@tmpc by -\rail@tmpb
wenzelm@2658
   581
\divide\rail@tmpc by 2
wenzelm@2658
   582
\ifnum\rail@tmpc>0
wenzelm@2658
   583
\advance\rail@x by \rail@tmpc
wenzelm@2658
   584
\fi
wenzelm@2658
   585
\rail@frame
wenzelm@2658
   586
}
wenzelm@2658
   587
wenzelm@2658
   588
\def\rail@text{
wenzelm@2658
   589
\advance\rail@x by \rail@textlf
wenzelm@2658
   590
\advance\rail@y by \rail@textup
wenzelm@2658
   591
\rail@put{\box\rail@box}
wenzelm@2658
   592
\advance\rail@y by -\rail@textup
wenzelm@2658
   593
\advance\rail@x by \rail@tmpa
wenzelm@2658
   594
\advance\rail@x by \rail@textrt
wenzelm@2658
   595
}
wenzelm@2658
   596
wenzelm@2658
   597
% alternatives
wenzelm@2658
   598
%
wenzelm@2658
   599
% \rail@jx \rail@jy : current join point
wenzelm@2658
   600
%
wenzelm@2658
   601
% \rail@gx \rail@gy \rail@gex \rail@grx : global versions of \rail@x etc,
wenzelm@2658
   602
%                                         to pass values over group closings
wenzelm@2658
   603
%
wenzelm@2658
   604
% \rail@mx : maximum x so far
wenzelm@2658
   605
%
wenzelm@2658
   606
% \rail@sy : starting \rail@y for alternatives
wenzelm@2658
   607
%
wenzelm@2658
   608
% \rail@jput : put at (\rail@jx,\rail@jy)
wenzelm@2658
   609
%
wenzelm@2658
   610
% \rail@joval[PART] : put \oval[PART] with adjust
wenzelm@2658
   611
wenzelm@2658
   612
\newcount\rail@jx
wenzelm@2658
   613
\newcount\rail@jy
wenzelm@2658
   614
wenzelm@2658
   615
\newcount\rail@gx
wenzelm@2658
   616
\newcount\rail@gy
wenzelm@2658
   617
\newcount\rail@gex
wenzelm@2658
   618
\newcount\rail@grx
wenzelm@2658
   619
wenzelm@2658
   620
\newcount\rail@sy
wenzelm@2658
   621
\newcount\rail@mx
wenzelm@2658
   622
wenzelm@2658
   623
\def\rail@jput{
wenzelm@2658
   624
\put(\number\rail@jx,\number\rail@jy)
wenzelm@2658
   625
}
wenzelm@2658
   626
wenzelm@2658
   627
\def\rail@joval[#1]{
wenzelm@2658
   628
\advance\rail@jx by \rail@joinadj
wenzelm@2658
   629
\rail@jput{\oval(\number\rail@joinsz,\number\rail@joinsz)[#1]}
wenzelm@2658
   630
\advance\rail@jx by -\rail@joinadj
wenzelm@2658
   631
}
wenzelm@2658
   632
wenzelm@2658
   633
% \rail@barsplit : incoming split for '|'
wenzelm@2658
   634
%
wenzelm@2658
   635
% \rail@plussplit : incoming split for '+'
wenzelm@2658
   636
%
wenzelm@2658
   637
wenzelm@2658
   638
\def\rail@barsplit{
wenzelm@2658
   639
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   640
\rail@joval[tr]
wenzelm@2658
   641
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   642
}
wenzelm@2658
   643
wenzelm@2658
   644
\def\rail@plussplit{
wenzelm@2658
   645
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   646
\advance\rail@jx by \rail@joinsz
wenzelm@2658
   647
\rail@joval[tl]
wenzelm@2658
   648
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   649
}
wenzelm@2658
   650
wenzelm@2658
   651
% \rail@alt{SPLIT} : start alternatives with incoming split SPLIT
wenzelm@2658
   652
%
wenzelm@2658
   653
wenzelm@2658
   654
\def\rail@alt#1{
wenzelm@2658
   655
\rail@sy=\rail@y
wenzelm@2658
   656
\rail@jx=\rail@x
wenzelm@2658
   657
\rail@jy=\rail@y
wenzelm@2658
   658
\advance\rail@x by \rail@joinsz
wenzelm@2658
   659
\rail@mx=0
wenzelm@2658
   660
\let\rail@list=\@empty
wenzelm@2658
   661
\let\rail@comma=\@empty
wenzelm@2658
   662
\let\rail@split=#1
wenzelm@2658
   663
\begingroup
wenzelm@2658
   664
\rail@sx=\rail@x
wenzelm@2658
   665
\rail@rx=0
wenzelm@2658
   666
}
wenzelm@2658
   667
wenzelm@2658
   668
% \rail@nextalt{FIX}{Y} : start next alternative at vertical position Y
wenzelm@2658
   669
%                         and fix-up FIX
wenzelm@2658
   670
%
wenzelm@2658
   671
wenzelm@2658
   672
\def\rail@nextalt#1#2{
wenzelm@2658
   673
\global\rail@gx=\rail@x
wenzelm@2658
   674
\global\rail@gy=\rail@y
wenzelm@2658
   675
\global\rail@gex=\rail@ex
wenzelm@2658
   676
\global\rail@grx=\rail@rx
wenzelm@2658
   677
\endgroup
wenzelm@2658
   678
#1
wenzelm@2658
   679
\ifnum\rail@gx>\rail@mx\rail@mx=\rail@gx\fi
wenzelm@2658
   680
\ifnum\rail@grx>\rail@mx\rail@mx=\rail@grx\fi
wenzelm@2658
   681
\edef\rail@list{\rail@list\rail@comma\number\rail@gex:\number\rail@gy}
wenzelm@2658
   682
\def\rail@comma{,}
wenzelm@2658
   683
\rail@split
wenzelm@2658
   684
\let\rail@split=\@empty
wenzelm@2658
   685
\rail@sety{#2}
wenzelm@2658
   686
\rail@tmpa=\rail@jy
wenzelm@2658
   687
\advance\rail@tmpa by -\rail@y
wenzelm@2658
   688
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   689
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   690
\rail@jy=\rail@y
wenzelm@2658
   691
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   692
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   693
\rail@joval[bl]
wenzelm@2658
   694
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   695
\rail@ex=\rail@x
wenzelm@2658
   696
\begingroup
wenzelm@2658
   697
\rail@sx=\rail@x
wenzelm@2658
   698
\rail@rx=0
wenzelm@2658
   699
}
wenzelm@2658
   700
wenzelm@2658
   701
% \rail@barjoin : outgoing join for first '|' alternative
wenzelm@2658
   702
%
wenzelm@2658
   703
% \rail@plusjoin : outgoing join for first '+' alternative
wenzelm@2658
   704
%
wenzelm@2658
   705
% \rail@altjoin : join for subsequent alternative
wenzelm@2658
   706
%
wenzelm@2658
   707
wenzelm@2658
   708
\def\rail@barjoin{
wenzelm@2658
   709
\ifnum\rail@y<\rail@sy
wenzelm@2658
   710
\global\rail@gex=\rail@jx
wenzelm@2658
   711
\else
wenzelm@2658
   712
\global\rail@gex=\rail@ex
wenzelm@2658
   713
\fi
wenzelm@2658
   714
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   715
\rail@joval[tl]
wenzelm@2658
   716
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   717
\ifnum\rail@y<\rail@sy
wenzelm@2658
   718
\rail@altjoin
wenzelm@2658
   719
\fi
wenzelm@2658
   720
}
wenzelm@2658
   721
wenzelm@2658
   722
\def\rail@plusjoin{
wenzelm@2658
   723
\global\rail@gex=\rail@ex
wenzelm@2658
   724
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   725
\advance\rail@jx by -\rail@joinsz
wenzelm@2658
   726
\rail@joval[tr]
wenzelm@2658
   727
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   728
}
wenzelm@2658
   729
wenzelm@2658
   730
\def\rail@altjoin{
wenzelm@2658
   731
\rail@eline
wenzelm@2658
   732
\rail@tmpa=\rail@jy
wenzelm@2658
   733
\advance\rail@tmpa by -\rail@y
wenzelm@2658
   734
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   735
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   736
\rail@jy=\rail@y
wenzelm@2658
   737
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   738
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   739
\rail@joval[br]
wenzelm@2658
   740
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   741
}
wenzelm@2658
   742
wenzelm@2658
   743
% \rail@eltsplit EX:Y; : split EX:Y into \rail@ex \rail@y
wenzelm@2658
   744
%
wenzelm@2658
   745
% \rail@endalt{JOIN} : end alternatives with outgoing join JOIN
wenzelm@2658
   746
wenzelm@2658
   747
\def\rail@eltsplit#1:#2;{\rail@ex=#1\rail@y=#2}
wenzelm@2658
   748
wenzelm@2658
   749
\def\rail@endalt#1{
wenzelm@2658
   750
\global\rail@gx=\rail@x
wenzelm@2658
   751
\global\rail@gy=\rail@y
wenzelm@2658
   752
\global\rail@gex=\rail@ex
wenzelm@2658
   753
\global\rail@grx=\rail@rx
wenzelm@2658
   754
\endgroup
wenzelm@2658
   755
\ifnum\rail@gx>\rail@mx\rail@mx=\rail@gx\fi
wenzelm@2658
   756
\ifnum\rail@grx>\rail@mx\rail@mx=\rail@grx\fi
wenzelm@2658
   757
\edef\rail@list{\rail@list\rail@comma\number\rail@gex:\number\rail@gy}
wenzelm@2658
   758
\rail@x=\rail@mx
wenzelm@2658
   759
\rail@jx=\rail@x
wenzelm@2658
   760
\rail@jy=\rail@sy
wenzelm@2658
   761
\advance\rail@jx by \rail@joinsz
wenzelm@2658
   762
\let\rail@join=#1
wenzelm@2658
   763
\@for\rail@elt:=\rail@list\do{
wenzelm@2658
   764
\expandafter\rail@eltsplit\rail@elt;
wenzelm@2658
   765
\rail@join
wenzelm@2658
   766
\let\rail@join=\rail@altjoin
wenzelm@2658
   767
}
wenzelm@2658
   768
\rail@x=\rail@mx
wenzelm@2658
   769
\rail@y=\rail@sy
wenzelm@2658
   770
\rail@ex=\rail@gex
wenzelm@2658
   771
\advance\rail@x by \rail@joinsz
wenzelm@2658
   772
}
wenzelm@2658
   773
wenzelm@2658
   774
% \rail@bar : start '|' alternatives
wenzelm@2658
   775
%
wenzelm@2658
   776
% \rail@nextbar : next '|' alternative
wenzelm@2658
   777
%
wenzelm@2658
   778
% \rail@endbar : end '|' alternatives
wenzelm@2658
   779
%
wenzelm@2658
   780
wenzelm@2658
   781
\def\rail@bar{
wenzelm@2658
   782
\rail@alt\rail@barsplit
wenzelm@2658
   783
}
wenzelm@2658
   784
wenzelm@2658
   785
\def\rail@nextbar{
wenzelm@2658
   786
\rail@nextalt\relax
wenzelm@2658
   787
}
wenzelm@2658
   788
wenzelm@2658
   789
\def\rail@endbar{
wenzelm@2658
   790
\rail@endalt\rail@barjoin
wenzelm@2658
   791
}
wenzelm@2658
   792
wenzelm@2658
   793
% \rail@plus : start '+' alternatives
wenzelm@2658
   794
%
wenzelm@2658
   795
% \rail@nextplus: next '+' alternative
wenzelm@2658
   796
%
wenzelm@2658
   797
% \rail@endplus : end '+' alternatives
wenzelm@2658
   798
%
wenzelm@2658
   799
wenzelm@2658
   800
\def\rail@plus{
wenzelm@2658
   801
\rail@alt\rail@plussplit
wenzelm@2658
   802
}
wenzelm@2658
   803
wenzelm@2658
   804
\def\rail@nextplus{
wenzelm@2658
   805
\rail@nextalt\rail@fixplus
wenzelm@2658
   806
}
wenzelm@2658
   807
wenzelm@2658
   808
\def\rail@fixplus{
wenzelm@2658
   809
\ifnum\rail@gy<\rail@sy
wenzelm@2658
   810
\begingroup
wenzelm@2658
   811
\rail@x=\rail@gx
wenzelm@2658
   812
\rail@y=\rail@gy
wenzelm@2658
   813
\rail@ex=\rail@gex
wenzelm@2658
   814
\rail@rx=\rail@grx
wenzelm@2658
   815
\ifnum\rail@x<\rail@rx
wenzelm@2658
   816
\rail@x=\rail@rx
wenzelm@2658
   817
\fi
wenzelm@2658
   818
\rail@eline
wenzelm@2658
   819
\rail@jx=\rail@x
wenzelm@2658
   820
\rail@jy=\rail@y
wenzelm@2658
   821
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   822
\rail@joval[br]
wenzelm@2658
   823
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   824
\rail@tmpa=\rail@sy
wenzelm@2658
   825
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   826
\advance\rail@tmpa by -\rail@jy
wenzelm@2658
   827
\rail@jput{\line(0,1){\number\rail@tmpa}}
wenzelm@2658
   828
\rail@jy=\rail@sy
wenzelm@2658
   829
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   830
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   831
\rail@joval[tl]
wenzelm@2658
   832
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   833
\global\rail@gx=\rail@jx
wenzelm@2658
   834
\global\rail@gy=\rail@jy
wenzelm@2658
   835
\global\rail@gex=\rail@gx
wenzelm@2658
   836
\global\rail@grx=\rail@rx
wenzelm@2658
   837
\endgroup
wenzelm@2658
   838
\fi
wenzelm@2658
   839
}
wenzelm@2658
   840
wenzelm@2658
   841
\def\rail@endplus{
wenzelm@2658
   842
\rail@endalt\rail@plusjoin
wenzelm@2658
   843
}
wenzelm@2658
   844
wenzelm@2658
   845
% \rail@cr{Y} : carriage return to vertical position Y
wenzelm@2658
   846
wenzelm@2658
   847
\def\rail@cr#1{
wenzelm@2658
   848
\rail@tmpa=\rail@sx
wenzelm@2658
   849
\advance\rail@tmpa by \rail@joinsz
wenzelm@2658
   850
\ifnum\rail@x<\rail@tmpa\rail@x=\rail@tmpa\fi
wenzelm@2658
   851
\rail@eline
wenzelm@2658
   852
\rail@jx=\rail@x
wenzelm@2658
   853
\rail@jy=\rail@y
wenzelm@2658
   854
\advance\rail@x by \rail@joinsz
wenzelm@2658
   855
\ifnum\rail@x>\rail@rx\rail@rx=\rail@x\fi
wenzelm@2658
   856
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   857
\rail@joval[tr]
wenzelm@2658
   858
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   859
\rail@sety{#1}
wenzelm@2658
   860
\rail@tmpa=\rail@jy
wenzelm@2658
   861
\advance\rail@tmpa by -\rail@y
wenzelm@2658
   862
\advance\rail@tmpa by -\rail@boxsp
wenzelm@2658
   863
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   864
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   865
\rail@jy=\rail@y
wenzelm@2658
   866
\advance\rail@jy by \rail@boxsp
wenzelm@2658
   867
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   868
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   869
\rail@joval[br]
wenzelm@2658
   870
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   871
\rail@tmpa=\rail@jx
wenzelm@2658
   872
\advance\rail@tmpa by -\rail@sx
wenzelm@2658
   873
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   874
\rail@jput{\line(-1,0){\number\rail@tmpa}}
wenzelm@2658
   875
\rail@jx=\rail@sx
wenzelm@2658
   876
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   877
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   878
\rail@joval[tl]
wenzelm@2658
   879
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   880
\rail@tmpa=\rail@boxsp
wenzelm@2658
   881
\advance\rail@tmpa by -\rail@joinsz
wenzelm@2658
   882
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   883
\advance\rail@jy by -\rail@tmpa
wenzelm@2658
   884
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   885
\rail@joval[bl]
wenzelm@2658
   886
\rail@x=\rail@jx
wenzelm@2658
   887
\rail@ex=\rail@x
wenzelm@2658
   888
}