beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / tex / commands.h
blob60bfef895d22019bd7ab94b9836581f64fa2cc21
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 no_boundary_cmd, /* suppress boundary ligatures ( \.{\\noboundary} ) */
144 radical_cmd, /* square root and similar signs ( \.{\\radical} ) */
145 super_sub_script_cmd, /* explicit super- or subscript */
146 math_shift_cs_cmd, /* start- and endmath */
147 end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */
148 char_ghost_cmd, /* \.{\\leftghost}, \.{\\rightghost} character for kerning */
149 assign_local_box_cmd, /* box for guillemets \.{\\localleftbox} or \.{\\localrightbox} */
150 char_given_cmd, /* character code defined by \.{\\chardef} */
151 # define min_internal_cmd char_given_cmd /* the smallest code that can follow \.{\\the} */
152 math_given_cmd, /* math code defined by \.{\\mathchardef} */
153 xmath_given_cmd, /* math code defined by \.{\\Umathchardef} or \.{\\Umathcharnumdef} */
154 last_item_cmd, /* most recent item ( \.{\\lastpenalty}, \.{\\lastkern}, \.{\\lastskip} ) */
155 # define max_non_prefixed_command_cmd last_item_cmd /* largest command code that can't be \.{\\global} */
156 toks_register_cmd, /* token list register ( \.{\\toks} ) */
157 assign_toks_cmd, /* special token list ( \.{\\output}, \.{\\everypar}, etc.~) */
158 assign_int_cmd, /* user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~) */
159 assign_attr_cmd, /* user-defined attributes */
160 assign_dimen_cmd, /* user-defined length ( \.{\\hsize}, etc.~) */
161 assign_glue_cmd, /* user-defined glue ( \.{\\baselineskip}, etc.~) */
162 assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */
163 assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */
164 assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */
165 set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */
166 set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */
167 set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */
168 set_page_int_cmd, /* specify state info ( \.{\\deadcycles}, \.{\\insertpenalties} ) */
169 set_box_dimen_cmd, /* change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} ) */
170 set_tex_shape_cmd, /* specify fancy paragraph shape ( \.{\\parshape} ) */
171 set_etex_shape_cmd, /* specify etex extended list ( \.{\\interlinepenalties}, etc.~) */
172 def_char_code_cmd, /* define a character code ( \.{\\catcode}, etc.~) */
173 def_del_code_cmd, /* define a delimiter code ( \.{\\delcode}) */
174 extdef_math_code_cmd, /* define an extended character code ( \.{\\Umathcode}, etc.~) */
175 extdef_del_code_cmd, /* define an extended delimiter code ( \.{\\Udelcode}, etc.~) */
176 def_family_cmd, /* declare math fonts ( \.{\\textfont}, etc.~) */
177 set_math_param_cmd, /* set math parameters ( \.{\\mathquad}, etc.~) */
178 set_font_cmd, /* set current font ( font identifiers ) */
179 def_font_cmd, /* define a font file ( \.{\\font} ) */
180 register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */
181 assign_box_dir_cmd, /* (\.{\\boxdir}) */
182 assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */
183 # define max_internal_cmd assign_dir_cmd /* the largest code that can follow \.{\\the} */
184 advance_cmd, /* advance a register or parameter ( \.{\\advance} ) */
185 multiply_cmd, /* multiply a register or parameter ( \.{\\multiply} ) */
186 divide_cmd, /* divide a register or parameter ( \.{\\divide} ) */
187 prefix_cmd, /* qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} ) */
188 let_cmd, /* assign a command code ( \.{\\let}, \.{\\futurelet} ) */
189 shorthand_def_cmd, /* code definition ( \.{\\chardef}, \.{\\countdef}, etc.~) */
190 read_to_cs_cmd, /* read into a control sequence ( \.{\\read} ) */
191 def_cmd, /* macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} ) */
192 set_box_cmd, /* set a box ( \.{\\setbox} ) */
193 hyph_data_cmd, /* hyphenation data ( \.{\\hyphenation}, \.{\\patterns} ) */
194 set_interaction_cmd, /* define level of interaction ( \.{\\batchmode}, etc.~) */
195 letterspace_font_cmd, /* letterspace a font ( \.{\\letterspacefont} ) */
196 expand_font_cmd, /* expand glyphs ( \.{\\expandglyphsinfont} ) */
197 copy_font_cmd, /* create a new font instance ( \.{\\copyfont} ) */
198 set_font_id_cmd,
199 undefined_cs_cmd, /* initial state of most |eq_type| fields */
200 expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */
201 no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */
202 input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or \.{\\scantokens} or \.{\\scantextokens} ) */
203 if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */
204 fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */
205 cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */
206 convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */
207 variable_cmd,
208 feedback_cmd,
209 the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */
210 combine_toks_cmd,
211 top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */
212 call_cmd, /* non-long, non-outer control sequence */
213 long_call_cmd, /* long, non-outer control sequence */
214 outer_call_cmd, /* non-long, outer control sequence */
215 long_outer_call_cmd, /* long, outer control sequence */
216 end_template_cmd, /* end of an alignment template */
217 dont_expand_cmd, /* the following token was marked by \.{\\noexpand} */
218 glue_ref_cmd, /* the equivalent points to a glue specification */
219 shape_ref_cmd, /* the equivalent points to a parshape specification */
220 box_ref_cmd, /* the equivalent points to a box node, or is |null| */
221 data_cmd, /* the equivalent is simply a halfword number */
222 } tex_command_code;
224 # define max_command_cmd set_font_id_cmd /* the largest command code seen at |big_switch| */
225 # define last_cmd data_cmd
226 # define max_non_prefixed_command last_item_cmd
228 typedef enum {
229 above_code = 0,
230 over_code = 1,
231 atop_code = 2,
232 skewed_code = 3,
233 delimited_code = 4,
234 } fraction_codes;
236 typedef enum {
237 number_code = 0, /* command code for \.{\\number} */
238 lua_function_code, /* command code for \.{\\luafunction} */
239 lua_code, /* command code for \.{\\directlua} */
240 expanded_code, /* command code for \.{\\expanded} */
241 math_style_code, /* command code for \.{\\mathstyle} */
242 string_code, /* command code for \.{\\string} */
243 cs_string_code, /* command code for \.{\\csstring} */
244 roman_numeral_code, /* command code for \.{\\romannumeral} */
245 meaning_code, /* command code for \.{\\meaning} */
246 uchar_code, /* command code for \.{\\Uchar} */
247 lua_escape_string_code, /* command code for \.{\\luaescapestring} */
248 font_id_code, /* command code for \.{\\fontid} */
249 font_name_code, /* command code for \.{\\fontname} */
250 left_margin_kern_code, /* command code for \.{\\leftmarginkern} */
251 right_margin_kern_code, /* command code for \.{\\rightmarginkern} */
252 uniform_deviate_code, /* command code for \.{\\uniformdeviate} */
253 normal_deviate_code, /* command code for \.{\\normaldeviate} */
254 math_char_class_code,
255 math_char_fam_code,
256 math_char_slot_code,
257 insert_ht_code, /* command code for \.{\\insertht} */
258 job_name_code, /* command code for \.{\\jobname} */
259 format_name_code, /* command code for \.{\\AlephVersion} */
260 luatex_banner_code, /* command code for \.{\\luatexbanner}: */
261 luatex_revision_code, /* command code for \.{\\luatexrevision} */
262 luatex_date_code, /* command code for \.{\\luatexdate} */
263 etex_code, /* command code for \.{\\eTeXVersion} */
264 eTeX_revision_code, /* command code for \.{\\eTeXrevision} */
265 font_identifier_code, /* command code for \.{tex.fontidentifier} (virtual) */
266 /* backend */
267 dvi_feedback_code,
268 pdf_feedback_code,
269 dvi_variable_code,
270 pdf_variable_code,
271 } convert_codes;
273 typedef enum {
274 lastpenalty_code = 0, /* code for \.{\\lastpenalty} */
275 lastattr_code, /* not used */
276 lastkern_code, /* code for \.{\\lastkern} */
277 lastskip_code, /* code for \.{\\lastskip} */
278 last_node_type_code, /* code for \.{\\lastnodetype} */
279 input_line_no_code, /* code for \.{\\inputlineno} */
280 badness_code, /* code for \.{\\badness} */
281 last_saved_box_resource_index_code, /* code for \.{\\lastsavedboxresourceindex} */
282 last_saved_image_resource_index_code, /* code for \.{\\lastsavedimageresourceindex} */
283 last_saved_image_resource_pages_code, /* code for \.{\\lastsavedimageresourcepages} */
284 last_x_pos_code, /* code for \.{\\lastxpos} */
285 last_y_pos_code, /* code for \.{\\lastypos} */
286 random_seed_code, /* code for \.{\\randomseed} */
287 luatex_version_code, /* code for \.{\\luatexversion} */
288 eTeX_minor_version_code, /* code for \.{\\eTeXminorversion} */
289 eTeX_version_code, /* code for \.{\\eTeXversion} */
290 # define eTeX_int eTeX_version_code /* first of \eTeX\ codes for integers */
291 current_group_level_code, /* code for \.{\\currentgrouplevel} */
292 current_group_type_code, /* code for \.{\\currentgrouptype} */
293 current_if_level_code, /* code for \.{\\currentiflevel} */
294 current_if_type_code, /* code for \.{\\currentiftype} */
295 current_if_branch_code, /* code for \.{\\currentifbranch} */
296 glue_stretch_order_code, /* code for \.{\\gluestretchorder} */
297 glue_shrink_order_code, /* code for \.{\\glueshrinkorder} */
298 font_char_wd_code, /* code for \.{\\fontcharwd} */
299 # define eTeX_dim font_char_wd_code /* first of \eTeX\ codes for dimensions */
300 font_char_ht_code, /* code for \.{\\fontcharht} */
301 font_char_dp_code, /* code for \.{\\fontchardp} */
302 font_char_ic_code, /* code for \.{\\fontcharic} */
303 par_shape_length_code, /* code for \.{\\parshapelength} */
304 par_shape_indent_code, /* code for \.{\\parshapeindent} */
305 par_shape_dimen_code, /* code for \.{\\parshapedimen} */
306 glue_stretch_code, /* code for \.{\\gluestretch} */
307 glue_shrink_code, /* code for \.{\\glueshrink} */
308 mu_to_glue_code, /* code for \.{\\mutoglue} */
309 # define eTeX_glue mu_to_glue_code /* first of \eTeX\ codes for glue */
310 glue_to_mu_code, /* code for \.{\\gluetomu} */
311 # define eTeX_mu glue_to_mu_code /* first of \eTeX\ codes for muglue */
312 numexpr_code, /* code for \.{\\numexpr} */
313 # define eTeX_expr numexpr_code /* first of \eTeX\ codes for expressions */
314 attrexpr_code, /* not used */
315 dimexpr_code, /* code for \.{\\dimexpr} */
316 glueexpr_code, /* code for \.{\\glueexpr} */
317 muexpr_code, /* code for \.{\\muexpr} */
318 } last_item_codes;
321 typedef enum {
322 save_cat_code_table_code=0,
323 init_cat_code_table_code,
324 set_random_seed_code,
325 save_pos_code,
326 late_lua_code,
327 expand_font_code,
328 } normal_codes;
330 # define lp_code_base 2
331 # define rp_code_base 3
332 # define ef_code_base 4
333 # define tag_code 5
334 # define no_lig_code 6
336 # define immediate_code 4 /* command modifier for \.{\\immediate} */
338 extern void initialize_commands(void);
339 extern void initialize_etex_commands(void);
341 #endif