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