Debian Codegraph @

texk/web2c/luatexdir/tex/commands.h

raw
1 /* commands.h
2
3 Copyright 2008 Taco Hoekwater <[email protected]>
4
5 This file is part of LuaTeX.
6
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.
11
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.
16
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/>. */
19
20
21 #ifndef COMMANDS_H
22 # define COMMANDS_H
23
24 /*
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.
34
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.
38
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}'.
42
43
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}'.
48
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.
54
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.
59
60
61 */
62
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 node_cmd,
93 xray_cmd, /* peek inside of \TeX\ ( \.{\\show}, \.{\\showbox}, etc.~) */
94 make_box_cmd, /* make a box ( \.{\\box}, \.{\\copy}, \.{\\hbox}, etc.~) */
95 hmove_cmd, /* horizontal motion ( \.{\\moveleft}, \.{\\moveright} ) */
96 vmove_cmd, /* vertical motion ( \.{\\raise}, \.{\\lower} ) */
97 un_hbox_cmd, /* unglue a box ( \.{\\unhbox}, \.{\\unhcopy} ) */
98 un_vbox_cmd, /* unglue a box ( \.{\\unvbox}, \.{\\unvcopy} or \.{\\pagediscards}, \.{\\splitdiscards} ) */
99 remove_item_cmd, /* nullify last item ( \.{\\unpenalty}, \.{\\unkern}, \.{\\unskip} ) */
100 hskip_cmd, /* horizontal glue ( \.{\\hskip}, \.{\\hfil}, etc.~) */
101 vskip_cmd, /* vertical glue ( \.{\\vskip}, \.{\\vfil}, etc.~) */
102 mskip_cmd, /* math glue ( \.{\\mskip} ) */
103 kern_cmd, /* fixed space ( \.{\\kern}) */
104 mkern_cmd, /* math kern ( \.{\\mkern} ) */
105 leader_ship_cmd, /* use a box ( \.{\\shipout}, \.{\\leaders}, etc.~) */
106 halign_cmd, /* horizontal table alignment ( \.{\\halign} ) */
107 valign_cmd, /* vertical table alignment ( \.{\\valign} ) */
108 no_align_cmd, /* temporary escape from alignment ( \.{\\noalign} ) */
109 vrule_cmd, /* vertical rule ( \.{\\vrule} ) */
110 hrule_cmd, /* horizontal rule ( \.{\\hrule} ) */
111 no_vrule_cmd, /* no rule, just reserve space ( \.{\\novrule} )*/
112 no_hrule_cmd, /* no rule, just reserve space ( \.{\\nohrule} )*/
113 insert_cmd, /* vlist inserted in box ( \.{\\insert} ) */
114 vadjust_cmd, /* vlist inserted in enclosing paragraph ( \.{\\vadjust} ) */
115 ignore_spaces_cmd, /* gobble |spacer| tokens ( \.{\\ignorespaces} ) */
116 after_assignment_cmd, /* save till assignment is done ( \.{\\afterassignment} ) */
117 after_group_cmd, /* save till group is done ( \.{\\aftergroup} ) */
118 partoken_name_cmd, /* something pdftex, not sure if this is the right order */
119 break_penalty_cmd, /* additional badness ( \.{\\penalty} ) */
120 start_par_cmd, /* begin paragraph ( \.{\\indent}, \.{\\noindent} ) */
121 ital_corr_cmd, /* italic correction ( \.{\\/} ) */
122 accent_cmd, /* attach accent in text ( \.{\\accent} ) */
123 math_accent_cmd, /* attach accent in math ( \.{\\mathaccent} ) */
124 discretionary_cmd, /* discretionary texts ( \.{\\-}, \.{\\discretionary} ) */
125 eq_no_cmd, /* equation number ( \.{\\eqno}, \.{\\leqno} ) */
126 left_right_cmd, /* variable delimiter ( \.{\\left}, \.{\\right} or \.{\\middle} ) */
127 math_comp_cmd, /* component of formula ( \.{\\mathbin}, etc.~) */
128 limit_switch_cmd, /* diddle limit conventions ( \.{\\displaylimits}, etc.~) */
129 above_cmd, /* generalized fraction ( \.{\\above}, \.{\\atop}, etc.~) */
130 math_style_cmd, /* style specification ( \.{\\displaystyle}, etc.~) */
131 math_choice_cmd, /* choice specification ( \.{\\mathchoice} ) */
132 non_script_cmd, /* conditional math glue ( \.{\\nonscript} ) */
133 vcenter_cmd, /* vertically center a vbox ( \.{\\vcenter} ) */
134 case_shift_cmd, /* force specific case ( \.{\\lowercase}, \.{\\uppercase}~) */
135 message_cmd, /* send to user ( \.{\\message}, \.{\\errmessage} ) */
136 normal_cmd, /* general extensions to \TeX\ that don't fit into a category */
137 extension_cmd, /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */
138 option_cmd, /* obsolete */
139 lua_function_call_cmd,
140 lua_bytecode_call_cmd,
141 lua_call_cmd,
142 in_stream_cmd, /* files for reading ( \.{\\openin}, \.{\\closein} ) */
143 begin_group_cmd, /* begin local grouping ( \.{\\begingroup} ) */
144 end_group_cmd, /* end local grouping ( \.{\\endgroup} ) */
145 omit_cmd, /* omit alignment template ( \.{\\omit} ) */
146 ex_space_cmd, /* explicit space ( \.{\\\ } ) */
147 boundary_cmd, /* insert boundry node with value ( \.{\\*boundary} ) */
148 radical_cmd, /* square root and similar signs ( \.{\\radical} ) */
149 super_sub_script_cmd, /* explicit super- or subscript */
150 no_super_sub_script_cmd, /* explicit no super- or subscript */
151 math_shift_cs_cmd, /* start- and endmath */
152 end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */
153 char_ghost_cmd, /* \.{\\leftghost}, \.{\\rightghost} character for kerning */
154 assign_local_box_cmd, /* box for guillemets \.{\\localleftbox} or \.{\\localrightbox} */
155 char_given_cmd, /* character code defined by \.{\\chardef} */
156 # define min_internal_cmd char_given_cmd /* the smallest code that can follow \.{\\the} */
157 math_given_cmd, /* math code defined by \.{\\mathchardef} */
158 xmath_given_cmd, /* math code defined by \.{\\Umathchardef} or \.{\\Umathcharnumdef} */
159 last_item_cmd, /* most recent item ( \.{\\lastpenalty}, \.{\\lastkern}, \.{\\lastskip} ) */
160 # define max_non_prefixed_command_cmd last_item_cmd /* largest command code that can't be \.{\\global} */
161 toks_register_cmd, /* token list register ( \.{\\toks} ) */
162 assign_toks_cmd, /* special token list ( \.{\\output}, \.{\\everypar}, etc.~) */
163 assign_int_cmd, /* user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~) */
164 assign_attr_cmd, /* user-defined attributes */
165 assign_dimen_cmd, /* user-defined length ( \.{\\hsize}, etc.~) */
166 assign_glue_cmd, /* user-defined glue ( \.{\\baselineskip}, etc.~) */
167 assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */
168 assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */
169 assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */
170 assign_hang_indent_cmd,
171 set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */
172 set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */
173 set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */
174 set_page_int_cmd, /* specify state info ( \.{\\deadcycles}, \.{\\insertpenalties} ) */
175 set_box_dimen_cmd, /* change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} ) */
176 set_tex_shape_cmd, /* specify fancy paragraph shape ( \.{\\parshape} ) */
177 set_etex_shape_cmd, /* specify etex extended list ( \.{\\interlinepenalties}, etc.~) */
178 def_char_code_cmd, /* define a character code ( \.{\\catcode}, etc.~) */
179 def_del_code_cmd, /* define a delimiter code ( \.{\\delcode}) */
180 extdef_math_code_cmd, /* define an extended character code ( \.{\\Umathcode}, etc.~) */
181 extdef_del_code_cmd, /* define an extended delimiter code ( \.{\\Udelcode}, etc.~) */
182 def_family_cmd, /* declare math fonts ( \.{\\textfont}, etc.~) */
183 set_math_param_cmd, /* set math parameters ( \.{\\mathquad}, etc.~) */
184 set_font_cmd, /* set current font ( font identifiers ) */
185 def_font_cmd, /* define a font file ( \.{\\font} ) */
186 register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */
187 assign_box_direction_cmd, /* (\.{\\boxdirection}) */
188 assign_box_dir_cmd, /* (\.{\\boxdir}) */
189 assign_direction_cmd, /* (\.{\\pagedirection}, \.{\\textdirection}) */
190 assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */
191 combine_toks_cmd,
192 # define max_internal_cmd assign_dir_cmd /* the largest code that can follow \.{\\the} */
193 advance_cmd, /* advance a register or parameter ( \.{\\advance} ) */
194 multiply_cmd, /* multiply a register or parameter ( \.{\\multiply} ) */
195 divide_cmd, /* divide a register or parameter ( \.{\\divide} ) */
196 prefix_cmd, /* qualify a definition ( \.{\\global}, \.{\\long}, \.{\\outer} ) */
197 let_cmd, /* assign a command code ( \.{\\let}, \.{\\futurelet} ) */
198 shorthand_def_cmd, /* code definition ( \.{\\chardef}, \.{\\countdef}, etc.~) */
199 def_lua_call_cmd,
200 read_to_cs_cmd, /* read into a control sequence ( \.{\\read} ) */
201 def_cmd, /* macro definition ( \.{\\def}, \.{\\gdef}, \.{\\xdef}, \.{\\edef} ) */
202 set_box_cmd, /* set a box ( \.{\\setbox} ) */
203 hyph_data_cmd, /* hyphenation data ( \.{\\hyphenation}, \.{\\patterns} ) */
204 set_interaction_cmd, /* define level of interaction ( \.{\\batchmode}, etc.~) */
205 letterspace_font_cmd, /* letterspace a font ( \.{\\letterspacefont} ) */
206 expand_font_cmd, /* expand glyphs ( \.{\\expandglyphsinfont} ) */
207 copy_font_cmd, /* create a new font instance ( \.{\\copyfont} ) */
208 set_font_id_cmd,
209 undefined_cs_cmd, /* initial state of most |eq_type| fields */
210 expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */
211 no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */
212 input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or \.{\\scantokens} or \.{\\scantextokens} ) */
213 lua_expandable_call_cmd,
214 lua_local_call_cmd,
215 if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */
216 fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */
217 cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */
218 convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */
219 variable_cmd,
220 feedback_cmd,
221 the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */
222 top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */
223 call_cmd, /* non-long, non-outer control sequence */
224 long_call_cmd, /* long, non-outer control sequence */
225 outer_call_cmd, /* non-long, outer control sequence */
226 long_outer_call_cmd, /* long, outer control sequence */
227 end_template_cmd, /* end of an alignment template */
228 dont_expand_cmd, /* the following token was marked by \.{\\noexpand} */
229 glue_ref_cmd, /* the equivalent points to a glue specification */
230 shape_ref_cmd, /* the equivalent points to a parshape specification */
231 box_ref_cmd, /* the equivalent points to a box node, or is |null| */
232 data_cmd, /* the equivalent is simply a halfword number */
233 } tex_command_code;
234
235 # define max_command_cmd set_font_id_cmd /* the largest command code seen at |big_switch| */
236 # define last_cmd data_cmd
237 # define max_non_prefixed_command last_item_cmd
238
239 typedef enum {
240 above_code = 0,
241 over_code = 1,
242 atop_code = 2,
243 skewed_code = 3,
244 delimited_code = 4,
245 } fraction_codes;
246
247 typedef enum {
248 number_code = 0, /* command code for \.{\\number} */
249 lua_code, /* command code for \.{\\directlua} */
250 lua_function_code, /* command code for \.{\\luafunction} */
251 lua_bytecode_code, /* command code for \.{\\luabytecode} */
252 expanded_code, /* command code for \.{\\expanded} */
253 immediate_assignment_code, /* command code for \.{\\immediateassignment} */
254 immediate_assigned_code, /* command code for \.{\\assigned} */
255 math_style_code, /* command code for \.{\\mathstyle} */
256 string_code, /* command code for \.{\\string} */
257 cs_string_code, /* command code for \.{\\csstring} */
258 roman_numeral_code, /* command code for \.{\\romannumeral} */
259 meaning_code, /* command code for \.{\\meaning} */
260 uchar_code, /* command code for \.{\\Uchar} */
261 lua_escape_string_code, /* command code for \.{\\luaescapestring} */
262 font_id_code, /* command code for \.{\\fontid} */
263 font_name_code, /* command code for \.{\\fontname} */
264 left_margin_kern_code, /* command code for \.{\\leftmarginkern} */
265 right_margin_kern_code, /* command code for \.{\\rightmarginkern} */
266 uniform_deviate_code, /* command code for \.{\\uniformdeviate} */
267 normal_deviate_code, /* command code for \.{\\normaldeviate} */
268 math_char_class_code,
269 math_char_fam_code,
270 math_char_slot_code,
271 insert_ht_code, /* command code for \.{\\insertht} */
272 job_name_code, /* command code for \.{\\jobname} */
273 format_name_code, /* command code for \.{\\AlephVersion} */
274 luatex_banner_code, /* command code for \.{\\luatexbanner}: */
275 luatex_revision_code, /* command code for \.{\\luatexrevision} */
276 etex_code, /* command code for \.{\\eTeXVersion} */
277 eTeX_revision_code, /* command code for \.{\\eTeXrevision} */
278 font_identifier_code, /* command code for \.{tex.fontidentifier} (virtual) */
279 /* backend */
280 dvi_feedback_code,
281 pdf_feedback_code,
282 dvi_variable_code,
283 pdf_variable_code,
284 } convert_codes;
285
286 typedef enum {
287 lastpenalty_code = 0, /* code for \.{\\lastpenalty} */
288 lastattr_code, /* not used */
289 lastkern_code, /* code for \.{\\lastkern} */
290 lastskip_code, /* code for \.{\\lastskip} */
291 last_node_type_code, /* code for \.{\\lastnodetype} */
292 input_line_no_code, /* code for \.{\\inputlineno} */
293 badness_code, /* code for \.{\\badness} */
294 last_saved_box_resource_index_code, /* code for \.{\\lastsavedboxresourceindex} */
295 last_saved_image_resource_index_code, /* code for \.{\\lastsavedimageresourceindex} */
296 last_saved_image_resource_pages_code, /* code for \.{\\lastsavedimageresourcepages} */
297 last_x_pos_code, /* code for \.{\\lastxpos} */
298 last_y_pos_code, /* code for \.{\\lastypos} */
299 random_seed_code, /* code for \.{\\randomseed} */
300 luatex_version_code, /* code for \.{\\luatexversion} */
301 eTeX_minor_version_code, /* code for \.{\\eTeXminorversion} */
302 eTeX_version_code, /* code for \.{\\eTeXversion} */
303 # define eTeX_int eTeX_version_code /* first of \eTeX\ codes for integers */
304 current_group_level_code, /* code for \.{\\currentgrouplevel} */
305 current_group_type_code, /* code for \.{\\currentgrouptype} */
306 current_if_level_code, /* code for \.{\\currentiflevel} */
307 current_if_type_code, /* code for \.{\\currentiftype} */
308 current_if_branch_code, /* code for \.{\\currentifbranch} */
309 glue_stretch_order_code, /* code for \.{\\gluestretchorder} */
310 glue_shrink_order_code, /* code for \.{\\glueshrinkorder} */
311 eTeX_glue_stretch_order_code, /* code for \.{\\eTeXgluestretchorder} */
312 eTeX_glue_shrink_order_code, /* code for \.{\\eTeXglueshrinkorder} */
313 font_char_wd_code, /* code for \.{\\fontcharwd} */
314 # define eTeX_dim font_char_wd_code /* first of \eTeX\ codes for dimensions */
315 font_char_ht_code, /* code for \.{\\fontcharht} */
316 font_char_dp_code, /* code for \.{\\fontchardp} */
317 font_char_ic_code, /* code for \.{\\fontcharic} */
318 par_shape_length_code, /* code for \.{\\parshapelength} */
319 par_shape_indent_code, /* code for \.{\\parshapeindent} */
320 par_shape_dimen_code, /* code for \.{\\parshapedimen} */
321 glue_stretch_code, /* code for \.{\\gluestretch} */
322 glue_shrink_code, /* code for \.{\\glueshrink} */
323 mu_to_glue_code, /* code for \.{\\mutoglue} */
324 # define eTeX_glue mu_to_glue_code /* first of \eTeX\ codes for glue */
325 glue_to_mu_code, /* code for \.{\\gluetomu} */
326 # define eTeX_mu glue_to_mu_code /* first of \eTeX\ codes for muglue */
327 numexpr_code, /* code for \.{\\numexpr} */
328 # define eTeX_expr numexpr_code /* first of \eTeX\ codes for expressions */
329 attrexpr_code, /* not used */
330 dimexpr_code, /* code for \.{\\dimexpr} */
331 glueexpr_code, /* code for \.{\\glueexpr} */
332 muexpr_code, /* code for \.{\\muexpr} */
333 } last_item_codes;
334
335
336 typedef enum {
337 save_cat_code_table_code=0,
338 init_cat_code_table_code,
339 set_random_seed_code,
340 save_pos_code,
341 late_lua_code,
342 late_lua_call_code,
343 expand_font_code,
344 } normal_codes;
345
346 typedef enum {
347 lp_code_base = 2,
348 rp_code_base = 3,
349 ef_code_base = 4,
350 tag_code = 5,
351 no_lig_code = 6,
352 gp_code_base = 7
353 } font_codes ;
354
355 # define immediate_code 4 /* reserved_immediate_code */ /* command modifier for \.{\\immediate} */
356 # define deferred_code 5 /* reserved_deferred_code */ /* command modifier for \.{\\deferred} */
357
358 extern void initialize_commands(void);
359 extern void initialize_etex_commands(void);
360
361 #endif