merge trunk head (37902)
[reactos.git] / reactos / base / applications / winhlp32 / lex.yy.c
1 /* A lexical scanner generated by flex */
2
3 /* Scanner skeleton version:
4 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
5 */
6
7 #define FLEX_SCANNER
8 #define YY_FLEX_MAJOR_VERSION 2
9 #define YY_FLEX_MINOR_VERSION 5
10
11 #include <stdio.h>
12
13
14 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
15 #ifdef c_plusplus
16 #ifndef __cplusplus
17 #define __cplusplus
18 #endif
19 #endif
20
21
22 #ifdef __cplusplus
23
24 #include <stdlib.h>
25 #include <unistd.h>
26
27 /* Use prototypes in function declarations. */
28 #define YY_USE_PROTOS
29
30 /* The "const" storage-class-modifier is valid. */
31 #define YY_USE_CONST
32
33 #else /* ! __cplusplus */
34
35 #if __STDC__
36
37 #define YY_USE_PROTOS
38 #define YY_USE_CONST
39
40 #endif /* __STDC__ */
41 #endif /* ! __cplusplus */
42
43 #ifdef __TURBOC__
44 #pragma warn -rch
45 #pragma warn -use
46 #include <io.h>
47 #include <stdlib.h>
48 #define YY_USE_CONST
49 #define YY_USE_PROTOS
50 #endif
51
52 #ifdef YY_USE_CONST
53 #define yyconst const
54 #else
55 #define yyconst
56 #endif
57
58
59 #ifdef YY_USE_PROTOS
60 #define YY_PROTO(proto) proto
61 #else
62 #define YY_PROTO(proto) ()
63 #endif
64
65 /* Returned upon end-of-file. */
66 #define YY_NULL 0
67
68 /* Promotes a possibly negative, possibly signed char to an unsigned
69 * integer for use as an array index. If the signed char is negative,
70 * we want to instead treat it as an 8-bit unsigned char, hence the
71 * double cast.
72 */
73 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
74
75 /* Enter a start condition. This macro really ought to take a parameter,
76 * but we do it the disgusting crufty way forced on us by the ()-less
77 * definition of BEGIN.
78 */
79 #define BEGIN yy_start = 1 + 2 *
80
81 /* Translate the current start state into a value that can be later handed
82 * to BEGIN to return to the state. The YYSTATE alias is for lex
83 * compatibility.
84 */
85 #define YY_START ((yy_start - 1) / 2)
86 #define YYSTATE YY_START
87
88 /* Action number for EOF rule of a given start state. */
89 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
90
91 /* Special action meaning "start processing a new file". */
92 #define YY_NEW_FILE yyrestart( yyin )
93
94 #define YY_END_OF_BUFFER_CHAR 0
95
96 /* Size of default input buffer. */
97 #define YY_BUF_SIZE 16384
98
99 typedef struct yy_buffer_state *YY_BUFFER_STATE;
100
101 extern int yyleng;
102 extern FILE *yyin, *yyout;
103
104 #define EOB_ACT_CONTINUE_SCAN 0
105 #define EOB_ACT_END_OF_FILE 1
106 #define EOB_ACT_LAST_MATCH 2
107
108 /* The funky do-while in the following #define is used to turn the definition
109 * int a single C statement (which needs a semi-colon terminator). This
110 * avoids problems with code like:
111 *
112 * if ( condition_holds )
113 * yyless( 5 );
114 * else
115 * do_something_else();
116 *
117 * Prior to using the do-while the compiler would get upset at the
118 * "else" because it interpreted the "if" statement as being all
119 * done when it reached the ';' after the yyless() call.
120 */
121
122 /* Return all but the first 'n' matched characters back to the input stream. */
123
124 #define yyless(n) \
125 do \
126 { \
127 /* Undo effects of setting up yytext. */ \
128 *yy_cp = yy_hold_char; \
129 YY_RESTORE_YY_MORE_OFFSET \
130 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
131 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
132 } \
133 while ( 0 )
134
135 #define unput(c) yyunput( c, yytext_ptr )
136
137 /* The following is because we cannot portably get our hands on size_t
138 * (without autoconf's help, which isn't available because we want
139 * flex-generated scanners to compile on their own).
140 */
141 typedef unsigned int yy_size_t;
142
143
144 struct yy_buffer_state
145 {
146 FILE *yy_input_file;
147
148 char *yy_ch_buf; /* input buffer */
149 char *yy_buf_pos; /* current position in input buffer */
150
151 /* Size of input buffer in bytes, not including room for EOB
152 * characters.
153 */
154 yy_size_t yy_buf_size;
155
156 /* Number of characters read into yy_ch_buf, not including EOB
157 * characters.
158 */
159 int yy_n_chars;
160
161 /* Whether we "own" the buffer - i.e., we know we created it,
162 * and can realloc() it to grow it, and should free() it to
163 * delete it.
164 */
165 int yy_is_our_buffer;
166
167 /* Whether this is an "interactive" input source; if so, and
168 * if we're using stdio for input, then we want to use getc()
169 * instead of fread(), to make sure we stop fetching input after
170 * each newline.
171 */
172 int yy_is_interactive;
173
174 /* Whether we're considered to be at the beginning of a line.
175 * If so, '^' rules will be active on the next match, otherwise
176 * not.
177 */
178 int yy_at_bol;
179
180 /* Whether to try to fill the input buffer when we reach the
181 * end of it.
182 */
183 int yy_fill_buffer;
184
185 int yy_buffer_status;
186 #define YY_BUFFER_NEW 0
187 #define YY_BUFFER_NORMAL 1
188 /* When an EOF's been seen but there's still some text to process
189 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
190 * shouldn't try reading from the input source any more. We might
191 * still have a bunch of tokens to match, though, because of
192 * possible backing-up.
193 *
194 * When we actually see the EOF, we change the status to "new"
195 * (via yyrestart()), so that the user can continue scanning by
196 * just pointing yyin at a new input file.
197 */
198 #define YY_BUFFER_EOF_PENDING 2
199 };
200
201 static YY_BUFFER_STATE yy_current_buffer = 0;
202
203 /* We provide macros for accessing buffer states in case in the
204 * future we want to put the buffer states in a more general
205 * "scanner state".
206 */
207 #define YY_CURRENT_BUFFER yy_current_buffer
208
209
210 /* yy_hold_char holds the character lost when yytext is formed. */
211 static char yy_hold_char;
212
213 static int yy_n_chars; /* number of characters read into yy_ch_buf */
214
215
216 int yyleng;
217
218 /* Points to current character in buffer. */
219 static char *yy_c_buf_p = (char *) 0;
220 static int yy_init = 1; /* whether we need to initialize */
221 static int yy_start = 0; /* start state number */
222
223 /* Flag which is used to allow yywrap()'s to do buffer switches
224 * instead of setting up a fresh yyin. A bit of a hack ...
225 */
226 static int yy_did_buffer_switch_on_eof;
227
228 void yyrestart YY_PROTO(( FILE *input_file ));
229
230 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
231 void yy_load_buffer_state YY_PROTO(( void ));
232 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
233 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
234 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
235 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
236 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
237
238 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
239 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
240 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
241
242 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
243 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
244 static void yy_flex_free YY_PROTO(( void * ));
245
246 #define yy_new_buffer yy_create_buffer
247
248 #define yy_set_interactive(is_interactive) \
249 { \
250 if ( ! yy_current_buffer ) \
251 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
252 yy_current_buffer->yy_is_interactive = is_interactive; \
253 }
254
255 #define yy_set_bol(at_bol) \
256 { \
257 if ( ! yy_current_buffer ) \
258 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
259 yy_current_buffer->yy_at_bol = at_bol; \
260 }
261
262 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
263
264 typedef unsigned char YY_CHAR;
265 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
266 typedef int yy_state_type;
267 extern char *yytext;
268 #define yytext_ptr yytext
269
270 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
271 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
272 static int yy_get_next_buffer YY_PROTO(( void ));
273 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
274
275 /* Done after the current pattern has been matched and before the
276 * corresponding action - sets up yytext.
277 */
278 #define YY_DO_BEFORE_ACTION \
279 yytext_ptr = yy_bp; \
280 yyleng = (int) (yy_cp - yy_bp); \
281 yy_hold_char = *yy_cp; \
282 *yy_cp = '\0'; \
283 yy_c_buf_p = yy_cp;
284
285 #define YY_NUM_RULES 14
286 #define YY_END_OF_BUFFER 15
287 static yyconst short int yy_accept[28] =
288 { 0,
289 0, 0, 0, 0, 15, 13, 14, 12, 5, 6,
290 13, 1, 1, 3, 4, 10, 8, 9, 10, 7,
291 1, 1, 0, 3, 11, 2, 0
292 } ;
293
294 static yyconst int yy_ec[256] =
295 { 0,
296 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
297 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
298 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
299 1, 3, 1, 4, 1, 1, 1, 1, 5, 1,
300 1, 1, 6, 1, 6, 1, 1, 7, 8, 8,
301 8, 8, 8, 8, 8, 8, 8, 1, 1, 1,
302 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
303 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
304 9, 9, 9, 9, 9, 9, 9, 10, 9, 9,
305 1, 11, 1, 1, 12, 13, 14, 14, 14, 14,
306
307 14, 14, 9, 9, 9, 9, 9, 9, 9, 9,
308 9, 9, 9, 9, 9, 9, 9, 9, 9, 10,
309 9, 9, 1, 1, 1, 1, 1, 1, 1, 1,
310 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
311 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
312 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
313 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
314 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
315 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
316 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
317
318 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
319 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
320 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
321 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
322 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
323 1, 1, 1, 1, 1
324 } ;
325
326 static yyconst int yy_meta[15] =
327 { 0,
328 1, 2, 1, 1, 1, 1, 3, 3, 4, 5,
329 1, 4, 1, 6
330 } ;
331
332 static yyconst short int yy_base[33] =
333 { 0,
334 0, 0, 13, 25, 25, 62, 62, 62, 62, 62,
335 12, 13, 14, 0, 62, 62, 62, 62, 0, 62,
336 6, 24, 0, 0, 62, 0, 62, 38, 42, 45,
337 51, 55
338 } ;
339
340 static yyconst short int yy_def[33] =
341 { 0,
342 27, 1, 28, 28, 27, 27, 27, 27, 27, 27,
343 27, 29, 27, 30, 27, 27, 27, 27, 31, 27,
344 29, 27, 32, 30, 27, 32, 0, 27, 27, 27,
345 27, 27
346 } ;
347
348 static yyconst short int yy_nxt[77] =
349 { 0,
350 6, 7, 8, 9, 10, 11, 12, 13, 14, 14,
351 6, 6, 15, 14, 7, 23, 17, 18, 21, 22,
352 22, 22, 23, 19, 27, 20, 7, 27, 17, 18,
353 22, 22, 27, 27, 27, 19, 27, 20, 16, 16,
354 16, 16, 16, 16, 22, 27, 22, 24, 24, 24,
355 24, 25, 27, 25, 25, 25, 25, 26, 27, 27,
356 26, 5, 27, 27, 27, 27, 27, 27, 27, 27,
357 27, 27, 27, 27, 27, 27
358 } ;
359
360 static yyconst short int yy_chk[77] =
361 { 0,
362 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
363 1, 1, 1, 1, 3, 21, 3, 3, 11, 11,
364 13, 13, 12, 3, 5, 3, 4, 0, 4, 4,
365 22, 22, 0, 0, 0, 4, 0, 4, 28, 28,
366 28, 28, 28, 28, 29, 0, 29, 30, 30, 30,
367 30, 31, 0, 31, 31, 31, 31, 32, 0, 0,
368 32, 27, 27, 27, 27, 27, 27, 27, 27, 27,
369 27, 27, 27, 27, 27, 27
370 } ;
371
372 static yy_state_type yy_last_accepting_state;
373 static char *yy_last_accepting_cpos;
374
375 /* The intent behind this definition is that it'll catch
376 * any uses of REJECT which flex missed.
377 */
378 #define REJECT reject_used_but_not_detected
379 #define yymore() yymore_used_but_not_detected
380 #define YY_MORE_ADJ 0
381 #define YY_RESTORE_YY_MORE_OFFSET
382 char *yytext;
383 #line 1 "macro.lex.l"
384 #define INITIAL 0
385 #line 2 "macro.lex.l"
386 /*
387 * Help Viewer
388 *
389 * Copyright 1996 Ulrich Schmid
390 * Copyright 2002,2008 Eric Pouech
391 *
392 * This library is free software; you can redistribute it and/or
393 * modify it under the terms of the GNU Lesser General Public
394 * License as published by the Free Software Foundation; either
395 * version 2.1 of the License, or (at your option) any later version.
396 *
397 * This library is distributed in the hope that it will be useful,
398 * but WITHOUT ANY WARRANTY; without even the implied warranty of
399 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
400 * Lesser General Public License for more details.
401 *
402 * You should have received a copy of the GNU Lesser General Public
403 * License along with this library; if not, write to the Free Software
404 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
405 */
406 #define YY_NO_INPUT 1
407 #define YY_NO_UNPUT 1
408 #define quote 1
409
410 #line 26 "macro.lex.l"
411 #include "config.h"
412 #include <assert.h>
413
414 #ifndef HAVE_UNISTD_H
415 #define YY_NO_UNISTD_H
416 #endif
417
418 #include "macro.h"
419
420 #include "wine/debug.h"
421
422 WINE_DEFAULT_DEBUG_CHANNEL(winhelp);
423
424 struct lex_data {
425 LPCSTR macroptr;
426 LPSTR strptr;
427 int quote_stack[32];
428 unsigned quote_stk_idx;
429 LPSTR cache_string[32];
430 int cache_used;
431 };
432 static struct lex_data* lex_data = NULL;
433
434 struct lexret yylval;
435
436 #define YY_INPUT(buf,result,max_size)\
437 if ((result = *lex_data->macroptr ? 1 : 0)) buf[0] = *lex_data->macroptr++;
438
439 #line 440 "lex.yy.c"
440
441 /* Macros after this point can all be overridden by user definitions in
442 * section 1.
443 */
444
445 #ifndef YY_SKIP_YYWRAP
446 #ifdef __cplusplus
447 extern "C" int yywrap YY_PROTO(( void ));
448 #else
449 extern int yywrap YY_PROTO(( void ));
450 #endif
451 #endif
452
453 #ifndef YY_NO_UNPUT
454 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
455 #endif
456
457 #ifndef yytext_ptr
458 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
459 #endif
460
461 #ifdef YY_NEED_STRLEN
462 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
463 #endif
464
465 #ifndef YY_NO_INPUT
466 #ifdef __cplusplus
467 static int yyinput YY_PROTO(( void ));
468 #else
469 static int input YY_PROTO(( void ));
470 #endif
471 #endif
472
473 #if YY_STACK_USED
474 static int yy_start_stack_ptr = 0;
475 static int yy_start_stack_depth = 0;
476 static int *yy_start_stack = 0;
477 #ifndef YY_NO_PUSH_STATE
478 static void yy_push_state YY_PROTO(( int new_state ));
479 #endif
480 #ifndef YY_NO_POP_STATE
481 static void yy_pop_state YY_PROTO(( void ));
482 #endif
483 #ifndef YY_NO_TOP_STATE
484 static int yy_top_state YY_PROTO(( void ));
485 #endif
486
487 #else
488 #define YY_NO_PUSH_STATE 1
489 #define YY_NO_POP_STATE 1
490 #define YY_NO_TOP_STATE 1
491 #endif
492
493 #ifdef YY_MALLOC_DECL
494 YY_MALLOC_DECL
495 #else
496 #if __STDC__
497 #ifndef __cplusplus
498 #include <stdlib.h>
499 #endif
500 #else
501 /* Just try to get by without declaring the routines. This will fail
502 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
503 * or sizeof(void*) != sizeof(int).
504 */
505 #endif
506 #endif
507
508 /* Amount of stuff to slurp up with each read. */
509 #ifndef YY_READ_BUF_SIZE
510 #define YY_READ_BUF_SIZE 8192
511 #endif
512
513 /* Copy whatever the last rule matched to the standard output. */
514
515 #ifndef ECHO
516 /* This used to be an fputs(), but since the string might contain NUL's,
517 * we now use fwrite().
518 */
519 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
520 #endif
521
522 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
523 * is returned in "result".
524 */
525 #ifndef YY_INPUT
526 #define YY_INPUT(buf,result,max_size) \
527 if ( yy_current_buffer->yy_is_interactive ) \
528 { \
529 int c = '*', n; \
530 for ( n = 0; n < max_size && \
531 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
532 buf[n] = (char) c; \
533 if ( c == '\n' ) \
534 buf[n++] = (char) c; \
535 if ( c == EOF && ferror( yyin ) ) \
536 YY_FATAL_ERROR( "input in flex scanner failed" ); \
537 result = n; \
538 } \
539 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
540 && ferror( yyin ) ) \
541 YY_FATAL_ERROR( "input in flex scanner failed" );
542 #endif
543
544 /* No semi-colon after return; correct usage is to write "yyterminate();" -
545 * we don't want an extra ';' after the "return" because that will cause
546 * some compilers to complain about unreachable statements.
547 */
548 #ifndef yyterminate
549 #define yyterminate() return YY_NULL
550 #endif
551
552 /* Number of entries by which start-condition stack grows. */
553 #ifndef YY_START_STACK_INCR
554 #define YY_START_STACK_INCR 25
555 #endif
556
557 /* Report a fatal error. */
558 #ifndef YY_FATAL_ERROR
559 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
560 #endif
561
562 /* Default declaration of generated scanner - a define so the user can
563 * easily add parameters.
564 */
565 #ifndef YY_DECL
566 #define YY_DECL int yylex YY_PROTO(( void ))
567 #endif
568
569 /* Code executed at the beginning of each rule, after yytext and yyleng
570 * have been set up.
571 */
572 #ifndef YY_USER_ACTION
573 #define YY_USER_ACTION
574 #endif
575
576 /* Code executed at the end of each rule. */
577 #ifndef YY_BREAK
578 #define YY_BREAK break;
579 #endif
580
581 #define YY_RULE_SETUP \
582 YY_USER_ACTION
583
584 YY_DECL
585 {
586 register yy_state_type yy_current_state;
587 register char *yy_cp, *yy_bp;
588 register int yy_act;
589
590 #line 55 "macro.lex.l"
591
592
593 #line 594 "lex.yy.c"
594
595 if ( yy_init )
596 {
597 yy_init = 0;
598
599 #ifdef YY_USER_INIT
600 YY_USER_INIT;
601 #endif
602
603 if ( ! yy_start )
604 yy_start = 1; /* first start state */
605
606 if ( ! yyin )
607 yyin = stdin;
608
609 if ( ! yyout )
610 yyout = stdout;
611
612 if ( ! yy_current_buffer )
613 yy_current_buffer =
614 yy_create_buffer( yyin, YY_BUF_SIZE );
615
616 yy_load_buffer_state();
617 }
618
619 while ( 1 ) /* loops until end-of-file is reached */
620 {
621 yy_cp = yy_c_buf_p;
622
623 /* Support of yytext. */
624 *yy_cp = yy_hold_char;
625
626 /* yy_bp points to the position in yy_ch_buf of the start of
627 * the current run.
628 */
629 yy_bp = yy_cp;
630
631 yy_current_state = yy_start;
632 yy_match:
633 do
634 {
635 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
636 if ( yy_accept[yy_current_state] )
637 {
638 yy_last_accepting_state = yy_current_state;
639 yy_last_accepting_cpos = yy_cp;
640 }
641 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
642 {
643 yy_current_state = (int) yy_def[yy_current_state];
644 if ( yy_current_state >= 28 )
645 yy_c = yy_meta[(unsigned int) yy_c];
646 }
647 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
648 ++yy_cp;
649 }
650 while ( yy_base[yy_current_state] != 62 );
651
652 yy_find_action:
653 yy_act = yy_accept[yy_current_state];
654 if ( yy_act == 0 )
655 { /* have to back up */
656 yy_cp = yy_last_accepting_cpos;
657 yy_current_state = yy_last_accepting_state;
658 yy_act = yy_accept[yy_current_state];
659 }
660
661 YY_DO_BEFORE_ACTION;
662
663
664 do_action: /* This label is used only to access EOF actions. */
665
666
667 switch ( yy_act )
668 { /* beginning of action switch */
669 case 0: /* must back up */
670 /* undo the effects of YY_DO_BEFORE_ACTION */
671 *yy_cp = yy_hold_char;
672 yy_cp = yy_last_accepting_cpos;
673 yy_current_state = yy_last_accepting_state;
674 goto yy_find_action;
675
676 case 1:
677 YY_RULE_SETUP
678 #line 57 "macro.lex.l"
679 yylval.integer = strtol(yytext, NULL, 10); return INTEGER;
680 YY_BREAK
681 case 2:
682 YY_RULE_SETUP
683 #line 58 "macro.lex.l"
684 yylval.integer = strtol(yytext, NULL, 16); return INTEGER;
685 YY_BREAK
686 case 3:
687 YY_RULE_SETUP
688 #line 60 "macro.lex.l"
689 return MACRO_Lookup(yytext, &yylval);
690 YY_BREAK
691 case 4:
692 #line 63 "macro.lex.l"
693 case 5:
694 #line 64 "macro.lex.l"
695 case 6:
696 #line 65 "macro.lex.l"
697 case 7:
698 #line 66 "macro.lex.l"
699 case 8:
700 #line 67 "macro.lex.l"
701 case 9:
702 YY_RULE_SETUP
703 #line 67 "macro.lex.l"
704 {
705 if (lex_data->quote_stk_idx == 0 ||
706 (yytext[0] == '\"' && lex_data->quote_stack[lex_data->quote_stk_idx - 1] != '\"') ||
707 (yytext[0] == '`'))
708 {
709 /* opening a new one */
710 if (lex_data->quote_stk_idx == 0)
711 {
712 assert(lex_data->cache_used < sizeof(lex_data->cache_string) / sizeof(lex_data->cache_string[0]));
713 lex_data->strptr = lex_data->cache_string[lex_data->cache_used] = HeapAlloc(GetProcessHeap(), 0, strlen(lex_data->macroptr) + 1);
714 yylval.string = lex_data->strptr;
715 lex_data->cache_used++;
716 BEGIN(quote);
717 }
718 else *lex_data->strptr++ = yytext[0];
719 lex_data->quote_stack[lex_data->quote_stk_idx++] = yytext[0];
720 assert(lex_data->quote_stk_idx < sizeof(lex_data->quote_stack) / sizeof(lex_data->quote_stack[0]));
721 }
722 else
723 {
724 if (yytext[0] == '`') assert(0);
725 /* close the current quote */
726 if (--lex_data->quote_stk_idx == 0)
727 {
728 BEGIN INITIAL;
729 *lex_data->strptr++ = '\0';
730 return STRING;
731 }
732 else *lex_data->strptr++ = yytext[0];
733 }
734 }
735 YY_BREAK
736 case 10:
737 YY_RULE_SETUP
738 #line 99 "macro.lex.l"
739 *lex_data->strptr++ = yytext[0];
740 YY_BREAK
741 case 11:
742 YY_RULE_SETUP
743 #line 100 "macro.lex.l"
744 *lex_data->strptr++ = yytext[1];
745 YY_BREAK
746 case YY_STATE_EOF(quote):
747 #line 101 "macro.lex.l"
748 return 0;
749 YY_BREAK
750 case 12:
751 YY_RULE_SETUP
752 #line 103 "macro.lex.l"
753
754 YY_BREAK
755 case 13:
756 YY_RULE_SETUP
757 #line 104 "macro.lex.l"
758 return yytext[0];
759 YY_BREAK
760 case 14:
761 YY_RULE_SETUP
762 #line 105 "macro.lex.l"
763 ECHO;
764 YY_BREAK
765 #line 766 "lex.yy.c"
766 case YY_STATE_EOF(INITIAL):
767 yyterminate();
768
769 case YY_END_OF_BUFFER:
770 {
771 /* Amount of text matched not including the EOB char. */
772 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
773
774 /* Undo the effects of YY_DO_BEFORE_ACTION. */
775 *yy_cp = yy_hold_char;
776 YY_RESTORE_YY_MORE_OFFSET
777
778 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
779 {
780 /* We're scanning a new file or input source. It's
781 * possible that this happened because the user
782 * just pointed yyin at a new source and called
783 * yylex(). If so, then we have to assure
784 * consistency between yy_current_buffer and our
785 * globals. Here is the right place to do so, because
786 * this is the first action (other than possibly a
787 * back-up) that will match for the new input source.
788 */
789 yy_n_chars = yy_current_buffer->yy_n_chars;
790 yy_current_buffer->yy_input_file = yyin;
791 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
792 }
793
794 /* Note that here we test for yy_c_buf_p "<=" to the position
795 * of the first EOB in the buffer, since yy_c_buf_p will
796 * already have been incremented past the NUL character
797 * (since all states make transitions on EOB to the
798 * end-of-buffer state). Contrast this with the test
799 * in input().
800 */
801 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
802 { /* This was really a NUL. */
803 yy_state_type yy_next_state;
804
805 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
806
807 yy_current_state = yy_get_previous_state();
808
809 /* Okay, we're now positioned to make the NUL
810 * transition. We couldn't have
811 * yy_get_previous_state() go ahead and do it
812 * for us because it doesn't know how to deal
813 * with the possibility of jamming (and we don't
814 * want to build jamming into it because then it
815 * will run more slowly).
816 */
817
818 yy_next_state = yy_try_NUL_trans( yy_current_state );
819
820 yy_bp = yytext_ptr + YY_MORE_ADJ;
821
822 if ( yy_next_state )
823 {
824 /* Consume the NUL. */
825 yy_cp = ++yy_c_buf_p;
826 yy_current_state = yy_next_state;
827 goto yy_match;
828 }
829
830 else
831 {
832 yy_cp = yy_c_buf_p;
833 goto yy_find_action;
834 }
835 }
836
837 else switch ( yy_get_next_buffer() )
838 {
839 case EOB_ACT_END_OF_FILE:
840 {
841 yy_did_buffer_switch_on_eof = 0;
842
843 if ( yywrap() )
844 {
845 /* Note: because we've taken care in
846 * yy_get_next_buffer() to have set up
847 * yytext, we can now set up
848 * yy_c_buf_p so that if some total
849 * hoser (like flex itself) wants to
850 * call the scanner after we return the
851 * YY_NULL, it'll still work - another
852 * YY_NULL will get returned.
853 */
854 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
855
856 yy_act = YY_STATE_EOF(YY_START);
857 goto do_action;
858 }
859
860 else
861 {
862 if ( ! yy_did_buffer_switch_on_eof )
863 YY_NEW_FILE;
864 }
865 break;
866 }
867
868 case EOB_ACT_CONTINUE_SCAN:
869 yy_c_buf_p =
870 yytext_ptr + yy_amount_of_matched_text;
871
872 yy_current_state = yy_get_previous_state();
873
874 yy_cp = yy_c_buf_p;
875 yy_bp = yytext_ptr + YY_MORE_ADJ;
876 goto yy_match;
877
878 case EOB_ACT_LAST_MATCH:
879 yy_c_buf_p =
880 &yy_current_buffer->yy_ch_buf[yy_n_chars];
881
882 yy_current_state = yy_get_previous_state();
883
884 yy_cp = yy_c_buf_p;
885 yy_bp = yytext_ptr + YY_MORE_ADJ;
886 goto yy_find_action;
887 }
888 break;
889 }
890
891 default:
892 YY_FATAL_ERROR(
893 "fatal flex scanner internal error--no action found" );
894 } /* end of action switch */
895 } /* end of scanning one token */
896 } /* end of yylex */
897
898
899 /* yy_get_next_buffer - try to read in a new buffer
900 *
901 * Returns a code representing an action:
902 * EOB_ACT_LAST_MATCH -
903 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
904 * EOB_ACT_END_OF_FILE - end of file
905 */
906
907 static int yy_get_next_buffer()
908 {
909 register char *dest = yy_current_buffer->yy_ch_buf;
910 register char *source = yytext_ptr;
911 register int number_to_move, i;
912 int ret_val;
913
914 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
915 YY_FATAL_ERROR(
916 "fatal flex scanner internal error--end of buffer missed" );
917
918 if ( yy_current_buffer->yy_fill_buffer == 0 )
919 { /* Don't try to fill the buffer, so this is an EOF. */
920 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
921 {
922 /* We matched a single character, the EOB, so
923 * treat this as a final EOF.
924 */
925 return EOB_ACT_END_OF_FILE;
926 }
927
928 else
929 {
930 /* We matched some text prior to the EOB, first
931 * process it.
932 */
933 return EOB_ACT_LAST_MATCH;
934 }
935 }
936
937 /* Try to read more data. */
938
939 /* First move last chars to start of buffer. */
940 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
941
942 for ( i = 0; i < number_to_move; ++i )
943 *(dest++) = *(source++);
944
945 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
946 /* don't do the read, it's not guaranteed to return an EOF,
947 * just force an EOF
948 */
949 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
950
951 else
952 {
953 int num_to_read =
954 yy_current_buffer->yy_buf_size - number_to_move - 1;
955
956 while ( num_to_read <= 0 )
957 { /* Not enough room in the buffer - grow it. */
958 #ifdef YY_USES_REJECT
959 YY_FATAL_ERROR(
960 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
961 #else
962
963 /* just a shorter name for the current buffer */
964 YY_BUFFER_STATE b = yy_current_buffer;
965
966 int yy_c_buf_p_offset =
967 (int) (yy_c_buf_p - b->yy_ch_buf);
968
969 if ( b->yy_is_our_buffer )
970 {
971 int new_size = b->yy_buf_size * 2;
972
973 if ( new_size <= 0 )
974 b->yy_buf_size += b->yy_buf_size / 8;
975 else
976 b->yy_buf_size *= 2;
977
978 b->yy_ch_buf = (char *)
979 /* Include room in for 2 EOB chars. */
980 yy_flex_realloc( (void *) b->yy_ch_buf,
981 b->yy_buf_size + 2 );
982 }
983 else
984 /* Can't grow it, we don't own it. */
985 b->yy_ch_buf = 0;
986
987 if ( ! b->yy_ch_buf )
988 YY_FATAL_ERROR(
989 "fatal error - scanner input buffer overflow" );
990
991 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
992
993 num_to_read = yy_current_buffer->yy_buf_size -
994 number_to_move - 1;
995 #endif
996 }
997
998 if ( num_to_read > YY_READ_BUF_SIZE )
999 num_to_read = YY_READ_BUF_SIZE;
1000
1001 /* Read in more data. */
1002 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1003 yy_n_chars, num_to_read );
1004
1005 yy_current_buffer->yy_n_chars = yy_n_chars;
1006 }
1007
1008 if ( yy_n_chars == 0 )
1009 {
1010 if ( number_to_move == YY_MORE_ADJ )
1011 {
1012 ret_val = EOB_ACT_END_OF_FILE;
1013 yyrestart( yyin );
1014 }
1015
1016 else
1017 {
1018 ret_val = EOB_ACT_LAST_MATCH;
1019 yy_current_buffer->yy_buffer_status =
1020 YY_BUFFER_EOF_PENDING;
1021 }
1022 }
1023
1024 else
1025 ret_val = EOB_ACT_CONTINUE_SCAN;
1026
1027 yy_n_chars += number_to_move;
1028 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1029 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1030
1031 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1032
1033 return ret_val;
1034 }
1035
1036
1037 /* yy_get_previous_state - get the state just before the EOB char was reached */
1038
1039 static yy_state_type yy_get_previous_state()
1040 {
1041 register yy_state_type yy_current_state;
1042 register char *yy_cp;
1043
1044 yy_current_state = yy_start;
1045
1046 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1047 {
1048 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1049 if ( yy_accept[yy_current_state] )
1050 {
1051 yy_last_accepting_state = yy_current_state;
1052 yy_last_accepting_cpos = yy_cp;
1053 }
1054 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1055 {
1056 yy_current_state = (int) yy_def[yy_current_state];
1057 if ( yy_current_state >= 28 )
1058 yy_c = yy_meta[(unsigned int) yy_c];
1059 }
1060 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1061 }
1062
1063 return yy_current_state;
1064 }
1065
1066
1067 /* yy_try_NUL_trans - try to make a transition on the NUL character
1068 *
1069 * synopsis
1070 * next_state = yy_try_NUL_trans( current_state );
1071 */
1072
1073 #ifdef YY_USE_PROTOS
1074 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1075 #else
1076 static yy_state_type yy_try_NUL_trans( yy_current_state )
1077 yy_state_type yy_current_state;
1078 #endif
1079 {
1080 register int yy_is_jam;
1081 register char *yy_cp = yy_c_buf_p;
1082
1083 register YY_CHAR yy_c = 1;
1084 if ( yy_accept[yy_current_state] )
1085 {
1086 yy_last_accepting_state = yy_current_state;
1087 yy_last_accepting_cpos = yy_cp;
1088 }
1089 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1090 {
1091 yy_current_state = (int) yy_def[yy_current_state];
1092 if ( yy_current_state >= 28 )
1093 yy_c = yy_meta[(unsigned int) yy_c];
1094 }
1095 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1096 yy_is_jam = (yy_current_state == 27);
1097
1098 return yy_is_jam ? 0 : yy_current_state;
1099 }
1100
1101
1102 #ifndef YY_NO_UNPUT
1103 #ifdef YY_USE_PROTOS
1104 static void yyunput( int c, register char *yy_bp )
1105 #else
1106 static void yyunput( c, yy_bp )
1107 int c;
1108 register char *yy_bp;
1109 #endif
1110 {
1111 register char *yy_cp = yy_c_buf_p;
1112
1113 /* undo effects of setting up yytext */
1114 *yy_cp = yy_hold_char;
1115
1116 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1117 { /* need to shift things up to make room */
1118 /* +2 for EOB chars. */
1119 register int number_to_move = yy_n_chars + 2;
1120 register char *dest = &yy_current_buffer->yy_ch_buf[
1121 yy_current_buffer->yy_buf_size + 2];
1122 register char *source =
1123 &yy_current_buffer->yy_ch_buf[number_to_move];
1124
1125 while ( source > yy_current_buffer->yy_ch_buf )
1126 *--dest = *--source;
1127
1128 yy_cp += (int) (dest - source);
1129 yy_bp += (int) (dest - source);
1130 yy_current_buffer->yy_n_chars =
1131 yy_n_chars = yy_current_buffer->yy_buf_size;
1132
1133 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1134 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1135 }
1136
1137 *--yy_cp = (char) c;
1138
1139
1140 yytext_ptr = yy_bp;
1141 yy_hold_char = *yy_cp;
1142 yy_c_buf_p = yy_cp;
1143 }
1144 #endif /* ifndef YY_NO_UNPUT */
1145
1146
1147 #ifdef __cplusplus
1148 static int yyinput()
1149 #else
1150 static int input()
1151 #endif
1152 {
1153 int c;
1154
1155 *yy_c_buf_p = yy_hold_char;
1156
1157 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1158 {
1159 /* yy_c_buf_p now points to the character we want to return.
1160 * If this occurs *before* the EOB characters, then it's a
1161 * valid NUL; if not, then we've hit the end of the buffer.
1162 */
1163 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1164 /* This was really a NUL. */
1165 *yy_c_buf_p = '\0';
1166
1167 else
1168 { /* need more input */
1169 int offset = yy_c_buf_p - yytext_ptr;
1170 ++yy_c_buf_p;
1171
1172 switch ( yy_get_next_buffer() )
1173 {
1174 case EOB_ACT_LAST_MATCH:
1175 /* This happens because yy_g_n_b()
1176 * sees that we've accumulated a
1177 * token and flags that we need to
1178 * try matching the token before
1179 * proceeding. But for input(),
1180 * there's no matching to consider.
1181 * So convert the EOB_ACT_LAST_MATCH
1182 * to EOB_ACT_END_OF_FILE.
1183 */
1184
1185 /* Reset buffer status. */
1186 yyrestart( yyin );
1187
1188 /* fall through */
1189
1190 case EOB_ACT_END_OF_FILE:
1191 {
1192 if ( yywrap() )
1193 return EOF;
1194
1195 if ( ! yy_did_buffer_switch_on_eof )
1196 YY_NEW_FILE;
1197 #ifdef __cplusplus
1198 return yyinput();
1199 #else
1200 return input();
1201 #endif
1202 }
1203
1204 case EOB_ACT_CONTINUE_SCAN:
1205 yy_c_buf_p = yytext_ptr + offset;
1206 break;
1207 }
1208 }
1209 }
1210
1211 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1212 *yy_c_buf_p = '\0'; /* preserve yytext */
1213 yy_hold_char = *++yy_c_buf_p;
1214
1215
1216 return c;
1217 }
1218
1219
1220 #ifdef YY_USE_PROTOS
1221 void yyrestart( FILE *input_file )
1222 #else
1223 void yyrestart( input_file )
1224 FILE *input_file;
1225 #endif
1226 {
1227 if ( ! yy_current_buffer )
1228 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1229
1230 yy_init_buffer( yy_current_buffer, input_file );
1231 yy_load_buffer_state();
1232 }
1233
1234
1235 #ifdef YY_USE_PROTOS
1236 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1237 #else
1238 void yy_switch_to_buffer( new_buffer )
1239 YY_BUFFER_STATE new_buffer;
1240 #endif
1241 {
1242 if ( yy_current_buffer == new_buffer )
1243 return;
1244
1245 if ( yy_current_buffer )
1246 {
1247 /* Flush out information for old buffer. */
1248 *yy_c_buf_p = yy_hold_char;
1249 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1250 yy_current_buffer->yy_n_chars = yy_n_chars;
1251 }
1252
1253 yy_current_buffer = new_buffer;
1254 yy_load_buffer_state();
1255
1256 /* We don't actually know whether we did this switch during
1257 * EOF (yywrap()) processing, but the only time this flag
1258 * is looked at is after yywrap() is called, so it's safe
1259 * to go ahead and always set it.
1260 */
1261 yy_did_buffer_switch_on_eof = 1;
1262 }
1263
1264
1265 #ifdef YY_USE_PROTOS
1266 void yy_load_buffer_state( void )
1267 #else
1268 void yy_load_buffer_state()
1269 #endif
1270 {
1271 yy_n_chars = yy_current_buffer->yy_n_chars;
1272 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1273 yyin = yy_current_buffer->yy_input_file;
1274 yy_hold_char = *yy_c_buf_p;
1275 }
1276
1277
1278 #ifdef YY_USE_PROTOS
1279 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1280 #else
1281 YY_BUFFER_STATE yy_create_buffer( file, size )
1282 FILE *file;
1283 int size;
1284 #endif
1285 {
1286 YY_BUFFER_STATE b;
1287
1288 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1289 if ( ! b )
1290 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1291
1292 b->yy_buf_size = size;
1293
1294 /* yy_ch_buf has to be 2 characters longer than the size given because
1295 * we need to put in 2 end-of-buffer characters.
1296 */
1297 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1298 if ( ! b->yy_ch_buf )
1299 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1300
1301 b->yy_is_our_buffer = 1;
1302
1303 yy_init_buffer( b, file );
1304
1305 return b;
1306 }
1307
1308
1309 #ifdef YY_USE_PROTOS
1310 void yy_delete_buffer( YY_BUFFER_STATE b )
1311 #else
1312 void yy_delete_buffer( b )
1313 YY_BUFFER_STATE b;
1314 #endif
1315 {
1316 if ( ! b )
1317 return;
1318
1319 if ( b == yy_current_buffer )
1320 yy_current_buffer = (YY_BUFFER_STATE) 0;
1321
1322 if ( b->yy_is_our_buffer )
1323 yy_flex_free( (void *) b->yy_ch_buf );
1324
1325 yy_flex_free( (void *) b );
1326 }
1327
1328
1329 #ifndef YY_ALWAYS_INTERACTIVE
1330 #ifndef YY_NEVER_INTERACTIVE
1331 extern int isatty YY_PROTO(( int ));
1332 #endif
1333 #endif
1334
1335 #ifdef YY_USE_PROTOS
1336 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1337 #else
1338 void yy_init_buffer( b, file )
1339 YY_BUFFER_STATE b;
1340 FILE *file;
1341 #endif
1342
1343
1344 {
1345 yy_flush_buffer( b );
1346
1347 b->yy_input_file = file;
1348 b->yy_fill_buffer = 1;
1349
1350 #if YY_ALWAYS_INTERACTIVE
1351 b->yy_is_interactive = 1;
1352 #else
1353 #if YY_NEVER_INTERACTIVE
1354 b->yy_is_interactive = 0;
1355 #else
1356 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1357 #endif
1358 #endif
1359 }
1360
1361
1362 #ifdef YY_USE_PROTOS
1363 void yy_flush_buffer( YY_BUFFER_STATE b )
1364 #else
1365 void yy_flush_buffer( b )
1366 YY_BUFFER_STATE b;
1367 #endif
1368
1369 {
1370 if ( ! b )
1371 return;
1372
1373 b->yy_n_chars = 0;
1374
1375 /* We always need two end-of-buffer characters. The first causes
1376 * a transition to the end-of-buffer state. The second causes
1377 * a jam in that state.
1378 */
1379 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1380 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1381
1382 b->yy_buf_pos = &b->yy_ch_buf[0];
1383
1384 b->yy_at_bol = 1;
1385 b->yy_buffer_status = YY_BUFFER_NEW;
1386
1387 if ( b == yy_current_buffer )
1388 yy_load_buffer_state();
1389 }
1390
1391
1392 #ifndef YY_NO_SCAN_BUFFER
1393 #ifdef YY_USE_PROTOS
1394 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1395 #else
1396 YY_BUFFER_STATE yy_scan_buffer( base, size )
1397 char *base;
1398 yy_size_t size;
1399 #endif
1400 {
1401 YY_BUFFER_STATE b;
1402
1403 if ( size < 2 ||
1404 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1405 base[size-1] != YY_END_OF_BUFFER_CHAR )
1406 /* They forgot to leave room for the EOB's. */
1407 return 0;
1408
1409 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1410 if ( ! b )
1411 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1412
1413 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1414 b->yy_buf_pos = b->yy_ch_buf = base;
1415 b->yy_is_our_buffer = 0;
1416 b->yy_input_file = 0;
1417 b->yy_n_chars = b->yy_buf_size;
1418 b->yy_is_interactive = 0;
1419 b->yy_at_bol = 1;
1420 b->yy_fill_buffer = 0;
1421 b->yy_buffer_status = YY_BUFFER_NEW;
1422
1423 yy_switch_to_buffer( b );
1424
1425 return b;
1426 }
1427 #endif
1428
1429
1430 #ifndef YY_NO_SCAN_STRING
1431 #ifdef YY_USE_PROTOS
1432 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1433 #else
1434 YY_BUFFER_STATE yy_scan_string( yy_str )
1435 yyconst char *yy_str;
1436 #endif
1437 {
1438 int len;
1439 for ( len = 0; yy_str[len]; ++len )
1440 ;
1441
1442 return yy_scan_bytes( yy_str, len );
1443 }
1444 #endif
1445
1446
1447 #ifndef YY_NO_SCAN_BYTES
1448 #ifdef YY_USE_PROTOS
1449 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1450 #else
1451 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1452 yyconst char *bytes;
1453 int len;
1454 #endif
1455 {
1456 YY_BUFFER_STATE b;
1457 char *buf;
1458 yy_size_t n;
1459 int i;
1460
1461 /* Get memory for full buffer, including space for trailing EOB's. */
1462 n = len + 2;
1463 buf = (char *) yy_flex_alloc( n );
1464 if ( ! buf )
1465 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1466
1467 for ( i = 0; i < len; ++i )
1468 buf[i] = bytes[i];
1469
1470 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1471
1472 b = yy_scan_buffer( buf, n );
1473 if ( ! b )
1474 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1475
1476 /* It's okay to grow etc. this buffer, and we should throw it
1477 * away when we're done.
1478 */
1479 b->yy_is_our_buffer = 1;
1480
1481 return b;
1482 }
1483 #endif
1484
1485
1486 #ifndef YY_NO_PUSH_STATE
1487 #ifdef YY_USE_PROTOS
1488 static void yy_push_state( int new_state )
1489 #else
1490 static void yy_push_state( new_state )
1491 int new_state;
1492 #endif
1493 {
1494 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1495 {
1496 yy_size_t new_size;
1497
1498 yy_start_stack_depth += YY_START_STACK_INCR;
1499 new_size = yy_start_stack_depth * sizeof( int );
1500
1501 if ( ! yy_start_stack )
1502 yy_start_stack = (int *) yy_flex_alloc( new_size );
1503
1504 else
1505 yy_start_stack = (int *) yy_flex_realloc(
1506 (void *) yy_start_stack, new_size );
1507
1508 if ( ! yy_start_stack )
1509 YY_FATAL_ERROR(
1510 "out of memory expanding start-condition stack" );
1511 }
1512
1513 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1514
1515 BEGIN(new_state);
1516 }
1517 #endif
1518
1519
1520 #ifndef YY_NO_POP_STATE
1521 static void yy_pop_state()
1522 {
1523 if ( --yy_start_stack_ptr < 0 )
1524 YY_FATAL_ERROR( "start-condition stack underflow" );
1525
1526 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1527 }
1528 #endif
1529
1530
1531 #ifndef YY_NO_TOP_STATE
1532 static int yy_top_state()
1533 {
1534 return yy_start_stack[yy_start_stack_ptr - 1];
1535 }
1536 #endif
1537
1538 #ifndef YY_EXIT_FAILURE
1539 #define YY_EXIT_FAILURE 2
1540 #endif
1541
1542 #ifdef YY_USE_PROTOS
1543 static void yy_fatal_error( yyconst char msg[] )
1544 #else
1545 static void yy_fatal_error( msg )
1546 char msg[];
1547 #endif
1548 {
1549 (void) fprintf( stderr, "%s\n", msg );
1550 exit( YY_EXIT_FAILURE );
1551 }
1552
1553
1554
1555 /* Redefine yyless() so it works in section 3 code. */
1556
1557 #undef yyless
1558 #define yyless(n) \
1559 do \
1560 { \
1561 /* Undo effects of setting up yytext. */ \
1562 yytext[yyleng] = yy_hold_char; \
1563 yy_c_buf_p = yytext + n; \
1564 yy_hold_char = *yy_c_buf_p; \
1565 *yy_c_buf_p = '\0'; \
1566 yyleng = n; \
1567 } \
1568 while ( 0 )
1569
1570
1571 /* Internal utility routines. */
1572
1573 #ifndef yytext_ptr
1574 #ifdef YY_USE_PROTOS
1575 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1576 #else
1577 static void yy_flex_strncpy( s1, s2, n )
1578 char *s1;
1579 yyconst char *s2;
1580 int n;
1581 #endif
1582 {
1583 register int i;
1584 for ( i = 0; i < n; ++i )
1585 s1[i] = s2[i];
1586 }
1587 #endif
1588
1589 #ifdef YY_NEED_STRLEN
1590 #ifdef YY_USE_PROTOS
1591 static int yy_flex_strlen( yyconst char *s )
1592 #else
1593 static int yy_flex_strlen( s )
1594 yyconst char *s;
1595 #endif
1596 {
1597 register int n;
1598 for ( n = 0; s[n]; ++n )
1599 ;
1600
1601 return n;
1602 }
1603 #endif
1604
1605
1606 #ifdef YY_USE_PROTOS
1607 static void *yy_flex_alloc( yy_size_t size )
1608 #else
1609 static void *yy_flex_alloc( size )
1610 yy_size_t size;
1611 #endif
1612 {
1613 return (void *) malloc( size );
1614 }
1615
1616 #ifdef YY_USE_PROTOS
1617 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1618 #else
1619 static void *yy_flex_realloc( ptr, size )
1620 void *ptr;
1621 yy_size_t size;
1622 #endif
1623 {
1624 /* The cast to (char *) in the following accommodates both
1625 * implementations that use char* generic pointers, and those
1626 * that use void* generic pointers. It works with the latter
1627 * because both ANSI C and C++ allow castless assignment from
1628 * any pointer type to void*, and deal with argument conversions
1629 * as though doing an assignment.
1630 */
1631 return (void *) realloc( (char *) ptr, size );
1632 }
1633
1634 #ifdef YY_USE_PROTOS
1635 static void yy_flex_free( void *ptr )
1636 #else
1637 static void yy_flex_free( ptr )
1638 void *ptr;
1639 #endif
1640 {
1641 free( ptr );
1642 }
1643
1644 #if YY_MAIN
1645 int main()
1646 {
1647 yylex();
1648 return 0;
1649 }
1650 #endif
1651 #line 105 "macro.lex.l"
1652
1653
1654 #if 0
1655 /* all code for testing macros */
1656 #include "winhelp.h"
1657 static CHAR szTestMacro[256];
1658
1659 static LRESULT CALLBACK MACRO_TestDialogProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
1660 {
1661 if (msg == WM_COMMAND && wParam == IDOK)
1662 {
1663 GetDlgItemText(hDlg, 99, szTestMacro, sizeof(szTestMacro));
1664 EndDialog(hDlg, IDOK);
1665 return TRUE;
1666 }
1667 return FALSE;
1668 }
1669
1670 void macro_test(void)
1671 {
1672 WNDPROC lpfnDlg = MakeProcInstance(MACRO_TestDialogProc, Globals.hInstance);
1673 DialogBox(Globals.hInstance, STRING_DIALOG_TEST, Globals.active_win->hMainWnd, lpfnDlg);
1674 FreeProcInstance(lpfnDlg);
1675 macro = szTestMacro;
1676 }
1677 #endif
1678
1679 /* small helper function for debug messages */
1680 static const char* ts(int t)
1681 {
1682 static char c[2] = {0,0};
1683
1684 switch (t)
1685 {
1686 case EMPTY: return "EMPTY";
1687 case VOID_FUNCTION: return "VOID_FUNCTION";
1688 case BOOL_FUNCTION: return "BOOL_FUNCTION";
1689 case INTEGER: return "INTEGER";
1690 case STRING: return "STRING";
1691 case IDENTIFIER: return "IDENTIFIER";
1692 default: c[0] = (char)t; return c;
1693 }
1694 }
1695
1696 static int MACRO_CallBoolFunc(FARPROC fn, const char* args, void** ret);
1697
1698 /******************************************************************
1699 * MACRO_CheckArgs
1700 *
1701 * checks number of arguments against prototype, and stores arguments on
1702 * stack pa for later call
1703 * returns -1 on error, otherwise the number of pushed parameters
1704 */
1705 static int MACRO_CheckArgs(void* pa[], unsigned max, const char* args)
1706 {
1707 int t;
1708 unsigned int len = 0, idx = 0;
1709
1710 WINE_TRACE("Checking %s\n", args);
1711
1712 if (yylex() != '(') {WINE_WARN("missing (\n");return -1;}
1713
1714 if (*args)
1715 {
1716 len = strlen(args);
1717 for (;;)
1718 {
1719 t = yylex();
1720 WINE_TRACE("Got %s <=> %c\n", ts(t), *args);
1721
1722 switch (*args)
1723 {
1724 case 'S':
1725 if (t != STRING)
1726 {WINE_WARN("missing S\n");return -1;}
1727 pa[idx] = (void*)yylval.string;
1728 break;
1729 case 'U':
1730 case 'I':
1731 if (t != INTEGER)
1732 {WINE_WARN("missing U\n");return -1;}
1733 pa[idx] = LongToPtr(yylval.integer);
1734 break;
1735 case 'B':
1736 if (t != BOOL_FUNCTION)
1737 {WINE_WARN("missing B\n");return -1;}
1738 if (MACRO_CallBoolFunc(yylval.function, yylval.proto, &pa[idx]) == 0)
1739 return -1;
1740 break;
1741 default:
1742 WINE_WARN("unexpected %s while args is %c\n", ts(t), *args);
1743 return -1;
1744 }
1745 idx++;
1746 if (*++args == '\0') break;
1747 t = yylex();
1748 if (t == ')') goto CheckArgs_end;
1749 if (t != ',') {WINE_WARN("missing ,\n");return -1;}
1750 if (idx >= max) {WINE_FIXME("stack overflow (%d)\n", max);return -1;}
1751 }
1752 }
1753 if (yylex() != ')') {WINE_WARN("missing )\n");return -1;}
1754
1755 CheckArgs_end:
1756 while (len > idx) pa[--len] = NULL;
1757 return idx;
1758 }
1759
1760 /******************************************************************
1761 * MACRO_CallBoolFunc
1762 *
1763 * Invokes boolean function fn, which arguments are defined by args
1764 * stores bool result into ret
1765 */
1766 static int MACRO_CallBoolFunc(FARPROC fn, const char* args, void** ret)
1767 {
1768 void* pa[2];
1769 int idx = MACRO_CheckArgs(pa, sizeof(pa)/sizeof(pa[0]), args);
1770
1771 if (idx < 0) return 0;
1772 if (!fn) return 1;
1773
1774 WINE_TRACE("calling with %u pmts\n", idx);
1775
1776 switch (strlen(args))
1777 {
1778 case 0: *ret = (void*)(fn)(); break;
1779 case 1: *ret = (void*)(fn)(pa[0]); break;
1780 default: WINE_FIXME("NIY\n");
1781 }
1782
1783 return 1;
1784 }
1785
1786 /******************************************************************
1787 * MACRO_CallVoidFunc
1788 *
1789 *
1790 */
1791 static int MACRO_CallVoidFunc(FARPROC fn, const char* args)
1792 {
1793 void* pa[6];
1794 int idx = MACRO_CheckArgs(pa, sizeof(pa)/sizeof(pa[0]), args);
1795
1796 if (idx < 0) return 0;
1797 if (!fn) return 1;
1798
1799 WINE_TRACE("calling %p with %u pmts\n", fn, idx);
1800
1801 switch (strlen(args))
1802 {
1803 case 0: (fn)(); break;
1804 case 1: (fn)(pa[0]); break;
1805 case 2: (fn)(pa[0],pa[1]); break;
1806 case 3: (fn)(pa[0],pa[1],pa[2]); break;
1807 case 4: (fn)(pa[0],pa[1],pa[2],pa[3]); break;
1808 case 5: (fn)(pa[0],pa[1],pa[2],pa[3],pa[4]); break;
1809 case 6: (fn)(pa[0],pa[1],pa[2],pa[3],pa[4],pa[5]); break;
1810 default: WINE_FIXME("NIY\n");
1811 }
1812
1813 return 1;
1814 }
1815
1816 BOOL MACRO_ExecuteMacro(LPCSTR macro)
1817 {
1818 struct lex_data curr_lex_data, *prev_lex_data;
1819 BOOL ret = TRUE;
1820 int t;
1821
1822 WINE_TRACE("%s\n", wine_dbgstr_a(macro));
1823
1824 prev_lex_data = lex_data;
1825 lex_data = &curr_lex_data;
1826
1827 memset(lex_data, 0, sizeof(*lex_data));
1828 lex_data->macroptr = macro;
1829
1830 while ((t = yylex()) != EMPTY)
1831 {
1832 switch (t)
1833 {
1834 case VOID_FUNCTION:
1835 WINE_TRACE("got type void func(%s)\n", yylval.proto);
1836 MACRO_CallVoidFunc(yylval.function, yylval.proto);
1837 break;
1838 case BOOL_FUNCTION:
1839 WINE_WARN("got type bool func(%s)\n", yylval.proto);
1840 break;
1841 default:
1842 WINE_WARN("got unexpected type %s\n", ts(t));
1843 return 0;
1844 }
1845 switch (t = yylex())
1846 {
1847 case EMPTY: goto done;
1848 case ';': break;
1849 default: ret = FALSE; goto done;
1850 }
1851 }
1852
1853 done:
1854 for (t = 0; t < lex_data->cache_used; t++)
1855 HeapFree(GetProcessHeap(), 0, lex_data->cache_string[t]);
1856 lex_data = prev_lex_data;
1857
1858 return ret;
1859 }
1860
1861 #ifndef yywrap
1862 int yywrap(void) { return 1; }
1863 #endif