boundary nodes made consistent (cleanup and document): WARNING: bump the format numbe...
[luatex.git] / source / texk / web2c / luatexdir / tex / commands.h
blobedaeb72fe28aae15c0604f409a37634b492d3f10
1 /* commands.h
3 Copyright 2008 Taco Hoekwater <taco@luatex.org>
5 This file is part of LuaTeX.
7 LuaTeX is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
12 LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 License for more details.
17 You should have received a copy of the GNU General Public License along
18 with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
21 #ifndef COMMANDS_H
22 # define COMMANDS_H
25 Before we can go any further, we need to define symbolic names for the internal
26 code numbers that represent the various commands obeyed by \TeX. These codes
27 are somewhat arbitrary, but not completely so. For example, the command
28 codes for character types are fixed by the language, since a user says,
29 e.g., `\.{\\catcode \`\\\${} = 3}' to make \.{\char'44} a math delimiter,
30 and the command code |math_shift| is equal to~3. Some other codes have
31 been made adjacent so that |case| statements in the program need not consider
32 cases that are widely spaced, or so that |case| statements can be replaced
33 by |if| statements.
35 At any rate, here is the list, for future reference. First come the
36 ``catcode'' commands, several of which share their numeric codes with
37 ordinary commands when the catcode cannot emerge from \TeX's scanning routine.
39 @ Next are the ordinary run-of-the-mill command codes. Codes that are
40 |min_internal| or more represent internal quantities that might be
41 expanded by `\.{\\the}'.
44 @ The next codes are special; they all relate to mode-independent
45 assignment of values to \TeX's internal registers or tables.
46 Codes that are |max_internal| or less represent internal quantities
47 that might be expanded by `\.{\\the}'.
49 There is no matching primitive to go with |assign_attr|, but even if
50 there was no \.{\\attributedef}, a reserved number would still be
51 needed because there is an implied correspondence between the
52 |assign_xxx| commands and |xxx_val| expression values. That would
53 break down otherwise.
55 @ The remaining command codes are extra special, since they cannot get through
56 \TeX's scanner to the main control routine. They have been given values higher
57 than |max_command| so that their special nature is easily discernible.
58 The ``expandable'' commands come first.
63 typedef enum {
64 relax_cmd = 0, /* do nothing ( \.{\\relax} ) */
65 # define escape_cmd relax_cmd /* escape delimiter (called \.\\ in {\sl The \TeX book\/}) */
66 left_brace_cmd, /* beginning of a group ( \.\{ ) */
67 right_brace_cmd, /* ending of a group ( \.\} ) */
68 math_shift_cmd, /* mathematics shift character ( \.\$ ) */
69 tab_mark_cmd, /* alignment delimiter ( \.\&, \.{\\span} ) */
70 car_ret_cmd, /* end of line ( |carriage_return|, \.{\\cr}, \.{\\crcr} ) */
71 # define out_param_cmd car_ret_cmd /* output a macro parameter */
72 mac_param_cmd, /* macro parameter symbol ( \.\# ) */
73 sup_mark_cmd, /* superscript ( \.{\char'136} ) */
74 sub_mark_cmd, /* subscript ( \.{\char'137} ) */
75 endv_cmd, /* end of \<v_j> list in alignment template */
76 # define ignore_cmd endv_cmd /* characters to ignore ( \.{\^\^@@} ) */
77 spacer_cmd, /* characters equivalent to blank space ( \.{\ } ) */
78 letter_cmd, /* characters regarded as letters ( \.{A..Z}, \.{a..z} ) */
79 other_char_cmd, /* none of the special character types */
80 par_end_cmd, /* end of paragraph ( \.{\\par} ) */
81 # define active_char_cmd par_end_cmd /* characters that invoke macros ( \.{\char`\~} ) */
82 # define match_cmd par_end_cmd /* match a macro parameter */
83 stop_cmd, /* end of job ( \.{\\end}, \.{\\dump} ) */
84 # define comment_cmd stop_cmd /* characters that introduce comments ( \.\% ) */
85 # define end_match_cmd stop_cmd /* end of parameters to macro */
86 delim_num_cmd, /* specify delimiter numerically ( \.{\\delimiter} ) */
87 # define invalid_char_cmd delim_num_cmd /* characters that shouldn't appear ( \.{\^\^?} ) */
88 # define max_char_code_cmd delim_num_cmd /* largest catcode for individual characters */
89 char_num_cmd, /* character specified numerically ( \.{\\char} ) */
90 math_char_num_cmd, /* explicit math code ( \.{\\mathchar} ) */
91 mark_cmd, /* mark definition ( \.{\\mark} ) */
92 xray_cmd, /* peek inside of \TeX\ ( \.{\\show}, \.{\\showbox}, etc.~) */
93 make_box_cmd, /* make a box ( \.{\\box}, \.{\\copy}, \.{\\hbox}, etc.~) */
94 hmove_cmd, /* horizontal motion ( \.{\\moveleft}, \.{\\moveright} ) */
95 vmove_cmd, /* vertical motion ( \.{\\raise}, \.{\\lower} ) */
96 un_hbox_cmd, /* unglue a box ( \.{\\unhbox}, \.{\\unhcopy} ) */
97 un_vbox_cmd, /* unglue a box ( \.{\\unvbox}, \.{\\unvcopy} or \.{\\pagediscards}, \.{\\splitdiscards} ) */
98 remove_item_cmd, /* nullify last item ( \.{\\unpenalty}, \.{\\unkern}, \.{\\unskip} ) */
99 hskip_cmd, /* horizontal glue ( \.{\\hskip}, \.{\\hfil}, etc.~) */
100 vskip_cmd, /* vertical glue ( \.{\\vskip}, \.{\\vfil}, etc.~) */
101 mskip_cmd, /* math glue ( \.{\\mskip} ) */
102 kern_cmd, /* fixed space ( \.{\\kern}) */
103 mkern_cmd, /* math kern ( \.{\\mkern} ) */
104 leader_ship_cmd, /* use a box ( \.{\\shipout}, \.{\\leaders}, etc.~) */
105 halign_cmd, /* horizontal table alignment ( \.{\\halign} ) */
106 valign_cmd, /* vertical table alignment ( \.{\\valign} ) */
107 no_align_cmd, /* temporary escape from alignment ( \.{\\noalign} ) */
108 vrule_cmd, /* vertical rule ( \.{\\vrule} ) */
109 hrule_cmd, /* horizontal rule ( \.{\\hrule} ) */
110 no_vrule_cmd, /* no rule, just reserve space ( \.{\\novrule} )*/
111 no_hrule_cmd, /* no rule, just reserve space ( \.{\\nohrule} )*/
112 insert_cmd, /* vlist inserted in box ( \.{\\insert} ) */
113 vadjust_cmd, /* vlist inserted in enclosing paragraph ( \.{\\vadjust} ) */
114 ignore_spaces_cmd, /* gobble |spacer| tokens ( \.{\\ignorespaces} ) */
115 after_assignment_cmd, /* save till assignment is done ( \.{\\afterassignment} ) */
116 after_group_cmd, /* save till group is done ( \.{\\aftergroup} ) */
117 break_penalty_cmd, /* additional badness ( \.{\\penalty} ) */
118 start_par_cmd, /* begin paragraph ( \.{\\indent}, \.{\\noindent} ) */
119 ital_corr_cmd, /* italic correction ( \.{\\/} ) */
120 accent_cmd, /* attach accent in text ( \.{\\accent} ) */
121 math_accent_cmd, /* attach accent in math ( \.{\\mathaccent} ) */
122 discretionary_cmd, /* discretionary texts ( \.{\\-}, \.{\\discretionary} ) */
123 eq_no_cmd, /* equation number ( \.{\\eqno}, \.{\\leqno} ) */
124 left_right_cmd, /* variable delimiter ( \.{\\left}, \.{\\right} or \.{\\middle} ) */
125 math_comp_cmd, /* component of formula ( \.{\\mathbin}, etc.~) */
126 limit_switch_cmd, /* diddle limit conventions ( \.{\\displaylimits}, etc.~) */
127 above_cmd, /* generalized fraction ( \.{\\above}, \.{\\atop}, etc.~) */
128 math_style_cmd, /* style specification ( \.{\\displaystyle}, etc.~) */
129 math_choice_cmd, /* choice specification ( \.{\\mathchoice} ) */
130 non_script_cmd, /* conditional math glue ( \.{\\nonscript} ) */
131 vcenter_cmd, /* vertically center a vbox ( \.{\\vcenter} ) */
132 case_shift_cmd, /* force specific case ( \.{\\lowercase}, \.{\\uppercase}~) */
133 message_cmd, /* send to user ( \.{\\message}, \.{\\errmessage} ) */
134 normal_cmd, /* general extensions to \TeX\ that don't fit into a category */
135 extension_cmd, /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */
136 option_cmd,
137 in_stream_cmd, /* files for reading ( \.{\\openin}, \.{\\closein} ) */
138 begin_group_cmd, /* begin local grouping ( \.{\\begingroup} ) */
139 end_group_cmd, /* end local grouping ( \.{\\endgroup} ) */
140 omit_cmd, /* omit alignment template ( \.{\\omit} ) */
141 ex_space_cmd, /* explicit space ( \.{\\\ } ) */
142 boundary_cmd, /* insert boundry node with value ( \.{\\*boundary} ) */
143 radical_cmd, /* square root and similar signs ( \.{\\radical} ) */
144 super_sub_script_cmd, /* explicit super- or subscript */
145 math_shift_cs_cmd, /* start- and endmath */
146 end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */
147 char_ghost_cmd, /* \.{\\leftghost}, \.{\\rightghost} character for kerning */
148 assign_local_box_cmd, /* box for guillemets \.{\\localleftbox} or \.{\\localrightbox} */
149 char_given_cmd, /* character code defined by \.{\\chardef} */
150 # define min_internal_cmd char_given_cmd /* the smallest code that can follow \.{\\the} */
151 math_given_cmd, /* math code defined by \.{\\mathchardef} */
152 xmath_given_cmd, /* math code defined by \.{\\Umathchardef} or \.{\\Umathcharnumdef} */
153 last_item_cmd, /* most recent item ( \.{\\lastpenalty}, \.{\\lastkern}, \.{\\lastskip} ) */
154 # define max_non_prefixed_command_cmd last_item_cmd /* largest command code that can't be \.{\\global} */
155 toks_register_cmd, /* token list register ( \.{\\toks} ) */
156 assign_toks_cmd, /* special token list ( \.{\\output}, \.{\\everypar}, etc.~) */
157 assign_int_cmd, /* user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~) */
158 assign_attr_cmd, /* user-defined attributes */
159 assign_dimen_cmd, /* user-defined length ( \.{\\hsize}, etc.~) */
160 assign_glue_cmd, /* user-defined glue ( \.{\\baselineskip}, etc.~) */
161 assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */
162 assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */
163 assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */
164 set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */
165 set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */
166 set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */
167 set_page_int_cmd, /* specify state info ( \.{\\deadcycles}, \.{\\insertpenalties} ) */
168 set_box_dimen_cmd, /* change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} ) */
169 set_tex_shape_cmd, /* specify fancy paragraph shape ( \.{\\parshape} ) */
170 set_etex_shape_cmd, /* specify etex extended list ( \.{\\interlinepenalties}, etc.~) */
171 def_char_code_cmd, /* define a character code ( \.{\\catcode}, etc.~) */
172 def_del_code_cmd, /* define a delimiter code ( \.{\\delcode}) */
173 extdef_math_code_cmd, /* define an extended character code ( \.{\\Umathcode}, etc.~) */
174 extdef_del_code_cmd, /* define an extended delimiter code ( \.{\\Udelcode}, etc.~) */
175 def_family_cmd, /* declare math fonts ( \.{\\textfont}, etc.~) */
176 set_math_param_cmd, /* set math parameters ( \.{\\mathquad}, etc.~) */
177 set_font_cmd, /* set current font ( font identifiers ) */
178 def_font_cmd, /* define a font file ( \.{\\font} ) */
179 register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */
180 assign_box_dir_cmd, /* (\.{\\boxdir}) */
181 assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */
182 # define max_internal_cmd assign_dir_cmd /* the largest code that can follow \.{\\the} */
183 advance_cmd, /* advance a register or parameter ( \.{\\advance} ) */
184 multiply_cmd, /* multiply a register or parameter ( \.{\\multiply} ) */
185 divide_cmd, /* divide a register or parameter ( \.{\\divide} ) */
186 prefix_cmd, /* qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} ) */
187 let_cmd, /* assign a command code ( \.{\\let}, \.{\\futurelet} ) */
188 shorthand_def_cmd, /* code definition ( \.{\\chardef}, \.{\\countdef}, etc.~) */
189 read_to_cs_cmd, /* read into a control sequence ( \.{\\read} ) */
190 def_cmd, /* macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} ) */
191 set_box_cmd, /* set a box ( \.{\\setbox} ) */
192 hyph_data_cmd, /* hyphenation data ( \.{\\hyphenation}, \.{\\patterns} ) */
193 set_interaction_cmd, /* define level of interaction ( \.{\\batchmode}, etc.~) */
194 letterspace_font_cmd, /* letterspace a font ( \.{\\letterspacefont} ) */
195 expand_font_cmd, /* expand glyphs ( \.{\\expandglyphsinfont} ) */
196 copy_font_cmd, /* create a new font instance ( \.{\\copyfont} ) */
197 set_font_id_cmd,
198 undefined_cs_cmd, /* initial state of most |eq_type| fields */
199 expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */
200 no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */
201 input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or \.{\\scantokens} or \.{\\scantextokens} ) */
202 if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */
203 fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */
204 cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */
205 convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */
206 variable_cmd,
207 feedback_cmd,
208 the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */
209 combine_toks_cmd,
210 top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */
211 call_cmd, /* non-long, non-outer control sequence */
212 long_call_cmd, /* long, non-outer control sequence */
213 outer_call_cmd, /* non-long, outer control sequence */
214 long_outer_call_cmd, /* long, outer control sequence */
215 end_template_cmd, /* end of an alignment template */
216 dont_expand_cmd, /* the following token was marked by \.{\\noexpand} */
217 glue_ref_cmd, /* the equivalent points to a glue specification */
218 shape_ref_cmd, /* the equivalent points to a parshape specification */
219 box_ref_cmd, /* the equivalent points to a box node, or is |null| */
220 data_cmd, /* the equivalent is simply a halfword number */
221 } tex_command_code;
223 # define max_command_cmd set_font_id_cmd /* the largest command code seen at |big_switch| */
224 # define last_cmd data_cmd
225 # define max_non_prefixed_command last_item_cmd
227 typedef enum {
228 above_code = 0,
229 over_code = 1,
230 atop_code = 2,
231 skewed_code = 3,
232 delimited_code = 4,
233 } fraction_codes;
235 typedef enum {
236 number_code = 0, /* command code for \.{\\number} */
237 lua_function_code, /* command code for \.{\\luafunction} */
238 lua_code, /* command code for \.{\\directlua} */
239 expanded_code, /* command code for \.{\\expanded} */
240 math_style_code, /* command code for \.{\\mathstyle} */
241 string_code, /* command code for \.{\\string} */
242 cs_string_code, /* command code for \.{\\csstring} */
243 roman_numeral_code, /* command code for \.{\\romannumeral} */
244 meaning_code, /* command code for \.{\\meaning} */
245 uchar_code, /* command code for \.{\\Uchar} */
246 lua_escape_string_code, /* command code for \.{\\luaescapestring} */
247 font_id_code, /* command code for \.{\\fontid} */
248 font_name_code, /* command code for \.{\\fontname} */
249 left_margin_kern_code, /* command code for \.{\\leftmarginkern} */
250 right_margin_kern_code, /* command code for \.{\\rightmarginkern} */
251 uniform_deviate_code, /* command code for \.{\\uniformdeviate} */
252 normal_deviate_code, /* command code for \.{\\normaldeviate} */
253 math_char_class_code,
254 math_char_fam_code,
255 math_char_slot_code,
256 insert_ht_code, /* command code for \.{\\insertht} */
257 job_name_code, /* command code for \.{\\jobname} */
258 format_name_code, /* command code for \.{\\AlephVersion} */
259 luatex_banner_code, /* command code for \.{\\luatexbanner}: */
260 luatex_revision_code, /* command code for \.{\\luatexrevision} */
261 luatex_date_code, /* command code for \.{\\luatexdate} */
262 etex_code, /* command code for \.{\\eTeXVersion} */
263 eTeX_revision_code, /* command code for \.{\\eTeXrevision} */
264 font_identifier_code, /* command code for \.{tex.fontidentifier} (virtual) */
265 /* backend */
266 dvi_feedback_code,
267 pdf_feedback_code,
268 dvi_variable_code,
269 pdf_variable_code,
270 } convert_codes;
272 typedef enum {
273 lastpenalty_code = 0, /* code for \.{\\lastpenalty} */
274 lastattr_code, /* not used */
275 lastkern_code, /* code for \.{\\lastkern} */
276 lastskip_code, /* code for \.{\\lastskip} */
277 last_node_type_code, /* code for \.{\\lastnodetype} */
278 input_line_no_code, /* code for \.{\\inputlineno} */
279 badness_code, /* code for \.{\\badness} */
280 last_saved_box_resource_index_code, /* code for \.{\\lastsavedboxresourceindex} */
281 last_saved_image_resource_index_code, /* code for \.{\\lastsavedimageresourceindex} */
282 last_saved_image_resource_pages_code, /* code for \.{\\lastsavedimageresourcepages} */
283 last_x_pos_code, /* code for \.{\\lastxpos} */
284 last_y_pos_code, /* code for \.{\\lastypos} */
285 random_seed_code, /* code for \.{\\randomseed} */
286 luatex_version_code, /* code for \.{\\luatexversion} */
287 eTeX_minor_version_code, /* code for \.{\\eTeXminorversion} */
288 eTeX_version_code, /* code for \.{\\eTeXversion} */
289 # define eTeX_int eTeX_version_code /* first of \eTeX\ codes for integers */
290 current_group_level_code, /* code for \.{\\currentgrouplevel} */
291 current_group_type_code, /* code for \.{\\currentgrouptype} */
292 current_if_level_code, /* code for \.{\\currentiflevel} */
293 current_if_type_code, /* code for \.{\\currentiftype} */
294 current_if_branch_code, /* code for \.{\\currentifbranch} */
295 glue_stretch_order_code, /* code for \.{\\gluestretchorder} */
296 glue_shrink_order_code, /* code for \.{\\glueshrinkorder} */
297 font_char_wd_code, /* code for \.{\\fontcharwd} */
298 # define eTeX_dim font_char_wd_code /* first of \eTeX\ codes for dimensions */
299 font_char_ht_code, /* code for \.{\\fontcharht} */
300 font_char_dp_code, /* code for \.{\\fontchardp} */
301 font_char_ic_code, /* code for \.{\\fontcharic} */
302 par_shape_length_code, /* code for \.{\\parshapelength} */
303 par_shape_indent_code, /* code for \.{\\parshapeindent} */
304 par_shape_dimen_code, /* code for \.{\\parshapedimen} */
305 glue_stretch_code, /* code for \.{\\gluestretch} */
306 glue_shrink_code, /* code for \.{\\glueshrink} */
307 mu_to_glue_code, /* code for \.{\\mutoglue} */
308 # define eTeX_glue mu_to_glue_code /* first of \eTeX\ codes for glue */
309 glue_to_mu_code, /* code for \.{\\gluetomu} */
310 # define eTeX_mu glue_to_mu_code /* first of \eTeX\ codes for muglue */
311 numexpr_code, /* code for \.{\\numexpr} */
312 # define eTeX_expr numexpr_code /* first of \eTeX\ codes for expressions */
313 attrexpr_code, /* not used */
314 dimexpr_code, /* code for \.{\\dimexpr} */
315 glueexpr_code, /* code for \.{\\glueexpr} */
316 muexpr_code, /* code for \.{\\muexpr} */
317 } last_item_codes;
320 typedef enum {
321 save_cat_code_table_code=0,
322 init_cat_code_table_code,
323 set_random_seed_code,
324 save_pos_code,
325 late_lua_code,
326 expand_font_code,
327 } normal_codes;
329 # define lp_code_base 2
330 # define rp_code_base 3
331 # define ef_code_base 4
332 # define tag_code 5
333 # define no_lig_code 6
335 # define immediate_code 4 /* command modifier for \.{\\immediate} */
337 extern void initialize_commands(void);
338 extern void initialize_etex_commands(void);
340 #endif