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