doc-src/rail.sty
author wenzelm
Mon, 27 Mar 2000 18:08:57 +0200
changeset 8591 9d660fc42916
parent 3097 ae362c99a635
child 13044 c049910774cb
permissions -rw-r--r--
fixed \rail@tokenfont (ever used?);
wenzelm@2658
     1
% rail.sty - style file to support railroad diagrams
wenzelm@2658
     2
%
wenzelm@2658
     3
% 09-Jul-90 L. Rooijakkers
wenzelm@8591
     4
% 08-Oct-90 L. Rooijakkers      fixed centering bug when \rail@tmpc<0.
wenzelm@8591
     5
% 07-Feb-91 L. Rooijakkers      added \railoptions command, indexing
wenzelm@8591
     6
% 08-Feb-91 L. Rooijakkers      minor fixes
wenzelm@8591
     7
% 28-Jun-94 K. Barthelmann      turned into LaTeX2e package
wenzelm@8591
     8
% 08-Dec-96 K. Barthelmann      replaced \@writefile
wenzelm@8591
     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@8591
   104
% \rail@textlf  : \railtextleft
wenzelm@8591
   105
% \rail@textrt  : \railtextright
wenzelm@8591
   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
wenzelm@8591
   195
\def\rail@tokenfont{\ttfamily\upshape}
berghofe@3097
   196
\def\rail@termfont{\ttfamily\upshape}
berghofe@3097
   197
\def\rail@nontfont{\rmfamily\upshape}
berghofe@3097
   198
\def\rail@annofont{\rmfamily\itshape}
berghofe@3097
   199
\def\rail@namefont{\rmfamily\itshape}
berghofe@3097
   200
\def\rail@indexfont{\rmfamily\itshape}
berghofe@3097
   201
berghofe@3097
   202
