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 $
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 5
17 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
34 /* Use prototypes in function declarations. */
37 /* The "const" storage-class-modifier is valid. */
40 #else /* ! __cplusplus */
47 #endif /* ! __cplusplus */
57 #define YY_PROTO(proto) proto
59 #define YY_PROTO(proto) ()
62 /* Returned upon end-of-file. */
65 /* Promotes a possibly negative, possibly signed char to an unsigned
66 * integer for use as an array index. If the signed char is negative,
67 * we want to instead treat it as an 8-bit unsigned char, hence the
70 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
72 /* Enter a start condition. This macro really ought to take a parameter,
73 * but we do it the disgusting crufty way forced on us by the ()-less
74 * definition of BEGIN.
76 #define BEGIN yy_start = 1 + 2 *
78 /* Translate the current start state into a value that can be later handed
79 * to BEGIN to return to the state. The YYSTATE alias is for lex
82 #define YY_START ((yy_start - 1) / 2)
83 #define YYSTATE YY_START
85 /* Action number for EOF rule of a given start state. */
86 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
88 /* Special action meaning "start processing a new file". */
89 #define YY_NEW_FILE yyrestart( yyin )
91 #define YY_END_OF_BUFFER_CHAR 0
93 /* Size of default input buffer. */
94 #define YY_BUF_SIZE 16384
96 typedef struct yy_buffer_state *YY_BUFFER_STATE;
100 extern FILE *yyin, *yyout;
103 #define EOB_ACT_CONTINUE_SCAN 0
104 #define EOB_ACT_END_OF_FILE 1
105 #define EOB_ACT_LAST_MATCH 2
107 /* The funky do-while in the following #define is used to turn the definition
108 * int a single C statement (which needs a semi-colon terminator). This
109 * avoids problems with code like:
111 * if ( condition_holds )
114 * do_something_else();
116 * Prior to using the do-while the compiler would get upset at the
117 * "else" because it interpreted the "if" statement as being all
118 * done when it reached the ';' after the yyless() call.
121 /* Return all but the first 'n' matched characters back to the input stream. */
126 /* Undo effects of setting up yytext. */ \
127 *yy_cp = yy_hold_char; \
128 YY_RESTORE_YY_MORE_OFFSET \
129 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
130 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
134 #define unput(c) yyunput( c, yytext_ptr )
136 /* The following is because we cannot portably get our hands on size_t
137 * (without autoconf's help, which isn't available because we want
138 * flex-generated scanners to compile on their own).
140 typedef unsigned int yy_size_t;
143 struct yy_buffer_state
148 istream* yy_input_file;
151 char *yy_ch_buf; /* input buffer */
152 char *yy_buf_pos; /* current position in input buffer */
154 /* Size of input buffer in bytes, not including room for EOB
157 yy_size_t yy_buf_size;
159 /* Number of characters read into yy_ch_buf, not including EOB
164 /* Whether we "own" the buffer - i.e., we know we created it,
165 * and can realloc() it to grow it, and should free() it to
168 int yy_is_our_buffer;
170 /* Whether this is an "interactive" input source; if so, and
171 * if we're using stdio for input, then we want to use getc()
172 * instead of fread(), to make sure we stop fetching input after
175 int yy_is_interactive;
177 /* Whether we're considered to be at the beginning of a line.
178 * If so, '^' rules will be active on the next match, otherwise
183 /* Whether to try to fill the input buffer when we reach the
188 int yy_buffer_status;
189 #define YY_BUFFER_NEW 0
190 #define YY_BUFFER_NORMAL 1
191 /* When an EOF's been seen but there's still some text to process
192 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
193 * shouldn't try reading from the input source any more. We might
194 * still have a bunch of tokens to match, though, because of
195 * possible backing-up.
197 * When we actually see the EOF, we change the status to "new"
198 * (via yyrestart()), so that the user can continue scanning by
199 * just pointing yyin at a new input file.
201 #define YY_BUFFER_EOF_PENDING 2
204 %- Standard (non-C++) definition
205 static YY_BUFFER_STATE yy_current_buffer = 0;
208 /* We provide macros for accessing buffer states in case in the
209 * future we want to put the buffer states in a more general
212 #define YY_CURRENT_BUFFER yy_current_buffer
215 %- Standard (non-C++) definition
216 /* yy_hold_char holds the character lost when yytext is formed. */
217 static char yy_hold_char;
219 static int yy_n_chars; /* number of characters read into yy_ch_buf */
224 /* Points to current character in buffer. */
225 static char *yy_c_buf_p = NULL;
226 static int yy_init = 1; /* whether we need to initialize */
227 static int yy_start = 0; /* start state number */
229 /* Flag which is used to allow yywrap()'s to do buffer switches
230 * instead of setting up a fresh yyin. A bit of a hack ...
232 static int yy_did_buffer_switch_on_eof;
234 void yyrestart YY_PROTO(( FILE *input_file ));
236 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
237 void yy_load_buffer_state YY_PROTO(( void ));
238 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
239 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
240 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
241 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
242 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
244 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
245 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
246 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
249 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
250 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ))
252 __attribute__((__unused__))
255 static void yy_flex_free YY_PROTO(( void * ));
257 #define yy_new_buffer yy_create_buffer
259 #define yy_set_interactive(is_interactive) \
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; \
266 #define yy_set_bol(at_bol) \
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; \
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.
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; \
292 %% code to copy yytext_ptr to yytext[] goes here, if %array
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
301 #ifndef YY_SKIP_YYWRAP
303 extern "C" int yywrap YY_PROTO(( void ));
305 extern int yywrap YY_PROTO(( void ));
311 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
316 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
319 #ifdef YY_NEED_STRLEN
320 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
324 %- Standard (non-C++) definition
326 static int yyinput YY_PROTO(( void ));
328 static int input YY_PROTO(( void ));
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 ));
340 #ifndef YY_NO_POP_STATE
341 static void yy_pop_state YY_PROTO(( void ));
343 #ifndef YY_NO_TOP_STATE
344 static int yy_top_state YY_PROTO(( void ));
348 #define YY_NO_PUSH_STATE 1
349 #define YY_NO_POP_STATE 1
350 #define YY_NO_TOP_STATE 1
353 #ifdef YY_MALLOC_DECL
361 /* Amount of stuff to slurp up with each read. */
362 #ifndef YY_READ_BUF_SIZE
363 #define YY_READ_BUF_SIZE 8192
366 /* Copy whatever the last rule matched to the standard output. */
369 %- Standard (non-C++) definition
370 /* This used to be an fputs(), but since the string might contain NUL's,
371 * we now use fwrite().
373 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
375 #define ECHO LexerOutput( yytext, yyleng )
379 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
380 * is returned in "result".
383 #define YY_INPUT(buf,result,max_size) \
384 %% fread()/read() definition of YY_INPUT goes here unless we're doing C++
386 if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
387 YY_FATAL_ERROR( "input in flex scanner failed" );
391 /* No semi-colon after return; correct usage is to write "yyterminate();" -
392 * we don't want an extra ';' after the "return" because that will cause
393 * some compilers to complain about unreachable statements.
396 #define yyterminate() return YY_NULL
399 /* Number of entries by which start-condition stack grows. */
400 #ifndef YY_START_STACK_INCR
401 #define YY_START_STACK_INCR 25
404 /* Report a fatal error. */
405 #ifndef YY_FATAL_ERROR
407 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
409 #define YY_FATAL_ERROR(msg) LexerError( msg )
413 /* Default declaration of generated scanner - a define so the user can
414 * easily add parameters.
417 %- Standard (non-C++) definition
418 #define YY_DECL int yylex YY_PROTO(( void ))
420 #define YY_DECL int yyFlexLexer::yylex()
424 /* Code executed at the beginning of each rule, after yytext and yyleng
427 #ifndef YY_USER_ACTION
428 #define YY_USER_ACTION
431 /* Code executed at the end of each rule. */
433 #define YY_BREAK break;
436 %% YY_RULE_SETUP definition goes here
440 yy_state_type yy_current_state;
444 %% user's declarations go here
455 yy_start = 1; /* first start state */
471 if ( ! yy_current_buffer )
473 yy_create_buffer( yyin, YY_BUF_SIZE );
475 yy_load_buffer_state();
478 while ( 1 ) /* loops until end-of-file is reached */
480 %% yymore()-related code goes here
483 /* Support of yytext. */
484 *yy_cp = yy_hold_char;
486 /* yy_bp points to the position in yy_ch_buf of the start of
491 %% code to set up and find next match goes here
494 %% code to find the action number goes here
498 %% code for yylineno update goes here
500 do_action: /* This label is used only to access EOF actions. */
502 %% debug code goes here
505 { /* beginning of action switch */
508 case YY_END_OF_BUFFER:
510 /* Amount of text matched not including the EOB char. */
511 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
513 /* Undo the effects of YY_DO_BEFORE_ACTION. */
514 *yy_cp = yy_hold_char;
515 YY_RESTORE_YY_MORE_OFFSET
517 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
519 /* We're scanning a new file or input source. It's
520 * possible that this happened because the user
521 * just pointed yyin at a new source and called
522 * yylex(). If so, then we have to assure
523 * consistency between yy_current_buffer and our
524 * globals. Here is the right place to do so, because
525 * this is the first action (other than possibly a
526 * back-up) that will match for the new input source.
528 yy_n_chars = yy_current_buffer->yy_n_chars;
529 yy_current_buffer->yy_input_file = yyin;
530 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
533 /* Note that here we test for yy_c_buf_p "<=" to the position
534 * of the first EOB in the buffer, since yy_c_buf_p will
535 * already have been incremented past the NUL character
536 * (since all states make transitions on EOB to the
537 * end-of-buffer state). Contrast this with the test
540 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
541 { /* This was really a NUL. */
542 yy_state_type yy_next_state;
544 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
546 yy_current_state = yy_get_previous_state();
548 /* Okay, we're now positioned to make the NUL
549 * transition. We couldn't have
550 * yy_get_previous_state() go ahead and do it
551 * for us because it doesn't know how to deal
552 * with the possibility of jamming (and we don't
553 * want to build jamming into it because then it
554 * will run more slowly).
557 yy_next_state = yy_try_NUL_trans( yy_current_state );
559 yy_bp = yytext_ptr + YY_MORE_ADJ;
563 /* Consume the NUL. */
564 yy_cp = ++yy_c_buf_p;
565 yy_current_state = yy_next_state;
571 %% code to do back-up for compressed tables and set up yy_cp goes here
576 else switch ( yy_get_next_buffer() )
578 case EOB_ACT_END_OF_FILE:
580 yy_did_buffer_switch_on_eof = 0;
584 /* Note: because we've taken care in
585 * yy_get_next_buffer() to have set up
586 * yytext, we can now set up
587 * yy_c_buf_p so that if some total
588 * hoser (like flex itself) wants to
589 * call the scanner after we return the
590 * YY_NULL, it'll still work - another
591 * YY_NULL will get returned.
593 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
595 yy_act = YY_STATE_EOF(YY_START);
601 if ( ! yy_did_buffer_switch_on_eof )
607 case EOB_ACT_CONTINUE_SCAN:
609 yytext_ptr + yy_amount_of_matched_text;
611 yy_current_state = yy_get_previous_state();
614 yy_bp = yytext_ptr + YY_MORE_ADJ;
617 case EOB_ACT_LAST_MATCH:
619 &yy_current_buffer->yy_ch_buf[yy_n_chars];
621 yy_current_state = yy_get_previous_state();
624 yy_bp = yytext_ptr + YY_MORE_ADJ;
632 "fatal flex scanner internal error--no action found" );
633 } /* end of action switch */
634 } /* end of scanning one token */
638 yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
646 yylineno = 1; // this will only get updated if %option yylineno
648 yy_did_buffer_switch_on_eof = 0;
650 yy_looking_for_trail_begin = 0;
653 yy_more_offset = yy_prev_more_offset = 0;
655 yy_start_stack_ptr = yy_start_stack_depth = 0;
658 yy_current_buffer = 0;
660 #ifdef YY_USES_REJECT
661 yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
667 yyFlexLexer::~yyFlexLexer()
670 yy_delete_buffer( yy_current_buffer );
673 void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
677 yy_delete_buffer( yy_current_buffer );
678 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
685 #ifdef YY_INTERACTIVE
686 int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
688 int yyFlexLexer::LexerInput( char* buf, int max_size )
691 if ( yyin->eof() || yyin->fail() )
694 #ifdef YY_INTERACTIVE
706 (void) yyin->read( buf, max_size );
711 return yyin->gcount();
715 void yyFlexLexer::LexerOutput( const char* buf, int size )
717 (void) yyout->write( buf, size );
721 /* yy_get_next_buffer - try to read in a new buffer
723 * Returns a code representing an action:
724 * EOB_ACT_LAST_MATCH -
725 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
726 * EOB_ACT_END_OF_FILE - end of file
731 static int yy_get_next_buffer( void )
733 static int yy_get_next_buffer()
736 int yyFlexLexer::yy_get_next_buffer()
739 char *dest = yy_current_buffer->yy_ch_buf;
740 char *source = yytext_ptr;
741 int number_to_move, i;
744 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
746 "fatal flex scanner internal error--end of buffer missed" );
748 if ( yy_current_buffer->yy_fill_buffer == 0 )
749 { /* Don't try to fill the buffer, so this is an EOF. */
750 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
752 /* We matched a single character, the EOB, so
753 * treat this as a final EOF.
755 return EOB_ACT_END_OF_FILE;
760 /* We matched some text prior to the EOB, first
763 return EOB_ACT_LAST_MATCH;
767 /* Try to read more data. */
769 /* First move last chars to start of buffer. */
770 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
772 for ( i = 0; i < number_to_move; ++i )
773 *(dest++) = *(source++);
775 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
776 /* don't do the read, it's not guaranteed to return an EOF,
779 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
784 yy_current_buffer->yy_buf_size - number_to_move - 1;
786 while ( num_to_read <= 0 )
787 { /* Not enough room in the buffer - grow it. */
788 #ifdef YY_USES_REJECT
790 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
793 /* just a shorter name for the current buffer */
794 YY_BUFFER_STATE b = yy_current_buffer;
796 int yy_c_buf_p_offset =
797 (int) (yy_c_buf_p - b->yy_ch_buf);
799 if ( b->yy_is_our_buffer )
801 int new_size = b->yy_buf_size * 2;
804 b->yy_buf_size += b->yy_buf_size / 8;
808 b->yy_ch_buf = (char *)
809 /* Include room in for 2 EOB chars. */
810 yy_flex_realloc( (void *) b->yy_ch_buf,
811 b->yy_buf_size + 2 );
814 /* Can't grow it, we don't own it. */
817 if ( ! b->yy_ch_buf )
819 "fatal error - scanner input buffer overflow" );
821 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
823 num_to_read = yy_current_buffer->yy_buf_size -
828 if ( num_to_read > YY_READ_BUF_SIZE )
829 num_to_read = YY_READ_BUF_SIZE;
831 /* Read in more data. */
832 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
833 yy_n_chars, num_to_read );
835 yy_current_buffer->yy_n_chars = yy_n_chars;
838 if ( yy_n_chars == 0 )
840 if ( number_to_move == YY_MORE_ADJ )
842 ret_val = EOB_ACT_END_OF_FILE;
848 ret_val = EOB_ACT_LAST_MATCH;
849 yy_current_buffer->yy_buffer_status =
850 YY_BUFFER_EOF_PENDING;
855 ret_val = EOB_ACT_CONTINUE_SCAN;
857 yy_n_chars += number_to_move;
858 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
859 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
861 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
867 /* yy_get_previous_state - get the state just before the EOB char was reached */
871 static yy_state_type yy_get_previous_state( void )
873 static yy_state_type yy_get_previous_state()
876 yy_state_type yyFlexLexer::yy_get_previous_state()
879 yy_state_type yy_current_state;
882 %% code to get the start state into yy_current_state goes here
884 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
886 %% code to find the next state goes here
889 return yy_current_state;
893 /* yy_try_NUL_trans - try to make a transition on the NUL character
896 * next_state = yy_try_NUL_trans( current_state );
901 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
903 static yy_state_type yy_try_NUL_trans( yy_current_state )
904 yy_state_type yy_current_state;
907 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
911 %% code to find the next state, and perhaps do backing up, goes here
913 return yy_is_jam ? 0 : yy_current_state;
920 static void yyunput( int c, char *yy_bp )
922 static void yyunput( c, yy_bp )
927 void yyFlexLexer::yyunput( int c, char* yy_bp )
930 char *yy_cp = yy_c_buf_p;
932 /* undo effects of setting up yytext */
933 *yy_cp = yy_hold_char;
935 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
936 { /* need to shift things up to make room */
937 /* +2 for EOB chars. */
938 int number_to_move = yy_n_chars + 2;
939 char *dest = &yy_current_buffer->yy_ch_buf[
940 yy_current_buffer->yy_buf_size + 2];
941 char *source = &yy_current_buffer->yy_ch_buf[number_to_move];
943 while ( source > yy_current_buffer->yy_ch_buf )
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" );
957 %% update yylineno here
960 yy_hold_char = *yy_cp;
964 #endif /* ifndef YY_NO_UNPUT */
974 static int input( void )
980 int yyFlexLexer::yyinput()
985 *yy_c_buf_p = yy_hold_char;
987 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
989 /* yy_c_buf_p now points to the character we want to return.
990 * If this occurs *before* the EOB characters, then it's a
991 * valid NUL; if not, then we've hit the end of the buffer.
993 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
994 /* This was really a NUL. */
998 { /* need more input */
999 int offset = yy_c_buf_p - yytext_ptr;
1002 switch ( yy_get_next_buffer() )
1004 case EOB_ACT_LAST_MATCH:
1005 /* This happens because yy_g_n_b()
1006 * sees that we've accumulated a
1007 * token and flags that we need to
1008 * try matching the token before
1009 * proceeding. But for input(),
1010 * there's no matching to consider.
1011 * So convert the EOB_ACT_LAST_MATCH
1012 * to EOB_ACT_END_OF_FILE.
1015 /* Reset buffer status. */
1020 case EOB_ACT_END_OF_FILE:
1025 if ( ! yy_did_buffer_switch_on_eof )
1034 case EOB_ACT_CONTINUE_SCAN:
1035 yy_c_buf_p = yytext_ptr + offset;
1041 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1042 *yy_c_buf_p = '\0'; /* preserve yytext */
1043 yy_hold_char = *++yy_c_buf_p;
1045 %% update BOL and yylineno
1050 #endif /* ifndef YY_NO_INPUT */
1055 #ifdef YY_USE_PROTOS
1056 void yyrestart( FILE *input_file )
1058 void yyrestart( input_file )
1062 void yyFlexLexer::yyrestart( istream* input_file )
1065 if ( ! yy_current_buffer )
1066 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1068 yy_init_buffer( yy_current_buffer, input_file );
1069 yy_load_buffer_state();
1074 #ifdef YY_USE_PROTOS
1075 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1077 void yy_switch_to_buffer( new_buffer )
1078 YY_BUFFER_STATE new_buffer;
1081 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1084 if ( yy_current_buffer == new_buffer )
1087 if ( yy_current_buffer )
1089 /* Flush out information for old buffer. */
1090 *yy_c_buf_p = yy_hold_char;
1091 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1092 yy_current_buffer->yy_n_chars = yy_n_chars;
1095 yy_current_buffer = new_buffer;
1096 yy_load_buffer_state();
1098 /* We don't actually know whether we did this switch during
1099 * EOF (yywrap()) processing, but the only time this flag
1100 * is looked at is after yywrap() is called, so it's safe
1101 * to go ahead and always set it.
1103 yy_did_buffer_switch_on_eof = 1;
1108 #ifdef YY_USE_PROTOS
1109 void yy_load_buffer_state( void )
1111 void yy_load_buffer_state()
1114 void yyFlexLexer::yy_load_buffer_state()
1117 yy_n_chars = yy_current_buffer->yy_n_chars;
1118 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1119 yyin = yy_current_buffer->yy_input_file;
1120 yy_hold_char = *yy_c_buf_p;
1125 #ifdef YY_USE_PROTOS
1126 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1128 YY_BUFFER_STATE yy_create_buffer( file, size )
1133 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
1138 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1140 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1142 b->yy_buf_size = size;
1144 /* yy_ch_buf has to be 2 characters longer than the size given because
1145 * we need to put in 2 end-of-buffer characters.
1147 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1148 if ( ! b->yy_ch_buf )
1149 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1151 b->yy_is_our_buffer = 1;
1153 yy_init_buffer( b, file );
1160 #ifdef YY_USE_PROTOS
1161 void yy_delete_buffer( YY_BUFFER_STATE b )
1163 void yy_delete_buffer( b )
1167 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
1173 if ( b == yy_current_buffer )
1174 yy_current_buffer = (YY_BUFFER_STATE) 0;
1176 if ( b->yy_is_our_buffer )
1177 yy_flex_free( (void *) b->yy_ch_buf );
1179 yy_flex_free( (void *) b );
1184 #ifdef YY_USE_PROTOS
1185 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1187 void yy_init_buffer( b, file )
1193 extern "C" int isatty YY_PROTO(( int ));
1194 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
1198 yy_flush_buffer( b );
1200 b->yy_input_file = file;
1201 b->yy_fill_buffer = 1;
1204 #if YY_ALWAYS_INTERACTIVE
1205 b->yy_is_interactive = 1;
1207 #if YY_NEVER_INTERACTIVE
1208 b->yy_is_interactive = 0;
1210 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1214 b->yy_is_interactive = 0;
1220 #ifdef YY_USE_PROTOS
1221 void yy_flush_buffer( YY_BUFFER_STATE b )
1223 void yy_flush_buffer( b )
1228 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
1236 /* We always need two end-of-buffer characters. The first causes
1237 * a transition to the end-of-buffer state. The second causes
1238 * a jam in that state.
1240 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1241 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1243 b->yy_buf_pos = &b->yy_ch_buf[0];
1246 b->yy_buffer_status = YY_BUFFER_NEW;
1248 if ( b == yy_current_buffer )
1249 yy_load_buffer_state();
1254 #ifndef YY_NO_SCAN_BUFFER
1256 #ifdef YY_USE_PROTOS
1257 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1259 YY_BUFFER_STATE yy_scan_buffer( base, size )
1267 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1268 base[size-1] != YY_END_OF_BUFFER_CHAR )
1269 /* They forgot to leave room for the EOB's. */
1272 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1274 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1276 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1277 b->yy_buf_pos = b->yy_ch_buf = base;
1278 b->yy_is_our_buffer = 0;
1279 b->yy_input_file = 0;
1280 b->yy_n_chars = b->yy_buf_size;
1281 b->yy_is_interactive = 0;
1283 b->yy_fill_buffer = 0;
1284 b->yy_buffer_status = YY_BUFFER_NEW;
1286 yy_switch_to_buffer( b );
1294 #ifndef YY_NO_SCAN_STRING
1296 #ifdef YY_USE_PROTOS
1297 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1299 YY_BUFFER_STATE yy_scan_string( yy_str )
1300 yyconst char *yy_str;
1304 for ( len = 0; yy_str[len]; ++len )
1307 return yy_scan_bytes( yy_str, len );
1313 #ifndef YY_NO_SCAN_BYTES
1315 #ifdef YY_USE_PROTOS
1316 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1318 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1319 yyconst char *bytes;
1328 /* Get memory for full buffer, including space for trailing EOB's. */
1330 buf = (char *) yy_flex_alloc( n );
1332 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1334 for ( i = 0; i < len; ++i )
1337 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1339 b = yy_scan_buffer( buf, n );
1341 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1343 /* It's okay to grow etc. this buffer, and we should throw it
1344 * away when we're done.
1346 b->yy_is_our_buffer = 1;
1354 #ifndef YY_NO_PUSH_STATE
1356 #ifdef YY_USE_PROTOS
1357 static void yy_push_state( int new_state )
1359 static void yy_push_state( new_state )
1363 void yyFlexLexer::yy_push_state( int new_state )
1366 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1370 yy_start_stack_depth += YY_START_STACK_INCR;
1371 new_size = yy_start_stack_depth * sizeof( int );
1373 if ( ! yy_start_stack )
1374 yy_start_stack = (int *) yy_flex_alloc( new_size );
1377 yy_start_stack = (int *) yy_flex_realloc(
1378 (void *) yy_start_stack, new_size );
1380 if ( ! yy_start_stack )
1382 "out of memory expanding start-condition stack" );
1385 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1392 #ifndef YY_NO_POP_STATE
1394 #ifdef YY_USE_PROTOS
1395 static void yy_pop_state( void )
1397 static void yy_pop_state()
1400 void yyFlexLexer::yy_pop_state()
1403 if ( --yy_start_stack_ptr < 0 )
1404 YY_FATAL_ERROR( "start-condition stack underflow" );
1406 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1411 #ifndef YY_NO_TOP_STATE
1413 #ifdef YY_USE_PROTOS
1414 static int yy_top_state( void )
1416 static int yy_top_state()
1419 int yyFlexLexer::yy_top_state()
1422 return yy_start_stack[yy_start_stack_ptr - 1];
1426 #ifndef YY_EXIT_FAILURE
1427 #define YY_EXIT_FAILURE 2
1431 #ifdef YY_USE_PROTOS
1432 static void yy_fatal_error( yyconst char msg[] )
1434 static void yy_fatal_error( msg )
1438 (void) fprintf( stderr, "%s\n", msg );
1439 exit( YY_EXIT_FAILURE );
1444 void yyFlexLexer::LexerError( yyconst char msg[] )
1446 cerr << msg << '\n';
1447 exit( YY_EXIT_FAILURE );
1452 /* Redefine yyless() so it works in section 3 code. */
1458 /* Undo effects of setting up yytext. */ \
1459 yytext[yyleng] = yy_hold_char; \
1460 yy_c_buf_p = yytext + n; \
1461 yy_hold_char = *yy_c_buf_p; \
1462 *yy_c_buf_p = '\0'; \
1468 /* Internal utility routines. */
1471 #ifdef YY_USE_PROTOS
1472 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1474 static void yy_flex_strncpy( s1, s2, n )
1481 for ( i = 0; i < n; ++i )
1486 #ifdef YY_NEED_STRLEN
1487 #ifdef YY_USE_PROTOS
1488 static int yy_flex_strlen( yyconst char *s )
1490 static int yy_flex_strlen( s )
1495 for ( n = 0; s[n]; ++n )
1503 #ifdef YY_USE_PROTOS
1504 static void *yy_flex_alloc( yy_size_t size )
1506 static void *yy_flex_alloc( size )
1510 return (void *) malloc( size );
1513 #ifdef YY_USE_PROTOS
1514 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1516 static void *yy_flex_realloc( ptr, size )
1521 /* The cast to (char *) in the following accommodates both
1522 * implementations that use char* generic pointers, and those
1523 * that use void* generic pointers. It works with the latter
1524 * because both ANSI C and C++ allow castless assignment from
1525 * any pointer type to void*, and deal with argument conversions
1526 * as though doing an assignment.
1528 return (void *) realloc( (char *) ptr, size );
1531 #ifdef YY_USE_PROTOS
1532 static void yy_flex_free( void *ptr )
1534 static void yy_flex_free( ptr )