Added package with the documentation and the examples
[lwc.git] / norm.h
blob46fcef53987b4b9847de80c6ad8cc1e79ab1b875
2 #define ESCBASE 10000
3 #define IDENTBASE 20000
4 #define DYNBASE 500000
5 #define ARGBASE 990000
6 #define VALBASE 1000000
7 #define STRBASE 2000000
8 #define XCOMMENT 3000000
10 // control sequences
11 enum {
12 THE_END = 1,
13 RETRY,
14 CPP_CONCAT,
15 CPP_DIRECTIVE
18 // C/C++ operators
19 enum {
20 ELLIPSIS = 650,
21 POINTSAT,
22 MINUSMINUS,
23 PLUSPLUS,
24 GEQCMP,
25 LSH,
26 OROR,
27 ANDAND,
28 EQCMP,
29 NEQCMP,
30 RSH,
31 LEQCMP,
32 PERLOP,
35 // '='
36 enum {
37 ASSIGNA = 670,
38 ASSIGNS,
39 ASSIGNM,
40 ASSIGND,
41 ASSIGNR,
42 ASSIGNBA,
43 ASSIGNBX,
44 ASSIGNBO,
45 ASSIGNRS,
46 ASSIGNLS
49 #define ISASSIGNMENT(x) (x >= ASSIGNA && x <= ASSIGNLS)
51 #define NOTHING 695
52 #define NOOBJ 697
53 #define MARKER 699
54 #define DBG_MARK 698
55 #define UWMARK 696
57 enum {
58 // C declaration flags
59 RESERVED_auto = IDENTBASE,
60 RESERVED_const,
61 RESERVED_extern,
62 RESERVED_static,
63 RESERVED_inline,
64 RESERVED_typedef,
65 RESERVED___thread,
66 RESERVED_register,
67 RESERVED_volatile,
68 RESERVED_final,
69 RESERVED_linkonce,
70 RESERVED___unwind__,
71 RESERVED___noctor__,
72 RESERVED___emit_vtbl__,
73 RESERVED_modular,
74 RESERVED_virtual,
75 #define ISDCLFLAG(x) (x >= RESERVED_auto && x <= RESERVED_virtual)
76 #define ISCDCLFLAG(x) (x <= RESERVED_volatile)
78 // these can define a type
79 RESERVED_long,
80 RESERVED_short,
81 RESERVED_signed,
82 RESERVED_unsigned,
84 // C base types
85 RESERVED_void,
86 RESERVED_char,
87 RESERVED_int,
88 RESERVED_float,
89 RESERVED_double,
90 #define ISTBASETYPE(x) (x >= RESERVED_long && x <= RESERVED_double)
91 #define ISBUILTIN(x) (x >= RESERVED_void && x <= RESERVED_double)
93 // C aggregate specs
94 RESERVED_enum,
95 RESERVED_benum,
96 RESERVED_struct,
97 RESERVED_class,
98 RESERVED_union,
99 #define ISAGGRSPC(x) (x >= RESERVED_enum && x <= RESERVED_union)
101 // standard C reserved
102 RESERVED_break,
103 RESERVED_case,
104 RESERVED_continue,
105 RESERVED_default,
106 RESERVED_do,
107 RESERVED_else,
108 RESERVED_for,
109 RESERVED_goto,
110 RESERVED_if,
111 RESERVED_return,
112 RESERVED_sizeof,
113 RESERVED_switch,
114 RESERVED_while,
116 RESERVED___asm__,
117 RESERVED___extension__,
118 RESERVED___attribute__,
119 RESERVED___restrict,
121 // our own lwc reserved words
122 RESERVED_template,
123 RESERVED_bool,
124 RESERVED_true,
125 RESERVED_false,
126 RESERVED_this,
127 RESERVED_new,
128 RESERVED_delete,
129 RESERVED_localloc,
130 RESERVED_operator,
131 RESERVED_try,
132 RESERVED_throw,
133 RESERVED_typeof,
134 RESERVED_specialize,
135 RESERVED_postfix,
136 RESERVED_dereference,
137 RESERVED_RegExp,
138 RESERVED___declexpr__,
139 RESERVED__lwc_config_,
140 RESERVED___C__,
142 #define ISRESERVED(x) (x >= RESERVED_auto && x <= RESERVED__lwc_config_)
144 // * * * * * * * * * * * * * * * * * * *
145 // these below fail the ISRESERVED test
146 // and pass the ISSYMBOL test. they are
147 // not reserved and can be used for
148 // various other things
149 // * * * * * * * * * * * * * * * * * * *
151 #define SYMBASE RESERVED_include
152 RESERVED_include,
153 RESERVED_define,
154 RESERVED_undef,
155 RESERVED_endif,
156 RESERVED_ifdef,
157 RESERVED_ifndef,
158 RESERVED_elif,
159 RESERVED_error,
160 RESERVED_line,
161 RESERVED_uses,
162 RESERVED___VA_ARGS__,
163 RESERVED_defined,
165 RESERVED___LINE__,
166 RESERVED___FILE__,
167 RESERVED___TIME__,
168 RESERVED___DATE__,
169 #define ISPREDEF(x) (x >= RESERVED___LINE__ && x <= RESERVED___DATE__)
171 RESERVED__,
172 RESERVED_ctor,
173 RESERVED_dtor,
174 RESERVED_nothrow,
175 RESERVED_alias,
176 RESERVED_used,
177 RESERVED_public,
178 RESERVED_private,
179 RESERVED___typeof__,
180 RESERVED___enumstr__,
181 RESERVED___inset__,
182 RESERVED__v_p_t_r_,
183 RESERVED__CLASS_,
184 RESERVED_typeid,
185 RESERVED__loadtext,
186 RESERVED__random_,
187 RESERVED_main,
188 RESERVED_size_t,
189 RESERVED_wchar_t,
190 RESERVED_malloc,
191 RESERVED_free,
192 RESERVED_alloca,
193 RESERVED___builtin_alloca,
194 RESERVED_jmp_buf,
195 RESERVED_setjmp,
196 RESERVED_longjmp,
197 RESERVED___on_throw__,
199 RESERVED___builtin_memcpy,
200 RESERVED_memcpy,
201 RESERVED_strncmp,
202 RESERVED___builtin_strncmp,
203 RESERVED_strncasecmp,
204 RESERVED___builtin_strncasecmp,
205 RESERVED___FUNCTION__,
206 RESERVED___PRETTY_FUNCTION__,
207 RESERVED___section__,
208 RESERVED___label__,
209 RESERVED_noreturn,
210 RESERVED_constructor,
211 RESERVED___lwc_unwind,
212 RESERVED___lwc_landingpad,
214 RESERVED_p,
215 RESERVED_pos,
216 RESERVED_len,
217 RESERVED_min,
218 RESERVED_max,
219 RESERVED_charp_len,
220 RESERVED_abbrev,
221 RESERVED_strlen,
222 RESERVED_a,
223 RESERVED_x,
224 RESERVED_X,
225 RESERVED_y,
226 RESERVED_j,
227 RESERVED_s,
228 RESERVED_i,
230 // operator overloaders -safe-
231 RESERVED_oper_plus,
232 RESERVED_oper_minus,
233 RESERVED_oper_thingy,
234 RESERVED_oper_fcall,
235 RESERVED_oper_comma,
236 RESERVED_oper_mod,
237 RESERVED_oper_or,
238 RESERVED_oper_and,
239 RESERVED_oper_xor,
240 RESERVED_oper_lsh,
241 RESERVED_oper_rsh,
242 RESERVED_oper_mul,
243 RESERVED_oper_div,
244 RESERVED_oper_andand,
245 RESERVED_oper_oror,
246 RESERVED_oper_as_m,
247 RESERVED_oper_as_d,
248 RESERVED_oper_as_r,
249 RESERVED_oper_as_ba,
250 RESERVED_oper_as_bx,
251 RESERVED_oper_as_bo,
252 RESERVED_oper_as_rs,
253 RESERVED_oper_as_ls,
255 // operator overloaders -unsafe-
256 RESERVED_oper_star,
257 RESERVED_oper_excl,
258 RESERVED_oper_array,
259 RESERVED_oper_plusplus,
260 RESERVED_oper_minusminus,
261 RESERVED_oper_plusplusp,
262 RESERVED_oper_minusminusp,
263 RESERVED_oper_add,
264 RESERVED_oper_sub,
265 RESERVED_oper_gr,
266 RESERVED_oper_le,
267 RESERVED_oper_greq,
268 RESERVED_oper_leq,
269 RESERVED_oper_eq,
270 RESERVED_oper_neq,
271 RESERVED_oper_assign,
272 RESERVED_oper_as_a,
273 RESERVED_oper_as_s,
274 RESERVED_oper_pointsat
277 #define ISIDENT(x) (x >= IDENTBASE && x < VALBASE)
278 #define ISSYMBOL(x) (x >= SYMBASE && x < VALBASE)
279 static inline int issymbol (int x) { return ISSYMBOL (x); }
280 #define ISVALUE(x) (x >= VALBASE)
281 static inline int isvalue (int x) { return ISVALUE (x); }
282 #define ISSYMVAL(x) (x >= SYMBASE)
283 static inline int isoperator (int x)
284 { return x <= '~' || x > ELLIPSIS && x <= ASSIGNLS || x == RESERVED_sizeof; }
285 static inline int isescoperator (int x)
286 { return x > ESCBASE && x < IDENTBASE ? x - ESCBASE : 0; }
287 #define ISTPLARG(x) (x >= ARGBASE && x < VALBASE)
288 static inline int isaggrspc (int x) { return ISAGGRSPC(x); }
289 static inline int isdclflag (int x) { return ISDCLFLAG (x); }
292 static inline int isoperfunc (int x) { return x >= RESERVED_oper_plus && x <= RESERVED_oper_pointsat; }
293 static inline int isunsafeop (int x) { return x >= RESERVED_oper_star && x <= RESERVED_oper_pointsat; }
295 // these are special values -- they match ISVALUE
296 enum {
297 RESERVED_0 = VALBASE,
298 RESERVED_1,
299 RESERVED_3,
300 RESERVED_C