f8c9b2ca18f6cb956f466ff529718092e6849d2c
[reactos.git] / reactos / tools / widl / parser.yy.c
1 #define yy_create_buffer parser__create_buffer
2 #define yy_delete_buffer parser__delete_buffer
3 #define yy_scan_buffer parser__scan_buffer
4 #define yy_scan_string parser__scan_string
5 #define yy_scan_bytes parser__scan_bytes
6 #define yy_flex_debug parser__flex_debug
7 #define yy_init_buffer parser__init_buffer
8 #define yy_flush_buffer parser__flush_buffer
9 #define yy_load_buffer_state parser__load_buffer_state
10 #define yy_switch_to_buffer parser__switch_to_buffer
11 #define yyin parser_in
12 #define yyleng parser_leng
13 #define yylex parser_lex
14 #define yyout parser_out
15 #define yyrestart parser_restart
16 #define yytext parser_text
17 #define yywrap parser_wrap
18
19 #line 20 "parser.yy.c"
20 /* A lexical scanner generated by flex */
21
22 /* Scanner skeleton version:
23 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
24 */
25
26 #define FLEX_SCANNER
27 #define YY_FLEX_MAJOR_VERSION 2
28 #define YY_FLEX_MINOR_VERSION 5
29
30 #include <stdio.h>
31
32
33 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
34 #ifdef c_plusplus
35 #ifndef __cplusplus
36 #define __cplusplus
37 #endif
38 #endif
39
40
41 #ifdef __cplusplus
42
43 #include <stdlib.h>
44 #include <unistd.h>
45
46 /* Use prototypes in function declarations. */
47 #define YY_USE_PROTOS
48
49 /* The "const" storage-class-modifier is valid. */
50 #define YY_USE_CONST
51
52 #else /* ! __cplusplus */
53
54 #if __STDC__
55
56 #define YY_USE_PROTOS
57 #define YY_USE_CONST
58
59 #endif /* __STDC__ */
60 #endif /* ! __cplusplus */
61
62 #ifdef __TURBOC__
63 #pragma warn -rch
64 #pragma warn -use
65 #include <io.h>
66 #include <stdlib.h>
67 #define YY_USE_CONST
68 #define YY_USE_PROTOS
69 #endif
70
71 #ifdef YY_USE_CONST
72 #define yyconst const
73 #else
74 #define yyconst
75 #endif
76
77
78 #ifdef YY_USE_PROTOS
79 #define YY_PROTO(proto) proto
80 #else
81 #define YY_PROTO(proto) ()
82 #endif
83
84 /* Returned upon end-of-file. */
85 #define YY_NULL 0
86
87 /* Promotes a possibly negative, possibly signed char to an unsigned
88 * integer for use as an array index. If the signed char is negative,
89 * we want to instead treat it as an 8-bit unsigned char, hence the
90 * double cast.
91 */
92 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
93
94 /* Enter a start condition. This macro really ought to take a parameter,
95 * but we do it the disgusting crufty way forced on us by the ()-less
96 * definition of BEGIN.
97 */
98 #define BEGIN yy_start = 1 + 2 *
99
100 /* Translate the current start state into a value that can be later handed
101 * to BEGIN to return to the state. The YYSTATE alias is for lex
102 * compatibility.
103 */
104 #define YY_START ((yy_start - 1) / 2)
105 #define YYSTATE YY_START
106
107 /* Action number for EOF rule of a given start state. */
108 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
109
110 /* Special action meaning "start processing a new file". */
111 #define YY_NEW_FILE yyrestart( yyin )
112
113 #define YY_END_OF_BUFFER_CHAR 0
114
115 /* Size of default input buffer. */
116 #define YY_BUF_SIZE 16384
117
118 typedef struct yy_buffer_state *YY_BUFFER_STATE;
119
120 extern int yyleng;
121 extern FILE *yyin, *yyout;
122
123 #define EOB_ACT_CONTINUE_SCAN 0
124 #define EOB_ACT_END_OF_FILE 1
125 #define EOB_ACT_LAST_MATCH 2
126
127 /* The funky do-while in the following #define is used to turn the definition
128 * int a single C statement (which needs a semi-colon terminator). This
129 * avoids problems with code like:
130 *
131 * if ( condition_holds )
132 * yyless( 5 );
133 * else
134 * do_something_else();
135 *
136 * Prior to using the do-while the compiler would get upset at the
137 * "else" because it interpreted the "if" statement as being all
138 * done when it reached the ';' after the yyless() call.
139 */
140
141 /* Return all but the first 'n' matched characters back to the input stream. */
142
143 #define yyless(n) \
144 do \
145 { \
146 /* Undo effects of setting up yytext. */ \
147 *yy_cp = yy_hold_char; \
148 YY_RESTORE_YY_MORE_OFFSET \
149 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
150 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
151 } \
152 while ( 0 )
153
154 #define unput(c) yyunput( c, yytext_ptr )
155
156 /* The following is because we cannot portably get our hands on size_t
157 * (without autoconf's help, which isn't available because we want
158 * flex-generated scanners to compile on their own).
159 */
160 typedef unsigned int yy_size_t;
161
162
163 struct yy_buffer_state
164 {
165 FILE *yy_input_file;
166
167 char *yy_ch_buf; /* input buffer */
168 char *yy_buf_pos; /* current position in input buffer */
169
170 /* Size of input buffer in bytes, not including room for EOB
171 * characters.
172 */
173 yy_size_t yy_buf_size;
174
175 /* Number of characters read into yy_ch_buf, not including EOB
176 * characters.
177 */
178 int yy_n_chars;
179
180 /* Whether we "own" the buffer - i.e., we know we created it,
181 * and can realloc() it to grow it, and should free() it to
182 * delete it.
183 */
184 int yy_is_our_buffer;
185
186 /* Whether this is an "interactive" input source; if so, and
187 * if we're using stdio for input, then we want to use getc()
188 * instead of fread(), to make sure we stop fetching input after
189 * each newline.
190 */
191 int yy_is_interactive;
192
193 /* Whether we're considered to be at the beginning of a line.
194 * If so, '^' rules will be active on the next match, otherwise
195 * not.
196 */
197 int yy_at_bol;
198
199 /* Whether to try to fill the input buffer when we reach the
200 * end of it.
201 */
202 int yy_fill_buffer;
203
204 int yy_buffer_status;
205 #define YY_BUFFER_NEW 0
206 #define YY_BUFFER_NORMAL 1
207 /* When an EOF's been seen but there's still some text to process
208 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
209 * shouldn't try reading from the input source any more. We might
210 * still have a bunch of tokens to match, though, because of
211 * possible backing-up.
212 *
213 * When we actually see the EOF, we change the status to "new"
214 * (via yyrestart()), so that the user can continue scanning by
215 * just pointing yyin at a new input file.
216 */
217 #define YY_BUFFER_EOF_PENDING 2
218 };
219
220 static YY_BUFFER_STATE yy_current_buffer = 0;
221
222 /* We provide macros for accessing buffer states in case in the
223 * future we want to put the buffer states in a more general
224 * "scanner state".
225 */
226 #define YY_CURRENT_BUFFER yy_current_buffer
227
228
229 /* yy_hold_char holds the character lost when yytext is formed. */
230 static char yy_hold_char;
231
232 static int yy_n_chars; /* number of characters read into yy_ch_buf */
233
234
235 int yyleng;
236
237 /* Points to current character in buffer. */
238 static char *yy_c_buf_p = (char *) 0;
239 static int yy_init = 1; /* whether we need to initialize */
240 static int yy_start = 0; /* start state number */
241
242 /* Flag which is used to allow yywrap()'s to do buffer switches
243 * instead of setting up a fresh yyin. A bit of a hack ...
244 */
245 static int yy_did_buffer_switch_on_eof;
246
247 void yyrestart YY_PROTO(( FILE *input_file ));
248
249 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
250 void yy_load_buffer_state YY_PROTO(( void ));
251 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
252 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
253 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
254 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
255 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
256
257 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
258 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
259 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
260
261 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
262 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
263 static void yy_flex_free YY_PROTO(( void * ));
264
265 #define yy_new_buffer yy_create_buffer
266
267 #define yy_set_interactive(is_interactive) \
268 { \
269 if ( ! yy_current_buffer ) \
270 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
271 yy_current_buffer->yy_is_interactive = is_interactive; \
272 }
273
274 #define yy_set_bol(at_bol) \
275 { \
276 if ( ! yy_current_buffer ) \
277 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
278 yy_current_buffer->yy_at_bol = at_bol; \
279 }
280
281 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
282
283 typedef unsigned char YY_CHAR;
284 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
285 typedef int yy_state_type;
286 extern char *yytext;
287 #define yytext_ptr yytext
288
289 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
290 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
291 static int yy_get_next_buffer YY_PROTO(( void ));
292 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
293
294 /* Done after the current pattern has been matched and before the
295 * corresponding action - sets up yytext.
296 */
297 #define YY_DO_BEFORE_ACTION \
298 yytext_ptr = yy_bp; \
299 yyleng = (int) (yy_cp - yy_bp); \
300 yy_hold_char = *yy_cp; \
301 *yy_cp = '\0'; \
302 yy_c_buf_p = yy_cp;
303
304 #define YY_NUM_RULES 23
305 #define YY_END_OF_BUFFER 24
306 static yyconst short int yy_accept[113] =
307 { 0,
308 0, 0, 0, 0, 0, 0, 2, 2, 24, 22,
309 19, 18, 3, 14, 14, 22, 22, 17, 17, 9,
310 19, 1, 8, 23, 4, 8, 14, 14, 11, 11,
311 10, 2, 0, 14, 0, 20, 21, 17, 17, 0,
312 1, 1, 7, 6, 5, 14, 0, 11, 11, 2,
313 15, 13, 17, 14, 0, 11, 0, 17, 14, 0,
314 11, 0, 15, 17, 14, 0, 11, 17, 14, 0,
315 11, 17, 14, 0, 11, 17, 14, 0, 11, 17,
316 0, 14, 0, 16, 0, 0, 0, 0, 0, 0,
317 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
318
319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
320 12, 0
321 } ;
322
323 static yyconst int yy_ec[256] =
324 { 0,
325 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
326 1, 2, 2, 1, 1, 1, 1, 1, 1, 1,
327 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
328 1, 2, 1, 4, 5, 1, 1, 1, 1, 6,
329 1, 1, 7, 1, 8, 9, 1, 10, 11, 11,
330 11, 11, 11, 11, 11, 11, 11, 1, 1, 12,
331 1, 13, 1, 1, 14, 15, 15, 15, 16, 17,
332 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
333 18, 19, 20, 18, 18, 18, 18, 18, 21, 18,
334 22, 23, 24, 1, 18, 1, 15, 15, 15, 15,
335
336 25, 15, 18, 18, 18, 18, 18, 18, 18, 18,
337 18, 18, 18, 18, 18, 18, 18, 18, 18, 26,
338 18, 18, 1, 1, 1, 1, 1, 1, 1, 1,
339 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
343 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
344 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
345 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
346
347 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
348 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
349 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
350 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
351 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
352 1, 1, 1, 1, 1
353 } ;
354
355 static yyconst int yy_meta[27] =
356 { 0,
357 1, 1, 2, 1, 1, 1, 1, 1, 1, 3,
358 3, 1, 1, 3, 3, 3, 3, 4, 4, 4,
359 4, 1, 1, 1, 3, 5
360 } ;
361
362 static yyconst short int yy_base[151] =
363 { 0,
364 0, 25, 25, 28, 42, 31, 265, 264, 266, 269,
365 269, 269, 269, 60, 28, 253, 251, 0, 249, 269,
366 38, 260, 269, 269, 269, 31, 39, 62, 79, 0,
367 269, 0, 31, 35, 0, 269, 269, 0, 244, 72,
368 258, 257, 269, 269, 269, 65, 0, 96, 0, 0,
369 113, 0, 242, 68, 0, 129, 149, 240, 70, 0,
370 151, 72, 74, 229, 81, 0, 168, 224, 91, 0,
371 185, 212, 98, 0, 202, 204, 117, 216, 207, 124,
372 0, 108, 129, 269, 0, 0, 0, 206, 0, 0,
373 0, 0, 201, 0, 0, 0, 0, 200, 0, 0,
374
375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
376 269, 269, 228, 233, 236, 241, 244, 247, 252, 204,
377 195, 194, 189, 188, 187, 178, 177, 172, 171, 170,
378 161, 160, 155, 150, 149, 148, 139, 138, 134, 133,
379 131, 130, 129, 117, 100, 84, 61, 52, 44, 31
380 } ;
381
382 static yyconst short int yy_def[151] =
383 { 0,
384 112, 1, 113, 113, 1, 5, 114, 114, 112, 112,
385 112, 112, 112, 112, 112, 112, 112, 115, 115, 112,
386 112, 112, 112, 112, 112, 116, 117, 117, 112, 118,
387 112, 119, 112, 112, 120, 112, 112, 115, 115, 112,
388 112, 112, 112, 112, 112, 121, 121, 112, 118, 119,
389 112, 120, 115, 122, 122, 112, 112, 115, 123, 123,
390 112, 112, 51, 115, 124, 124, 112, 115, 125, 125,
391 112, 115, 126, 126, 112, 115, 112, 112, 118, 115,
392 127, 112, 112, 112, 128, 129, 130, 112, 131, 132,
393 133, 134, 112, 135, 136, 137, 138, 112, 139, 140,
394
395 141, 142, 143, 144, 145, 146, 147, 148, 149, 150,
396 112, 0, 112, 112, 112, 112, 112, 112, 112, 112,
397 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
398 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
399 112, 112, 112, 112, 112, 112, 112, 112, 112, 112
400 } ;
401
402 static yyconst short int yy_nxt[296] =
403 { 0,
404 10, 11, 12, 13, 10, 10, 10, 10, 10, 14,
405 15, 16, 17, 18, 18, 18, 18, 18, 18, 19,
406 18, 20, 10, 10, 18, 18, 21, 24, 25, 22,
407 24, 25, 21, 111, 44, 22, 33, 34, 34, 40,
408 51, 51, 41, 33, 34, 34, 110, 26, 46, 46,
409 26, 27, 28, 45, 109, 29, 29, 29, 29, 30,
410 30, 30, 30, 108, 35, 31, 29, 30, 33, 34,
411 34, 46, 46, 40, 54, 54, 41, 59, 59, 65,
412 65, 63, 63, 63, 63, 35, 107, 112, 48, 48,
413 69, 69, 48, 48, 48, 48, 49, 49, 49, 49,
414
415 73, 73, 106, 48, 49, 56, 56, 77, 77, 56,
416 56, 56, 56, 49, 49, 49, 49, 82, 82, 105,
417 56, 49, 51, 51, 81, 83, 82, 82, 57, 84,
418 83, 104, 103, 102, 84, 101, 100, 57, 61, 61,
419 98, 97, 61, 61, 61, 61, 49, 49, 49, 49,
420 96, 95, 93, 61, 49, 62, 62, 92, 63, 63,
421 67, 67, 91, 90, 67, 67, 67, 67, 49, 49,
422 49, 49, 88, 87, 86, 67, 49, 71, 71, 85,
423 78, 71, 71, 71, 71, 49, 49, 49, 49, 74,
424 70, 66, 71, 49, 75, 75, 60, 55, 75, 75,
425
426 75, 75, 49, 49, 49, 49, 52, 99, 94, 75,
427 49, 79, 79, 89, 81, 79, 79, 79, 79, 49,
428 49, 49, 49, 81, 80, 76, 79, 49, 23, 23,
429 23, 23, 23, 32, 32, 32, 32, 32, 38, 38,
430 38, 43, 72, 43, 43, 43, 47, 68, 47, 49,
431 49, 49, 50, 64, 50, 50, 50, 58, 42, 42,
432 53, 42, 39, 37, 36, 112, 24, 24, 9, 112,
433 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
434 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
435 112, 112, 112, 112, 112
436
437 } ;
438
439 static yyconst short int yy_chk[296] =
440 { 0,
441 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
442 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
443 1, 1, 1, 1, 1, 1, 2, 3, 3, 2,
444 4, 4, 6, 150, 26, 6, 15, 15, 15, 21,
445 33, 33, 21, 34, 34, 34, 149, 3, 27, 27,
446 4, 5, 5, 26, 148, 5, 5, 5, 5, 5,
447 5, 5, 5, 147, 27, 5, 5, 5, 14, 14,
448 14, 28, 28, 40, 46, 46, 40, 54, 54, 59,
449 59, 62, 62, 63, 63, 14, 146, 28, 29, 29,
450 65, 65, 29, 29, 29, 29, 29, 29, 29, 29,
451
452 69, 69, 145, 29, 29, 48, 48, 73, 73, 48,
453 48, 48, 48, 48, 48, 48, 48, 82, 82, 144,
454 48, 48, 51, 51, 77, 80, 77, 77, 51, 80,
455 83, 143, 142, 141, 83, 140, 139, 51, 56, 56,
456 138, 137, 56, 56, 56, 56, 56, 56, 56, 56,
457 136, 135, 134, 56, 56, 57, 57, 133, 57, 57,
458 61, 61, 132, 131, 61, 61, 61, 61, 61, 61,
459 61, 61, 130, 129, 128, 61, 61, 67, 67, 127,
460 126, 67, 67, 67, 67, 67, 67, 67, 67, 125,
461 124, 123, 67, 67, 71, 71, 122, 121, 71, 71,
462
463 71, 71, 71, 71, 71, 71, 120, 98, 93, 71,
464 71, 75, 75, 88, 79, 75, 75, 75, 75, 75,
465 75, 75, 75, 78, 76, 72, 75, 75, 113, 113,
466 113, 113, 113, 114, 114, 114, 114, 114, 115, 115,
467 115, 116, 68, 116, 116, 116, 117, 64, 117, 118,
468 118, 118, 119, 58, 119, 119, 119, 53, 42, 41,
469 39, 22, 19, 17, 16, 9, 8, 7, 112, 112,
470 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
471 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
472 112, 112, 112, 112, 112
473
474 } ;
475
476 static yy_state_type yy_last_accepting_state;
477 static char *yy_last_accepting_cpos;
478
479 /* The intent behind this definition is that it'll catch
480 * any uses of REJECT which flex missed.
481 */
482 #define REJECT reject_used_but_not_detected
483 #define yymore() yymore_used_but_not_detected
484 #define YY_MORE_ADJ 0
485 #define YY_RESTORE_YY_MORE_OFFSET
486 char *yytext;
487 #line 1 "parser.l"
488 #define INITIAL 0
489 /* -*-C-*-
490 * IDL Compiler
491 *
492 * Copyright 2002 Ove Kaaven
493 *
494 * This library is free software; you can redistribute it and/or
495 * modify it under the terms of the GNU Lesser General Public
496 * License as published by the Free Software Foundation; either
497 * version 2.1 of the License, or (at your option) any later version.
498 *
499 * This library is distributed in the hope that it will be useful,
500 * but WITHOUT ANY WARRANTY; without even the implied warranty of
501 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
502 * Lesser General Public License for more details.
503 *
504 * You should have received a copy of the GNU Lesser General Public
505 * License along with this library; if not, write to the Free Software
506 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
507 */
508 #define YY_STACK_USED 1
509 #define YY_NO_UNPUT 1
510 #define YY_NO_TOP_STATE 1
511 #define YY_NEVER_INTERACTIVE 1
512 #define QUOTE 1
513
514 #define ATTR 2
515
516 #define PP_LINE 3
517
518 #line 39 "parser.l"
519
520 #include "config.h"
521
522 #include <stdio.h>
523 #include <stdlib.h>
524 #include <string.h>
525 #include <ctype.h>
526 #include <assert.h>
527 #ifdef HAVE_UNISTD_H
528 # include <unistd.h>
529 #endif
530
531 #include "widl.h"
532 #include "utils.h"
533 #include "parser.h"
534 #include "wine/wpp.h"
535
536 #include "parser.tab.h"
537
538 extern char *temp_name;
539
540 static void addcchar(char c);
541 static char *get_buffered_cstring(void);
542
543 static char *cbuffer;
544 static int cbufidx;
545 static int cbufalloc = 0;
546
547 static int kw_token(const char *kw);
548 static int attr_token(const char *kw);
549
550 #define MAX_IMPORT_DEPTH 10
551 struct {
552 YY_BUFFER_STATE state;
553 char *input_name;
554 int line_number;
555 char *temp_name;
556 } import_stack[MAX_IMPORT_DEPTH];
557 int import_stack_ptr = 0;
558
559 static void pop_import(void);
560
561 UUID *parse_uuid(const char *u)
562 {
563 UUID* uuid = xmalloc(sizeof(UUID));
564 char b[3];
565 /* it would be nice to use UuidFromStringA */
566 uuid->Data1 = strtoul(u, NULL, 16);
567 uuid->Data2 = strtoul(u+9, NULL, 16);
568 uuid->Data3 = strtoul(u+14, NULL, 16);
569 b[2] = 0;
570 memcpy(b, u+19, 2); uuid->Data4[0] = strtoul(b, NULL, 16);
571 memcpy(b, u+21, 2); uuid->Data4[1] = strtoul(b, NULL, 16);
572 memcpy(b, u+24, 2); uuid->Data4[2] = strtoul(b, NULL, 16);
573 memcpy(b, u+26, 2); uuid->Data4[3] = strtoul(b, NULL, 16);
574 memcpy(b, u+28, 2); uuid->Data4[4] = strtoul(b, NULL, 16);
575 memcpy(b, u+30, 2); uuid->Data4[5] = strtoul(b, NULL, 16);
576 memcpy(b, u+32, 2); uuid->Data4[6] = strtoul(b, NULL, 16);
577 memcpy(b, u+34, 2); uuid->Data4[7] = strtoul(b, NULL, 16);
578 return uuid;
579 }
580
581 /*
582 **************************************************************************
583 * The flexer starts here
584 **************************************************************************
585 */
586 #line 587 "parser.yy.c"
587
588 /* Macros after this point can all be overridden by user definitions in
589 * section 1.
590 */
591
592 #ifndef YY_SKIP_YYWRAP
593 #ifdef __cplusplus
594 extern "C" int yywrap YY_PROTO(( void ));
595 #else
596 extern int yywrap YY_PROTO(( void ));
597 #endif
598 #endif
599
600 #ifndef YY_NO_UNPUT
601 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
602 #endif
603
604 #ifndef yytext_ptr
605 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
606 #endif
607
608 #ifdef YY_NEED_STRLEN
609 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
610 #endif
611
612 #ifndef YY_NO_INPUT
613 #ifdef __cplusplus
614 static int yyinput YY_PROTO(( void ));
615 #else
616 static int input YY_PROTO(( void ));
617 #endif
618 #endif
619
620 #if YY_STACK_USED
621 static int yy_start_stack_ptr = 0;
622 static int yy_start_stack_depth = 0;
623 static int *yy_start_stack = 0;
624 #ifndef YY_NO_PUSH_STATE
625 static void yy_push_state YY_PROTO(( int new_state ));
626 #endif
627 #ifndef YY_NO_POP_STATE
628 static void yy_pop_state YY_PROTO(( void ));
629 #endif
630 #ifndef YY_NO_TOP_STATE
631 static int yy_top_state YY_PROTO(( void ));
632 #endif
633
634 #else
635 #define YY_NO_PUSH_STATE 1
636 #define YY_NO_POP_STATE 1
637 #define YY_NO_TOP_STATE 1
638 #endif
639
640 #ifdef YY_MALLOC_DECL
641 YY_MALLOC_DECL
642 #else
643 #if __STDC__
644 #ifndef __cplusplus
645 #include <stdlib.h>
646 #endif
647 #else
648 /* Just try to get by without declaring the routines. This will fail
649 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
650 * or sizeof(void*) != sizeof(int).
651 */
652 #endif
653 #endif
654
655 /* Amount of stuff to slurp up with each read. */
656 #ifndef YY_READ_BUF_SIZE
657 #define YY_READ_BUF_SIZE 8192
658 #endif
659
660 /* Copy whatever the last rule matched to the standard output. */
661
662 #ifndef ECHO
663 /* This used to be an fputs(), but since the string might contain NUL's,
664 * we now use fwrite().
665 */
666 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
667 #endif
668
669 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
670 * is returned in "result".
671 */
672 #ifndef YY_INPUT
673 #define YY_INPUT(buf,result,max_size) \
674 if ( yy_current_buffer->yy_is_interactive ) \
675 { \
676 int c = '*', n; \
677 for ( n = 0; n < max_size && \
678 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
679 buf[n] = (char) c; \
680 if ( c == '\n' ) \
681 buf[n++] = (char) c; \
682 if ( c == EOF && ferror( yyin ) ) \
683 YY_FATAL_ERROR( "input in flex scanner failed" ); \
684 result = n; \
685 } \
686 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
687 && ferror( yyin ) ) \
688 YY_FATAL_ERROR( "input in flex scanner failed" );
689 #endif
690
691 /* No semi-colon after return; correct usage is to write "yyterminate();" -
692 * we don't want an extra ';' after the "return" because that will cause
693 * some compilers to complain about unreachable statements.
694 */
695 #ifndef yyterminate
696 #define yyterminate() return YY_NULL
697 #endif
698
699 /* Number of entries by which start-condition stack grows. */
700 #ifndef YY_START_STACK_INCR
701 #define YY_START_STACK_INCR 25
702 #endif
703
704 /* Report a fatal error. */
705 #ifndef YY_FATAL_ERROR
706 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
707 #endif
708
709 /* Default declaration of generated scanner - a define so the user can
710 * easily add parameters.
711 */
712 #ifndef YY_DECL
713 #define YY_DECL int yylex YY_PROTO(( void ))
714 #endif
715
716 /* Code executed at the beginning of each rule, after yytext and yyleng
717 * have been set up.
718 */
719 #ifndef YY_USER_ACTION
720 #define YY_USER_ACTION
721 #endif
722
723 /* Code executed at the end of each rule. */
724 #ifndef YY_BREAK
725 #define YY_BREAK break;
726 #endif
727
728 #define YY_RULE_SETUP \
729 if ( yyleng > 0 ) \
730 yy_current_buffer->yy_at_bol = \
731 (yytext[yyleng - 1] == '\n'); \
732 YY_USER_ACTION
733
734 YY_DECL
735 {
736 register yy_state_type yy_current_state;
737 register char *yy_cp, *yy_bp;
738 register int yy_act;
739
740 #line 108 "parser.l"
741
742 #line 743 "parser.yy.c"
743
744 if ( yy_init )
745 {
746 yy_init = 0;
747
748 #ifdef YY_USER_INIT
749 YY_USER_INIT;
750 #endif
751
752 if ( ! yy_start )
753 yy_start = 1; /* first start state */
754
755 if ( ! yyin )
756 yyin = stdin;
757
758 if ( ! yyout )
759 yyout = stdout;
760
761 if ( ! yy_current_buffer )
762 yy_current_buffer =
763 yy_create_buffer( yyin, YY_BUF_SIZE );
764
765 yy_load_buffer_state();
766 }
767
768 while ( 1 ) /* loops until end-of-file is reached */
769 {
770 yy_cp = yy_c_buf_p;
771
772 /* Support of yytext. */
773 *yy_cp = yy_hold_char;
774
775 /* yy_bp points to the position in yy_ch_buf of the start of
776 * the current run.
777 */
778 yy_bp = yy_cp;
779
780 yy_current_state = yy_start;
781 yy_current_state += YY_AT_BOL();
782 yy_match:
783 do
784 {
785 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
786 if ( yy_accept[yy_current_state] )
787 {
788 yy_last_accepting_state = yy_current_state;
789 yy_last_accepting_cpos = yy_cp;
790 }
791 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
792 {
793 yy_current_state = (int) yy_def[yy_current_state];
794 if ( yy_current_state >= 113 )
795 yy_c = yy_meta[(unsigned int) yy_c];
796 }
797 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
798 ++yy_cp;
799 }
800 while ( yy_base[yy_current_state] != 269 );
801
802 yy_find_action:
803 yy_act = yy_accept[yy_current_state];
804 if ( yy_act == 0 )
805 { /* have to back up */
806 yy_cp = yy_last_accepting_cpos;
807 yy_current_state = yy_last_accepting_state;
808 yy_act = yy_accept[yy_current_state];
809 }
810
811 YY_DO_BEFORE_ACTION;
812
813
814 do_action: /* This label is used only to access EOF actions. */
815
816
817 switch ( yy_act )
818 { /* beginning of action switch */
819 case 0: /* must back up */
820 /* undo the effects of YY_DO_BEFORE_ACTION */
821 *yy_cp = yy_hold_char;
822 yy_cp = yy_last_accepting_cpos;
823 yy_current_state = yy_last_accepting_state;
824 goto yy_find_action;
825
826 case 1:
827 YY_RULE_SETUP
828 #line 109 "parser.l"
829 yy_push_state(PP_LINE);
830 YY_BREAK
831 case 2:
832 YY_RULE_SETUP
833 #line 110 "parser.l"
834 {
835 int lineno;
836 char *cptr, *fname;
837 yy_pop_state();
838 lineno = (int)strtol(yytext, &cptr, 10);
839 if(!lineno)
840 error_loc("Malformed '#...' line-directive; invalid linenumber\n");
841 fname = strchr(cptr, '"');
842 if(!fname)
843 error_loc("Malformed '#...' line-directive; missing filename\n");
844 fname++;
845 cptr = strchr(fname, '"');
846 if(!cptr)
847 error_loc("Malformed '#...' line-directive; missing terminating \"\n");
848 *cptr = '\0';
849 line_number = lineno - 1; /* We didn't read the newline */
850 free( input_name );
851 input_name = xstrdup(fname);
852 }
853 YY_BREAK
854 case 3:
855 YY_RULE_SETUP
856 #line 129 "parser.l"
857 yy_push_state(QUOTE); cbufidx = 0;
858 YY_BREAK
859 case 4:
860 YY_RULE_SETUP
861 #line 130 "parser.l"
862 {
863 yy_pop_state();
864 parser_lval.str = get_buffered_cstring();
865 return aSTRING;
866 }
867 YY_BREAK
868 case 5:
869 #line 136 "parser.l"
870 case 6:
871 YY_RULE_SETUP
872 #line 136 "parser.l"
873 addcchar(yytext[1]);
874 YY_BREAK
875 case 7:
876 YY_RULE_SETUP
877 #line 137 "parser.l"
878 addcchar('\\'); addcchar(yytext[1]);
879 YY_BREAK
880 case 8:
881 YY_RULE_SETUP
882 #line 138 "parser.l"
883 addcchar(yytext[0]);
884 YY_BREAK
885 case 9:
886 YY_RULE_SETUP
887 #line 139 "parser.l"
888 yy_push_state(ATTR); return '[';
889 YY_BREAK
890 case 10:
891 YY_RULE_SETUP
892 #line 140 "parser.l"
893 yy_pop_state(); return ']';
894 YY_BREAK
895 case 11:
896 YY_RULE_SETUP
897 #line 141 "parser.l"
898 return attr_token(yytext);
899 YY_BREAK
900 case 12:
901 YY_RULE_SETUP
902 #line 142 "parser.l"
903 {
904 parser_lval.uuid = parse_uuid(yytext);
905 return aUUID;
906 }
907 YY_BREAK
908 case 13:
909 YY_RULE_SETUP
910 #line 146 "parser.l"
911 {
912 parser_lval.num = strtoul(yytext, NULL, 0);
913 return aHEXNUM;
914 }
915 YY_BREAK
916 case 14:
917 YY_RULE_SETUP
918 #line 150 "parser.l"
919 {
920 parser_lval.num = strtoul(yytext, NULL, 0);
921 return aNUM;
922 }
923 YY_BREAK
924 case 15:
925 YY_RULE_SETUP
926 #line 154 "parser.l"
927 {
928 parser_lval.dbl = strtod(yytext, NULL);
929 return aDOUBLE;
930 }
931 YY_BREAK
932 case 16:
933 *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
934 yy_c_buf_p = yy_cp -= 1;
935 YY_DO_BEFORE_ACTION; /* set up yytext again */
936 YY_RULE_SETUP
937 #line 158 "parser.l"
938 return tSAFEARRAY;
939 YY_BREAK
940 case 17:
941 YY_RULE_SETUP
942 #line 159 "parser.l"
943 return kw_token(yytext);
944 YY_BREAK
945 case 18:
946 YY_RULE_SETUP
947 #line 160 "parser.l"
948 line_number++;
949 YY_BREAK
950 case 19:
951 YY_RULE_SETUP
952 #line 161 "parser.l"
953
954 YY_BREAK
955 case 20:
956 YY_RULE_SETUP
957 #line 162 "parser.l"
958 return SHL;
959 YY_BREAK
960 case 21:
961 YY_RULE_SETUP
962 #line 163 "parser.l"
963 return SHR;
964 YY_BREAK
965 case 22:
966 YY_RULE_SETUP
967 #line 164 "parser.l"
968 return yytext[0];
969 YY_BREAK
970 case YY_STATE_EOF(INITIAL):
971 case YY_STATE_EOF(QUOTE):
972 case YY_STATE_EOF(ATTR):
973 case YY_STATE_EOF(PP_LINE):
974 #line 165 "parser.l"
975 {
976 if (import_stack_ptr) {
977 pop_import();
978 return aEOF;
979 }
980 else yyterminate();
981 }
982 YY_BREAK
983 case 23:
984 YY_RULE_SETUP
985 #line 172 "parser.l"
986 ECHO;
987 YY_BREAK
988 #line 989 "parser.yy.c"
989
990 case YY_END_OF_BUFFER:
991 {
992 /* Amount of text matched not including the EOB char. */
993 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
994
995 /* Undo the effects of YY_DO_BEFORE_ACTION. */
996 *yy_cp = yy_hold_char;
997 YY_RESTORE_YY_MORE_OFFSET
998
999 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
1000 {
1001 /* We're scanning a new file or input source. It's
1002 * possible that this happened because the user
1003 * just pointed yyin at a new source and called
1004 * yylex(). If so, then we have to assure
1005 * consistency between yy_current_buffer and our
1006 * globals. Here is the right place to do so, because
1007 * this is the first action (other than possibly a
1008 * back-up) that will match for the new input source.
1009 */
1010 yy_n_chars = yy_current_buffer->yy_n_chars;
1011 yy_current_buffer->yy_input_file = yyin;
1012 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
1013 }
1014
1015 /* Note that here we test for yy_c_buf_p "<=" to the position
1016 * of the first EOB in the buffer, since yy_c_buf_p will
1017 * already have been incremented past the NUL character
1018 * (since all states make transitions on EOB to the
1019 * end-of-buffer state). Contrast this with the test
1020 * in input().
1021 */
1022 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1023 { /* This was really a NUL. */
1024 yy_state_type yy_next_state;
1025
1026 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
1027
1028 yy_current_state = yy_get_previous_state();
1029
1030 /* Okay, we're now positioned to make the NUL
1031 * transition. We couldn't have
1032 * yy_get_previous_state() go ahead and do it
1033 * for us because it doesn't know how to deal
1034 * with the possibility of jamming (and we don't
1035 * want to build jamming into it because then it
1036 * will run more slowly).
1037 */
1038
1039 yy_next_state = yy_try_NUL_trans( yy_current_state );
1040
1041 yy_bp = yytext_ptr + YY_MORE_ADJ;
1042
1043 if ( yy_next_state )
1044 {
1045 /* Consume the NUL. */
1046 yy_cp = ++yy_c_buf_p;
1047 yy_current_state = yy_next_state;
1048 goto yy_match;
1049 }
1050
1051 else
1052 {
1053 yy_cp = yy_c_buf_p;
1054 goto yy_find_action;
1055 }
1056 }
1057
1058 else switch ( yy_get_next_buffer() )
1059 {
1060 case EOB_ACT_END_OF_FILE:
1061 {
1062 yy_did_buffer_switch_on_eof = 0;
1063
1064 if ( yywrap() )
1065 {
1066 /* Note: because we've taken care in
1067 * yy_get_next_buffer() to have set up
1068 * yytext, we can now set up
1069 * yy_c_buf_p so that if some total
1070 * hoser (like flex itself) wants to
1071 * call the scanner after we return the
1072 * YY_NULL, it'll still work - another
1073 * YY_NULL will get returned.
1074 */
1075 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1076
1077 yy_act = YY_STATE_EOF(YY_START);
1078 goto do_action;
1079 }
1080
1081 else
1082 {
1083 if ( ! yy_did_buffer_switch_on_eof )
1084 YY_NEW_FILE;
1085 }
1086 break;
1087 }
1088
1089 case EOB_ACT_CONTINUE_SCAN:
1090 yy_c_buf_p =
1091 yytext_ptr + yy_amount_of_matched_text;
1092
1093 yy_current_state = yy_get_previous_state();
1094
1095 yy_cp = yy_c_buf_p;
1096 yy_bp = yytext_ptr + YY_MORE_ADJ;
1097 goto yy_match;
1098
1099 case EOB_ACT_LAST_MATCH:
1100 yy_c_buf_p =
1101 &yy_current_buffer->yy_ch_buf[yy_n_chars];
1102
1103 yy_current_state = yy_get_previous_state();
1104
1105 yy_cp = yy_c_buf_p;
1106 yy_bp = yytext_ptr + YY_MORE_ADJ;
1107 goto yy_find_action;
1108 }
1109 break;
1110 }
1111
1112 default:
1113 YY_FATAL_ERROR(
1114 "fatal flex scanner internal error--no action found" );
1115 } /* end of action switch */
1116 } /* end of scanning one token */
1117 } /* end of yylex */
1118
1119
1120 /* yy_get_next_buffer - try to read in a new buffer
1121 *
1122 * Returns a code representing an action:
1123 * EOB_ACT_LAST_MATCH -
1124 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1125 * EOB_ACT_END_OF_FILE - end of file
1126 */
1127
1128 static int yy_get_next_buffer()
1129 {
1130 register char *dest = yy_current_buffer->yy_ch_buf;
1131 register char *source = yytext_ptr;
1132 register int number_to_move, i;
1133 int ret_val;
1134
1135 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
1136 YY_FATAL_ERROR(
1137 "fatal flex scanner internal error--end of buffer missed" );
1138
1139 if ( yy_current_buffer->yy_fill_buffer == 0 )
1140 { /* Don't try to fill the buffer, so this is an EOF. */
1141 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
1142 {
1143 /* We matched a single character, the EOB, so
1144 * treat this as a final EOF.
1145 */
1146 return EOB_ACT_END_OF_FILE;
1147 }
1148
1149 else
1150 {
1151 /* We matched some text prior to the EOB, first
1152 * process it.
1153 */
1154 return EOB_ACT_LAST_MATCH;
1155 }
1156 }
1157
1158 /* Try to read more data. */
1159
1160 /* First move last chars to start of buffer. */
1161 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1162
1163 for ( i = 0; i < number_to_move; ++i )
1164 *(dest++) = *(source++);
1165
1166 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1167 /* don't do the read, it's not guaranteed to return an EOF,
1168 * just force an EOF
1169 */
1170 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1171
1172 else
1173 {
1174 int num_to_read =
1175 yy_current_buffer->yy_buf_size - number_to_move - 1;
1176
1177 while ( num_to_read <= 0 )
1178 { /* Not enough room in the buffer - grow it. */
1179 #ifdef YY_USES_REJECT
1180 YY_FATAL_ERROR(
1181 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1182 #else
1183
1184 /* just a shorter name for the current buffer */
1185 YY_BUFFER_STATE b = yy_current_buffer;
1186
1187 int yy_c_buf_p_offset =
1188 (int) (yy_c_buf_p - b->yy_ch_buf);
1189
1190 if ( b->yy_is_our_buffer )
1191 {
1192 int new_size = b->yy_buf_size * 2;
1193
1194 if ( new_size <= 0 )
1195 b->yy_buf_size += b->yy_buf_size / 8;
1196 else
1197 b->yy_buf_size *= 2;
1198
1199 b->yy_ch_buf = (char *)
1200 /* Include room in for 2 EOB chars. */
1201 yy_flex_realloc( (void *) b->yy_ch_buf,
1202 b->yy_buf_size + 2 );
1203 }
1204 else
1205 /* Can't grow it, we don't own it. */
1206 b->yy_ch_buf = 0;
1207
1208 if ( ! b->yy_ch_buf )
1209 YY_FATAL_ERROR(
1210 "fatal error - scanner input buffer overflow" );
1211
1212 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1213
1214 num_to_read = yy_current_buffer->yy_buf_size -
1215 number_to_move - 1;
1216 #endif
1217 }
1218
1219 if ( num_to_read > YY_READ_BUF_SIZE )
1220 num_to_read = YY_READ_BUF_SIZE;
1221
1222 /* Read in more data. */
1223 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1224 yy_n_chars, num_to_read );
1225
1226 yy_current_buffer->yy_n_chars = yy_n_chars;
1227 }
1228
1229 if ( yy_n_chars == 0 )
1230 {
1231 if ( number_to_move == YY_MORE_ADJ )
1232 {
1233 ret_val = EOB_ACT_END_OF_FILE;
1234 yyrestart( yyin );
1235 }
1236
1237 else
1238 {
1239 ret_val = EOB_ACT_LAST_MATCH;
1240 yy_current_buffer->yy_buffer_status =
1241 YY_BUFFER_EOF_PENDING;
1242 }
1243 }
1244
1245 else
1246 ret_val = EOB_ACT_CONTINUE_SCAN;
1247
1248 yy_n_chars += number_to_move;
1249 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1250 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1251
1252 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1253
1254 return ret_val;
1255 }
1256
1257
1258 /* yy_get_previous_state - get the state just before the EOB char was reached */
1259
1260 static yy_state_type yy_get_previous_state()
1261 {
1262 register yy_state_type yy_current_state;
1263 register char *yy_cp;
1264
1265 yy_current_state = yy_start;
1266 yy_current_state += YY_AT_BOL();
1267
1268 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1269 {
1270 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1271 if ( yy_accept[yy_current_state] )
1272 {
1273 yy_last_accepting_state = yy_current_state;
1274 yy_last_accepting_cpos = yy_cp;
1275 }
1276 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1277 {
1278 yy_current_state = (int) yy_def[yy_current_state];
1279 if ( yy_current_state >= 113 )
1280 yy_c = yy_meta[(unsigned int) yy_c];
1281 }
1282 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1283 }
1284
1285 return yy_current_state;
1286 }
1287
1288
1289 /* yy_try_NUL_trans - try to make a transition on the NUL character
1290 *
1291 * synopsis
1292 * next_state = yy_try_NUL_trans( current_state );
1293 */
1294
1295 #ifdef YY_USE_PROTOS
1296 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1297 #else
1298 static yy_state_type yy_try_NUL_trans( yy_current_state )
1299 yy_state_type yy_current_state;
1300 #endif
1301 {
1302 register int yy_is_jam;
1303 register char *yy_cp = yy_c_buf_p;
1304
1305 register YY_CHAR yy_c = 1;
1306 if ( yy_accept[yy_current_state] )
1307 {
1308 yy_last_accepting_state = yy_current_state;
1309 yy_last_accepting_cpos = yy_cp;
1310 }
1311 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1312 {
1313 yy_current_state = (int) yy_def[yy_current_state];
1314 if ( yy_current_state >= 113 )
1315 yy_c = yy_meta[(unsigned int) yy_c];
1316 }
1317 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1318 yy_is_jam = (yy_current_state == 112);
1319
1320 return yy_is_jam ? 0 : yy_current_state;
1321 }
1322
1323
1324 #ifndef YY_NO_UNPUT
1325 #ifdef YY_USE_PROTOS
1326 static void yyunput( int c, register char *yy_bp )
1327 #else
1328 static void yyunput( c, yy_bp )
1329 int c;
1330 register char *yy_bp;
1331 #endif
1332 {
1333 register char *yy_cp = yy_c_buf_p;
1334
1335 /* undo effects of setting up yytext */
1336 *yy_cp = yy_hold_char;
1337
1338 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1339 { /* need to shift things up to make room */
1340 /* +2 for EOB chars. */
1341 register int number_to_move = yy_n_chars + 2;
1342 register char *dest = &yy_current_buffer->yy_ch_buf[
1343 yy_current_buffer->yy_buf_size + 2];
1344 register char *source =
1345 &yy_current_buffer->yy_ch_buf[number_to_move];
1346
1347 while ( source > yy_current_buffer->yy_ch_buf )
1348 *--dest = *--source;
1349
1350 yy_cp += (int) (dest - source);
1351 yy_bp += (int) (dest - source);
1352 yy_current_buffer->yy_n_chars =
1353 yy_n_chars = yy_current_buffer->yy_buf_size;
1354
1355 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1356 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1357 }
1358
1359 *--yy_cp = (char) c;
1360
1361
1362 yytext_ptr = yy_bp;
1363 yy_hold_char = *yy_cp;
1364 yy_c_buf_p = yy_cp;
1365 }
1366 #endif /* ifndef YY_NO_UNPUT */
1367
1368
1369 #ifdef __cplusplus
1370 static int yyinput()
1371 #else
1372 static int input()
1373 #endif
1374 {
1375 int c;
1376
1377 *yy_c_buf_p = yy_hold_char;
1378
1379 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1380 {
1381 /* yy_c_buf_p now points to the character we want to return.
1382 * If this occurs *before* the EOB characters, then it's a
1383 * valid NUL; if not, then we've hit the end of the buffer.
1384 */
1385 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1386 /* This was really a NUL. */
1387 *yy_c_buf_p = '\0';
1388
1389 else
1390 { /* need more input */
1391 int offset = yy_c_buf_p - yytext_ptr;
1392 ++yy_c_buf_p;
1393
1394 switch ( yy_get_next_buffer() )
1395 {
1396 case EOB_ACT_LAST_MATCH:
1397 /* This happens because yy_g_n_b()
1398 * sees that we've accumulated a
1399 * token and flags that we need to
1400 * try matching the token before
1401 * proceeding. But for input(),
1402 * there's no matching to consider.
1403 * So convert the EOB_ACT_LAST_MATCH
1404 * to EOB_ACT_END_OF_FILE.
1405 */
1406
1407 /* Reset buffer status. */
1408 yyrestart( yyin );
1409
1410 /* fall through */
1411
1412 case EOB_ACT_END_OF_FILE:
1413 {
1414 if ( yywrap() )
1415 return EOF;
1416
1417 if ( ! yy_did_buffer_switch_on_eof )
1418 YY_NEW_FILE;
1419 #ifdef __cplusplus
1420 return yyinput();
1421 #else
1422 return input();
1423 #endif
1424 }
1425
1426 case EOB_ACT_CONTINUE_SCAN:
1427 yy_c_buf_p = yytext_ptr + offset;
1428 break;
1429 }
1430 }
1431 }
1432
1433 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1434 *yy_c_buf_p = '\0'; /* preserve yytext */
1435 yy_hold_char = *++yy_c_buf_p;
1436
1437 yy_current_buffer->yy_at_bol = (c == '\n');
1438
1439 return c;
1440 }
1441
1442
1443 #ifdef YY_USE_PROTOS
1444 void yyrestart( FILE *input_file )
1445 #else
1446 void yyrestart( input_file )
1447 FILE *input_file;
1448 #endif
1449 {
1450 if ( ! yy_current_buffer )
1451 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1452
1453 yy_init_buffer( yy_current_buffer, input_file );
1454 yy_load_buffer_state();
1455 }
1456
1457
1458 #ifdef YY_USE_PROTOS
1459 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1460 #else
1461 void yy_switch_to_buffer( new_buffer )
1462 YY_BUFFER_STATE new_buffer;
1463 #endif
1464 {
1465 if ( yy_current_buffer == new_buffer )
1466 return;
1467
1468 if ( yy_current_buffer )
1469 {
1470 /* Flush out information for old buffer. */
1471 *yy_c_buf_p = yy_hold_char;
1472 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1473 yy_current_buffer->yy_n_chars = yy_n_chars;
1474 }
1475
1476 yy_current_buffer = new_buffer;
1477 yy_load_buffer_state();
1478
1479 /* We don't actually know whether we did this switch during
1480 * EOF (yywrap()) processing, but the only time this flag
1481 * is looked at is after yywrap() is called, so it's safe
1482 * to go ahead and always set it.
1483 */
1484 yy_did_buffer_switch_on_eof = 1;
1485 }
1486
1487
1488 #ifdef YY_USE_PROTOS
1489 void yy_load_buffer_state( void )
1490 #else
1491 void yy_load_buffer_state()
1492 #endif
1493 {
1494 yy_n_chars = yy_current_buffer->yy_n_chars;
1495 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1496 yyin = yy_current_buffer->yy_input_file;
1497 yy_hold_char = *yy_c_buf_p;
1498 }
1499
1500
1501 #ifdef YY_USE_PROTOS
1502 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1503 #else
1504 YY_BUFFER_STATE yy_create_buffer( file, size )
1505 FILE *file;
1506 int size;
1507 #endif
1508 {
1509 YY_BUFFER_STATE b;
1510
1511 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1512 if ( ! b )
1513 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1514
1515 b->yy_buf_size = size;
1516
1517 /* yy_ch_buf has to be 2 characters longer than the size given because
1518 * we need to put in 2 end-of-buffer characters.
1519 */
1520 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1521 if ( ! b->yy_ch_buf )
1522 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1523
1524 b->yy_is_our_buffer = 1;
1525
1526 yy_init_buffer( b, file );
1527
1528 return b;
1529 }
1530
1531
1532 #ifdef YY_USE_PROTOS
1533 void yy_delete_buffer( YY_BUFFER_STATE b )
1534 #else
1535 void yy_delete_buffer( b )
1536 YY_BUFFER_STATE b;
1537 #endif
1538 {
1539 if ( ! b )
1540 return;
1541
1542 if ( b == yy_current_buffer )
1543 yy_current_buffer = (YY_BUFFER_STATE) 0;
1544
1545 if ( b->yy_is_our_buffer )
1546 yy_flex_free( (void *) b->yy_ch_buf );
1547
1548 yy_flex_free( (void *) b );
1549 }
1550
1551
1552 #ifndef YY_ALWAYS_INTERACTIVE
1553 #ifndef YY_NEVER_INTERACTIVE
1554 extern int isatty YY_PROTO(( int ));
1555 #endif
1556 #endif
1557
1558 #ifdef YY_USE_PROTOS
1559 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1560 #else
1561 void yy_init_buffer( b, file )
1562 YY_BUFFER_STATE b;
1563 FILE *file;
1564 #endif
1565
1566
1567 {
1568 yy_flush_buffer( b );
1569
1570 b->yy_input_file = file;
1571 b->yy_fill_buffer = 1;
1572
1573 #if YY_ALWAYS_INTERACTIVE
1574 b->yy_is_interactive = 1;
1575 #else
1576 #if YY_NEVER_INTERACTIVE
1577 b->yy_is_interactive = 0;
1578 #else
1579 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1580 #endif
1581 #endif
1582 }
1583
1584
1585 #ifdef YY_USE_PROTOS
1586 void yy_flush_buffer( YY_BUFFER_STATE b )
1587 #else
1588 void yy_flush_buffer( b )
1589 YY_BUFFER_STATE b;
1590 #endif
1591
1592 {
1593 if ( ! b )
1594 return;
1595
1596 b->yy_n_chars = 0;
1597
1598 /* We always need two end-of-buffer characters. The first causes
1599 * a transition to the end-of-buffer state. The second causes
1600 * a jam in that state.
1601 */
1602 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1603 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1604
1605 b->yy_buf_pos = &b->yy_ch_buf[0];
1606
1607 b->yy_at_bol = 1;
1608 b->yy_buffer_status = YY_BUFFER_NEW;
1609
1610 if ( b == yy_current_buffer )
1611 yy_load_buffer_state();
1612 }
1613
1614
1615 #ifndef YY_NO_SCAN_BUFFER
1616 #ifdef YY_USE_PROTOS
1617 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1618 #else
1619 YY_BUFFER_STATE yy_scan_buffer( base, size )
1620 char *base;
1621 yy_size_t size;
1622 #endif
1623 {
1624 YY_BUFFER_STATE b;
1625
1626 if ( size < 2 ||
1627 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1628 base[size-1] != YY_END_OF_BUFFER_CHAR )
1629 /* They forgot to leave room for the EOB's. */
1630 return 0;
1631
1632 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1633 if ( ! b )
1634 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1635
1636 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1637 b->yy_buf_pos = b->yy_ch_buf = base;
1638 b->yy_is_our_buffer = 0;
1639 b->yy_input_file = 0;
1640 b->yy_n_chars = b->yy_buf_size;
1641 b->yy_is_interactive = 0;
1642 b->yy_at_bol = 1;
1643 b->yy_fill_buffer = 0;
1644 b->yy_buffer_status = YY_BUFFER_NEW;
1645
1646 yy_switch_to_buffer( b );
1647
1648 return b;
1649 }
1650 #endif
1651
1652
1653 #ifndef YY_NO_SCAN_STRING
1654 #ifdef YY_USE_PROTOS
1655 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1656 #else
1657 YY_BUFFER_STATE yy_scan_string( yy_str )
1658 yyconst char *yy_str;
1659 #endif
1660 {
1661 int len;
1662 for ( len = 0; yy_str[len]; ++len )
1663 ;
1664
1665 return yy_scan_bytes( yy_str, len );
1666 }
1667 #endif
1668
1669
1670 #ifndef YY_NO_SCAN_BYTES
1671 #ifdef YY_USE_PROTOS
1672 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1673 #else
1674 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1675 yyconst char *bytes;
1676 int len;
1677 #endif
1678 {
1679 YY_BUFFER_STATE b;
1680 char *buf;
1681 yy_size_t n;
1682 int i;
1683
1684 /* Get memory for full buffer, including space for trailing EOB's. */
1685 n = len + 2;
1686 buf = (char *) yy_flex_alloc( n );
1687 if ( ! buf )
1688 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1689
1690 for ( i = 0; i < len; ++i )
1691 buf[i] = bytes[i];
1692
1693 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1694
1695 b = yy_scan_buffer( buf, n );
1696 if ( ! b )
1697 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1698
1699 /* It's okay to grow etc. this buffer, and we should throw it
1700 * away when we're done.
1701 */
1702 b->yy_is_our_buffer = 1;
1703
1704 return b;
1705 }
1706 #endif
1707
1708
1709 #ifndef YY_NO_PUSH_STATE
1710 #ifdef YY_USE_PROTOS
1711 static void yy_push_state( int new_state )
1712 #else
1713 static void yy_push_state( new_state )
1714 int new_state;
1715 #endif
1716 {
1717 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1718 {
1719 yy_size_t new_size;
1720
1721 yy_start_stack_depth += YY_START_STACK_INCR;
1722 new_size = yy_start_stack_depth * sizeof( int );
1723
1724 if ( ! yy_start_stack )
1725 yy_start_stack = (int *) yy_flex_alloc( new_size );
1726
1727 else
1728 yy_start_stack = (int *) yy_flex_realloc(
1729 (void *) yy_start_stack, new_size );
1730
1731 if ( ! yy_start_stack )
1732 YY_FATAL_ERROR(
1733 "out of memory expanding start-condition stack" );
1734 }
1735
1736 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1737
1738 BEGIN(new_state);
1739 }
1740 #endif
1741
1742
1743 #ifndef YY_NO_POP_STATE
1744 static void yy_pop_state()
1745 {
1746 if ( --yy_start_stack_ptr < 0 )
1747 YY_FATAL_ERROR( "start-condition stack underflow" );
1748
1749 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1750 }
1751 #endif
1752
1753
1754 #ifndef YY_NO_TOP_STATE
1755 static int yy_top_state()
1756 {
1757 return yy_start_stack[yy_start_stack_ptr - 1];
1758 }
1759 #endif
1760
1761 #ifndef YY_EXIT_FAILURE
1762 #define YY_EXIT_FAILURE 2
1763 #endif
1764
1765 #ifdef YY_USE_PROTOS
1766 static void yy_fatal_error( yyconst char msg[] )
1767 #else
1768 static void yy_fatal_error( msg )
1769 char msg[];
1770 #endif
1771 {
1772 (void) fprintf( stderr, "%s\n", msg );
1773 exit( YY_EXIT_FAILURE );
1774 }
1775
1776
1777
1778 /* Redefine yyless() so it works in section 3 code. */
1779
1780 #undef yyless
1781 #define yyless(n) \
1782 do \
1783 { \
1784 /* Undo effects of setting up yytext. */ \
1785 yytext[yyleng] = yy_hold_char; \
1786 yy_c_buf_p = yytext + n; \
1787 yy_hold_char = *yy_c_buf_p; \
1788 *yy_c_buf_p = '\0'; \
1789 yyleng = n; \
1790 } \
1791 while ( 0 )
1792
1793
1794 /* Internal utility routines. */
1795
1796 #ifndef yytext_ptr
1797 #ifdef YY_USE_PROTOS
1798 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1799 #else
1800 static void yy_flex_strncpy( s1, s2, n )
1801 char *s1;
1802 yyconst char *s2;
1803 int n;
1804 #endif
1805 {
1806 register int i;
1807 for ( i = 0; i < n; ++i )
1808 s1[i] = s2[i];
1809 }
1810 #endif
1811
1812 #ifdef YY_NEED_STRLEN
1813 #ifdef YY_USE_PROTOS
1814 static int yy_flex_strlen( yyconst char *s )
1815 #else
1816 static int yy_flex_strlen( s )
1817 yyconst char *s;
1818 #endif
1819 {
1820 register int n;
1821 for ( n = 0; s[n]; ++n )
1822 ;
1823
1824 return n;
1825 }
1826 #endif
1827
1828
1829 #ifdef YY_USE_PROTOS
1830 static void *yy_flex_alloc( yy_size_t size )
1831 #else
1832 static void *yy_flex_alloc( size )
1833 yy_size_t size;
1834 #endif
1835 {
1836 return (void *) malloc( size );
1837 }
1838
1839 #ifdef YY_USE_PROTOS
1840 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1841 #else
1842 static void *yy_flex_realloc( ptr, size )
1843 void *ptr;
1844 yy_size_t size;
1845 #endif
1846 {
1847 /* The cast to (char *) in the following accommodates both
1848 * implementations that use char* generic pointers, and those
1849 * that use void* generic pointers. It works with the latter
1850 * because both ANSI C and C++ allow castless assignment from
1851 * any pointer type to void*, and deal with argument conversions
1852 * as though doing an assignment.
1853 */
1854 return (void *) realloc( (char *) ptr, size );
1855 }
1856
1857 #ifdef YY_USE_PROTOS
1858 static void yy_flex_free( void *ptr )
1859 #else
1860 static void yy_flex_free( ptr )
1861 void *ptr;
1862 #endif
1863 {
1864 free( ptr );
1865 }
1866
1867 #if YY_MAIN
1868 int main()
1869 {
1870 yylex();
1871 return 0;
1872 }
1873 #endif
1874 #line 172 "parser.l"
1875
1876
1877 #ifndef parser_wrap
1878 int parser_wrap(void)
1879 {
1880 return 1;
1881 }
1882 #endif
1883
1884 struct keyword {
1885 const char *kw;
1886 int token;
1887 };
1888
1889 static const struct keyword keywords[] = {
1890 {"FALSE", tFALSE},
1891 {"TRUE", tTRUE},
1892 {"__cdecl", tCDECL},
1893 {"__int64", tINT64},
1894 {"__stdcall", tSTDCALL},
1895 {"_stdcall", tSTDCALL},
1896 {"boolean", tBOOLEAN},
1897 {"byte", tBYTE},
1898 {"callback", tCALLBACK},
1899 {"case", tCASE},
1900 {"char", tCHAR},
1901 {"coclass", tCOCLASS},
1902 {"code", tCODE},
1903 {"comm_status", tCOMMSTATUS},
1904 {"const", tCONST},
1905 {"cpp_quote", tCPPQUOTE},
1906 {"default", tDEFAULT},
1907 {"dispinterface", tDISPINTERFACE},
1908 {"double", tDOUBLE},
1909 {"enum", tENUM},
1910 {"error_status_t", tERRORSTATUST},
1911 {"extern", tEXTERN},
1912 {"float", tFLOAT},
1913 {"handle_t", tHANDLET},
1914 {"hyper", tHYPER},
1915 {"import", tIMPORT},
1916 {"importlib", tIMPORTLIB},
1917 {"in_line", tINLINE},
1918 {"int", tINT},
1919 {"interface", tINTERFACE},
1920 {"library", tLIBRARY},
1921 {"long", tLONG},
1922 {"methods", tMETHODS},
1923 {"module", tMODULE},
1924 {"properties", tPROPERTIES},
1925 {"short", tSHORT},
1926 {"signed", tSIGNED},
1927 {"sizeof", tSIZEOF},
1928 {"small", tSMALL},
1929 {"struct", tSTRUCT},
1930 {"switch", tSWITCH},
1931 {"typedef", tTYPEDEF},
1932 {"union", tUNION},
1933 {"unsigned", tUNSIGNED},
1934 {"void", tVOID},
1935 {"wchar_t", tWCHAR},
1936 };
1937 #define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
1938
1939 /* keywords only recognized in attribute lists */
1940 static const struct keyword attr_keywords[] =
1941 {
1942 {"aggregatable", tAGGREGATABLE},
1943 {"allocate", tALLOCATE},
1944 {"appobject", tAPPOBJECT},
1945 {"async", tASYNC},
1946 {"async_uuid", tASYNCUUID},
1947 {"auto_handle", tAUTOHANDLE},
1948 {"bindable", tBINDABLE},
1949 {"broadcast", tBROADCAST},
1950 {"byte_count", tBYTECOUNT},
1951 {"call_as", tCALLAS},
1952 {"context_handle", tCONTEXTHANDLE},
1953 {"context_handle_noserialize", tCONTEXTHANDLENOSERIALIZE},
1954 {"context_handle_serialize", tCONTEXTHANDLENOSERIALIZE},
1955 {"control", tCONTROL},
1956 {"defaultcollelem", tDEFAULTCOLLELEM},
1957 {"defaultvalue", tDEFAULTVALUE},
1958 {"defaultvtable", tDEFAULTVTABLE},
1959 {"displaybind", tDISPLAYBIND},
1960 {"dllname", tDLLNAME},
1961 {"dual", tDUAL},
1962 {"endpoint", tENDPOINT},
1963 {"entry", tENTRY},
1964 {"explicit_handle", tEXPLICITHANDLE},
1965 {"handle", tHANDLE},
1966 {"helpcontext", tHELPCONTEXT},
1967 {"helpfile", tHELPFILE},
1968 {"helpstring", tHELPSTRING},
1969 {"helpstringcontext", tHELPSTRINGCONTEXT},
1970 {"helpstringdll", tHELPSTRINGDLL},
1971 {"hidden", tHIDDEN},
1972 {"id", tID},
1973 {"idempotent", tIDEMPOTENT},
1974 {"iid_is", tIIDIS},
1975 {"immediatebind", tIMMEDIATEBIND},
1976 {"implicit_handle", tIMPLICITHANDLE},
1977 {"in", tIN},
1978 {"input_sync", tINPUTSYNC},
1979 {"lcid", tLCID},
1980 {"length_is", tLENGTHIS},
1981 {"local", tLOCAL},
1982 {"nonbrowsable", tNONBROWSABLE},
1983 {"noncreatable", tNONCREATABLE},
1984 {"nonextensible", tNONEXTENSIBLE},
1985 {"object", tOBJECT},
1986 {"odl", tODL},
1987 {"oleautomation", tOLEAUTOMATION},
1988 {"optional", tOPTIONAL},
1989 {"out", tOUT},
1990 {"pointer_default", tPOINTERDEFAULT},
1991 {"propget", tPROPGET},
1992 {"propput", tPROPPUT},
1993 {"propputref", tPROPPUTREF},
1994 {"ptr", tPTR},
1995 {"public", tPUBLIC},
1996 {"range", tRANGE},
1997 {"readonly", tREADONLY},
1998 {"ref", tREF},
1999 {"requestedit", tREQUESTEDIT},
2000 {"restricted", tRESTRICTED},
2001 {"retval", tRETVAL},
2002 {"single", tSINGLE},
2003 {"size_is", tSIZEIS},
2004 {"source", tSOURCE},
2005 {"strict_context_handle", tSTRICTCONTEXTHANDLE},
2006 {"string", tSTRING},
2007 {"switch_is", tSWITCHIS},
2008 {"switch_type", tSWITCHTYPE},
2009 {"transmit_as", tTRANSMITAS},
2010 {"unique", tUNIQUE},
2011 {"uuid", tUUID},
2012 {"v1_enum", tV1ENUM},
2013 {"vararg", tVARARG},
2014 {"version", tVERSION},
2015 {"wire_marshal", tWIREMARSHAL},
2016 };
2017
2018
2019 #define KWP(p) ((const struct keyword *)(p))
2020
2021 static int kw_cmp_func(const void *s1, const void *s2)
2022 {
2023 return strcmp(KWP(s1)->kw, KWP(s2)->kw);
2024 }
2025
2026 static int kw_token(const char *kw)
2027 {
2028 struct keyword key, *kwp;
2029 key.kw = kw;
2030 kwp = bsearch(&key, keywords, NKEYWORDS, sizeof(keywords[0]), kw_cmp_func);
2031 if (kwp) {
2032 parser_lval.str = xstrdup(kwp->kw);
2033 return kwp->token;
2034 }
2035 parser_lval.str = xstrdup(kw);
2036 return is_type(kw) ? aKNOWNTYPE : aIDENTIFIER;
2037 }
2038
2039 static int attr_token(const char *kw)
2040 {
2041 struct keyword key, *kwp;
2042 key.kw = kw;
2043 kwp = bsearch(&key, attr_keywords, sizeof(attr_keywords)/sizeof(attr_keywords[0]),
2044 sizeof(attr_keywords[0]), kw_cmp_func);
2045 if (kwp) {
2046 parser_lval.str = xstrdup(kwp->kw);
2047 return kwp->token;
2048 }
2049 return kw_token(kw);
2050 }
2051
2052 static void addcchar(char c)
2053 {
2054 if(cbufidx >= cbufalloc)
2055 {
2056 cbufalloc += 1024;
2057 cbuffer = xrealloc(cbuffer, cbufalloc * sizeof(cbuffer[0]));
2058 if(cbufalloc > 65536)
2059 parser_warning("Reallocating string buffer larger than 64kB\n");
2060 }
2061 cbuffer[cbufidx++] = c;
2062 }
2063
2064 static char *get_buffered_cstring(void)
2065 {
2066 addcchar(0);
2067 return xstrdup(cbuffer);
2068 }
2069
2070 static void pop_import(void)
2071 {
2072 int ptr = import_stack_ptr-1;
2073
2074 fclose(yyin);
2075 yy_delete_buffer( YY_CURRENT_BUFFER );
2076 yy_switch_to_buffer( import_stack[ptr].state );
2077 if (temp_name) {
2078 unlink(temp_name);
2079 free(temp_name);
2080 }
2081 temp_name = import_stack[ptr].temp_name;
2082 free( input_name );
2083 input_name = import_stack[ptr].input_name;
2084 line_number = import_stack[ptr].line_number;
2085 import_stack_ptr--;
2086 }
2087
2088 struct imports {
2089 char *name;
2090 struct imports *next;
2091 } *first_import;
2092
2093 int do_import(char *fname)
2094 {
2095 FILE *f;
2096 char *hname, *path, *p;
2097 struct imports *import;
2098 int ptr = import_stack_ptr;
2099 int ret;
2100
2101 if (!parse_only && do_header) {
2102 hname = dup_basename(fname, ".idl");
2103 p = hname + strlen(hname) - 2;
2104 if (p <= hname || strcmp( p, ".h" )) strcat(hname, ".h");
2105
2106 fprintf(header, "#include <%s>\n", hname);
2107 free(hname);
2108 }
2109
2110 import = first_import;
2111 while (import && strcmp(import->name, fname))
2112 import = import->next;
2113 if (import) return 0; /* already imported */
2114
2115 import = xmalloc(sizeof(struct imports));
2116 import->name = xstrdup(fname);
2117 import->next = first_import;
2118 first_import = import;
2119
2120 /* don't search for a file name with a path in the include directories,
2121 * for compatibility with MIDL */
2122 if (strchr( fname, '/' ) || strchr( fname, '\\' ))
2123 path = strdup( fname );
2124 else if (!(path = wpp_find_include( fname, input_name )))
2125 error_loc("Unable to open include file %s\n", fname);
2126
2127 import_stack[ptr].temp_name = temp_name;
2128 import_stack[ptr].input_name = input_name;
2129 import_stack[ptr].line_number = line_number;
2130 import_stack_ptr++;
2131 input_name = path;
2132 line_number = 1;
2133
2134 ret = wpp_parse_temp( path, NULL, &temp_name );
2135 if (ret) exit(1);
2136
2137 if((f = fopen(temp_name, "r")) == NULL)
2138 error_loc("Unable to open %s\n", temp_name);
2139
2140 import_stack[ptr].state = YY_CURRENT_BUFFER;
2141 yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
2142 return 1;
2143 }
2144
2145 void abort_import(void)
2146 {
2147 int ptr;
2148
2149 for (ptr=0; ptr<import_stack_ptr; ptr++)
2150 unlink(import_stack[ptr].temp_name);
2151 }