fixed a bug in openMemStream (LS); deleted unused close_lua_node (HH)
[luatex.git] / source / texk / web2c / luatexdir / tex / commands.h
blobc8200ab93f83854d3a7e0a3f44fce5490572dc42
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
89 /* largest catcode for individual characters */
90 char_num_cmd, /* character specified numerically ( \.{\\char} ) */
91 math_char_num_cmd, /* explicit math code ( \.{\\mathchar} ) */
92 mark_cmd, /* mark definition ( \.{\\mark} ) */
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
99 \.{\\pagediscards}, \.{\\splitdiscards} ) */
100 remove_item_cmd, /* nullify last item ( \.{\\unpenalty}, \.{\\unkern}, \.{\\unskip} ) */
101 hskip_cmd, /* horizontal glue ( \.{\\hskip}, \.{\\hfil}, etc.~) */
102 vskip_cmd, /* vertical glue ( \.{\\vskip}, \.{\\vfil}, etc.~) */
103 mskip_cmd, /* math glue ( \.{\\mskip} ) */
104 kern_cmd, /* fixed space ( \.{\\kern}) */
105 mkern_cmd, /* math kern ( \.{\\mkern} ) */
106 leader_ship_cmd, /* use a box ( \.{\\shipout}, \.{\\leaders}, etc.~) */
107 halign_cmd, /* horizontal table alignment ( \.{\\halign} ) */
108 valign_cmd, /* vertical table alignment ( \.{\\valign} ) */
109 no_align_cmd, /* temporary escape from alignment ( \.{\\noalign} ) */
110 vrule_cmd, /* vertical rule ( \.{\\vrule} ) */
111 hrule_cmd, /* horizontal rule ( \.{\\hrule} ) */
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 extension_cmd, /* extensions to \TeX\ ( \.{\\write}, \.{\\special}, etc.~) */
135 in_stream_cmd, /* files for reading ( \.{\\openin}, \.{\\closein} ) */
136 begin_group_cmd, /* begin local grouping ( \.{\\begingroup} ) */
137 end_group_cmd, /* end local grouping ( \.{\\endgroup} ) */
138 omit_cmd, /* omit alignment template ( \.{\\omit} ) */
139 ex_space_cmd, /* explicit space ( \.{\\\ } ) */
140 no_boundary_cmd, /* suppress boundary ligatures ( \.{\\noboundary} ) */
141 radical_cmd, /* square root and similar signs ( \.{\\radical} ) */
142 super_sub_script_cmd, /* explicit super- or subscript */
143 math_shift_cs_cmd, /* start- and endmath */
144 end_cs_name_cmd, /* end control sequence ( \.{\\endcsname} ) */
145 char_ghost_cmd, /* \.{\\leftghost}, \.{\\rightghost} character for kerning */
146 assign_local_box_cmd, /* box for guillemets \.{\\localleftbox} or \.{\\localrightbox} */
147 char_given_cmd, /* character code defined by \.{\\chardef} */
148 # define min_internal_cmd char_given_cmd
149 /* the smallest code that can follow \.{\\the} */
150 math_given_cmd, /* math code defined by \.{\\mathchardef} */
151 xmath_given_cmd, /* math code defined by \.{\\Umathchardef} or \.{\\Umathcharnumdef} */
152 last_item_cmd, /* most recent item ( \.{\\lastpenalty}, \.{\\lastkern}, \.{\\lastskip} ) */
153 # define max_non_prefixed_command_cmd last_item_cmd /* largest command code that can't be \.{\\global} */
154 toks_register_cmd, /* token list register ( \.{\\toks} ) */
155 assign_toks_cmd, /* special token list ( \.{\\output}, \.{\\everypar}, etc.~) */
156 assign_int_cmd, /* user-defined integer ( \.{\\tolerance}, \.{\\day}, etc.~) */
157 assign_attr_cmd, /* user-defined attributes */
158 assign_dimen_cmd, /* user-defined length ( \.{\\hsize}, etc.~) */
159 assign_glue_cmd, /* user-defined glue ( \.{\\baselineskip}, etc.~) */
160 assign_mu_glue_cmd, /* user-defined muglue ( \.{\\thinmuskip}, etc.~) */
161 assign_font_dimen_cmd, /* user-defined font dimension ( \.{\\fontdimen} ) */
162 assign_font_int_cmd, /* user-defined font integer ( \.{\\hyphenchar}, \.{\\skewchar} ) */
163 set_aux_cmd, /* specify state info ( \.{\\spacefactor}, \.{\\prevdepth} ) */
164 set_prev_graf_cmd, /* specify state info ( \.{\\prevgraf} ) */
165 set_page_dimen_cmd, /* specify state info ( \.{\\pagegoal}, etc.~) */
166 set_page_int_cmd, /* specify state info ( \.{\\deadcycles}, \.{\\insertpenalties} ) */
167 set_box_dimen_cmd, /* change dimension of box ( \.{\\wd}, \.{\\ht}, \.{\\dp} ) */
168 set_tex_shape_cmd, /* specify fancy paragraph shape ( \.{\\parshape} ) */
169 set_etex_shape_cmd, /* specify etex extended list ( \.{\\interlinepenalties}, etc.~) */
170 def_char_code_cmd, /* define a character code ( \.{\\catcode}, etc.~) */
171 def_del_code_cmd, /* define a delimiter code ( \.{\\delcode}) */
172 extdef_math_code_cmd, /* define an extended character code ( \.{\\Umathcode}, etc.~) */
173 extdef_del_code_cmd, /* define an extended delimiter code ( \.{\\Udelcode}, etc.~) */
174 def_family_cmd, /* declare math fonts ( \.{\\textfont}, etc.~) */
175 set_math_param_cmd, /* set math parameters ( \.{\\mathquad}, etc.~) */
176 set_font_cmd, /* set current font ( font identifiers ) */
177 def_font_cmd, /* define a font file ( \.{\\font} ) */
178 register_cmd, /* internal register ( \.{\\count}, \.{\\dimen}, etc.~) */
179 assign_box_dir_cmd, /* (\.{\\boxdir}) */
180 assign_dir_cmd, /* (\.{\\pagedir}, \.{\\textdir}) */
181 # define max_internal_cmd assign_dir_cmd
182 /* 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 pdf_copy_font_cmd, /* create a new font instance ( \.{\\pdfcopyfont} ) */
196 undefined_cs_cmd, /* initial state of most |eq_type| fields */
197 expand_after_cmd, /* special expansion ( \.{\\expandafter} ) */
198 no_expand_cmd, /* special nonexpansion ( \.{\\noexpand} ) */
199 input_cmd, /* input a source file ( \.{\\input}, \.{\\endinput} or
200 \.{\\scantokens} or \.{\\scantextokens} ) */
201 if_test_cmd, /* conditional text ( \.{\\if}, \.{\\ifcase}, etc.~) */
202 fi_or_else_cmd, /* delimiters for conditionals ( \.{\\else}, etc.~) */
203 cs_name_cmd, /* make a control sequence from tokens ( \.{\\csname} ) */
204 convert_cmd, /* convert to text ( \.{\\number}, \.{\\string}, etc.~) */
205 the_cmd, /* expand an internal quantity ( \.{\\the} or \.{\\unexpanded}, \.{\\detokenize} ) */
206 top_bot_mark_cmd, /* inserted mark ( \.{\\topmark}, etc.~) */
207 call_cmd, /* non-long, non-outer control sequence */
208 long_call_cmd, /* long, non-outer control sequence */
209 outer_call_cmd, /* non-long, outer control sequence */
210 long_outer_call_cmd, /* long, outer control sequence */
211 end_template_cmd, /* end of an alignment template */
212 dont_expand_cmd, /* the following token was marked by \.{\\noexpand} */
213 glue_ref_cmd, /* the equivalent points to a glue specification */
214 shape_ref_cmd, /* the equivalent points to a parshape specification */
215 box_ref_cmd, /* the equivalent points to a box node, or is |null| */
216 data_cmd, /* the equivalent is simply a halfword number */
217 } tex_command_code;
219 # define max_command_cmd pdf_copy_font_cmd /* the largest command code seen at |big_switch| */
220 # define last_cmd data_cmd
221 # define max_non_prefixed_command last_item_cmd
223 typedef enum {
224 above_code = 0,
225 over_code = 1,
226 atop_code = 2,
227 delimited_code = 3
228 } fraction_codes;
230 typedef enum {
231 number_code = 0, /* command code for \.{\\number} */
232 roman_numeral_code, /* command code for \.{\\romannumeral} */
233 string_code, /* command code for \.{\\string} */
234 meaning_code, /* command code for \.{\\meaning} */
235 font_name_code, /* command code for \.{\\fontname} */
236 etex_code, /* command code for \.{\\eTeXVersion} */
237 format_name_code, /* command code for \.{\\AlephVersion} */
238 luatex_banner_code, /* command code for \.{\\luatexbanner}: */
239 pdf_font_name_code, /* command code for \.{\\pdffontname} */
240 pdf_font_objnum_code, /* command code for \.{\\pdffontobjnum} */
241 pdf_font_size_code, /* command code for \.{\\pdffontsize} */
242 pdf_page_ref_code, /* command code for \.{\\pdfpageref} */
243 pdf_xform_name_code, /* command code for \.{\\pdfxformname} */
244 left_margin_kern_code, /* command code for \.{\\leftmarginkern} */
245 right_margin_kern_code, /* command code for \.{\\rightmarginkern} */
246 pdf_creation_date_code, /* command code for \.{\\pdfcreationdate} */
247 uniform_deviate_code, /* command code for \.{\\uniformdeviate} */
248 normal_deviate_code, /* command code for \.{\\normaldeviate} */
249 pdf_insert_ht_code, /* command code for \.{\\pdfinsertht} */
250 pdf_ximage_bbox_code, /* command code for \.{\\pdfximagebbox} */
251 lua_code, /* command code for \.{\\directlua} */
252 lua_escape_string_code, /* command code for \.{\\luaescapestring} */
253 pdf_colorstack_init_code, /* command code for \.{\\pdfcolorstackinit} */
254 luatex_revision_code, /* command code for \.{\\luatexrevision} */
255 luatex_date_code, /* command code for \.{\\luatexdate} */
256 math_style_code, /* command code for \.{\\mathstyle} */
257 expanded_code, /* command code for \.{\\expanded} */
258 job_name_code, /* command code for \.{\\jobname} */
259 eTeX_revision_code, /* command code for \.{\\eTeXrevision} */
260 font_identifier_code, /* command code for \.{tex.fontidentifier} (virtual) */
261 font_id_code, /* command code for \.{\\fontid} */
262 uchar_code, /* command code for \.{\\Uchar} */
263 lua_function_code, /* command code for \.{\\luafunction} */
264 } convert_codes;
266 typedef enum {
267 lastpenalty_code = 0, /* code for \.{\\lastpenalty} */
268 lastattr_code, /* not used */
269 lastkern_code, /* code for \.{\\lastkern} */
270 lastskip_code, /* code for \.{\\lastskip} */
271 last_node_type_code, /* code for \.{\\lastnodetype} */
272 input_line_no_code, /* code for \.{\\inputlineno} */
273 badness_code, /* code for \.{\\badness} */
274 pdf_last_obj_code, /* code for \.{\\pdflastobj} */
275 pdf_last_xform_code, /* code for \.{\\pdflastxform} */
276 pdf_last_ximage_code, /* code for \.{\\pdflastximage} */
277 pdf_last_ximage_pages_code, /* code for \.{\\pdflastximagepages} */
278 pdf_last_annot_code, /* code for \.{\\pdflastannot} */
279 last_x_pos_code, /* code for \.{\\lastxpos} */
280 last_y_pos_code, /* code for \.{\\lastypos} */
281 pdf_retval_code, /* global multi-purpose return value */
282 pdf_last_ximage_colordepth_code, /* code for \.{\\pdflastximagecolordepth} */
283 random_seed_code, /* code for \.{\\pdfrandomseed} */
284 pdf_last_link_code, /* code for \.{\\pdflastlink} */
285 luatex_version_code, /* code for \.{\\luatexversion} */
286 eTeX_minor_version_code, /* code for \.{\\eTeXminorversion} */
287 eTeX_version_code, /* code for \.{\\eTeXversion} */
288 # define eTeX_int eTeX_version_code /* first of \eTeX\ codes for integers */
289 current_group_level_code, /* code for \.{\\currentgrouplevel} */
290 current_group_type_code, /* code for \.{\\currentgrouptype} */
291 current_if_level_code, /* code for \.{\\currentiflevel} */
292 current_if_type_code, /* code for \.{\\currentiftype} */
293 current_if_branch_code, /* code for \.{\\currentifbranch} */
294 glue_stretch_order_code, /* code for \.{\\gluestretchorder} */
295 glue_shrink_order_code, /* code for \.{\\glueshrinkorder} */
296 font_char_wd_code, /* code for \.{\\fontcharwd} */
297 # define eTeX_dim font_char_wd_code /* first of \eTeX\ codes for dimensions */
298 font_char_ht_code, /* code for \.{\\fontcharht} */
299 font_char_dp_code, /* code for \.{\\fontchardp} */
300 font_char_ic_code, /* code for \.{\\fontcharic} */
301 par_shape_length_code, /* code for \.{\\parshapelength} */
302 par_shape_indent_code, /* code for \.{\\parshapeindent} */
303 par_shape_dimen_code, /* code for \.{\\parshapedimen} */
304 glue_stretch_code, /* code for \.{\\gluestretch} */
305 glue_shrink_code, /* code for \.{\\glueshrink} */
306 mu_to_glue_code, /* code for \.{\\mutoglue} */
307 # define eTeX_glue mu_to_glue_code /* first of \eTeX\ codes for glue */
308 glue_to_mu_code, /* code for \.{\\gluetomu} */
309 # define eTeX_mu glue_to_mu_code
310 /* 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;
319 # define explicit 1
320 # define acc_kern 2
321 # define lp_code_base 2
322 # define rp_code_base 3
323 # define ef_code_base 4
324 # define tag_code 5
325 # define auto_kern explicit
326 # define no_lig_code 6
328 # define immediate_code 4 /* command modifier for \.{\\immediate} */
330 extern void initialize_commands(void);
332 extern void initialize_etex_commands(void);
334 #endif