Update the agp(4) code to the latest one from FreeBSD HEAD. This brings in
[dragonfly/port-amd64.git] / usr.bin / lex / flex.skl
blob88757e6612b0159e87bbe4f68a236436743c7df1
1 /* A lexical scanner generated by flex */
3 /* Scanner skeleton version:
4  * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
5  * $FreeBSD: src/usr.bin/lex/flex.skl,v 1.4 1999/10/27 07:56:44 obrien Exp $
6  * $DragonFly: src/usr.bin/lex/flex.skl,v 1.6 2006/06/11 12:57:31 joerg Exp $
7  */
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
14 #include <stdio.h>
18 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
19 #ifdef c_plusplus
20 #ifndef __cplusplus
21 #define __cplusplus
22 #endif
23 #endif
26 #ifdef __cplusplus
28 #include <stdlib.h>
30 #include <iosfwd>
31 using namespace std;
33 #include <unistd.h>
35 /* Use prototypes in function declarations. */
36 #define YY_USE_PROTOS
38 /* The "const" storage-class-modifier is valid. */
39 #define YY_USE_CONST
41 #else   /* ! __cplusplus */
43 #include <unistd.h>
45 #if __STDC__
47 #define YY_USE_PROTOS
48 #define YY_USE_CONST
50 #endif  /* __STDC__ */
51 #endif  /* ! __cplusplus */
53 #ifdef YY_USE_CONST
54 #define yyconst const
55 #else
56 #define yyconst
57 #endif
60 #ifdef YY_USE_PROTOS
61 #define YY_PROTO(proto) proto
62 #else
63 #define YY_PROTO(proto) ()
64 #endif
66 /* Returned upon end-of-file. */
67 #define YY_NULL 0
69 /* Promotes a possibly negative, possibly signed char to an unsigned
70  * integer for use as an array index.  If the signed char is negative,
71  * we want to instead treat it as an 8-bit unsigned char, hence the
72  * double cast.
73  */
74 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
76 /* Enter a start condition.  This macro really ought to take a parameter,
77  * but we do it the disgusting crufty way forced on us by the ()-less
78  * definition of BEGIN.
79  */
80 #define BEGIN yy_start = 1 + 2 *
82 /* Translate the current start state into a value that can be later handed
83  * to BEGIN to return to the state.  The YYSTATE alias is for lex
84  * compatibility.
85  */
86 #define YY_START ((yy_start - 1) / 2)
87 #define YYSTATE YY_START
89 /* Action number for EOF rule of a given start state. */
90 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
92 /* Special action meaning "start processing a new file". */
93 #define YY_NEW_FILE yyrestart( yyin )
95 #define YY_END_OF_BUFFER_CHAR 0
97 /* Size of default input buffer. */
98 #define YY_BUF_SIZE 16384
100 typedef struct yy_buffer_state *YY_BUFFER_STATE;
102 extern int yyleng;
104 extern FILE *yyin, *yyout;
107 #define EOB_ACT_CONTINUE_SCAN 0
108 #define EOB_ACT_END_OF_FILE 1
109 #define EOB_ACT_LAST_MATCH 2
111 /* The funky do-while in the following #define is used to turn the definition
112  * int a single C statement (which needs a semi-colon terminator).  This
113  * avoids problems with code like:
115  *      if ( condition_holds )
116  *              yyless( 5 );
117  *      else
118  *              do_something_else();
120  * Prior to using the do-while the compiler would get upset at the
121  * "else" because it interpreted the "if" statement as being all
122  * done when it reached the ';' after the yyless() call.
123  */
125 /* Return all but the first 'n' matched characters back to the input stream. */
127 #define yyless(n) \
128         do \
129                 { \
130                 /* Undo effects of setting up yytext. */ \
131                 *yy_cp = yy_hold_char; \
132                 YY_RESTORE_YY_MORE_OFFSET \
133                 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
134                 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
135                 } \
136         while ( 0 )
138 #define unput(c) yyunput( c, yytext_ptr )
140 /* The following is because we cannot portably get our hands on size_t
141  * (without autoconf's help, which isn't available because we want
142  * flex-generated scanners to compile on their own).
143  */
144 typedef unsigned int yy_size_t;
147 struct yy_buffer_state
148         {
150         FILE *yy_input_file;
152         istream* yy_input_file;
155         char *yy_ch_buf;                /* input buffer */
156         char *yy_buf_pos;               /* current position in input buffer */
158         /* Size of input buffer in bytes, not including room for EOB
159          * characters.
160          */
161         yy_size_t yy_buf_size;
163         /* Number of characters read into yy_ch_buf, not including EOB
164          * characters.
165          */
166         int yy_n_chars;
168         /* Whether we "own" the buffer - i.e., we know we created it,
169          * and can realloc() it to grow it, and should free() it to
170          * delete it.
171          */
172         int yy_is_our_buffer;
174         /* Whether this is an "interactive" input source; if so, and
175          * if we're using stdio for input, then we want to use getc()
176          * instead of fread(), to make sure we stop fetching input after
177          * each newline.
178          */
179         int yy_is_interactive;
181         /* Whether we're considered to be at the beginning of a line.
182          * If so, '^' rules will be active on the next match, otherwise
183          * not.
184          */
185         int yy_at_bol;
187         /* Whether to try to fill the input buffer when we reach the
188          * end of it.
189          */
190         int yy_fill_buffer;
192         int yy_buffer_status;
193 #define YY_BUFFER_NEW 0
194 #define YY_BUFFER_NORMAL 1
195         /* When an EOF's been seen but there's still some text to process
196          * then we mark the buffer as YY_EOF_PENDING, to indicate that we
197          * shouldn't try reading from the input source any more.  We might
198          * still have a bunch of tokens to match, though, because of
199          * possible backing-up.
200          *
201          * When we actually see the EOF, we change the status to "new"
202          * (via yyrestart()), so that the user can continue scanning by
203          * just pointing yyin at a new input file.
204          */
205 #define YY_BUFFER_EOF_PENDING 2
206         };
208 %- Standard (non-C++) definition
209 static YY_BUFFER_STATE yy_current_buffer = 0;
212 /* We provide macros for accessing buffer states in case in the
213  * future we want to put the buffer states in a more general
214  * "scanner state".
215  */
216 #define YY_CURRENT_BUFFER yy_current_buffer
219 %- Standard (non-C++) definition
220 /* yy_hold_char holds the character lost when yytext is formed. */
221 static char yy_hold_char;
223 static int yy_n_chars;          /* number of characters read into yy_ch_buf */
226 int yyleng;
228 /* Points to current character in buffer. */
229 static char *yy_c_buf_p = (char *) 0;
230 static int yy_init = 1;         /* whether we need to initialize */
231 static int yy_start = 0;        /* start state number */
233 /* Flag which is used to allow yywrap()'s to do buffer switches
234  * instead of setting up a fresh yyin.  A bit of a hack ...
235  */
236 static int yy_did_buffer_switch_on_eof;
238 void yyrestart YY_PROTO(( FILE *input_file ));
240 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
241 void yy_load_buffer_state YY_PROTO(( void ));
242 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
243 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
244 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
245 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
246 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
248 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
249 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
250 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
253 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
254 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
255 static void yy_flex_free YY_PROTO(( void * ));
257 #define yy_new_buffer yy_create_buffer
259 #define yy_set_interactive(is_interactive) \
260         { \
261         if ( ! yy_current_buffer ) \
262                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
263         yy_current_buffer->yy_is_interactive = is_interactive; \
264         }
266 #define yy_set_bol(at_bol) \
267         { \
268         if ( ! yy_current_buffer ) \
269                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
270         yy_current_buffer->yy_at_bol = at_bol; \
271         }
273 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
275 %% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
277 %- Standard (non-C++) definition
278 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
279 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
280 static int yy_get_next_buffer YY_PROTO(( void ));
281 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
284 /* Done after the current pattern has been matched and before the
285  * corresponding action - sets up yytext.
286  */
287 #define YY_DO_BEFORE_ACTION \
288         yytext_ptr = yy_bp; \
289 %% code to fiddle yytext and yyleng for yymore() goes here
290         yy_hold_char = *yy_cp; \
291         *yy_cp = '\0'; \
292 %% code to copy yytext_ptr to yytext[] goes here, if %array
293         yy_c_buf_p = yy_cp;
295 %% data tables for the DFA and the user's section 1 definitions go here
297 /* Macros after this point can all be overridden by user definitions in
298  * section 1.
299  */
301 #ifndef YY_SKIP_YYWRAP
302 #ifdef __cplusplus
303 extern "C" int yywrap YY_PROTO(( void ));
304 #else
305 extern int yywrap YY_PROTO(( void ));
306 #endif
307 #endif
310 #ifndef YY_NO_UNPUT
311 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
312 #endif
315 #ifndef yytext_ptr
316 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
317 #endif
319 #ifdef YY_NEED_STRLEN
320 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
321 #endif
323 #ifndef YY_NO_INPUT
324 %- Standard (non-C++) definition
325 #ifdef __cplusplus
326 static int yyinput YY_PROTO(( void ));
327 #else
328 static int input YY_PROTO(( void ));
329 #endif
331 #endif
333 #if YY_STACK_USED
334 static int yy_start_stack_ptr = 0;
335 static int yy_start_stack_depth = 0;
336 static int *yy_start_stack = 0;
337 #ifndef YY_NO_PUSH_STATE
338 static void yy_push_state YY_PROTO(( int new_state ));
339 #endif
340 #ifndef YY_NO_POP_STATE
341 static void yy_pop_state YY_PROTO(( void ));
342 #endif
343 #ifndef YY_NO_TOP_STATE
344 static int yy_top_state YY_PROTO(( void ));
345 #endif
347 #else
348 #define YY_NO_PUSH_STATE 1
349 #define YY_NO_POP_STATE 1
350 #define YY_NO_TOP_STATE 1
351 #endif
353 #ifdef YY_MALLOC_DECL
354 YY_MALLOC_DECL
355 #else
356 #if __STDC__
357 #ifndef __cplusplus
358 #include <stdlib.h>
359 #endif
360 #else
361 /* Just try to get by without declaring the routines.  This will fail
362  * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
363  * or sizeof(void*) != sizeof(int).
364  */
365 #endif
366 #endif
368 /* Amount of stuff to slurp up with each read. */
369 #ifndef YY_READ_BUF_SIZE
370 #define YY_READ_BUF_SIZE 8192
371 #endif
373 /* Copy whatever the last rule matched to the standard output. */
375 #ifndef ECHO
376 %- Standard (non-C++) definition
377 /* This used to be an fputs(), but since the string might contain NUL's,
378  * we now use fwrite().
379  */
380 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
381 %+ C++ definition
382 #define ECHO LexerOutput( yytext, yyleng )
384 #endif
386 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
387  * is returned in "result".
388  */
389 #ifndef YY_INPUT
390 #define YY_INPUT(buf,result,max_size) \
391 %% fread()/read() definition of YY_INPUT goes here unless we're doing C++
392 %+ C++ definition
393         if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
394                 YY_FATAL_ERROR( "input in flex scanner failed" );
396 #endif
398 /* No semi-colon after return; correct usage is to write "yyterminate();" -
399  * we don't want an extra ';' after the "return" because that will cause
400  * some compilers to complain about unreachable statements.
401  */
402 #ifndef yyterminate
403 #define yyterminate() return YY_NULL
404 #endif
406 /* Number of entries by which start-condition stack grows. */
407 #ifndef YY_START_STACK_INCR
408 #define YY_START_STACK_INCR 25
409 #endif
411 /* Report a fatal error. */
412 #ifndef YY_FATAL_ERROR
414 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
416 #define YY_FATAL_ERROR(msg) LexerError( msg )
418 #endif
420 /* Default declaration of generated scanner - a define so the user can
421  * easily add parameters.
422  */
423 #ifndef YY_DECL
424 %- Standard (non-C++) definition
425 #define YY_DECL int yylex YY_PROTO(( void ))
426 %+ C++ definition
427 #define YY_DECL int yyFlexLexer::yylex()
429 #endif
431 /* Code executed at the beginning of each rule, after yytext and yyleng
432  * have been set up.
433  */
434 #ifndef YY_USER_ACTION
435 #define YY_USER_ACTION
436 #endif
438 /* Code executed at the end of each rule. */
439 #ifndef YY_BREAK
440 #define YY_BREAK break;
441 #endif
443 %% YY_RULE_SETUP definition goes here
445 YY_DECL
446         {
447         register yy_state_type yy_current_state;
448         register char *yy_cp, *yy_bp;
449         register int yy_act;
451 %% user's declarations go here
453         if ( yy_init )
454                 {
455                 yy_init = 0;
457 #ifdef YY_USER_INIT
458                 YY_USER_INIT;
459 #endif
461                 if ( ! yy_start )
462                         yy_start = 1;   /* first start state */
464                 if ( ! yyin )
466                         yyin = stdin;
468                         yyin = &cin;
471                 if ( ! yyout )
473                         yyout = stdout;
475                         yyout = &cout;
478                 if ( ! yy_current_buffer )
479                         yy_current_buffer =
480                                 yy_create_buffer( yyin, YY_BUF_SIZE );
482                 yy_load_buffer_state();
483                 }
485         while ( 1 )             /* loops until end-of-file is reached */
486                 {
487 %% yymore()-related code goes here
488                 yy_cp = yy_c_buf_p;
490                 /* Support of yytext. */
491                 *yy_cp = yy_hold_char;
493                 /* yy_bp points to the position in yy_ch_buf of the start of
494                  * the current run.
495                  */
496                 yy_bp = yy_cp;
498 %% code to set up and find next match goes here
500 yy_find_action:
501 %% code to find the action number goes here
503                 YY_DO_BEFORE_ACTION;
505 %% code for yylineno update goes here
507 do_action:      /* This label is used only to access EOF actions. */
509 %% debug code goes here
511                 switch ( yy_act )
512         { /* beginning of action switch */
513 %% actions go here
515         case YY_END_OF_BUFFER:
516                 {
517                 /* Amount of text matched not including the EOB char. */
518                 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
520                 /* Undo the effects of YY_DO_BEFORE_ACTION. */
521                 *yy_cp = yy_hold_char;
522                 YY_RESTORE_YY_MORE_OFFSET
524                 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
525                         {
526                         /* We're scanning a new file or input source.  It's
527                          * possible that this happened because the user
528                          * just pointed yyin at a new source and called
529                          * yylex().  If so, then we have to assure
530                          * consistency between yy_current_buffer and our
531                          * globals.  Here is the right place to do so, because
532                          * this is the first action (other than possibly a
533                          * back-up) that will match for the new input source.
534                          */
535                         yy_n_chars = yy_current_buffer->yy_n_chars;
536                         yy_current_buffer->yy_input_file = yyin;
537                         yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
538                         }
540                 /* Note that here we test for yy_c_buf_p "<=" to the position
541                  * of the first EOB in the buffer, since yy_c_buf_p will
542                  * already have been incremented past the NUL character
543                  * (since all states make transitions on EOB to the
544                  * end-of-buffer state).  Contrast this with the test
545                  * in input().
546                  */
547                 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
548                         { /* This was really a NUL. */
549                         yy_state_type yy_next_state;
551                         yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
553                         yy_current_state = yy_get_previous_state();
555                         /* Okay, we're now positioned to make the NUL
556                          * transition.  We couldn't have
557                          * yy_get_previous_state() go ahead and do it
558                          * for us because it doesn't know how to deal
559                          * with the possibility of jamming (and we don't
560                          * want to build jamming into it because then it
561                          * will run more slowly).
562                          */
564                         yy_next_state = yy_try_NUL_trans( yy_current_state );
566                         yy_bp = yytext_ptr + YY_MORE_ADJ;
568                         if ( yy_next_state )
569                                 {
570                                 /* Consume the NUL. */
571                                 yy_cp = ++yy_c_buf_p;
572                                 yy_current_state = yy_next_state;
573                                 goto yy_match;
574                                 }
576                         else
577                                 {
578 %% code to do back-up for compressed tables and set up yy_cp goes here
579                                 goto yy_find_action;
580                                 }
581                         }
583                 else switch ( yy_get_next_buffer() )
584                         {
585                         case EOB_ACT_END_OF_FILE:
586                                 {
587                                 yy_did_buffer_switch_on_eof = 0;
589                                 if ( yywrap() )
590                                         {
591                                         /* Note: because we've taken care in
592                                          * yy_get_next_buffer() to have set up
593                                          * yytext, we can now set up
594                                          * yy_c_buf_p so that if some total
595                                          * hoser (like flex itself) wants to
596                                          * call the scanner after we return the
597                                          * YY_NULL, it'll still work - another
598                                          * YY_NULL will get returned.
599                                          */
600                                         yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
602                                         yy_act = YY_STATE_EOF(YY_START);
603                                         goto do_action;
604                                         }
606                                 else
607                                         {
608                                         if ( ! yy_did_buffer_switch_on_eof )
609                                                 YY_NEW_FILE;
610                                         }
611                                 break;
612                                 }
614                         case EOB_ACT_CONTINUE_SCAN:
615                                 yy_c_buf_p =
616                                         yytext_ptr + yy_amount_of_matched_text;
618                                 yy_current_state = yy_get_previous_state();
620                                 yy_cp = yy_c_buf_p;
621                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
622                                 goto yy_match;
624                         case EOB_ACT_LAST_MATCH:
625                                 yy_c_buf_p =
626                                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
628                                 yy_current_state = yy_get_previous_state();
630                                 yy_cp = yy_c_buf_p;
631                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
632                                 goto yy_find_action;
633                         }
634                 break;
635                 }
637         default:
638                 YY_FATAL_ERROR(
639                         "fatal flex scanner internal error--no action found" );
640         } /* end of action switch */
641                 } /* end of scanning one token */
642         } /* end of yylex */
645 yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
646         {
647         yyin = arg_yyin;
648         yyout = arg_yyout;
649         yy_c_buf_p = 0;
650         yy_init = 1;
651         yy_start = 0;
652         yy_flex_debug = 0;
653         yylineno = 1;   // this will only get updated if %option yylineno
655         yy_did_buffer_switch_on_eof = 0;
657         yy_looking_for_trail_begin = 0;
658         yy_more_flag = 0;
659         yy_more_len = 0;
660         yy_more_offset = yy_prev_more_offset = 0;
662         yy_start_stack_ptr = yy_start_stack_depth = 0;
663         yy_start_stack = 0;
665         yy_current_buffer = 0;
667 #ifdef YY_USES_REJECT
668         yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
669 #else
670         yy_state_buf = 0;
671 #endif
672         }
674 yyFlexLexer::~yyFlexLexer()
675         {
676         delete yy_state_buf;
677         yy_delete_buffer( yy_current_buffer );
678         }
680 void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
681         {
682         if ( new_in )
683                 {
684                 yy_delete_buffer( yy_current_buffer );
685                 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
686                 }
688         if ( new_out )
689                 yyout = new_out;
690         }
692 #ifdef YY_INTERACTIVE
693 int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
694 #else
695 int yyFlexLexer::LexerInput( char* buf, int max_size )
696 #endif
697         {
698         if ( yyin->eof() || yyin->fail() )
699                 return 0;
701 #ifdef YY_INTERACTIVE
702         yyin->get( buf[0] );
704         if ( yyin->eof() )
705                 return 0;
707         if ( yyin->bad() )
708                 return -1;
710         return 1;
712 #else
713         (void) yyin->read( buf, max_size );
715         if ( yyin->bad() )
716                 return -1;
717         else
718                 return yyin->gcount();
719 #endif
720         }
722 void yyFlexLexer::LexerOutput( const char* buf, int size )
723         {
724         (void) yyout->write( buf, size );
725         }
728 /* yy_get_next_buffer - try to read in a new buffer
730  * Returns a code representing an action:
731  *      EOB_ACT_LAST_MATCH -
732  *      EOB_ACT_CONTINUE_SCAN - continue scanning from current position
733  *      EOB_ACT_END_OF_FILE - end of file
734  */
737 static int yy_get_next_buffer()
739 int yyFlexLexer::yy_get_next_buffer()
741         {
742         register char *dest = yy_current_buffer->yy_ch_buf;
743         register char *source = yytext_ptr;
744         register int number_to_move, i;
745         int ret_val;
747         if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
748                 YY_FATAL_ERROR(
749                 "fatal flex scanner internal error--end of buffer missed" );
751         if ( yy_current_buffer->yy_fill_buffer == 0 )
752                 { /* Don't try to fill the buffer, so this is an EOF. */
753                 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
754                         {
755                         /* We matched a single character, the EOB, so
756                          * treat this as a final EOF.
757                          */
758                         return EOB_ACT_END_OF_FILE;
759                         }
761                 else
762                         {
763                         /* We matched some text prior to the EOB, first
764                          * process it.
765                          */
766                         return EOB_ACT_LAST_MATCH;
767                         }
768                 }
770         /* Try to read more data. */
772         /* First move last chars to start of buffer. */
773         number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
775         for ( i = 0; i < number_to_move; ++i )
776                 *(dest++) = *(source++);
778         if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
779                 /* don't do the read, it's not guaranteed to return an EOF,
780                  * just force an EOF
781                  */
782                 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
784         else
785                 {
786                 int num_to_read =
787                         yy_current_buffer->yy_buf_size - number_to_move - 1;
789                 while ( num_to_read <= 0 )
790                         { /* Not enough room in the buffer - grow it. */
791 #ifdef YY_USES_REJECT
792                         YY_FATAL_ERROR(
793 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
794 #else
796                         /* just a shorter name for the current buffer */
797                         YY_BUFFER_STATE b = yy_current_buffer;
799                         int yy_c_buf_p_offset =
800                                 (int) (yy_c_buf_p - b->yy_ch_buf);
802                         if ( b->yy_is_our_buffer )
803                                 {
804                                 int new_size = b->yy_buf_size * 2;
806                                 if ( new_size <= 0 )
807                                         b->yy_buf_size += b->yy_buf_size / 8;
808                                 else
809                                         b->yy_buf_size *= 2;
811                                 b->yy_ch_buf = (char *)
812                                         /* Include room in for 2 EOB chars. */
813                                         yy_flex_realloc( (void *) b->yy_ch_buf,
814                                                          b->yy_buf_size + 2 );
815                                 }
816                         else
817                                 /* Can't grow it, we don't own it. */
818                                 b->yy_ch_buf = 0;
820                         if ( ! b->yy_ch_buf )
821                                 YY_FATAL_ERROR(
822                                 "fatal error - scanner input buffer overflow" );
824                         yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
826                         num_to_read = yy_current_buffer->yy_buf_size -
827                                                 number_to_move - 1;
828 #endif
829                         }
831                 if ( num_to_read > YY_READ_BUF_SIZE )
832                         num_to_read = YY_READ_BUF_SIZE;
834                 /* Read in more data. */
835                 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
836                         yy_n_chars, num_to_read );
838                 yy_current_buffer->yy_n_chars = yy_n_chars;
839                 }
841         if ( yy_n_chars == 0 )
842                 {
843                 if ( number_to_move == YY_MORE_ADJ )
844                         {
845                         ret_val = EOB_ACT_END_OF_FILE;
846                         yyrestart( yyin );
847                         }
849                 else
850                         {
851                         ret_val = EOB_ACT_LAST_MATCH;
852                         yy_current_buffer->yy_buffer_status =
853                                 YY_BUFFER_EOF_PENDING;
854                         }
855                 }
857         else
858                 ret_val = EOB_ACT_CONTINUE_SCAN;
860         yy_n_chars += number_to_move;
861         yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
862         yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
864         yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
866         return ret_val;
867         }
870 /* yy_get_previous_state - get the state just before the EOB char was reached */
873 static yy_state_type yy_get_previous_state()
875 yy_state_type yyFlexLexer::yy_get_previous_state()
877         {
878         register yy_state_type yy_current_state;
879         register char *yy_cp;
881 %% code to get the start state into yy_current_state goes here
883         for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
884                 {
885 %% code to find the next state goes here
886                 }
888         return yy_current_state;
889         }
892 /* yy_try_NUL_trans - try to make a transition on the NUL character
894  * synopsis
895  *      next_state = yy_try_NUL_trans( current_state );
896  */
899 #ifdef YY_USE_PROTOS
900 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
901 #else
902 static yy_state_type yy_try_NUL_trans( yy_current_state )
903 yy_state_type yy_current_state;
904 #endif
906 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
908         {
909         register int yy_is_jam;
910 %% code to find the next state, and perhaps do backing up, goes here
912         return yy_is_jam ? 0 : yy_current_state;
913         }
917 #ifndef YY_NO_UNPUT
918 #ifdef YY_USE_PROTOS
919 static void yyunput( int c, register char *yy_bp )
920 #else
921 static void yyunput( c, yy_bp )
922 int c;
923 register char *yy_bp;
924 #endif
926 void yyFlexLexer::yyunput( int c, register char* yy_bp )
928         {
929         register char *yy_cp = yy_c_buf_p;
931         /* undo effects of setting up yytext */
932         *yy_cp = yy_hold_char;
934         if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
935                 { /* need to shift things up to make room */
936                 /* +2 for EOB chars. */
937                 register int number_to_move = yy_n_chars + 2;
938                 register char *dest = &yy_current_buffer->yy_ch_buf[
939                                         yy_current_buffer->yy_buf_size + 2];
940                 register char *source =
941                                 &yy_current_buffer->yy_ch_buf[number_to_move];
943                 while ( source > yy_current_buffer->yy_ch_buf )
944                         *--dest = *--source;
946                 yy_cp += (int) (dest - source);
947                 yy_bp += (int) (dest - source);
948                 yy_current_buffer->yy_n_chars =
949                         yy_n_chars = yy_current_buffer->yy_buf_size;
951                 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
952                         YY_FATAL_ERROR( "flex scanner push-back overflow" );
953                 }
955         *--yy_cp = (char) c;
957 %% update yylineno here
959         yytext_ptr = yy_bp;
960         yy_hold_char = *yy_cp;
961         yy_c_buf_p = yy_cp;
962         }
964 #endif  /* ifndef YY_NO_UNPUT */
969 #ifdef __cplusplus
970 static int yyinput()
971 #else
972 static int input()
973 #endif
975 int yyFlexLexer::yyinput()
977         {
978         int c;
980         *yy_c_buf_p = yy_hold_char;
982         if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
983                 {
984                 /* yy_c_buf_p now points to the character we want to return.
985                  * If this occurs *before* the EOB characters, then it's a
986                  * valid NUL; if not, then we've hit the end of the buffer.
987                  */
988                 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
989                         /* This was really a NUL. */
990                         *yy_c_buf_p = '\0';
992                 else
993                         { /* need more input */
994                         int offset = yy_c_buf_p - yytext_ptr;
995                         ++yy_c_buf_p;
997                         switch ( yy_get_next_buffer() )
998                                 {
999                                 case EOB_ACT_LAST_MATCH:
1000                                         /* This happens because yy_g_n_b()
1001                                          * sees that we've accumulated a
1002                                          * token and flags that we need to
1003                                          * try matching the token before
1004                                          * proceeding.  But for input(),
1005                                          * there's no matching to consider.
1006                                          * So convert the EOB_ACT_LAST_MATCH
1007                                          * to EOB_ACT_END_OF_FILE.
1008                                          */
1010                                         /* Reset buffer status. */
1011                                         yyrestart( yyin );
1013                                         /* fall through */
1015                                 case EOB_ACT_END_OF_FILE:
1016                                         {
1017                                         if ( yywrap() )
1018                                                 return EOF;
1020                                         if ( ! yy_did_buffer_switch_on_eof )
1021                                                 YY_NEW_FILE;
1022 #ifdef __cplusplus
1023                                         return yyinput();
1024 #else
1025                                         return input();
1026 #endif
1027                                         }
1029                                 case EOB_ACT_CONTINUE_SCAN:
1030                                         yy_c_buf_p = yytext_ptr + offset;
1031                                         break;
1032                                 }
1033                         }
1034                 }
1036         c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
1037         *yy_c_buf_p = '\0';     /* preserve yytext */
1038         yy_hold_char = *++yy_c_buf_p;
1040 %% update BOL and yylineno
1042         return c;
1043         }
1047 #ifdef YY_USE_PROTOS
1048 void yyrestart( FILE *input_file )
1049 #else
1050 void yyrestart( input_file )
1051 FILE *input_file;
1052 #endif
1054 void yyFlexLexer::yyrestart( istream* input_file )
1056         {
1057         if ( ! yy_current_buffer )
1058                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1060         yy_init_buffer( yy_current_buffer, input_file );
1061         yy_load_buffer_state();
1062         }
1066 #ifdef YY_USE_PROTOS
1067 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1068 #else
1069 void yy_switch_to_buffer( new_buffer )
1070 YY_BUFFER_STATE new_buffer;
1071 #endif
1073 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1075         {
1076         if ( yy_current_buffer == new_buffer )
1077                 return;
1079         if ( yy_current_buffer )
1080                 {
1081                 /* Flush out information for old buffer. */
1082                 *yy_c_buf_p = yy_hold_char;
1083                 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1084                 yy_current_buffer->yy_n_chars = yy_n_chars;
1085                 }
1087         yy_current_buffer = new_buffer;
1088         yy_load_buffer_state();
1090         /* We don't actually know whether we did this switch during
1091          * EOF (yywrap()) processing, but the only time this flag
1092          * is looked at is after yywrap() is called, so it's safe
1093          * to go ahead and always set it.
1094          */
1095         yy_did_buffer_switch_on_eof = 1;
1096         }
1100 #ifdef YY_USE_PROTOS
1101 void yy_load_buffer_state( void )
1102 #else
1103 void yy_load_buffer_state()
1104 #endif
1106 void yyFlexLexer::yy_load_buffer_state()
1108         {
1109         yy_n_chars = yy_current_buffer->yy_n_chars;
1110         yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1111         yyin = yy_current_buffer->yy_input_file;
1112         yy_hold_char = *yy_c_buf_p;
1113         }
1117 #ifdef YY_USE_PROTOS
1118 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1119 #else
1120 YY_BUFFER_STATE yy_create_buffer( file, size )
1121 FILE *file;
1122 int size;
1123 #endif
1125 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
1127         {
1128         YY_BUFFER_STATE b;
1130         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1131         if ( ! b )
1132                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1134         b->yy_buf_size = size;
1136         /* yy_ch_buf has to be 2 characters longer than the size given because
1137          * we need to put in 2 end-of-buffer characters.
1138          */
1139         b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1140         if ( ! b->yy_ch_buf )
1141                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1143         b->yy_is_our_buffer = 1;
1145         yy_init_buffer( b, file );
1147         return b;
1148         }
1152 #ifdef YY_USE_PROTOS
1153 void yy_delete_buffer( YY_BUFFER_STATE b )
1154 #else
1155 void yy_delete_buffer( b )
1156 YY_BUFFER_STATE b;
1157 #endif
1159 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
1161         {
1162         if ( ! b )
1163                 return;
1165         if ( b == yy_current_buffer )
1166                 yy_current_buffer = (YY_BUFFER_STATE) 0;
1168         if ( b->yy_is_our_buffer )
1169                 yy_flex_free( (void *) b->yy_ch_buf );
1171         yy_flex_free( (void *) b );
1172         }
1176 #ifdef YY_USE_PROTOS
1177 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1178 #else
1179 void yy_init_buffer( b, file )
1180 YY_BUFFER_STATE b;
1181 FILE *file;
1182 #endif
1185 extern "C" int isatty YY_PROTO(( int ));
1186 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
1189         {
1190         yy_flush_buffer( b );
1192         b->yy_input_file = file;
1193         b->yy_fill_buffer = 1;
1196 #if YY_ALWAYS_INTERACTIVE
1197         b->yy_is_interactive = 1;
1198 #else
1199 #if YY_NEVER_INTERACTIVE
1200         b->yy_is_interactive = 0;
1201 #else
1202         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1203 #endif
1204 #endif
1206         b->yy_is_interactive = 0;
1208         }
1212 #ifdef YY_USE_PROTOS
1213 void yy_flush_buffer( YY_BUFFER_STATE b )
1214 #else
1215 void yy_flush_buffer( b )
1216 YY_BUFFER_STATE b;
1217 #endif
1220 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
1222         {
1223         if ( ! b )
1224                 return;
1226         b->yy_n_chars = 0;
1228         /* We always need two end-of-buffer characters.  The first causes
1229          * a transition to the end-of-buffer state.  The second causes
1230          * a jam in that state.
1231          */
1232         b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1233         b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1235         b->yy_buf_pos = &b->yy_ch_buf[0];
1237         b->yy_at_bol = 1;
1238         b->yy_buffer_status = YY_BUFFER_NEW;
1240         if ( b == yy_current_buffer )
1241                 yy_load_buffer_state();
1242         }
1246 #ifndef YY_NO_SCAN_BUFFER
1248 #ifdef YY_USE_PROTOS
1249 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1250 #else
1251 YY_BUFFER_STATE yy_scan_buffer( base, size )
1252 char *base;
1253 yy_size_t size;
1254 #endif
1255         {
1256         YY_BUFFER_STATE b;
1258         if ( size < 2 ||
1259              base[size-2] != YY_END_OF_BUFFER_CHAR ||
1260              base[size-1] != YY_END_OF_BUFFER_CHAR )
1261                 /* They forgot to leave room for the EOB's. */
1262                 return 0;
1264         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1265         if ( ! b )
1266                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1268         b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
1269         b->yy_buf_pos = b->yy_ch_buf = base;
1270         b->yy_is_our_buffer = 0;
1271         b->yy_input_file = 0;
1272         b->yy_n_chars = b->yy_buf_size;
1273         b->yy_is_interactive = 0;
1274         b->yy_at_bol = 1;
1275         b->yy_fill_buffer = 0;
1276         b->yy_buffer_status = YY_BUFFER_NEW;
1278         yy_switch_to_buffer( b );
1280         return b;
1281         }
1283 #endif
1286 #ifndef YY_NO_SCAN_STRING
1288 #ifdef YY_USE_PROTOS
1289 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1290 #else
1291 YY_BUFFER_STATE yy_scan_string( yy_str )
1292 yyconst char *yy_str;
1293 #endif
1294         {
1295         int len;
1296         for ( len = 0; yy_str[len]; ++len )
1297                 ;
1299         return yy_scan_bytes( yy_str, len );
1300         }
1302 #endif
1305 #ifndef YY_NO_SCAN_BYTES
1307 #ifdef YY_USE_PROTOS
1308 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1309 #else
1310 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1311 yyconst char *bytes;
1312 int len;
1313 #endif
1314         {
1315         YY_BUFFER_STATE b;
1316         char *buf;
1317         yy_size_t n;
1318         int i;
1320         /* Get memory for full buffer, including space for trailing EOB's. */
1321         n = len + 2;
1322         buf = (char *) yy_flex_alloc( n );
1323         if ( ! buf )
1324                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1326         for ( i = 0; i < len; ++i )
1327                 buf[i] = bytes[i];
1329         buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1331         b = yy_scan_buffer( buf, n );
1332         if ( ! b )
1333                 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1335         /* It's okay to grow etc. this buffer, and we should throw it
1336          * away when we're done.
1337          */
1338         b->yy_is_our_buffer = 1;
1340         return b;
1341         }
1343 #endif
1346 #ifndef YY_NO_PUSH_STATE
1348 #ifdef YY_USE_PROTOS
1349 static void yy_push_state( int new_state )
1350 #else
1351 static void yy_push_state( new_state )
1352 int new_state;
1353 #endif
1355 void yyFlexLexer::yy_push_state( int new_state )
1357         {
1358         if ( yy_start_stack_ptr >= yy_start_stack_depth )
1359                 {
1360                 yy_size_t new_size;
1362                 yy_start_stack_depth += YY_START_STACK_INCR;
1363                 new_size = yy_start_stack_depth * sizeof( int );
1365                 if ( ! yy_start_stack )
1366                         yy_start_stack = (int *) yy_flex_alloc( new_size );
1368                 else
1369                         yy_start_stack = (int *) yy_flex_realloc(
1370                                         (void *) yy_start_stack, new_size );
1372                 if ( ! yy_start_stack )
1373                         YY_FATAL_ERROR(
1374                         "out of memory expanding start-condition stack" );
1375                 }
1377         yy_start_stack[yy_start_stack_ptr++] = YY_START;
1379         BEGIN(new_state);
1380         }
1381 #endif
1384 #ifndef YY_NO_POP_STATE
1386 static void yy_pop_state()
1388 void yyFlexLexer::yy_pop_state()
1390         {
1391         if ( --yy_start_stack_ptr < 0 )
1392                 YY_FATAL_ERROR( "start-condition stack underflow" );
1394         BEGIN(yy_start_stack[yy_start_stack_ptr]);
1395         }
1396 #endif
1399 #ifndef YY_NO_TOP_STATE
1401 static int yy_top_state()
1403 int yyFlexLexer::yy_top_state()
1405         {
1406         return yy_start_stack[yy_start_stack_ptr - 1];
1407         }
1408 #endif
1410 #ifndef YY_EXIT_FAILURE
1411 #define YY_EXIT_FAILURE 2
1412 #endif
1415 #ifdef YY_USE_PROTOS
1416 static void yy_fatal_error( yyconst char msg[] )
1417 #else
1418 static void yy_fatal_error( msg )
1419 char msg[];
1420 #endif
1421         {
1422         (void) fprintf( stderr, "%s\n", msg );
1423         exit( YY_EXIT_FAILURE );
1424         }
1428 void yyFlexLexer::LexerError( yyconst char msg[] )
1429         {
1430         cerr << msg << '\n';
1431         exit( YY_EXIT_FAILURE );
1432         }
1436 /* Redefine yyless() so it works in section 3 code. */
1438 #undef yyless
1439 #define yyless(n) \
1440         do \
1441                 { \
1442                 /* Undo effects of setting up yytext. */ \
1443                 yytext[yyleng] = yy_hold_char; \
1444                 yy_c_buf_p = yytext + n; \
1445                 yy_hold_char = *yy_c_buf_p; \
1446                 *yy_c_buf_p = '\0'; \
1447                 yyleng = n; \
1448                 } \
1449         while ( 0 )
1452 /* Internal utility routines. */
1454 #ifndef yytext_ptr
1455 #ifdef YY_USE_PROTOS
1456 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1457 #else
1458 static void yy_flex_strncpy( s1, s2, n )
1459 char *s1;
1460 yyconst char *s2;
1461 int n;
1462 #endif
1463         {
1464         register int i;
1465         for ( i = 0; i < n; ++i )
1466                 s1[i] = s2[i];
1467         }
1468 #endif
1470 #ifdef YY_NEED_STRLEN
1471 #ifdef YY_USE_PROTOS
1472 static int yy_flex_strlen( yyconst char *s )
1473 #else
1474 static int yy_flex_strlen( s )
1475 yyconst char *s;
1476 #endif
1477         {
1478         register int n;
1479         for ( n = 0; s[n]; ++n )
1480                 ;
1482         return n;
1483         }
1484 #endif
1487 #ifdef YY_USE_PROTOS
1488 static void *yy_flex_alloc( yy_size_t size )
1489 #else
1490 static void *yy_flex_alloc( size )
1491 yy_size_t size;
1492 #endif
1493         {
1494         return (void *) malloc( size );
1495         }
1497 #ifdef YY_USE_PROTOS
1498 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1499 #else
1500 static void *yy_flex_realloc( ptr, size )
1501 void *ptr;
1502 yy_size_t size;
1503 #endif
1504         {
1505         /* The cast to (char *) in the following accommodates both
1506          * implementations that use char* generic pointers, and those
1507          * that use void* generic pointers.  It works with the latter
1508          * because both ANSI C and C++ allow castless assignment from
1509          * any pointer type to void*, and deal with argument conversions
1510          * as though doing an assignment.
1511          */
1512         return (void *) realloc( (char *) ptr, size );
1513         }
1515 #ifdef YY_USE_PROTOS
1516 static void yy_flex_free( void *ptr )
1517 #else
1518 static void yy_flex_free( ptr )
1519 void *ptr;
1520 #endif
1521         {
1522         free( ptr );
1523         }
1525 #if YY_MAIN
1526 int main()
1527         {
1528         yylex();
1529         return 0;
1530         }
1531 #endif