Debian Codegraph @

gcc/testsuite/gm2/projects/pim/run/pass/tower/advflex.c

raw
1 #line 2 "advflex.c"
2
3 #line 4 "advflex.c"
4
5 #define YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 6
12 #define YY_FLEX_SUBMINOR_VERSION 4
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
16
17 /* First, we deal with platform-specific or compiler-specific issues. */
18
19 /* begin standard C headers. */
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <stdlib.h>
24
25 /* end standard C headers. */
26
27 /* flex integer type definitions */
28
29 #ifndef FLEXINT_H
30 #define FLEXINT_H
31
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
33
34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
35
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
38 */
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
41 #endif
42
43 #include <inttypes.h>
44 typedef int8_t flex_int8_t;
45 typedef uint8_t flex_uint8_t;
46 typedef int16_t flex_int16_t;
47 typedef uint16_t flex_uint16_t;
48 typedef int32_t flex_int32_t;
49 typedef uint32_t flex_uint32_t;
50 #else
51 typedef signed char flex_int8_t;
52 typedef short int flex_int16_t;
53 typedef int flex_int32_t;
54 typedef unsigned char flex_uint8_t;
55 typedef unsigned short int flex_uint16_t;
56 typedef unsigned int flex_uint32_t;
57
58 /* Limits of integral types. */
59 #ifndef INT8_MIN
60 #define INT8_MIN (-128)
61 #endif
62 #ifndef INT16_MIN
63 #define INT16_MIN (-32767-1)
64 #endif
65 #ifndef INT32_MIN
66 #define INT32_MIN (-2147483647-1)
67 #endif
68 #ifndef INT8_MAX
69 #define INT8_MAX (127)
70 #endif
71 #ifndef INT16_MAX
72 #define INT16_MAX (32767)
73 #endif
74 #ifndef INT32_MAX
75 #define INT32_MAX (2147483647)
76 #endif
77 #ifndef UINT8_MAX
78 #define UINT8_MAX (255U)
79 #endif
80 #ifndef UINT16_MAX
81 #define UINT16_MAX (65535U)
82 #endif
83 #ifndef UINT32_MAX
84 #define UINT32_MAX (4294967295U)
85 #endif
86
87 #ifndef SIZE_MAX
88 #define SIZE_MAX (~(size_t)0)
89 #endif
90
91 #endif /* ! C99 */
92
93 #endif /* ! FLEXINT_H */
94
95 /* begin standard C++ headers. */
96
97 /* TODO: this is always defined, so inline it */
98 #define yyconst const
99
100 #if defined(__GNUC__) && __GNUC__ >= 3
101 #define yynoreturn __attribute__((__noreturn__))
102 #else
103 #define yynoreturn
104 #endif
105
106 /* Returned upon end-of-file. */
107 #define YY_NULL 0
108
109 /* Promotes a possibly negative, possibly signed char to an
110 * integer in range [0..255] for use as an array index.
111 */
112 #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
113
114 /* Enter a start condition. This macro really ought to take a parameter,
115 * but we do it the disgusting crufty way forced on us by the ()-less
116 * definition of BEGIN.
117 */
118 #define BEGIN (yy_start) = 1 + 2 *
119 /* Translate the current start state into a value that can be later handed
120 * to BEGIN to return to the state. The YYSTATE alias is for lex
121 * compatibility.
122 */
123 #define YY_START (((yy_start) - 1) / 2)
124 #define YYSTATE YY_START
125 /* Action number for EOF rule of a given start state. */
126 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
127 /* Special action meaning "start processing a new file". */
128 #define YY_NEW_FILE yyrestart( yyin )
129 #define YY_END_OF_BUFFER_CHAR 0
130
131 /* Size of default input buffer. */
132 #ifndef YY_BUF_SIZE
133 #ifdef __ia64__
134 /* On IA-64, the buffer size is 16k, not 8k.
135 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
136 * Ditto for the __ia64__ case accordingly.
137 */
138 #define YY_BUF_SIZE 32768
139 #else
140 #define YY_BUF_SIZE 16384
141 #endif /* __ia64__ */
142 #endif
143
144 /* The state buf must be large enough to hold one state per character in the main buffer.
145 */
146 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
147
148 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
149 #define YY_TYPEDEF_YY_BUFFER_STATE
150 typedef struct yy_buffer_state *YY_BUFFER_STATE;
151 #endif
152
153 #ifndef YY_TYPEDEF_YY_SIZE_T
154 #define YY_TYPEDEF_YY_SIZE_T
155 typedef size_t yy_size_t;
156 #endif
157
158 extern int yyleng;
159
160 extern FILE *yyin, *yyout;
161
162 #define EOB_ACT_CONTINUE_SCAN 0
163 #define EOB_ACT_END_OF_FILE 1
164 #define EOB_ACT_LAST_MATCH 2
165
166 #define YY_LESS_LINENO(n)
167 #define YY_LINENO_REWIND_TO(ptr)
168
169 /* Return all but the first "n" matched characters back to the input stream. */
170 #define yyless(n) \
171 do \
172 { \
173 /* Undo effects of setting up yytext. */ \
174 int yyless_macro_arg = (n); \
175 YY_LESS_LINENO(yyless_macro_arg);\
176 *yy_cp = (yy_hold_char); \
177 YY_RESTORE_YY_MORE_OFFSET \
178 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
179 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
180 } \
181 while ( 0 )
182 #define unput(c) yyunput( c, (yytext_ptr) )
183
184 #ifndef YY_STRUCT_YY_BUFFER_STATE
185 #define YY_STRUCT_YY_BUFFER_STATE
186 struct yy_buffer_state
187 {
188 FILE *yy_input_file;
189
190 char *yy_ch_buf; /* input buffer */
191 char *yy_buf_pos; /* current position in input buffer */
192
193 /* Size of input buffer in bytes, not including room for EOB
194 * characters.
195 */
196 int yy_buf_size;
197
198 /* Number of characters read into yy_ch_buf, not including EOB
199 * characters.
200 */
201 int yy_n_chars;
202
203 /* Whether we "own" the buffer - i.e., we know we created it,
204 * and can realloc() it to grow it, and should free() it to
205 * delete it.
206 */
207 int yy_is_our_buffer;
208
209 /* Whether this is an "interactive" input source; if so, and
210 * if we're using stdio for input, then we want to use getc()
211 * instead of fread(), to make sure we stop fetching input after
212 * each newline.
213 */
214 int yy_is_interactive;
215
216 /* Whether we're considered to be at the beginning of a line.
217 * If so, '^' rules will be active on the next match, otherwise
218 * not.
219 */
220 int yy_at_bol;
221
222 int yy_bs_lineno; /**< The line count. */
223 int yy_bs_column; /**< The column count. */
224
225 /* Whether to try to fill the input buffer when we reach the
226 * end of it.
227 */
228 int yy_fill_buffer;
229
230 int yy_buffer_status;
231
232 #define YY_BUFFER_NEW 0
233 #define YY_BUFFER_NORMAL 1
234 /* When an EOF's been seen but there's still some text to process
235 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
236 * shouldn't try reading from the input source any more. We might
237 * still have a bunch of tokens to match, though, because of
238 * possible backing-up.
239 *
240 * When we actually see the EOF, we change the status to "new"
241 * (via yyrestart()), so that the user can continue scanning by
242 * just pointing yyin at a new input file.
243 */
244 #define YY_BUFFER_EOF_PENDING 2
245
246 };
247 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
248
249 /* Stack of input buffers. */
250 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
251 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
252 static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
253
254 /* We provide macros for accessing buffer states in case in the
255 * future we want to put the buffer states in a more general
256 * "scanner state".
257 *
258 * Returns the top of the stack, or NULL.
259 */
260 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
261 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
262 : NULL)
263 /* Same as previous macro, but useful when we know that the buffer stack is not
264 * NULL or when we need an lvalue. For internal use only.
265 */
266 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
267
268 /* yy_hold_char holds the character lost when yytext is formed. */
269 static char yy_hold_char;
270 static int yy_n_chars; /* number of characters read into yy_ch_buf */
271 int yyleng;
272
273 /* Points to current character in buffer. */
274 static char *yy_c_buf_p = NULL;
275 static int yy_init = 0; /* whether we need to initialize */
276 static int yy_start = 0; /* start state number */
277
278 /* Flag which is used to allow yywrap()'s to do buffer switches
279 * instead of setting up a fresh yyin. A bit of a hack ...
280 */
281 static int yy_did_buffer_switch_on_eof;
282
283 void yyrestart ( FILE *input_file );
284 void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer );
285 YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size );
286 void yy_delete_buffer ( YY_BUFFER_STATE b );
287 void yy_flush_buffer ( YY_BUFFER_STATE b );
288 void yypush_buffer_state ( YY_BUFFER_STATE new_buffer );
289 void yypop_buffer_state ( void );
290
291 static void yyensure_buffer_stack ( void );
292 static void yy_load_buffer_state ( void );
293 static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file );
294 #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER )
295
296 YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size );
297 YY_BUFFER_STATE yy_scan_string ( const char *yy_str );
298 YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len );
299
300 void *yyalloc ( yy_size_t );
301 void *yyrealloc ( void *, yy_size_t );
302 void yyfree ( void * );
303
304 #define yy_new_buffer yy_create_buffer
305 #define yy_set_interactive(is_interactive) \
306 { \
307 if ( ! YY_CURRENT_BUFFER ){ \
308 yyensure_buffer_stack (); \
309 YY_CURRENT_BUFFER_LVALUE = \
310 yy_create_buffer( yyin, YY_BUF_SIZE ); \
311 } \
312 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
313 }
314 #define yy_set_bol(at_bol) \
315 { \
316 if ( ! YY_CURRENT_BUFFER ){\
317 yyensure_buffer_stack (); \
318 YY_CURRENT_BUFFER_LVALUE = \
319 yy_create_buffer( yyin, YY_BUF_SIZE ); \
320 } \
321 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
322 }
323 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
324
325 /* Begin user sect3 */
326 typedef flex_uint8_t YY_CHAR;
327
328 FILE *yyin = NULL, *yyout = NULL;
329
330 typedef int yy_state_type;
331
332 extern int yylineno;
333 int yylineno = 1;
334
335 extern char *yytext;
336 #ifdef yytext_ptr
337 #undef yytext_ptr
338 #endif
339 #define yytext_ptr yytext
340
341 static yy_state_type yy_get_previous_state ( void );
342 static yy_state_type yy_try_NUL_trans ( yy_state_type current_state );
343 static int yy_get_next_buffer ( void );
344 static void yynoreturn yy_fatal_error ( const char* msg );
345
346 /* Done after the current pattern has been matched and before the
347 * corresponding action - sets up yytext.
348 */
349 #define YY_DO_BEFORE_ACTION \
350 (yytext_ptr) = yy_bp; \
351 yyleng = (int) (yy_cp - yy_bp); \
352 (yy_hold_char) = *yy_cp; \
353 *yy_cp = '\0'; \
354 (yy_c_buf_p) = yy_cp;
355 #define YY_NUM_RULES 19
356 #define YY_END_OF_BUFFER 20
357 /* This struct is not used in this scanner,
358 but its presence is necessary. */
359 struct yy_trans_info
360 {
361 flex_int32_t yy_verify;
362 flex_int32_t yy_nxt;
363 };
364 static const flex_int16_t yy_accept[75] =
365 { 0,
366 3, 3, 20, 19, 3, 1, 2, 19, 19, 19,
367 19, 19, 19, 19, 19, 19, 19, 19, 3, 1,
368 2, 15, 0, 0, 0, 16, 0, 0, 0, 0,
369 0, 0, 13, 0, 0, 0, 0, 5, 0, 0,
370 0, 0, 0, 0, 0, 0, 0, 7, 17, 0,
371 10, 0, 4, 0, 0, 0, 6, 0, 12, 0,
372 0, 0, 0, 9, 0, 11, 8, 0, 0, 0,
373 0, 14, 18, 0
374 } ;
375
376 static const YY_CHAR yy_ec[256] =
377 { 0,
378 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
381 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
382 1, 1, 1, 1, 1, 1, 1, 4, 4, 4,
383 4, 4, 4, 4, 4, 4, 4, 1, 1, 1,
384 1, 1, 1, 1, 5, 1, 6, 7, 8, 1,
385 1, 1, 9, 1, 1, 10, 11, 12, 13, 14,
386 1, 15, 16, 17, 18, 1, 19, 1, 1, 20,
387 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
388
389 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
390 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
391 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
392 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
393 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
398 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
399
400 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
401 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1
406 } ;
407
408 static const YY_CHAR yy_meta[21] =
409 { 0,
410 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
412 } ;
413
414 static const flex_int16_t yy_base[77] =
415 { 0,
416 0, 0, 78, 79, 75, 0, 72, 58, 64, 60,
417 60, 55, 62, 55, 16, 14, 10, 63, 65, 0,
418 62, 79, 52, 51, 56, 79, 57, 53, 48, 46,
419 52, 52, 79, 48, 45, 38, 38, 0, 45, 39,
420 43, 38, 33, 30, 41, 35, 36, 79, 79, 27,
421 79, 29, 79, 33, 22, 23, 79, 31, 79, 26,
422 19, 19, 16, 79, 24, 79, 79, 17, 10, 20,
423 19, 79, 79, 79, 25, 23
424 } ;
425
426 static const flex_int16_t yy_def[77] =
427 { 0,
428 74, 1, 74, 74, 74, 75, 74, 74, 74, 74,
429 74, 74, 74, 74, 74, 74, 74, 74, 74, 75,
430 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
431 74, 74, 74, 74, 74, 74, 74, 76, 74, 74,
432 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
433 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
434 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
435 74, 74, 74, 0, 74, 74
436 } ;
437
438 static const flex_int16_t yy_nxt[100] =
439 { 0,
440 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
441 4, 4, 14, 4, 15, 16, 17, 4, 18, 4,
442 29, 31, 33, 49, 34, 20, 73, 72, 30, 71,
443 32, 70, 69, 68, 67, 66, 65, 64, 63, 62,
444 61, 60, 59, 58, 57, 56, 55, 54, 53, 52,
445 51, 50, 48, 47, 46, 45, 44, 43, 42, 41,
446 40, 39, 38, 37, 36, 21, 19, 35, 28, 27,
447 26, 25, 24, 23, 22, 21, 19, 74, 3, 74,
448 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
449 74, 74, 74, 74, 74, 74, 74, 74, 74
450
451 } ;
452
453 static const flex_int16_t yy_chk[100] =
454 { 0,
455 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
456 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
457 15, 16, 17, 76, 17, 75, 71, 70, 15, 69,
458 16, 68, 65, 63, 62, 61, 60, 58, 56, 55,
459 54, 52, 50, 47, 46, 45, 44, 43, 42, 41,
460 40, 39, 37, 36, 35, 34, 32, 31, 30, 29,
461 28, 27, 25, 24, 23, 21, 19, 18, 14, 13,
462 12, 11, 10, 9, 8, 7, 5, 3, 74, 74,
463 74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
464 74, 74, 74, 74, 74, 74, 74, 74, 74
465
466 } ;
467
468 static yy_state_type yy_last_accepting_state;
469 static char *yy_last_accepting_cpos;
470
471 extern int yy_flex_debug;
472 int yy_flex_debug = 0;
473
474 /* The intent behind this definition is that it'll catch
475 * any uses of REJECT which flex missed.
476 */
477 #define REJECT reject_used_but_not_detected
478 #define yymore() yymore_used_but_not_detected
479 #define YY_MORE_ADJ 0
480 #define YY_RESTORE_YY_MORE_OFFSET
481 char *yytext;
482 #line 1 "adv.flex"
483 #line 2 "adv.flex"
484 /* Copyright (C) 2022 Free Software Foundation, Inc.
485 This file is part of GNU Modula-2.
486
487 GNU Modula-2 is free software; you can redistribute it and/or modify it under
488 the terms of the GNU General Public License as published by the Free
489 Software Foundation; either version 2, or (at your option) any later
490 version.
491
492 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
493 WARRANTY; without even the implied warranty of MERCHANTABILITY or
494 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
495 for more details.
496
497 You should have received a copy of the GNU General Public License along
498 with gm2; see the file COPYING. If not, write to the Free Software
499 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
500 */
501
502 /*
503 * adv.flex - provides a lexical analyser for Dungeon
504 */
505
506 struct lineInfo {
507 char *linebuf; /* line contents */
508 int linelen; /* length */
509 int tokenpos; /* start position of token within line */
510 int toklen; /* a copy of yylen (length of token) */
511 int nextpos; /* position after token */
512 int actualline; /* line number of this line */
513 };
514
515 static int lineno =1; /* a running count of the file line number */
516 static char *filename =NULL;
517 static struct lineInfo *currentLine =NULL;
518
519 void advflex_error (const char *);
520 static void finishedLine (void);
521 static void resetpos (void);
522 static void consumeLine (void);
523 static void updatepos (void);
524 static void skippos (void);
525 static void poperrorskip (const char *);
526 int advflex_OpenSource (char *s);
527 int advflex_GetLineNo (void);
528 void advflex_CloseSource(void);
529 char *advflex_GetToken (void);
530 void _M2_advflex_init (int, char *, char *);
531 void _M2_advflex_finish (int, char *, char *);
532 void _M2_advflex_ctor (void);
533 extern void yylex (void);
534
535 #if !defined(TRUE)
536 # define TRUE (1==1)
537 #endif
538 #if !defined(FALSE)
539 # define FALSE (1==0)
540 #endif
541
542 typedef enum {eoftok, roomtok, doortok, walltok, treasuretok, attok,
543 leadstok, totok, statustok, closedtok, opentok, secrettok,
544 istok, endtok, enddottok, integertok, randomizetok} toktype ;
545
546 toktype advflex_currenttoken;
547 char *advflex_currentident;
548 int advflex_currentinteger;
549
550
551 #define YY_DECL void yylex (void)
552 #line 553 "advflex.c"
553 #line 554 "advflex.c"
554
555 #define INITIAL 0
556
557 #ifndef YY_NO_UNISTD_H
558 /* Special case for "unistd.h", since it is non-ANSI. We include it way
559 * down here because we want the user's section 1 to have been scanned first.
560 * The user has a chance to override it with an option.
561 */
562 #include <unistd.h>
563 #endif
564
565 #ifndef YY_EXTRA_TYPE
566 #define YY_EXTRA_TYPE void *
567 #endif
568
569 static int yy_init_globals ( void );
570
571 /* Accessor methods to globals.
572 These are made visible to non-reentrant scanners for convenience. */
573
574 int yylex_destroy ( void );
575
576 int yyget_debug ( void );
577
578 void yyset_debug ( int debug_flag );
579
580 YY_EXTRA_TYPE yyget_extra ( void );
581
582 void yyset_extra ( YY_EXTRA_TYPE user_defined );
583
584 FILE *yyget_in ( void );
585
586 void yyset_in ( FILE * _in_str );
587
588 FILE *yyget_out ( void );
589
590 void yyset_out ( FILE * _out_str );
591
592 int yyget_leng ( void );
593
594 char *yyget_text ( void );
595
596 int yyget_lineno ( void );
597
598 void yyset_lineno ( int _line_number );
599
600 /* Macros after this point can all be overridden by user definitions in
601 * section 1.
602 */
603
604 #ifndef YY_SKIP_YYWRAP
605 #ifdef __cplusplus
606 extern "C" int yywrap ( void );
607 #else
608 extern int yywrap ( void );
609 #endif
610 #endif
611
612 #ifndef YY_NO_UNPUT
613
614 static void yyunput ( int c, char *buf_ptr );
615
616 #endif
617
618 #ifndef yytext_ptr
619 static void yy_flex_strncpy ( char *, const char *, int );
620 #endif
621
622 #ifdef YY_NEED_STRLEN
623 static int yy_flex_strlen ( const char * );
624 #endif
625
626 #ifndef YY_NO_INPUT
627 #ifdef __cplusplus
628 static int yyinput ( void );
629 #else
630 static int input ( void );
631 #endif
632
633 #endif
634
635 /* Amount of stuff to slurp up with each read. */
636 #ifndef YY_READ_BUF_SIZE
637 #ifdef __ia64__
638 /* On IA-64, the buffer size is 16k, not 8k */
639 #define YY_READ_BUF_SIZE 16384
640 #else
641 #define YY_READ_BUF_SIZE 8192
642 #endif /* __ia64__ */
643 #endif
644
645 /* Copy whatever the last rule matched to the standard output. */
646 #ifndef ECHO
647 /* This used to be an fputs(), but since the string might contain NUL's,
648 * we now use fwrite().
649 */
650 #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
651 #endif
652
653 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
654 * is returned in "result".
655 */
656 #ifndef YY_INPUT
657 #define YY_INPUT(buf,result,max_size) \
658 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
659 { \
660 int c = '*'; \
661 int n; \
662 for ( n = 0; n < max_size && \
663 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
664 buf[n] = (char) c; \
665 if ( c == '\n' ) \
666 buf[n++] = (char) c; \
667 if ( c == EOF && ferror( yyin ) ) \
668 YY_FATAL_ERROR( "input in flex scanner failed" ); \
669 result = n; \
670 } \
671 else \
672 { \
673 errno=0; \
674 while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
675 { \
676 if( errno != EINTR) \
677 { \
678 YY_FATAL_ERROR( "input in flex scanner failed" ); \
679 break; \
680 } \
681 errno=0; \
682 clearerr(yyin); \
683 } \
684 }\
685 \
686
687 #endif
688
689 /* No semi-colon after return; correct usage is to write "yyterminate();" -
690 * we don't want an extra ';' after the "return" because that will cause
691 * some compilers to complain about unreachable statements.
692 */
693 #ifndef yyterminate
694 #define yyterminate() return YY_NULL
695 #endif
696
697 /* Number of entries by which start-condition stack grows. */
698 #ifndef YY_START_STACK_INCR
699 #define YY_START_STACK_INCR 25
700 #endif
701
702 /* Report a fatal error. */
703 #ifndef YY_FATAL_ERROR
704 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
705 #endif
706
707 /* end tables serialization structures and prototypes */
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_IS_OURS 1
714
715 extern int yylex (void);
716
717 #define YY_DECL int yylex (void)
718 #endif /* !YY_DECL */
719
720 /* Code executed at the beginning of each rule, after yytext and yyleng
721 * have been set up.
722 */
723 #ifndef YY_USER_ACTION
724 #define YY_USER_ACTION
725 #endif
726
727 /* Code executed at the end of each rule. */
728 #ifndef YY_BREAK
729 #define YY_BREAK /*LINTED*/break;
730 #endif
731
732 #define YY_RULE_SETUP \
733 YY_USER_ACTION
734
735 /** The main scanner function which does all the work.
736 */
737 YY_DECL
738 {
739 yy_state_type yy_current_state;
740 char *yy_cp, *yy_bp;
741 int yy_act;
742
743 if ( !(yy_init) )
744 {
745 (yy_init) = 1;
746
747 #ifdef YY_USER_INIT
748 YY_USER_INIT;
749 #endif
750
751 if ( ! (yy_start) )
752 (yy_start) = 1; /* first start state */
753
754 if ( ! yyin )
755 yyin = stdin;
756
757 if ( ! yyout )
758 yyout = stdout;
759
760 if ( ! YY_CURRENT_BUFFER ) {
761 yyensure_buffer_stack ();
762 YY_CURRENT_BUFFER_LVALUE =
763 yy_create_buffer( yyin, YY_BUF_SIZE );
764 }
765
766 yy_load_buffer_state( );
767 }
768
769 {
770 #line 72 "adv.flex"
771
772
773 #line 774 "advflex.c"
774
775 while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
776 {
777 yy_cp = (yy_c_buf_p);
778
779 /* Support of yytext. */
780 *yy_cp = (yy_hold_char);
781
782 /* yy_bp points to the position in yy_ch_buf of the start of
783 * the current run.
784 */
785 yy_bp = yy_cp;
786
787 yy_current_state = (yy_start);
788 yy_match:
789 do
790 {
791 YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
792 if ( yy_accept[yy_current_state] )
793 {
794 (yy_last_accepting_state) = yy_current_state;
795 (yy_last_accepting_cpos) = yy_cp;
796 }
797 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
798 {
799 yy_current_state = (int) yy_def[yy_current_state];
800 if ( yy_current_state >= 75 )
801 yy_c = yy_meta[yy_c];
802 }
803 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
804 ++yy_cp;
805 }
806 while ( yy_base[yy_current_state] != 79 );
807
808 yy_find_action:
809 yy_act = yy_accept[yy_current_state];
810 if ( yy_act == 0 )
811 { /* have to back up */
812 yy_cp = (yy_last_accepting_cpos);
813 yy_current_state = (yy_last_accepting_state);
814 yy_act = yy_accept[yy_current_state];
815 }
816
817 YY_DO_BEFORE_ACTION;
818
819 do_action: /* This label is used only to access EOF actions. */
820
821 switch ( yy_act )
822 { /* beginning of action switch */
823 case 0: /* must back up */
824 /* undo the effects of YY_DO_BEFORE_ACTION */
825 *yy_cp = (yy_hold_char);
826 yy_cp = (yy_last_accepting_cpos);
827 yy_current_state = (yy_last_accepting_state);
828 goto yy_find_action;
829
830 case 1:
831 /* rule 1 can match eol */
832 YY_RULE_SETUP
833 #line 74 "adv.flex"
834 { consumeLine(); /* printf("found: %s\n", currentLine->linebuf); */ }
835 YY_BREAK
836 case 2:
837 YY_RULE_SETUP
838 #line 75 "adv.flex"
839 { updatepos();
840 advflex_currenttoken = integertok;
841 advflex_currentinteger = atoi(yytext);
842 return; }
843 YY_BREAK
844 case 3:
845 YY_RULE_SETUP
846 #line 79 "adv.flex"
847 { updatepos(); }
848 YY_BREAK
849 case 4:
850 YY_RULE_SETUP
851 #line 80 "adv.flex"
852 { updatepos(); advflex_currenttoken = roomtok; return; }
853 YY_BREAK
854 case 5:
855 YY_RULE_SETUP
856 #line 81 "adv.flex"
857 { updatepos(); advflex_currenttoken = endtok; return; }
858 YY_BREAK
859 case 6:
860 YY_RULE_SETUP
861 #line 82 "adv.flex"
862 { updatepos(); advflex_currenttoken = walltok; return; }
863 YY_BREAK
864 case 7:
865 YY_RULE_SETUP
866 #line 83 "adv.flex"
867 { updatepos(); advflex_currenttoken = doortok; return; }
868 YY_BREAK
869 case 8:
870 YY_RULE_SETUP
871 #line 84 "adv.flex"
872 { updatepos(); advflex_currenttoken = statustok; return; }
873 YY_BREAK
874 case 9:
875 YY_RULE_SETUP
876 #line 85 "adv.flex"
877 { updatepos(); advflex_currenttoken = closedtok; return; }
878 YY_BREAK
879 case 10:
880 YY_RULE_SETUP
881 #line 86 "adv.flex"
882 { updatepos(); advflex_currenttoken = opentok; return; }
883 YY_BREAK
884 case 11:
885 YY_RULE_SETUP
886 #line 87 "adv.flex"
887 { updatepos(); advflex_currenttoken = secrettok; return; }
888 YY_BREAK
889 case 12:
890 YY_RULE_SETUP
891 #line 88 "adv.flex"
892 { updatepos(); advflex_currenttoken = leadstok; return; }
893 YY_BREAK
894 case 13:
895 YY_RULE_SETUP
896 #line 89 "adv.flex"
897 { updatepos(); advflex_currenttoken = totok; return; }
898 YY_BREAK
899 case 14:
900 YY_RULE_SETUP
901 #line 90 "adv.flex"
902 { updatepos(); advflex_currenttoken = treasuretok; return; }
903 YY_BREAK
904 case 15:
905 YY_RULE_SETUP
906 #line 91 "adv.flex"
907 { updatepos(); advflex_currenttoken = attok; return; }
908 YY_BREAK
909 case 16:
910 YY_RULE_SETUP
911 #line 92 "adv.flex"
912 { updatepos(); advflex_currenttoken = istok; return; }
913 YY_BREAK
914 case 17:
915 YY_RULE_SETUP
916 #line 93 "adv.flex"
917 { updatepos(); advflex_currenttoken = enddottok; return; }
918 YY_BREAK
919 case 18:
920 YY_RULE_SETUP
921 #line 94 "adv.flex"
922 { updatepos(); advflex_currenttoken = randomizetok; return; }
923 YY_BREAK
924 case YY_STATE_EOF(INITIAL):
925 #line 95 "adv.flex"
926 { updatepos(); advflex_currenttoken = eoftok; return; }
927 YY_BREAK
928 case 19:
929 YY_RULE_SETUP
930 #line 97 "adv.flex"
931 ECHO;
932 YY_BREAK
933 #line 934 "advflex.c"
934
935 case YY_END_OF_BUFFER:
936 {
937 /* Amount of text matched not including the EOB char. */
938 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
939
940 /* Undo the effects of YY_DO_BEFORE_ACTION. */
941 *yy_cp = (yy_hold_char);
942 YY_RESTORE_YY_MORE_OFFSET
943
944 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
945 {
946 /* We're scanning a new file or input source. It's
947 * possible that this happened because the user
948 * just pointed yyin at a new source and called
949 * yylex(). If so, then we have to assure
950 * consistency between YY_CURRENT_BUFFER and our
951 * globals. Here is the right place to do so, because
952 * this is the first action (other than possibly a
953 * back-up) that will match for the new input source.
954 */
955 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
956 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
957 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
958 }
959
960 /* Note that here we test for yy_c_buf_p "<=" to the position
961 * of the first EOB in the buffer, since yy_c_buf_p will
962 * already have been incremented past the NUL character
963 * (since all states make transitions on EOB to the
964 * end-of-buffer state). Contrast this with the test
965 * in input().
966 */
967 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
968 { /* This was really a NUL. */
969 yy_state_type yy_next_state;
970
971 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
972
973 yy_current_state = yy_get_previous_state( );
974
975 /* Okay, we're now positioned to make the NUL
976 * transition. We couldn't have
977 * yy_get_previous_state() go ahead and do it
978 * for us because it doesn't know how to deal
979 * with the possibility of jamming (and we don't
980 * want to build jamming into it because then it
981 * will run more slowly).
982 */
983
984 yy_next_state = yy_try_NUL_trans( yy_current_state );
985
986 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
987
988 if ( yy_next_state )
989 {
990 /* Consume the NUL. */
991 yy_cp = ++(yy_c_buf_p);
992 yy_current_state = yy_next_state;
993 goto yy_match;
994 }
995
996 else
997 {
998 yy_cp = (yy_c_buf_p);
999 goto yy_find_action;
1000 }
1001 }
1002
1003 else switch ( yy_get_next_buffer( ) )
1004 {
1005 case EOB_ACT_END_OF_FILE:
1006 {
1007 (yy_did_buffer_switch_on_eof) = 0;
1008
1009 if ( yywrap( ) )
1010 {
1011 /* Note: because we've taken care in
1012 * yy_get_next_buffer() to have set up
1013 * yytext, we can now set up
1014 * yy_c_buf_p so that if some total
1015 * hoser (like flex itself) wants to
1016 * call the scanner after we return the
1017 * YY_NULL, it'll still work - another
1018 * YY_NULL will get returned.
1019 */
1020 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1021
1022 yy_act = YY_STATE_EOF(YY_START);
1023 goto do_action;
1024 }
1025
1026 else
1027 {
1028 if ( ! (yy_did_buffer_switch_on_eof) )
1029 YY_NEW_FILE;
1030 }
1031 break;
1032 }
1033
1034 case EOB_ACT_CONTINUE_SCAN:
1035 (yy_c_buf_p) =
1036 (yytext_ptr) + yy_amount_of_matched_text;
1037
1038 yy_current_state = yy_get_previous_state( );
1039
1040 yy_cp = (yy_c_buf_p);
1041 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1042 goto yy_match;
1043
1044 case EOB_ACT_LAST_MATCH:
1045 (yy_c_buf_p) =
1046 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1047
1048 yy_current_state = yy_get_previous_state( );
1049
1050 yy_cp = (yy_c_buf_p);
1051 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1052 goto yy_find_action;
1053 }
1054 break;
1055 }
1056
1057 default:
1058 YY_FATAL_ERROR(
1059 "fatal flex scanner internal error--no action found" );
1060 } /* end of action switch */
1061 } /* end of scanning one token */
1062 } /* end of user's declarations */
1063 } /* end of yylex */
1064
1065 /* yy_get_next_buffer - try to read in a new buffer
1066 *
1067 * Returns a code representing an action:
1068 * EOB_ACT_LAST_MATCH -
1069 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1070 * EOB_ACT_END_OF_FILE - end of file
1071 */
1072 static int yy_get_next_buffer (void)
1073 {
1074 char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1075 char *source = (yytext_ptr);
1076 int number_to_move, i;
1077 int ret_val;
1078
1079 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1080 YY_FATAL_ERROR(
1081 "fatal flex scanner internal error--end of buffer missed" );
1082
1083 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1084 { /* Don't try to fill the buffer, so this is an EOF. */
1085 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1086 {
1087 /* We matched a single character, the EOB, so
1088 * treat this as a final EOF.
1089 */
1090 return EOB_ACT_END_OF_FILE;
1091 }
1092
1093 else
1094 {
1095 /* We matched some text prior to the EOB, first
1096 * process it.
1097 */
1098 return EOB_ACT_LAST_MATCH;
1099 }
1100 }
1101
1102 /* Try to read more data. */
1103
1104 /* First move last chars to start of buffer. */
1105 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
1106
1107 for ( i = 0; i < number_to_move; ++i )
1108 *(dest++) = *(source++);
1109
1110 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1111 /* don't do the read, it's not guaranteed to return an EOF,
1112 * just force an EOF
1113 */
1114 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1115
1116 else
1117 {
1118 int num_to_read =
1119 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1120
1121 while ( num_to_read <= 0 )
1122 { /* Not enough room in the buffer - grow it. */
1123
1124 /* just a shorter name for the current buffer */
1125 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1126
1127 int yy_c_buf_p_offset =
1128 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1129
1130 if ( b->yy_is_our_buffer )
1131 {
1132 int new_size = b->yy_buf_size * 2;
1133
1134 if ( new_size <= 0 )
1135 b->yy_buf_size += b->yy_buf_size / 8;
1136 else
1137 b->yy_buf_size *= 2;
1138
1139 b->yy_ch_buf = (char *)
1140 /* Include room in for 2 EOB chars. */
1141 yyrealloc( (void *) b->yy_ch_buf,
1142 (yy_size_t) (b->yy_buf_size + 2) );
1143 }
1144 else
1145 /* Can't grow it, we don't own it. */
1146 b->yy_ch_buf = NULL;
1147
1148 if ( ! b->yy_ch_buf )
1149 YY_FATAL_ERROR(
1150 "fatal error - scanner input buffer overflow" );
1151
1152 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1153
1154 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1155 number_to_move - 1;
1156
1157 }
1158
1159 if ( num_to_read > YY_READ_BUF_SIZE )
1160 num_to_read = YY_READ_BUF_SIZE;
1161
1162 /* Read in more data. */
1163 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1164 (yy_n_chars), num_to_read );
1165
1166 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1167 }
1168
1169 if ( (yy_n_chars) == 0 )
1170 {
1171 if ( number_to_move == YY_MORE_ADJ )
1172 {
1173 ret_val = EOB_ACT_END_OF_FILE;
1174 yyrestart( yyin );
1175 }
1176
1177 else
1178 {
1179 ret_val = EOB_ACT_LAST_MATCH;
1180 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1181 YY_BUFFER_EOF_PENDING;
1182 }
1183 }
1184
1185 else
1186 ret_val = EOB_ACT_CONTINUE_SCAN;
1187
1188 if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1189 /* Extend the array by 50%, plus the number we really need. */
1190 int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1191 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1192 (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size );
1193 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1194 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1195 /* "- 2" to take care of EOB's */
1196 YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1197 }
1198
1199 (yy_n_chars) += number_to_move;
1200 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1201 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1202
1203 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1204
1205 return ret_val;
1206 }
1207
1208 /* yy_get_previous_state - get the state just before the EOB char was reached */
1209
1210 static yy_state_type yy_get_previous_state (void)
1211 {
1212 yy_state_type yy_current_state;
1213 char *yy_cp;
1214
1215 yy_current_state = (yy_start);
1216
1217 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1218 {
1219 YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1220 if ( yy_accept[yy_current_state] )
1221 {
1222 (yy_last_accepting_state) = yy_current_state;
1223 (yy_last_accepting_cpos) = yy_cp;
1224 }
1225 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1226 {
1227 yy_current_state = (int) yy_def[yy_current_state];
1228 if ( yy_current_state >= 75 )
1229 yy_c = yy_meta[yy_c];
1230 }
1231 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1232 }
1233
1234 return yy_current_state;
1235 }
1236
1237 /* yy_try_NUL_trans - try to make a transition on the NUL character
1238 *
1239 * synopsis
1240 * next_state = yy_try_NUL_trans( current_state );
1241 */
1242 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1243 {
1244 int yy_is_jam;
1245 char *yy_cp = (yy_c_buf_p);
1246
1247 YY_CHAR yy_c = 1;
1248 if ( yy_accept[yy_current_state] )
1249 {
1250 (yy_last_accepting_state) = yy_current_state;
1251 (yy_last_accepting_cpos) = yy_cp;
1252 }
1253 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1254 {
1255 yy_current_state = (int) yy_def[yy_current_state];
1256 if ( yy_current_state >= 75 )
1257 yy_c = yy_meta[yy_c];
1258 }
1259 yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1260 yy_is_jam = (yy_current_state == 74);
1261
1262 return yy_is_jam ? 0 : yy_current_state;
1263 }
1264
1265 #ifndef YY_NO_UNPUT
1266
1267 static void yyunput (int c, char * yy_bp )
1268 {
1269 char *yy_cp;
1270
1271 yy_cp = (yy_c_buf_p);
1272
1273 /* undo effects of setting up yytext */
1274 *yy_cp = (yy_hold_char);
1275
1276 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1277 { /* need to shift things up to make room */
1278 /* +2 for EOB chars. */
1279 int number_to_move = (yy_n_chars) + 2;
1280 char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1281 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1282 char *source =
1283 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1284
1285 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1286 *--dest = *--source;
1287
1288 yy_cp += (int) (dest - source);
1289 yy_bp += (int) (dest - source);
1290 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1291 (yy_n_chars) = (int) YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1292
1293 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1294 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1295 }
1296
1297 *--yy_cp = (char) c;
1298
1299 (yytext_ptr) = yy_bp;
1300 (yy_hold_char) = *yy_cp;
1301 (yy_c_buf_p) = yy_cp;
1302 }
1303
1304 #endif
1305
1306 #ifndef YY_NO_INPUT
1307 #ifdef __cplusplus
1308 static int yyinput (void)
1309 #else
1310 static int input (void)
1311 #endif
1312
1313 {
1314 int c;
1315
1316 *(yy_c_buf_p) = (yy_hold_char);
1317
1318 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1319 {
1320 /* yy_c_buf_p now points to the character we want to return.
1321 * If this occurs *before* the EOB characters, then it's a
1322 * valid NUL; if not, then we've hit the end of the buffer.
1323 */
1324 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1325 /* This was really a NUL. */
1326 *(yy_c_buf_p) = '\0';
1327
1328 else
1329 { /* need more input */
1330 int offset = (int) ((yy_c_buf_p) - (yytext_ptr));
1331 ++(yy_c_buf_p);
1332
1333 switch ( yy_get_next_buffer( ) )
1334 {
1335 case EOB_ACT_LAST_MATCH:
1336 /* This happens because yy_g_n_b()
1337 * sees that we've accumulated a
1338 * token and flags that we need to
1339 * try matching the token before
1340 * proceeding. But for input(),
1341 * there's no matching to consider.
1342 * So convert the EOB_ACT_LAST_MATCH
1343 * to EOB_ACT_END_OF_FILE.
1344 */
1345
1346 /* Reset buffer status. */
1347 yyrestart( yyin );
1348
1349 /*FALLTHROUGH*/
1350
1351 case EOB_ACT_END_OF_FILE:
1352 {
1353 if ( yywrap( ) )
1354 return 0;
1355
1356 if ( ! (yy_did_buffer_switch_on_eof) )
1357 YY_NEW_FILE;
1358 #ifdef __cplusplus
1359 return yyinput();
1360 #else
1361 return input();
1362 #endif
1363 }
1364
1365 case EOB_ACT_CONTINUE_SCAN:
1366 (yy_c_buf_p) = (yytext_ptr) + offset;
1367 break;
1368 }
1369 }
1370 }
1371
1372 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1373 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1374 (yy_hold_char) = *++(yy_c_buf_p);
1375
1376 return c;
1377 }
1378 #endif /* ifndef YY_NO_INPUT */
1379
1380 /** Immediately switch to a different input stream.
1381 * @param input_file A readable stream.
1382 *
1383 * @note This function does not reset the start condition to @c INITIAL .
1384 */
1385 void yyrestart (FILE * input_file )
1386 {
1387
1388 if ( ! YY_CURRENT_BUFFER ){
1389 yyensure_buffer_stack ();
1390 YY_CURRENT_BUFFER_LVALUE =
1391 yy_create_buffer( yyin, YY_BUF_SIZE );
1392 }
1393
1394 yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1395 yy_load_buffer_state( );
1396 }
1397
1398 /** Switch to a different input buffer.
1399 * @param new_buffer The new input buffer.
1400 *
1401 */
1402 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1403 {
1404
1405 /* TODO. We should be able to replace this entire function body
1406 * with
1407 * yypop_buffer_state();
1408 * yypush_buffer_state(new_buffer);
1409 */
1410 yyensure_buffer_stack ();
1411 if ( YY_CURRENT_BUFFER == new_buffer )
1412 return;
1413
1414 if ( YY_CURRENT_BUFFER )
1415 {
1416 /* Flush out information for old buffer. */
1417 *(yy_c_buf_p) = (yy_hold_char);
1418 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1419 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1420 }
1421
1422 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1423 yy_load_buffer_state( );
1424
1425 /* We don't actually know whether we did this switch during
1426 * EOF (yywrap()) processing, but the only time this flag
1427 * is looked at is after yywrap() is called, so it's safe
1428 * to go ahead and always set it.
1429 */
1430 (yy_did_buffer_switch_on_eof) = 1;
1431 }
1432
1433 static void yy_load_buffer_state (void)
1434 {
1435 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1436 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1437 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1438 (yy_hold_char) = *(yy_c_buf_p);
1439 }
1440
1441 /** Allocate and initialize an input buffer state.
1442 * @param file A readable stream.
1443 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1444 *
1445 * @return the allocated buffer state.
1446 */
1447 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1448 {
1449 YY_BUFFER_STATE b;
1450
1451 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
1452 if ( ! b )
1453 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1454
1455 b->yy_buf_size = size;
1456
1457 /* yy_ch_buf has to be 2 characters longer than the size given because
1458 * we need to put in 2 end-of-buffer characters.
1459 */
1460 b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) );
1461 if ( ! b->yy_ch_buf )
1462 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1463
1464 b->yy_is_our_buffer = 1;
1465
1466 yy_init_buffer( b, file );
1467
1468 return b;
1469 }
1470
1471 /** Destroy the buffer.
1472 * @param b a buffer created with yy_create_buffer()
1473 *
1474 */
1475 void yy_delete_buffer (YY_BUFFER_STATE b )
1476 {
1477
1478 if ( ! b )
1479 return;
1480
1481 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1482 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1483
1484 if ( b->yy_is_our_buffer )
1485 yyfree( (void *) b->yy_ch_buf );
1486
1487 yyfree( (void *) b );
1488 }
1489
1490 /* Initializes or reinitializes a buffer.
1491 * This function is sometimes called more than once on the same buffer,
1492 * such as during a yyrestart() or at EOF.
1493 */
1494 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1495
1496 {
1497 int oerrno = errno;
1498
1499 yy_flush_buffer( b );
1500
1501 b->yy_input_file = file;
1502 b->yy_fill_buffer = 1;
1503
1504 /* If b is the current buffer, then yy_init_buffer was _probably_
1505 * called from yyrestart() or through yy_get_next_buffer.
1506 * In that case, we don't want to reset the lineno or column.
1507 */
1508 if (b != YY_CURRENT_BUFFER){
1509 b->yy_bs_lineno = 1;
1510 b->yy_bs_column = 0;
1511 }
1512
1513 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1514
1515 errno = oerrno;
1516 }
1517
1518 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1519 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1520 *
1521 */
1522 void yy_flush_buffer (YY_BUFFER_STATE b )
1523 {
1524 if ( ! b )
1525 return;
1526
1527 b->yy_n_chars = 0;
1528
1529 /* We always need two end-of-buffer characters. The first causes
1530 * a transition to the end-of-buffer state. The second causes
1531 * a jam in that state.
1532 */
1533 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1534 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1535
1536 b->yy_buf_pos = &b->yy_ch_buf[0];
1537
1538 b->yy_at_bol = 1;
1539 b->yy_buffer_status = YY_BUFFER_NEW;
1540
1541 if ( b == YY_CURRENT_BUFFER )
1542 yy_load_buffer_state( );
1543 }
1544
1545 /** Pushes the new state onto the stack. The new state becomes
1546 * the current state. This function will allocate the stack
1547 * if necessary.
1548 * @param new_buffer The new state.
1549 *
1550 */
1551 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1552 {
1553 if (new_buffer == NULL)
1554 return;
1555
1556 yyensure_buffer_stack();
1557
1558 /* This block is copied from yy_switch_to_buffer. */
1559 if ( YY_CURRENT_BUFFER )
1560 {
1561 /* Flush out information for old buffer. */
1562 *(yy_c_buf_p) = (yy_hold_char);
1563 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1564 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1565 }
1566
1567 /* Only push if top exists. Otherwise, replace top. */
1568 if (YY_CURRENT_BUFFER)
1569 (yy_buffer_stack_top)++;
1570 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1571
1572 /* copied from yy_switch_to_buffer. */
1573 yy_load_buffer_state( );
1574 (yy_did_buffer_switch_on_eof) = 1;
1575 }
1576
1577 /** Removes and deletes the top of the stack, if present.
1578 * The next element becomes the new top.
1579 *
1580 */
1581 void yypop_buffer_state (void)
1582 {
1583 if (!YY_CURRENT_BUFFER)
1584 return;
1585
1586 yy_delete_buffer(YY_CURRENT_BUFFER );
1587 YY_CURRENT_BUFFER_LVALUE = NULL;
1588 if ((yy_buffer_stack_top) > 0)
1589 --(yy_buffer_stack_top);
1590
1591 if (YY_CURRENT_BUFFER) {
1592 yy_load_buffer_state( );
1593 (yy_did_buffer_switch_on_eof) = 1;
1594 }
1595 }
1596
1597 /* Allocates the stack if it does not exist.
1598 * Guarantees space for at least one push.
1599 */
1600 static void yyensure_buffer_stack (void)
1601 {
1602 yy_size_t num_to_alloc;
1603
1604 if (!(yy_buffer_stack)) {
1605
1606 /* First allocation is just for 2 elements, since we don't know if this
1607 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1608 * immediate realloc on the next call.
1609 */
1610 num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
1611 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1612 (num_to_alloc * sizeof(struct yy_buffer_state*)
1613 );
1614 if ( ! (yy_buffer_stack) )
1615 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1616
1617 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1618
1619 (yy_buffer_stack_max) = num_to_alloc;
1620 (yy_buffer_stack_top) = 0;
1621 return;
1622 }
1623
1624 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1625
1626 /* Increase the buffer to prepare for a possible push. */
1627 yy_size_t grow_size = 8 /* arbitrary grow size */;
1628
1629 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1630 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1631 ((yy_buffer_stack),
1632 num_to_alloc * sizeof(struct yy_buffer_state*)
1633 );
1634 if ( ! (yy_buffer_stack) )
1635 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1636
1637 /* zero only the new slots.*/
1638 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1639 (yy_buffer_stack_max) = num_to_alloc;
1640 }
1641 }
1642
1643 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1644 * @param base the character buffer
1645 * @param size the size in bytes of the character buffer
1646 *
1647 * @return the newly allocated buffer state object.
1648 */
1649 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1650 {
1651 YY_BUFFER_STATE b;
1652
1653 if ( size < 2 ||
1654 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1655 base[size-1] != YY_END_OF_BUFFER_CHAR )
1656 /* They forgot to leave room for the EOB's. */
1657 return NULL;
1658
1659 b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) );
1660 if ( ! b )
1661 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1662
1663 b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
1664 b->yy_buf_pos = b->yy_ch_buf = base;
1665 b->yy_is_our_buffer = 0;
1666 b->yy_input_file = NULL;
1667 b->yy_n_chars = b->yy_buf_size;
1668 b->yy_is_interactive = 0;
1669 b->yy_at_bol = 1;
1670 b->yy_fill_buffer = 0;
1671 b->yy_buffer_status = YY_BUFFER_NEW;
1672
1673 yy_switch_to_buffer( b );
1674
1675 return b;
1676 }
1677
1678 /** Setup the input buffer state to scan a string. The next call to yylex() will
1679 * scan from a @e copy of @a str.
1680 * @param yystr a NUL-terminated string to scan
1681 *
1682 * @return the newly allocated buffer state object.
1683 * @note If you want to scan bytes that may contain NUL values, then use
1684 * yy_scan_bytes() instead.
1685 */
1686 YY_BUFFER_STATE yy_scan_string (const char * yystr )
1687 {
1688
1689 return yy_scan_bytes( yystr, (int) strlen(yystr) );
1690 }
1691
1692 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1693 * scan from a @e copy of @a bytes.
1694 * @param yybytes the byte buffer to scan
1695 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1696 *
1697 * @return the newly allocated buffer state object.
1698 */
1699 YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len )
1700 {
1701 YY_BUFFER_STATE b;
1702 char *buf;
1703 yy_size_t n;
1704 int i;
1705
1706 /* Get memory for full buffer, including space for trailing EOB's. */
1707 n = (yy_size_t) (_yybytes_len + 2);
1708 buf = (char *) yyalloc( n );
1709 if ( ! buf )
1710 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1711
1712 for ( i = 0; i < _yybytes_len; ++i )
1713 buf[i] = yybytes[i];
1714
1715 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1716
1717 b = yy_scan_buffer( buf, n );
1718 if ( ! b )
1719 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1720
1721 /* It's okay to grow etc. this buffer, and we should throw it
1722 * away when we're done.
1723 */
1724 b->yy_is_our_buffer = 1;
1725
1726 return b;
1727 }
1728
1729 #ifndef YY_EXIT_FAILURE
1730 #define YY_EXIT_FAILURE 2
1731 #endif
1732
1733 static void yynoreturn yy_fatal_error (const char* msg )
1734 {
1735 fprintf( stderr, "%s\n", msg );
1736 exit( YY_EXIT_FAILURE );
1737 }
1738
1739 /* Redefine yyless() so it works in section 3 code. */
1740
1741 #undef yyless
1742 #define yyless(n) \
1743 do \
1744 { \
1745 /* Undo effects of setting up yytext. */ \
1746 int yyless_macro_arg = (n); \
1747 YY_LESS_LINENO(yyless_macro_arg);\
1748 yytext[yyleng] = (yy_hold_char); \
1749 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1750 (yy_hold_char) = *(yy_c_buf_p); \
1751 *(yy_c_buf_p) = '\0'; \
1752 yyleng = yyless_macro_arg; \
1753 } \
1754 while ( 0 )
1755
1756 /* Accessor methods (get/set functions) to struct members. */
1757
1758 /** Get the current line number.
1759 *
1760 */
1761 int yyget_lineno (void)
1762 {
1763
1764 return yylineno;
1765 }
1766
1767 /** Get the input stream.
1768 *
1769 */
1770 FILE *yyget_in (void)
1771 {
1772 return yyin;
1773 }
1774
1775 /** Get the output stream.
1776 *
1777 */
1778 FILE *yyget_out (void)
1779 {
1780 return yyout;
1781 }
1782
1783 /** Get the length of the current token.
1784 *
1785 */
1786 int yyget_leng (void)
1787 {
1788 return yyleng;
1789 }
1790
1791 /** Get the current token.
1792 *
1793 */
1794
1795 char *yyget_text (void)
1796 {
1797 return yytext;
1798 }
1799
1800 /** Set the current line number.
1801 * @param _line_number line number
1802 *
1803 */
1804 void yyset_lineno (int _line_number )
1805 {
1806
1807 yylineno = _line_number;
1808 }
1809
1810 /** Set the input stream. This does not discard the current
1811 * input buffer.
1812 * @param _in_str A readable stream.
1813 *
1814 * @see yy_switch_to_buffer
1815 */
1816 void yyset_in (FILE * _in_str )
1817 {
1818 yyin = _in_str ;
1819 }
1820
1821 void yyset_out (FILE * _out_str )
1822 {
1823 yyout = _out_str ;
1824 }
1825
1826 int yyget_debug (void)
1827 {
1828 return yy_flex_debug;
1829 }
1830
1831 void yyset_debug (int _bdebug )
1832 {
1833 yy_flex_debug = _bdebug ;
1834 }
1835
1836 static int yy_init_globals (void)
1837 {
1838 /* Initialization is the same as for the non-reentrant scanner.
1839 * This function is called from yylex_destroy(), so don't allocate here.
1840 */
1841
1842 (yy_buffer_stack) = NULL;
1843 (yy_buffer_stack_top) = 0;
1844 (yy_buffer_stack_max) = 0;
1845 (yy_c_buf_p) = NULL;
1846 (yy_init) = 0;
1847 (yy_start) = 0;
1848
1849 /* Defined in main.c */
1850 #ifdef YY_STDINIT
1851 yyin = stdin;
1852 yyout = stdout;
1853 #else
1854 yyin = NULL;
1855 yyout = NULL;
1856 #endif
1857
1858 /* For future reference: Set errno on error, since we are called by
1859 * yylex_init()
1860 */
1861 return 0;
1862 }
1863
1864 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
1865 int yylex_destroy (void)
1866 {
1867
1868 /* Pop the buffer stack, destroying each element. */
1869 while(YY_CURRENT_BUFFER){
1870 yy_delete_buffer( YY_CURRENT_BUFFER );
1871 YY_CURRENT_BUFFER_LVALUE = NULL;
1872 yypop_buffer_state();
1873 }
1874
1875 /* Destroy the stack itself. */
1876 yyfree((yy_buffer_stack) );
1877 (yy_buffer_stack) = NULL;
1878
1879 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1880 * yylex() is called, initialization will occur. */
1881 yy_init_globals( );
1882
1883 return 0;
1884 }
1885
1886 /*
1887 * Internal utility routines.
1888 */
1889
1890 #ifndef yytext_ptr
1891 static void yy_flex_strncpy (char* s1, const char * s2, int n )
1892 {
1893
1894 int i;
1895 for ( i = 0; i < n; ++i )
1896 s1[i] = s2[i];
1897 }
1898 #endif
1899
1900 #ifdef YY_NEED_STRLEN
1901 static int yy_flex_strlen (const char * s )
1902 {
1903 int n;
1904 for ( n = 0; s[n]; ++n )
1905 ;
1906
1907 return n;
1908 }
1909 #endif
1910
1911 void *yyalloc (yy_size_t size )
1912 {
1913 return malloc(size);
1914 }
1915
1916 void *yyrealloc (void * ptr, yy_size_t size )
1917 {
1918
1919 /* The cast to (char *) in the following accommodates both
1920 * implementations that use char* generic pointers, and those
1921 * that use void* generic pointers. It works with the latter
1922 * because both ANSI C and C++ allow castless assignment from
1923 * any pointer type to void*, and deal with argument conversions
1924 * as though doing an assignment.
1925 */
1926 return realloc(ptr, size);
1927 }
1928
1929 void yyfree (void * ptr )
1930 {
1931 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
1932 }
1933
1934 #define YYTABLES_NAME "yytables"
1935
1936 #line 97 "adv.flex"
1937
1938
1939 /*
1940 * consumeLine - reads a line into a buffer, it then pushes back the whole
1941 * line except the initial \n.
1942 */
1943
1944 static void consumeLine (void)
1945 {
1946 if (currentLine->linelen<yyleng) {
1947 currentLine->linebuf = (char *)realloc (currentLine->linebuf, yyleng);
1948 currentLine->linelen = yyleng;
1949 }
1950 strcpy(currentLine->linebuf, yytext+1); /* copy all except the initial \n */
1951 lineno++;
1952 currentLine->actualline = lineno;
1953 currentLine->tokenpos=0;
1954 currentLine->nextpos=0;
1955 yyless(1); /* push back all but the \n */
1956 }
1957
1958 /*
1959 * updatepos - updates the current token position.
1960 * Should be used when a rule matches a token.
1961 */
1962
1963 static void updatepos (void)
1964 {
1965 currentLine->nextpos = currentLine->tokenpos+yyleng;
1966 currentLine->toklen = yyleng;
1967 }
1968
1969 /*
1970 * skippos - skips over this token. This function should be called
1971 * if we are not returning and thus not calling getToken.
1972 */
1973
1974 static void skippos (void)
1975 {
1976 currentLine->tokenpos = currentLine->nextpos;
1977 }
1978
1979 /*
1980 * initLine - initializes a currentLine
1981 */
1982
1983 static void initLine (void)
1984 {
1985 currentLine = (struct lineInfo *)malloc (sizeof(struct lineInfo));
1986
1987 if (currentLine == NULL)
1988 perror("malloc");
1989 currentLine->linebuf = NULL;
1990 currentLine->linelen = 0;
1991 currentLine->tokenpos = 0;
1992 currentLine->toklen = 0;
1993 currentLine->nextpos = 0;
1994 currentLine->actualline = lineno;
1995 }
1996
1997 /*
1998 * resetpos - resets the position of the next token to the start of the line.
1999 */
2000
2001 static void resetpos (void)
2002 {
2003 if (currentLine != NULL)
2004 currentLine->nextpos = 0;
2005 }
2006
2007 /*
2008 * advflex_GetToken - returns a new token.
2009 */
2010
2011 char *advflex_GetToken (void)
2012 {
2013 if (currentLine == NULL)
2014 initLine();
2015 currentLine->tokenpos = currentLine->nextpos;
2016 yylex();
2017 }
2018
2019 void advflex_error (const char *s)
2020 {
2021 if (currentLine != NULL) {
2022 printf("%s:%d:%s\n", filename, currentLine->actualline, s);
2023 printf("%s\n", currentLine->linebuf);
2024 # if 0
2025 printf("%*s%*s\n", currentLine->nextpos, " ", currentLine->toklen, "^");
2026 # endif
2027 }
2028 }
2029
2030 /*
2031 * OpenSource - returns TRUE if file, s, can be opened and
2032 * all tokens are taken from this file.
2033 */
2034
2035 int advflex_OpenSource (char *s)
2036 {
2037 FILE *f = fopen(s, "r");
2038
2039 if (f == NULL)
2040 return FALSE;
2041 else {
2042 yy_delete_buffer(YY_CURRENT_BUFFER);
2043 yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
2044 filename = strdup(s);
2045 lineno =1;
2046 if (currentLine != NULL)
2047 currentLine->actualline = lineno;
2048 return TRUE;
2049 }
2050 }
2051
2052 /*
2053 * CloseSource - provided for semantic sugar
2054 */
2055
2056 void advflex_CloseSource (void)
2057 {
2058 }
2059
2060 /*
2061 * advflex_GetLineNo - returns the current line number.
2062 */
2063
2064 int advflex_GetLineNo (void)
2065 {
2066 if (currentLine != NULL)
2067 return currentLine->actualline;
2068 else
2069 return 0;
2070 }
2071
2072 /*
2073 * yywrap is called when end of file is seen. We push an eof token
2074 * and tell the lexical analysis to stop.
2075 */
2076
2077 int yywrap (void)
2078 {
2079 updatepos(); return 1;
2080 }
2081
2082 void _M2_advflex_init (int, char *, char *)
2083 {
2084 }
2085
2086 void _M2_advflex_finish (int, char *, char *)
2087 {
2088 }
2089
2090 void _M2_advflex_ctor (void)
2091 {
2092 }
2093
2094 #if 0
2095 main () {
2096 char *s;
2097
2098 if (advflex_OpenSource("../maps/glover")) {
2099 s = (char *)advflex_GetToken();
2100 while (s != NULL) {
2101 advflex_error(s);
2102 s = (char *)advflex_GetToken();
2103 }
2104 }
2105 }
2106 #endif
2107