texcommands.h /size: 53 Kb    last modification: 2025-02-21 11:03
1/*
2    See license.txt in the root of this project.
3*/
4
5# ifndef LMT_COMMANDS_H
6# define LMT_COMMANDS_H
7
8/*tex
9
10    Before we can go any further, we need to define symbolic names for the internal code numbers
11    that represent the various commands obeyed by \TEX. These codes are somewhat arbitrary, but
12    not completely so. For example, the command codes for character types are fixed by the
13    language, since a user says, e.g., |\catcode `\$ = 3| to make |\char'44| a math delimiter,
14    and the command code |math_shift| is equal to~3. Some other codes have been made adjacent so
15    that |case| statements in the program need not consider cases that are widely spaced, or so
16    that |case| statements can be replaced by |if| statements.
17
18    At any rate, here is the list, for future reference. First come the catcode commands, several
19    of which share their numeric codes with ordinary commands when the catcode cannot emerge from
20    \TEX's scanning routine.
21
22    Next are the ordinary run-of-the-mill command codes. Codes that are |min_internal| or more
23    represent internal quantities that might be expanded by |\the|.
24
25    The next codes are special; they all relate to mode-independent assignment of values to \TEX's
26    internal registers or tables. Codes that are |max_internal| or less represent internal
27    quantities that might be expanded by |\the|.
28
29    There is no matching primitive to go with |assign_attr|, but even if there was no
30    |\attributedef|, a reserved number would still be needed because there is an implied
31    correspondence between the |assign_xxx| commands and |xxx_val| expression values. That would
32    break down otherwise.
33
34    The remaining command codes are extra special, since they cannot get through \TEX's scanner to
35    the main control routine. They have been given values higher than |max_command| so that their
36    special nature is easily discernible. The expandable commands come first.
37
38    The extensions on top of standard \TEX\ came with extra |cmd| categories so at some point it
39    make sense to normalize soms of that. Similar commands became one category. Some more could be
40    combined, like rules and move etc.\ but for now it makes no sense. We could also move the mode
41    tests to the runners and make the main lookup simpler. Some commands need their own category
42    because they also can bind to characters (like super and subscript).
43
44    Because much now uses |last_item_cmd| this one has been renamed to the more neutral
45    |some_item_cmd|.
46
47    Watch out: check |command_names| in |lmttokenlib.c| after adding cmd's as these need to be in
48    sync.
49
50    Maybe we should use |box_property|, |font property| and |page property| instead if the now
51    split ones. Actually we should drop setting font dimensions.
52
53    todo: some codes -> subtypes (when not related to commands)
54
55*/
56
57/*tex
58
59    Some commands are shared, for instance |car_ret_cmd| is never seen in a token list so it can be
60    used for signaling a parameter: |out_param_cmd| in a macro body. These constants relate to the
61    21 bit shifting in token properties!
62
63    These two are for nicer syntax highlighting in visual studio code or any IDE that is clever
64    enough to recognize enumerations. Otherwise they would get the color of a macro.
65
66    \starttyping
67    # define escape_cmd        relax_cmd
68    # define out_param_cmd     car_ret_cmd
69    # define end_template_cmd  ignore_cmd
70    # define active_char_cmd   par_end_cmd
71    # define match_cmd         par_end_cmd
72    # define comment_cmd       stop_cmd
73    # define end_match_cmd     stop_cmd
74    # define invalid_char_cmd  delimiter_num_cmd
75    \stoptyping
76
77    In the end sharing these command codes (as regular \TEX\ does) with character codes is not worth
78    the trouble because it gives fuzzy cmd codes in the \LUA\ token interface (and related tracing)
79    so at the cost of some extra slots they now are unique. The |foo_token| macros have to match the
80    cmd codes! Be aware that you need to map the new cmd names onto the original ones when you
81    consult the \TEX\ program source.
82
83    As a consequence of having more commands, the need to be distinctive in the \LUA\ token interface,
84    some commands have been combined (at the cost of a little overhead in testing chr codes). Some
85    names have been made more generic as a side effect but the principles remain the same. Sorry for
86    any introduced confusion.
87
88    An example of where some cmd codes were collapsed is alignments: |\omit|, |\span|, |\noalign|,
89    |\cr| and |\crcr| are now all handled by one cmd/chr code combination. This might make it a bit
90    easier to extend alignments when we're at it because it brings some code and logic together (of
91    course the principles are the same, but there can be slight differences in the way errors are
92    reported).
93
94    Comment: experimental |string_cmd| has been removed, as we now have |\constant| flagged macros.
95*/
96
97
98/*tex
99    In the future we can add classifications that tell what to pick up in which case we can also
100    have generic handlers that take arguments but I need to check first what that does with
101    performance at the \TEX\ end.
102*/
103
104typedef enum code_classifications {
105    classification_no_arguments = 0,
106    classification_unknown      = 1,
107    classification_integer      = 2,
108} code_classifications;
109
110typedef enum tex_command_code {
111    /*tex
112        The first 16 command codes are used for characters with a special meaning. In traditional
113        \TEX\ some have different names and also aliases. Because we have a public token interface
114        they now are uniquely used for characters and the aliases have their own cmd/chr codes.
115    */
116    escape_cmd,                       /*tex  0: escape delimiter*/
117    left_brace_cmd,                   /*tex  1: beginning of a group */
118    right_brace_cmd,                  /*tex  2: ending of a group */
119    math_shift_cmd,                   /*tex  3: mathematics shift character */
120    alignment_tab_cmd,                /*tex  4: alignment delimiter */
121    end_line_cmd,                     /*tex  5: end of line */
122    parameter_cmd,                    /*tex  6: macro parameter symbol */
123    superscript_cmd,                  /*tex  7: superscript */
124    subscript_cmd,                    /*tex  8: subscript */
125    ignore_cmd,                       /*tex  9: characters to ignore */
126    spacer_cmd,                       /*tex 10: characters equivalent to blank space */
127    letter_cmd,                       /*tex 11: characters regarded as letters */
128    other_char_cmd,                   /*tex 12: none of the special character types */
129    active_char_cmd,                  /*tex 13: characters that invoke macros */
130    comment_cmd,                      /*tex 14: characters that introduce comments */
131    invalid_char_cmd,                 /*tex 15: characters that shouldn't appear (|^^|) */
132    /*tex
133        The next set of commands is handled in the big switch where interpretation depends
134        on the current mode. It is a chicken or egg choice: either we have one runner per
135        command in which the mode is chosen, or we have a runner for each mode. The later is
136        used in \TEX.
137    */
138    relax_cmd,                        /*tex do nothing (|\relax|) */
139    end_template_cmd,                 /*tex end of |v_j| list in alignment template */
140    alignment_cmd,                    /*tex |\cr|, |\crcr| and |\span| */
141    match_cmd,                        /*tex match a macro parameter */
142    end_match_cmd,                    /*tex end of parameters to macro */
143    parameter_reference_cmd,          /*tex the value passed as parameter */
144 /* parameter_relative_cmd,        */ /*tex discarded experiment: too ugly, reference to parent parameters |#-XX| */
145    end_paragraph_cmd,                /*tex end of paragraph (|\par|) */
146    end_job_cmd,                      /*tex end of job (|\end|, |\dump|) */
147    delimiter_number_cmd,             /*tex specify delimiter numerically (|\delimiter|) */
148    char_number_cmd,                  /*tex character specified numerically (|\char|) */
149    math_char_number_cmd,             /*tex explicit math code (|mathchar} ) */
150    mark_cmd,                         /*tex mark definition (|mark|) */
151    node_cmd,                         /*tex a node injected via \LUA */
152    xray_cmd,                         /*tex peek inside of \TEX\ (|\show|, |\showbox|, etc.) */
153    mvl_cmd,
154    make_box_cmd,                     /*tex make a box (|\box|, |\copy|, |\hbox|, etc.) */
155    hmove_cmd,                        /*tex horizontal motion (|\moveleft|, |\moveright|) */
156    vmove_cmd,                        /*tex vertical motion (|\raise|, |\lower|) */
157    un_hbox_cmd,                      /*tex unglue a box (|\unhbox|, |\unhcopy|) */
158    un_vbox_cmd,                      /*tex unglue a box (|\unvbox|, |\unvcopy|, |\pagediscards|, |\splitdiscards|) */
159    remove_item_cmd,                  /*tex nullify last item (|\unpenalty|, |\unkern|, |\unskip|) */
160    hskip_cmd,                        /*tex horizontal glue (|\hskip|, |\hfil|, etc.) */
161    vskip_cmd,                        /*tex vertical glue (|\vskip|, |\vfil|, etc.) */
162    mskip_cmd,                        /*tex math glue (|\mskip|) */
163    kern_cmd,                         /*tex fixed space (|\kern|) */
164    mkern_cmd,                        /*tex math kern (|\mkern|) */
165    leader_cmd,                       /*tex all these |\leaders| */
166    legacy_cmd,                       /*tex obsolete |\shipout|,etc.) */
167    local_box_cmd,                    /*tex use a box (|\localleftbox|, etc.) */
168    halign_cmd,                       /*tex horizontal table alignment (|\halign|) */
169    valign_cmd,                       /*tex vertical table alignment (|\valign|) */
170    vrule_cmd,                        /*tex vertical rule (|\vrule|, etc.) */
171    hrule_cmd,                        /*tex horizontal rule (|\hrule|. etc.) */
172    insert_cmd,                       /*tex vlist inserted in box (|\insert|) */
173    vadjust_cmd,                      /*tex vlist inserted in enclosing paragraph (|\vadjust|) */
174    ignore_something_cmd,             /*tex gobble |spacer| tokens (|\ignorespaces|) */
175    after_something_cmd,              /*tex save till assignment or group is done (|\after*|) */
176    penalty_cmd,                      /*tex additional badness (|\penalty|) */
177    begin_paragraph_cmd,              /*tex (begin) paragraph (|\indent|, |\noindent|) */
178    italic_correction_cmd,            /*tex italic correction (|/|) */
179    accent_cmd,                       /*tex attach accent in text (|\accent|) */
180    math_accent_cmd,                  /*tex attach accent in math (|\mathaccent|) */
181    discretionary_cmd,                /*tex discretionary texts (|-|, |\discretionary|) */
182    equation_number_cmd,              /*tex equation number (|\eqno|, |\leqno|) */
183    math_fence_cmd,                   /*tex variable delimiter (|\left|, |\right| or |\middle|) part of a fence */
184    math_component_cmd,               /*tex component of formula (|\mathbin|, etc.) */
185    math_modifier_cmd,                /*tex limit conventions (|\displaylimits|, etc.) */
186    math_fraction_cmd,                /*tex generalized fraction (|\above|, |\atop|, etc.) */
187    math_choice_cmd,                  /*tex choice specification (|\mathchoice|) */
188    vcenter_cmd,                      /*tex vertically center a vbox (|\vcenter|) */
189    case_shift_cmd,                   /*tex force specific case (|\lowercase|, |\uppercase|) */
190    message_cmd,                      /*tex send to user (|\message|, |\errmessage|) */
191    catcode_table_cmd,                /*tex manipulators for catcode tables */
192    end_local_cmd,                    /*tex finishes a |local_cmd| */
193    lua_function_call_cmd,            /*tex an expandable function call */
194    lua_protected_call_cmd,           /*tex a function call that doesn's expand in edef like situations */
195    lua_semi_protected_call_cmd,
196    begin_group_cmd,                  /*tex begin local grouping (|\begingroup|) */
197    end_group_cmd,                    /*tex end local grouping (|\endgroup|) */
198    explicit_space_cmd,               /*tex explicit space (|\ |) */
199    boundary_cmd,                     /*tex insert boundry node with value (|\*boundary|) */
200    math_radical_cmd,                 /*tex square root and similar signs (|\radical|) */
201    math_script_cmd,                  /*tex explicit super- or subscript */
202    math_shift_cs_cmd,                /*tex start- and endmath */
203    end_cs_name_cmd,                  /*tex end control sequence (|\endcsname|) */
204    /*tex
205        The next set can come after |\the| so they are either handled in the big switch or
206        during expansion of this serializer prefix.
207    */
208    char_given_cmd,                   /*tex character code defined by |\chardef| */
209    some_item_cmd,                    /*tex most recent item (|\lastpenalty|, |\lastkern|, |\lastskip| and more) */
210    /*tex
211       The previous command was described as \quotation {the last that cannot be prefixed by
212       |\global|} which is not entirely true any more. Actually more accurate is that the next
213       bunch can be prefixed and that's a mixed bag. It is used in |handle_assignments| which
214       deals with assignments in some special cases.
215    */
216    internal_toks_cmd,                /*tex special token list (|\output|, |\everypar|, etc.) */
217    register_toks_cmd,                /*tex user defined token lists */
218    internal_integer_cmd,             /*tex integer (|\tolerance|, |\day|, etc.) */
219    register_integer_cmd,             /*tex user-defined integers */
220    internal_attribute_cmd,           /*tex */
221    register_attribute_cmd,           /*tex user-defined attributes */
222    internal_posit_cmd,
223    register_posit_cmd,
224    internal_dimension_cmd,           /*tex length (|\hsize|, etc.) */
225    register_dimension_cmd,           /*tex user-defined dimensions */
226    internal_glue_cmd,                /*tex glue (|\baselineskip|, etc.) */
227    register_glue_cmd,                /*tex user-defined glue */
228    internal_muglue_cmd,              /*tex */
229    register_muglue_cmd,              /*tex user-defined math glue */
230    lua_value_cmd,                    /*tex reference to a regular lua function */
231    iterator_value_cmd,               /*tex prefixes make no sense here (yet) */
232    font_property_cmd,                /*tex user-defined font integer (|\hyphenchar|, |\skewchar|) or (|\fontdimen|)  */
233    auxiliary_cmd,                    /*tex state info (|\spacefactor|, |\prevdepth|) */
234    hyphenation_cmd,                  /*tex hyphenation data (|\hyphenation|, |\patterns|) */
235    page_property_cmd,                /*tex page info (|\pagegoal|, etc.) */
236    box_property_cmd,                 /*tex change property of box (|\wd|, |\ht|, |\dp|) */
237    specification_cmd,                /*tex specifications (|\parshape|, |\interlinepenalties|, etc.) */
238    define_char_code_cmd,             /*tex define a character code (|\catcode|, etc.) */
239    define_family_cmd,                /*tex declare math fonts (|\textfont|, etc.) */
240    math_parameter_cmd,               /*tex set math parameters (|\mathquad|, etc.) */
241    math_style_cmd,                   /*tex style specification (|\displaystyle|, etc.) */
242    set_font_cmd,                     /*tex set current font (font identifiers) */
243    define_font_cmd,                  /*tex define a font file (|\font|) */
244    integer_cmd,                      /*tex the equivalent is a halfword number */
245    posit_cmd,
246    dimension_cmd,                    /*tex the equivalent is a halfword number representing a dimension */
247    gluespec_cmd,                     /*tex the equivalent is a halfword reference to glue */
248    mugluespec_cmd,                   /*tex the equivalent is a halfword reference to glue with math units */
249    index_cmd,                        /*tex references a parameter, works with (|\parameterdef|) */
250    mathspec_cmd,
251    fontspec_cmd,
252    specificationspec_cmd,
253    association_cmd,
254# if (match_experiment)
255integer_reference_cmd,
256dimension_reference_cmd,
257# endif
258    interaction_cmd,                  /*tex define level of interaction (|\batchmode|, etc.) */ /* valid after |\the|, see ** */
259    register_cmd,                     /*tex internal register (|\count|, |\dimen|, etc.) */
260    /*tex
261        That was the last command that could follow |\the|.
262    */
263    combine_toks_cmd,                 /*tex the |toksapp| and similar token (list) combiners */
264    arithmic_cmd,                     /*tex |\advance|, |\multiply|, |\divide|, ... */
265    prefix_cmd,                       /*tex qualify a definition (|\global|, |\long|, |\outer|) */
266    let_cmd,                          /*tex assign a command code (|\let|, |\futurelet|) */
267    shorthand_def_cmd,                /*tex code definition (|\chardef|, |\countdef|, etc.) */
268    def_cmd,                          /*tex macro definition (|\def|, |\gdef|, |\xdef|, |\edef|) */
269 /* interaction_cmd,               */ /*tex define level of interaction (|\batchmode|, etc.) */ /* invalid after |\the|,  see ** */
270    set_box_cmd,                      /*tex set a box (|\setbox|) */
271    /*tex
272        Here ends the section that is part of the big switch.  What follows are commands that are
273        intercepted when expanding tokens. The |string_cmd| came from a todo list and moved to a
274        maybe list and finally became obsolete.
275    */
276    undefined_cs_cmd,                 /*tex initial state of most |eq_type| fields */
277    expand_after_cmd,                 /*tex special expansion (|\expandafter|) */
278    no_expand_cmd,                    /*tex special nonexpansion (|\noexpand|) */
279    input_cmd,                        /*tex input a source file (|\input|, |\endinput| or |\scantokens| or |\scantextokens|) */
280    lua_call_cmd,                     /*tex a reference to a \LUA\ function */
281    lua_local_call_cmd,               /*tex idem, but in a nested main loop */
282    begin_local_cmd,                  /*tex enter a a nested main loop */
283    if_test_cmd,                      /*tex conditional text (|\if|, |\ifcase|, etc.) */
284    cs_name_cmd,                      /*tex make a control sequence from tokens (|\csname|) */
285    convert_cmd,                      /*tex convert to text (|\number|, |\string|, etc.) */
286    the_cmd,                          /*tex expand an internal quantity (|\the| or |\unexpanded|, |\detokenize|) */
287    get_mark_cmd,                     /*tex inserted mark (|\topmark|, etc.) */
288    /*tex
289        These refer to macros. We might at some point promote the tolerant ones to have their own
290        cmd codes. Protected macros were done with an initial token signaling that property but
291        they became |protected_call_cmd|. After that we also got two frozen variants and later four
292        tolerant so we ended up with eight. When I wanted some more, a different solution was
293        chosen, so now we have just one again instead of |[tolerant_][frozen_][protected_]call_cmd|.
294        But ... in the end I setteled again for four basic call commands because it's nicer in
295        the token interface.
296
297        The todo cmds come from a todo list and relate to |\expand| but then like \expand{...} even
298        when normally it's protected. But it adds overhead we don't want right now an din the end I
299        didn't need it. I keep it as reference so that I won't recycle it.
300
301    */
302    call_cmd,                         /*tex regular control sequence */
303    protected_call_cmd,               /*tex idem but doesn't expand in edef like situations */
304    semi_protected_call_cmd,
305    constant_call_cmd,
306    tolerant_call_cmd,                /*tex control sequence with tolerant arguments */
307    tolerant_protected_call_cmd,      /*tex idem but doesn't expand in edef like situations */
308    tolerant_semi_protected_call_cmd,
309    /*tex
310        These are special and are inserted in token streams. They cannot end up in macros.
311    */
312    deep_frozen_end_template_cmd,     /*tex end of an alignment template */
313    deep_frozen_dont_expand_cmd,      /*tex the following token was marked by |\noexpand|) */
314    deep_frozen_keep_constant_cmd,
315    /*tex
316        The next bunch is never seen directly as they are shortcuts to registers and special data
317        strutures. They  are the internal register (pseudo) commands and are also needed for
318        token and node memory management.
319    */
320    internal_glue_reference_cmd,      /*tex the equivalent points to internal glue specification */
321    register_glue_reference_cmd,      /*tex the equivalent points to register glue specification */
322    internal_muglue_reference_cmd,    /*tex the equivalent points to internal muglue specification */
323    register_muglue_reference_cmd,    /*tex the equivalent points to egister muglue specification */
324    internal_box_reference_cmd,       /*tex the equivalent points to internal box node, or is |null| */
325    register_box_reference_cmd,       /*tex the equivalent points to register box node, or is |null| */
326    internal_toks_reference_cmd,      /*tex the equivalent points to internal token list */
327    register_toks_reference_cmd,      /*tex the equivalent points to register token list */
328    specification_reference_cmd,      /*tex the equivalent points to parshape or penalties specification */
329    unit_reference_cmd,
330    /*
331        We don't really need these but they are used to flag the registers eq entries properly. They
332        are not really references because the values are included but we want to be consistent here.
333    */
334    internal_integer_reference_cmd,
335    register_integer_reference_cmd,
336    internal_attribute_reference_cmd,
337    register_attribute_reference_cmd,
338    internal_posit_reference_cmd,
339    register_posit_reference_cmd,
340    internal_dimension_reference_cmd,
341    register_dimension_reference_cmd,
342    /*tex
343        This is how many commands we have:
344    */
345    number_tex_commands,
346} tex_command_code;
347
348# define max_char_code_cmd    invalid_char_cmd       /*tex largest catcode for individual characters */
349# define min_internal_cmd     char_given_cmd         /*tex the smallest code that can follow |the| */
350# define max_non_prefixed_cmd some_item_cmd          /*tex largest command code that can't be |global| */
351# define max_internal_cmd     register_cmd           /*tex the largest code that can follow |the| */
352# define max_command_cmd      (undefined_cs_cmd - 1) /*tex the largest command code seen at |big_switch| */
353
354# define first_cmd            escape_cmd
355# define last_cmd             register_dimension_reference_cmd
356
357# define first_call_cmd       call_cmd
358# define last_call_cmd        tolerant_semi_protected_call_cmd
359
360# define last_visible_cmd     tolerant_semi_protected_call_cmd
361
362# define is_call_cmd(cmd)           (cmd >= first_call_cmd && cmd <= last_call_cmd)
363# define is_protected_cmd(cmd)      (cmd == protected_call_cmd || cmd == tolerant_protected_call_cmd)
364# define is_semi_protected_cmd(cmd) (cmd == semi_protected_call_cmd || cmd == tolerant_semi_protected_call_cmd)
365# define is_tolerant_cmd(cmd)       (cmd == tolerant_call_cmd || cmd == tolerant_protected_call_cmd || cmd == tolerant_semi_protected_call_cmd)
366
367# define is_referenced_cmd(cmd)     (cmd >= call_cmd)
368# define is_nodebased_cmd(cmd)      (cmd >= gluespec_cmd && cmd <= specificationspec_cmd)
369# define is_constant_cmd(cmd)       ((cmd >= integer_cmd && cmd <= gluespec_cmd) || cmd == constant_call_cmd)
370
371/*tex Once these were different numbers, no series (see archive): */
372
373typedef enum tex_modes {
374    nomode           =  0,
375    vmode            =  1,
376    hmode            =  2,
377    mmode            =  3,
378    internal_vmode   = -1,
379    restricted_hmode = -2,
380    inline_mmode     = -3,
381} tex_modes;
382
383static inline int is_v_mode(halfword mode) { return mode == vmode || mode == internal_vmode; }
384static inline int is_h_mode(halfword mode) { return mode == hmode || mode == restricted_hmode; }
385static inline int is_m_mode(halfword mode) { return mode == mmode || mode == inline_mmode; }
386
387static inline int tex_normalized_mode(halfword mode)
388{
389    switch (mode) {
390        case internal_vmode  : return vmode;
391        case restricted_hmode: return hmode;
392        case inline_mmode    : return mmode;
393        default              : return mode;
394    }
395}
396
397typedef enum arithmic_codes {
398    advance_code,
399    advance_by_code,
400    multiply_code,
401    multiply_by_code,
402    divide_code,
403    e_divide_code,
404    r_divide_code,
405    divide_by_code,
406    e_divide_by_code,
407    r_divide_by_code,
408 /* bitwise_and_code, */
409 /* bitwise_xor_code, */
410 /* bitwise_or_code,  */
411 /* bitwise_not_code, */
412 /* advance_by_plus_one_code,  */
413 /* advance_by_minus_one_code, */
414} arithmic_codes;
415
416# define last_arithmic_code r_divide_code
417
418typedef enum math_script_codes {
419    /* It's a bit strange to have this here but both inject a control glue. */
420    math_no_script_space_code,
421    math_no_ruling_space_code,
422    /* */
423    math_sub_script_code,
424    math_super_script_code,
425    math_super_pre_script_code,
426    math_sub_pre_script_code,
427    math_no_sub_script_code,
428    math_no_super_script_code,
429    math_no_sub_pre_script_code,
430    math_no_super_pre_script_code,
431    math_indexed_sub_script_code,
432    math_indexed_super_script_code,
433    math_indexed_sub_pre_script_code,
434    math_indexed_super_pre_script_code,
435    math_prime_script_code,
436    math_no_script_code,
437} math_script_codes;
438
439# define last_math_script_code math_no_script_code
440
441typedef enum math_fraction_codes {
442    math_above_code,
443    math_above_delimited_code,
444    math_over_code,
445    math_over_delimited_code,
446    math_atop_code,
447    math_atop_delimited_code,
448    math_u_above_code,
449    math_u_above_delimited_code,
450    math_u_over_code,
451    math_u_over_delimited_code,
452    math_u_atop_code,
453    math_u_atop_delimited_code,
454    math_u_skewed_code,
455    math_u_skewed_delimited_code,
456    math_u_stretched_code,
457    math_u_stretched_delimited_code,
458} math_fraction_codes;
459
460# define last_math_fraction_code math_u_skewed_code
461
462/*tex
463    These don't fit into the internal register model because they are for instance global or
464    bound to the current list.
465*/
466
467typedef enum auxiliary_codes {
468    space_factor_code,
469    prev_depth_code,
470    prev_graf_code,
471    interaction_mode_code,
472    insert_mode_code,
473} auxiliary_codes;
474
475# define last_auxiliary_code insert_mode_code
476
477typedef enum convert_codes {
478    number_code,              /*tex command code for |\number| */
479    to_integer_code,          /*tex command code for |\tointeger| (also gobbles |\relax|) */
480    to_hexadecimal_code,      /*tex command code for |\tohexadecimal| */
481    to_scaled_code,           /*tex command code for |\toscaled| (also gobbles |\relax|) */
482    to_sparse_scaled_code,    /*tex command code for |\tosparsescaled| (also gobbles |\relax|) */
483    to_dimension_code,        /*tex command code for |\todimension| (also gobbles |\relax|) */
484    to_sparse_dimension_code, /*tex command code for |\tosparsedimension| */
485    to_mathstyle_code,        /*tex command code for |\tomathstyle| */
486    lua_code,                 /*tex command code for |\directlua| */
487    lua_function_code,        /*tex command code for |\luafunction| */
488    lua_bytecode_code,        /*tex command code for |\luabytecode| */
489    expanded_code,            /*tex command code for |\expanded| */
490    semi_expanded_code,       /*tex command code for |\constantexpanded| */
491 /* expanded_after_cs_code,   */
492    string_code,              /*tex command code for |\string| */
493    cs_string_code,           /*tex command code for |\csstring| */
494    cs_active_code,           /*tex command code for |\csactive| */
495    cs_lastname_code,         /*tex command code for |\cslastname| */
496    detokenized_code,         /*tex command code for |\detokenized| */
497    detokened_code,           /*tex command code for |\detokened| */
498    roman_numeral_code,       /*tex command code for |\romannumeral| */
499    meaning_code,             /*tex command code for |\meaning| */
500    meaning_full_code,        /*tex command code for |\meaningfull| */
501    meaning_less_code,        /*tex command code for |\meaningless| */
502    meaning_asis_code,        /*tex command code for |\meaningasis| */
503    meaning_ful_code,         /*tex command code for |\meaningful| */
504    meaning_les_code,         /*tex command code for |\meaningles| */
505    to_character_code,        /*tex command code for |\Uchar| */
506    lua_escape_string_code,   /*tex command code for |\luaescapestring| */
507 /* lua_token_string_code, */ /*tex command code for |\luatokenstring| */
508    font_name_code,           /*tex command code for |\fontname| */
509    font_specification_code,  /*tex command code for |\fontspecification| */
510    job_name_code,            /*tex command code for |\jobname| */
511    format_name_code,         /*tex command code for |\AlephVersion| */
512    luatex_banner_code,       /*tex command code for |\luatexbanner| */
513    font_identifier_code,     /*tex command code for |tex.fontidentifier| (virtual) */
514} convert_codes;
515
516extern const unsigned char some_convert_classification[font_identifier_code+1];
517
518# define first_convert_code number_code
519# define last_convert_code  luatex_banner_code
520
521/*tex
522    At some point we might make |token_input_code| behave like |tex_token_input_code| and get rid
523    of |\everyeof| which is a quite useless feature that does more harm than good.
524*/
525
526typedef enum input_codes {
527    normal_input_code,
528    eof_input_code,
529    end_of_input_code,
530    token_input_code,
531    tex_token_input_code,
532    tokenized_code,
533    retokenized_code,
534 /* quit_fi_now_code, */ /*tex only for performance testing */
535    quit_loop_code,
536    quit_loop_now_code,
537} input_codes;
538
539# define last_input_code quit_loop_now_code
540
541typedef enum mvl_codes {
542    begin_mvl_code,
543    end_mvl_code,
544} mvl_codes;
545
546# define last_mvl_code end_mvl_code
547
548typedef enum some_item_codes {
549    lastpenalty_code,              /*tex |\lastpenalty| */
550    lastkern_code,                 /*tex |\lastkern| */
551    lastskip_code,                 /*tex |\lastskip| */
552    lastboundary_code,             /*tex |\lastboundary| */
553    last_node_type_code,           /*tex |\lastnodetype| */
554    last_node_subtype_code,        /*tex |\lastnodesubtype| */
555    input_line_no_code,            /*tex |\inputlineno| */
556    badness_code,                  /*tex |\badness| */
557    overshoot_code,                /*tex |\overshoot| */
558    luametatex_major_version_code, /*tex |\luametatexversion| */
559    luametatex_minor_version_code, /*tex |\luametatexrevision| */
560    luametatex_release_code,       /*tex |\luametatexrelease| */
561    luatex_version_code,           /*tex |\luatexversion| (old) */
562    luatex_revision_code,          /*tex |\luatexrevision| (old) */
563    current_group_level_code,      /*tex |\currentgrouplevel| */
564    current_group_type_code,       /*tex |\currentgrouptype| */
565    current_stack_size_code,       /*tex |\currentstacksize| */
566    current_if_level_code,         /*tex |\currentiflevel| */
567    current_if_type_code,          /*tex |\currentiftype| */
568    current_if_branch_code,        /*tex |\currentifbranch| */
569    glue_stretch_order_code,       /*tex |\gluestretchorder| */
570    glue_shrink_order_code,        /*tex |\glueshrinkorder| */
571    font_id_code,                  /*tex |\fontid| */
572    glyph_x_scaled_code,           /*tex |\glyphxscaled| */
573    glyph_y_scaled_code,           /*tex |\glyphyscaled| */
574    font_char_wd_code,             /*tex |\fontcharwd| */
575    font_char_ht_code,             /*tex |\fontcharht| */
576    font_char_dp_code,             /*tex |\fontchardp| */
577    font_char_ic_code,             /*tex |\fontcharic| */
578    font_char_ta_code,             /*tex |\fontcharta| */
579    font_char_ba_code,             /*tex |\fontcharba| */
580    scaled_font_char_wd_code,      /*tex |\scaledfontcharwd| */
581    scaled_font_char_ht_code,      /*tex |\scaledfontcharht| */
582    scaled_font_char_dp_code,      /*tex |\scaledfontchardp| */
583    scaled_font_char_ic_code,      /*tex |\scaledfontcharic| */
584    scaled_font_char_ta_code,      /*tex |\scaledfontcharta| */
585    scaled_font_char_ba_code,      /*tex |\scaledfontcharba| */
586    font_spec_id_code,             /*tex |\fontspecid| */
587    font_spec_scale_code,          /*tex |\fontspecscale| */
588    font_spec_xscale_code,         /*tex |\fontspecxscale| */
589    font_spec_yscale_code,         /*tex |\fontspecyscale| */
590    font_spec_slant_code,          /*tex |\fontspecslant| */
591    font_spec_weight_code,         /*tex |\fontspecweight| */
592    font_size_code,                /*tex |\fontsize| */
593    font_math_control_code,        /*tex |\fontmathcontrol| */
594    font_text_control_code,        /*tex |\fonttextcontrol| */
595    math_scale_code,               /*tex |\mathscale| */
596    math_style_code,               /*tex |\mathstyle| */
597    math_main_style_code,          /*tex |\mathmainstyle| */
598    math_parent_style_code,        /*tex |\mathparentstyle| */
599    math_style_font_id_code,       /*tex |\mathstylefontid| */
600    math_stack_style_code,         /*tex |\mathstackstyle| */
601    math_char_class_code,          /*tex |\Umathcharclass| */
602    math_char_fam_code,            /*tex |\Umathcharfam| */
603    math_char_slot_code,           /*tex |\Umathcharslot| */
604    scaled_slant_per_point_code,
605    scaled_interword_space_code,
606    scaled_interword_stretch_code,
607    scaled_interword_shrink_code,
608    scaled_ex_height_code,
609    scaled_em_width_code,
610    scaled_extra_space_code,
611    scaled_math_axis_code,
612    scaled_math_ex_height_code,
613    scaled_math_em_width_code,
614    last_arguments_code,        /*tex |\lastarguments| */
615    parameter_count_code,       /*tex |\parametercount| */
616    parameter_index_code,       /*tex |\parametercount| */
617 /* lua_value_function_code, */ /*tex |\luavaluefunction| */
618    insert_progress_code,       /*tex |\insertprogress| */
619    left_margin_kern_code,      /*tex |\leftmarginkern| */
620    right_margin_kern_code,     /*tex |\rightmarginkern| */
621    par_shape_length_code,      /*tex |\parshapelength| */
622    par_shape_indent_code,      /*tex |\parshapeindent| */
623    par_shape_width_code,       /*tex |\parshapewidth| */
624    balance_shape_vsize_code,
625    balance_shape_top_space_code,
626    balance_shape_bottom_space_code,
627    glue_stretch_code,          /*tex |\gluestretch| */
628    glue_shrink_code,           /*tex |\glueshrink| */
629    mu_to_glue_code,            /*tex |\mutoglue| */
630    glue_to_mu_code,            /*tex |\gluetomu| */
631    numexpr_code,               /*tex |\numexpr| */
632    posexpr_code,
633 /* attrexpr_code, */           /*tex not used */
634    dimexpr_code,               /*tex |\dimexpr| */
635    glueexpr_code,              /*tex |\glueexpr| */
636    muexpr_code,                /*tex |\muexpr| */
637    numexpression_code,         /*tex |\numexpression| */
638    dimexpression_code,         /*tex |\dimexpression| */
639    numexperimental_code,       /*tex |\numexperimental| */
640    dimexperimental_code,       /*tex |\dimexperimental| */
641    last_chk_integer_code,      /*tex |\ifchkinteger| */
642    last_chk_dimension_code,    /*tex |\ifchkdimension| */
643 // dimen_to_scale_code,        /*tex |\dimentoscale| */
644    numeric_scale_code,         /*tex |\numericscale| */
645    numeric_scaled_code,        /*tex |\numericscaled| */
646    index_of_register_code,
647    index_of_character_code,
648    math_atom_glue_code,
649    last_left_class_code,
650    last_right_class_code,
651    last_atom_class_code,
652    nested_loop_iterator_code,
653    previous_loop_iterator_code,
654    current_loop_iterator_code,
655    current_loop_nesting_code,
656    last_loop_iterator_code,
657    last_par_trigger_code,
658    last_par_context_code,
659    last_page_extra_code,
660} some_item_codes;
661
662extern const unsigned char some_item_classification[last_page_extra_code+1];
663
664# define last_some_item_code last_page_extra_code
665
666typedef enum catcode_table_codes {
667    save_cat_code_table_code,
668    restore_cat_code_table_code,
669    init_cat_code_table_code,
670 /* dflt_cat_code_table_code, */
671} catcode_table_codes;
672
673# define last_catcode_table_code init_cat_code_table_code
674
675typedef enum font_property_codes {
676    font_hyphen_code,
677    font_skew_code,
678    font_lp_code,
679    font_rp_code,
680    font_ef_code,
681    font_cf_code,
682    font_dimension_code,
683    scaled_font_dimension_code,
684} font_property_codes;
685
686# define last_font_property_code scaled_font_dimension_code
687
688typedef enum box_property_codes {
689    box_width_code,
690    box_height_code,
691    box_depth_code,
692    box_direction_code,
693    box_geometry_code,
694    box_orientation_code,
695    box_anchor_code,
696    box_anchors_code,
697    box_source_code,
698    box_target_code,
699    box_xoffset_code,
700    box_yoffset_code,
701    box_xmove_code,
702    box_ymove_code,
703    box_total_code,
704    box_shift_code,
705    box_adapt_code,
706    box_repack_code,
707    box_freeze_code,
708    box_migrate_code,
709    box_limitate_code,
710    box_finalize_code,
711    box_limit_code,
712    box_stretch_code,
713    box_shrink_code,
714    box_subtype_code,
715    /* we actually need set_box_int_cmd, or set_box_property */
716    box_attribute_code,
717    box_vadjust_code,
718    box_inserts_code,
719} box_property_codes;
720
721# define last_box_property_code box_inserts_code
722
723typedef enum hyphenation_codes {
724    hyphenation_code,
725    patterns_code,
726    prehyphenchar_code,
727    posthyphenchar_code,
728    preexhyphenchar_code,
729    postexhyphenchar_code,
730    hyphenationmin_code,
731    hjcode_code,
732} hyphenation_codes;
733
734# define last_hyphenation_code hjcode_code
735
736typedef enum begin_paragraph_codes {
737    noindent_par_code,
738    indent_par_code,
739    quitvmode_par_code,
740    undent_par_code,
741    snapshot_par_code,
742    attribute_par_code,
743    options_par_code,
744    wrapup_par_code,
745} begin_paragraph_codes;
746
747# define last_begin_paragraph_code wrapup_par_code
748
749extern void tex_initialize_commands (void);
750
751/*tex
752
753   A |\chardef| creates a control sequence whose |cmd| is |char_given|; a |\mathchardef| creates a
754   control sequence whose |cmd| is |math_given|; and the corresponding |chr| is the character code
755   or math code. A |\countdef| or |\dimendef| or |\skipdef| or |\muskipdef| creates a control
756   sequence whose |cmd| is |assign_int| or \dots\ or |assign_mu_glue|, and the corresponding |chr|
757   is the |eqtb| location of the internal register in question.
758
759    We have the following codes for |shorthand_def|:
760
761*/
762
763typedef enum relax_codes {
764    relax_code,
765    no_relax_code,
766    no_expand_relax_code,
767} relax_codes;
768
769# define last_relax_code no_relax_code
770
771typedef enum end_paragraph_codes {
772    normal_end_paragraph_code,
773    inserted_end_paragraph_code,
774    new_line_end_paragraph_code,
775    local_break_end_paragraph_code,
776} end_paragraph_codes;
777
778# define last_end_paragraph_code local_break_end_paragraph_code
779
780typedef enum shorthand_def_codes {
781    char_def_code,        /*tex |\chardef| */
782    math_char_def_code,   /*tex |\mathchardef| */
783    math_uchar_def_code,  /*tex |\Umathchardef| */
784    math_dchar_def_code,  /*tex |\Umathdictdef| */
785    count_def_code,       /*tex |\countdef| */
786    attribute_def_code,   /*tex |\attributedef| */
787    dimen_def_code,       /*tex |\dimendef| */
788    skip_def_code,        /*tex |\skipdef| */
789    muskip_def_code,      /*tex |\muskipdef| */
790    toks_def_code,        /*tex |\toksdef| */
791    float_def_code,
792    lua_def_code,         /*tex |\luadef| */
793    integer_def_code,
794    dimension_def_code,
795    gluespec_def_code,
796    mugluespec_def_code,
797    posit_def_code,
798    parameter_def_code,
799 /* mathspec_def_code, */
800    fontspec_def_code,
801    specification_def_code,
802 /* integer_def_csname_code,   */
803 /* dimension_def_csname_code, */
804} shorthand_def_codes;
805
806# define last_shorthand_def_code specification_def_code
807
808typedef enum association_codes {
809    unit_association_code,
810} association_codes;
811
812# define last_association_code unit_association_code
813
814typedef enum char_number_codes {
815    char_number_code,  /*tex |\char| */
816    glyph_number_code, /*tex |\glyph| */
817} char_number_codes;
818
819# define last_char_number_code glyph_number_code
820
821typedef enum math_char_number_codes {
822    math_char_number_code,        /*tex |\mathchar| */
823    math_xchar_number_code,       /*tex |\Umathchar| */
824    math_dictionary_number_code,  /*tex |\Umathdictionary| */
825    math_class_number_code,       /*tex |\Umathclass| */
826    math_char_ignore_code,        /*tex |\nomathchar| */
827} math_char_number_codes;
828
829# define last_math_char_number_code math_char_ignore_code
830
831typedef enum xray_codes {
832    show_code,            /*tex |\show| */
833    show_box_code,        /*tex |\showbox| */
834    show_the_code,        /*tex |\showthe| */
835    show_lists_code,      /*tex |\showlists| */
836    show_groups_code,     /*tex |\showgroups| */
837    show_stack_code,      /*tex |\showstack| */
838    show_code_stack_code, /*tex |\showcodestack| */
839    show_tokens_code,     /*tex |\showtokens|, must be odd! */
840    show_ifs_code,        /*tex |\showifs| */
841} xray_codes;
842
843# define last_xray_code show_ifs_code
844
845typedef enum the_codes {
846    the_code,
847    the_without_unit_code,
848 /* the_with_property_code, */ /* replaced by value functions */
849    detokenize_code,
850    expanded_detokenize_code,
851    protected_detokenize_code,
852    protected_expanded_detokenize_code,
853    unexpanded_code,
854} the_codes;
855
856# define last_the_code unexpanded_code
857
858typedef enum expand_after_codes {
859    expand_after_code,
860    expand_unless_code,
861    future_expand_code,       /*tex |token,yes,no|: nicer than future_expand_keep_space_when_no_match*/
862    future_expand_is_code,    /*tex |token,yes,no|: nicer than future_expand_ignore_spaces_code */
863    future_expand_is_ap_code, /*tex |token,yes,no|: nicer than future_expand_ignore_spaces_and_pars_code */
864 /* expand_after_2_code, */
865 /* expand_after_3_code, */
866    expand_after_spaces_code,
867    expand_after_pars_code,
868    expand_token_code,
869    expand_cs_token_code,
870    expand_code,
871    expand_toks_code,
872    expand_active_code,
873    expand_semi_code,
874    expand_after_toks_code,
875    expand_parameter_code,
876 /* expand_after_fi_code, */ /* keep as reference */
877} expand_after_codes;
878
879# define last_expand_after_code expand_parameter_code
880
881typedef enum after_something_codes {
882    after_group_code,
883    after_grouped_code,
884    after_assignment_code,
885    after_assigned_code,
886    at_end_of_group_code,
887    at_end_of_grouped_code,
888    at_end_of_file_code,
889    at_end_of_filed_code,
890} after_something_codes;
891
892# define last_after_something_code at_end_of_filed_code
893
894typedef enum begin_group_codes {
895    semi_simple_group_code,
896    also_simple_group_code,
897    math_simple_group_code,
898} begin_group_codes;
899
900# define last_begin_group_code also_simple_group_code
901
902typedef enum end_job_codes {
903    end_code,
904    dump_code,
905} end_job_codes;
906
907# define last_end_job_code dump_code
908
909typedef enum local_control_codes {
910    local_control_begin_code,
911    local_control_token_code,
912    local_control_list_code,
913    local_control_loop_code,
914    expanded_loop_code,
915    unexpanded_loop_code,
916    local_control_repeat_code,
917    expanded_repeat_code,
918    unexpanded_repeat_code,
919    local_control_endless_code,
920    expanded_endless_code,
921    unexpanded_endless_code,
922} local_control_codes;
923
924# define last_local_control_code unexpanded_endless_code
925
926/*tex
927
928    Maybe also a prefix |\unfrozen| that avoids the warning or have a variant that only issues a
929    warning but then we get 8 more cmd codes and we don't want that. An alternative is to have some
930    bits for this but we don't have enough. Now, because frozen macros can be unfrozen we can
931    indeed have a prefix that bypasses the check. Explicit (re)definitions are then up to the user.
932
933    Constant macros are special in the sense that we set the reference count to the maximum. This is
934    then a signal that we have an expanded macro with a meaning that we can immediately copy into
935    the expanded token list, as in csname construction. This saves some memory access and token
936    allocation.
937
938*/
939
940typedef enum prefix_codes {
941    frozen_code,
942    permanent_code,
943    immutable_code,
944 /* primitive_code, */
945    mutable_code,
946    noaligned_code,
947    instance_code,
948    untraced_code,
949    global_code,
950    tolerant_code,
951    protected_code,
952    overloaded_code,
953    aliased_code,
954    immediate_code,
955    deferred_code,
956 /* conditional_code */
957 /* value_code */
958    semiprotected_code,
959    enforced_code,
960    always_code,
961    inherited_code,
962    constant_code,
963    retained_code,
964    constrained_code,
965    long_code,
966    outer_code,
967} prefix_codes;
968
969# define last_prefix_code enforced_code
970
971typedef enum combine_toks_codes {
972    expanded_toks_code,
973    append_toks_code,
974    append_expanded_toks_code,
975    prepend_toks_code,
976    prepend_expanded_toks_code,
977    global_expanded_toks_code,
978    global_append_toks_code,
979    global_append_expanded_toks_code,
980    global_prepend_toks_code,
981    global_prepend_expanded_toks_code,
982} combine_toks_codes;
983
984# define last_combine_toks_code global_prepend_expanded_toks_code
985
986typedef enum cs_name_codes {
987    cs_name_code,
988    last_named_cs_code,
989    begin_cs_name_code,
990    future_cs_name_code,
991} cs_name_codes;
992
993# define last_cs_name_code begin_cs_name_code
994
995typedef enum def_codes {
996    expanded_def_code,
997    def_code,
998    global_expanded_def_code,
999    global_def_code,
1000    expanded_def_csname_code,
1001    def_csname_code,
1002    global_expanded_def_csname_code,
1003    global_def_csname_code,
1004    constant_def_code,
1005    constant_def_csname_code,
1006} def_codes;
1007
1008# define last_def_code constant_def_csname_code
1009
1010typedef enum let_codes {
1011    global_let_code,
1012    let_code,
1013    future_let_code,
1014    future_def_code,
1015    let_charcode_code,
1016    swap_cs_values_code,
1017    let_protected_code,
1018    unlet_protected_code,
1019    let_frozen_code,
1020    unlet_frozen_code,
1021    global_let_csname_code,
1022    let_csname_code,
1023    global_let_to_nothing_code,
1024    let_to_nothing_code,
1025    let_to_last_named_cs_code,
1026} let_codes;
1027
1028# define last_let_code let_to_last_named_cs_code
1029
1030typedef enum message_codes {
1031    message_code,
1032    error_message_code,
1033} message_codes;
1034
1035# define last_message_code error_message_code
1036
1037/*tex
1038
1039    These are no longer needed, but we keep them as reference:
1040
1041    \starttyping
1042    typedef enum in_stream_codes {
1043        close_stream_code,
1044        open_stream_code,
1045    } in_stream_codes;
1046
1047    # define last_in_stream_code open_stream_code
1048
1049    typedef enum read_to_cs_codes {
1050        read_code,
1051        read_line_code,
1052    } read_to_cs_codes;
1053
1054    # define last_read_to_cs_code read_line_code
1055    \stoptyping
1056
1057*/
1058
1059typedef enum lua_call_codes {
1060    lua_function_call_code,
1061    lua_bytecode_call_code,
1062} lua_codes;
1063
1064typedef enum math_delimiter_codes {
1065    math_delimiter_code,
1066    math_udelimiter_code,
1067} math_delimiter_codes;
1068
1069# define last_math_delimiter_code math_udelimiter_code
1070
1071typedef enum math_choice_codes {
1072    math_choice_code,
1073    math_discretionary_code,
1074    math_stack_code,
1075} math_choice_codes;
1076
1077# define last_math_choice_code math_stack_code
1078
1079typedef enum math_accent_codes {
1080    math_accent_code,
1081    math_uaccent_code,
1082} math_accent_codes;
1083
1084# define last_math_accent_code math_uaccent_code
1085
1086typedef enum lua_value_codes {
1087    lua_value_none_code,
1088    lua_value_integer_code,
1089    lua_value_cardinal_code,
1090    lua_value_dimension_code,
1091    lua_value_skip_code,
1092    lua_value_boolean_code,
1093    lua_value_float_code,
1094    lua_value_string_code,
1095    lua_value_node_code,
1096    lua_value_direct_code,
1097    lua_value_conditional_code,
1098    /*tex total number of lua values */
1099    number_lua_values,
1100} lua_value_codes;
1101
1102typedef enum math_shift_cs_codes {
1103    begin_inline_math_code,
1104    end_inline_math_code,
1105    begin_display_math_code,
1106    end_display_math_code,
1107    begin_math_mode_code,
1108    end_math_mode_code,
1109} math_shift_cs_codes;
1110
1111# define first_math_shift_cs_code begin_inline_math_code
1112# define last_math_shift_cs_code  end_math_mode_code
1113
1114/*tex
1115    The next base and offset are what we always had so we keep it but we do use a proper zero based
1116    chr code that we adapt to the old value in the runner, so from then on we're in old mode again.
1117
1118    \starttyping
1119    # define leader_ship_base   (a_leaders - 1)
1120    # define leader_ship_offset (leader_flag - a_leaders)
1121    \stoptyping
1122
1123    Internal boxes are kind of special as they can have different scanners and as such they don't
1124    really fit in the rest of the internals. Now, for consistency we treat local boxes as internal
1125    ones but if we ever need more (which is unlikely) we can have a dedicated local_box_base. If
1126    we ever extend the repertoire of interal boxes we havbe to keep the local ones at the start.
1127
1128*/
1129
1130typedef enum legacy_codes {
1131    shipout_code,
1132} legacy_codes;
1133
1134# define first_legacy_code shipout_code
1135# define last_legacy_code  shipout_code
1136
1137typedef enum leader_codes {
1138    a_leaders_code,
1139    c_leaders_code,
1140    x_leaders_code,
1141    g_leaders_code,
1142    u_leaders_code,
1143} leader_codes;
1144
1145# define first_leader_code a_leaders_code
1146# define last_leader_code  u_leaders_code
1147
1148typedef enum local_box_codes {
1149    local_left_box_code,
1150    local_right_box_code,
1151    local_middle_box_code,
1152    /* room for more but then we go internal_box_codes */
1153    number_box_pars,
1154    local_reset_boxes_code,
1155} local_box_codes;
1156
1157# define first_local_box_code local_left_box_code
1158# define last_local_box_code  local_middle_box_code
1159
1160typedef enum local_box_options {
1161    local_box_par_option   = 0x1,
1162    local_box_local_option = 0x2,
1163    local_box_keep_option  = 0x4,
1164} local_box_options;
1165
1166typedef enum skip_codes {
1167    fi_l_code,         /*tex |\hfil| and |\vfil| */
1168    fi_ll_code,        /*tex |\hfill| and |\vfill| */
1169    fi_ss_code,        /*tex |\hss| and |\vss|, aka |ss_code| */
1170    fi_l_neg_code,     /*tex |\hfilneg| and |\vfilneg| */
1171    skip_code,         /*tex |\hskip| and |\vskip| */
1172    mskip_code,        /*tex |\mskip| */
1173} skip_codes;
1174
1175# define first_skip_code fi_l_code
1176# define last_skip_code  skip_code
1177
1178/*tex All kind of character related codes: */
1179
1180typedef enum charcode_codes {
1181    catcode_charcode,
1182    lccode_charcode,
1183    uccode_charcode,
1184    sfcode_charcode,
1185    hccode_charcode,
1186    hmcode_charcode,
1187    amcode_charcode,
1188    cccode_charcode,
1189    mathcode_charcode,
1190    extmathcode_charcode,
1191    delcode_charcode,
1192    extdelcode_charcode,
1193} charcode_codes;
1194
1195# define first_charcode_code catcode_charcode
1196# define last_charcode_code  extdelcode_charcode
1197
1198typedef enum math_styles {
1199    display_style,               /*tex |\displaystyle| */
1200    cramped_display_style,       /*tex |\crampeddisplaystyle| */
1201    text_style,                  /*tex |\textstyle| */
1202    cramped_text_style,          /*tex |\crampedtextstyle| */
1203    script_style,                /*tex |\scriptstyle| */
1204    cramped_script_style,        /*tex |\crampedscriptstyle| */
1205    script_script_style,         /*tex |\scriptscriptstyle| */
1206    cramped_script_script_style, /*tex |\crampedscriptscriptstyle| */
1207    /* hidden */                 /*tex These can be used to emulate the defaults. */
1208    all_display_styles,
1209    all_text_styles,
1210    all_script_styles,
1211    all_script_script_styles,
1212    all_math_styles,
1213    all_main_styles,
1214    all_split_styles,
1215    all_unsplit_styles,
1216    all_uncramped_styles,
1217    all_cramped_styles,
1218    /* hidden */
1219    currently_set_math_style,
1220    yet_unset_math_style,
1221    scaled_math_style,
1222    former_choice_math_style,
1223} math_styles;
1224
1225# define first_math_style display_style
1226# define last_math_style  former_choice_math_style
1227
1228# define is_valid_math_style(n)   (n >= display_style      && n <= cramped_script_script_style)
1229# define are_valid_math_styles(n) (n >= all_display_styles && n <= all_cramped_styles)
1230# define visible_math_styles(n)   (n >= display_style      && n <= all_cramped_styles)
1231
1232static inline halfword tex_math_style_to_size(halfword s)
1233{
1234    if (s == script_style || s == cramped_script_style) {
1235        return script_size;
1236    } else if (s == script_script_style || s == cramped_script_script_style) {
1237        return script_script_size;
1238    } else {
1239        return text_size;
1240    }
1241}
1242
1243typedef enum math_choices {
1244    math_display_choice,
1245    math_text_choice,
1246    math_script_choice,
1247    math_script_script_choice,
1248} math_choices;
1249
1250typedef enum math_discretionary_choices {
1251    math_pre_break_choice,
1252    math_post_break_choice,
1253    math_no_break_choice,
1254} math_discretionary_choices;
1255
1256typedef enum math_aboves {
1257    math_numerator_above,
1258    math_denominator_above,
1259} math_aboves;
1260
1261typedef enum math_limits {
1262    math_limits_top,
1263    math_limits_bottom,
1264} math_limits;
1265
1266typedef enum dir_codes {
1267    dir_lefttoright,
1268    dir_righttoleft
1269} dir_codes;
1270
1271typedef enum quantitity_levels {
1272    level_zero, /*tex level for undefined quantities */
1273    level_one,  /*tex outermost level for defined quantities */
1274} quantitity_levels;
1275
1276typedef enum move_codes {
1277    move_forward_code,
1278    move_backward_code,
1279} move_codes;
1280
1281# define last_move_code move_backward_code
1282
1283typedef enum ignore_something_codes {
1284    ignore_space_code,
1285    ignore_par_code,
1286    ignore_argument_code,
1287    ignore_upto_code,
1288    ignore_nested_upto_code,
1289    ignore_rest_code,
1290} ignore_something_codes;
1291
1292# define last_ignore_something_code ignore_rest_code
1293
1294typedef enum case_shift_codes {
1295    lower_case_code,
1296    upper_case_code,
1297} case_shift_codes;
1298
1299# define last_case_shift_code upper_case_code
1300
1301typedef enum location_codes {
1302    left_location_code,
1303    right_location_code,
1304    top_location_code,
1305    bottom_location_code,
1306} location_codes;
1307
1308# define first_location_code left_location_code
1309# define last_location_code  right_location_code
1310
1311typedef enum remove_item_codes {
1312    kern_item_code,
1313    penalty_item_code,
1314    skip_item_code,
1315    boundary_item_code,
1316} remove_item_codes;
1317
1318# define last_remove_item_code boundary_item_code
1319
1320typedef enum kern_codes {
1321    normal_kern_code,
1322    h_kern_code,
1323    v_kern_code,
1324    non_zero_width_kern_code, /* maybe */
1325} kern_codes;
1326
1327# define last_kern_code normal_kern_code
1328
1329typedef enum penalty_codes {
1330    normal_penalty_code,
1331    h_penalty_code,
1332    v_penalty_code,
1333} penalty_codes;
1334
1335# define last_penalty_code normal_penalty_code
1336
1337typedef enum tex_mskip_codes {
1338    normal_mskip_code,
1339    atom_mskip_code,
1340} tex_mskip_codes;
1341
1342# define last_mskip_code atom_mskip_code
1343
1344typedef enum tex_correction_codes {
1345    italic_correction_code,
1346    left_correction_code,
1347    right_correction_code,
1348} tex_correction_codes;
1349
1350# define last_correction_code right_correction_code
1351
1352typedef enum tex_math_script_codes {
1353    fixed_super_or_sub_script_code  = 0x01,
1354    fixed_super_and_sub_script_code = 0x02,
1355    ignore_empty_super_script_code  = 0x10,
1356    ignore_empty_sub_script_code    = 0x20,
1357    ignore_empty_prime_script_code  = 0x40,
1358} tex_math_script_codes;
1359
1360/*tex
1361    All the other cases are zero but we use an indicator for that.
1362*/
1363
1364# define normal_code 0
1365
1366# endif
1367