\newcommand\railtermfont[1]{
berghofe@3097
   203
\def\rail@termfont{#1}
berghofe@3097
   204
}
berghofe@3097
   205
berghofe@3097
   206
\newcommand\railnontermfont[1]{
berghofe@3097
   207
\def\rail@nontfont{#1}
berghofe@3097
   208
}
berghofe@3097
   209
berghofe@3097
   210
\newcommand\railannotatefont[1]{
berghofe@3097
   211
\def\rail@annofont{#1}
berghofe@3097
   212
}
berghofe@3097
   213
berghofe@3097
   214
\newcommand\railnamefont[1]{
berghofe@3097
   215
\def\rail@namefont{#1}
berghofe@3097
   216
}
berghofe@3097
   217
berghofe@3097
   218
\newcommand\railindexfont[1]{
berghofe@3097
   219
\def\rail@indexfont{#1}
berghofe@3097
   220
}
berghofe@3097
   221
berghofe@3097
   222
% railroad read/write macros
berghofe@3097
   223
%
berghofe@3097
   224
% \begin{rail} TEXT \end{rail} : TEXT is written out to the .rai file,
berghofe@3097
   225
%                                as \rail@i{NR}{TEXT}. Then the matching
berghofe@3097
   226
%                                \rail@o{NR}{FMT} from the .rao file is
berghofe@3097
   227
%                                executed (if defined).
berghofe@3097
   228
%
berghofe@3097
   229
% \railoptions{OPTIONS} : OPTIONS are written out to the .rai file,
berghofe@3097
   230
%                         as \rail@p{OPTIONS}.
berghofe@3097
   231
%
berghofe@3097
   232
% \railterm{IDENT,IDENT,...} : format IDENT as terminals. writes out
berghofe@3097
   233
%                              \rail@t{IDENT} to the .rai file
berghofe@3097
   234
%
berghofe@3097
   235
% \railalias{IDENT}{TEXT} : format IDENT as TEXT. defines \rail@t@IDENT as
berghofe@3097
   236
%                           TEXT.
berghofe@3097
   237
%
berghofe@3097
   238
% \rail@nr : railroad diagram counter
berghofe@3097
   239
%
berghofe@3097
   240
% \ifrail@match : current \rail@i{NR}{TEXT} matches
berghofe@3097
   241
%
wenzelm@8591
   242
% \rail@first : actions to be done first. read in .rao file,
berghofe@3097
   243
%               open .rai file if \@filesw true, undefine \rail@first.
berghofe@3097
   244
%               executed from \begin{rail} and \railtoken.
berghofe@3097
   245
%
berghofe@3097
   246
% \rail@i{NR}{TEXT} : defines \rail@i@NR as TEXT. written to the .rai
berghofe@3097
   247
%                     file by \rail, read from the .rao file by
berghofe@3097
   248
%                     \rail@first
berghofe@3097
   249
%
berghofe@3097
   250
% \rail@t{IDENT} : tells Rail that IDENT is to be custom formatted,
berghofe@3097
   251
%                  written to the .rai file by \railterm.
berghofe@3097
   252
%
berghofe@3097
   253
% \rail@o{NR}{TEXT} : defines \rail@o@NR as TEXT, read from the .rao
berghofe@3097
   254
%                     file by \rail@first.
berghofe@3097
   255
%
berghofe@3097
   256
% \rail@p{OPTIONS} : pass options to rail, written to the .rai file by
berghofe@3097
   257
%                    \railoptions
berghofe@3097
   258
%
berghofe@3097
   259
% \rail@write{TEXT} : write TEXT to the .rai file
berghofe@3097
   260
%
berghofe@3097
   261
% \rail@warn : warn user for mismatching diagrams
berghofe@3097
   262
%
berghofe@3097
   263
% \rail@endwarn : either \relax or \rail@warn
berghofe@3097
   264
%
berghofe@3097
   265
% \ifrail@all : checked at the end of the document
berghofe@3097
   266
berghofe@3097
   267
\newcount\rail@nr
berghofe@3097
   268
berghofe@3097
   269
\newif\ifrail@all
berghofe@3097
   270
\rail@alltrue
berghofe@3097
   271
berghofe@3097
   272
\newif\ifrail@match
berghofe@3097
   273
berghofe@3097
   274
\def\rail@first{
berghofe@3097
   275
\makeatletter
berghofe@3097
   276
\InputIfFileExists{\jobname.rao}{}{\PackageInfo{rail}{No file \jobname.rao}}
berghofe@3097
   277
\makeatother
berghofe@3097
   278
\if@filesw
berghofe@3097
   279
\newwrite\tf@rai
berghofe@3097
   280
\immediate\openout\tf@rai=\jobname.rai
wenzelm@2658
   281
\fi
berghofe@3097
   282
\global\let\rail@first=\relax
berghofe@3097
   283
}
wenzelm@2658
   284
berghofe@3097
   285
\long\def\rail@body#1\end{
berghofe@3097
   286
\begingroup
berghofe@3097
   287
\let\\=\relax
berghofe@3097
   288
\xdef\rail@i@{#1}
berghofe@3097
   289
\rail@write{\string\rail@i{\number\rail@nr}{\rail@i@}}
berghofe@3097
   290
\endgroup
berghofe@3097
   291
\end
berghofe@3097
   292
}
berghofe@3097
   293
berghofe@3097
   294
\newenvironment{rail}{
berghofe@3097
   295
\global\advance\rail@nr by 1
berghofe@3097
   296
\rail@first
berghofe@3097
   297
\rail@body
berghofe@3097
   298
}{
berghofe@3097
   299
\rail@matchtrue
berghofe@3097
   300
\@ifundefined{rail@o@\number\rail@nr}{\rail@matchfalse}{}
berghofe@3097
   301
\expandafter\ifx\csname rail@i@\number\rail@nr\endcsname\rail@i@
berghofe@3097
   302
\else
berghofe@3097
   303
\rail@matchfalse
berghofe@3097
   304
\fi
berghofe@3097
   305
\ifrail@match
berghofe@3097
   306
\csname rail@o@\number\rail@nr\endcsname
berghofe@3097
   307
\else
berghofe@3097
   308
\PackageWarning{rail}{Railroad diagram {\number\rail@nr} doesn't match}
berghofe@3097
   309
\global\let\rail@endwarn=\rail@warn
berghofe@3097
   310
\begin{list}{}{\rail@param}
berghofe@3097
   311
\rail@begin{1}{}
berghofe@3097
   312
\rail@setbox{\bfseries ???}
berghofe@3097
   313
\rail@oval
berghofe@3097
   314
\rail@end
berghofe@3097
   315
\end{list}
berghofe@3097
   316
\fi
berghofe@3097
   317
}
berghofe@3097
   318
berghofe@3097
   319
\newcommand\railoptions[1]{
berghofe@3097
   320
\rail@first
berghofe@3097
   321
\rail@write{\string\rail@p{#1}}
berghofe@3097
   322
}
berghofe@3097
   323
berghofe@3097
   324
\newcommand\railterm[1]{
berghofe@3097
   325
\rail@first
berghofe@3097
   326
\@for\rail@@:=#1\do{
berghofe@3097
   327
\rail@write{\string\rail@t{\rail@@}}
berghofe@3097
   328
}
berghofe@3097
   329
}
berghofe@3097
   330
berghofe@3097
   331
\newcommand\railalias[2]{
berghofe@3097
   332
\expandafter\def\csname rail@t@#1\endcsname{#2}
berghofe@3097
   333
}
berghofe@3097
   334
berghofe@3097
   335
\long\def\rail@i#1#2{
berghofe@3097
   336
\expandafter\gdef\csname rail@i@#1\endcsname{#2}
berghofe@3097
   337
}
berghofe@3097
   338
berghofe@3097
   339
\def\rail@o#1#2{
berghofe@3097
   340
\expandafter\gdef\csname rail@o@#1\endcsname{
berghofe@3097
   341
\begin{list}{}{\rail@param}#2\end{list}
berghofe@3097
   342
}
berghofe@3097
   343
}
berghofe@3097
   344
berghofe@3097
   345
\def\rail@t#1{}
berghofe@3097
   346
berghofe@3097
   347
\def\rail@p#1{}
berghofe@3097
   348
berghofe@3097
   349
\def\rail@write#1{\@ifundefined{tf@rai}{}{\immediate\write\tf@rai{#1}}}
berghofe@3097
   350
berghofe@3097
   351
\def\rail@warn{
berghofe@3097
   352
\PackageWarningNoLine{rail}{Railroad diagram(s) may have changed.
berghofe@3097
   353
                            Use 'rail' and rerun}
berghofe@3097
   354
}
berghofe@3097
   355
berghofe@3097
   356
\let\rail@endwarn=\relax
berghofe@3097
   357
berghofe@3097
   358
\AtEndDocument{\rail@endwarn}
berghofe@3097
   359
berghofe@3097
   360
% index entry macro
berghofe@3097
   361
%
berghofe@3097
   362
% \rail@index{IDENT} : add index entry for IDENT
berghofe@3097
   363
berghofe@3097
   364
\def\rail@index#1{
berghofe@3097
   365
\index{\rail@indexfont#1}
berghofe@3097
   366
}
wenzelm@2658
   367
wenzelm@2658
   368
% railroad formatting primitives
wenzelm@2658
   369
%
wenzelm@2658
   370
% \rail@x : current x
wenzelm@2658
   371
% \rail@y : current y
wenzelm@2658
   372
% \rail@ex : current end x
wenzelm@2658
   373
% \rail@sx : starting x for \rail@cr
wenzelm@2658
   374
% \rail@rx : rightmost previous x for \rail@cr
wenzelm@2658
   375
%
wenzelm@2658
   376
% \rail@tmpa : temporary count
wenzelm@2658
   377
% \rail@tmpb : temporary count
wenzelm@2658
   378
% \rail@tmpc : temporary count
wenzelm@2658
   379
%
wenzelm@2658
   380
% \rail@put : put at (\rail@x,\rail@y)
wenzelm@2658
   381
%
wenzelm@2658
   382
% \rail@eline : end line by drawing from \rail@ex to \rail@x
wenzelm@2658
   383
%
wenzelm@2658
   384
% \rail@sety{LEVEL} : set \rail@y to level LEVEL
wenzelm@2658
   385
wenzelm@2658
   386
\newcount\rail@x
wenzelm@2658
   387
\newcount\rail@y
wenzelm@2658
   388
\newcount\rail@ex
wenzelm@2658
   389
\newcount\rail@sx
wenzelm@2658
   390
\newcount\rail@rx
wenzelm@2658
   391
wenzelm@2658
   392
\newcount\rail@tmpa
wenzelm@2658
   393
\newcount\rail@tmpb
wenzelm@2658
   394
\newcount\rail@tmpc
wenzelm@2658
   395
wenzelm@2658
   396
\def\rail@put{\put(\number\rail@x,\number\rail@y)}
wenzelm@2658
   397
wenzelm@2658
   398
\def\rail@eline{
wenzelm@2658
   399
\rail@tmpb=\rail@x
wenzelm@2658
   400
\advance\rail@tmpb by -\rail@ex
wenzelm@2658
   401
\rail@put{\line(-1,0){\number\rail@tmpb}}
wenzelm@2658
   402
}
wenzelm@2658
   403
wenzelm@2658
   404
\def\rail@sety#1{
wenzelm@2658
   405
\rail@y=#1
wenzelm@2658
   406
\multiply\rail@y by -\rail@boxsp
wenzelm@2658
   407
\advance\rail@y by -\rail@boxht
wenzelm@2658
   408
}
wenzelm@2658
   409
wenzelm@2658
   410
% \rail@begin{HEIGHT}{NAME} : begin a railroad diagram of height HEIGHT
wenzelm@2658
   411
%
wenzelm@2658
   412
% \rail@end : end a railroad diagram
berghofe@3097
   413
%
berghofe@3097
   414
% \rail@expand{IDENT} : expand IDENT
wenzelm@2658
   415
wenzelm@2658
   416
\def\rail@begin#1#2{
wenzelm@2658
   417
\item[]
berghofe@3097
   418
\begin{minipage}[t]{\linewidth}
wenzelm@2658
   419
\ifx\@empty#2\else
berghofe@3097
   420
{\rail@namefont \rail@expand{#2}}\\*[\railnamesep]
wenzelm@2658
   421
\fi
wenzelm@2658
   422
\unitlength=\railunit
wenzelm@2658
   423
\rail@tmpa=#1
wenzelm@2658
   424
\multiply\rail@tmpa by \rail@boxsp
wenzelm@2658
   425
\begin{picture}(0,\number\rail@tmpa)(0,-\number\rail@tmpa)
wenzelm@2658
   426
\rail@ex=0
wenzelm@2658
   427
\rail@rx=0
wenzelm@2658
   428
\rail@x=\rail@extra
wenzelm@2658
   429
\rail@sx=\rail@x
wenzelm@2658
   430
\rail@sety{0}
wenzelm@2658
   431
}
wenzelm@2658
   432
wenzelm@2658
   433
\def\rail@end{
wenzelm@2658
   434
\advance\rail@x by \rail@extra
wenzelm@2658
   435
\rail@eline
wenzelm@2658
   436
\end{picture}
berghofe@3097
   437
\end{minipage}
wenzelm@2658
   438
}
wenzelm@2658
   439
berghofe@3097
   440
\def\rail@expand#1{\@ifundefined{rail@t@#1}{#1}{\csname rail@t@#1\endcsname}}
berghofe@3097
   441
berghofe@3097
   442
% \rail@token{TEXT}[ANNOT] : format token TEXT with annotation
wenzelm@2658
   443
%
berghofe@3097
   444
% \rail@ctoken{TEXT}[ANNOT] : format token TEXT centered with annotation
wenzelm@2658
   445
%
berghofe@3097
   446
% \rail@nont{TEXT}[ANNOT] : format nonterminal TEXT with annotation
wenzelm@2658
   447
%
berghofe@3097
   448
% \rail@cnont{TEXT}[ANNOT] : format nonterminal TEXT centered with annotation
wenzelm@2658
   449
%
berghofe@3097
   450
% \rail@term{TEXT}[ANNOT] : format terminal TEXT with annotation
wenzelm@2658
   451
%
berghofe@3097
   452
% \rail@cterm{TEXT}[ANNOT] : format terminal TEXT centered with annotation
wenzelm@2658
   453
%
wenzelm@2658
   454
% \rail@annote[TEXT] : format TEXT as annotation
wenzelm@2658
   455
berghofe@3097
   456
\def\rail@token#1[#2]{
berghofe@3097
   457
\rail@setbox{%
wenzelm@8591
   458
{\rail@tokenfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
wenzelm@2658
   459
}
wenzelm@2658
   460
\rail@oval
wenzelm@2658
   461
}
wenzelm@2658
   462
berghofe@3097
   463
\def\rail@ctoken#1[#2]{
berghofe@3097
   464
\rail@setbox{%
wenzelm@8591
   465
{\rail@tokenfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   466
}
wenzelm@2658
   467
\rail@coval
wenzelm@2658
   468
}
wenzelm@2658
   469
berghofe@3097
   470
\def\rail@nont#1[#2]{
berghofe@3097
   471
\rail@setbox{%
berghofe@3097
   472
{\rail@nontfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   473
}
wenzelm@2658
   474
\rail@frame
wenzelm@2658
   475
}
wenzelm@2658
   476
berghofe@3097
   477
\def\rail@cnont#1[#2]{
berghofe@3097
   478
\rail@setbox{%
berghofe@3097
   479
{\rail@nontfont \rail@expand{#1}}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   480
}
wenzelm@2658
   481
\rail@cframe
wenzelm@2658
   482
}
wenzelm@2658
   483
berghofe@3097
   484
\def\rail@term#1[#2]{
berghofe@3097
   485
\rail@setbox{%
berghofe@3097
   486
{\rail@termfont #1}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   487
}
wenzelm@2658
   488
\rail@oval
wenzelm@2658
   489
}
wenzelm@2658
   490
berghofe@3097
   491
\def\rail@cterm#1[#2]{
berghofe@3097
   492
\rail@setbox{%
berghofe@3097
   493
{\rail@termfont #1}\ifx\@empty#2\else\ {\rail@annofont #2}\fi
berghofe@3097
   494
}
wenzelm@2658
   495
\rail@coval
wenzelm@2658
   496
}
wenzelm@2658
   497
wenzelm@2658
   498
\def\rail@annote[#1]{
wenzelm@2658
   499
\rail@setbox{\rail@annofont #1}
wenzelm@2658
   500
\rail@text
wenzelm@2658
   501
}
wenzelm@2658
   502
wenzelm@2658
   503
% \rail@box : temporary box for \rail@oval and \rail@frame
wenzelm@2658
   504
%
wenzelm@2658
   505
% \rail@setbox{TEXT} : set \rail@box to TEXT, set \rail@tmpa to width
wenzelm@2658
   506
%
wenzelm@2658
   507
% \rail@oval : format \rail@box of width \rail@tmpa inside an oval
wenzelm@2658
   508
%
wenzelm@2658
   509
% \rail@coval : same as \rail@oval, but centered between \rail@x and
wenzelm@2658
   510
%               \rail@mx
wenzelm@2658
   511
%
wenzelm@2658
   512
% \rail@frame : format \rail@box of width \rail@tmpa inside a frame
wenzelm@2658
   513
%
wenzelm@2658
   514
% \rail@cframe : same as \rail@frame, but centered between \rail@x and
wenzelm@2658
   515
%                \rail@mx
wenzelm@2658
   516
%
wenzelm@2658
   517
% \rail@text : format \rail@box of width \rail@tmpa above the line
wenzelm@2658
   518
wenzelm@2658
   519
\newbox\rail@box
wenzelm@2658
   520
wenzelm@2658
   521
\def\rail@setbox#1{
wenzelm@2658
   522
\setbox\rail@box\hbox{\strut#1}
wenzelm@2658
   523
\rail@tmpa=\wd\rail@box
wenzelm@2658
   524
\divide\rail@tmpa by \railunit
wenzelm@2658
   525
}
wenzelm@2658
   526
wenzelm@2658
   527
\def\rail@oval{
wenzelm@2658
   528
\advance\rail@x by \rail@boxlf
wenzelm@2658
   529
\rail@eline
wenzelm@2658
   530
\advance\rail@tmpa by \rail@ovalsp
wenzelm@2658
   531
\ifnum\rail@tmpa<\rail@boxht\rail@tmpa=\rail@boxht\fi
wenzelm@2658
   532
\rail@tmpb=\rail@tmpa
wenzelm@2658
   533
\divide\rail@tmpb by 2
wenzelm@2658
   534
\advance\rail@y by -\rail@boxhht
wenzelm@2658
   535
\rail@put{\makebox(\number\rail@tmpa,\number\rail@boxht){\box\rail@box}}
wenzelm@2658
   536
\advance\rail@y by \rail@boxhht
wenzelm@2658
   537
\advance\rail@x by \rail@tmpb
wenzelm@2658
   538
\rail@put{\oval(\number\rail@tmpa,\number\rail@boxht)}
wenzelm@2658
   539
\advance\rail@x by \rail@tmpb
wenzelm@2658
   540
\rail@ex=\rail@x
wenzelm@2658
   541
\advance\rail@x by \rail@boxrt
wenzelm@2658
   542
}
wenzelm@2658
   543
wenzelm@2658
   544
\def\rail@coval{
wenzelm@2658
   545
\rail@tmpb=\rail@tmpa
wenzelm@2658
   546
\advance\rail@tmpb by \rail@ovalsp
wenzelm@2658
   547
\ifnum\rail@tmpb<\rail@boxht\rail@tmpb=\rail@boxht\fi
wenzelm@2658
   548
\advance\rail@tmpb by \rail@boxlf
wenzelm@2658
   549
\advance\rail@tmpb by \rail@boxrt
wenzelm@2658
   550
\rail@tmpc=\rail@mx
wenzelm@2658
   551
\advance\rail@tmpc by -\rail@x
wenzelm@2658
   552
\advance\rail@tmpc by -\rail@tmpb
wenzelm@2658
   553
\divide\rail@tmpc by 2
wenzelm@2658
   554
\ifnum\rail@tmpc>0
wenzelm@2658
   555
\advance\rail@x by \rail@tmpc
wenzelm@2658
   556
\fi
wenzelm@2658
   557
\rail@oval
wenzelm@2658
   558
}
wenzelm@2658
   559
wenzelm@2658
   560
\def\rail@frame{
wenzelm@2658
   561
\advance\rail@x by \rail@boxlf
wenzelm@2658
   562
\rail@eline
wenzelm@2658
   563
\advance\rail@tmpa by \rail@framesp
wenzelm@2658
   564
\ifnum\rail@tmpa<\rail@boxht\rail@tmpa=\rail@boxht\fi
wenzelm@2658
   565
\advance\rail@y by -\rail@boxhht
wenzelm@2658
   566
\rail@put{\framebox(\number\rail@tmpa,\number\rail@boxht){\box\rail@box}}
wenzelm@2658
   567
\advance\rail@y by \rail@boxhht
wenzelm@2658
   568
\advance\rail@x by \rail@tmpa
wenzelm@2658
   569
\rail@ex=\rail@x
wenzelm@2658
   570
\advance\rail@x by \rail@boxrt
wenzelm@2658
   571
}
wenzelm@2658
   572
wenzelm@2658
   573
\def\rail@cframe{
wenzelm@2658
   574
\rail@tmpb=\rail@tmpa
wenzelm@2658
   575
\advance\rail@tmpb by \rail@framesp
wenzelm@2658
   576
\ifnum\rail@tmpb<\rail@boxht\rail@tmpb=\rail@boxht\fi
wenzelm@2658
   577
\advance\rail@tmpb by \rail@boxlf
wenzelm@2658
   578
\advance\rail@tmpb by \rail@boxrt
wenzelm@2658
   579
\rail@tmpc=\rail@mx
wenzelm@2658
   580
\advance\rail@tmpc by -\rail@x
wenzelm@2658
   581
\advance\rail@tmpc by -\rail@tmpb
wenzelm@2658
   582
\divide\rail@tmpc by 2
wenzelm@2658
   583
\ifnum\rail@tmpc>0
wenzelm@2658
   584
\advance\rail@x by \rail@tmpc
wenzelm@2658
   585
\fi
wenzelm@2658
   586
\rail@frame
wenzelm@2658
   587
}
wenzelm@2658
   588
wenzelm@2658
   589
\def\rail@text{
wenzelm@2658
   590
\advance\rail@x by \rail@textlf
wenzelm@2658
   591
\advance\rail@y by \rail@textup
wenzelm@2658
   592
\rail@put{\box\rail@box}
wenzelm@2658
   593
\advance\rail@y by -\rail@textup
wenzelm@2658
   594
\advance\rail@x by \rail@tmpa
wenzelm@2658
   595
\advance\rail@x by \rail@textrt
wenzelm@2658
   596
}
wenzelm@2658
   597
wenzelm@2658
   598
% alternatives
wenzelm@2658
   599
%
wenzelm@2658
   600
% \rail@jx \rail@jy : current join point
wenzelm@2658
   601
%
wenzelm@2658
   602
% \rail@gx \rail@gy \rail@gex \rail@grx : global versions of \rail@x etc,
wenzelm@2658
   603
%                                         to pass values over group closings
wenzelm@2658
   604
%
wenzelm@2658
   605
% \rail@mx : maximum x so far
wenzelm@2658
   606
%
wenzelm@2658
   607
% \rail@sy : starting \rail@y for alternatives
wenzelm@2658
   608
%
wenzelm@2658
   609
% \rail@jput : put at (\rail@jx,\rail@jy)
wenzelm@2658
   610
%
wenzelm@2658
   611
% \rail@joval[PART] : put \oval[PART] with adjust
wenzelm@2658
   612
wenzelm@2658
   613
\newcount\rail@jx
wenzelm@2658
   614
\newcount\rail@jy
wenzelm@2658
   615
wenzelm@2658
   616
\newcount\rail@gx
wenzelm@2658
   617
\newcount\rail@gy
wenzelm@2658
   618
\newcount\rail@gex
wenzelm@2658
   619
\newcount\rail@grx
wenzelm@2658
   620
wenzelm@2658
   621
\newcount\rail@sy
wenzelm@2658
   622
\newcount\rail@mx
wenzelm@2658
   623
wenzelm@2658
   624
\def\rail@jput{
wenzelm@2658
   625
\put(\number\rail@jx,\number\rail@jy)
wenzelm@2658
   626
}
wenzelm@2658
   627
wenzelm@2658
   628
\def\rail@joval[#1]{
wenzelm@2658
   629
\advance\rail@jx by \rail@joinadj
wenzelm@2658
   630
\rail@jput{\oval(\number\rail@joinsz,\number\rail@joinsz)[#1]}
wenzelm@2658
   631
\advance\rail@jx by -\rail@joinadj
wenzelm@2658
   632
}
wenzelm@2658
   633
wenzelm@2658
   634
% \rail@barsplit : incoming split for '|'
wenzelm@2658
   635
%
wenzelm@2658
   636
% \rail@plussplit : incoming split for '+'
wenzelm@2658
   637
%
wenzelm@2658
   638
wenzelm@2658
   639
\def\rail@barsplit{
wenzelm@2658
   640
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   641
\rail@joval[tr]
wenzelm@2658
   642
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   643
}
wenzelm@2658
   644
wenzelm@2658
   645
\def\rail@plussplit{
wenzelm@2658
   646
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   647
\advance\rail@jx by \rail@joinsz
wenzelm@2658
   648
\rail@joval[tl]
wenzelm@2658
   649
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   650
}
wenzelm@2658
   651
wenzelm@2658
   652
% \rail@alt{SPLIT} : start alternatives with incoming split SPLIT
wenzelm@2658
   653
%
wenzelm@2658
   654
wenzelm@2658
   655
\def\rail@alt#1{
wenzelm@2658
   656
\rail@sy=\rail@y
wenzelm@2658
   657
\rail@jx=\rail@x
wenzelm@2658
   658
\rail@jy=\rail@y
wenzelm@2658
   659
\advance\rail@x by \rail@joinsz
wenzelm@2658
   660
\rail@mx=0
wenzelm@2658
   661
\let\rail@list=\@empty
wenzelm@2658
   662
\let\rail@comma=\@empty
wenzelm@2658
   663
\let\rail@split=#1
wenzelm@2658
   664
\begingroup
wenzelm@2658
   665
\rail@sx=\rail@x
wenzelm@2658
   666
\rail@rx=0
wenzelm@2658
   667
}
wenzelm@2658
   668
wenzelm@2658
   669
% \rail@nextalt{FIX}{Y} : start next alternative at vertical position Y
wenzelm@2658
   670
%                         and fix-up FIX
wenzelm@2658
   671
%
wenzelm@2658
   672
wenzelm@2658
   673
\def\rail@nextalt#1#2{
wenzelm@2658
   674
\global\rail@gx=\rail@x
wenzelm@2658
   675
\global\rail@gy=\rail@y
wenzelm@2658
   676
\global\rail@gex=\rail@ex
wenzelm@2658
   677
\global\rail@grx=\rail@rx
wenzelm@2658
   678
\endgroup
wenzelm@2658
   679
#1
wenzelm@2658
   680
\ifnum\rail@gx>\rail@mx\rail@mx=\rail@gx\fi
wenzelm@2658
   681
\ifnum\rail@grx>\rail@mx\rail@mx=\rail@grx\fi
wenzelm@2658
   682
\edef\rail@list{\rail@list\rail@comma\number\rail@gex:\number\rail@gy}
wenzelm@2658
   683
\def\rail@comma{,}
wenzelm@2658
   684
\rail@split
wenzelm@2658
   685
\let\rail@split=\@empty
wenzelm@2658
   686
\rail@sety{#2}
wenzelm@2658
   687
\rail@tmpa=\rail@jy
wenzelm@2658
   688
\advance\rail@tmpa by -\rail@y
wenzelm@2658
   689
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   690
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   691
\rail@jy=\rail@y
wenzelm@2658
   692
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   693
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   694
\rail@joval[bl]
wenzelm@2658
   695
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   696
\rail@ex=\rail@x
wenzelm@2658
   697
\begingroup
wenzelm@2658
   698
\rail@sx=\rail@x
wenzelm@2658
   699
\rail@rx=0
wenzelm@2658
   700
}
wenzelm@2658
   701
wenzelm@2658
   702
% \rail@barjoin : outgoing join for first '|' alternative
wenzelm@2658
   703
%
wenzelm@2658
   704
% \rail@plusjoin : outgoing join for first '+' alternative
wenzelm@2658
   705
%
wenzelm@2658
   706
% \rail@altjoin : join for subsequent alternative
wenzelm@2658
   707
%
wenzelm@2658
   708
wenzelm@2658
   709
\def\rail@barjoin{
wenzelm@2658
   710
\ifnum\rail@y<\rail@sy
wenzelm@2658
   711
\global\rail@gex=\rail@jx
wenzelm@2658
   712
\else
wenzelm@2658
   713
\global\rail@gex=\rail@ex
wenzelm@2658
   714
\fi
wenzelm@2658
   715
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   716
\rail@joval[tl]
wenzelm@2658
   717
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   718
\ifnum\rail@y<\rail@sy
wenzelm@2658
   719
\rail@altjoin
wenzelm@2658
   720
\fi
wenzelm@2658
   721
}
wenzelm@2658
   722
wenzelm@2658
   723
\def\rail@plusjoin{
wenzelm@2658
   724
\global\rail@gex=\rail@ex
wenzelm@2658
   725
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   726
\advance\rail@jx by -\rail@joinsz
wenzelm@2658
   727
\rail@joval[tr]
wenzelm@2658
   728
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   729
}
wenzelm@2658
   730
wenzelm@2658
   731
\def\rail@altjoin{
wenzelm@2658
   732
\rail@eline
wenzelm@2658
   733
\rail@tmpa=\rail@jy
wenzelm@2658
   734
\advance\rail@tmpa by -\rail@y
wenzelm@2658
   735
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   736
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   737
\rail@jy=\rail@y
wenzelm@2658
   738
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   739
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   740
\rail@joval[br]
wenzelm@2658
   741
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   742
}
wenzelm@2658
   743
wenzelm@2658
   744
% \rail@eltsplit EX:Y; : split EX:Y into \rail@ex \rail@y
wenzelm@2658
   745
%
wenzelm@2658
   746
% \rail@endalt{JOIN} : end alternatives with outgoing join JOIN
wenzelm@2658
   747
wenzelm@2658
   748
\def\rail@eltsplit#1:#2;{\rail@ex=#1\rail@y=#2}
wenzelm@2658
   749
wenzelm@2658
   750
\def\rail@endalt#1{
wenzelm@2658
   751
\global\rail@gx=\rail@x
wenzelm@2658
   752
\global\rail@gy=\rail@y
wenzelm@2658
   753
\global\rail@gex=\rail@ex
wenzelm@2658
   754
\global\rail@grx=\rail@rx
wenzelm@2658
   755
\endgroup
wenzelm@2658
   756
\ifnum\rail@gx>\rail@mx\rail@mx=\rail@gx\fi
wenzelm@2658
   757
\ifnum\rail@grx>\rail@mx\rail@mx=\rail@grx\fi
wenzelm@2658
   758
\edef\rail@list{\rail@list\rail@comma\number\rail@gex:\number\rail@gy}
wenzelm@2658
   759
\rail@x=\rail@mx
wenzelm@2658
   760
\rail@jx=\rail@x
wenzelm@2658
   761
\rail@jy=\rail@sy
wenzelm@2658
   762
\advance\rail@jx by \rail@joinsz
wenzelm@2658
   763
\let\rail@join=#1
wenzelm@2658
   764
\@for\rail@elt:=\rail@list\do{
wenzelm@2658
   765
\expandafter\rail@eltsplit\rail@elt;
wenzelm@2658
   766
\rail@join
wenzelm@2658
   767
\let\rail@join=\rail@altjoin
wenzelm@2658
   768
}
wenzelm@2658
   769
\rail@x=\rail@mx
wenzelm@2658
   770
\rail@y=\rail@sy
wenzelm@2658
   771
\rail@ex=\rail@gex
wenzelm@2658
   772
\advance\rail@x by \rail@joinsz
wenzelm@2658
   773
}
wenzelm@2658
   774
wenzelm@2658
   775
% \rail@bar : start '|' alternatives
wenzelm@2658
   776
%
wenzelm@2658
   777
% \rail@nextbar : next '|' alternative
wenzelm@2658
   778
%
wenzelm@2658
   779
% \rail@endbar : end '|' alternatives
wenzelm@2658
   780
%
wenzelm@2658
   781
wenzelm@2658
   782
\def\rail@bar{
wenzelm@2658
   783
\rail@alt\rail@barsplit
wenzelm@2658
   784
}
wenzelm@2658
   785
wenzelm@2658
   786
\def\rail@nextbar{
wenzelm@2658
   787
\rail@nextalt\relax
wenzelm@2658
   788
}
wenzelm@2658
   789
wenzelm@2658
   790
\def\rail@endbar{
wenzelm@2658
   791
\rail@endalt\rail@barjoin
wenzelm@2658
   792
}
wenzelm@2658
   793
wenzelm@2658
   794
% \rail@plus : start '+' alternatives
wenzelm@2658
   795
%
wenzelm@2658
   796
% \rail@nextplus: next '+' alternative
wenzelm@2658
   797
%
wenzelm@2658
   798
% \rail@endplus : end '+' alternatives
wenzelm@2658
   799
%
wenzelm@2658
   800
wenzelm@2658
   801
\def\rail@plus{
wenzelm@2658
   802
\rail@alt\rail@plussplit
wenzelm@2658
   803
}
wenzelm@2658
   804
wenzelm@2658
   805
\def\rail@nextplus{
wenzelm@2658
   806
\rail@nextalt\rail@fixplus
wenzelm@2658
   807
}
wenzelm@2658
   808
wenzelm@2658
   809
\def\rail@fixplus{
wenzelm@2658
   810
\ifnum\rail@gy<\rail@sy
wenzelm@2658
   811
\begingroup
wenzelm@2658
   812
\rail@x=\rail@gx
wenzelm@2658
   813
\rail@y=\rail@gy
wenzelm@2658
   814
\rail@ex=\rail@gex
wenzelm@2658
   815
\rail@rx=\rail@grx
wenzelm@2658
   816
\ifnum\rail@x<\rail@rx
wenzelm@2658
   817
\rail@x=\rail@rx
wenzelm@2658
   818
\fi
wenzelm@2658
   819
\rail@eline
wenzelm@2658
   820
\rail@jx=\rail@x
wenzelm@2658
   821
\rail@jy=\rail@y
wenzelm@2658
   822
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   823
\rail@joval[br]
wenzelm@2658
   824
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   825
\rail@tmpa=\rail@sy
wenzelm@2658
   826
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   827
\advance\rail@tmpa by -\rail@jy
wenzelm@2658
   828
\rail@jput{\line(0,1){\number\rail@tmpa}}
wenzelm@2658
   829
\rail@jy=\rail@sy
wenzelm@2658
   830
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   831
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   832
\rail@joval[tl]
wenzelm@2658
   833
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   834
\global\rail@gx=\rail@jx
wenzelm@2658
   835
\global\rail@gy=\rail@jy
wenzelm@2658
   836
\global\rail@gex=\rail@gx
wenzelm@2658
   837
\global\rail@grx=\rail@rx
wenzelm@2658
   838
\endgroup
wenzelm@2658
   839
\fi
wenzelm@2658
   840
}
wenzelm@2658
   841
wenzelm@2658
   842
\def\rail@endplus{
wenzelm@2658
   843
\rail@endalt\rail@plusjoin
wenzelm@2658
   844
}
wenzelm@2658
   845
wenzelm@2658
   846
% \rail@cr{Y} : carriage return to vertical position Y
wenzelm@2658
   847
wenzelm@2658
   848
\def\rail@cr#1{
wenzelm@2658
   849
\rail@tmpa=\rail@sx
wenzelm@2658
   850
\advance\rail@tmpa by \rail@joinsz
wenzelm@2658
   851
\ifnum\rail@x<\rail@tmpa\rail@x=\rail@tmpa\fi
wenzelm@2658
   852
\rail@eline
wenzelm@2658
   853
\rail@jx=\rail@x
wenzelm@2658
   854
\rail@jy=\rail@y
wenzelm@2658
   855
\advance\rail@x by \rail@joinsz
wenzelm@2658
   856
\ifnum\rail@x>\rail@rx\rail@rx=\rail@x\fi
wenzelm@2658
   857
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   858
\rail@joval[tr]
wenzelm@2658
   859
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   860
\rail@sety{#1}
wenzelm@2658
   861
\rail@tmpa=\rail@jy
wenzelm@2658
   862
\advance\rail@tmpa by -\rail@y
wenzelm@2658
   863
\advance\rail@tmpa by -\rail@boxsp
wenzelm@2658
   864
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   865
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   866
\rail@jy=\rail@y
wenzelm@2658
   867
\advance\rail@jy by \rail@boxsp
wenzelm@2658
   868
\advance\rail@jy by \rail@joinhsz
wenzelm@2658
   869
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   870
\rail@joval[br]
wenzelm@2658
   871
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   872
\rail@tmpa=\rail@jx
wenzelm@2658
   873
\advance\rail@tmpa by -\rail@sx
wenzelm@2658
   874
\advance\rail@tmpa by -\rail@joinhsz
wenzelm@2658
   875
\rail@jput{\line(-1,0){\number\rail@tmpa}}
wenzelm@2658
   876
\rail@jx=\rail@sx
wenzelm@2658
   877
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   878
\advance\rail@jy by -\rail@joinhsz
wenzelm@2658
   879
\rail@joval[tl]
wenzelm@2658
   880
\advance\rail@jx by -\rail@joinhsz
wenzelm@2658
   881
\rail@tmpa=\rail@boxsp
wenzelm@2658
   882
\advance\rail@tmpa by -\rail@joinsz
wenzelm@2658
   883
\rail@jput{\line(0,-1){\number\rail@tmpa}}
wenzelm@2658
   884
\advance\rail@jy by -\rail@tmpa
wenzelm@2658
   885
\advance\rail@jx by \rail@joinhsz
wenzelm@2658
   886
\rail@joval[bl]
wenzelm@2658
   887
\rail@x=\rail@jx
wenzelm@2658
   888
\rail@ex=\rail@x
wenzelm@2658
   889
}