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