Debian Codegraph @

texk/web2c/luatexdir/tex/textoken.h

raw
1 /* textoken.h
2
3 Copyright 2006-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 TEXTOKEN_H
22 # define TEXTOKEN_H
23
24 # define token_list 0
25 # define null 0
26 # define cs_token_flag 0x1FFFFFFF
27
28 # define left_brace_token 0x0200000 /* $2^{21}\cdot|left_brace|$ */
29 # define right_brace_token 0x0400000 /* $2^{21}\cdot|right_brace|$ */
30 # define left_brace_limit 0x0400000 /* $2^{21}\cdot(|left_brace|+1)$ */
31 # define right_brace_limit 0x0600000 /* $2^{21}\cdot(|right_brace|+1)$ */
32 # define math_shift_token 0x0600000 /* $2^{21}\cdot|math_shift|$ */
33 # define tab_token 0x0800000 /* $2^{21}\cdot|tab_mark|$ */
34 # define out_param_token 0x0A00000 /* $2^{21}\cdot|out_param|$ */
35 # define space_token 0x1400020 /* $2^{21}\cdot|spacer|+|" "|$ */
36 # define letter_token 0x1600000 /* $2^{21}\cdot|letter|$ */
37 # define other_token 0x1800000 /* $2^{21}\cdot|other_char|$ */
38 # define match_token 0x1A00000 /* $2^{21}\cdot|match|$ */
39 # define end_match_token 0x1C00000 /* $2^{21}\cdot|end_match|$ */
40 # define protected_token 0x1C00001 /* $2^{21}\cdot|end_match|+1$ */
41
42 # include "tex/stringpool.h"
43
44 typedef struct smemory_word_ {
45 # ifdef WORDS_BIGENDIAN
46 halfword hhrh;
47 halfword hhlh;
48 # else
49 halfword hhlh;
50 halfword hhrh;
51 # endif
52 } smemory_word;
53
54 # define fix_mem_init 10000
55
56 extern smemory_word *fixmem;
57 extern unsigned fix_mem_min;
58 extern unsigned fix_mem_max;
59
60 extern halfword garbage; /* head of a junk list, write only */
61 extern halfword temp_token_head; /* head of a temporary list of some kind */
62 extern halfword hold_token_head; /* head of a temporary list of another kind */
63 extern halfword omit_template; /* a constant token list */
64 extern halfword null_list; /* permanently empty list */
65 extern halfword backup_head; /* head of token list built by |scan_keyword| */
66
67 extern void initialize_tokens(void);
68
69 extern int dyn_used;
70
71 # define token_info(a) fixmem[(a)].hhlh
72 # define token_link(a) fixmem[(a)].hhrh
73 # define set_token_info(a,b) fixmem[(a)].hhlh=(b)
74 # define set_token_link(a,b) fixmem[(a)].hhrh=(b)
75
76 extern halfword avail; /* head of the list of available one-word nodes */
77 extern unsigned fix_mem_end; /* the last one-word node used in |mem| */
78
79 extern halfword get_avail(void);
80
81 /* A one-word node is recycled by calling |free_avail|.
82 This routine is part of \TeX's ``inner loop,'' so we want it to be fast.
83 */
84
85 # define free_avail(A) do { /* single-word node liberation */ \
86 token_link(A)=avail; avail=(A); decr(dyn_used); \
87 } while (0)
88
89 /*
90 There's also a |fast_get_avail| routine, which saves the procedure-call
91 overhead at the expense of extra programming. This routine is used in
92 the places that would otherwise account for the most calls of |get_avail|.
93 */
94
95 # define fast_get_avail(A) do { \
96 (A)=avail; /* avoid |get_avail| if possible, to save time */ \
97 if ((A)==null) { (A)=get_avail(); } \
98 else { avail=token_link((A)); token_link((A))=null; incr(dyn_used); } \
99 } while (0)
100
101 extern void print_meaning(void);
102
103 extern void flush_list(halfword p);
104 extern void show_token_list(int p, int q, int l);
105 extern void token_show(halfword p);
106
107 # define token_ref_count(a) token_info((a)) /* reference count preceding a token list */
108 # define set_token_ref_count(a,b) token_info((a))=b
109 # define add_token_ref(a) token_ref_count(a)++ /* new reference to a token list */
110
111 # define store_new_token(a) do { \
112 q=get_avail(); token_link(p)=q; token_info(q)=(a); p=q; \
113 } while (0)
114
115 # define fast_store_new_token(a) do { \
116 fast_get_avail(q); token_link(p)=q; token_info(q)=(a); p=q; \
117 } while (0)
118
119 extern void delete_token_ref(halfword p);
120
121 extern void make_token_table(lua_State * L, int cmd, int chr, int cs);
122
123 # define NO_CAT_TABLE -2
124 # define DEFAULT_CAT_TABLE -1
125
126 extern void get_next(void);
127 extern void check_outer_validity(void);
128 extern boolean scan_keyword(const char *);
129 extern boolean scan_keyword_case_sensitive(const char *);
130 extern halfword active_to_cs(int, int);
131 extern void get_token_lua(void);
132 halfword string_to_toks(const char *);
133 extern int get_char_cat_code(int);
134
135 /*
136 |no_expand_flag| is a special character value that is inserted by
137 |get_next| if it wants to suppress expansion.
138 */
139
140 # define no_expand_flag special_char
141
142 extern halfword par_loc;
143 extern halfword par_token;
144 extern boolean force_eof;
145 extern int luacstrings;
146
147 extern void firm_up_the_line(void);
148 extern void get_token(void);
149
150 extern halfword str_toks(lstring b);
151 extern halfword str_scan_toks(int c, lstring b);
152 extern void ins_the_toks(void);
153 extern void combine_the_toks(void);
154
155 extern int scan_lua_state(void);
156
157 extern void conv_toks(void);
158 extern str_number the_convert_string(halfword c, int i);
159 extern void do_variable(void);
160 extern void do_feedback(void);
161 extern void do_mathoption(void);
162
163 extern halfword lua_str_toks(lstring b);
164 extern boolean in_lua_escape;
165
166 # define closed 2 /* not open, or at end of file */
167 # define just_open 1 /* newly opened, first line not yet read */
168
169 extern FILE *read_file[16]; /* used for \.{\\read} */
170 extern int read_open[17]; /* state of |read_file[n]| */
171
172 extern void initialize_read(void);
173
174 extern void read_toks(int n, halfword r, halfword j);
175
176 extern str_number tokens_to_string(halfword p); /* return a string from tokens list */
177
178 extern char *tokenlist_to_xstring(int p, int inhibit_par, int *siz);
179 extern char *tokenlist_to_cstring(int p, int inhibit_par, int *siz);
180 extern lstring *tokenlist_to_lstring(int pp, int inhibit_par);
181 extern void free_lstring(lstring * ls);
182
183 # define token_cmd(A) ((A) >> STRING_OFFSET_BITS)
184 # define token_chr(A) ((A) & (STRING_OFFSET - 1))
185 # define token_val(A,B) (((A)<<STRING_OFFSET_BITS)+(B))
186
187 extern void l_set_token_data(void) ;
188
189 #endif