1 #line 2 "scanner.cpp"
2
3 #line 4 "scanner.cpp"
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 5
12 #define YY_FLEX_SUBMINOR_VERSION 37
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 #endif /* ! C99 */
88
89 #endif /* ! FLEXINT_H */
90
91 #ifdef __cplusplus
92
93 /* The "const" storage-class-modifier is valid. */
94 #define YY_USE_CONST
95
96 #else /* ! __cplusplus */
97
98 /* C99 requires __STDC__ to be defined as 1. */
99 #if defined (__STDC__)
100
101 #define YY_USE_CONST
102
103 #endif /* defined (__STDC__) */
104 #endif /* ! __cplusplus */
105
106 #ifdef YY_USE_CONST
107 #define yyconst const
108 #else
109 #define yyconst
110 #endif
111
112 /* Returned upon end-of-file. */
113 #define YY_NULL 0
114
115 /* Promotes a possibly negative, possibly signed char to an unsigned
116 * integer for use as an array index. If the signed char is negative,
117 * we want to instead treat it as an 8-bit unsigned char, hence the
118 * double cast.
119 */
120 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
121
122 /* Enter a start condition. This macro really ought to take a parameter,
123 * but we do it the disgusting crufty way forced on us by the ()-less
124 * definition of BEGIN.
125 */
126 #define BEGIN (yy_start) = 1 + 2 *
127
128 /* Translate the current start state into a value that can be later handed
129 * to BEGIN to return to the state. The YYSTATE alias is for lex
130 * compatibility.
131 */
132 #define YY_START (((yy_start) - 1) / 2)
133 #define YYSTATE YY_START
134
135 /* Action number for EOF rule of a given start state. */
136 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
137
138 /* Special action meaning "start processing a new file". */
139 #define YY_NEW_FILE yyrestart(yyin )
140
141 #define YY_END_OF_BUFFER_CHAR 0
142
143 /* Size of default input buffer. */
144 #ifndef YY_BUF_SIZE
145 #define YY_BUF_SIZE 16384
146 #endif
147
148 /* The state buf must be large enough to hold one state per character in the main buffer.
149 */
150 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
151
152 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
153 #define YY_TYPEDEF_YY_BUFFER_STATE
154 typedef struct yy_buffer_state *YY_BUFFER_STATE;
155 #endif
156
157 #ifndef YY_TYPEDEF_YY_SIZE_T
158 #define YY_TYPEDEF_YY_SIZE_T
159 typedef size_t yy_size_t;
160 #endif
161
162 extern yy_size_t yyleng;
163
164 extern FILE *yyin, *yyout;
165
166 #define EOB_ACT_CONTINUE_SCAN 0
167 #define EOB_ACT_END_OF_FILE 1
168 #define EOB_ACT_LAST_MATCH 2
169
170 #define YY_LESS_LINENO(n)
171
172 /* Return all but the first "n" matched characters back to the input stream. */
173 #define yyless(n) \
174 do \
175 { \
176 /* Undo effects of setting up yytext. */ \
177 int yyless_macro_arg = (n); \
178 YY_LESS_LINENO(yyless_macro_arg);\
179 *yy_cp = (yy_hold_char); \
180 YY_RESTORE_YY_MORE_OFFSET \
181 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
182 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
183 } \
184 while ( 0 )
185
186 #define unput(c) yyunput( c, (yytext_ptr) )
187
188 #ifndef YY_STRUCT_YY_BUFFER_STATE
189 #define YY_STRUCT_YY_BUFFER_STATE
190 struct yy_buffer_state
191 {
192 FILE *yy_input_file;
193
194 char *yy_ch_buf; /* input buffer */
195 char *yy_buf_pos; /* current position in input buffer */
196
197 /* Size of input buffer in bytes, not including room for EOB
198 * characters.
199 */
200 yy_size_t yy_buf_size;
201
202 /* Number of characters read into yy_ch_buf, not including EOB
203 * characters.
204 */
205 yy_size_t yy_n_chars;
206
207 /* Whether we "own" the buffer - i.e., we know we created it,
208 * and can realloc() it to grow it, and should free() it to
209 * delete it.
210 */
211 int yy_is_our_buffer;
212
213 /* Whether this is an "interactive" input source; if so, and
214 * if we're using stdio for input, then we want to use getc()
215 * instead of fread(), to make sure we stop fetching input after
216 * each newline.
217 */
218 int yy_is_interactive;
219
220 /* Whether we're considered to be at the beginning of a line.
221 * If so, '^' rules will be active on the next match, otherwise
222 * not.
223 */
224 int yy_at_bol;
225
226 int yy_bs_lineno; /**< The line count. */
227 int yy_bs_column; /**< The column count. */
228
229 /* Whether to try to fill the input buffer when we reach the
230 * end of it.
231 */
232 int yy_fill_buffer;
233
234 int yy_buffer_status;
235
236 #define YY_BUFFER_NEW 0
237 #define YY_BUFFER_NORMAL 1
238 /* When an EOF's been seen but there's still some text to process
239 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
240 * shouldn't try reading from the input source any more. We might
241 * still have a bunch of tokens to match, though, because of
242 * possible backing-up.
243 *
244 * When we actually see the EOF, we change the status to "new"
245 * (via yyrestart()), so that the user can continue scanning by
246 * just pointing yyin at a new input file.
247 */
248 #define YY_BUFFER_EOF_PENDING 2
249
250 };
251 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
252
253 /* Stack of input buffers. */
254 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
255 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
256 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
257
258 /* We provide macros for accessing buffer states in case in the
259 * future we want to put the buffer states in a more general
260 * "scanner state".
261 *
262 * Returns the top of the stack, or NULL.
263 */
264 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
265 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
266 : NULL)
267
268 /* Same as previous macro, but useful when we know that the buffer stack is not
269 * NULL or when we need an lvalue. For internal use only.
270 */
271 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
272
273 /* yy_hold_char holds the character lost when yytext is formed. */
274 static char yy_hold_char;
275 static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
276 yy_size_t yyleng;
277
278 /* Points to current character in buffer. */
279 static char *yy_c_buf_p = (char *) 0;
280 static int yy_init = 0; /* whether we need to initialize */
281 static int yy_start = 0; /* start state number */
282
283 /* Flag which is used to allow yywrap()'s to do buffer switches
284 * instead of setting up a fresh yyin. A bit of a hack ...
285 */
286 static int yy_did_buffer_switch_on_eof;
287
288 void yyrestart (FILE *input_file );
289 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
290 YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
291 void yy_delete_buffer (YY_BUFFER_STATE b );
292 void yy_flush_buffer (YY_BUFFER_STATE b );
293 void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
294 void yypop_buffer_state (void );
295
296 static void yyensure_buffer_stack (void );
297 static void yy_load_buffer_state (void );
298 static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
299
300 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
301
302 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
303 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
304 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
305
306 void *yyalloc (yy_size_t );
307 void *yyrealloc (void *,yy_size_t );
308 void yyfree (void * );
309
310 #define yy_new_buffer yy_create_buffer
311
312 #define yy_set_interactive(is_interactive) \
313 { \
314 if ( ! YY_CURRENT_BUFFER ){ \
315 yyensure_buffer_stack (); \
316 YY_CURRENT_BUFFER_LVALUE = \
317 yy_create_buffer(yyin,YY_BUF_SIZE ); \
318 } \
319 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
320 }
321
322 #define yy_set_bol(at_bol) \
323 { \
324 if ( ! YY_CURRENT_BUFFER ){\
325 yyensure_buffer_stack (); \
326 YY_CURRENT_BUFFER_LVALUE = \
327 yy_create_buffer(yyin,YY_BUF_SIZE ); \
328 } \
329 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
330 }
331
332 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
333
334 /* Begin user sect3 */
335
336 #define yywrap() 1
337 #define YY_SKIP_YYWRAP
338
339 typedef unsigned char YY_CHAR;
340
341 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
342
343 typedef int yy_state_type;
344
345 extern int yylineno;
346
347 int yylineno = 1;
348
349 extern char *yytext;
350 #define yytext_ptr yytext
351
352 static yy_state_type yy_get_previous_state (void );
353 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
354 static int yy_get_next_buffer (void );
355 static void yy_fatal_error (yyconst char msg[] );
356
357 /* Done after the current pattern has been matched and before the
358 * corresponding action - sets up yytext.
359 */
360 #define YY_DO_BEFORE_ACTION \
361 (yytext_ptr) = yy_bp; \
362 yyleng = (size_t) (yy_cp - yy_bp); \
363 (yy_hold_char) = *yy_cp; \
364 *yy_cp = '\0'; \
365 (yy_c_buf_p) = yy_cp;
366
367 #define YY_NUM_RULES 25
368 #define YY_END_OF_BUFFER 26
369 /* This struct is not used in this scanner,
370 but its presence is necessary. */
371 struct yy_trans_info
372 {
373 flex_int32_t yy_verify;
374 flex_int32_t yy_nxt;
375 };
376 static yyconst flex_int16_t yy_accept[68] =
377 { 0,
378 0, 0, 0, 0, 0, 0, 26, 24, 22, 23,
379 21, 15, 24, 13, 14, 4, 3, 24, 24, 24,
380 24, 24, 24, 24, 1, 2, 17, 25, 16, 20,
381 19, 18, 14, 0, 0, 0, 0, 0, 0, 0,
382 0, 0, 0, 0, 0, 0, 0, 7, 0, 10,
383 0, 0, 6, 0, 0, 0, 0, 12, 0, 0,
384 8, 9, 0, 5, 0, 11, 0
385 } ;
386
387 static yyconst flex_int32_t yy_ec[256] =
388 { 0,
389 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
390 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
391 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
392 1, 4, 1, 5, 1, 1, 1, 1, 1, 1,
393 1, 1, 1, 1, 1, 1, 6, 7, 8, 8,
394 8, 8, 8, 8, 8, 8, 8, 1, 9, 1,
395 10, 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, 11, 12, 13, 14,
399
400 15, 16, 17, 18, 19, 1, 1, 20, 1, 1,
401 21, 22, 1, 23, 24, 25, 26, 1, 27, 1,
402 28, 1, 29, 1, 30, 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, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
415 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
416 1, 1, 1, 1, 1
417 } ;
418
419 static yyconst flex_int32_t yy_meta[31] =
420 { 0,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
424 } ;
425
426 static yyconst flex_int16_t yy_base[70] =
427 { 0,
428 0, 0, 28, 29, 74, 73, 75, 78, 78, 78,
429 78, 78, 68, 78, 28, 78, 78, 62, 57, 26,
430 56, 48, 48, 49, 78, 78, 78, 78, 78, 78,
431 78, 78, 31, 43, 47, 37, 48, 50, 39, 39,
432 46, 44, 41, 42, 31, 34, 35, 78, 28, 78,
433 34, 28, 78, 30, 24, 30, 22, 78, 25, 30,
434 78, 78, 18, 78, 20, 78, 78, 41, 39
435 } ;
436
437 static yyconst flex_int16_t yy_def[70] =
438 { 0,
439 67, 1, 68, 68, 69, 69, 67, 67, 67, 67,
440 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
441 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
442 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
443 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
444 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
445 67, 67, 67, 67, 67, 67, 0, 67, 67
446 } ;
447
448 static yyconst flex_int16_t yy_nxt[109] =
449 { 0,
450 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
451 8, 18, 8, 8, 8, 8, 8, 19, 8, 20,
452 8, 8, 21, 22, 23, 8, 24, 8, 25, 26,
453 28, 28, 29, 29, 33, 33, 36, 33, 33, 30,
454 37, 27, 66, 65, 64, 63, 62, 61, 60, 59,
455 58, 57, 56, 55, 54, 53, 52, 51, 50, 49,
456 48, 47, 46, 45, 44, 43, 42, 41, 40, 39,
457 38, 35, 34, 32, 67, 31, 31, 7, 67, 67,
458 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
459 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
460
461 67, 67, 67, 67, 67, 67, 67, 67
462 } ;
463
464 static yyconst flex_int16_t yy_chk[109] =
465 { 0,
466 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
467 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
468 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
469 3, 4, 3, 4, 15, 15, 20, 33, 33, 69,
470 20, 68, 65, 63, 60, 59, 57, 56, 55, 54,
471 52, 51, 49, 47, 46, 45, 44, 43, 42, 41,
472 40, 39, 38, 37, 36, 35, 34, 24, 23, 22,
473 21, 19, 18, 13, 7, 6, 5, 67, 67, 67,
474 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
475 67, 67, 67, 67, 67, 67, 67, 67, 67, 67,
476
477 67, 67, 67, 67, 67, 67, 67, 67
478 } ;
479
480 static yy_state_type yy_last_accepting_state;
481 static char *yy_last_accepting_cpos;
482
483 extern int yy_flex_debug;
484 int yy_flex_debug = 0;
485
486 /* The intent behind this definition is that it'll catch
487 * any uses of REJECT which flex missed.
488 */
489 #define REJECT reject_used_but_not_detected
490 #define yymore() yymore_used_but_not_detected
491 #define YY_MORE_ADJ 0
492 #define YY_RESTORE_YY_MORE_OFFSET
493 char *yytext;
494 #line 1 "scanner.l"
495 /*
496 Copyright (c) 2013 Albert "Alberth" Hofkamp
497
498 Permission is hereby granted, free of charge, to any person obtaining a copy of
499 this software and associated documentation files (the "Software"), to deal in
500 the Software without restriction, including without limitation the rights to
501 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
502 of the Software, and to permit persons to whom the Software is furnished to do
503 so, subject to the following conditions:
504
505 The above copyright notice and this permission notice shall be included in all
506 copies or substantial portions of the Software.
507
508 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
509 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
510 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
511 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
512 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
513 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
514 SOFTWARE.
515 */
516 #line 24 "scanner.l"
517 #include <cstdio>
518 #include <string>
519 #include "ast.h"
520 #include "tokens.h"
521
522 int line = 1;
523 std::string filename;
524
525
526 #line 527 "scanner.cpp"
527
528 #define INITIAL 0
529 #define IN_STRING 1
530 #define IN_COMMENT 2
531
532 #ifndef YY_NO_UNISTD_H
533 /* Special case for "unistd.h", since it is non-ANSI. We include it way
534 * down here because we want the user's section 1 to have been scanned first.
535 * The user has a chance to override it with an option.
536 */
537 #include <unistd.h>
538 #endif
539
540 #ifndef YY_EXTRA_TYPE
541 #define YY_EXTRA_TYPE void *
542 #endif
543
544 static int yy_init_globals (void );
545
546 /* Accessor methods to globals.
547 These are made visible to non-reentrant scanners for convenience. */
548
549 int yylex_destroy (void );
550
551 int yyget_debug (void );
552
553 void yyset_debug (int debug_flag );
554
555 YY_EXTRA_TYPE yyget_extra (void );
556
557 void yyset_extra (YY_EXTRA_TYPE user_defined );
558
559 FILE *yyget_in (void );
560
561 void yyset_in (FILE * in_str );
562
563 FILE *yyget_out (void );
564
565 void yyset_out (FILE * out_str );
566
567 yy_size_t yyget_leng (void );
568
569 char *yyget_text (void );
570
571 int yyget_lineno (void );
572
573 void yyset_lineno (int line_number );
574
575 /* Macros after this point can all be overridden by user definitions in
576 * section 1.
577 */
578
579 #ifndef YY_SKIP_YYWRAP
580 #ifdef __cplusplus
581 extern "C" int yywrap (void );
582 #else
583 extern int yywrap (void );
584 #endif
585 #endif
586
587 static void yyunput (int c,char *buf_ptr );
588
589 #ifndef yytext_ptr
590 static void yy_flex_strncpy (char *,yyconst char *,int );
591 #endif
592
593 #ifdef YY_NEED_STRLEN
594 static int yy_flex_strlen (yyconst char * );
595 #endif
596
597 #ifndef YY_NO_INPUT
598
599 #ifdef __cplusplus
600 static int yyinput (void );
601 #else
602 static int input (void );
603 #endif
604
605 #endif
606
607 /* Amount of stuff to slurp up with each read. */
608 #ifndef YY_READ_BUF_SIZE
609 #define YY_READ_BUF_SIZE 8192
610 #endif
611
612 /* Copy whatever the last rule matched to the standard output. */
613 #ifndef ECHO
614 /* This used to be an fputs(), but since the string might contain NUL's,
615 * we now use fwrite().
616 */
617 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
618 #endif
619
620 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
621 * is returned in "result".
622 */
623 #ifndef YY_INPUT
624 #define YY_INPUT(buf,result,max_size) \
625 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
626 { \
627 int c = '*'; \
628 size_t n; \
629 for ( n = 0; n < max_size && \
630 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
631 buf[n] = (char) c; \
632 if ( c == '\n' ) \
633 buf[n++] = (char) c; \
634 if ( c == EOF && ferror( yyin ) ) \
635 YY_FATAL_ERROR( "input in flex scanner failed" ); \
636 result = n; \
637 } \
638 else \
639 { \
640 errno=0; \
641 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
642 { \
643 if( errno != EINTR) \
644 { \
645 YY_FATAL_ERROR( "input in flex scanner failed" ); \
646 break; \
647 } \
648 errno=0; \
649 clearerr(yyin); \
650 } \
651 }\
652 \
653
654 #endif
655
656 /* No semi-colon after return; correct usage is to write "yyterminate();" -
657 * we don't want an extra ';' after the "return" because that will cause
658 * some compilers to complain about unreachable statements.
659 */
660 #ifndef yyterminate
661 #define yyterminate() return YY_NULL
662 #endif
663
664 /* Number of entries by which start-condition stack grows. */
665 #ifndef YY_START_STACK_INCR
666 #define YY_START_STACK_INCR 25
667 #endif
668
669 /* Report a fatal error. */
670 #ifndef YY_FATAL_ERROR
671 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
672 #endif
673
674 /* end tables serialization structures and prototypes */
675
676 /* Default declaration of generated scanner - a define so the user can
677 * easily add parameters.
678 */
679 #ifndef YY_DECL
680 #define YY_DECL_IS_OURS 1
681
682 extern int yylex (void);
683
684 #define YY_DECL int yylex (void)
685 #endif /* !YY_DECL */
686
687 /* Code executed at the beginning of each rule, after yytext and yyleng
688 * have been set up.
689 */
690 #ifndef YY_USER_ACTION
691 #define YY_USER_ACTION
692 #endif
693
694 /* Code executed at the end of each rule. */
695 #ifndef YY_BREAK
696 #define YY_BREAK break;
697 #endif
698
699 #define YY_RULE_SETUP \
700 YY_USER_ACTION
701
702 /** The main scanner function which does all the work.
703 */
704 YY_DECL
705 {
706 register yy_state_type yy_current_state;
707 register char *yy_cp, *yy_bp;
708 register int yy_act;
709
710 #line 38 "scanner.l"
711
712
713 #line 714 "scanner.cpp"
714
715 if ( !(yy_init) )
716 {
717 (yy_init) = 1;
718
719 #ifdef YY_USER_INIT
720 YY_USER_INIT;
721 #endif
722
723 if ( ! (yy_start) )
724 (yy_start) = 1; /* first start state */
725
726 if ( ! yyin )
727 yyin = stdin;
728
729 if ( ! yyout )
730 yyout = stdout;
731
732 if ( ! YY_CURRENT_BUFFER ) {
733 yyensure_buffer_stack ();
734 YY_CURRENT_BUFFER_LVALUE =
735 yy_create_buffer(yyin,YY_BUF_SIZE );
736 }
737
738 yy_load_buffer_state( );
739 }
740
741 while ( 1 ) /* loops until end-of-file is reached */
742 {
743 yy_cp = (yy_c_buf_p);
744
745 /* Support of yytext. */
746 *yy_cp = (yy_hold_char);
747
748 /* yy_bp points to the position in yy_ch_buf of the start of
749 * the current run.
750 */
751 yy_bp = yy_cp;
752
753 yy_current_state = (yy_start);
754 yy_match:
755 do
756 {
757 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
758 if ( yy_accept[yy_current_state] )
759 {
760 (yy_last_accepting_state) = yy_current_state;
761 (yy_last_accepting_cpos) = yy_cp;
762 }
763 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
764 {
765 yy_current_state = (int) yy_def[yy_current_state];
766 if ( yy_current_state >= 68 )
767 yy_c = yy_meta[(unsigned int) yy_c];
768 }
769 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
770 ++yy_cp;
771 }
772 while ( yy_base[yy_current_state] != 78 );
773
774 yy_find_action:
775 yy_act = yy_accept[yy_current_state];
776 if ( yy_act == 0 )
777 { /* have to back up */
778 yy_cp = (yy_last_accepting_cpos);
779 yy_current_state = (yy_last_accepting_state);
780 yy_act = yy_accept[yy_current_state];
781 }
782
783 YY_DO_BEFORE_ACTION;
784
785 do_action: /* This label is used only to access EOF actions. */
786
787 switch ( yy_act )
788 { /* beginning of action switch */
789 case 0: /* must back up */
790 /* undo the effects of YY_DO_BEFORE_ACTION */
791 *yy_cp = (yy_hold_char);
792 yy_cp = (yy_last_accepting_cpos);
793 yy_current_state = (yy_last_accepting_state);
794 goto yy_find_action;
795
796 case 1:
797 YY_RULE_SETUP
798 #line 40 "scanner.l"
799 { yylval.line = line; return CURLY_OPEN; }
800 YY_BREAK
801 case 2:
802 YY_RULE_SETUP
803 #line 41 "scanner.l"
804 { yylval.line = line; return CURLY_CLOSE; }
805 YY_BREAK
806 case 3:
807 YY_RULE_SETUP
808 #line 42 "scanner.l"
809 { yylval.line = line; return EQUAL; }
810 YY_BREAK
811 case 4:
812 YY_RULE_SETUP
813 #line 43 "scanner.l"
814 { yylval.line = line; return SEMICOL; }
815 YY_BREAK
816 case 5:
817 YY_RULE_SETUP
818 #line 45 "scanner.l"
819 { yylval.line = line; return SPRITEKW; }
820 YY_BREAK
821 case 6:
822 YY_RULE_SETUP
823 #line 46 "scanner.l"
824 { yylval.line = line; return LEFTKW; }
825 YY_BREAK
826 case 7:
827 YY_RULE_SETUP
828 #line 47 "scanner.l"
829 { yylval.line = line; return TOPKW; }
830 YY_BREAK
831 case 8:
832 YY_RULE_SETUP
833 #line 48 "scanner.l"
834 { yylval.line = line; return WIDTHKW; }
835 YY_BREAK
836 case 9:
837 YY_RULE_SETUP
838 #line 49 "scanner.l"
839 { yylval.line = line; return HEIGHTKW; }
840 YY_BREAK
841 case 10:
842 YY_RULE_SETUP
843 #line 50 "scanner.l"
844 { yylval.line = line; return BASEIMGKW; }
845 YY_BREAK
846 case 11:
847 YY_RULE_SETUP
848 #line 51 "scanner.l"
849 { yylval.line = line; return RECOLOURKW; }
850 YY_BREAK
851 case 12:
852 YY_RULE_SETUP
853 #line 52 "scanner.l"
854 { yylval.line = line; return LAYERKW; }
855 YY_BREAK
856 case 13:
857 YY_RULE_SETUP
858 #line 54 "scanner.l"
859 { yylval.line = line;
860 yylval.number = 0;
861 return NUMBER; }
862 YY_BREAK
863 case 14:
864 YY_RULE_SETUP
865 #line 58 "scanner.l"
866 { yylval.line = line;
867 yylval.number = atoi(yytext);
868 return NUMBER; }
869 YY_BREAK
870 case 15:
871 YY_RULE_SETUP
872 #line 62 "scanner.l"
873 { yylval.text = "";
874 yylval.line = line;
875 BEGIN(IN_STRING); }
876 YY_BREAK
877 case 16:
878 YY_RULE_SETUP
879 #line 66 "scanner.l"
880 { BEGIN(INITIAL);
881 return STRING; }
882 YY_BREAK
883 case 17:
884 YY_RULE_SETUP
885 #line 69 "scanner.l"
886 { yylval.text += yytext; }
887 YY_BREAK
888 case 18:
889 YY_RULE_SETUP
890 #line 71 "scanner.l"
891 { BEGIN(IN_COMMENT); }
892 YY_BREAK
893 case 19:
894 /* rule 19 can match eol */
895 YY_RULE_SETUP
896 #line 73 "scanner.l"
897 { BEGIN(INITIAL);
898 line++; }
899 YY_BREAK
900 case 20:
901 YY_RULE_SETUP
902 #line 76 "scanner.l"
903 { }
904 YY_BREAK
905 case 21:
906 YY_RULE_SETUP
907 #line 78 "scanner.l"
908 { }
909 YY_BREAK
910 case 22:
911 YY_RULE_SETUP
912 #line 80 "scanner.l"
913 { }
914 YY_BREAK
915 case 23:
916 /* rule 23 can match eol */
917 YY_RULE_SETUP
918 #line 82 "scanner.l"
919 { line++; }
920 YY_BREAK
921 case 24:
922 YY_RULE_SETUP
923 #line 84 "scanner.l"
924 { fprintf(stderr, "Unrecognized character encountered at line %d\n", line);
925 exit(1); }
926 YY_BREAK
927 case YY_STATE_EOF(IN_COMMENT):
928 #line 87 "scanner.l"
929 { BEGIN(INITIAL); }
930 YY_BREAK
931 case YY_STATE_EOF(IN_STRING):
932 #line 88 "scanner.l"
933 { BEGIN(INITIAL); }
934 YY_BREAK
935 case 25:
936 YY_RULE_SETUP
937 #line 90 "scanner.l"
938 ECHO;
939 YY_BREAK
940 #line 941 "scanner.cpp"
941 case YY_STATE_EOF(INITIAL):
942 yyterminate();
943
944 case YY_END_OF_BUFFER:
945 {
946 /* Amount of text matched not including the EOB char. */
947 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
948
949 /* Undo the effects of YY_DO_BEFORE_ACTION. */
950 *yy_cp = (yy_hold_char);
951 YY_RESTORE_YY_MORE_OFFSET
952
953 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
954 {
955 /* We're scanning a new file or input source. It's
956 * possible that this happened because the user
957 * just pointed yyin at a new source and called
958 * yylex(). If so, then we have to assure
959 * consistency between YY_CURRENT_BUFFER and our
960 * globals. Here is the right place to do so, because
961 * this is the first action (other than possibly a
962 * back-up) that will match for the new input source.
963 */
964 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
965 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
966 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
967 }
968
969 /* Note that here we test for yy_c_buf_p "<=" to the position
970 * of the first EOB in the buffer, since yy_c_buf_p will
971 * already have been incremented past the NUL character
972 * (since all states make transitions on EOB to the
973 * end-of-buffer state). Contrast this with the test
974 * in input().
975 */
976 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
977 { /* This was really a NUL. */
978 yy_state_type yy_next_state;
979
980 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
981
982 yy_current_state = yy_get_previous_state( );
983
984 /* Okay, we're now positioned to make the NUL
985 * transition. We couldn't have
986 * yy_get_previous_state() go ahead and do it
987 * for us because it doesn't know how to deal
988 * with the possibility of jamming (and we don't
989 * want to build jamming into it because then it
990 * will run more slowly).
991 */
992
993 yy_next_state = yy_try_NUL_trans( yy_current_state );
994
995 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
996
997 if ( yy_next_state )
998 {
999 /* Consume the NUL. */
1000 yy_cp = ++(yy_c_buf_p);
1001 yy_current_state = yy_next_state;
1002 goto yy_match;
1003 }
1004
1005 else
1006 {
1007 yy_cp = (yy_c_buf_p);
1008 goto yy_find_action;
1009 }
1010 }
1011
1012 else switch ( yy_get_next_buffer( ) )
1013 {
1014 case EOB_ACT_END_OF_FILE:
1015 {
1016 (yy_did_buffer_switch_on_eof) = 0;
1017
1018 if ( yywrap( ) )
1019 {
1020 /* Note: because we've taken care in
1021 * yy_get_next_buffer() to have set up
1022 * yytext, we can now set up
1023 * yy_c_buf_p so that if some total
1024 * hoser (like flex itself) wants to
1025 * call the scanner after we return the
1026 * YY_NULL, it'll still work - another
1027 * YY_NULL will get returned.
1028 */
1029 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1030
1031 yy_act = YY_STATE_EOF(YY_START);
1032 goto do_action;
1033 }
1034
1035 else
1036 {
1037 if ( ! (yy_did_buffer_switch_on_eof) )
1038 YY_NEW_FILE;
1039 }
1040 break;
1041 }
1042
1043 case EOB_ACT_CONTINUE_SCAN:
1044 (yy_c_buf_p) =
1045 (yytext_ptr) + yy_amount_of_matched_text;
1046
1047 yy_current_state = yy_get_previous_state( );
1048
1049 yy_cp = (yy_c_buf_p);
1050 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1051 goto yy_match;
1052
1053 case EOB_ACT_LAST_MATCH:
1054 (yy_c_buf_p) =
1055 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1056
1057 yy_current_state = yy_get_previous_state( );
1058
1059 yy_cp = (yy_c_buf_p);
1060 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1061 goto yy_find_action;
1062 }
1063 break;
1064 }
1065
1066 default:
1067 YY_FATAL_ERROR(
1068 "fatal flex scanner internal error--no action found" );
1069 } /* end of action switch */
1070 } /* end of scanning one token */
1071 } /* end of yylex */
1072
1073 /* yy_get_next_buffer - try to read in a new buffer
1074 *
1075 * Returns a code representing an action:
1076 * EOB_ACT_LAST_MATCH -
1077 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1078 * EOB_ACT_END_OF_FILE - end of file
1079 */
1080 static int yy_get_next_buffer (void)
1081 {
1082 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1083 register char *source = (yytext_ptr);
1084 register int number_to_move, i;
1085 int ret_val;
1086
1087 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1088 YY_FATAL_ERROR(
1089 "fatal flex scanner internal error--end of buffer missed" );
1090
1091 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1092 { /* Don't try to fill the buffer, so this is an EOF. */
1093 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1094 {
1095 /* We matched a single character, the EOB, so
1096 * treat this as a final EOF.
1097 */
1098 return EOB_ACT_END_OF_FILE;
1099 }
1100
1101 else
1102 {
1103 /* We matched some text prior to the EOB, first
1104 * process it.
1105 */
1106 return EOB_ACT_LAST_MATCH;
1107 }
1108 }
1109
1110 /* Try to read more data. */
1111
1112 /* First move last chars to start of buffer. */
1113 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1114
1115 for ( i = 0; i < number_to_move; ++i )
1116 *(dest++) = *(source++);
1117
1118 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1119 /* don't do the read, it's not guaranteed to return an EOF,
1120 * just force an EOF
1121 */
1122 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1123
1124 else
1125 {
1126 yy_size_t num_to_read =
1127 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1128
1129 while ( num_to_read <= 0 )
1130 { /* Not enough room in the buffer - grow it. */
1131
1132 /* just a shorter name for the current buffer */
1133 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1134
1135 int yy_c_buf_p_offset =
1136 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1137
1138 if ( b->yy_is_our_buffer )
1139 {
1140 yy_size_t new_size = b->yy_buf_size * 2;
1141
1142 if ( new_size <= 0 )
1143 b->yy_buf_size += b->yy_buf_size / 8;
1144 else
1145 b->yy_buf_size *= 2;
1146
1147 b->yy_ch_buf = (char *)
1148 /* Include room in for 2 EOB chars. */
1149 yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1150 }
1151 else
1152 /* Can't grow it, we don't own it. */
1153 b->yy_ch_buf = 0;
1154
1155 if ( ! b->yy_ch_buf )
1156 YY_FATAL_ERROR(
1157 "fatal error - scanner input buffer overflow" );
1158
1159 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1160
1161 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1162 number_to_move - 1;
1163
1164 }
1165
1166 if ( num_to_read > YY_READ_BUF_SIZE )
1167 num_to_read = YY_READ_BUF_SIZE;
1168
1169 /* Read in more data. */
1170 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1171 (yy_n_chars), num_to_read );
1172
1173 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1174 }
1175
1176 if ( (yy_n_chars) == 0 )
1177 {
1178 if ( number_to_move == YY_MORE_ADJ )
1179 {
1180 ret_val = EOB_ACT_END_OF_FILE;
1181 yyrestart(yyin );
1182 }
1183
1184 else
1185 {
1186 ret_val = EOB_ACT_LAST_MATCH;
1187 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1188 YY_BUFFER_EOF_PENDING;
1189 }
1190 }
1191
1192 else
1193 ret_val = EOB_ACT_CONTINUE_SCAN;
1194
1195 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1196 /* Extend the array by 50%, plus the number we really need. */
1197 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1198 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1199 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1200 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1201 }
1202
1203 (yy_n_chars) += number_to_move;
1204 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1205 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1206
1207 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1208
1209 return ret_val;
1210 }
1211
1212 /* yy_get_previous_state - get the state just before the EOB char was reached */
1213
yy_get_previous_state(void)1214 static yy_state_type yy_get_previous_state (void)
1215 {
1216 register yy_state_type yy_current_state;
1217 register char *yy_cp;
1218
1219 yy_current_state = (yy_start);
1220
1221 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1222 {
1223 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1224 if ( yy_accept[yy_current_state] )
1225 {
1226 (yy_last_accepting_state) = yy_current_state;
1227 (yy_last_accepting_cpos) = yy_cp;
1228 }
1229 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1230 {
1231 yy_current_state = (int) yy_def[yy_current_state];
1232 if ( yy_current_state >= 68 )
1233 yy_c = yy_meta[(unsigned int) yy_c];
1234 }
1235 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1236 }
1237
1238 return yy_current_state;
1239 }
1240
1241 /* yy_try_NUL_trans - try to make a transition on the NUL character
1242 *
1243 * synopsis
1244 * next_state = yy_try_NUL_trans( current_state );
1245 */
yy_try_NUL_trans(yy_state_type yy_current_state)1246 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1247 {
1248 register int yy_is_jam;
1249 register char *yy_cp = (yy_c_buf_p);
1250
1251 register YY_CHAR yy_c = 1;
1252 if ( yy_accept[yy_current_state] )
1253 {
1254 (yy_last_accepting_state) = yy_current_state;
1255 (yy_last_accepting_cpos) = yy_cp;
1256 }
1257 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1258 {
1259 yy_current_state = (int) yy_def[yy_current_state];
1260 if ( yy_current_state >= 68 )
1261 yy_c = yy_meta[(unsigned int) yy_c];
1262 }
1263 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1264 yy_is_jam = (yy_current_state == 67);
1265
1266 return yy_is_jam ? 0 : yy_current_state;
1267 }
1268
yyunput(int c,register char * yy_bp)1269 static void yyunput (int c, register char * yy_bp )
1270 {
1271 register char *yy_cp;
1272
1273 yy_cp = (yy_c_buf_p);
1274
1275 /* undo effects of setting up yytext */
1276 *yy_cp = (yy_hold_char);
1277
1278 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1279 { /* need to shift things up to make room */
1280 /* +2 for EOB chars. */
1281 register yy_size_t number_to_move = (yy_n_chars) + 2;
1282 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1283 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1284 register char *source =
1285 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1286
1287 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1288 *--dest = *--source;
1289
1290 yy_cp += (int) (dest - source);
1291 yy_bp += (int) (dest - source);
1292 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1293 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1294
1295 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1296 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1297 }
1298
1299 *--yy_cp = (char) c;
1300
1301 (yytext_ptr) = yy_bp;
1302 (yy_hold_char) = *yy_cp;
1303 (yy_c_buf_p) = yy_cp;
1304 }
1305
1306 #ifndef YY_NO_INPUT
1307 #ifdef __cplusplus
yyinput(void)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 yy_size_t offset = (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 EOF;
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 */
yyrestart(FILE * input_file)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 */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)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
yy_load_buffer_state(void)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 */
yy_create_buffer(FILE * file,int size)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(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 */
yy_delete_buffer(YY_BUFFER_STATE b)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 */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file)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 */
yy_flush_buffer(YY_BUFFER_STATE b)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 */
yypush_buffer_state(YY_BUFFER_STATE new_buffer)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 */
yypop_buffer_state(void)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 */
yyensure_buffer_stack(void)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;
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 int 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 */
yy_scan_buffer(char * base,yy_size_t size)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 0;
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 = 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 = 0;
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 */
yy_scan_string(yyconst char * yystr)1686 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1687 {
1688
1689 return yy_scan_bytes(yystr,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 */
yy_scan_bytes(yyconst char * yybytes,yy_size_t _yybytes_len)1699 YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
1700 {
1701 YY_BUFFER_STATE b;
1702 char *buf;
1703 yy_size_t n;
1704 yy_size_t i;
1705
1706 /* Get memory for full buffer, including space for trailing EOB's. */
1707 n = _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
yy_fatal_error(yyconst char * msg)1733 static void yy_fatal_error (yyconst char* msg )
1734 {
1735 (void) 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 */
yyget_lineno(void)1761 int yyget_lineno (void)
1762 {
1763
1764 return yylineno;
1765 }
1766
1767 /** Get the input stream.
1768 *
1769 */
yyget_in(void)1770 FILE *yyget_in (void)
1771 {
1772 return yyin;
1773 }
1774
1775 /** Get the output stream.
1776 *
1777 */
yyget_out(void)1778 FILE *yyget_out (void)
1779 {
1780 return yyout;
1781 }
1782
1783 /** Get the length of the current token.
1784 *
1785 */
yyget_leng(void)1786 yy_size_t yyget_leng (void)
1787 {
1788 return yyleng;
1789 }
1790
1791 /** Get the current token.
1792 *
1793 */
1794
yyget_text(void)1795 char *yyget_text (void)
1796 {
1797 return yytext;
1798 }
1799
1800 /** Set the current line number.
1801 * @param line_number
1802 *
1803 */
yyset_lineno(int line_number)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 */
yyset_in(FILE * in_str)1816 void yyset_in (FILE * in_str )
1817 {
1818 yyin = in_str ;
1819 }
1820
yyset_out(FILE * out_str)1821 void yyset_out (FILE * out_str )
1822 {
1823 yyout = out_str ;
1824 }
1825
yyget_debug(void)1826 int yyget_debug (void)
1827 {
1828 return yy_flex_debug;
1829 }
1830
yyset_debug(int bdebug)1831 void yyset_debug (int bdebug )
1832 {
1833 yy_flex_debug = bdebug ;
1834 }
1835
yy_init_globals(void)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) = 0;
1843 (yy_buffer_stack_top) = 0;
1844 (yy_buffer_stack_max) = 0;
1845 (yy_c_buf_p) = (char *) 0;
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 = (FILE *) 0;
1855 yyout = (FILE *) 0;
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. */
yylex_destroy(void)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
yy_flex_strncpy(char * s1,yyconst char * s2,int n)1891 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1892 {
1893 register int i;
1894 for ( i = 0; i < n; ++i )
1895 s1[i] = s2[i];
1896 }
1897 #endif
1898
1899 #ifdef YY_NEED_STRLEN
yy_flex_strlen(yyconst char * s)1900 static int yy_flex_strlen (yyconst char * s )
1901 {
1902 register int n;
1903 for ( n = 0; s[n]; ++n )
1904 ;
1905
1906 return n;
1907 }
1908 #endif
1909
yyalloc(yy_size_t size)1910 void *yyalloc (yy_size_t size )
1911 {
1912 return (void *) malloc( size );
1913 }
1914
yyrealloc(void * ptr,yy_size_t size)1915 void *yyrealloc (void * ptr, yy_size_t size )
1916 {
1917 /* The cast to (char *) in the following accommodates both
1918 * implementations that use char* generic pointers, and those
1919 * that use void* generic pointers. It works with the latter
1920 * because both ANSI C and C++ allow castless assignment from
1921 * any pointer type to void*, and deal with argument conversions
1922 * as though doing an assignment.
1923 */
1924 return (void *) realloc( (char *) ptr, size );
1925 }
1926
yyfree(void * ptr)1927 void yyfree (void * ptr )
1928 {
1929 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
1930 }
1931
1932 #define YYTABLES_NAME "yytables"
1933
1934 #line 90 "scanner.l"
1935
1936
1937
SetupScanner(const char * fname,FILE * new_file)1938 void SetupScanner(const char *fname, FILE *new_file)
1939 {
1940 if (new_file == NULL || fname == NULL)
1941 {
1942 new_file = stdin;
1943 }
1944 yyrestart(new_file);
1945 BEGIN(INITIAL);
1946
1947 filename = (fname == NULL) ? "<stdin>" : fname;
1948 line = 1;
1949 }
1950
1951
1952