No empty .Rs/.Re
[netbsd-mini2440.git] / usr.bin / lex / flex.skl
blobd84da2d2fef784d17814c62cfaf9db18e3a7224c
1 /* A lexical scanner generated by flex */
3 /* Scanner skeleton version:
4  * $NetBSD: flex.skl,v 1.24 2009/07/20 21:13:28 christos Exp $
5  */
7 #define FLEX_SCANNER
8 #define YY_FLEX_MAJOR_VERSION 2
9 #define YY_FLEX_MINOR_VERSION 5
12 #include <stdio.h>
16 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
17 #ifdef c_plusplus
18 #ifndef __cplusplus
19 #define __cplusplus
20 #endif
21 #endif
24 #ifdef __cplusplus
26 #include <stdlib.h>
28 #include <iosfwd>
30 #include <unistd.h>
32 /* Use prototypes in function declarations. */
33 #define YY_USE_PROTOS
35 /* The "const" storage-class-modifier is valid. */
36 #define YY_USE_CONST
38 #else   /* ! __cplusplus */
40 #if __STDC__
42 #define YY_USE_PROTOS
43 #define YY_USE_CONST
45 #endif  /* __STDC__ */
46 #endif  /* ! __cplusplus */
48 #ifdef __TURBOC__
49  #pragma warn -rch
50  #pragma warn -use
51 #include <io.h>
52 #include <stdlib.h>
53 #define YY_USE_CONST
54 #define YY_USE_PROTOS
55 #endif
57 #ifdef YY_USE_CONST
58 #define yyconst const
59 #else
60 #define yyconst
61 #endif
64 #ifdef YY_USE_PROTOS
65 #define YY_PROTO(proto) proto
66 #else
67 #define YY_PROTO(proto) ()
68 #endif
70 /* Returned upon end-of-file. */
71 #define YY_NULL 0
73 /* Promotes a possibly negative, possibly signed char to an unsigned
74  * integer for use as an array index.  If the signed char is negative,
75  * we want to instead treat it as an 8-bit unsigned char, hence the
76  * double cast.
77  */
78 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
80 /* Enter a start condition.  This macro really ought to take a parameter,
81  * but we do it the disgusting crufty way forced on us by the ()-less
82  * definition of BEGIN.
83  */
84 #define BEGIN yy_start = 1 + 2 *
86 /* Translate the current start state into a value that can be later handed
87  * to BEGIN to return to the state.  The YYSTATE alias is for lex
88  * compatibility.
89  */
90 #define YY_START ((yy_start - 1) / 2)
91 #define YYSTATE YY_START
93 /* Action number for EOF rule of a given start state. */
94 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
96 /* Special action meaning "start processing a new file". */
97 #define YY_NEW_FILE yyrestart( yyin )
99 #define YY_END_OF_BUFFER_CHAR 0
101 /* Size of default input buffer. */
102 #define YY_BUF_SIZE 16384
104 typedef struct yy_buffer_state *YY_BUFFER_STATE;
106 extern int yyleng;
108 extern FILE *yyin, *yyout;
111 #define EOB_ACT_CONTINUE_SCAN 0
112 #define EOB_ACT_END_OF_FILE 1
113 #define EOB_ACT_LAST_MATCH 2
115 /* The funky do-while in the following #define is used to turn the definition
116  * int a single C statement (which needs a semi-colon terminator).  This
117  * avoids problems with code like:
119  *      if ( condition_holds )
120  *              yyless( 5 );
121  *      else
122  *              do_something_else();
124  * Prior to using the do-while the compiler would get upset at the
125  * "else" because it interpreted the "if" statement as being all
126  * done when it reached the ';' after the yyless() call.
127  */
129 /* Return all but the first 'n' matched characters back to the input stream. */
131 #define yyless(n) \
132         do \
133                 { \
134                 /* Undo effects of setting up yytext. */ \
135                 *yy_cp = yy_hold_char; \
136                 YY_RESTORE_YY_MORE_OFFSET \
137                 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
138                 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
139                 } \
140         while ( 0 )
142 #define unput(c) yyunput( c, yytext_ptr )
144 /* The following is because we cannot portably get our hands on size_t
145  * (without autoconf's help, which isn't available because we want
146  * flex-generated scanners to compile on their own).
147  */
148 typedef unsigned int yy_size_t;
151 struct yy_buffer_state
152         {
154         FILE *yy_input_file;
156         std::istream* yy_input_file;
159         char *yy_ch_buf;                /* input buffer */
160         char *yy_buf_pos;               /* current position in input buffer */
162         /* Size of input buffer in bytes, not including room for EOB
163          * characters.
164          */
165         yy_size_t yy_buf_size;
167         /* Number of characters read into yy_ch_buf, not including EOB
168          * characters.
169          */
170         int yy_n_chars;
172         /* Whether we "own" the buffer - i.e., we know we created it,
173          * and can realloc() it to grow it, and should free() it to
174          * delete it.
175          */
176         int yy_is_our_buffer;
178         /* Whether this is an "interactive" input source; if so, and
179          * if we're using stdio for input, then we want to use getc()
180          * instead of fread(), to make sure we stop fetching input after
181          * each newline.
182          */
183         int yy_is_interactive;
185         /* Whether we're considered to be at the beginning of a line.
186          * If so, '^' rules will be active on the next match, otherwise
187          * not.
188          */
189         int yy_at_bol;
191         /* Whether to try to fill the input buffer when we reach the
192          * end of it.
193          */
194         int yy_fill_buffer;
196         int yy_buffer_status;
197 #define YY_BUFFER_NEW 0
198 #define YY_BUFFER_NORMAL 1
199         /* When an EOF's been seen but there's still some text to process
200          * then we mark the buffer as YY_EOF_PENDING, to indicate that we
201          * shouldn't try reading from the input source any more.  We might
202          * still have a bunch of tokens to match, though, because of
203          * possible backing-up.
204          *
205          * When we actually see the EOF, we change the status to "new"
206          * (via yyrestart()), so that the user can continue scanning by
207          * just pointing yyin at a new input file.
208          */
209 #define YY_BUFFER_EOF_PENDING 2
210         };
212 %- Standard (non-C++) definition
213 static YY_BUFFER_STATE yy_current_buffer = 0;
216 /* We provide macros for accessing buffer states in case in the
217  * future we want to put the buffer states in a more general
218  * "scanner state".
219  */
220 #define YY_CURRENT_BUFFER yy_current_buffer
223 %- Standard (non-C++) definition
224 /* yy_hold_char holds the character lost when yytext is formed. */
225 static char yy_hold_char;
227 static int yy_n_chars;          /* number of characters read into yy_ch_buf */
230 int yyleng;
232 /* Points to current character in buffer. */
233 static char *yy_c_buf_p = (char *) 0;
234 static int yy_init = 1;         /* whether we need to initialize */
235 static int yy_start = 0;        /* start state number */
237 /* Flag which is used to allow yywrap()'s to do buffer switches
238  * instead of setting up a fresh yyin.  A bit of a hack ...
239  */
240 static int yy_did_buffer_switch_on_eof;
242 void yyrestart YY_PROTO(( FILE *input_file ));
244 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
245 void yy_load_buffer_state YY_PROTO(( void ));
246 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
247 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
248 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
249 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
250 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
252 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
253 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
254 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, yy_size_t len ));
255 #ifdef __cplusplus
256 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, int size ));
257 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
258 #endif
261 #define yy_new_buffer yy_create_buffer
263 #define yy_set_interactive(is_interactive) \
264         { \
265         if ( ! yy_current_buffer ) \
266                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
267         yy_current_buffer->yy_is_interactive = is_interactive; \
268         }
270 #define yy_set_bol(at_bol) \
271         { \
272         if ( ! yy_current_buffer ) \
273                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
274         yy_current_buffer->yy_at_bol = at_bol; \
275         }
277 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
279 %% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
281 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
282 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ))
283 #ifdef __GNUC__
284     __attribute__((__unused__))
285 #endif
287 static void yy_flex_free YY_PROTO(( void * ));
289 %- Standard (non-C++) definition
290 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
291 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
292 static int yy_get_next_buffer YY_PROTO(( void ));
293 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
296 /* Done after the current pattern has been matched and before the
297  * corresponding action - sets up yytext.
298  */
299 #define YY_DO_BEFORE_ACTION \
300         yytext_ptr = yy_bp; \
301 %% code to fiddle yytext and yyleng for yymore() goes here
302         yy_hold_char = *yy_cp; \
303         *yy_cp = '\0'; \
304 %% code to copy yytext_ptr to yytext[] goes here, if %array
305         yy_c_buf_p = yy_cp;
307 %% data tables for the DFA and the user's section 1 definitions go here
309 /* Macros after this point can all be overridden by user definitions in
310  * section 1.
311  */
313 #ifndef YY_SKIP_YYWRAP
314 #ifdef __cplusplus
315 extern "C" int yywrap YY_PROTO(( void ));
316 #else
317 extern int yywrap YY_PROTO(( void ));
318 #endif
319 #endif
322 #ifndef YY_NO_UNPUT
323 static void yyunput YY_PROTO(( int c, char *buf_ptr ))
324 #ifdef __GNUC__
325     __attribute__((__unused__))
326 #endif
328 #endif
331 #ifndef yytext_ptr
332 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, yy_size_t ));
333 #endif
335 #ifdef YY_NEED_STRLEN
336 static yy_size_t yy_flex_strlen YY_PROTO(( yyconst char * ));
337 #endif
339 #ifndef YY_NO_INPUT
340 %- Standard (non-C++) definition
341 #ifdef __cplusplus
342 static int yyinput YY_PROTO(( void ));
343 #else
344 static int input YY_PROTO(( void ));
345 #endif
347 #endif
349 #if YY_STACK_USED
350 static int yy_start_stack_ptr = 0;
351 static int yy_start_stack_depth = 0;
352 static int *yy_start_stack = 0;
353 #ifndef YY_NO_PUSH_STATE
354 static void yy_push_state YY_PROTO(( int new_state ));
355 #endif
356 #ifndef YY_NO_POP_STATE
357 static void yy_pop_state YY_PROTO(( void ));
358 #endif
359 #ifndef YY_NO_TOP_STATE
360 static int yy_top_state YY_PROTO(( void ));
361 #endif
363 #else
364 #define YY_NO_PUSH_STATE 1
365 #define YY_NO_POP_STATE 1
366 #define YY_NO_TOP_STATE 1
367 #endif
369 #ifdef YY_MALLOC_DECL
370 YY_MALLOC_DECL
371 #else
372 #if __STDC__
373 #ifndef __cplusplus
374 #include <stdlib.h>
375 #endif
376 #else
377 /* Just try to get by without declaring the routines.  This will fail
378  * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
379  * or sizeof(void*) != sizeof(int).
380  */
381 #endif
382 #endif
384 /* Amount of stuff to slurp up with each read. */
385 #ifndef YY_READ_BUF_SIZE
386 #define YY_READ_BUF_SIZE 8192
387 #endif
389 /* Copy whatever the last rule matched to the standard output. */
391 #ifndef ECHO
392 %- Standard (non-C++) definition
393 /* This used to be an fputs(), but since the string might contain NUL's,
394  * we now use fwrite().
395  */
396 #define ECHO (void) fwrite( yytext, (size_t)yyleng, 1, yyout )
397 %+ C++ definition
398 #define ECHO LexerOutput( yytext, yyleng )
400 #endif
402 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
403  * is returned in "result".
404  */
405 #ifndef YY_INPUT
406 #define YY_INPUT(buf,result,max_size) \
407 %% fread()/read() definition of YY_INPUT goes here unless we're doing C++
408 %+ C++ definition
409         if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
410                 YY_FATAL_ERROR( "input in flex scanner failed" );
412 #endif
414 /* No semi-colon after return; correct usage is to write "yyterminate();" -
415  * we don't want an extra ';' after the "return" because that will cause
416  * some compilers to complain about unreachable statements.
417  */
418 #ifndef yyterminate
419 #define yyterminate() return YY_NULL
420 #endif
422 /* Number of entries by which start-condition stack grows. */
423 #ifndef YY_START_STACK_INCR
424 #define YY_START_STACK_INCR 25
425 #endif
427 /* Report a fatal error. */
428 #ifndef YY_FATAL_ERROR
430 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
432 #define YY_FATAL_ERROR(msg) LexerError( msg )
434 #endif
436 /* Default declaration of generated scanner - a define so the user can
437  * easily add parameters.
438  */
439 #ifndef YY_DECL
440 %- Standard (non-C++) definition
441 #define YY_DECL int yylex YY_PROTO(( void ))
442 %+ C++ definition
443 #define YY_DECL int yyFlexLexer::yylex()
445 #endif
447 /* Code executed at the beginning of each rule, after yytext and yyleng
448  * have been set up.
449  */
450 #ifndef YY_USER_ACTION
451 #define YY_USER_ACTION
452 #endif
454 /* Code executed at the end of each rule. */
455 #ifndef YY_BREAK
456 #define YY_BREAK /*LINTED*/break;
457 #endif
459 %% YY_RULE_SETUP definition goes here
461 YY_DECL
462         {
463         register yy_state_type yy_current_state;
464         register char *yy_cp, *yy_bp;
465         register int yy_act;
467 %% user's declarations go here
469 #if defined(YY_USES_REJECT) && (defined(__GNUC__) || defined(lint))
470         /* XXX: shut up `unused label' warning with %options yylineno */
471         if (/*CONSTCOND*/0 && yy_full_match)
472                 goto find_rule;
473 #endif
474         if ( yy_init )
475                 {
476                 yy_init = 0;
478 #ifdef YY_USER_INIT
479                 YY_USER_INIT;
480 #endif
482                 if ( ! yy_start )
483                         yy_start = 1;   /* first start state */
485                 if ( ! yyin )
487                         yyin = stdin;
489                         yyin = &std::cin;
492                 if ( ! yyout )
494                         yyout = stdout;
496                         yyout = &std::cout;
499                 if ( ! yy_current_buffer )
500                         yy_current_buffer =
501                                 yy_create_buffer( yyin, YY_BUF_SIZE );
503                 yy_load_buffer_state();
504                 }
506         while (/*CONSTCOND*/ 1 )        /* loops until end-of-file is reached */
507                 {
508 %% yymore()-related code goes here
509                 yy_cp = yy_c_buf_p;
511                 /* Support of yytext. */
512                 *yy_cp = yy_hold_char;
514                 /* yy_bp points to the position in yy_ch_buf of the start of
515                  * the current run.
516                  */
517                 yy_bp = yy_cp;
519 %% code to set up and find next match goes here
521 yy_find_action:
522 %% code to find the action number goes here
524                 YY_DO_BEFORE_ACTION;
526 %% code for yylineno update goes here
528 do_action:      /* This label is used only to access EOF actions. */
530 %% debug code goes here
532                 switch ( yy_act )
533         { /* beginning of action switch */
534 %% actions go here
536         case YY_END_OF_BUFFER:
537                 {
538                 /* Amount of text matched not including the EOB char. */
539                 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
541                 /* Undo the effects of YY_DO_BEFORE_ACTION. */
542                 *yy_cp = yy_hold_char;
543                 YY_RESTORE_YY_MORE_OFFSET
545                 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
546                         {
547                         /* We're scanning a new file or input source.  It's
548                          * possible that this happened because the user
549                          * just pointed yyin at a new source and called
550                          * yylex().  If so, then we have to assure
551                          * consistency between yy_current_buffer and our
552                          * globals.  Here is the right place to do so, because
553                          * this is the first action (other than possibly a
554                          * back-up) that will match for the new input source.
555                          */
556                         yy_n_chars = yy_current_buffer->yy_n_chars;
557                         yy_current_buffer->yy_input_file = yyin;
558                         yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
559                         }
561                 /* Note that here we test for yy_c_buf_p "<=" to the position
562                  * of the first EOB in the buffer, since yy_c_buf_p will
563                  * already have been incremented past the NUL character
564                  * (since all states make transitions on EOB to the
565                  * end-of-buffer state).  Contrast this with the test
566                  * in input().
567                  */
568                 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
569                         { /* This was really a NUL. */
570                         yy_state_type yy_next_state;
572                         yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
574                         yy_current_state = yy_get_previous_state();
576                         /* Okay, we're now positioned to make the NUL
577                          * transition.  We couldn't have
578                          * yy_get_previous_state() go ahead and do it
579                          * for us because it doesn't know how to deal
580                          * with the possibility of jamming (and we don't
581                          * want to build jamming into it because then it
582                          * will run more slowly).
583                          */
585                         yy_next_state = yy_try_NUL_trans( yy_current_state );
587                         yy_bp = yytext_ptr + YY_MORE_ADJ;
589                         if ( yy_next_state )
590                                 {
591                                 /* Consume the NUL. */
592                                 yy_cp = ++yy_c_buf_p;
593                                 yy_current_state = yy_next_state;
594                                 goto yy_match;
595                                 }
597                         else
598                                 {
599 %% code to do back-up for compressed tables and set up yy_cp goes here
600                                 goto yy_find_action;
601                                 }
602                         }
604                 else switch ( yy_get_next_buffer() )
605                         {
606                         case EOB_ACT_END_OF_FILE:
607                                 {
608                                 yy_did_buffer_switch_on_eof = 0;
610                                 if ( yywrap() )
611                                         {
612                                         /* Note: because we've taken care in
613                                          * yy_get_next_buffer() to have set up
614                                          * yytext, we can now set up
615                                          * yy_c_buf_p so that if some total
616                                          * hoser (like flex itself) wants to
617                                          * call the scanner after we return the
618                                          * YY_NULL, it'll still work - another
619                                          * YY_NULL will get returned.
620                                          */
621                                         yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
623                                         yy_act = YY_STATE_EOF(YY_START);
624                                         goto do_action;
625                                         }
627                                 else
628                                         {
629                                         if ( ! yy_did_buffer_switch_on_eof )
630                                                 YY_NEW_FILE;
631                                         }
632                                 break;
633                                 }
635                         case EOB_ACT_CONTINUE_SCAN:
636                                 yy_c_buf_p =
637                                         yytext_ptr + yy_amount_of_matched_text;
639                                 yy_current_state = yy_get_previous_state();
641                                 yy_cp = yy_c_buf_p;
642                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
643                                 goto yy_match;
645                         case EOB_ACT_LAST_MATCH:
646                                 yy_c_buf_p =
647                                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
649                                 yy_current_state = yy_get_previous_state();
651                                 yy_cp = yy_c_buf_p;
652                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
653                                 goto yy_find_action;
654                         }
655                 break;
656                 }
658         default:
659                 YY_FATAL_ERROR(
660                         "fatal flex scanner internal error--no action found" );
661         } /* end of action switch */
662                 } /* end of scanning one token */
663         } /* end of yylex */
666 yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
667         {
668         yyin = arg_yyin;
669         yyout = arg_yyout;
670         yy_c_buf_p = 0;
671         yy_init = 1;
672         yy_start = 0;
673         yy_flex_debug = 0;
674         yylineno = 1;   // this will only get updated if %option yylineno
676         yy_did_buffer_switch_on_eof = 0;
678         yy_looking_for_trail_begin = 0;
679         yy_more_flag = 0;
680         yy_more_len = 0;
681         yy_more_offset = yy_prev_more_offset = 0;
683         yy_start_stack_ptr = yy_start_stack_depth = 0;
684         yy_start_stack = 0;
686         yy_current_buffer = 0;
688 #ifdef YY_USES_REJECT
689         yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
690 #else
691         yy_state_buf = 0;
692 #endif
693         }
695 yyFlexLexer::~yyFlexLexer()
696         {
697         delete yy_state_buf;
698         yy_delete_buffer( yy_current_buffer );
699         }
701 void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out )
702         {
703         if ( new_in )
704                 {
705                 yy_delete_buffer( yy_current_buffer );
706                 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
707                 }
709         if ( new_out )
710                 yyout = new_out;
711         }
713 #ifdef YY_INTERACTIVE
714 int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
715 #else
716 int yyFlexLexer::LexerInput( char* buf, int max_size )
717 #endif
718         {
719         if ( yyin->eof() || yyin->fail() )
720                 return 0;
722 #ifdef YY_INTERACTIVE
723         yyin->get( buf[0] );
725         if ( yyin->eof() )
726                 return 0;
728         if ( yyin->bad() )
729                 return -1;
731         return 1;
733 #else
734         (void) yyin->read( buf, max_size );
736         if ( yyin->bad() )
737                 return -1;
738         else
739                 return yyin->gcount();
740 #endif
741         }
743 void yyFlexLexer::LexerOutput( const char* buf, int size )
744         {
745         (void) yyout->write( buf, size );
746         }
749 /* yy_get_next_buffer - try to read in a new buffer
751  * Returns a code representing an action:
752  *      EOB_ACT_LAST_MATCH -
753  *      EOB_ACT_CONTINUE_SCAN - continue scanning from current position
754  *      EOB_ACT_END_OF_FILE - end of file
755  */
758 static int yy_get_next_buffer()
760 int yyFlexLexer::yy_get_next_buffer()
762         {
763         register char *dest = yy_current_buffer->yy_ch_buf;
764         register char *source = yytext_ptr;
765         register int number_to_move, i;
766         int ret_val;
768         if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
769                 YY_FATAL_ERROR(
770                 "fatal flex scanner internal error--end of buffer missed" );
772         if ( yy_current_buffer->yy_fill_buffer == 0 )
773                 { /* Don't try to fill the buffer, so this is an EOF. */
774                 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
775                         {
776                         /* We matched a single character, the EOB, so
777                          * treat this as a final EOF.
778                          */
779                         return EOB_ACT_END_OF_FILE;
780                         }
782                 else
783                         {
784                         /* We matched some text prior to the EOB, first
785                          * process it.
786                          */
787                         return EOB_ACT_LAST_MATCH;
788                         }
789                 }
791         /* Try to read more data. */
793         /* First move last chars to start of buffer. */
794         number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
796         for ( i = 0; i < number_to_move; ++i )
797                 *(dest++) = *(source++);
799         if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
800                 /* don't do the read, it's not guaranteed to return an EOF,
801                  * just force an EOF
802                  */
803                 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
805         else
806                 {
807                 int num_to_read =
808                         yy_current_buffer->yy_buf_size - number_to_move - 1;
810                 while ( num_to_read <= 0 )
811                         { /* Not enough room in the buffer - grow it. */
812 #ifdef YY_USES_REJECT
813                         YY_FATAL_ERROR(
814 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
815 #else
817                         /* just a shorter name for the current buffer */
818                         YY_BUFFER_STATE b = yy_current_buffer;
820                         int yy_c_buf_p_offset =
821                                 (int) (yy_c_buf_p - b->yy_ch_buf);
823                         if ( b->yy_is_our_buffer )
824                                 {
825                                 int new_size = b->yy_buf_size * 2;
827                                 if ( new_size <= 0 )
828                                         b->yy_buf_size += b->yy_buf_size / 8;
829                                 else
830                                         b->yy_buf_size *= 2;
832                                 b->yy_ch_buf = (char *)
833                                         /* Include room in for 2 EOB chars. */
834                                         yy_flex_realloc( (void *) b->yy_ch_buf,
835                                                          b->yy_buf_size + 2 );
836                                 }
837                         else
838                                 /* Can't grow it, we don't own it. */
839                                 b->yy_ch_buf = 0;
841                         if ( ! b->yy_ch_buf )
842                                 YY_FATAL_ERROR(
843                                 "fatal error - scanner input buffer overflow" );
845                         yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
847                         num_to_read = yy_current_buffer->yy_buf_size -
848                                                 number_to_move - 1;
849 #endif
850                         }
852                 if ( num_to_read > YY_READ_BUF_SIZE )
853                         num_to_read = YY_READ_BUF_SIZE;
855                 /* Read in more data. */
856                 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
857                         yy_n_chars, num_to_read );
859                 yy_current_buffer->yy_n_chars = yy_n_chars;
860                 }
862         if ( yy_n_chars == 0 )
863                 {
864                 if ( number_to_move == YY_MORE_ADJ )
865                         {
866                         ret_val = EOB_ACT_END_OF_FILE;
867                         yyrestart( yyin );
868                         }
870                 else
871                         {
872                         ret_val = EOB_ACT_LAST_MATCH;
873                         yy_current_buffer->yy_buffer_status =
874                                 YY_BUFFER_EOF_PENDING;
875                         }
876                 }
878         else
879                 ret_val = EOB_ACT_CONTINUE_SCAN;
881         yy_n_chars += number_to_move;
882         yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
883         yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
885         yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
887         return ret_val;
888         }
891 /* yy_get_previous_state - get the state just before the EOB char was reached */
894 static yy_state_type yy_get_previous_state()
896 yy_state_type yyFlexLexer::yy_get_previous_state()
898         {
899         register yy_state_type yy_current_state;
900         register char *yy_cp;
902 %% code to get the start state into yy_current_state goes here
904         for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
905                 {
906 %% code to find the next state goes here
907                 }
909         return yy_current_state;
910         }
913 /* yy_try_NUL_trans - try to make a transition on the NUL character
915  * synopsis
916  *      next_state = yy_try_NUL_trans( current_state );
917  */
920 #ifdef YY_USE_PROTOS
921 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
922 #else
923 static yy_state_type yy_try_NUL_trans( yy_current_state )
924 yy_state_type yy_current_state;
925 #endif
927 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
929         {
930         register int yy_is_jam;
931 %% code to find the next state, and perhaps do backing up, goes here
933         return yy_is_jam ? 0 : yy_current_state;
934         }
938 #ifndef YY_NO_UNPUT
939 #ifdef YY_USE_PROTOS
940 static void yyunput( int c, register char *yy_bp )
941 #else
942 static void yyunput( c, yy_bp )
943 int c;
944 register char *yy_bp;
945 #endif
947 void yyFlexLexer::yyunput( int c, register char* yy_bp )
949         {
950         register char *yy_cp = yy_c_buf_p;
952         /* undo effects of setting up yytext */
953         *yy_cp = yy_hold_char;
955         if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
956                 { /* need to shift things up to make room */
957                 /* +2 for EOB chars. */
958                 register int number_to_move = yy_n_chars + 2;
959                 register char *dest = &yy_current_buffer->yy_ch_buf[
960                                         yy_current_buffer->yy_buf_size + 2];
961                 register char *source =
962                                 &yy_current_buffer->yy_ch_buf[number_to_move];
964                 while ( source > yy_current_buffer->yy_ch_buf )
965                         *--dest = *--source;
967                 yy_cp += (int) (dest - source);
968                 yy_bp += (int) (dest - source);
969                 yy_current_buffer->yy_n_chars =
970                         yy_n_chars = yy_current_buffer->yy_buf_size;
972                 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
973                         YY_FATAL_ERROR( "flex scanner push-back overflow" );
974                 }
976         *--yy_cp = (char) c;
978 %% update yylineno here
980         yytext_ptr = yy_bp;
981         yy_hold_char = *yy_cp;
982         yy_c_buf_p = yy_cp;
983         }
985 #endif  /* ifndef YY_NO_UNPUT */
990 #ifndef YY_NO_INPUT
991 #ifdef __cplusplus
992 static int yyinput YY_PROTO(( void ))
993 #else
994 static int input YY_PROTO(( void ))
995 #endif
997 int yyFlexLexer::yyinput(void)
999         {
1000         int c;
1002         *yy_c_buf_p = yy_hold_char;
1004         if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1005                 {
1006                 /* yy_c_buf_p now points to the character we want to return.
1007                  * If this occurs *before* the EOB characters, then it's a
1008                  * valid NUL; if not, then we've hit the end of the buffer.
1009                  */
1010                 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1011                         /* This was really a NUL. */
1012                         *yy_c_buf_p = '\0';
1014                 else
1015                         { /* need more input */
1016                         int offset = yy_c_buf_p - yytext_ptr;
1017                         ++yy_c_buf_p;
1019                         switch ( yy_get_next_buffer() )
1020                                 {
1021                                 case EOB_ACT_LAST_MATCH:
1022                                         /* This happens because yy_g_n_b()
1023                                          * sees that we've accumulated a
1024                                          * token and flags that we need to
1025                                          * try matching the token before
1026                                          * proceeding.  But for input(),
1027                                          * there's no matching to consider.
1028                                          * So convert the EOB_ACT_LAST_MATCH
1029                                          * to EOB_ACT_END_OF_FILE.
1030                                          */
1032                                         /* Reset buffer status. */
1033                                         yyrestart( yyin );
1035                                         /*FALLTHROUGH*/
1037                                 case EOB_ACT_END_OF_FILE:
1038                                         {
1039                                         if ( yywrap() )
1040                                                 return EOF;
1042                                         if ( ! yy_did_buffer_switch_on_eof )
1043                                                 YY_NEW_FILE;
1044 #ifdef __cplusplus
1045                                         return yyinput();
1046 #else
1047                                         return input();
1048 #endif
1049                                         }
1051                                 case EOB_ACT_CONTINUE_SCAN:
1052                                         yy_c_buf_p = yytext_ptr + offset;
1053                                         break;
1054                                 }
1055                         }
1056                 }
1058         c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
1059         *yy_c_buf_p = '\0';     /* preserve yytext */
1060         yy_hold_char = *++yy_c_buf_p;
1062 %% update BOL and yylineno
1064         return c;
1065         }
1067 #endif /* ifndef YY_NO_INPUT */
1072 #ifdef YY_USE_PROTOS
1073 void yyrestart( FILE *input_file )
1074 #else
1075 void yyrestart( input_file )
1076 FILE *input_file;
1077 #endif
1079 void yyFlexLexer::yyrestart( std::istream* input_file )
1081         {
1082         if ( ! yy_current_buffer )
1083                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1085         yy_init_buffer( yy_current_buffer, input_file );
1086         yy_load_buffer_state();
1087         }
1091 #ifdef YY_USE_PROTOS
1092 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1093 #else
1094 void yy_switch_to_buffer( new_buffer )
1095 YY_BUFFER_STATE new_buffer;
1096 #endif
1098 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1100         {
1101         if ( yy_current_buffer == new_buffer )
1102                 return;
1104         if ( yy_current_buffer )
1105                 {
1106                 /* Flush out information for old buffer. */
1107                 *yy_c_buf_p = yy_hold_char;
1108                 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1109                 yy_current_buffer->yy_n_chars = yy_n_chars;
1110                 }
1112         yy_current_buffer = new_buffer;
1113         yy_load_buffer_state();
1115         /* We don't actually know whether we did this switch during
1116          * EOF (yywrap()) processing, but the only time this flag
1117          * is looked at is after yywrap() is called, so it's safe
1118          * to go ahead and always set it.
1119          */
1120         yy_did_buffer_switch_on_eof = 1;
1121         }
1125 #ifdef YY_USE_PROTOS
1126 void yy_load_buffer_state( void )
1127 #else
1128 void yy_load_buffer_state()
1129 #endif
1131 void yyFlexLexer::yy_load_buffer_state()
1133         {
1134         yy_n_chars = yy_current_buffer->yy_n_chars;
1135         yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1136         yyin = yy_current_buffer->yy_input_file;
1137         yy_hold_char = *yy_c_buf_p;
1138         }
1142 #ifdef YY_USE_PROTOS
1143 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1144 #else
1145 YY_BUFFER_STATE yy_create_buffer( file, size )
1146 FILE *file;
1147 int size;
1148 #endif
1150 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size )
1152         {
1153         YY_BUFFER_STATE b;
1155         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1156         if ( ! b )
1157                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1159         b->yy_buf_size = size;
1161         /* yy_ch_buf has to be 2 characters longer than the size given because
1162          * we need to put in 2 end-of-buffer characters.
1163          */
1164         b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1165         if ( ! b->yy_ch_buf )
1166                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1168         b->yy_is_our_buffer = 1;
1170         yy_init_buffer( b, file );
1172         return b;
1173         }
1177 #ifdef YY_USE_PROTOS
1178 void yy_delete_buffer( YY_BUFFER_STATE b )
1179 #else
1180 void yy_delete_buffer( b )
1181 YY_BUFFER_STATE b;
1182 #endif
1184 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
1186         {
1187         if ( ! b )
1188                 return;
1190         if ( b == yy_current_buffer )
1191                 yy_current_buffer = (YY_BUFFER_STATE) 0;
1193         if ( b->yy_is_our_buffer )
1194                 yy_flex_free( (void *) b->yy_ch_buf );
1196         yy_flex_free( (void *) b );
1197         }
1201 #ifndef YY_ALWAYS_INTERACTIVE
1202 #ifndef YY_NEVER_INTERACTIVE
1203 #include <unistd.h>
1204 #endif
1205 #endif
1207 #ifdef YY_USE_PROTOS
1208 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1209 #else
1210 void yy_init_buffer( b, file )
1211 YY_BUFFER_STATE b;
1212 FILE *file;
1213 #endif
1216 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
1219         {
1220         yy_flush_buffer( b );
1222         b->yy_input_file = file;
1223         b->yy_fill_buffer = 1;
1226 #if YY_ALWAYS_INTERACTIVE
1227         b->yy_is_interactive = 1;
1228 #else
1229 #if YY_NEVER_INTERACTIVE
1230         b->yy_is_interactive = 0;
1231 #else
1232         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1233 #endif
1234 #endif
1236         b->yy_is_interactive = 0;
1238         }
1242 #ifdef YY_USE_PROTOS
1243 void yy_flush_buffer( YY_BUFFER_STATE b )
1244 #else
1245 void yy_flush_buffer( b )
1246 YY_BUFFER_STATE b;
1247 #endif
1250 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
1252         {
1253         if ( ! b )
1254                 return;
1256         b->yy_n_chars = 0;
1258         /* We always need two end-of-buffer characters.  The first causes
1259          * a transition to the end-of-buffer state.  The second causes
1260          * a jam in that state.
1261          */
1262         b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1263         b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1265         b->yy_buf_pos = &b->yy_ch_buf[0];
1267         b->yy_at_bol = 1;
1268         b->yy_buffer_status = YY_BUFFER_NEW;
1270         if ( b == yy_current_buffer )
1271                 yy_load_buffer_state();
1272         }
1276 #ifndef YY_NO_SCAN_BUFFER
1278 #ifdef YY_USE_PROTOS
1279 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1280 #else
1281 YY_BUFFER_STATE yy_scan_buffer( base, size )
1282 char *base;
1283 yy_size_t size;
1284 #endif
1285         {
1286         YY_BUFFER_STATE b;
1288         if ( size < 2 ||
1289              base[size-2] != YY_END_OF_BUFFER_CHAR ||
1290              base[size-1] != YY_END_OF_BUFFER_CHAR )
1291                 /* They forgot to leave room for the EOB's. */
1292                 return 0;
1294         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1295         if ( ! b )
1296                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1298         b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
1299         b->yy_buf_pos = b->yy_ch_buf = base;
1300         b->yy_is_our_buffer = 0;
1301         b->yy_input_file = 0;
1302         b->yy_n_chars = b->yy_buf_size;
1303         b->yy_is_interactive = 0;
1304         b->yy_at_bol = 1;
1305         b->yy_fill_buffer = 0;
1306         b->yy_buffer_status = YY_BUFFER_NEW;
1308         yy_switch_to_buffer( b );
1310         return b;
1311         }
1312 #ifdef __cplusplus
1313 YY_BUFFER_STATE yy_scan_buffer( char *base, int size )
1314         {
1315         return yy_scan_buffer(base, (yy_size_t) size);
1316         }
1317 #endif
1319 #endif
1322 #ifndef YY_NO_SCAN_STRING
1324 #ifdef YY_USE_PROTOS
1325 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1326 #else
1327 YY_BUFFER_STATE yy_scan_string( yy_str )
1328 yyconst char *yy_str;
1329 #endif
1330         {
1331         yy_size_t len;
1332         for ( len = 0; yy_str[len]; ++len )
1333                 ;
1335         return yy_scan_bytes( yy_str, len );
1336         }
1338 #endif
1341 #ifndef YY_NO_SCAN_BYTES
1343 #ifdef YY_USE_PROTOS
1344 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, yy_size_t len )
1345 #else
1346 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1347 yyconst char *bytes;
1348 yy_size_t len;
1349 #endif
1350         {
1351         YY_BUFFER_STATE b;
1352         char *buf;
1353         yy_size_t n, i;
1355         /* Get memory for full buffer, including space for trailing EOB's. */
1356         n = len + 2;
1357         buf = (char *) yy_flex_alloc( n );
1358         if ( ! buf )
1359                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1361         for ( i = 0; i < len; ++i )
1362                 buf[i] = bytes[i];
1364         buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1366         b = yy_scan_buffer( buf, n );
1367         if ( ! b )
1368                 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1370         /* It's okay to grow etc. this buffer, and we should throw it
1371          * away when we're done.
1372          */
1373         b->yy_is_our_buffer = 1;
1375         return b;
1376         }
1377 #ifdef __cplusplus
1378 YY_BUFFER_STATE yy_scan_bytes( yyconst char *base, int size )
1379         {
1380         return yy_scan_bytes(base, (yy_size_t) size);
1381         }
1382 #endif
1384 #endif
1387 #ifndef YY_NO_PUSH_STATE
1389 #ifdef YY_USE_PROTOS
1390 static void yy_push_state( int new_state )
1391 #else
1392 static void yy_push_state( new_state )
1393 int new_state;
1394 #endif
1396 void yyFlexLexer::yy_push_state( int new_state )
1398         {
1399         if ( yy_start_stack_ptr >= yy_start_stack_depth )
1400                 {
1401                 yy_size_t new_size;
1403                 yy_start_stack_depth += YY_START_STACK_INCR;
1404                 new_size = yy_start_stack_depth * sizeof( int );
1406                 if ( ! yy_start_stack )
1407                         yy_start_stack = (int *) yy_flex_alloc( new_size );
1409                 else
1410                         yy_start_stack = (int *) yy_flex_realloc(
1411                                         (void *) yy_start_stack, new_size );
1413                 if ( ! yy_start_stack )
1414                         YY_FATAL_ERROR(
1415                         "out of memory expanding start-condition stack" );
1416                 }
1418         yy_start_stack[yy_start_stack_ptr++] = YY_START;
1420         BEGIN(new_state);
1421         }
1422 #endif
1425 #ifndef YY_NO_POP_STATE
1427 static void yy_pop_state()
1429 void yyFlexLexer::yy_pop_state()
1431         {
1432         if ( --yy_start_stack_ptr < 0 )
1433                 YY_FATAL_ERROR( "start-condition stack underflow" );
1435         BEGIN(yy_start_stack[yy_start_stack_ptr]);
1436         }
1437 #endif
1440 #ifndef YY_NO_TOP_STATE
1442 static int yy_top_state()
1444 int yyFlexLexer::yy_top_state()
1446         {
1447         return yy_start_stack[yy_start_stack_ptr - 1];
1448         }
1449 #endif
1451 #ifndef YY_EXIT_FAILURE
1452 #define YY_EXIT_FAILURE 2
1453 #endif
1456 #ifdef YY_USE_PROTOS
1457 static void yy_fatal_error( yyconst char msg[] )
1458 #else
1459 static void yy_fatal_error( msg )
1460 char msg[];
1461 #endif
1462         {
1463         (void) fprintf( stderr, "%s\n", msg );
1464         exit( YY_EXIT_FAILURE );
1465         }
1469 void yyFlexLexer::LexerError( yyconst char msg[] )
1470         {
1471         std::cerr << msg << std::endl;
1472         exit( YY_EXIT_FAILURE );
1473         }
1477 /* Redefine yyless() so it works in section 3 code. */
1479 #undef yyless
1480 #define yyless(n) \
1481         do \
1482                 { \
1483                 /* Undo effects of setting up yytext. */ \
1484                 yytext[yyleng] = yy_hold_char; \
1485                 yy_c_buf_p = yytext + n; \
1486                 yy_hold_char = *yy_c_buf_p; \
1487                 *yy_c_buf_p = '\0'; \
1488                 yyleng = n; \
1489                 } \
1490         while ( 0 )
1493 /* Internal utility routines. */
1495 #ifndef yytext_ptr
1496 #ifdef YY_USE_PROTOS
1497 static void yy_flex_strncpy( char *s1, yyconst char *s2, yy_size_t n )
1498 #else
1499 static void yy_flex_strncpy( s1, s2, n )
1500 char *s1;
1501 yyconst char *s2;
1502 yy_size_t n;
1503 #endif
1504         {
1505         register yy_size_t i;
1506         for ( i = 0; i < n; ++i )
1507                 s1[i] = s2[i];
1508         }
1509 #endif
1511 #ifdef YY_NEED_STRLEN
1512 #ifdef YY_USE_PROTOS
1513 static yy_size_t yy_flex_strlen( yyconst char *s )
1514 #else
1515 static yy_size_t yy_flex_strlen( s )
1516 yyconst char *s;
1517 #endif
1518         {
1519         register yy_size_t n;
1520         for ( n = 0; s[n]; ++n )
1521                 ;
1523         return n;
1524         }
1525 #endif
1528 #ifdef YY_USE_PROTOS
1529 static void *yy_flex_alloc( yy_size_t size )
1530 #else
1531 static void *yy_flex_alloc( size )
1532 yy_size_t size;
1533 #endif
1534         {
1535         return (void *) malloc( size );
1536         }
1538 #ifdef YY_USE_PROTOS
1539 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1540 #else
1541 static void *yy_flex_realloc( ptr, size )
1542 void *ptr;
1543 yy_size_t size;
1544 #endif
1545         {
1546         /* The cast to (char *) in the following accommodates both
1547          * implementations that use char* generic pointers, and those
1548          * that use void* generic pointers.  It works with the latter
1549          * because both ANSI C and C++ allow castless assignment from
1550          * any pointer type to void*, and deal with argument conversions
1551          * as though doing an assignment.
1552          */
1553         return (void *) realloc( (char *) ptr, size );
1554         }
1556 #ifdef YY_USE_PROTOS
1557 static void yy_flex_free( void *ptr )
1558 #else
1559 static void yy_flex_free( ptr )
1560 void *ptr;
1561 #endif
1562         {
1563         free( ptr );
1564         }
1566 #if YY_MAIN
1567 int main()
1568         {
1569         yylex();
1570         return 0;
1571         }
1572 #endif