| 1 |
% om16bit.ch: Basic changes to TeX data structures allowing all |
| 2 |
% 8-bit entities to become 32-bit entities, in particular |
| 3 |
% characters and glyphs. |
| 4 |
% |
| 5 |
% This file is part of Omega, |
| 6 |
% which is based on the web2c distribution of TeX, |
| 7 |
% |
| 8 |
% Copyright (c) 1994--2000 John Plaice and Yannis Haralambous |
| 9 |
% |
| 10 |
% This library is free software; you can redistribute it and/or |
| 11 |
% modify it under the terms of the GNU Library General Public |
| 12 |
% License as published by the Free Software Foundation; either |
| 13 |
% version 2 of the License, or (at your option) any later version. |
| 14 |
% |
| 15 |
% This library is distributed in the hope that it will be useful, |
| 16 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
% Library General Public License for more details. |
| 19 |
% |
| 20 |
% You should have received a copy of the GNU Library General Public |
| 21 |
% License along with this library; if not, write to the Free Software |
| 22 |
% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 23 |
% |
| 24 |
@x limbo l.1 - Omega |
| 25 |
% This program is copyright (C) 1982 by D. E. Knuth; all rights are reserved. |
| 26 |
@y |
| 27 |
% This program is copyright |
| 28 |
% (C) 1994--2000 by John Plaice and Yannis Haralambous. |
| 29 |
% It is designed to be a change file for D. E. Knuth's TeX. |
| 30 |
% |
| 31 |
% This program is copyright (C) 1982 by D. E. Knuth; all rights are reserved. |
| 32 |
@z |
| 33 |
%--------------------------------------- |
| 34 |
@x limbo l.80 |
| 35 |
\def\title{\TeX82} |
| 36 |
@y |
| 37 |
\def\title{$\Omega$ (OMEGA)} |
| 38 |
@z |
| 39 |
%--------------------------------------- |
| 40 |
@x [1] m.1 l.90 - Omega |
| 41 |
This is \TeX, a document compiler intended to produce typesetting of high |
| 42 |
quality. |
| 43 |
The \PASCAL\ program that follows is the definition of \TeX82, a standard |
| 44 |
@:PASCAL}{\PASCAL@> |
| 45 |
@!@:TeX82}{\TeX82@> |
| 46 |
@y |
| 47 |
This is $\Omega$, a document compiler intended to simplify high-quality |
| 48 |
typesetting for many of the world's languages. It is an extension |
| 49 |
of D. E. Knuth's \TeX, which was designed essentially for the |
| 50 |
typesetting of languages using the Latin alphabet. |
| 51 |
|
| 52 |
The $\Omega$ system loosens many of the restrictions imposed by~\TeX: |
| 53 |
register numbers are no longer limited to 8~bits; fonts may have more |
| 54 |
than 256~characters; more than 256~fonts may be used; etc. In addition, |
| 55 |
$\Omega$ allows much more complex ligature mechanisms between characters, |
| 56 |
thereby simplifying the typesetting of alphabets that have preserved |
| 57 |
their calligraphic traditions. |
| 58 |
|
| 59 |
The \PASCAL\ program that follows is a modification of the definition of \TeX82, |
| 60 |
a standard @:PASCAL}{\PASCAL@> @!@:TeX82}{\TeX82@> |
| 61 |
@z |
| 62 |
%--------------------------------------- |
| 63 |
@x [1] m.1 l.97 - Omega |
| 64 |
will be obtainable on a great variety of computers. |
| 65 |
|
| 66 |
@y |
| 67 |
will be obtainable on a great variety of computers. |
| 68 |
|
| 69 |
As little as possible is changed in this document. This means that |
| 70 |
unless the contrary is explicitly stated, references to \TeX\ in the |
| 71 |
documentation are equally applicable to~$\Omega$. References to `the |
| 72 |
author' in the documentation are to D. E. Knuth. |
| 73 |
|
| 74 |
@z |
| 75 |
%--------------------------------------- |
| 76 |
@x [1] m.2 l.187 - Omega |
| 77 |
@d banner=='This is TeX, Version 3.141592653' {printed when \TeX\ starts} |
| 78 |
@y |
| 79 |
@d banner=='This is Omega, Version 3.141592653--1.15' {printed when \TeX\ starts} |
| 80 |
@z |
| 81 |
%--------------------------------------- |
| 82 |
@x [1] m.4 l.243 |
| 83 |
program TEX; {all file names are defined dynamically} |
| 84 |
@y |
| 85 |
program OMEGA; {all file names are defined dynamically} |
| 86 |
@z |
| 87 |
%--------------------------------------- |
| 88 |
@x [1] m.11 l.392 - Omega |
| 89 |
@!font_max=75; {maximum internal font number; must not exceed |max_quarterword| |
| 90 |
and must be at most |font_base+256|} |
| 91 |
@!font_mem_size=20000; {number of words of |font_info| for all fonts} |
| 92 |
@y |
| 93 |
@!font_max=65535; {maximum internal font number; must be at most |font_biggest|} |
| 94 |
@z |
| 95 |
%--------------------------------------- |
| 96 |
@x [1] m.11 l.412 - Omega |
| 97 |
@!pool_name='TeXformats:TEX.POOL '; |
| 98 |
@y |
| 99 |
@!pool_name='TeXformats:OMEGA.POOL '; |
| 100 |
@z |
| 101 |
%--------------------------------------- |
| 102 |
@x [1] m.12 l.437 - Omega |
| 103 |
@d hash_size=2100 {maximum number of control sequences; it should be at most |
| 104 |
about |(mem_max-mem_min)/10|} |
| 105 |
@d hash_prime=1777 {a prime number equal to about 85\pct! of |hash_size|} |
| 106 |
@d hyph_size=307 {another prime; the number of \.{\\hyphenation} exceptions} |
| 107 |
@y |
| 108 |
@d hash_size=65536 {maximum number of control sequences; it should be at most |
| 109 |
about |(mem_max-mem_min)/10|} |
| 110 |
@d hash_prime=55711 {a prime number equal to about 85\pct! of |hash_size|} |
| 111 |
@d hyph_size=307 {another prime; the number of \.{\\hyphenation} exceptions} |
| 112 |
@d biggest_char=65535 {the largest allowed character number; |
| 113 |
must be |<=max_quarterword|} |
| 114 |
@d too_big_char=65536 {|biggest_char+1|} |
| 115 |
@d special_char=65537 {|biggest_char+2|} |
| 116 |
@d number_chars=65536 {|biggest_char+1|} |
| 117 |
@d biggest_reg=65535 {the largest allowed register number; |
| 118 |
must be |<=max_quarterword|} |
| 119 |
@d number_regs=65536 {|biggest_reg+1|} |
| 120 |
@d font_biggest=65535 {the real biggest font} |
| 121 |
@d number_fonts=font_biggest-font_base+2 |
| 122 |
@d number_math_fonts=768 |
| 123 |
@d math_font_biggest=767 |
| 124 |
@d text_size=0 {size code for the largest size in a family} |
| 125 |
@d script_size=256 {size code for the medium size in a family} |
| 126 |
@d script_script_size=512 {size code for the smallest size in a family} |
| 127 |
@d biggest_lang=255 |
| 128 |
@d too_big_lang=256 |
| 129 |
@z |
| 130 |
%--------------------------------------- |
| 131 |
@x [8] m.110 l.2355 - Omega |
| 132 |
In order to make efficient use of storage space, \TeX\ bases its major data |
| 133 |
structures on a |memory_word|, which contains either a (signed) integer, |
| 134 |
possibly scaled, or a (signed) |glue_ratio|, or a small number of |
| 135 |
fields that are one half or one quarter of the size used for storing |
| 136 |
integers. |
| 137 |
|
| 138 |
@y |
| 139 |
In order to make efficient use of storage space, \TeX\ bases its major data |
| 140 |
structures on a |memory_word|, which contains either a (signed) integer, |
| 141 |
possibly scaled, or a (signed) |glue_ratio|, or a small number of |
| 142 |
fields that are one half or one quarter of the size used for storing |
| 143 |
integers. |
| 144 |
|
| 145 |
That is the description for \TeX. For $\Omega$, we are going to keep |
| 146 |
the same terminology, except that |quarterword| is going to refer to |
| 147 |
16~bits, and |halfword| is going to refer to 32~bits. So, in fact, |
| 148 |
a |memory_word| will take 64 bits, and, on a 64-bit machine, will run |
| 149 |
smaller than \TeX\ will! |
| 150 |
|
| 151 |
@z |
| 152 |
%--------------------------------------- |
| 153 |
@x [8] m.110 l.2378 - Omega |
| 154 |
Since we are assuming 32-bit integers, a halfword must contain at least |
| 155 |
16 bits, and a quarterword must contain at least 8 bits. |
| 156 |
@^system dependencies@> |
| 157 |
But it doesn't hurt to have more bits; for example, with enough 36-bit |
| 158 |
words you might be able to have |mem_max| as large as 262142, which is |
| 159 |
eight times as much memory as anybody had during the first four years of |
| 160 |
\TeX's existence. |
| 161 |
|
| 162 |
N.B.: Valuable memory space will be dreadfully wasted unless \TeX\ is compiled |
| 163 |
by a \PASCAL\ that packs all of the |memory_word| variants into |
| 164 |
the space of a single integer. This means, for example, that |glue_ratio| |
| 165 |
words should be |short_real| instead of |real| on some computers. Some |
| 166 |
\PASCAL\ compilers will pack an integer whose subrange is `|0..255|' into |
| 167 |
an eight-bit field, but others insist on allocating space for an additional |
| 168 |
sign bit; on such systems you can get 256 values into a quarterword only |
| 169 |
if the subrange is `|-128..127|'. |
| 170 |
|
| 171 |
@y |
| 172 |
@z |
| 173 |
%--------------------------------------- |
| 174 |
@x [8] m.110 l.2406 - Omega |
| 175 |
@d max_quarterword=255 {largest allowable value in a |quarterword|} |
| 176 |
@d min_halfword==0 {smallest allowable value in a |halfword|} |
| 177 |
@d max_halfword==65535 {largest allowable value in a |halfword|} |
| 178 |
@y |
| 179 |
@d max_quarterword=@"FFFF {largest allowable value in a |quarterword|} |
| 180 |
@d min_halfword=0 {smallest allowable value in a |halfword|} |
| 181 |
@d max_halfword=@"3FFFFFFF {largest allowable value in a |halfword|} |
| 182 |
@z |
| 183 |
%--------------------------------------- |
| 184 |
@x [8] m.111 l.2416 - Omega |
| 185 |
if (min_quarterword>0)or(max_quarterword<127) then bad:=11; |
| 186 |
if (min_halfword>0)or(max_halfword<32767) then bad:=12; |
| 187 |
@y |
| 188 |
if (min_quarterword>0)or(max_quarterword<@"7FFF) then bad:=11; |
| 189 |
if (min_halfword<>0)or(max_halfword<@"3FFFFFFF) then bad:=12; |
| 190 |
@z |
| 191 |
%--------------------------------------- |
| 192 |
@x [8.111] l.2435 - min_halfword and max_halfword |
| 193 |
if (mem_min<min_halfword)or(mem_max>=max_halfword)or@| |
| 194 |
(mem_bot-mem_min>max_halfword+1) then bad:=14; |
| 195 |
@y |
| 196 |
if (mem_min<min_halfword)or@| |
| 197 |
(mem_top+sup_main_memory>=max_halfword) then bad:=14; |
| 198 |
@z |
| 199 |
%--------------------------------------- |
| 200 |
@x [8] m.111 l.2438 - Omega |
| 201 |
if font_max>font_base+256 then bad:=16; |
| 202 |
@y |
| 203 |
if font_max>font_base+@"10000 then bad:=16; |
| 204 |
@z |
| 205 |
%--------------------------------------- |
| 206 |
@x [8] m.111 l.2426 - Omega |
| 207 |
if max_quarterword-min_quarterword<255 then bad:=19; |
| 208 |
@y |
| 209 |
if max_quarterword-min_quarterword<@"FFFF then bad:=19; |
| 210 |
@z |
| 211 |
%--------------------------------------- |
| 212 |
@x [10] m.134 l.2832 - Omega |
| 213 |
Note that the format of a |char_node| allows for up to 256 different |
| 214 |
fonts and up to 256 characters per font; but most implementations will |
| 215 |
probably limit the total number of fonts to fewer than 75 per job, |
| 216 |
and most fonts will stick to characters whose codes are |
| 217 |
less than 128 (since higher codes |
| 218 |
are more difficult to access on most keyboards). |
| 219 |
|
| 220 |
Extensions of \TeX\ intended for oriental languages will need even more |
| 221 |
than $256\times256$ possible characters, when we consider different sizes |
| 222 |
@^oriental characters@>@^Chinese characters@>@^Japanese characters@> |
| 223 |
and styles of type. It is suggested that Chinese and Japanese fonts be |
| 224 |
handled by representing such characters in two consecutive |char_node| |
| 225 |
entries: The first of these has |font=font_base|, and its |link| points |
| 226 |
to the second; |
| 227 |
the second identifies the font and the character dimensions. |
| 228 |
The saving feature about oriental characters is that most of them have |
| 229 |
the same box dimensions. The |character| field of the first |char_node| |
| 230 |
is a ``\\{charext}'' that distinguishes between graphic symbols whose |
| 231 |
dimensions are identical for typesetting purposes. (See the \MF\ manual.) |
| 232 |
Such an extension of \TeX\ would not be difficult; further details are |
| 233 |
left to the reader. |
| 234 |
@y |
| 235 |
Note that the format of a |char_node| allows for up to 65536 different |
| 236 |
fonts and up to 65536 characters per font. |
| 237 |
@z |
| 238 |
%--------------------------------------- |
| 239 |
@x [15] m.208 l.4127 - Omega |
| 240 |
@d min_internal=68 {the smallest code that can follow \.{\\the}} |
| 241 |
@d char_given=68 {character code defined by \.{\\chardef}} |
| 242 |
@d math_given=69 {math code defined by \.{\\mathchardef}} |
| 243 |
@d last_item=70 {most recent item ( \.{\\lastpenalty}, |
| 244 |
\.{\\lastkern}, \.{\\lastskip} )} |
| 245 |
@d max_non_prefixed_command=70 {largest command code that can't be \.{\\global}} |
| 246 |
@y |
| 247 |
@d min_internal=end_cs_name+1 {the smallest code that can follow \.{\\the}} |
| 248 |
@d char_given=min_internal {character code defined by \.{\\chardef}} |
| 249 |
@d math_given=char_given+1 {math code defined by \.{\\mathchardef}} |
| 250 |
@d omath_given=math_given+1 {math code defined by \.{\\omathchardef}} |
| 251 |
@d last_item=omath_given+1 {most recent item ( \.{\\lastpenalty}, |
| 252 |
\.{\\lastkern}, \.{\\lastskip} )} |
| 253 |
@d max_non_prefixed_command=last_item |
| 254 |
{largest command code that can't be \.{\\global}} |
| 255 |
@z |
| 256 |
%--------------------------------------- |
| 257 |
@x [15] m.209 l.4138 - Omega |
| 258 |
@d toks_register=71 {token list register ( \.{\\toks} )} |
| 259 |
@d assign_toks=72 {special token list ( \.{\\output}, \.{\\everypar}, etc.~)} |
| 260 |
@d assign_int=73 {user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~)} |
| 261 |
@d assign_dimen=74 {user-defined length ( \.{\\hsize}, etc.~)} |
| 262 |
@d assign_glue=75 {user-defined glue ( \.{\\baselineskip}, etc.~)} |
| 263 |
@d assign_mu_glue=76 {user-defined muglue ( \.{\\thinmuskip}, etc.~)} |
| 264 |
@d assign_font_dimen=77 {user-defined font dimension ( \.{\\fontdimen} )} |
| 265 |
@d assign_font_int=78 {user-defined font integer ( \.{\\hyphenchar}, |
| 266 |
\.{\\skewchar} )} |
| 267 |
@d set_aux=79 {specify state info ( \.{\\spacefactor}, \.{\\prevdepth} )} |
| 268 |
@d set_prev_graf=80 {specify state info ( \.{\\prevgraf} )} |
| 269 |
@d set_page_dimen=81 {specify state info ( \.{\\pagegoal}, etc.~)} |
| 270 |
@d set_page_int=82 {specify state info ( \.{\\deadcycles}, |
| 271 |
\.{\\insertpenalties} )} |
| 272 |
@d set_box_dimen=83 {change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} )} |
| 273 |
@d set_shape=84 {specify fancy paragraph shape ( \.{\\parshape} )} |
| 274 |
@d def_code=85 {define a character code ( \.{\\catcode}, etc.~)} |
| 275 |
@d def_family=86 {declare math fonts ( \.{\\textfont}, etc.~)} |
| 276 |
@d set_font=87 {set current font ( font identifiers )} |
| 277 |
@d def_font=88 {define a font file ( \.{\\font} )} |
| 278 |
@d register=89 {internal register ( \.{\\count}, \.{\\dimen}, etc.~)} |
| 279 |
@d max_internal=89 {the largest code that can follow \.{\\the}} |
| 280 |
@d advance=90 {advance a register or parameter ( \.{\\advance} )} |
| 281 |
@d multiply=91 {multiply a register or parameter ( \.{\\multiply} )} |
| 282 |
@d divide=92 {divide a register or parameter ( \.{\\divide} )} |
| 283 |
@d prefix=93 {qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} )} |
| 284 |
@d let=94 {assign a command code ( \.{\\let}, \.{\\futurelet} )} |
| 285 |
@d shorthand_def=95 {code definition ( \.{\\chardef}, \.{\\countdef}, etc.~)} |
| 286 |
@d read_to_cs=96 {read into a control sequence ( \.{\\read} )} |
| 287 |
@d def=97 {macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} )} |
| 288 |
@d set_box=98 {set a box ( \.{\\setbox} )} |
| 289 |
@d hyph_data=99 {hyphenation data ( \.{\\hyphenation}, \.{\\patterns} )} |
| 290 |
@d set_interaction=100 {define level of interaction ( \.{\\batchmode}, etc.~)} |
| 291 |
@d max_command=100 {the largest command code seen at |big_switch|} |
| 292 |
@y |
| 293 |
@d toks_register=max_non_prefixed_command+1 |
| 294 |
{token list register ( \.{\\toks} )} |
| 295 |
@d assign_toks=toks_register+1 |
| 296 |
{special token list ( \.{\\output}, \.{\\everypar}, etc.~)} |
| 297 |
@d assign_int=assign_toks+1 |
| 298 |
{user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~)} |
| 299 |
@d assign_dimen=assign_int+1 |
| 300 |
{user-defined length ( \.{\\hsize}, etc.~)} |
| 301 |
@d assign_glue=assign_dimen+1 |
| 302 |
{user-defined glue ( \.{\\baselineskip}, etc.~)} |
| 303 |
@d assign_mu_glue=assign_glue+1 |
| 304 |
{user-defined muglue ( \.{\\thinmuskip}, etc.~)} |
| 305 |
@d assign_font_dimen=assign_mu_glue+1 |
| 306 |
{user-defined font dimension ( \.{\\fontdimen} )} |
| 307 |
@d assign_font_int=assign_font_dimen+1 |
| 308 |
{user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} )} |
| 309 |
@d set_aux=assign_font_int+1 |
| 310 |
{specify state info ( \.{\\spacefactor}, \.{\\prevdepth} )} |
| 311 |
@d set_prev_graf=set_aux+1 |
| 312 |
{specify state info ( \.{\\prevgraf} )} |
| 313 |
@d set_page_dimen=set_prev_graf+1 |
| 314 |
{specify state info ( \.{\\pagegoal}, etc.~)} |
| 315 |
@d set_page_int=set_page_dimen+1 |
| 316 |
{specify state info ( \.{\\deadcycles}, |
| 317 |
\.{\\insertpenalties} )} |
| 318 |
@d set_box_dimen=set_page_int+1 |
| 319 |
{change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} )} |
| 320 |
@d set_shape=set_box_dimen+1 |
| 321 |
{specify fancy paragraph shape ( \.{\\parshape} )} |
| 322 |
@d def_code=set_shape+1 |
| 323 |
{define a character code ( \.{\\catcode}, etc.~)} |
| 324 |
@d def_family=def_code+1 |
| 325 |
{declare math fonts ( \.{\\textfont}, etc.~)} |
| 326 |
@d set_font=def_family+1 |
| 327 |
{set current font ( font identifiers )} |
| 328 |
@d def_font=set_font+1 |
| 329 |
{define a font file ( \.{\\font} )} |
| 330 |
@d register=def_font+1 |
| 331 |
{internal register ( \.{\\count}, \.{\\dimen}, etc.~)} |
| 332 |
@d max_internal=register |
| 333 |
{the largest code that can follow \.{\\the}} |
| 334 |
@d advance=max_internal+1 |
| 335 |
{advance a register or parameter ( \.{\\advance} )} |
| 336 |
@d multiply=advance+1 |
| 337 |
{multiply a register or parameter ( \.{\\multiply} )} |
| 338 |
@d divide=multiply+1 |
| 339 |
{divide a register or parameter ( \.{\\divide} )} |
| 340 |
@d prefix=divide+1 |
| 341 |
{qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} )} |
| 342 |
@d let=prefix+1 |
| 343 |
{assign a command code ( \.{\\let}, \.{\\futurelet} )} |
| 344 |
@d shorthand_def=let+1 |
| 345 |
{code definition ( \.{\\chardef}, \.{\\countdef}, etc.~)} |
| 346 |
@d read_to_cs=shorthand_def+1 |
| 347 |
{read into a control sequence ( \.{\\read} )} |
| 348 |
@d def=read_to_cs+1 |
| 349 |
{macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} )} |
| 350 |
@d set_box=def+1 |
| 351 |
{set a box ( \.{\\setbox} )} |
| 352 |
@d hyph_data=set_box+1 |
| 353 |
{hyphenation data ( \.{\\hyphenation}, \.{\\patterns} )} |
| 354 |
@d set_interaction=hyph_data+1 |
| 355 |
{define level of interaction ( \.{\\batchmode}, etc.~)} |
| 356 |
@d max_command=set_interaction |
| 357 |
{the largest command code seen at |big_switch|} |
| 358 |
@z |
| 359 |
%--------------------------------------- |
| 360 |
@x [17] m.220 l.4486 - Omega |
| 361 |
@d eq_level(#)==eq_level_field(eqtb[#]) {level of definition} |
| 362 |
@d eq_type(#)==eq_type_field(eqtb[#]) {command code for equivalent} |
| 363 |
@d equiv(#)==equiv_field(eqtb[#]) {equivalent value} |
| 364 |
@y |
| 365 |
@d eq_level(#)==new_eq_level(#) {level of definition} |
| 366 |
@d eq_type(#)==new_eq_type(#) {command code for equivalent} |
| 367 |
@d equiv(#)==new_equiv(#) {equivalent value} |
| 368 |
@d equiv1(#)==new_equiv1(#) {equivalent value} |
| 369 |
@z |
| 370 |
%--------------------------------------- |
| 371 |
@x [17] m.222 l.4496 - Omega |
| 372 |
In the first region we have 256 equivalents for ``active characters'' that |
| 373 |
act as control sequences, followed by 256 equivalents for single-character |
| 374 |
control sequences. |
| 375 |
@y |
| 376 |
In the first region we have |number_chars| equivalents for ``active characters'' |
| 377 |
that act as control sequences, followed by |number_chars| equivalents for |
| 378 |
single-character control sequences. |
| 379 |
@z |
| 380 |
%--------------------------------------- |
| 381 |
@x [17] m.222 l.4507 - Omega |
| 382 |
@d single_base=active_base+256 {equivalents of one-character control sequences} |
| 383 |
@d null_cs=single_base+256 {equivalent of \.{\\csname\\endcsname}} |
| 384 |
@y |
| 385 |
@d single_base=active_base+number_chars |
| 386 |
{equivalents of one-character control sequences} |
| 387 |
@d null_cs=single_base+number_chars {equivalent of \.{\\csname\\endcsname}} |
| 388 |
@z |
| 389 |
%--------------------------------------- |
| 390 |
@x [17] m.222 l.4530 - Omega |
| 391 |
eq_type(undefined_control_sequence):=undefined_cs; |
| 392 |
equiv(undefined_control_sequence):=null; |
| 393 |
eq_level(undefined_control_sequence):=level_zero; |
| 394 |
for k:=active_base to undefined_control_sequence-1 do |
| 395 |
eqtb[k]:=eqtb[undefined_control_sequence]; |
| 396 |
@y |
| 397 |
set_eq_type(undefined_control_sequence,undefined_cs); |
| 398 |
set_equiv(undefined_control_sequence,null); |
| 399 |
set_eq_level(undefined_control_sequence,level_zero); |
| 400 |
@z |
| 401 |
%--------------------------------------- |
| 402 |
@x [17] m.224 l.4547 - Omega |
| 403 |
@ Region 3 of |eqtb| contains the 256 \.{\\skip} registers, as well as the |
| 404 |
glue parameters defined here. It is important that the ``muskip'' |
| 405 |
parameters have larger numbers than the others. |
| 406 |
@y |
| 407 |
@ Region 3 of |eqtb| contains the |number_regs| \.{\\skip} registers, |
| 408 |
as well as the glue parameters defined here. It is important that the |
| 409 |
``muskip'' parameters have larger numbers than the others. |
| 410 |
@z |
| 411 |
%--------------------------------------- |
| 412 |
@x [17] m.224 l.4572 - Omega |
| 413 |
@d skip_base=glue_base+glue_pars {table of 256 ``skip'' registers} |
| 414 |
@d mu_skip_base=skip_base+256 {table of 256 ``muskip'' registers} |
| 415 |
@d local_base=mu_skip_base+256 {beginning of region 4} |
| 416 |
@y |
| 417 |
@d skip_base=glue_base+glue_pars {table of |number_regs| ``skip'' registers} |
| 418 |
@d mu_skip_base=skip_base+number_regs |
| 419 |
{table of |number_regs| ``muskip'' registers} |
| 420 |
@d local_base=mu_skip_base+number_regs {beginning of region 4} |
| 421 |
@z |
| 422 |
%--------------------------------------- |
| 423 |
@x [17] m.228 l.4685 - Omega |
| 424 |
equiv(glue_base):=zero_glue; eq_level(glue_base):=level_one; |
| 425 |
eq_type(glue_base):=glue_ref; |
| 426 |
for k:=glue_base+1 to local_base-1 do eqtb[k]:=eqtb[glue_base]; |
| 427 |
@y |
| 428 |
set_equiv(glue_base,zero_glue); set_eq_level(glue_base,level_one); |
| 429 |
set_eq_type(glue_base,glue_ref); |
| 430 |
@z |
| 431 |
%--------------------------------------- |
| 432 |
@x [17] m.230 l.4721 - Omega |
| 433 |
@d toks_base=local_base+10 {table of 256 token list registers} |
| 434 |
@d box_base=toks_base+256 {table of 256 box registers} |
| 435 |
@d cur_font_loc=box_base+256 {internal font number outside math mode} |
| 436 |
@d math_font_base=cur_font_loc+1 {table of 48 math font numbers} |
| 437 |
@d cat_code_base=math_font_base+48 |
| 438 |
{table of 256 command codes (the ``catcodes'')} |
| 439 |
@d lc_code_base=cat_code_base+256 {table of 256 lowercase mappings} |
| 440 |
@d uc_code_base=lc_code_base+256 {table of 256 uppercase mappings} |
| 441 |
@d sf_code_base=uc_code_base+256 {table of 256 spacefactor mappings} |
| 442 |
@d math_code_base=sf_code_base+256 {table of 256 math mode mappings} |
| 443 |
@d int_base=math_code_base+256 {beginning of region 5} |
| 444 |
@y |
| 445 |
@d toks_base=local_base+10 {table of |number_regs| token list registers} |
| 446 |
@d box_base=toks_base+number_regs {table of |number_regs| box registers} |
| 447 |
@d cur_font_loc=box_base+number_regs {internal font number outside math mode} |
| 448 |
@d math_font_base=cur_font_loc+1 |
| 449 |
{table of |number_math_fonts| math font numbers} |
| 450 |
@d cat_code_base=math_font_base+number_math_fonts |
| 451 |
{table of |number_chars| command codes (the ``catcodes'')} |
| 452 |
@d lc_code_base=cat_code_base+number_chars |
| 453 |
{table of |number_chars| lowercase mappings} |
| 454 |
@d uc_code_base=lc_code_base+number_chars |
| 455 |
{table of |number_chars| uppercase mappings} |
| 456 |
@d sf_code_base=uc_code_base+number_chars |
| 457 |
{table of |number_chars| spacefactor mappings} |
| 458 |
@d math_code_base=sf_code_base+number_chars |
| 459 |
{table of |number_chars| math mode mappings} |
| 460 |
@d int_base=math_code_base+number_chars {beginning of region 5} |
| 461 |
@z |
| 462 |
%--------------------------------------- |
| 463 |
@x [17] m.232 l.4802 - Omega |
| 464 |
@d var_code==@'70000 {math code meaning ``use the current family''} |
| 465 |
|
| 466 |
@<Initialize table entries...@>= |
| 467 |
par_shape_ptr:=null; eq_type(par_shape_loc):=shape_ref; |
| 468 |
eq_level(par_shape_loc):=level_one;@/ |
| 469 |
for k:=output_routine_loc to toks_base+255 do |
| 470 |
eqtb[k]:=eqtb[undefined_control_sequence]; |
| 471 |
box(0):=null; eq_type(box_base):=box_ref; eq_level(box_base):=level_one; |
| 472 |
for k:=box_base+1 to box_base+255 do eqtb[k]:=eqtb[box_base]; |
| 473 |
cur_font:=null_font; eq_type(cur_font_loc):=data; |
| 474 |
eq_level(cur_font_loc):=level_one;@/ |
| 475 |
for k:=math_font_base to math_font_base+47 do eqtb[k]:=eqtb[cur_font_loc]; |
| 476 |
equiv(cat_code_base):=0; eq_type(cat_code_base):=data; |
| 477 |
eq_level(cat_code_base):=level_one;@/ |
| 478 |
for k:=cat_code_base+1 to int_base-1 do eqtb[k]:=eqtb[cat_code_base]; |
| 479 |
for k:=0 to 255 do |
| 480 |
begin cat_code(k):=other_char; math_code(k):=hi(k); sf_code(k):=1000; |
| 481 |
end; |
| 482 |
cat_code(carriage_return):=car_ret; cat_code(" "):=spacer; |
| 483 |
cat_code("\"):=escape; cat_code("%"):=comment; |
| 484 |
cat_code(invalid_code):=invalid_char; cat_code(null_code):=ignore; |
| 485 |
for k:="0" to "9" do math_code(k):=hi(k+var_code); |
| 486 |
for k:="A" to "Z" do |
| 487 |
begin cat_code(k):=letter; cat_code(k+"a"-"A"):=letter;@/ |
| 488 |
math_code(k):=hi(k+var_code+@"100); |
| 489 |
math_code(k+"a"-"A"):=hi(k+"a"-"A"+var_code+@"100);@/ |
| 490 |
lc_code(k):=k+"a"-"A"; lc_code(k+"a"-"A"):=k+"a"-"A";@/ |
| 491 |
uc_code(k):=k; uc_code(k+"a"-"A"):=k;@/ |
| 492 |
sf_code(k):=999; |
| 493 |
end; |
| 494 |
@y |
| 495 |
@d var_code==@"7000000 {math code meaning ``use the current family''} |
| 496 |
|
| 497 |
@<Initialize table entries...@>= |
| 498 |
set_equiv(par_shape_loc,null); set_eq_type(par_shape_loc,shape_ref); |
| 499 |
set_eq_level(par_shape_loc,level_one);@/ |
| 500 |
set_equiv(cat_code_base+carriage_return,car_ret); |
| 501 |
set_equiv(cat_code_base+" ",spacer); |
| 502 |
set_equiv(cat_code_base+"\",escape); |
| 503 |
set_equiv(cat_code_base+"%",comment); |
| 504 |
set_equiv(cat_code_base+invalid_code,invalid_char); |
| 505 |
set_equiv(cat_code_base+null_code,ignore); |
| 506 |
for k:="0" to "9" do set_equiv(math_code_base+k,hi(k+var_code)); |
| 507 |
for k:="A" to "Z" do |
| 508 |
begin set_equiv(cat_code_base+k,letter); |
| 509 |
set_equiv(cat_code_base+k+"a"-"A",letter);@/ |
| 510 |
set_equiv(math_code_base+k,hi(k+var_code+@"10000)); |
| 511 |
set_equiv(math_code_base+k+"a"-"A",hi(k+"a"-"A"+var_code+@"10000));@/ |
| 512 |
set_equiv(lc_code_base+k,k+"a"-"A"); |
| 513 |
set_equiv(lc_code_base+k+"a"-"A",k+"a"-"A");@/ |
| 514 |
set_equiv(uc_code_base+k,k); |
| 515 |
set_equiv(uc_code_base+k+"a"-"A",k);@/ |
| 516 |
set_equiv(sf_code_base+k,999); |
| 517 |
end; |
| 518 |
@z |
| 519 |
%--------------------------------------- |
| 520 |
@x [17] m.234 l.4857 - Omega |
| 521 |
@ @<Show the font identifier in |eqtb[n]|@>= |
| 522 |
begin if n=cur_font_loc then print("current font") |
| 523 |
else if n<math_font_base+16 then |
| 524 |
begin print_esc("textfont"); print_int(n-math_font_base); |
| 525 |
end |
| 526 |
else if n<math_font_base+32 then |
| 527 |
begin print_esc("scriptfont"); print_int(n-math_font_base-16); |
| 528 |
end |
| 529 |
else begin print_esc("scriptscriptfont"); print_int(n-math_font_base-32); |
| 530 |
end; |
| 531 |
print_char("=");@/ |
| 532 |
print_esc(hash[font_id_base+equiv(n)].rh); |
| 533 |
{that's |font_id_text(equiv(n))|} |
| 534 |
@y |
| 535 |
@ @<Show the font identifier in |eqtb[n]|@>= |
| 536 |
begin if n=cur_font_loc then print("current font") |
| 537 |
else if n<math_font_base+script_size then |
| 538 |
begin print_esc("textfont"); print_int(n-math_font_base); |
| 539 |
end |
| 540 |
else if n<math_font_base+script_script_size then |
| 541 |
begin print_esc("scriptfont"); print_int(n-math_font_base-script_size); |
| 542 |
end |
| 543 |
else begin print_esc("scriptscriptfont"); |
| 544 |
print_int(n-math_font_base-script_script_size); |
| 545 |
end; |
| 546 |
print_char("=");@/ |
| 547 |
print_esc(newtext(font_id_base+equiv(n))); |
| 548 |
{that's |font_id_text(equiv(n))|} |
| 549 |
@z |
| 550 |
%--------------------------------------- |
| 551 |
@x [17] m.236 l.4955 - Omega |
| 552 |
@d count_base=int_base+int_pars {256 user \.{\\count} registers} |
| 553 |
@d del_code_base=count_base+256 {256 delimiter code mappings} |
| 554 |
@d dimen_base=del_code_base+256 {beginning of region 6} |
| 555 |
@# |
| 556 |
@d del_code(#)==eqtb[del_code_base+#].int |
| 557 |
@d count(#)==eqtb[count_base+#].int |
| 558 |
@d int_par(#)==eqtb[int_base+#].int {an integer parameter} |
| 559 |
@y |
| 560 |
@d count_base=int_base+int_pars {|number_regs| user \.{\\count} registers} |
| 561 |
@d del_code_base=count_base+number_regs {|number_chars| delimiter code mappings} |
| 562 |
@d dimen_base=del_code_base+number_chars {beginning of region 6} |
| 563 |
@# |
| 564 |
@d del_code0(#)==new_equiv(del_code_base+#) |
| 565 |
@d del_code1(#)==new_equiv1(del_code_base+#) |
| 566 |
@d count(#)==new_eqtb_int(count_base+#) |
| 567 |
@d int_par(#)==new_eqtb_int(int_base+#) {an integer parameter} |
| 568 |
@z |
| 569 |
%--------------------------------------- |
| 570 |
@x [17] m.240 l.5213 - Omega |
| 571 |
for k:=int_base to del_code_base-1 do eqtb[k].int:=0; |
| 572 |
mag:=1000; tolerance:=10000; hang_after:=1; max_dead_cycles:=25; |
| 573 |
escape_char:="\"; end_line_char:=carriage_return; |
| 574 |
for k:=0 to 255 do del_code(k):=-1; |
| 575 |
del_code("."):=0; {this null delimiter is used in error recovery} |
| 576 |
@y |
| 577 |
set_new_eqtb_int(int_base+mag_code,1000); |
| 578 |
set_new_eqtb_int(int_base+tolerance_code,10000); |
| 579 |
set_new_eqtb_int(int_base+hang_after_code,1); |
| 580 |
set_new_eqtb_int(int_base+max_dead_cycles_code,25); |
| 581 |
set_new_eqtb_int(int_base+escape_char_code,"\"); |
| 582 |
set_new_eqtb_int(int_base+end_line_char_code,carriage_return); |
| 583 |
set_equiv(del_code_base+".",0); |
| 584 |
set_equiv1(del_code_base+".",0); |
| 585 |
{this null delimiter is used in error recovery} |
| 586 |
|
| 587 |
@ @<Set newline character to -1@>= |
| 588 |
set_new_eqtb_int(int_base+new_line_char_code,-1) |
| 589 |
|
| 590 |
@ @<Set newline character to nl@>= |
| 591 |
set_new_eqtb_int(int_base+new_line_char_code,nl) |
| 592 |
|
| 593 |
@z |
| 594 |
%--------------------------------------- |
| 595 |
@x [17] m.242 l.5240 - Omega |
| 596 |
print_char("="); print_int(eqtb[n].int); |
| 597 |
@y |
| 598 |
print_char("="); print_int(new_eqtb_int(n)); |
| 599 |
@z |
| 600 |
%--------------------------------------- |
| 601 |
@x [17] m.247 l.5273 - Omega |
| 602 |
here, and the 256 \.{\\dimen} registers. |
| 603 |
@y |
| 604 |
here, and the |number_regs| \.{\\dimen} registers. |
| 605 |
@z |
| 606 |
%--------------------------------------- |
| 607 |
@x [17] m.247 l.5298 - Omega |
| 608 |
{table of 256 user-defined \.{\\dimen} registers} |
| 609 |
@d eqtb_size=scaled_base+255 {largest subscript of |eqtb|} |
| 610 |
@# |
| 611 |
@d dimen(#)==eqtb[scaled_base+#].sc |
| 612 |
@d dimen_par(#)==eqtb[dimen_base+#].sc {a scaled quantity} |
| 613 |
@y |
| 614 |
{table of |number_regs| user-defined \.{\\dimen} registers} |
| 615 |
@d eqtb_size=scaled_base+biggest_reg {largest subscript of |eqtb|} |
| 616 |
@# |
| 617 |
@d dimen(#)==new_eqtb_sc(scaled_base+(#)) |
| 618 |
@d dimen_par(#)==new_eqtb_sc(dimen_base+(#)) {a scaled quantity} |
| 619 |
@z |
| 620 |
%--------------------------------------- |
| 621 |
@x [17] m.250 l.5405 - Omega |
| 622 |
for k:=dimen_base to eqtb_size do eqtb[k].sc:=0; |
| 623 |
@y |
| 624 |
|
| 625 |
@ @p function init_eqtb_entry (p:pointer):memory_word; |
| 626 |
var mw:memory_word; |
| 627 |
begin |
| 628 |
{ Regions 1 and 2 } |
| 629 |
if (p>=active_base) and |
| 630 |
(p<=undefined_control_sequence) then begin |
| 631 |
equiv_field(mw):=null; |
| 632 |
eq_type_field(mw):=undefined_cs; |
| 633 |
eq_level_field(mw):=level_zero; |
| 634 |
end |
| 635 |
{ Region 3 } |
| 636 |
else if (p>=glue_base) and |
| 637 |
(p<=local_base+1) then begin |
| 638 |
equiv_field(mw):=zero_glue; |
| 639 |
eq_type_field(mw):=glue_ref; |
| 640 |
eq_level_field(mw):=level_one; |
| 641 |
end |
| 642 |
{ Region 4 } |
| 643 |
else if (p>=par_shape_loc) and |
| 644 |
(p<=toks_base+biggest_reg) then begin |
| 645 |
equiv_field(mw):=null; |
| 646 |
eq_type_field(mw):=undefined_cs; |
| 647 |
eq_level_field(mw):=level_zero; |
| 648 |
end |
| 649 |
else if (p>=box_base) and |
| 650 |
(p<=box_base+biggest_reg) then begin |
| 651 |
equiv_field(mw):=null; |
| 652 |
eq_type_field(mw):=box_ref; |
| 653 |
eq_level_field(mw):=level_one; |
| 654 |
end |
| 655 |
else if (p>=cur_font_loc) and |
| 656 |
(p<=math_font_base+math_font_biggest) then begin |
| 657 |
equiv_field(mw):=null_font; |
| 658 |
eq_type_field(mw):=data; |
| 659 |
eq_level_field(mw):=level_one; |
| 660 |
end |
| 661 |
else if (p>=cat_code_base) and |
| 662 |
(p<=cat_code_base+biggest_char) then begin |
| 663 |
equiv_field(mw):=other_char; |
| 664 |
eq_type_field(mw):=data; |
| 665 |
eq_level_field(mw):=level_one; |
| 666 |
end |
| 667 |
else if (p>=lc_code_base) and |
| 668 |
(p<=uc_code_base+biggest_char) then begin |
| 669 |
equiv_field(mw):=0; |
| 670 |
eq_type_field(mw):=data; |
| 671 |
eq_level_field(mw):=level_one; |
| 672 |
end |
| 673 |
else if (p>=sf_code_base) and |
| 674 |
(p<=sf_code_base+biggest_char) then begin |
| 675 |
equiv_field(mw):=1000; |
| 676 |
eq_type_field(mw):=data; |
| 677 |
eq_level_field(mw):=level_one; |
| 678 |
end |
| 679 |
else if (p>=math_code_base) and |
| 680 |
(p<=math_code_base+biggest_char) then begin |
| 681 |
equiv_field(mw):=hi(p-math_code_base); |
| 682 |
eq_type_field(mw):=data; |
| 683 |
eq_level_field(mw):=level_one; |
| 684 |
end |
| 685 |
{ Region 5 } |
| 686 |
else if (p>=int_base) and (p<=del_code_base-1) then begin |
| 687 |
setintzero(mw,0); |
| 688 |
setintone(mw,0); |
| 689 |
end |
| 690 |
else if (p>=del_code_base) and (p<=del_code_base+biggest_char) then begin |
| 691 |
setintzero(mw,-1); |
| 692 |
setintone(mw,-1); |
| 693 |
end |
| 694 |
{ Region 6 } |
| 695 |
else if (p>=dimen_base) and (p<=eqtb_size) then begin |
| 696 |
setintzero(mw,0); |
| 697 |
setintone(mw,0); |
| 698 |
end |
| 699 |
else begin |
| 700 |
equiv_field(mw):=null; |
| 701 |
eq_type_field(mw):=undefined_cs; |
| 702 |
eq_level_field(mw):=level_zero; |
| 703 |
end; |
| 704 |
init_eqtb_entry:=mw; |
| 705 |
end; |
| 706 |
|
| 707 |
@z |
| 708 |
%--------------------------------------- |
| 709 |
@x [17] m.251 l.5411 - Omega |
| 710 |
print_char("="); print_scaled(eqtb[n].sc); print("pt"); |
| 711 |
@y |
| 712 |
print_char("="); print_scaled(new_eqtb_sc(n)); print("pt"); |
| 713 |
@z |
| 714 |
%--------------------------------------- |
| 715 |
@x [17] m.254 l.5435 - Omega |
| 716 |
@ The last two regions of |eqtb| have fullword values instead of the |
| 717 |
three fields |eq_level|, |eq_type|, and |equiv|. An |eq_type| is unnecessary, |
| 718 |
but \TeX\ needs to store the |eq_level| information in another array |
| 719 |
called |xeq_level|. |
| 720 |
|
| 721 |
@<Glob...@>= |
| 722 |
@!eqtb:array[active_base..eqtb_size] of memory_word; |
| 723 |
@!xeq_level:array[int_base..eqtb_size] of quarterword; |
| 724 |
@y |
| 725 |
@ The last two regions of |eqtb| have fullword values instead of the |
| 726 |
three fields |eq_level|, |eq_type|, and |equiv|. An |eq_type| is unnecessary, |
| 727 |
but \TeX\ needs to store the |eq_level| information in another array |
| 728 |
called |xeq_level|. |
| 729 |
|
| 730 |
@d xeq_level(#) == new_xeq_level(eqtb_size+eqtb_size+#) |
| 731 |
@d set_xeq_level(#) == set_new_eqtb_int(eqtb_size+eqtb_size+#) |
| 732 |
@z |
| 733 |
%--------------------------------------- |
| 734 |
@x [17] m.255 l.5439 - Omega |
| 735 |
for k:=int_base to eqtb_size do xeq_level[k]:=level_one; |
| 736 |
@y |
| 737 |
@z |
| 738 |
%--------------------------------------- |
| 739 |
@x [17] m.255 l.5446 - Omega |
| 740 |
for q:=active_base to box_base+255 do |
| 741 |
@y |
| 742 |
for q:=active_base to box_base+biggest_reg do |
| 743 |
@z |
| 744 |
%--------------------------------------- |
| 745 |
@x [18] m.256 l.5477 - Omega |
| 746 |
@d next(#) == hash[#].lh {link for coalesced lists} |
| 747 |
@d text(#) == hash[#].rh {string number for control sequence name} |
| 748 |
@d hash_is_full == (hash_used=hash_base) {test if all positions are occupied} |
| 749 |
@d font_id_text(#) == text(font_id_base+#) {a frozen font identifier's name} |
| 750 |
|
| 751 |
@<Glob...@>= |
| 752 |
@!hash: array[hash_base..undefined_control_sequence-1] of two_halves; |
| 753 |
{the hash table} |
| 754 |
@y |
| 755 |
@d hash_is_full == (hash_used=hash_base) {test if all positions are occupied} |
| 756 |
@d font_id_text(#) == newtext(font_id_base+#) {a frozen font identifier's name} |
| 757 |
@d newtext(#) == new_hash_text(eqtb_size+#) |
| 758 |
@d newnext(#) == new_hash_next(eqtb_size+#) |
| 759 |
@d settext(#) == set_hash_text(eqtb_size+#) |
| 760 |
@d setnext(#) == set_hash_next(eqtb_size+#) |
| 761 |
|
| 762 |
@<Glob...@>= |
| 763 |
@z |
| 764 |
%--------------------------------------- |
| 765 |
@x [18] m.257 l.5491 - Omega |
| 766 |
next(hash_base):=0; text(hash_base):=0; |
| 767 |
for k:=hash_base+1 to undefined_control_sequence-1 do hash[k]:=hash[hash_base]; |
| 768 |
@y |
| 769 |
@z |
| 770 |
%--------------------------------------- |
| 771 |
@x [18] m.258 l.5497 - Omega |
| 772 |
hash_used:=frozen_control_sequence; {nothing is used} |
| 773 |
cs_count:=0; |
| 774 |
eq_type(frozen_dont_expand):=dont_expand; |
| 775 |
text(frozen_dont_expand):="notexpanded:"; |
| 776 |
@y |
| 777 |
hash_used:=frozen_control_sequence; {nothing is used} |
| 778 |
cs_count:=0; |
| 779 |
set_eq_type(frozen_dont_expand,dont_expand); |
| 780 |
settext(frozen_dont_expand,"notexpanded:"); |
| 781 |
@z |
| 782 |
%--------------------------------------- |
| 783 |
@x [18] m.259 l.5514 - Omega |
| 784 |
@!k:pointer; {index in |buffer| array} |
| 785 |
begin @<Compute the hash code |h|@>; |
| 786 |
p:=h+hash_base; {we start searching here; note that |0<=h<hash_prime|} |
| 787 |
loop@+begin if text(p)>0 then if length(text(p))=l then |
| 788 |
if str_eq_buf(text(p),j) then goto found; |
| 789 |
if next(p)=0 then |
| 790 |
begin if no_new_control_sequence then |
| 791 |
p:=undefined_control_sequence |
| 792 |
else @<Insert a new control sequence after |p|, then make |
| 793 |
|p| point to it@>; |
| 794 |
goto found; |
| 795 |
end; |
| 796 |
p:=next(p); |
| 797 |
end; |
| 798 |
found: id_lookup:=p; |
| 799 |
@y |
| 800 |
@!k:pointer; {index in |buffer| array} |
| 801 |
@!newstring:integer; |
| 802 |
begin @<Compute the hash code |h|@>; |
| 803 |
p:=h+hash_base; {we start searching here; note that |0<=h<hash_prime|} |
| 804 |
loop@+begin if newtext(p)>0 then if length(newtext(p))=l then |
| 805 |
if str_eq_buf(newtext(p),j) then goto found; |
| 806 |
if newnext(p)=0 then |
| 807 |
begin if no_new_control_sequence then |
| 808 |
p:=undefined_control_sequence |
| 809 |
else @<Insert a new control sequence after |p|, then make |
| 810 |
|p| point to it@>; |
| 811 |
goto found; |
| 812 |
end; |
| 813 |
p:=newnext(p); |
| 814 |
end; |
| 815 |
found: id_lookup:=p; |
| 816 |
@z |
| 817 |
%--------------------------------------- |
| 818 |
@x [18] m.260 l.5532 - Omega |
| 819 |
begin if text(p)>0 then |
| 820 |
begin repeat if hash_is_full then overflow("hash size",hash_size); |
| 821 |
@:TeX capacity exceeded hash size}{\quad hash size@> |
| 822 |
decr(hash_used); |
| 823 |
until text(hash_used)=0; {search for an empty location in |hash|} |
| 824 |
next(p):=hash_used; p:=hash_used; |
| 825 |
end; |
| 826 |
str_room(l); d:=cur_length; |
| 827 |
while pool_ptr>str_start[str_ptr] do |
| 828 |
begin decr(pool_ptr); str_pool[pool_ptr+l]:=str_pool[pool_ptr]; |
| 829 |
end; {move current string up to make room for another} |
| 830 |
for k:=j to j+l-1 do append_char(buffer[k]); |
| 831 |
text(p):=make_string; pool_ptr:=pool_ptr+d; |
| 832 |
@y |
| 833 |
begin if newtext(p)>0 then |
| 834 |
begin repeat if hash_is_full then overflow("hash size",hash_size); |
| 835 |
@:TeX capacity exceeded hash size}{\quad hash size@> |
| 836 |
decr(hash_used); |
| 837 |
until newtext(hash_used)=0; {search for an empty location in |hash|} |
| 838 |
setnext(p,hash_used); p:=hash_used; |
| 839 |
end; |
| 840 |
str_room(l); d:=cur_length; |
| 841 |
while pool_ptr>str_start[str_ptr] do |
| 842 |
begin decr(pool_ptr); str_pool[pool_ptr+l]:=str_pool[pool_ptr]; |
| 843 |
end; {move current string up to make room for another} |
| 844 |
for k:=j to j+l-1 do append_char(buffer[k]); |
| 845 |
newstring:=make_string; |
| 846 |
settext(p,newstring); pool_ptr:=pool_ptr+d; |
| 847 |
@z |
| 848 |
%--------------------------------------- |
| 849 |
@x [18] m.262 l.5584 - Omega |
| 850 |
else if (text(p)<0)or(text(p)>=str_ptr) then print_esc("NONEXISTENT.") |
| 851 |
@.NONEXISTENT@> |
| 852 |
else begin print_esc(text(p)); |
| 853 |
@y |
| 854 |
else if (newtext(p)<0)or(newtext(p)>=str_ptr) then print_esc("NONEXISTENT.") |
| 855 |
@.NONEXISTENT@> |
| 856 |
else begin print_esc(newtext(p)); |
| 857 |
@z |
| 858 |
%--------------------------------------- |
| 859 |
@x [18] m.263 l.5601 - Omega |
| 860 |
else print_esc(text(p)); |
| 861 |
@y |
| 862 |
else print_esc(newtext(p)); |
| 863 |
@z |
| 864 |
%--------------------------------------- |
| 865 |
@x [18] m.264 l.5610 - Omega |
| 866 |
@p @!init procedure primitive(@!s:str_number;@!c:quarterword;@!o:halfword); |
| 867 |
var k:pool_pointer; {index into |str_pool|} |
| 868 |
@!j:small_number; {index into |buffer|} |
| 869 |
@!l:small_number; {length of the string} |
| 870 |
begin if s<256 then cur_val:=s+single_base |
| 871 |
else begin k:=str_start[s]; l:=str_start[s+1]-k; |
| 872 |
{we will move |s| into the (empty) |buffer|} |
| 873 |
for j:=0 to l-1 do buffer[j]:=so(str_pool[k+j]); |
| 874 |
cur_val:=id_lookup(0,l); {|no_new_control_sequence| is |false|} |
| 875 |
flush_string; text(cur_val):=s; {we don't want to have the string twice} |
| 876 |
end; |
| 877 |
eq_level(cur_val):=level_one; eq_type(cur_val):=c; equiv(cur_val):=o; |
| 878 |
@y |
| 879 |
@p @!init procedure primitive(@!s:str_number;@!c:quarterword;@!o:halfword); |
| 880 |
var k:pool_pointer; {index into |str_pool|} |
| 881 |
@!j:small_number; {index into |buffer|} |
| 882 |
@!l:small_number; {length of the string} |
| 883 |
begin if s<=biggest_char then cur_val:=s+single_base |
| 884 |
else begin k:=str_start[s]; l:=str_start[s+1]-k; |
| 885 |
{we will move |s| into the (empty) |buffer|} |
| 886 |
for j:=0 to l-1 do buffer[j]:=so(str_pool[k+j]); |
| 887 |
cur_val:=id_lookup(0,l); {|no_new_control_sequence| is |false|} |
| 888 |
flush_string; settext(cur_val,s); {we don't want to have the string twice} |
| 889 |
end; |
| 890 |
set_eq_level(cur_val,level_one); set_eq_type(cur_val,c); |
| 891 |
set_equiv(cur_val,o); |
| 892 |
@z |
| 893 |
%--------------------------------------- |
| 894 |
@x [18] m.265 l.5648 - Omega |
| 895 |
primitive("delimiter",delim_num,0);@/ |
| 896 |
@!@:delimiter_}{\.{\\delimiter} primitive@> |
| 897 |
@y |
| 898 |
primitive("delimiter",delim_num,0);@/ |
| 899 |
@!@:delimiter_}{\.{\\delimiter} primitive@> |
| 900 |
primitive("odelimiter",delim_num,1);@/ |
| 901 |
@!@:delimiter_}{\.{\\odelimiter} primitive@> |
| 902 |
@z |
| 903 |
%--------------------------------------- |
| 904 |
@x [18] m.265 l.5656 - Omega |
| 905 |
text(frozen_end_group):="endgroup"; eqtb[frozen_end_group]:=eqtb[cur_val];@/ |
| 906 |
@y |
| 907 |
settext(frozen_end_group,"endgroup"); |
| 908 |
set_new_eqtb(frozen_end_group,new_eqtb(cur_val));@/ |
| 909 |
@z |
| 910 |
%--------------------------------------- |
| 911 |
@x [18] m.265 l.5673 - Omega |
| 912 |
primitive("mathaccent",math_accent,0);@/ |
| 913 |
@!@:math_accent_}{\.{\\mathaccent} primitive@> |
| 914 |
primitive("mathchar",math_char_num,0);@/ |
| 915 |
@!@:math_char_}{\.{\\mathchar} primitive@> |
| 916 |
@y |
| 917 |
primitive("mathaccent",math_accent,0);@/ |
| 918 |
@!@:math_accent_}{\.{\\mathaccent} primitive@> |
| 919 |
primitive("mathchar",math_char_num,0);@/ |
| 920 |
@!@:math_char_}{\.{\\mathchar} primitive@> |
| 921 |
primitive("omathaccent",math_accent,1);@/ |
| 922 |
@!@:math_accent_}{\.{\\omathaccent} primitive@> |
| 923 |
primitive("omathchar",math_char_num,1);@/ |
| 924 |
@!@:math_char_}{\.{\\omathchar} primitive@> |
| 925 |
@z |
| 926 |
%--------------------------------------- |
| 927 |
@x [18] m.265 l.5697 - Omega |
| 928 |
primitive("radical",radical,0);@/ |
| 929 |
@!@:radical_}{\.{\\radical} primitive@> |
| 930 |
@y |
| 931 |
primitive("radical",radical,0);@/ |
| 932 |
@!@:radical_}{\.{\\radical} primitive@> |
| 933 |
primitive("oradical",radical,1);@/ |
| 934 |
@!@:radical_}{\.{\\oradical} primitive@> |
| 935 |
@z |
| 936 |
%--------------------------------------- |
| 937 |
@x [18] m.265 l.5701 - Omega |
| 938 |
primitive("relax",relax,256); {cf.\ |scan_file_name|} |
| 939 |
@!@:relax_}{\.{\\relax} primitive@> |
| 940 |
text(frozen_relax):="relax"; eqtb[frozen_relax]:=eqtb[cur_val];@/ |
| 941 |
@y |
| 942 |
primitive("relax",relax,too_big_char); {cf.\ |scan_file_name|} |
| 943 |
@!@:relax_}{\.{\\relax} primitive@> |
| 944 |
settext(frozen_relax,"relax"); |
| 945 |
set_new_eqtb(frozen_relax,new_eqtb(cur_val));@/ |
| 946 |
@z |
| 947 |
%--------------------------------------- |
| 948 |
@x |
| 949 |
delim_num: print_esc("delimiter"); |
| 950 |
@y |
| 951 |
delim_num: if chr_code=0 then print_esc("delimiter") |
| 952 |
else print_esc("odelimiter"); |
| 953 |
@z |
| 954 |
@x |
| 955 |
math_accent: print_esc("mathaccent"); |
| 956 |
math_char_num: print_esc("mathchar"); |
| 957 |
@y |
| 958 |
math_accent: if chr_code=0 then print_esc("mathaccent") |
| 959 |
else print_esc("omathaccent"); |
| 960 |
math_char_num: if chr_code=0 then print_esc("mathchar") |
| 961 |
else print_esc("omathchar"); |
| 962 |
@z |
| 963 |
@x |
| 964 |
radical: print_esc("radical"); |
| 965 |
@y |
| 966 |
radical: if chr_code=0 then print_esc("radical") |
| 967 |
else print_esc("oradical"); |
| 968 |
@z |
| 969 |
%--------------------------------------- |
| 970 |
@x [19] m.276 l.5951 - Omega |
| 971 |
else begin save_stack[save_ptr]:=eqtb[p]; incr(save_ptr); |
| 972 |
@y |
| 973 |
else begin save_stack[save_ptr]:=new_eqtb(p); incr(save_ptr); |
| 974 |
@z |
| 975 |
%--------------------------------------- |
| 976 |
@x [19] m.277 l.5967 - Omega |
| 977 |
begin if eq_level(p)=cur_level then eq_destroy(eqtb[p]) |
| 978 |
else if cur_level>level_one then eq_save(p,eq_level(p)); |
| 979 |
eq_level(p):=cur_level; eq_type(p):=t; equiv(p):=e; |
| 980 |
@y |
| 981 |
begin if eq_level(p)=cur_level then eq_destroy(new_eqtb(p)) |
| 982 |
else if cur_level>level_one then eq_save(p,eq_level(p)); |
| 983 |
set_eq_level(p,cur_level); set_eq_type(p,t); set_equiv(p,e); |
| 984 |
@z |
| 985 |
%--------------------------------------- |
| 986 |
@x [19] m.278 l.5980 - Omega |
| 987 |
@p procedure eq_word_define(@!p:pointer;@!w:integer); |
| 988 |
begin if xeq_level[p]<>cur_level then |
| 989 |
begin eq_save(p,xeq_level[p]); xeq_level[p]:=cur_level; |
| 990 |
end; |
| 991 |
eqtb[p].int:=w; |
| 992 |
end; |
| 993 |
@y |
| 994 |
@p procedure eq_word_define(@!p:pointer;@!w:integer); |
| 995 |
begin if xeq_level(p)<>cur_level then |
| 996 |
begin eq_save(p,xeq_level(p)); set_xeq_level(p,cur_level); |
| 997 |
end; |
| 998 |
set_new_eqtb_int(p,w); |
| 999 |
end; |
| 1000 |
|
| 1001 |
procedure del_eq_word_define(@!p:pointer;@!w,wone:integer); |
| 1002 |
begin if xeq_level(p)<>cur_level then |
| 1003 |
begin eq_save(p,xeq_level(p)); set_xeq_level(p,cur_level); |
| 1004 |
end; |
| 1005 |
set_equiv(p,w); set_equiv1(p,wone); |
| 1006 |
end; |
| 1007 |
|
| 1008 |
@z |
| 1009 |
%--------------------------------------- |
| 1010 |
@x [19] m.279 l.5990 - Omega |
| 1011 |
begin eq_destroy(eqtb[p]); |
| 1012 |
eq_level(p):=level_one; eq_type(p):=t; equiv(p):=e; |
| 1013 |
end; |
| 1014 |
@# |
| 1015 |
procedure geq_word_define(@!p:pointer;@!w:integer); {global |eq_word_define|} |
| 1016 |
begin eqtb[p].int:=w; xeq_level[p]:=level_one; |
| 1017 |
end; |
| 1018 |
@y |
| 1019 |
begin eq_destroy(new_eqtb(p)); |
| 1020 |
set_eq_level(p,level_one); set_eq_type(p,t); set_equiv(p,e); |
| 1021 |
end; |
| 1022 |
@# |
| 1023 |
procedure geq_word_define(@!p:pointer;@!w:integer); {global |eq_word_define|} |
| 1024 |
begin set_new_eqtb_int(p,w); set_xeq_level(p,level_one); |
| 1025 |
end; |
| 1026 |
|
| 1027 |
procedure del_geq_word_define(@!p:pointer;@!w,wone:integer); |
| 1028 |
{global |del_eq_word_define|} |
| 1029 |
begin set_equiv(p,w); set_equiv1(p,wone); set_xeq_level(p,level_one); |
| 1030 |
end; |
| 1031 |
@z |
| 1032 |
%--------------------------------------- |
| 1033 |
@x [19] m.282 l.6036 - Omega |
| 1034 |
else save_stack[save_ptr]:=eqtb[undefined_control_sequence]; |
| 1035 |
@y |
| 1036 |
else save_stack[save_ptr]:=new_eqtb(undefined_control_sequence); |
| 1037 |
@z |
| 1038 |
%--------------------------------------- |
| 1039 |
@x [19] m.283 l.6056 - Omega |
| 1040 |
else begin eq_destroy(eqtb[p]); {destroy the current value} |
| 1041 |
eqtb[p]:=save_stack[save_ptr]; {restore the saved value} |
| 1042 |
@!stat if tracing_restores>0 then restore_trace(p,"restoring");@+tats@;@/ |
| 1043 |
end |
| 1044 |
else if xeq_level[p]<>level_one then |
| 1045 |
begin eqtb[p]:=save_stack[save_ptr]; xeq_level[p]:=l; |
| 1046 |
@y |
| 1047 |
else begin eq_destroy(new_eqtb(p)); {destroy the current value} |
| 1048 |
set_new_eqtb(p,save_stack[save_ptr]); {restore the saved value} |
| 1049 |
@!stat if tracing_restores>0 then restore_trace(p,"restoring");@+tats@;@/ |
| 1050 |
end |
| 1051 |
else if xeq_level(p)<>level_one then |
| 1052 |
begin set_new_eqtb(p,save_stack[save_ptr]); set_xeq_level(p,l); |
| 1053 |
@z |
| 1054 |
%--------------------------------------- |
| 1055 |
@x [20] m.289 l.6129 - Omega |
| 1056 |
number $2^8m+c$; the command code is in the range |1<=m<=14|. (2)~A control |
| 1057 |
sequence whose |eqtb| address is |p| is represented as the number |
| 1058 |
|cs_token_flag+p|. Here |cs_token_flag=@t$2^{12}-1$@>| is larger than |
| 1059 |
@y |
| 1060 |
number $2^16m+c$; the command code is in the range |1<=m<=14|. (2)~A control |
| 1061 |
sequence whose |eqtb| address is |p| is represented as the number |
| 1062 |
|cs_token_flag+p|. Here |cs_token_flag=@t$2^{20}-1$@>| is larger than |
| 1063 |
@z |
| 1064 |
%--------------------------------------- |
| 1065 |
@x [20] m.289 l.6142 - Omega |
| 1066 |
@d cs_token_flag==@'7777 {amount added to the |eqtb| location in a |
| 1067 |
token that stands for a control sequence; is a multiple of~256, less~1} |
| 1068 |
@d left_brace_token=@'0400 {$2^8\cdot|left_brace|$} |
| 1069 |
@d left_brace_limit=@'1000 {$2^8\cdot(|left_brace|+1)$} |
| 1070 |
@d right_brace_token=@'1000 {$2^8\cdot|right_brace|$} |
| 1071 |
@d right_brace_limit=@'1400 {$2^8\cdot(|right_brace|+1)$} |
| 1072 |
@d math_shift_token=@'1400 {$2^8\cdot|math_shift|$} |
| 1073 |
@d tab_token=@'2000 {$2^8\cdot|tab_mark|$} |
| 1074 |
@d out_param_token=@'2400 {$2^8\cdot|out_param|$} |
| 1075 |
@d space_token=@'5040 {$2^8\cdot|spacer|+|" "|$} |
| 1076 |
@d letter_token=@'5400 {$2^8\cdot|letter|$} |
| 1077 |
@d other_token=@'6000 {$2^8\cdot|other_char|$} |
| 1078 |
@d match_token=@'6400 {$2^8\cdot|match|$} |
| 1079 |
@d end_match_token=@'7000 {$2^8\cdot|end_match|$} |
| 1080 |
@y |
| 1081 |
@d cs_token_flag=@"FFFFF {amount added to the |eqtb| location in a |
| 1082 |
token that stands for a control sequence; is a multiple of~65536, less~1} |
| 1083 |
@d max_char_val=@"10000 {to separate char and command code} |
| 1084 |
@d left_brace_token=@"10000 {$2^16\cdot|left_brace|$} |
| 1085 |
@d left_brace_limit=@"20000 {$2^16\cdot(|left_brace|+1)$} |
| 1086 |
@d right_brace_token=@"20000 {$2^16\cdot|right_brace|$} |
| 1087 |
@d right_brace_limit=@"30000 {$2^16\cdot(|right_brace|+1)$} |
| 1088 |
@d math_shift_token=@"30000 {$2^16\cdot|math_shift|$} |
| 1089 |
@d tab_token=@"40000 {$2^16\cdot|tab_mark|$} |
| 1090 |
@d out_param_token=@"50000 {$2^16\cdot|out_param|$} |
| 1091 |
@d space_token=@"A0020 {$2^16\cdot|spacer|+|" "|$} |
| 1092 |
@d letter_token=@"B0000 {$2^16\cdot|letter|$} |
| 1093 |
@d other_token=@"C0000 {$2^16\cdot|other_char|$} |
| 1094 |
@d match_token=@"D0000 {$2^16\cdot|match|$} |
| 1095 |
@d end_match_token=@"E0000 {$2^16\cdot|end_match|$} |
| 1096 |
@z |
| 1097 |
%--------------------------------------- |
| 1098 |
@x [20] m.293 l.6256 - Omega |
| 1099 |
else begin m:=info(p) div @'400; c:=info(p) mod @'400; |
| 1100 |
@y |
| 1101 |
else begin m:=info(p) div max_char_val; c:=info(p) mod max_char_val; |
| 1102 |
@z |
| 1103 |
%--------------------------------------- |
| 1104 |
@x [21] m.298 l.6375 - Omega |
| 1105 |
procedure print_cmd_chr(@!cmd:quarterword;@!chr_code:halfword); |
| 1106 |
@y |
| 1107 |
procedure print_cmd_chr(@!cmd:quarterword;@!chr_code:halfword); |
| 1108 |
@z |
| 1109 |
%--------------------------------------- |
| 1110 |
@x [24] m.334 l.7110 - Omega |
| 1111 |
primitive("par",par_end,256); {cf.\ |scan_file_name|} |
| 1112 |
@y |
| 1113 |
primitive("par",par_end,too_big_char); {cf. |scan_file_name|} |
| 1114 |
@z |
| 1115 |
%--------------------------------------- |
| 1116 |
@x [24] m.357 l.7462 - Omega |
| 1117 |
else begin cur_cmd:=t div @'400; cur_chr:=t mod @'400; |
| 1118 |
@y |
| 1119 |
else begin cur_cmd:=t div max_char_val; cur_chr:=t mod max_char_val; |
| 1120 |
@z |
| 1121 |
%--------------------------------------- |
| 1122 |
@x [24] m.358 l.7479 - Omega |
| 1123 |
@d no_expand_flag=257 {this characterizes a special variant of |relax|} |
| 1124 |
@y |
| 1125 |
@d no_expand_flag=special_char {this characterizes a special variant of |relax|} |
| 1126 |
@z |
| 1127 |
%--------------------------------------- |
| 1128 |
@x [24] m.365 l.7606 - Omega |
| 1129 |
if cur_cs=0 then cur_tok:=(cur_cmd*@'400)+cur_chr |
| 1130 |
@y |
| 1131 |
if cur_cs=0 then cur_tok:=(cur_cmd*max_char_val)+cur_chr |
| 1132 |
@z |
| 1133 |
%--------------------------------------- |
| 1134 |
@x [25] m.374 l.7728 - Omega |
| 1135 |
begin eq_define(cur_cs,relax,256); {N.B.: The |save_stack| might change} |
| 1136 |
@y |
| 1137 |
begin eq_define(cur_cs,relax,too_big_char); |
| 1138 |
{N.B.: The |save_stack| might change} |
| 1139 |
@z |
| 1140 |
%--------------------------------------- |
| 1141 |
@x [25] m.374 l.7750 - Omega |
| 1142 |
buffer[j]:=info(p) mod @'400; incr(j); p:=link(p); |
| 1143 |
@y |
| 1144 |
buffer[j]:=info(p) mod max_char_val; incr(j); p:=link(p); |
| 1145 |
@z |
| 1146 |
%--------------------------------------- |
| 1147 |
@x [25] m.380 l.7812 - Omega |
| 1148 |
done: if cur_cs=0 then cur_tok:=(cur_cmd*@'400)+cur_chr |
| 1149 |
@y |
| 1150 |
done: if cur_cs=0 then cur_tok:=(cur_cmd*max_char_val)+cur_chr |
| 1151 |
@z |
| 1152 |
%--------------------------------------- |
| 1153 |
@x [25] m.381 l.7824 - Omega |
| 1154 |
if cur_cs=0 then cur_tok:=(cur_cmd*@'400)+cur_chr |
| 1155 |
@y |
| 1156 |
if cur_cs=0 then cur_tok:=(cur_cmd*max_char_val)+cur_chr |
| 1157 |
@z |
| 1158 |
%--------------------------------------- |
| 1159 |
@x [25] m.391 l.7985 - Omega |
| 1160 |
if (info(r)>match_token+255)or(info(r)<match_token) then s:=null |
| 1161 |
@y |
| 1162 |
if (info(r)>=end_match_token)or(info(r)<match_token) then s:=null |
| 1163 |
@z |
| 1164 |
%--------------------------------------- |
| 1165 |
@x [26] m.407 l.8161 - Omega |
| 1166 |
@ The |scan_left_brace| routine is called when a left brace is supposed to be |
| 1167 |
the next non-blank token. (The term ``left brace'' means, more precisely, |
| 1168 |
a character whose catcode is |left_brace|.) \TeX\ allows \.{\\relax} to |
| 1169 |
appear before the |left_brace|. |
| 1170 |
|
| 1171 |
@p procedure scan_left_brace; {reads a mandatory |left_brace|} |
| 1172 |
begin @<Get the next non-blank non-relax non-call token@>; |
| 1173 |
if cur_cmd<>left_brace then |
| 1174 |
begin print_err("Missing { inserted"); |
| 1175 |
@.Missing \{ inserted@> |
| 1176 |
help4("A left brace was mandatory here, so I've put one in.")@/ |
| 1177 |
("You might want to delete and/or insert some corrections")@/ |
| 1178 |
("so that I will find a matching right brace soon.")@/ |
| 1179 |
("(If you're confused by all this, try typing `I}' now.)"); |
| 1180 |
back_error; cur_tok:=left_brace_token+"{"; cur_cmd:=left_brace; |
| 1181 |
cur_chr:="{"; incr(align_state); |
| 1182 |
end; |
| 1183 |
end; |
| 1184 |
@y |
| 1185 |
@ The |scan_left_brace| routine is called when a left brace is supposed to be |
| 1186 |
the next non-blank token. (The term ``left brace'' means, more precisely, |
| 1187 |
a character whose catcode is |left_brace|.) \TeX\ allows \.{\\relax} to |
| 1188 |
appear before the |left_brace|. |
| 1189 |
|
| 1190 |
@p procedure scan_left_brace; {reads a mandatory |left_brace|} |
| 1191 |
begin @<Get the next non-blank non-relax non-call token@>; |
| 1192 |
if cur_cmd<>left_brace then |
| 1193 |
begin print_err("Missing { inserted"); |
| 1194 |
@.Missing \{ inserted@> |
| 1195 |
help4("A left brace was mandatory here, so I've put one in.")@/ |
| 1196 |
("You might want to delete and/or insert some corrections")@/ |
| 1197 |
("so that I will find a matching right brace soon.")@/ |
| 1198 |
("(If you're confused by all this, try typing `I}' now.)"); |
| 1199 |
back_error; cur_tok:=left_brace_token+"{"; cur_cmd:=left_brace; |
| 1200 |
cur_chr:="{"; incr(align_state); |
| 1201 |
end; |
| 1202 |
end; |
| 1203 |
|
| 1204 |
@ The |scan_right_brace| routine is called when a right brace is supposed to be |
| 1205 |
the next non-blank token. (The term ``right brace'' means, more precisely, |
| 1206 |
a character whose catcode is |right_brace|.) \TeX\ allows \.{\\relax} to |
| 1207 |
appear before the |right_brace|. |
| 1208 |
|
| 1209 |
@p procedure scan_right_brace; {reads a mandatory |right_brace|} |
| 1210 |
begin @<Get the next non-blank non-relax non-call token@>; |
| 1211 |
if cur_cmd<>right_brace then |
| 1212 |
begin print_err("Missing { inserted"); |
| 1213 |
@.Missing \{ inserted@> |
| 1214 |
help4("A right brace was mandatory here, so I've put one in.")@/ |
| 1215 |
("You might want to delete and/or insert some corrections")@/ |
| 1216 |
("so that I will find a matching right brace soon.")@/ |
| 1217 |
("(If you're confused by all this, try typing `I}' now.)"); |
| 1218 |
back_error; cur_tok:=right_brace_token+"}"; cur_cmd:=right_brace; |
| 1219 |
cur_chr:="}"; incr(align_state); |
| 1220 |
end; |
| 1221 |
end; |
| 1222 |
@z |
| 1223 |
%--------------------------------------- |
| 1224 |
@x [26] m.410 l.8293 - Omega |
| 1225 |
@!cur_val:integer; {value returned by numeric scanners} |
| 1226 |
@y |
| 1227 |
@!cur_val:integer; {value returned by numeric scanners} |
| 1228 |
@z |
| 1229 |
%--------------------------------------- |
| 1230 |
@x [26] m.413 l.8335 - Omega |
| 1231 |
assign_int: scanned_result(eqtb[m].int)(int_val); |
| 1232 |
assign_dimen: scanned_result(eqtb[m].sc)(dimen_val); |
| 1233 |
@y |
| 1234 |
assign_int: scanned_result(new_eqtb_int(m))(int_val); |
| 1235 |
assign_dimen: scanned_result(new_eqtb_sc(m))(dimen_val); |
| 1236 |
@z |
| 1237 |
%--------------------------------------- |
| 1238 |
@x [26] m.413 l.8345 - Omega |
| 1239 |
char_given,math_given: scanned_result(cur_chr)(int_val); |
| 1240 |
@y |
| 1241 |
char_given,math_given,omath_given: scanned_result(cur_chr)(int_val); |
| 1242 |
@z |
| 1243 |
%--------------------------------------- |
| 1244 |
@x [26] m.414 l.8356 - Omega |
| 1245 |
@ @<Fetch a character code from some table@>= |
| 1246 |
begin scan_char_num; |
| 1247 |
if m=math_code_base then scanned_result(ho(math_code(cur_val)))(int_val) |
| 1248 |
else if m<math_code_base then scanned_result(equiv(m+cur_val))(int_val) |
| 1249 |
else scanned_result(eqtb[m+cur_val].int)(int_val); |
| 1250 |
@y |
| 1251 |
@ @<Fetch a character code from some table@>= |
| 1252 |
begin scan_char_num; |
| 1253 |
if m=math_code_base then begin |
| 1254 |
cur_val1:=ho(math_code(cur_val)); |
| 1255 |
if ((cur_val1 div @"1000000)>8) or |
| 1256 |
(((cur_val1 mod @"1000000) div @"10000)>15) or |
| 1257 |
((cur_val1 mod @"10000)>255) then |
| 1258 |
begin print_err("Extended mathchar used as mathchar"); |
| 1259 |
@.Bad mathchar@> |
| 1260 |
help2("A mathchar number must be between 0 and ""7FFF.")@/ |
| 1261 |
("I changed this one to zero."); int_error(cur_val1); cur_val1:=0; |
| 1262 |
end; |
| 1263 |
cur_val1:=((cur_val1 div @"1000000)*@"1000) + |
| 1264 |
(((cur_val1 mod @"1000000) div @"10000)*@"100) + |
| 1265 |
(cur_val1 mod @"10000); |
| 1266 |
scanned_result(cur_val1)(int_val) |
| 1267 |
end |
| 1268 |
else if m=(math_code_base+256) then |
| 1269 |
scanned_result(ho(math_code(cur_val)))(int_val) |
| 1270 |
else if m=del_code_base then begin |
| 1271 |
cur_val1:=del_code1(cur_val); cur_val:=del_code0(cur_val); |
| 1272 |
cur_val1:=(cur_val1 div @"10000)*@"100 + (cur_val1 mod @"10000); |
| 1273 |
cur_val:=(cur_val div @"10000)*@"100 + (cur_val mod @"10000); |
| 1274 |
if ((cur_val div @"100) mod @"100 > 15) or (cur_val1>=@"1000) then |
| 1275 |
begin print_err("Extended delimiter code used as delcode"); |
| 1276 |
@.Bad delimiter code@> |
| 1277 |
help2("A numeric delimiter code must be between 0 and 2^{27}-1.")@/ |
| 1278 |
("I changed this one to zero."); error; |
| 1279 |
scanned_result(0)(int_val); |
| 1280 |
end |
| 1281 |
else scanned_result(cur_val*@"1000+cur_val1)(int_val); |
| 1282 |
end |
| 1283 |
else if m=(del_code_base+256) then begin |
| 1284 |
scanned_result(-1)(int_val); |
| 1285 |
end |
| 1286 |
else if m<math_code_base then scanned_result(equiv(m+cur_val))(int_val) |
| 1287 |
else scanned_result(new_eqtb_int(m+cur_val))(int_val); |
| 1288 |
@z |
| 1289 |
%--------------------------------------- |
| 1290 |
@x [26] m.433 l.8593 - Omega |
| 1291 |
procedure scan_eight_bit_int; |
| 1292 |
begin scan_int; |
| 1293 |
if (cur_val<0)or(cur_val>255) then |
| 1294 |
begin print_err("Bad register code"); |
| 1295 |
@.Bad register code@> |
| 1296 |
help2("A register number must be between 0 and 255.")@/ |
| 1297 |
@y |
| 1298 |
procedure scan_eight_bit_int; |
| 1299 |
begin scan_int; |
| 1300 |
if (cur_val<0)or(cur_val>biggest_reg) then |
| 1301 |
begin print_err("Bad register code"); |
| 1302 |
@.Bad register code@> |
| 1303 |
help2("A register number must be between 0 and 65535.")@/ |
| 1304 |
@z |
| 1305 |
%--------------------------------------- |
| 1306 |
@x [26] m.434 l.8604 - Omega |
| 1307 |
procedure scan_char_num; |
| 1308 |
begin scan_int; |
| 1309 |
if (cur_val<0)or(cur_val>255) then |
| 1310 |
begin print_err("Bad character code"); |
| 1311 |
@.Bad character code@> |
| 1312 |
help2("A character number must be between 0 and 255.")@/ |
| 1313 |
@y |
| 1314 |
procedure scan_char_num; |
| 1315 |
begin scan_int; |
| 1316 |
if (cur_val<0)or(cur_val>biggest_char) then |
| 1317 |
begin print_err("Bad character code"); |
| 1318 |
@.Bad character code@> |
| 1319 |
help2("A character number must be between 0 and 65535.")@/ |
| 1320 |
@z |
| 1321 |
%--------------------------------------- |
| 1322 |
@x [26] m.435 l.8618 - Omega |
| 1323 |
procedure scan_four_bit_int; |
| 1324 |
begin scan_int; |
| 1325 |
if (cur_val<0)or(cur_val>15) then |
| 1326 |
begin print_err("Bad number"); |
| 1327 |
@.Bad number@> |
| 1328 |
help2("Since I expected to read a number between 0 and 15,")@/ |
| 1329 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1330 |
end; |
| 1331 |
end; |
| 1332 |
@y |
| 1333 |
procedure scan_four_bit_int; |
| 1334 |
begin scan_int; |
| 1335 |
if (cur_val<0)or(cur_val>15) then |
| 1336 |
begin print_err("Bad number"); |
| 1337 |
@.Bad number@> |
| 1338 |
help2("Since I expected to read a number between 0 and 15,")@/ |
| 1339 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1340 |
end; |
| 1341 |
end; |
| 1342 |
|
| 1343 |
procedure scan_big_four_bit_int; |
| 1344 |
begin scan_int; |
| 1345 |
if (cur_val<0)or(cur_val>255) then |
| 1346 |
begin print_err("Bad number"); |
| 1347 |
@.Bad number@> |
| 1348 |
help2("Since I expected to read a number between 0 and 255,")@/ |
| 1349 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1350 |
end; |
| 1351 |
end; |
| 1352 |
@z |
| 1353 |
%--------------------------------------- |
| 1354 |
@x [26] m.436 l.8629 - Omega |
| 1355 |
procedure scan_fifteen_bit_int; |
| 1356 |
begin scan_int; |
| 1357 |
if (cur_val<0)or(cur_val>@'77777) then |
| 1358 |
begin print_err("Bad mathchar"); |
| 1359 |
@.Bad mathchar@> |
| 1360 |
help2("A mathchar number must be between 0 and 32767.")@/ |
| 1361 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1362 |
end; |
| 1363 |
end; |
| 1364 |
@y |
| 1365 |
procedure scan_real_fifteen_bit_int; |
| 1366 |
begin scan_int; |
| 1367 |
if (cur_val<0)or(cur_val>@'77777) then |
| 1368 |
begin print_err("Bad mathchar"); |
| 1369 |
@.Bad mathchar@> |
| 1370 |
help2("A mathchar number must be between 0 and 32767.")@/ |
| 1371 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1372 |
end; |
| 1373 |
end; |
| 1374 |
|
| 1375 |
procedure scan_fifteen_bit_int; |
| 1376 |
begin scan_int; |
| 1377 |
if (cur_val<0)or(cur_val>@'77777) then |
| 1378 |
begin print_err("Bad mathchar"); |
| 1379 |
@.Bad mathchar@> |
| 1380 |
help2("A mathchar number must be between 0 and 32767.")@/ |
| 1381 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1382 |
end; |
| 1383 |
cur_val := ((cur_val div @"1000) * @"1000000) + |
| 1384 |
(((cur_val mod @"1000) div @"100) * @"10000) + |
| 1385 |
(cur_val mod @"100); |
| 1386 |
end; |
| 1387 |
|
| 1388 |
procedure scan_big_fifteen_bit_int; |
| 1389 |
begin scan_int; |
| 1390 |
if (cur_val<0)or(cur_val>@"7FFFFFF) then |
| 1391 |
begin print_err("Bad extended mathchar"); |
| 1392 |
@.Bad mathchar@> |
| 1393 |
help2("An extended mathchar number must be between 0 and ""7FFFFFF.")@/ |
| 1394 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1395 |
end; |
| 1396 |
end; |
| 1397 |
@z |
| 1398 |
%--------------------------------------- |
| 1399 |
@x [26] m.437 l.8640 - Omega |
| 1400 |
procedure scan_twenty_seven_bit_int; |
| 1401 |
begin scan_int; |
| 1402 |
if (cur_val<0)or(cur_val>@'777777777) then |
| 1403 |
begin print_err("Bad delimiter code"); |
| 1404 |
@.Bad delimiter code@> |
| 1405 |
help2("A numeric delimiter code must be between 0 and 2^{27}-1.")@/ |
| 1406 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1407 |
end; |
| 1408 |
end; |
| 1409 |
@y |
| 1410 |
procedure scan_twenty_seven_bit_int; |
| 1411 |
begin scan_int; |
| 1412 |
if (cur_val<0)or(cur_val>@'777777777) then |
| 1413 |
begin print_err("Bad delimiter code"); |
| 1414 |
@.Bad delimiter code@> |
| 1415 |
help2("A numeric delimiter code must be between 0 and 2^{27}-1.")@/ |
| 1416 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1417 |
end; |
| 1418 |
cur_val1 := (((cur_val mod @"1000) div @"100) * @"10000) + |
| 1419 |
(cur_val mod @"100); |
| 1420 |
cur_val := cur_val div @"1000; |
| 1421 |
cur_val := ((cur_val div @"1000) * @"1000000) + |
| 1422 |
(((cur_val mod @"1000) div @"100) * @"10000) + |
| 1423 |
(cur_val mod @"100); |
| 1424 |
end; |
| 1425 |
|
| 1426 |
procedure scan_fifty_one_bit_int; |
| 1427 |
var iiii:integer; |
| 1428 |
begin scan_int; |
| 1429 |
if (cur_val<0)or(cur_val>@'777777777) then |
| 1430 |
begin print_err("Bad delimiter code"); |
| 1431 |
@.Bad delimiter code@> |
| 1432 |
help2("A numeric delimiter (first part) must be between 0 and 2^{27}-1.") |
| 1433 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1434 |
end; |
| 1435 |
iiii:=cur_val; |
| 1436 |
scan_int; |
| 1437 |
if (cur_val<0)or(cur_val>@"FFFFFF) then |
| 1438 |
begin print_err("Bad delimiter code"); |
| 1439 |
@.Bad delimiter code@> |
| 1440 |
help2("A numeric delimiter (second part) must be between 0 and 2^{24}-1.")@/ |
| 1441 |
("I changed this one to zero."); int_error(cur_val); cur_val:=0; |
| 1442 |
end; |
| 1443 |
cur_val1:=cur_val; |
| 1444 |
cur_val:=iiii; |
| 1445 |
end; |
| 1446 |
|
| 1447 |
procedure scan_string_argument; |
| 1448 |
var s:integer; |
| 1449 |
begin |
| 1450 |
scan_left_brace; |
| 1451 |
get_x_token; |
| 1452 |
while (cur_cmd<>right_brace) do |
| 1453 |
begin |
| 1454 |
if (cur_cmd=letter) or (cur_cmd=other_char) then begin |
| 1455 |
str_room(1); append_char(cur_chr); |
| 1456 |
end |
| 1457 |
else if (cur_cmd=spacer) then begin |
| 1458 |
str_room(1); append_char(" "); |
| 1459 |
end |
| 1460 |
else begin |
| 1461 |
print("Bad token appearing in string argument"); |
| 1462 |
end; |
| 1463 |
get_x_token; |
| 1464 |
end; |
| 1465 |
s:=make_string; |
| 1466 |
if str_eq_str("mi",s) then s:="mi"; |
| 1467 |
if str_eq_str("mo",s) then s:="mo"; |
| 1468 |
if str_eq_str("mn",s) then s:="mn"; |
| 1469 |
cur_val:=s; |
| 1470 |
end; |
| 1471 |
@z |
| 1472 |
%--------------------------------------- |
| 1473 |
@x [26] m.442 l.8720 - Omega |
| 1474 |
if cur_val>255 then |
| 1475 |
begin print_err("Improper alphabetic constant"); |
| 1476 |
@y |
| 1477 |
if cur_val>biggest_char then |
| 1478 |
begin print_err("Improper alphabetic constant"); |
| 1479 |
@z |
| 1480 |
%--------------------------------------- |
| 1481 |
@x [27] m.468 l.9200 - Omega |
| 1482 |
@d job_name_code=5 {command code for \.{\\jobname}} |
| 1483 |
@y |
| 1484 |
@d omega_code=5 {command code for \.{\\OmegaVersion}} |
| 1485 |
@d job_name_code=6 {command code for \.{\\jobname}} |
| 1486 |
@z |
| 1487 |
%--------------------------------------- |
| 1488 |
@x [27] m.468 l.9200 - Omega |
| 1489 |
primitive("jobname",convert,job_name_code);@/ |
| 1490 |
@!@:job_name_}{\.{\\jobname} primitive@> |
| 1491 |
@y |
| 1492 |
primitive("OmegaVersion",convert,omega_code);@/ |
| 1493 |
@!@:omega_version_}{\.{\\OmegaVersion} primitive@> |
| 1494 |
primitive("jobname",convert,job_name_code);@/ |
| 1495 |
@!@:job_name_}{\.{\\jobname} primitive@> |
| 1496 |
@z |
| 1497 |
%--------------------------------------- |
| 1498 |
@x [27] m.469 l.9223 - Omega |
| 1499 |
othercases print_esc("jobname") |
| 1500 |
@y |
| 1501 |
omega_code: print_esc("OmegaVersion"); |
| 1502 |
othercases print_esc("jobname") |
| 1503 |
@z |
| 1504 |
%--------------------------------------- |
| 1505 |
@x [27] m.471 l.9248 - Omega |
| 1506 |
job_name_code: if job_name=0 then open_log_file; |
| 1507 |
@y |
| 1508 |
omega_code:; |
| 1509 |
job_name_code: if job_name=0 then open_log_file; |
| 1510 |
@z |
| 1511 |
%--------------------------------------- |
| 1512 |
@x [27] m.472 l.9258 - Omega |
| 1513 |
job_name_code: print(job_name); |
| 1514 |
@y |
| 1515 |
omega_code: print("1.15"); |
| 1516 |
job_name_code: print(job_name); |
| 1517 |
@z |
| 1518 |
%--------------------------------------- |
| 1519 |
@x [28] m.491 l.9610 - Omega |
| 1520 |
text(frozen_fi):="fi"; eqtb[frozen_fi]:=eqtb[cur_val]; |
| 1521 |
@y |
| 1522 |
settext(frozen_fi,"fi"); set_new_eqtb(frozen_fi,new_eqtb(cur_val)); |
| 1523 |
@z |
| 1524 |
%--------------------------------------- |
| 1525 |
@x [28] m.506 l.9802 - Omega |
| 1526 |
if (cur_cmd>active_char)or(cur_chr>255) then {not a character} |
| 1527 |
begin m:=relax; n:=256; |
| 1528 |
@y |
| 1529 |
if (cur_cmd>active_char)or(cur_chr>biggest_char) then {not a character} |
| 1530 |
begin m:=relax; n:=too_big_char; |
| 1531 |
@z |
| 1532 |
%--------------------------------------- |
| 1533 |
@x [28] m.506 l.9808 - Omega |
| 1534 |
if (cur_cmd>active_char)or(cur_chr>255) then |
| 1535 |
begin cur_cmd:=relax; cur_chr:=256; |
| 1536 |
@y |
| 1537 |
if (cur_cmd>active_char)or(cur_chr>biggest_char) then |
| 1538 |
begin cur_cmd:=relax; cur_chr:=too_big_char; |
| 1539 |
@z |
| 1540 |
%--------------------------------------- |
| 1541 |
@x [29] m.526 l.10178 - Omega |
| 1542 |
loop@+begin if (cur_cmd>other_char)or(cur_chr>255) then {not a character} |
| 1543 |
@y |
| 1544 |
loop@+begin if (cur_cmd>other_char)or(cur_chr>biggest_char) then |
| 1545 |
{not a character} |
| 1546 |
@z |
| 1547 |
%--------------------------------------- |
| 1548 |
@x [37] m.780 l.15354 - Omega |
| 1549 |
@d span_code=256 {distinct from any character} |
| 1550 |
@d cr_code=257 {distinct from |span_code| and from any character} |
| 1551 |
@y |
| 1552 |
@d span_code=special_char {distinct from any character} |
| 1553 |
@d cr_code=span_code+1 {distinct from |span_code| and from any character} |
| 1554 |
@z |
| 1555 |
%--------------------------------------- |
| 1556 |
@x [37] m.780 l.15364 - Omega |
| 1557 |
text(frozen_cr):="cr"; eqtb[frozen_cr]:=eqtb[cur_val];@/ |
| 1558 |
primitive("crcr",car_ret,cr_cr_code); |
| 1559 |
@!@:cr_cr_}{\.{\\crcr} primitive@> |
| 1560 |
text(frozen_end_template):="endtemplate"; text(frozen_endv):="endtemplate"; |
| 1561 |
@.endtemplate@> |
| 1562 |
eq_type(frozen_endv):=endv; equiv(frozen_endv):=null_list; |
| 1563 |
eq_level(frozen_endv):=level_one;@/ |
| 1564 |
eqtb[frozen_end_template]:=eqtb[frozen_endv]; |
| 1565 |
eq_type(frozen_end_template):=end_template; |
| 1566 |
@y |
| 1567 |
settext(frozen_cr,"cr"); |
| 1568 |
set_new_eqtb(frozen_cr,new_eqtb(cur_val));@/ |
| 1569 |
primitive("crcr",car_ret,cr_cr_code); |
| 1570 |
@!@:cr_cr_}{\.{\\crcr} primitive@> |
| 1571 |
settext(frozen_end_template,"endtemplate"); settext(frozen_endv,"endtemplate"); |
| 1572 |
set_eq_type(frozen_endv,endv); set_equiv(frozen_endv,null_list); |
| 1573 |
set_eq_level(frozen_endv,level_one);@/ |
| 1574 |
set_new_eqtb(frozen_end_template,new_eqtb(frozen_endv)); |
| 1575 |
set_eq_type(frozen_end_template,end_template); |
| 1576 |
@z |
| 1577 |
%--------------------------------------- |
| 1578 |
@x [37] m.798 l.15651 - Omega |
| 1579 |
if n>max_quarterword then confusion("256 spans"); {this can happen, but won't} |
| 1580 |
@^system dependencies@> |
| 1581 |
@:this can't happen 256 spans}{\quad 256 spans@> |
| 1582 |
@y |
| 1583 |
if n>max_quarterword then confusion("too many spans"); |
| 1584 |
{this can happen, but won't} |
| 1585 |
@^system dependencies@> |
| 1586 |
@:this can't happen too many spans}{\quad too many spans@> |
| 1587 |
@z |
| 1588 |
%--------------------------------------- |
| 1589 |
@x [37] m.804 l.15794 - Omega |
| 1590 |
overfull_rule:=0; {prevent rule from being packaged} |
| 1591 |
p:=hpack(preamble,saved(1),saved(0)); overfull_rule:=rule_save; |
| 1592 |
@y |
| 1593 |
set_new_eqtb_sc(dimen_base+overfull_rule_code,0); |
| 1594 |
{prevent rule from being packaged} |
| 1595 |
p:=hpack(preamble,saved(1),saved(0)); |
| 1596 |
set_new_eqtb_sc(dimen_base+overfull_rule_code,rule_save); |
| 1597 |
@z |
| 1598 |
%--------------------------------------- |
| 1599 |
@x [37] m.827 l.16255 - Omega |
| 1600 |
check_shrinkage(left_skip); check_shrinkage(right_skip);@/ |
| 1601 |
@y |
| 1602 |
if (shrink_order(left_skip)<>normal)and(shrink(left_skip)<>0) then |
| 1603 |
begin set_equiv(glue_base+left_skip_code,finite_shrink(left_skip)); |
| 1604 |
end; |
| 1605 |
if (shrink_order(right_skip)<>normal)and(shrink(right_skip)<>0) then |
| 1606 |
begin set_equiv(glue_base+right_skip_code,finite_shrink(right_skip)); |
| 1607 |
end; |
| 1608 |
@z |
| 1609 |
%--------------------------------------- |
| 1610 |
@x [40] m.891 l.17434 - Omega |
| 1611 |
$c_1$ will be treated as nonletters. The |hyphen_char| for that font |
| 1612 |
must be between 0 and 255, otherwise hyphenation will not be attempted. |
| 1613 |
@y |
| 1614 |
$c_1$ will be treated as nonletters. The |hyphen_char| for that font must |
| 1615 |
be between 0 and |biggest_char|, otherwise hyphenation will not be attempted. |
| 1616 |
@z |
| 1617 |
%--------------------------------------- |
| 1618 |
@x [40] m.892 l.17469 - Omega |
| 1619 |
@!hc:array[0..65] of 0..256; {word to be hyphenated} |
| 1620 |
@!hn:0..64; {the number of positions occupied in |hc|; |
| 1621 |
not always a |small_number|} |
| 1622 |
@!ha,@!hb:pointer; {nodes |ha..hb| should be replaced by the hyphenated result} |
| 1623 |
@!hf:internal_font_number; {font number of the letters in |hc|} |
| 1624 |
@!hu:array[0..63] of 0..256; {like |hc|, before conversion to lowercase} |
| 1625 |
@!hyf_char:integer; {hyphen character of the relevant font} |
| 1626 |
@!cur_lang,@!init_cur_lang:ASCII_code; {current hyphenation table of interest} |
| 1627 |
@!l_hyf,@!r_hyf,@!init_l_hyf,@!init_r_hyf:integer; {limits on fragment sizes} |
| 1628 |
@!hyf_bchar:halfword; {boundary character after $c_n$} |
| 1629 |
@y |
| 1630 |
@!hc:array[0..65] of 0..too_big_char; {word to be hyphenated} |
| 1631 |
@!hn:0..64; {the number of positions occupied in |hc|; |
| 1632 |
not always a |small_number|} |
| 1633 |
@!ha,@!hb:pointer; {nodes |ha..hb| should be replaced by the hyphenated result} |
| 1634 |
@!hf:internal_font_number; {font number of the letters in |hc|} |
| 1635 |
@!hu:array[0..63] of 0..too_big_char; |
| 1636 |
{like |hc|, before conversion to lowercase} |
| 1637 |
@!hyf_char:integer; {hyphen character of the relevant font} |
| 1638 |
@!cur_lang,@!init_cur_lang:0..biggest_lang; |
| 1639 |
{current hyphenation table of interest} |
| 1640 |
@!l_hyf,@!r_hyf,@!init_l_hyf,@!init_r_hyf:integer; {limits on fragment sizes} |
| 1641 |
@!hyf_bchar:halfword; {boundary character after $c_n$} |
| 1642 |
@!max_hyph_char:integer; |
| 1643 |
|
| 1644 |
@ @<Set initial values of key variables@>= |
| 1645 |
max_hyph_char:=too_big_lang; |
| 1646 |
|
| 1647 |
@z |
| 1648 |
%--------------------------------------- |
| 1649 |
@x [40] m.893 l.17483 - Omega |
| 1650 |
@!c:0..255; {character being considered for hyphenation} |
| 1651 |
@y |
| 1652 |
@!c:ASCII_code; {character being considered for hyphenation} |
| 1653 |
@z |
| 1654 |
%--------------------------------------- |
| 1655 |
@x [40] m.896 l.17534 - Omega |
| 1656 |
if hyf_char>255 then goto done1; |
| 1657 |
@y |
| 1658 |
if hyf_char>biggest_char then goto done1; |
| 1659 |
@z |
| 1660 |
%--------------------------------------- |
| 1661 |
@x [40] m.897 l.17546 - Omega |
| 1662 |
if lc_code(c)=0 then goto done3; |
| 1663 |
@y |
| 1664 |
if lc_code(c)=0 then goto done3; |
| 1665 |
if lc_code(c)>max_hyph_char then goto done3; |
| 1666 |
@z |
| 1667 |
%--------------------------------------- |
| 1668 |
@x [40] m.898 l.17572 - Omega |
| 1669 |
if lc_code(c)=0 then goto done3; |
| 1670 |
@y |
| 1671 |
if lc_code(c)=0 then goto done3; |
| 1672 |
if lc_code(c)>max_hyph_char then goto done3; |
| 1673 |
@z |
| 1674 |
%--------------------------------------- |
| 1675 |
@x [41] m.903 l.17648 - Omega |
| 1676 |
begin hu[0]:=256; init_lig:=false; |
| 1677 |
@y |
| 1678 |
begin hu[0]:=max_hyph_char; init_lig:=false; |
| 1679 |
@z |
| 1680 |
%--------------------------------------- |
| 1681 |
@x [41] m.903 l.17660 - Omega |
| 1682 |
found2: s:=ha; j:=0; hu[0]:=256; init_lig:=false; init_list:=null; |
| 1683 |
@y |
| 1684 |
found2: s:=ha; j:=0; hu[0]:=max_hyph_char; init_lig:=false; init_list:=null; |
| 1685 |
@z |
| 1686 |
%--------------------------------------- |
| 1687 |
@x [41] m.905 l.17707 - Omega |
| 1688 |
getting the input $x_j\ldots x_n$ from the |hu| array. If $x_j=256$, |
| 1689 |
we consider $x_j$ to be an implicit left boundary character; in this |
| 1690 |
case |j| must be strictly less than~|n|. There is a |
| 1691 |
parameter |bchar|, which is either 256 or an implicit right boundary character |
| 1692 |
@y |
| 1693 |
getting the input $x_j\ldots x_n$ from the |hu| array. If $x_j=|max_hyph_char|$, |
| 1694 |
we consider $x_j$ to be an implicit left boundary character; in this |
| 1695 |
case |j| must be strictly less than~|n|. There is a |
| 1696 |
parameter |bchar|, which is either |max_hyph_char| |
| 1697 |
or an implicit right boundary character |
| 1698 |
@z |
| 1699 |
%--------------------------------------- |
| 1700 |
@x [41] m.916 l.17980 - Omega |
| 1701 |
begin decr(l); c:=hu[l]; c_loc:=l; hu[l]:=256; |
| 1702 |
@y |
| 1703 |
begin decr(l); c:=hu[l]; c_loc:=l; hu[l]:=max_hyph_char; |
| 1704 |
@z |
| 1705 |
%--------------------------------------- |
| 1706 |
@x [42] m.921 l.18079 - Omega |
| 1707 |
@!op_start:array[ASCII_code] of 0..trie_op_size; {offset for current language} |
| 1708 |
@y |
| 1709 |
@!op_start:array[0..biggest_lang] of 0..trie_op_size; |
| 1710 |
{offset for current language} |
| 1711 |
@z |
| 1712 |
%--------------------------------------- |
| 1713 |
@x [42] m.923 l.18086 - Omega |
| 1714 |
hyphenation algorithm is quite short. In the following code we set |hc[hn+2]| |
| 1715 |
to the impossible value 256, in order to guarantee that |hc[hn+3]| will |
| 1716 |
@y |
| 1717 |
hyphenation algorithm is quite short. In the following code we set |hc[hn+2]| to |
| 1718 |
the impossible value |max_hyph_char|, in order to guarantee that |hc[hn+3]| will |
| 1719 |
@z |
| 1720 |
%--------------------------------------- |
| 1721 |
@x [42] m.923 l.18095 - Omega |
| 1722 |
hc[0]:=0; hc[hn+1]:=0; hc[hn+2]:=256; {insert delimiters} |
| 1723 |
@y |
| 1724 |
hc[0]:=0; hc[hn+1]:=0; hc[hn+2]:=max_hyph_char; {insert delimiters} |
| 1725 |
@z |
| 1726 |
%--------------------------------------- |
| 1727 |
@x [42] m.934 l.18206 - Omega |
| 1728 |
@d set_cur_lang==if language<=0 then cur_lang:=0 |
| 1729 |
else if language>255 then cur_lang:=0 |
| 1730 |
@y |
| 1731 |
@d set_cur_lang==if language<=0 then cur_lang:=0 |
| 1732 |
else if language>biggest_lang then cur_lang:=0 |
| 1733 |
@z |
| 1734 |
%--------------------------------------- |
| 1735 |
@x [43] m.943 l.18348 - Omega |
| 1736 |
@!trie_used:array[ASCII_code] of quarterword; |
| 1737 |
{largest opcode used so far for this language} |
| 1738 |
@!trie_op_lang:array[1..trie_op_size] of ASCII_code; |
| 1739 |
@y |
| 1740 |
@!trie_used:array[0..biggest_lang] of quarterword; |
| 1741 |
{largest opcode used so far for this language} |
| 1742 |
@!trie_op_lang:array[1..trie_op_size] of 0..biggest_lang; |
| 1743 |
@z |
| 1744 |
%--------------------------------------- |
| 1745 |
@x [43] m.945 l.18400 - Omega |
| 1746 |
for j:=1 to 255 do op_start[j]:=op_start[j-1]+qo(trie_used[j-1]); |
| 1747 |
@y |
| 1748 |
for j:=1 to biggest_lang do op_start[j]:=op_start[j-1]+qo(trie_used[j-1]); |
| 1749 |
@z |
| 1750 |
%--------------------------------------- |
| 1751 |
@x [43] m.946 l.18416 - Omega |
| 1752 |
for k:=0 to 255 do trie_used[k]:=min_quarterword; |
| 1753 |
@y |
| 1754 |
for k:=0 to biggest_lang do trie_used[k]:=min_quarterword; |
| 1755 |
@z |
| 1756 |
%--------------------------------------- |
| 1757 |
@x [43] m.947 l.18438 - Omega |
| 1758 |
@!init @!trie_c:packed array[trie_pointer] of packed_ASCII_code; |
| 1759 |
@y |
| 1760 |
@!init @!trie_c:packed array[trie_pointer] of ASCII_code; |
| 1761 |
@z |
| 1762 |
%--------------------------------------- |
| 1763 |
@x [43] m.952 l.18551 - Omega |
| 1764 |
for p:=0 to 255 do trie_min[p]:=p+1; |
| 1765 |
@y |
| 1766 |
for p:=0 to biggest_char do trie_min[p]:=p+1; |
| 1767 |
@z |
| 1768 |
%--------------------------------------- |
| 1769 |
@x [43] m.953 l.18569 - Omega |
| 1770 |
@!ll:1..256; {upper limit of |trie_min| updating} |
| 1771 |
@y |
| 1772 |
@!ll:1..too_big_char; {upper limit of |trie_min| updating} |
| 1773 |
@z |
| 1774 |
%--------------------------------------- |
| 1775 |
@x [43] m.953 l.18573 - Omega |
| 1776 |
@<Ensure that |trie_max>=h+256|@>; |
| 1777 |
@y |
| 1778 |
@<Ensure that |trie_max>=h+max_hyph_char|@>; |
| 1779 |
@z |
| 1780 |
%--------------------------------------- |
| 1781 |
@x [43] m.954 l.18582 - Omega |
| 1782 |
@ By making sure that |trie_max| is at least |h+256|, we can be sure that |
| 1783 |
|trie_max>z|, since |h=z-c|. It follows that location |trie_max| will |
| 1784 |
never be occupied in |trie|, and we will have |trie_max>=trie_link(z)|. |
| 1785 |
|
| 1786 |
@<Ensure that |trie_max>=h+256|@>= |
| 1787 |
if trie_max<h+256 then |
| 1788 |
begin if trie_size<=h+256 then overflow("pattern memory",trie_size); |
| 1789 |
@y |
| 1790 |
@ By making sure that |trie_max| is at least |h+max_hyph_char|, |
| 1791 |
we can be sure that |
| 1792 |
|trie_max>z|, since |h=z-c|. It follows that location |trie_max| will |
| 1793 |
never be occupied in |trie|, and we will have |trie_max>=trie_link(z)|. |
| 1794 |
|
| 1795 |
@<Ensure that |trie_max>=h+max_hyph_char|@>= |
| 1796 |
if trie_max<h+max_hyph_char then |
| 1797 |
begin if trie_size<=h+max_hyph_char then overflow("pattern memory",trie_size); |
| 1798 |
@z |
| 1799 |
%--------------------------------------- |
| 1800 |
@x [43] m.954 l.18592 - Omega |
| 1801 |
until trie_max=h+256; |
| 1802 |
@y |
| 1803 |
until trie_max=h+max_hyph_char; |
| 1804 |
@z |
| 1805 |
%--------------------------------------- |
| 1806 |
@x [43] m.956 l.18607 - Omega |
| 1807 |
if l<256 then |
| 1808 |
begin if z<256 then ll:=z @+else ll:=256; |
| 1809 |
@y |
| 1810 |
if l<max_hyph_char then |
| 1811 |
begin if z<max_hyph_char then ll:=z @+else ll:=max_hyph_char; |
| 1812 |
@z |
| 1813 |
%--------------------------------------- |
| 1814 |
@x [43] m.958 l.18637 - Omega |
| 1815 |
if trie_root=0 then {no patterns were given} |
| 1816 |
begin for r:=0 to 256 do trie[r]:=h; |
| 1817 |
trie_max:=256; |
| 1818 |
@y |
| 1819 |
if trie_root=0 then {no patterns were given} |
| 1820 |
begin for r:=0 to max_hyph_char do trie[r]:=h; |
| 1821 |
trie_max:=max_hyph_char; |
| 1822 |
@z |
| 1823 |
%--------------------------------------- |
| 1824 |
@x [43] m.962 l.18714 - Omega |
| 1825 |
@ @<Append a new letter or a hyphen level@>= |
| 1826 |
if digit_sensed or(cur_chr<"0")or(cur_chr>"9") then |
| 1827 |
begin if cur_chr="." then cur_chr:=0 {edge-of-word delimiter} |
| 1828 |
else begin cur_chr:=lc_code(cur_chr); |
| 1829 |
if cur_chr=0 then |
| 1830 |
begin print_err("Nonletter"); |
| 1831 |
@.Nonletter@> |
| 1832 |
help1("(See Appendix H.)"); error; |
| 1833 |
end; |
| 1834 |
end; |
| 1835 |
@y |
| 1836 |
@ @<Append a new letter or a hyphen level@>= |
| 1837 |
if digit_sensed or(cur_chr<"0")or(cur_chr>"9") then |
| 1838 |
begin if cur_chr="." then cur_chr:=0 {edge-of-word delimiter} |
| 1839 |
else begin cur_chr:=lc_code(cur_chr); |
| 1840 |
if cur_chr=0 then |
| 1841 |
begin print_err("Nonletter"); |
| 1842 |
@.Nonletter@> |
| 1843 |
help1("(See Appendix H.)"); error; |
| 1844 |
end; |
| 1845 |
end; |
| 1846 |
if cur_chr>max_hyph_char then max_hyph_char:=cur_chr; |
| 1847 |
@z |
| 1848 |
%--------------------------------------- |
| 1849 |
@x [43] m.966 l. - Omega |
| 1850 |
procedure init_trie; |
| 1851 |
var @!p:trie_pointer; {pointer for initialization} |
| 1852 |
@!j,@!k,@!t:integer; {all-purpose registers for initialization} |
| 1853 |
@!r,@!s:trie_pointer; {used to clean up the packed |trie|} |
| 1854 |
@!h:two_halves; {template used to zero out |trie|'s holes} |
| 1855 |
begin @<Get ready to compress the trie@>; |
| 1856 |
@y |
| 1857 |
procedure init_trie; |
| 1858 |
var @!p:trie_pointer; {pointer for initialization} |
| 1859 |
@!j,@!k,@!t:integer; {all-purpose registers for initialization} |
| 1860 |
@!r,@!s:trie_pointer; {used to clean up the packed |trie|} |
| 1861 |
@!h:two_halves; {template used to zero out |trie|'s holes} |
| 1862 |
begin |
| 1863 |
incr(max_hyph_char); |
| 1864 |
@<Get ready to compress the trie@>; |
| 1865 |
@z |
| 1866 |
%--------------------------------------- |
| 1867 |
@x [44] m.977 l.19008 - Omega |
| 1868 |
if q=null then box(n):=null {the |eq_level| of the box stays the same} |
| 1869 |
else box(n):=vpack(q,natural); |
| 1870 |
@y |
| 1871 |
if q=null then set_equiv(box_base+n,null) |
| 1872 |
{the |eq_level| of the box stays the same} |
| 1873 |
else set_equiv(box_base+n,vpack(q,natural)); |
| 1874 |
@z |
| 1875 |
%--------------------------------------- |
| 1876 |
@x [45] m.992 l.24928 - Omega |
| 1877 |
flush_node_list(box(n)); box(n):=null; |
| 1878 |
@y |
| 1879 |
flush_node_list(box(n)); set_equiv(box_base+n,null); |
| 1880 |
@z |
| 1881 |
%--------------------------------------- |
| 1882 |
@x [45] m.994 l.19364 - Omega |
| 1883 |
@!n:min_quarterword..255; {insertion box number} |
| 1884 |
@y |
| 1885 |
@!n:min_quarterword..biggest_reg; {insertion box number} |
| 1886 |
@z |
| 1887 |
%--------------------------------------- |
| 1888 |
@x [45] m.1012 l.19655 - Omega |
| 1889 |
@!n:min_quarterword..255; {insertion box number} |
| 1890 |
@y |
| 1891 |
@!n:min_quarterword..biggest_reg; {insertion box number} |
| 1892 |
@z |
| 1893 |
%--------------------------------------- |
| 1894 |
@x [45] m.1014 l.19710 - Omega |
| 1895 |
split_top_skip:=save_split_top_skip; |
| 1896 |
@y |
| 1897 |
set_equiv(glue_base+split_top_skip_code,save_split_top_skip); |
| 1898 |
@z |
| 1899 |
%--------------------------------------- |
| 1900 |
@x [45] m.1017 l.19753 - Omega |
| 1901 |
save_vbadness:=vbadness; vbadness:=inf_bad; |
| 1902 |
save_vfuzz:=vfuzz; vfuzz:=max_dimen; {inhibit error messages} |
| 1903 |
box(255):=vpackage(link(page_head),best_size,exactly,page_max_depth); |
| 1904 |
vbadness:=save_vbadness; vfuzz:=save_vfuzz; |
| 1905 |
@y |
| 1906 |
save_vbadness:=vbadness; |
| 1907 |
set_new_eqtb_int(int_base+vbadness_code,inf_bad); |
| 1908 |
save_vfuzz:=vfuzz; |
| 1909 |
set_new_eqtb_sc(dimen_base+vfuzz_code,max_dimen); |
| 1910 |
{inhibit error messages} |
| 1911 |
set_equiv(box_base+255, |
| 1912 |
vpackage(link(page_head),best_size,exactly,page_max_depth)); |
| 1913 |
set_new_eqtb_int(int_base+vbadness_code,save_vbadness); |
| 1914 |
set_new_eqtb_sc(dimen_base+vfuzz_code,save_vfuzz); |
| 1915 |
@z |
| 1916 |
%--------------------------------------- |
| 1917 |
@x [45] m.1018 l.19774 - Omega |
| 1918 |
if box(n)=null then box(n):=new_null_box; |
| 1919 |
@y |
| 1920 |
if box(n)=null then set_equiv(box_base+n,new_null_box); |
| 1921 |
@z |
| 1922 |
%--------------------------------------- |
| 1923 |
@x [45] m.1021 l.19817 - Omega |
| 1924 |
split_top_skip:=split_top_ptr(p); |
| 1925 |
ins_ptr(p):=prune_page_top(broken_ptr(r)); |
| 1926 |
if ins_ptr(p)<>null then |
| 1927 |
begin temp_ptr:=vpack(ins_ptr(p),natural); |
| 1928 |
height(p):=height(temp_ptr)+depth(temp_ptr); |
| 1929 |
free_node(temp_ptr,box_node_size); wait:=true; |
| 1930 |
end; |
| 1931 |
end; |
| 1932 |
best_ins_ptr(r):=null; |
| 1933 |
n:=qo(subtype(r)); |
| 1934 |
temp_ptr:=list_ptr(box(n)); |
| 1935 |
free_node(box(n),box_node_size); |
| 1936 |
box(n):=vpack(temp_ptr,natural); |
| 1937 |
@y |
| 1938 |
set_equiv(glue_base+split_top_skip_code,split_top_ptr(p)); |
| 1939 |
ins_ptr(p):=prune_page_top(broken_ptr(r)); |
| 1940 |
if ins_ptr(p)<>null then |
| 1941 |
begin temp_ptr:=vpack(ins_ptr(p),natural); |
| 1942 |
height(p):=height(temp_ptr)+depth(temp_ptr); |
| 1943 |
free_node(temp_ptr,box_node_size); wait:=true; |
| 1944 |
end; |
| 1945 |
end; |
| 1946 |
best_ins_ptr(r):=null; |
| 1947 |
n:=qo(subtype(r)); |
| 1948 |
temp_ptr:=list_ptr(box(n)); |
| 1949 |
free_node(box(n),box_node_size); |
| 1950 |
set_equiv(box_base+n,vpack(temp_ptr,natural)); |
| 1951 |
@z |
| 1952 |
%--------------------------------------- |
| 1953 |
@x [45] m.1023 l.19854 - Omega |
| 1954 |
ship_out(box(255)); box(255):=null; |
| 1955 |
@y |
| 1956 |
ship_out(box(255)); set_equiv(box_base+255,null); |
| 1957 |
@z |
| 1958 |
%--------------------------------------- |
| 1959 |
@x [46] m.1046 l.20339 - Omega |
| 1960 |
non_math(math_given), non_math(math_comp), non_math(delim_num), |
| 1961 |
@y |
| 1962 |
non_math(math_given), non_math(omath_given), |
| 1963 |
non_math(math_comp), non_math(delim_num), |
| 1964 |
@z |
| 1965 |
%--------------------------------------- |
| 1966 |
@x [47] m.1071 l.20718 - Omega |
| 1967 |
|box_flag+255| represent `\.{\\setbox0}' through `\.{\\setbox255}'; |
| 1968 |
codes |box_flag+256| through |box_flag+511| represent `\.{\\global\\setbox0}' |
| 1969 |
through `\.{\\global\\setbox255}'; |
| 1970 |
code |box_flag+512| represents `\.{\\shipout}'; and codes |box_flag+513| |
| 1971 |
through |box_flag+515| represent `\.{\\leaders}', `\.{\\cleaders}', |
| 1972 |
@y |
| 1973 |
|box_flag+biggest_reg| represent `\.{\\setbox0}' through |
| 1974 |
`\.{\\setbox}|biggest_reg|'; codes |box_flag+biggest_reg+1| through |
| 1975 |
|box_flag+2*biggest_reg| represent `\.{\\global\\setbox0}' |
| 1976 |
through `\.{\\global\\setbox}|biggest_reg|'; code |box_flag+2*number_regs| |
| 1977 |
represents `\.{\\shipout}'; and codes |box_flag+2*number_regs+1| |
| 1978 |
through |box_flag+2*number_regs+3| represent `\.{\\leaders}', `\.{\\cleaders}', |
| 1979 |
@z |
| 1980 |
%--------------------------------------- |
| 1981 |
@x [47] m.1071 l.20732 - Omega |
| 1982 |
@d ship_out_flag==box_flag+512 {context code for `\.{\\shipout}'} |
| 1983 |
@d leader_flag==box_flag+513 {context code for `\.{\\leaders}'} |
| 1984 |
@y |
| 1985 |
@d ship_out_flag==box_flag+(number_regs+number_regs) |
| 1986 |
{context code for `\.{\\shipout}'} |
| 1987 |
@d leader_flag==ship_out_flag+1 {context code for `\.{\\leaders}'} |
| 1988 |
@z |
| 1989 |
%--------------------------------------- |
| 1990 |
@x [47] m.1077 l.20853 - Omega |
| 1991 |
if box_context<box_flag+256 then |
| 1992 |
eq_define(box_base-box_flag+box_context,box_ref,cur_box) |
| 1993 |
else geq_define(box_base-box_flag-256+box_context,box_ref,cur_box) |
| 1994 |
@y |
| 1995 |
if box_context<box_flag+number_regs then |
| 1996 |
eq_define(box_base-box_flag+box_context,box_ref,cur_box) |
| 1997 |
else geq_define(box_base-box_flag-number_regs+box_context,box_ref,cur_box) |
| 1998 |
@z |
| 1999 |
%--------------------------------------- |
| 2000 |
@x [47] m.1079 l.20888 - Omega |
| 2001 |
box(cur_val):=null; {the box becomes void, at the same level} |
| 2002 |
@y |
| 2003 |
set_equiv(box_base+cur_val,null); |
| 2004 |
{the box becomes void, at the same level} |
| 2005 |
@z |
| 2006 |
%--------------------------------------- |
| 2007 |
@x [47] m.1100 l.21156 - Omega |
| 2008 |
if saved(0)<255 then |
| 2009 |
@y |
| 2010 |
if saved(0)<>255 then |
| 2011 |
@z |
| 2012 |
%--------------------------------------- |
| 2013 |
@x [47] m.1109 l.21265 - Omega |
| 2014 |
@ The |un_hbox| and |un_vbox| commands unwrap one of the 256 current boxes. |
| 2015 |
@y |
| 2016 |
@ The |un_hbox| and |un_vbox| commands unwrap one of the current boxes. |
| 2017 |
@z |
| 2018 |
%--------------------------------------- |
| 2019 |
@x [47] m.1110 l.21287 - Omega |
| 2020 |
else begin link(tail):=list_ptr(p); box(cur_val):=null; |
| 2021 |
@y |
| 2022 |
else begin link(tail):=list_ptr(p); |
| 2023 |
set_equiv(box_base+cur_val,null); |
| 2024 |
@z |
| 2025 |
%--------------------------------------- |
| 2026 |
@x [47] m.1117 l.21342 - Omega |
| 2027 |
if c>=0 then if c<256 then pre_break(tail):=new_character(cur_font,c); |
| 2028 |
@y |
| 2029 |
if c>=0 then if c<=biggest_char then |
| 2030 |
pre_break(tail):=new_character(cur_font,c); |
| 2031 |
@z |
| 2032 |
%--------------------------------------- |
| 2033 |
@x [48] m.1151 l.21810 - Omega |
| 2034 |
@ Recall that the |nucleus|, |subscr|, and |supscr| fields in a noad are |
| 2035 |
broken down into subfields called |math_type| and either |info| or |
| 2036 |
|(fam,character)|. The job of |scan_math| is to figure out what to place |
| 2037 |
in one of these principal fields; it looks at the subformula that |
| 2038 |
comes next in the input, and places an encoding of that subformula |
| 2039 |
into a given word of |mem|. |
| 2040 |
|
| 2041 |
@d fam_in_range==((cur_fam>=0)and(cur_fam<16)) |
| 2042 |
|
| 2043 |
@<Declare act...@>= |
| 2044 |
procedure scan_math(@!p:pointer); |
| 2045 |
label restart,reswitch,exit; |
| 2046 |
var c:integer; {math character code} |
| 2047 |
begin restart:@<Get the next non-blank non-relax...@>; |
| 2048 |
reswitch:case cur_cmd of |
| 2049 |
letter,other_char,char_given: begin c:=ho(math_code(cur_chr)); |
| 2050 |
if c=@'100000 then |
| 2051 |
begin @<Treat |cur_chr| as an active character@>; |
| 2052 |
goto restart; |
| 2053 |
end; |
| 2054 |
end; |
| 2055 |
char_num: begin scan_char_num; cur_chr:=cur_val; cur_cmd:=char_given; |
| 2056 |
goto reswitch; |
| 2057 |
end; |
| 2058 |
math_char_num: begin scan_fifteen_bit_int; c:=cur_val; |
| 2059 |
end; |
| 2060 |
math_given: c:=cur_chr; |
| 2061 |
delim_num: begin scan_twenty_seven_bit_int; c:=cur_val div @'10000; |
| 2062 |
end; |
| 2063 |
othercases @<Scan a subformula enclosed in braces and |return|@> |
| 2064 |
endcases;@/ |
| 2065 |
math_type(p):=math_char; character(p):=qi(c mod 256); |
| 2066 |
if (c>=var_code)and fam_in_range then fam(p):=cur_fam |
| 2067 |
else fam(p):=(c div 256) mod 16; |
| 2068 |
exit:end; |
| 2069 |
@y |
| 2070 |
@ Recall that the |nucleus|, |subscr|, and |supscr| fields in a noad are |
| 2071 |
broken down into subfields called |math_type| and either |info| or |
| 2072 |
|(fam,character)|. The job of |scan_math| is to figure out what to place |
| 2073 |
in one of these principal fields; it looks at the subformula that |
| 2074 |
comes next in the input, and places an encoding of that subformula |
| 2075 |
into a given word of |mem|. |
| 2076 |
|
| 2077 |
@d fam_in_range==((cur_fam>=0)and(cur_fam<256)) |
| 2078 |
|
| 2079 |
@<Declare act...@>= |
| 2080 |
@t\4@>@<Declare the function called |fin_mlist|@>@t@>@;@/ |
| 2081 |
|
| 2082 |
procedure scan_math(@!p:pointer); |
| 2083 |
label restart,reswitch,exit; |
| 2084 |
var c:integer; {math character code} |
| 2085 |
begin restart:@<Get the next non-blank non-relax...@>; |
| 2086 |
reswitch: |
| 2087 |
case cur_cmd of |
| 2088 |
letter,other_char,char_given: begin |
| 2089 |
c:=ho(math_code(cur_chr)); |
| 2090 |
if c=@"8000000 then |
| 2091 |
begin @<Treat |cur_chr| as an active character@>; |
| 2092 |
goto restart; |
| 2093 |
end; |
| 2094 |
end; |
| 2095 |
char_num: begin scan_char_num; cur_chr:=cur_val; cur_cmd:=char_given; |
| 2096 |
goto reswitch; |
| 2097 |
end; |
| 2098 |
math_char_num: begin |
| 2099 |
if cur_chr=0 then scan_fifteen_bit_int |
| 2100 |
else scan_big_fifteen_bit_int; |
| 2101 |
c:=cur_val; |
| 2102 |
end; |
| 2103 |
math_given: begin |
| 2104 |
c := ((cur_chr div @"1000) * @"1000000) + |
| 2105 |
(((cur_chr mod @"1000) div @"100) * @"10000) + |
| 2106 |
(cur_chr mod @"100); |
| 2107 |
end; |
| 2108 |
omath_given: begin c:=cur_chr; |
| 2109 |
end; |
| 2110 |
delim_num: begin |
| 2111 |
if cur_chr=0 then scan_twenty_seven_bit_int |
| 2112 |
else scan_fifty_one_bit_int; |
| 2113 |
c:=cur_val; |
| 2114 |
end; |
| 2115 |
othercases @<Scan a subformula enclosed in braces and |return|@> |
| 2116 |
endcases;@/ |
| 2117 |
math_type(p):=math_char; character(p):=qi(c mod @"10000); |
| 2118 |
if (c>=var_code)and fam_in_range then fam(p):=cur_fam |
| 2119 |
else fam(p):=(c div @"10000) mod @"100; |
| 2120 |
exit:end; |
| 2121 |
@z |
| 2122 |
%--------------------------------------- |
| 2123 |
@x [48] m.1154 l.21860 - Omega |
| 2124 |
mmode+letter,mmode+other_char,mmode+char_given: |
| 2125 |
set_math_char(ho(math_code(cur_chr))); |
| 2126 |
mmode+char_num: begin scan_char_num; cur_chr:=cur_val; |
| 2127 |
set_math_char(ho(math_code(cur_chr))); |
| 2128 |
end; |
| 2129 |
mmode+math_char_num: begin scan_fifteen_bit_int; set_math_char(cur_val); |
| 2130 |
end; |
| 2131 |
mmode+math_given: set_math_char(cur_chr); |
| 2132 |
mmode+delim_num: begin scan_twenty_seven_bit_int; |
| 2133 |
set_math_char(cur_val div @'10000); |
| 2134 |
@y |
| 2135 |
mmode+letter,mmode+other_char,mmode+char_given: |
| 2136 |
set_math_char(ho(math_code(cur_chr))); |
| 2137 |
mmode+char_num: begin scan_char_num; cur_chr:=cur_val; |
| 2138 |
set_math_char(ho(math_code(cur_chr))); |
| 2139 |
end; |
| 2140 |
mmode+math_char_num: begin |
| 2141 |
if cur_chr=0 then scan_fifteen_bit_int |
| 2142 |
else scan_big_fifteen_bit_int; |
| 2143 |
set_math_char(cur_val); |
| 2144 |
end; |
| 2145 |
mmode+math_given: begin |
| 2146 |
set_math_char(((cur_chr div @"1000) * @"1000000) + |
| 2147 |
(((cur_chr mod @"1000) div @"100) * @"10000) + |
| 2148 |
(cur_chr mod @"100)); |
| 2149 |
end; |
| 2150 |
mmode+omath_given: begin |
| 2151 |
set_math_char(cur_chr); |
| 2152 |
end; |
| 2153 |
mmode+delim_num: begin |
| 2154 |
if cur_chr=0 then scan_twenty_seven_bit_int |
| 2155 |
else scan_fifty_one_bit_int; |
| 2156 |
set_math_char(cur_val); |
| 2157 |
@z |
| 2158 |
%--------------------------------------- |
| 2159 |
@x [48] m.1155 l.21878 - Omega |
| 2160 |
procedure set_math_char(@!c:integer); |
| 2161 |
var p:pointer; {the new noad} |
| 2162 |
begin if c>=@'100000 then |
| 2163 |
@<Treat |cur_chr|...@> |
| 2164 |
else begin p:=new_noad; math_type(nucleus(p)):=math_char; |
| 2165 |
character(nucleus(p)):=qi(c mod 256); |
| 2166 |
fam(nucleus(p)):=(c div 256) mod 16; |
| 2167 |
if c>=var_code then |
| 2168 |
begin if fam_in_range then fam(nucleus(p)):=cur_fam; |
| 2169 |
type(p):=ord_noad; |
| 2170 |
end |
| 2171 |
else type(p):=ord_noad+(c div @'10000); |
| 2172 |
link(tail):=p; tail:=p; |
| 2173 |
end; |
| 2174 |
end; |
| 2175 |
@y |
| 2176 |
procedure set_math_char(@!c:integer); |
| 2177 |
var p:pointer; {the new noad} |
| 2178 |
begin if c>=@"8000000 then |
| 2179 |
@<Treat |cur_chr|...@> |
| 2180 |
else begin p:=new_noad; math_type(nucleus(p)):=math_char; |
| 2181 |
character(nucleus(p)):=qi(c mod @"10000); |
| 2182 |
fam(nucleus(p)):=(c div @"10000) mod @"100; |
| 2183 |
if c>=var_code then |
| 2184 |
begin if fam_in_range then fam(nucleus(p)):=cur_fam; |
| 2185 |
type(p):=ord_noad; |
| 2186 |
end |
| 2187 |
else type(p):=ord_noad+(c div @"1000000); |
| 2188 |
link(tail):=p; tail:=p; |
| 2189 |
end; |
| 2190 |
end; |
| 2191 |
@z |
| 2192 |
%--------------------------------------- |
| 2193 |
@x [48] m.1160 l.21966 - Omega |
| 2194 |
procedure scan_delimiter(@!p:pointer;@!r:boolean); |
| 2195 |
begin if r then scan_twenty_seven_bit_int |
| 2196 |
else begin @<Get the next non-blank non-relax...@>; |
| 2197 |
case cur_cmd of |
| 2198 |
letter,other_char: cur_val:=del_code(cur_chr); |
| 2199 |
delim_num: scan_twenty_seven_bit_int; |
| 2200 |
othercases cur_val:=-1 |
| 2201 |
endcases; |
| 2202 |
end; |
| 2203 |
if cur_val<0 then @<Report that an invalid delimiter code is being changed |
| 2204 |
to null; set~|cur_val:=0|@>; |
| 2205 |
small_fam(p):=(cur_val div @'4000000) mod 16; |
| 2206 |
small_char(p):=qi((cur_val div @'10000) mod 256); |
| 2207 |
large_fam(p):=(cur_val div 256) mod 16; |
| 2208 |
large_char(p):=qi(cur_val mod 256); |
| 2209 |
@y |
| 2210 |
procedure scan_delimiter(@!p:pointer;@!r:integer); |
| 2211 |
begin if r=1 then scan_twenty_seven_bit_int |
| 2212 |
else if r=2 then scan_fifty_one_bit_int |
| 2213 |
else begin @<Get the next non-blank non-relax...@>; |
| 2214 |
case cur_cmd of |
| 2215 |
letter,other_char: begin |
| 2216 |
cur_val:=del_code0(cur_chr); cur_val1:=del_code1(cur_chr); |
| 2217 |
end; |
| 2218 |
delim_num: if cur_chr=0 then scan_twenty_seven_bit_int |
| 2219 |
else scan_fifty_one_bit_int; |
| 2220 |
othercases begin cur_val:=-1; cur_val1:=-1; end; |
| 2221 |
endcases; |
| 2222 |
end; |
| 2223 |
if cur_val<0 then begin @<Report that an invalid delimiter code is being changed |
| 2224 |
to null; set~|cur_val:=0|@>; |
| 2225 |
cur_val1:=0; |
| 2226 |
end; |
| 2227 |
small_fam(p):=(cur_val div @"10000) mod @"100; |
| 2228 |
small_char(p):=qi(cur_val mod @"10000); |
| 2229 |
large_fam(p):=(cur_val1 div @"10000) mod @"100; |
| 2230 |
large_char(p):=qi(cur_val1 mod @"10000); |
| 2231 |
@z |
| 2232 |
%--------------------------------------- |
| 2233 |
@x [48] m.1163 l.22005 - Omega |
| 2234 |
scan_delimiter(left_delimiter(tail),true); scan_math(nucleus(tail)); |
| 2235 |
@y |
| 2236 |
scan_delimiter(left_delimiter(tail),cur_chr+1); scan_math(nucleus(tail)); |
| 2237 |
@z |
| 2238 |
%--------------------------------------- |
| 2239 |
@x [48] m.1165 l.22012 - Omega |
| 2240 |
procedure math_ac; |
| 2241 |
begin if cur_cmd=accent then |
| 2242 |
@<Complain that the user should have said \.{\\mathaccent}@>; |
| 2243 |
tail_append(get_node(accent_noad_size)); |
| 2244 |
type(tail):=accent_noad; subtype(tail):=normal; |
| 2245 |
mem[nucleus(tail)].hh:=empty_field; |
| 2246 |
mem[subscr(tail)].hh:=empty_field; |
| 2247 |
mem[supscr(tail)].hh:=empty_field; |
| 2248 |
math_type(accent_chr(tail)):=math_char; |
| 2249 |
scan_fifteen_bit_int; |
| 2250 |
character(accent_chr(tail)):=qi(cur_val mod 256); |
| 2251 |
if (cur_val>=var_code)and fam_in_range then fam(accent_chr(tail)):=cur_fam |
| 2252 |
else fam(accent_chr(tail)):=(cur_val div 256) mod 16; |
| 2253 |
scan_math(nucleus(tail)); |
| 2254 |
end; |
| 2255 |
@y |
| 2256 |
procedure math_ac; |
| 2257 |
begin if cur_cmd=accent then |
| 2258 |
@<Complain that the user should have said \.{\\mathaccent}@>; |
| 2259 |
tail_append(get_node(accent_noad_size)); |
| 2260 |
type(tail):=accent_noad; subtype(tail):=normal; |
| 2261 |
mem[nucleus(tail)].hh:=empty_field; |
| 2262 |
mem[subscr(tail)].hh:=empty_field; |
| 2263 |
mem[supscr(tail)].hh:=empty_field; |
| 2264 |
math_type(accent_chr(tail)):=math_char; |
| 2265 |
if cur_chr=0 then scan_fifteen_bit_int |
| 2266 |
else scan_big_fifteen_bit_int; |
| 2267 |
character(accent_chr(tail)):=qi(cur_val mod @"10000); |
| 2268 |
if (cur_val>=var_code)and fam_in_range then fam(accent_chr(tail)):=cur_fam |
| 2269 |
else fam(accent_chr(tail)):=(cur_val div @"10000) mod @"100; |
| 2270 |
scan_math(nucleus(tail)); |
| 2271 |
end; |
| 2272 |
@z |
| 2273 |
%--------------------------------------- |
| 2274 |
@x [48] m.1174 l.22085 - Omega |
| 2275 |
@t\4@>@<Declare the function called |fin_mlist|@>@t@>@;@/ |
| 2276 |
@y |
| 2277 |
@z |
| 2278 |
%--------------------------------------- |
| 2279 |
@x [48] m.1188 l.22284 - Omega |
| 2280 |
text(frozen_right):="right"; eqtb[frozen_right]:=eqtb[cur_val]; |
| 2281 |
@y |
| 2282 |
settext(frozen_right,"right"); |
| 2283 |
set_new_eqtb(frozen_right,new_eqtb(cur_val)); |
| 2284 |
@z |
| 2285 |
%--------------------------------------- |
| 2286 |
@x [49] m.1214 l.22700 - Omega |
| 2287 |
@d word_define(#)==if global then geq_word_define(#)@+else eq_word_define(#) |
| 2288 |
@y |
| 2289 |
@d word_define(#)==if global then geq_word_define(#)@+else eq_word_define(#) |
| 2290 |
@d del_word_define(#)==if global |
| 2291 |
then del_geq_word_define(#)@+else del_eq_word_define(#) |
| 2292 |
@z |
| 2293 |
%--------------------------------------- |
| 2294 |
@x [49] m.1216 l.22734 - Omega |
| 2295 |
text(frozen_protection):="inaccessible"; |
| 2296 |
@y |
| 2297 |
settext(frozen_protection,"inaccessible"); |
| 2298 |
@z |
| 2299 |
%--------------------------------------- |
| 2300 |
@x [49] m.1222 l.22789 - Omega |
| 2301 |
@d char_def_code=0 {|shorthand_def| for \.{\\chardef}} |
| 2302 |
@d math_char_def_code=1 {|shorthand_def| for \.{\\mathchardef}} |
| 2303 |
@d count_def_code=2 {|shorthand_def| for \.{\\countdef}} |
| 2304 |
@d dimen_def_code=3 {|shorthand_def| for \.{\\dimendef}} |
| 2305 |
@d skip_def_code=4 {|shorthand_def| for \.{\\skipdef}} |
| 2306 |
@d mu_skip_def_code=5 {|shorthand_def| for \.{\\muskipdef}} |
| 2307 |
@d toks_def_code=6 {|shorthand_def| for \.{\\toksdef}} |
| 2308 |
|
| 2309 |
@<Put each...@>= |
| 2310 |
primitive("chardef",shorthand_def,char_def_code);@/ |
| 2311 |
@!@:char_def_}{\.{\\chardef} primitive@> |
| 2312 |
primitive("mathchardef",shorthand_def,math_char_def_code);@/ |
| 2313 |
@!@:math_char_def_}{\.{\\mathchardef} primitive@> |
| 2314 |
@y |
| 2315 |
@d char_def_code=0 {|shorthand_def| for \.{\\chardef}} |
| 2316 |
@d math_char_def_code=1 {|shorthand_def| for \.{\\mathchardef}} |
| 2317 |
@d omath_char_def_code=2 {|shorthand_def| for \.{\\omathchardef}} |
| 2318 |
@d count_def_code=3 {|shorthand_def| for \.{\\countdef}} |
| 2319 |
@d dimen_def_code=4 {|shorthand_def| for \.{\\dimendef}} |
| 2320 |
@d skip_def_code=5 {|shorthand_def| for \.{\\skipdef}} |
| 2321 |
@d mu_skip_def_code=6 {|shorthand_def| for \.{\\muskipdef}} |
| 2322 |
@d toks_def_code=7 {|shorthand_def| for \.{\\toksdef}} |
| 2323 |
|
| 2324 |
@<Put each...@>= |
| 2325 |
primitive("chardef",shorthand_def,char_def_code);@/ |
| 2326 |
@!@:char_def_}{\.{\\chardef} primitive@> |
| 2327 |
primitive("mathchardef",shorthand_def,math_char_def_code);@/ |
| 2328 |
@!@:math_char_def_}{\.{\\mathchardef} primitive@> |
| 2329 |
primitive("omathchardef",shorthand_def,omath_char_def_code);@/ |
| 2330 |
@!@:math_char_def_}{\.{\\omathchardef} primitive@> |
| 2331 |
@z |
| 2332 |
%--------------------------------------- |
| 2333 |
@x |
| 2334 |
math_char_def_code: print_esc("mathchardef"); |
| 2335 |
@y |
| 2336 |
math_char_def_code: print_esc("mathchardef"); |
| 2337 |
omath_char_def_code: print_esc("omathchardef"); |
| 2338 |
@z |
| 2339 |
%--------------------------------------- |
| 2340 |
@x |
| 2341 |
math_given: begin print_esc("mathchar"); print_hex(chr_code); |
| 2342 |
end; |
| 2343 |
@y |
| 2344 |
math_given: begin print_esc("mathchar"); print_hex(chr_code); |
| 2345 |
end; |
| 2346 |
omath_given: begin print_esc("omathchar"); print_hex(chr_code); |
| 2347 |
end; |
| 2348 |
@z |
| 2349 |
%--------------------------------------- |
| 2350 |
@x [49] m.1224 l.22833 - Omega |
| 2351 |
shorthand_def: begin n:=cur_chr; get_r_token; p:=cur_cs; define(p,relax,256); |
| 2352 |
scan_optional_equals; |
| 2353 |
case n of |
| 2354 |
char_def_code: begin scan_char_num; define(p,char_given,cur_val); |
| 2355 |
end; |
| 2356 |
math_char_def_code: begin scan_fifteen_bit_int; define(p,math_given,cur_val); |
| 2357 |
end; |
| 2358 |
@y |
| 2359 |
shorthand_def: begin n:=cur_chr; get_r_token; p:=cur_cs; |
| 2360 |
define(p,relax,too_big_char); scan_optional_equals; |
| 2361 |
case n of |
| 2362 |
char_def_code: begin scan_char_num; define(p,char_given,cur_val); |
| 2363 |
end; |
| 2364 |
math_char_def_code: begin scan_real_fifteen_bit_int; |
| 2365 |
define(p,math_given,cur_val); |
| 2366 |
end; |
| 2367 |
omath_char_def_code: begin scan_big_fifteen_bit_int; |
| 2368 |
define(p,omath_given,cur_val); |
| 2369 |
end; |
| 2370 |
@z |
| 2371 |
%--------------------------------------- |
| 2372 |
@x [49] m.1230 l. - Omega |
| 2373 |
primitive("mathcode",def_code,math_code_base); |
| 2374 |
@!@:math_code_}{\.{\\mathcode} primitive@> |
| 2375 |
primitive("lccode",def_code,lc_code_base); |
| 2376 |
@!@:lc_code_}{\.{\\lccode} primitive@> |
| 2377 |
primitive("uccode",def_code,uc_code_base); |
| 2378 |
@!@:uc_code_}{\.{\\uccode} primitive@> |
| 2379 |
primitive("sfcode",def_code,sf_code_base); |
| 2380 |
@!@:sf_code_}{\.{\\sfcode} primitive@> |
| 2381 |
primitive("delcode",def_code,del_code_base); |
| 2382 |
@!@:del_code_}{\.{\\delcode} primitive@> |
| 2383 |
@y |
| 2384 |
primitive("mathcode",def_code,math_code_base); |
| 2385 |
@!@:math_code_}{\.{\\mathcode} primitive@> |
| 2386 |
primitive("omathcode",def_code,math_code_base+256); |
| 2387 |
@!@:math_code_}{\.{\\omathcode} primitive@> |
| 2388 |
primitive("lccode",def_code,lc_code_base); |
| 2389 |
@!@:lc_code_}{\.{\\lccode} primitive@> |
| 2390 |
primitive("uccode",def_code,uc_code_base); |
| 2391 |
@!@:uc_code_}{\.{\\uccode} primitive@> |
| 2392 |
primitive("sfcode",def_code,sf_code_base); |
| 2393 |
@!@:sf_code_}{\.{\\sfcode} primitive@> |
| 2394 |
primitive("delcode",def_code,del_code_base); |
| 2395 |
@!@:del_code_}{\.{\\delcode} primitive@> |
| 2396 |
primitive("odelcode",def_code,del_code_base+256); |
| 2397 |
@!@:del_code_}{\.{\\odelcode} primitive@> |
| 2398 |
@z |
| 2399 |
%--------------------------------------- |
| 2400 |
@x |
| 2401 |
else if chr_code=lc_code_base then print_esc("lccode") |
| 2402 |
else if chr_code=uc_code_base then print_esc("uccode") |
| 2403 |
else if chr_code=sf_code_base then print_esc("sfcode") |
| 2404 |
else print_esc("delcode"); |
| 2405 |
@y |
| 2406 |
else if chr_code=math_code_base+256 then print_esc("omathcode") |
| 2407 |
else if chr_code=lc_code_base then print_esc("lccode") |
| 2408 |
else if chr_code=uc_code_base then print_esc("uccode") |
| 2409 |
else if chr_code=sf_code_base then print_esc("sfcode") |
| 2410 |
else if chr_code=del_code_base then print_esc("delcode") |
| 2411 |
else print_esc("odelcode"); |
| 2412 |
@z |
| 2413 |
%--------------------------------------- |
| 2414 |
@x [49] m.1232 l.22990 - Omega |
| 2415 |
def_code: begin @<Let |n| be the largest legal code value, based on |cur_chr|@>; |
| 2416 |
p:=cur_chr; scan_char_num; p:=p+cur_val; scan_optional_equals; |
| 2417 |
scan_int; |
| 2418 |
if ((cur_val<0)and(p<del_code_base))or(cur_val>n) then |
| 2419 |
begin print_err("Invalid code ("); print_int(cur_val); |
| 2420 |
@.Invalid code@> |
| 2421 |
if p<del_code_base then print("), should be in the range 0..") |
| 2422 |
else print("), should be at most "); |
| 2423 |
print_int(n); |
| 2424 |
help1("I'm going to use 0 instead of that illegal code value.");@/ |
| 2425 |
error; cur_val:=0; |
| 2426 |
end; |
| 2427 |
if p<math_code_base then define(p,data,cur_val) |
| 2428 |
else if p<del_code_base then define(p,data,hi(cur_val)) |
| 2429 |
else word_define(p,cur_val); |
| 2430 |
@y |
| 2431 |
def_code: begin |
| 2432 |
if cur_chr=(del_code_base+256) then begin |
| 2433 |
p:=cur_chr-256; scan_char_num; p:=p+cur_val; scan_optional_equals; |
| 2434 |
scan_int; cur_val1:=cur_val; scan_int; {backwards} |
| 2435 |
if (cur_val1>@"FFFFFF) or (cur_val>@"FFFFFF) then |
| 2436 |
begin print_err("Invalid code ("); print_int(cur_val1); print(" "); |
| 2437 |
print_int(cur_val); |
| 2438 |
print("), should be at most ""FFFFFF ""FFFFFF"); |
| 2439 |
help1("I'm going to use 0 instead of that illegal code value.");@/ |
| 2440 |
error; cur_val1:=0; cur_val:=0; |
| 2441 |
end; |
| 2442 |
del_word_define(p,cur_val1,cur_val); |
| 2443 |
end |
| 2444 |
else begin |
| 2445 |
@<Let |n| be the largest legal code value, based on |cur_chr|@>; |
| 2446 |
p:=cur_chr; scan_char_num; p:=p+cur_val; scan_optional_equals; |
| 2447 |
scan_int; |
| 2448 |
if ((cur_val<0)and(p<del_code_base))or(cur_val>n) then |
| 2449 |
begin print_err("Invalid code ("); print_int(cur_val); |
| 2450 |
@.Invalid code@> |
| 2451 |
if p<del_code_base then print("), should be in the range 0..") |
| 2452 |
else print("), should be at most "); |
| 2453 |
print_int(n); |
| 2454 |
help1("I'm going to use 0 instead of that illegal code value.");@/ |
| 2455 |
error; cur_val:=0; |
| 2456 |
end; |
| 2457 |
if p<math_code_base then define(p,data,cur_val) |
| 2458 |
else if p<(math_code_base+256) then begin |
| 2459 |
if cur_val=@"8000 then cur_val:=@"8000000 |
| 2460 |
else cur_val:=((cur_val div @"1000) * @"1000000) + |
| 2461 |
(((cur_val mod @"1000) div @"100) * @"10000) + |
| 2462 |
(cur_val mod @"100); |
| 2463 |
define(p,data,hi(cur_val)); |
| 2464 |
end |
| 2465 |
else if p<del_code_base then define(p-256,data,hi(cur_val)) |
| 2466 |
else begin |
| 2467 |
cur_val1:=cur_val div @"1000; |
| 2468 |
cur_val1:=(cur_val1 div @"100)*@"10000 + (cur_val1 mod @"100); |
| 2469 |
cur_val:=cur_val mod @"1000; |
| 2470 |
cur_val:=(cur_val div @"100)*@"10000 + (cur_val mod @"100); |
| 2471 |
del_word_define(p,cur_val1,cur_val); |
| 2472 |
end; |
| 2473 |
end; |
| 2474 |
@z |
| 2475 |
%--------------------------------------- |
| 2476 |
@x [49] m.1233 l.22990 - Omega |
| 2477 |
if cur_chr=cat_code_base then n:=max_char_code |
| 2478 |
else if cur_chr=math_code_base then n:=@'100000 |
| 2479 |
else if cur_chr=sf_code_base then n:=@'77777 |
| 2480 |
else if cur_chr=del_code_base then n:=@'77777777 |
| 2481 |
else n:=255 |
| 2482 |
@y |
| 2483 |
if cur_chr=cat_code_base then n:=max_char_code |
| 2484 |
else if cur_chr=math_code_base then n:=@'100000 |
| 2485 |
else if cur_chr=(math_code_base+256) then n:=@"8000000 |
| 2486 |
else if cur_chr=sf_code_base then n:=@'77777 |
| 2487 |
else if cur_chr=del_code_base then n:=@'77777777 |
| 2488 |
else n:=biggest_char |
| 2489 |
@z |
| 2490 |
%--------------------------------------- |
| 2491 |
@x [49] m.1234 l.22990 - Omega |
| 2492 |
def_family: begin p:=cur_chr; scan_four_bit_int; p:=p+cur_val; |
| 2493 |
@y |
| 2494 |
def_family: begin p:=cur_chr; scan_big_four_bit_int; p:=p+cur_val; |
| 2495 |
@z |
| 2496 |
%--------------------------------------- |
| 2497 |
@x [49] m.1238 l.23059 - Omega |
| 2498 |
if q=advance then cur_val:=cur_val+eqtb[l].int; |
| 2499 |
@y |
| 2500 |
if q=advance then cur_val:=cur_val+new_eqtb_int(l); |
| 2501 |
@z |
| 2502 |
%--------------------------------------- |
| 2503 |
@x [49] m.1240 l.23086 - Omega |
| 2504 |
if p=int_val then cur_val:=mult_integers(eqtb[l].int,cur_val) |
| 2505 |
else cur_val:=nx_plus_y(eqtb[l].int,cur_val,0) |
| 2506 |
else cur_val:=x_over_n(eqtb[l].int,cur_val) |
| 2507 |
@y |
| 2508 |
if p=int_val then cur_val:=mult_integers(new_eqtb_int(l),cur_val) |
| 2509 |
else cur_val:=nx_plus_y(new_eqtb_int(l),cur_val,0) |
| 2510 |
else cur_val:=x_over_n(new_eqtb_int(l),cur_val) |
| 2511 |
@z |
| 2512 |
%--------------------------------------- |
| 2513 |
@x [49] m.1241 l.23109 - Omega |
| 2514 |
if global then n:=256+cur_val@+else n:=cur_val; |
| 2515 |
@y |
| 2516 |
if global then n:=number_regs+cur_val@+else n:=cur_val; |
| 2517 |
@z |
| 2518 |
%--------------------------------------- |
| 2519 |
@x [49] m.1289 l.23546 - Omega |
| 2520 |
|cs_token_flag+active_base| is a multiple of~256. |
| 2521 |
@y |
| 2522 |
|cs_token_flag+active_base| is a multiple of~|max_char_val|. |
| 2523 |
@z |
| 2524 |
%--------------------------------------- |
| 2525 |
@x [49] m.1289 l.23552 - Omega |
| 2526 |
begin c:=t mod 256; |
| 2527 |
@y |
| 2528 |
begin c:=t mod max_char_val; |
| 2529 |
@z |
| 2530 |
%--------------------------------------- |
| 2531 |
@x [50] m.1313 l.23892 - Omega |
| 2532 |
@<Dump regions 1 to 4 of |eqtb|@>; |
| 2533 |
@<Dump regions 5 and 6 of |eqtb|@>; |
| 2534 |
@y |
| 2535 |
dump_eqtb_table; |
| 2536 |
@z |
| 2537 |
%--------------------------------------- |
| 2538 |
@x [50] m.1314 l.23904 - Omega |
| 2539 |
@<Undump regions 1 to 6 of |eqtb|@>; |
| 2540 |
@y |
| 2541 |
undump_eqtb_table; |
| 2542 |
@z |
| 2543 |
%--------------------------------------- |
| 2544 |
@x [50] m.1315 l.23904 - Omega |
| 2545 |
@ The table of equivalents usually contains repeated information, so we dump it |
| 2546 |
in compressed form: The sequence of $n+2$ values $(n,x_1,\ldots,x_n,m)$ in the |
| 2547 |
format file represents $n+m$ consecutive entries of |eqtb|, with |m| extra |
| 2548 |
copies of $x_n$, namely $(x_1,\ldots,x_n,x_n,\ldots,x_n)$. |
| 2549 |
|
| 2550 |
@<Dump regions 1 to 4 of |eqtb|@>= |
| 2551 |
k:=active_base; |
| 2552 |
repeat j:=k; |
| 2553 |
while j<int_base-1 do |
| 2554 |
begin if (equiv(j)=equiv(j+1))and(eq_type(j)=eq_type(j+1))and@| |
| 2555 |
(eq_level(j)=eq_level(j+1)) then goto found1; |
| 2556 |
incr(j); |
| 2557 |
end; |
| 2558 |
l:=int_base; goto done1; {|j=int_base-1|} |
| 2559 |
found1: incr(j); l:=j; |
| 2560 |
while j<int_base-1 do |
| 2561 |
begin if (equiv(j)<>equiv(j+1))or(eq_type(j)<>eq_type(j+1))or@| |
| 2562 |
(eq_level(j)<>eq_level(j+1)) then goto done1; |
| 2563 |
incr(j); |
| 2564 |
end; |
| 2565 |
done1:dump_int(l-k); |
| 2566 |
while k<l do |
| 2567 |
begin dump_wd(eqtb[k]); incr(k); |
| 2568 |
end; |
| 2569 |
k:=j+1; dump_int(k-l); |
| 2570 |
until k=int_base |
| 2571 |
|
| 2572 |
@ @<Dump regions 5 and 6 of |eqtb|@>= |
| 2573 |
repeat j:=k; |
| 2574 |
while j<eqtb_size do |
| 2575 |
begin if eqtb[j].int=eqtb[j+1].int then goto found2; |
| 2576 |
incr(j); |
| 2577 |
end; |
| 2578 |
l:=eqtb_size+1; goto done2; {|j=eqtb_size|} |
| 2579 |
found2: incr(j); l:=j; |
| 2580 |
while j<eqtb_size do |
| 2581 |
begin if eqtb[j].int<>eqtb[j+1].int then goto done2; |
| 2582 |
incr(j); |
| 2583 |
end; |
| 2584 |
done2:dump_int(l-k); |
| 2585 |
while k<l do |
| 2586 |
begin dump_wd(eqtb[k]); incr(k); |
| 2587 |
end; |
| 2588 |
k:=j+1; dump_int(k-l); |
| 2589 |
until k>eqtb_size |
| 2590 |
|
| 2591 |
@ @<Undump regions 1 to 6 of |eqtb|@>= |
| 2592 |
k:=active_base; |
| 2593 |
repeat undump_int(x); |
| 2594 |
if (x<1)or(k+x>eqtb_size+1) then goto bad_fmt; |
| 2595 |
for j:=k to k+x-1 do undump_wd(eqtb[j]); |
| 2596 |
k:=k+x; |
| 2597 |
undump_int(x); |
| 2598 |
if (x<0)or(k+x>eqtb_size+1) then goto bad_fmt; |
| 2599 |
for j:=k to k+x-1 do eqtb[j]:=eqtb[k-1]; |
| 2600 |
k:=k+x; |
| 2601 |
until k>eqtb_size |
| 2602 |
@y |
| 2603 |
|
| 2604 |
@z |
| 2605 |
%--------------------------------------- |
| 2606 |
@x [50] m.1318 l.23967 - Omega |
| 2607 |
@<Dump the hash table@>= |
| 2608 |
dump_int(hash_used); cs_count:=frozen_control_sequence-1-hash_used; |
| 2609 |
for p:=hash_base to hash_used do if text(p)<>0 then |
| 2610 |
begin dump_int(p); dump_hh(hash[p]); incr(cs_count); |
| 2611 |
end; |
| 2612 |
for p:=hash_used+1 to undefined_control_sequence-1 do dump_hh(hash[p]); |
| 2613 |
dump_int(cs_count);@/ |
| 2614 |
print_ln; print_int(cs_count); print(" multiletter control sequences") |
| 2615 |
@y |
| 2616 |
@<Dump the hash table@>= |
| 2617 |
dump_int(hash_used); |
| 2618 |
@z |
| 2619 |
%--------------------------------------- |
| 2620 |
@x [50] m.1319 l.23976 - Omega |
| 2621 |
undump(hash_base)(frozen_control_sequence)(hash_used); p:=hash_base-1; |
| 2622 |
repeat undump(p+1)(hash_used)(p); undump_hh(hash[p]); |
| 2623 |
until p=hash_used; |
| 2624 |
for p:=hash_used+1 to undefined_control_sequence-1 do undump_hh(hash[p]); |
| 2625 |
undump_int(cs_count) |
| 2626 |
@y |
| 2627 |
undump(hash_base)(frozen_control_sequence)(hash_used); |
| 2628 |
@z |
| 2629 |
%--------------------------------------- |
| 2630 |
@x [50] m.1324 l.24066 - Omega |
| 2631 |
for k:=0 to trie_max do dump_hh(trie[k]); |
| 2632 |
@y |
| 2633 |
for k:=0 to trie_max do dump_hh(trie[k]); |
| 2634 |
dump_int(max_hyph_char); |
| 2635 |
@z |
| 2636 |
%--------------------------------------- |
| 2637 |
@x [50] m.1324 l.24078 - Omega |
| 2638 |
for k:=255 downto 0 do if trie_used[k]>min_quarterword then |
| 2639 |
@y |
| 2640 |
for k:=biggest_lang downto 0 do if trie_used[k]>min_quarterword then |
| 2641 |
@z |
| 2642 |
%--------------------------------------- |
| 2643 |
@x [50] m.1325 l.24094 - Omega |
| 2644 |
for k:=0 to j do undump_hh(trie[k]); |
| 2645 |
@y |
| 2646 |
for k:=0 to j do undump_hh(trie[k]); |
| 2647 |
undump_int(max_hyph_char); |
| 2648 |
@z |
| 2649 |
%--------------------------------------- |
| 2650 |
@x [50] m.1325 l.24101 - Omega |
| 2651 |
init for k:=0 to 255 do trie_used[k]:=min_quarterword;@+tini@;@/ |
| 2652 |
k:=256; |
| 2653 |
@y |
| 2654 |
init for k:=0 to biggest_lang do trie_used[k]:=min_quarterword;@+tini@;@/ |
| 2655 |
k:=biggest_lang+1; |
| 2656 |
@z |
| 2657 |
%--------------------------------------- |
| 2658 |
@x [50] m.1326 l.24100 - Omega |
| 2659 |
dump_int(interaction); dump_int(format_ident); dump_int(69069); |
| 2660 |
tracing_stats:=0 |
| 2661 |
@y |
| 2662 |
dump_int(interaction); dump_int(format_ident); dump_int(69069); |
| 2663 |
set_new_eqtb_int(int_base+tracing_stats_code,0) |
| 2664 |
@z |
| 2665 |
%--------------------------------------- |
| 2666 |
@x [53] m.1341 l.24506 - Omega |
| 2667 |
@d what_lang(#)==link(#+1) {language number, in the range |0..255|} |
| 2668 |
@y |
| 2669 |
@d what_lang(#)==link(#+1) {language number, in the range |0..biggest_lang|} |
| 2670 |
@z |
| 2671 |
%--------------------------------------- |
| 2672 |
@x [53] m.1370 |
| 2673 |
@!write_file:array[0..15] of alpha_file; |
| 2674 |
@y |
| 2675 |
@!outside_string_array: array[0..1000] of 0..255; |
| 2676 |
@!write_file:array[0..15] of alpha_file; |
| 2677 |
@z |
| 2678 |
%--------------------------------------- |
| 2679 |
@x [53] m. l.24761 - Omega |
| 2680 |
text(end_write):="endwrite"; eq_level(end_write):=level_one; |
| 2681 |
eq_type(end_write):=outer_call; equiv(end_write):=null; |
| 2682 |
@y |
| 2683 |
settext(end_write,"endwrite"); set_eq_level(end_write,level_one); |
| 2684 |
set_eq_type(end_write,outer_call); set_equiv(end_write,null); |
| 2685 |
@z |
| 2686 |
%--------------------------------------- |
| 2687 |
@x [53] m.1376 l.24878 - Omega |
| 2688 |
else if language>255 then l:=0 |
| 2689 |
@y |
| 2690 |
else if language>biggest_lang then l:=0 |
| 2691 |
@z |
| 2692 |
%--------------------------------------- |
| 2693 |
@x [53] m.1377 l.24893 - Omega |
| 2694 |
else if cur_val>255 then clang:=0 |
| 2695 |
@y |
| 2696 |
else if cur_val>biggest_lang then clang:=0 |
| 2697 |
@z |
| 2698 |
%--------------------------------------- |
| 2699 |
@x [54] |
| 2700 |
This section should be replaced, if necessary, by any special |
| 2701 |
modifications of the program |
| 2702 |
that are necessary to make \TeX\ work at a particular installation. |
| 2703 |
It is usually best to design your change file so that all changes to |
| 2704 |
previous sections preserve the section numbering; then everybody's version |
| 2705 |
will be consistent with the published program. More extensive changes, |
| 2706 |
which introduce new sections, can be inserted here; then only the index |
| 2707 |
itself will get a new section number. |
| 2708 |
@^system dependencies@> |
| 2709 |
|
| 2710 |
@y |
| 2711 |
@* \[54] $\Omega$ changes. |
| 2712 |
|
| 2713 |
@z |
| 2714 |
%--------------------------------------- |