Annotation of src/usr.bin/lex/flex.skl, Revision 1.1.1.1
1.1 deraadt 1: /* A lexical scanner generated by flex */
2:
3: /* Scanner skeleton version:
4: * $Header: /a/cvsroot/src/usr.bin/lex/flex.skl,v 1.7 1995/05/05 05:35:20 jtc Exp $
5: */
6:
7: #define FLEX_SCANNER
8: #define YY_FLEX_MAJOR_VERSION 2
9: #define YY_FLEX_MINOR_VERSION 5
10:
11: %-
12: #include <stdio.h>
13: %*
14:
15:
16: /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
17: #ifdef c_plusplus
18: #ifndef __cplusplus
19: #define __cplusplus
20: #endif
21: #endif
22:
23:
24: #ifdef __cplusplus
25:
26: #include <stdlib.h>
27: %+
28: class istream;
29: %*
30: #include <unistd.h>
31:
32: /* Use prototypes in function declarations. */
33: #define YY_USE_PROTOS
34:
35: /* The "const" storage-class-modifier is valid. */
36: #define YY_USE_CONST
37:
38: #else /* ! __cplusplus */
39:
40: #if __STDC__
41:
42: #define YY_USE_PROTOS
43: #define YY_USE_CONST
44:
45: #endif /* __STDC__ */
46: #endif /* ! __cplusplus */
47:
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
56:
57: #ifdef YY_USE_CONST
58: #define yyconst const
59: #else
60: #define yyconst
61: #endif
62:
63:
64: #ifdef YY_USE_PROTOS
65: #define YY_PROTO(proto) proto
66: #else
67: #define YY_PROTO(proto) ()
68: #endif
69:
70: /* Returned upon end-of-file. */
71: #define YY_NULL 0
72:
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)
79:
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 *
85:
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
92:
93: /* Action number for EOF rule of a given start state. */
94: #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
95:
96: /* Special action meaning "start processing a new file". */
97: #define YY_NEW_FILE yyrestart( yyin )
98:
99: #define YY_END_OF_BUFFER_CHAR 0
100:
101: /* Size of default input buffer. */
102: #define YY_BUF_SIZE 16384
103:
104: typedef struct yy_buffer_state *YY_BUFFER_STATE;
105:
106: extern int yyleng;
107: %-
108: extern FILE *yyin, *yyout;
109: %*
110:
111: #define EOB_ACT_CONTINUE_SCAN 0
112: #define EOB_ACT_END_OF_FILE 1
113: #define EOB_ACT_LAST_MATCH 2
114:
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:
118: *
119: * if ( condition_holds )
120: * yyless( 5 );
121: * else
122: * do_something_else();
123: *
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: */
128:
129: /* Return all but the first 'n' matched characters back to the input stream. */
130:
131: #define yyless(n) \
132: do \
133: { \
134: /* Undo effects of setting up yytext. */ \
135: *yy_cp = yy_hold_char; \
136: yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
137: YY_DO_BEFORE_ACTION; /* set up yytext again */ \
138: } \
139: while ( 0 )
140:
141: #define unput(c) yyunput( c, yytext_ptr )
142:
143: /* The following is because we cannot portably get our hands on size_t
144: * (without autoconf's help, which isn't available because we want
145: * flex-generated scanners to compile on their own).
146: */
147: typedef unsigned int yy_size_t;
148:
149:
150: struct yy_buffer_state
151: {
152: %-
153: FILE *yy_input_file;
154: %+
155: istream* yy_input_file;
156: %*
157:
158: char *yy_ch_buf; /* input buffer */
159: char *yy_buf_pos; /* current position in input buffer */
160:
161: /* Size of input buffer in bytes, not including room for EOB
162: * characters.
163: */
164: yy_size_t yy_buf_size;
165:
166: /* Number of characters read into yy_ch_buf, not including EOB
167: * characters.
168: */
169: int yy_n_chars;
170:
171: /* Whether we "own" the buffer - i.e., we know we created it,
172: * and can realloc() it to grow it, and should free() it to
173: * delete it.
174: */
175: int yy_is_our_buffer;
176:
177: /* Whether this is an "interactive" input source; if so, and
178: * if we're using stdio for input, then we want to use getc()
179: * instead of fread(), to make sure we stop fetching input after
180: * each newline.
181: */
182: int yy_is_interactive;
183:
184: /* Whether we're considered to be at the beginning of a line.
185: * If so, '^' rules will be active on the next match, otherwise
186: * not.
187: */
188: int yy_at_bol;
189:
190: /* Whether to try to fill the input buffer when we reach the
191: * end of it.
192: */
193: int yy_fill_buffer;
194:
195: int yy_buffer_status;
196: #define YY_BUFFER_NEW 0
197: #define YY_BUFFER_NORMAL 1
198: /* When an EOF's been seen but there's still some text to process
199: * then we mark the buffer as YY_EOF_PENDING, to indicate that we
200: * shouldn't try reading from the input source any more. We might
201: * still have a bunch of tokens to match, though, because of
202: * possible backing-up.
203: *
204: * When we actually see the EOF, we change the status to "new"
205: * (via yyrestart()), so that the user can continue scanning by
206: * just pointing yyin at a new input file.
207: */
208: #define YY_BUFFER_EOF_PENDING 2
209: };
210:
211: %- Standard (non-C++) definition
212: static YY_BUFFER_STATE yy_current_buffer = 0;
213: %*
214:
215: /* We provide macros for accessing buffer states in case in the
216: * future we want to put the buffer states in a more general
217: * "scanner state".
218: */
219: #define YY_CURRENT_BUFFER yy_current_buffer
220:
221:
222: %- Standard (non-C++) definition
223: /* yy_hold_char holds the character lost when yytext is formed. */
224: static char yy_hold_char;
225:
226: static int yy_n_chars; /* number of characters read into yy_ch_buf */
227:
228:
229: int yyleng;
230:
231: /* Points to current character in buffer. */
232: static char *yy_c_buf_p = (char *) 0;
233: static int yy_init = 1; /* whether we need to initialize */
234: static int yy_start = 0; /* start state number */
235:
236: /* Flag which is used to allow yywrap()'s to do buffer switches
237: * instead of setting up a fresh yyin. A bit of a hack ...
238: */
239: static int yy_did_buffer_switch_on_eof;
240:
241: void yyrestart YY_PROTO(( FILE *input_file ));
242:
243: void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
244: void yy_load_buffer_state YY_PROTO(( void ));
245: YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
246: void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
247: void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
248: void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
249: #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
250:
251: YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
252: YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *str ));
253: YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
254: %*
255:
256: static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
257: static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
258: static void yy_flex_free YY_PROTO(( void * ));
259:
260: #define yy_new_buffer yy_create_buffer
261:
262: #define yy_set_interactive(is_interactive) \
263: { \
264: if ( ! yy_current_buffer ) \
265: yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
266: yy_current_buffer->yy_is_interactive = is_interactive; \
267: }
268:
269: #define yy_set_bol(at_bol) \
270: { \
271: if ( ! yy_current_buffer ) \
272: yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
273: yy_current_buffer->yy_at_bol = at_bol; \
274: }
275:
276: #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
277:
278: %% yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here
279:
280: %- Standard (non-C++) definition
281: static yy_state_type yy_get_previous_state YY_PROTO(( void ));
282: static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
283: static int yy_get_next_buffer YY_PROTO(( void ));
284: static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
285: %*
286:
287: /* Done after the current pattern has been matched and before the
288: * corresponding action - sets up yytext.
289: */
290: #define YY_DO_BEFORE_ACTION \
291: yytext_ptr = yy_bp; \
292: %% code to fiddle yytext and yyleng for yymore() goes here
293: yy_hold_char = *yy_cp; \
294: *yy_cp = '\0'; \
295: %% code to copy yytext_ptr to yytext[] goes here, if %array
296: yy_c_buf_p = yy_cp;
297:
298: %% data tables for the DFA and the user's section 1 definitions go here
299:
300: /* Macros after this point can all be overridden by user definitions in
301: * section 1.
302: */
303:
304: #ifndef YY_SKIP_YYWRAP
305: #ifdef __cplusplus
306: extern "C" int yywrap YY_PROTO(( void ));
307: #else
308: extern int yywrap YY_PROTO(( void ));
309: #endif
310: #endif
311:
312: %-
313: #ifndef YY_NO_UNPUT
314: static void yyunput YY_PROTO(( int c, char *buf_ptr ));
315: #endif
316: %*
317:
318: #ifndef yytext_ptr
319: static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
320: #endif
321:
322: #ifndef YY_NO_INPUT
323: %- Standard (non-C++) definition
324: #ifdef __cplusplus
325: static int yyinput YY_PROTO(( void ));
326: #else
327: static int input YY_PROTO(( void ));
328: #endif
329: %*
330: #endif
331:
332: #if YY_STACK_USED
333: static int yy_start_stack_ptr = 0;
334: static int yy_start_stack_depth = 0;
335: static int *yy_start_stack = 0;
336: #ifndef YY_NO_PUSH_STATE
337: static void yy_push_state YY_PROTO(( int new_state ));
338: #endif
339: #ifndef YY_NO_POP_STATE
340: static void yy_pop_state YY_PROTO(( void ));
341: #endif
342: #ifndef YY_NO_TOP_STATE
343: static int yy_top_state YY_PROTO(( void ));
344: #endif
345:
346: #else
347: #define YY_NO_PUSH_STATE 1
348: #define YY_NO_POP_STATE 1
349: #define YY_NO_TOP_STATE 1
350: #endif
351:
352: #ifdef YY_MALLOC_DECL
353: YY_MALLOC_DECL
354: #else
355: #if __STDC__
356: #ifndef __cplusplus
357: #include <stdlib.h>
358: #endif
359: #else
360: /* Just try to get by without declaring the routines. This will fail
361: * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
362: * or sizeof(void*) != sizeof(int).
363: */
364: #endif
365: #endif
366:
367: /* Amount of stuff to slurp up with each read. */
368: #ifndef YY_READ_BUF_SIZE
369: #define YY_READ_BUF_SIZE 8192
370: #endif
371:
372: /* Copy whatever the last rule matched to the standard output. */
373:
374: #ifndef ECHO
375: %- Standard (non-C++) definition
376: /* This used to be an fputs(), but since the string might contain NUL's,
377: * we now use fwrite().
378: */
379: #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
380: %+ C++ definition
381: #define ECHO LexerOutput( yytext, yyleng )
382: %*
383: #endif
384:
385: /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
386: * is returned in "result".
387: */
388: #ifndef YY_INPUT
389: #define YY_INPUT(buf,result,max_size) \
390: %% fread()/read() definition of YY_INPUT goes here unless we're doing C++
391: %+ C++ definition
392: if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
393: YY_FATAL_ERROR( "input in flex scanner failed" );
394: %*
395: #endif
396:
397: /* No semi-colon after return; correct usage is to write "yyterminate();" -
398: * we don't want an extra ';' after the "return" because that will cause
399: * some compilers to complain about unreachable statements.
400: */
401: #ifndef yyterminate
402: #define yyterminate() return YY_NULL
403: #endif
404:
405: /* Number of entries by which start-condition stack grows. */
406: #ifndef YY_START_STACK_INCR
407: #define YY_START_STACK_INCR 25
408: #endif
409:
410: /* Report a fatal error. */
411: #ifndef YY_FATAL_ERROR
412: %-
413: #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
414: %+
415: #define YY_FATAL_ERROR(msg) LexerError( msg )
416: %*
417: #endif
418:
419: /* Default declaration of generated scanner - a define so the user can
420: * easily add parameters.
421: */
422: #ifndef YY_DECL
423: %- Standard (non-C++) definition
424: #define YY_DECL int yylex YY_PROTO(( void ))
425: %+ C++ definition
426: #define YY_DECL int yyFlexLexer::yylex()
427: %*
428: #endif
429:
430: /* Code executed at the beginning of each rule, after yytext and yyleng
431: * have been set up.
432: */
433: #ifndef YY_USER_ACTION
434: #define YY_USER_ACTION
435: #endif
436:
437: /* Code executed at the end of each rule. */
438: #ifndef YY_BREAK
439: #define YY_BREAK break;
440: #endif
441:
442: %% YY_RULE_SETUP definition goes here
443:
444: YY_DECL
445: {
446: register yy_state_type yy_current_state;
447: register char *yy_cp, *yy_bp;
448: register int yy_act;
449:
450: %% user's declarations go here
451:
452: if ( yy_init )
453: {
454: yy_init = 0;
455:
456: #ifdef YY_USER_INIT
457: YY_USER_INIT;
458: #endif
459:
460: if ( ! yy_start )
461: yy_start = 1; /* first start state */
462:
463: if ( ! yyin )
464: %-
465: yyin = stdin;
466: %+
467: yyin = &cin;
468: %*
469:
470: if ( ! yyout )
471: %-
472: yyout = stdout;
473: %+
474: yyout = &cout;
475: %*
476:
477: if ( ! yy_current_buffer )
478: yy_current_buffer =
479: yy_create_buffer( yyin, YY_BUF_SIZE );
480:
481: yy_load_buffer_state();
482: }
483:
484: while ( 1 ) /* loops until end-of-file is reached */
485: {
486: %% yymore()-related code goes here
487: yy_cp = yy_c_buf_p;
488:
489: /* Support of yytext. */
490: *yy_cp = yy_hold_char;
491:
492: /* yy_bp points to the position in yy_ch_buf of the start of
493: * the current run.
494: */
495: yy_bp = yy_cp;
496:
497: %% code to set up and find next match goes here
498:
499: yy_find_action:
500: %% code to find the action number goes here
501:
502: YY_DO_BEFORE_ACTION;
503:
504: %% code for yylineno update goes here
505:
506: do_action: /* This label is used only to access EOF actions. */
507:
508: %% debug code goes here
509:
510: switch ( yy_act )
511: { /* beginning of action switch */
512: %% actions go here
513:
514: case YY_END_OF_BUFFER:
515: {
516: /* Amount of text matched not including the EOB char. */
517: int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
518:
519: /* Undo the effects of YY_DO_BEFORE_ACTION. */
520: *yy_cp = yy_hold_char;
521:
522: if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
523: {
524: /* We're scanning a new file or input source. It's
525: * possible that this happened because the user
526: * just pointed yyin at a new source and called
527: * yylex(). If so, then we have to assure
528: * consistency between yy_current_buffer and our
529: * globals. Here is the right place to do so, because
530: * this is the first action (other than possibly a
531: * back-up) that will match for the new input source.
532: */
533: yy_n_chars = yy_current_buffer->yy_n_chars;
534: yy_current_buffer->yy_input_file = yyin;
535: yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
536: }
537:
538: /* Note that here we test for yy_c_buf_p "<=" to the position
539: * of the first EOB in the buffer, since yy_c_buf_p will
540: * already have been incremented past the NUL character
541: * (since all states make transitions on EOB to the
542: * end-of-buffer state). Contrast this with the test
543: * in input().
544: */
545: if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
546: { /* This was really a NUL. */
547: yy_state_type yy_next_state;
548:
549: yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
550:
551: yy_current_state = yy_get_previous_state();
552:
553: /* Okay, we're now positioned to make the NUL
554: * transition. We couldn't have
555: * yy_get_previous_state() go ahead and do it
556: * for us because it doesn't know how to deal
557: * with the possibility of jamming (and we don't
558: * want to build jamming into it because then it
559: * will run more slowly).
560: */
561:
562: yy_next_state = yy_try_NUL_trans( yy_current_state );
563:
564: yy_bp = yytext_ptr + YY_MORE_ADJ;
565:
566: if ( yy_next_state )
567: {
568: /* Consume the NUL. */
569: yy_cp = ++yy_c_buf_p;
570: yy_current_state = yy_next_state;
571: goto yy_match;
572: }
573:
574: else
575: {
576: %% code to do back-up for compressed tables and set up yy_cp goes here
577: goto yy_find_action;
578: }
579: }
580:
581: else switch ( yy_get_next_buffer() )
582: {
583: case EOB_ACT_END_OF_FILE:
584: {
585: yy_did_buffer_switch_on_eof = 0;
586:
587: if ( yywrap() )
588: {
589: /* Note: because we've taken care in
590: * yy_get_next_buffer() to have set up
591: * yytext, we can now set up
592: * yy_c_buf_p so that if some total
593: * hoser (like flex itself) wants to
594: * call the scanner after we return the
595: * YY_NULL, it'll still work - another
596: * YY_NULL will get returned.
597: */
598: yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
599:
600: yy_act = YY_STATE_EOF(YY_START);
601: goto do_action;
602: }
603:
604: else
605: {
606: if ( ! yy_did_buffer_switch_on_eof )
607: YY_NEW_FILE;
608: }
609: break;
610: }
611:
612: case EOB_ACT_CONTINUE_SCAN:
613: yy_c_buf_p =
614: yytext_ptr + yy_amount_of_matched_text;
615:
616: yy_current_state = yy_get_previous_state();
617:
618: yy_cp = yy_c_buf_p;
619: yy_bp = yytext_ptr + YY_MORE_ADJ;
620: goto yy_match;
621:
622: case EOB_ACT_LAST_MATCH:
623: yy_c_buf_p =
624: &yy_current_buffer->yy_ch_buf[yy_n_chars];
625:
626: yy_current_state = yy_get_previous_state();
627:
628: yy_cp = yy_c_buf_p;
629: yy_bp = yytext_ptr + YY_MORE_ADJ;
630: goto yy_find_action;
631: }
632: break;
633: }
634:
635: default:
636: YY_FATAL_ERROR(
637: "fatal flex scanner internal error--no action found" );
638: } /* end of action switch */
639: } /* end of scanning one token */
640: } /* end of yylex */
641:
642: %+
643: yyFlexLexer::yyFlexLexer( istream* arg_yyin, ostream* arg_yyout )
644: {
645: yyin = arg_yyin;
646: yyout = arg_yyout;
647: yy_c_buf_p = 0;
648: yy_init = 1;
649: yy_start = 0;
650: yy_flex_debug = 0;
651: yylineno = 1; // this will only get updated if %option yylineno
652:
653: yy_did_buffer_switch_on_eof = 0;
654:
655: yy_looking_for_trail_begin = 0;
656: yy_more_flag = 0;
657: yy_more_len = 0;
658:
659: yy_start_stack_ptr = yy_start_stack_depth = 0;
660: yy_start_stack = 0;
661:
662: yy_current_buffer = 0;
663:
664: #ifdef YY_USES_REJECT
665: yy_state_buf = new yy_state_type[YY_BUF_SIZE + 2];
666: #else
667: yy_state_buf = 0;
668: #endif
669: }
670:
671: yyFlexLexer::~yyFlexLexer()
672: {
673: delete yy_state_buf;
674: yy_delete_buffer( yy_current_buffer );
675: }
676:
677: void yyFlexLexer::switch_streams( istream* new_in, ostream* new_out )
678: {
679: if ( new_in )
680: {
681: yy_delete_buffer( yy_current_buffer );
682: yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
683: }
684:
685: if ( new_out )
686: yyout = new_out;
687: }
688:
689: #ifdef YY_INTERACTIVE
690: int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
691: #else
692: int yyFlexLexer::LexerInput( char* buf, int max_size )
693: #endif
694: {
695: if ( yyin->eof() || yyin->fail() )
696: return 0;
697:
698: #ifdef YY_INTERACTIVE
699: yyin->get( buf[0] );
700:
701: if ( yyin->eof() )
702: return 0;
703:
704: if ( yyin->bad() )
705: return -1;
706:
707: return 1;
708:
709: #else
710: (void) yyin->read( buf, max_size );
711:
712: if ( yyin->bad() )
713: return -1;
714: else
715: return yyin->gcount();
716: #endif
717: }
718:
719: void yyFlexLexer::LexerOutput( const char* buf, int size )
720: {
721: (void) yyout->write( buf, size );
722: }
723: %*
724:
725: /* yy_get_next_buffer - try to read in a new buffer
726: *
727: * Returns a code representing an action:
728: * EOB_ACT_LAST_MATCH -
729: * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
730: * EOB_ACT_END_OF_FILE - end of file
731: */
732:
733: %-
734: static int yy_get_next_buffer()
735: %+
736: int yyFlexLexer::yy_get_next_buffer()
737: %*
738: {
739: register char *dest = yy_current_buffer->yy_ch_buf;
740: register char *source = yytext_ptr;
741: register int number_to_move, i;
742: int ret_val;
743:
744: if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
745: YY_FATAL_ERROR(
746: "fatal flex scanner internal error--end of buffer missed" );
747:
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 )
751: {
752: /* We matched a singled characater, the EOB, so
753: * treat this as a final EOF.
754: */
755: return EOB_ACT_END_OF_FILE;
756: }
757:
758: else
759: {
760: /* We matched some text prior to the EOB, first
761: * process it.
762: */
763: return EOB_ACT_LAST_MATCH;
764: }
765: }
766:
767: /* Try to read more data. */
768:
769: /* First move last chars to start of buffer. */
770: number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
771:
772: for ( i = 0; i < number_to_move; ++i )
773: *(dest++) = *(source++);
774:
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,
777: * just force an EOF
778: */
779: yy_n_chars = 0;
780:
781: else
782: {
783: int num_to_read =
784: yy_current_buffer->yy_buf_size - number_to_move - 1;
785:
786: while ( num_to_read <= 0 )
787: { /* Not enough room in the buffer - grow it. */
788: #ifdef YY_USES_REJECT
789: YY_FATAL_ERROR(
790: "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
791: #else
792:
793: /* just a shorter name for the current buffer */
794: YY_BUFFER_STATE b = yy_current_buffer;
795:
796: int yy_c_buf_p_offset =
797: (int) (yy_c_buf_p - b->yy_ch_buf);
798:
799: if ( b->yy_is_our_buffer )
800: {
801: int new_size = b->yy_buf_size * 2;
802:
803: if ( new_size <= 0 )
804: b->yy_buf_size += b->yy_buf_size / 8;
805: else
806: b->yy_buf_size *= 2;
807:
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 );
812: }
813: else
814: /* Can't grow it, we don't own it. */
815: b->yy_ch_buf = 0;
816:
817: if ( ! b->yy_ch_buf )
818: YY_FATAL_ERROR(
819: "fatal error - scanner input buffer overflow" );
820:
821: yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
822:
823: num_to_read = yy_current_buffer->yy_buf_size -
824: number_to_move - 1;
825: #endif
826: }
827:
828: if ( num_to_read > YY_READ_BUF_SIZE )
829: num_to_read = YY_READ_BUF_SIZE;
830:
831: /* Read in more data. */
832: YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
833: yy_n_chars, num_to_read );
834: }
835:
836: if ( yy_n_chars == 0 )
837: {
838: if ( number_to_move == YY_MORE_ADJ )
839: {
840: ret_val = EOB_ACT_END_OF_FILE;
841: yyrestart( yyin );
842: }
843:
844: else
845: {
846: ret_val = EOB_ACT_LAST_MATCH;
847: yy_current_buffer->yy_buffer_status =
848: YY_BUFFER_EOF_PENDING;
849: }
850: }
851:
852: else
853: ret_val = EOB_ACT_CONTINUE_SCAN;
854:
855: yy_n_chars += number_to_move;
856: yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
857: yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
858:
859: yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
860:
861: return ret_val;
862: }
863:
864:
865: /* yy_get_previous_state - get the state just before the EOB char was reached */
866:
867: %-
868: static yy_state_type yy_get_previous_state()
869: %+
870: yy_state_type yyFlexLexer::yy_get_previous_state()
871: %*
872: {
873: register yy_state_type yy_current_state;
874: register char *yy_cp;
875:
876: %% code to get the start state into yy_current_state goes here
877:
878: for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
879: {
880: %% code to find the next state goes here
881: }
882:
883: return yy_current_state;
884: }
885:
886:
887: /* yy_try_NUL_trans - try to make a transition on the NUL character
888: *
889: * synopsis
890: * next_state = yy_try_NUL_trans( current_state );
891: */
892:
893: %-
894: #ifdef YY_USE_PROTOS
895: static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
896: #else
897: static yy_state_type yy_try_NUL_trans( yy_current_state )
898: yy_state_type yy_current_state;
899: #endif
900: %+
901: yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
902: %*
903: {
904: register int yy_is_jam;
905: %% code to find the next state, and perhaps do backing up, goes here
906:
907: return yy_is_jam ? 0 : yy_current_state;
908: }
909:
910:
911: %-
912: #ifndef YY_NO_UNPUT
913: #ifdef YY_USE_PROTOS
914: static void yyunput( int c, register char *yy_bp )
915: #else
916: static void yyunput( c, yy_bp )
917: int c;
918: register char *yy_bp;
919: #endif
920: %+
921: void yyFlexLexer::yyunput( int c, register char* yy_bp )
922: %*
923: {
924: register char *yy_cp = yy_c_buf_p;
925:
926: /* undo effects of setting up yytext */
927: *yy_cp = yy_hold_char;
928:
929: if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
930: { /* need to shift things up to make room */
931: /* +2 for EOB chars. */
932: register int number_to_move = yy_n_chars + 2;
933: register char *dest = &yy_current_buffer->yy_ch_buf[
934: yy_current_buffer->yy_buf_size + 2];
935: register char *source =
936: &yy_current_buffer->yy_ch_buf[number_to_move];
937:
938: while ( source > yy_current_buffer->yy_ch_buf )
939: *--dest = *--source;
940:
941: yy_cp += (int) (dest - source);
942: yy_bp += (int) (dest - source);
943: yy_n_chars = yy_current_buffer->yy_buf_size;
944:
945: if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
946: YY_FATAL_ERROR( "flex scanner push-back overflow" );
947: }
948:
949: *--yy_cp = (char) c;
950:
951: %% update yylineno here
952:
953: yytext_ptr = yy_bp;
954: yy_hold_char = *yy_cp;
955: yy_c_buf_p = yy_cp;
956: }
957: %-
958: #endif /* ifndef YY_NO_UNPUT */
959: %*
960:
961:
962: %-
963: #ifdef __cplusplus
964: static int yyinput()
965: #else
966: static int input()
967: #endif
968: %+
969: int yyFlexLexer::yyinput()
970: %*
971: {
972: int c;
973:
974: *yy_c_buf_p = yy_hold_char;
975:
976: if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
977: {
978: /* yy_c_buf_p now points to the character we want to return.
979: * If this occurs *before* the EOB characters, then it's a
980: * valid NUL; if not, then we've hit the end of the buffer.
981: */
982: if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
983: /* This was really a NUL. */
984: *yy_c_buf_p = '\0';
985:
986: else
987: { /* need more input */
988: yytext_ptr = yy_c_buf_p;
989: ++yy_c_buf_p;
990:
991: switch ( yy_get_next_buffer() )
992: {
993: case EOB_ACT_END_OF_FILE:
994: {
995: if ( yywrap() )
996: {
997: yy_c_buf_p =
998: yytext_ptr + YY_MORE_ADJ;
999: return EOF;
1000: }
1001:
1002: if ( ! yy_did_buffer_switch_on_eof )
1003: YY_NEW_FILE;
1004: #ifdef __cplusplus
1005: return yyinput();
1006: #else
1007: return input();
1008: #endif
1009: }
1010:
1011: case EOB_ACT_CONTINUE_SCAN:
1012: yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1013: break;
1014:
1015: case EOB_ACT_LAST_MATCH:
1016: #ifdef __cplusplus
1017: YY_FATAL_ERROR(
1018: "unexpected last match in yyinput()" );
1019: #else
1020: YY_FATAL_ERROR(
1021: "unexpected last match in input()" );
1022: #endif
1023: }
1024: }
1025: }
1026:
1027: c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1028: *yy_c_buf_p = '\0'; /* preserve yytext */
1029: yy_hold_char = *++yy_c_buf_p;
1030:
1031: %% update BOL and yylineno
1032:
1033: return c;
1034: }
1035:
1036:
1037: %-
1038: #ifdef YY_USE_PROTOS
1039: void yyrestart( FILE *input_file )
1040: #else
1041: void yyrestart( input_file )
1042: FILE *input_file;
1043: #endif
1044: %+
1045: void yyFlexLexer::yyrestart( istream* input_file )
1046: %*
1047: {
1048: if ( ! yy_current_buffer )
1049: yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1050:
1051: yy_init_buffer( yy_current_buffer, input_file );
1052: yy_load_buffer_state();
1053: }
1054:
1055:
1056: %-
1057: #ifdef YY_USE_PROTOS
1058: void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1059: #else
1060: void yy_switch_to_buffer( new_buffer )
1061: YY_BUFFER_STATE new_buffer;
1062: #endif
1063: %+
1064: void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1065: %*
1066: {
1067: if ( yy_current_buffer == new_buffer )
1068: return;
1069:
1070: if ( yy_current_buffer )
1071: {
1072: /* Flush out information for old buffer. */
1073: *yy_c_buf_p = yy_hold_char;
1074: yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1075: yy_current_buffer->yy_n_chars = yy_n_chars;
1076: }
1077:
1078: yy_current_buffer = new_buffer;
1079: yy_load_buffer_state();
1080:
1081: /* We don't actually know whether we did this switch during
1082: * EOF (yywrap()) processing, but the only time this flag
1083: * is looked at is after yywrap() is called, so it's safe
1084: * to go ahead and always set it.
1085: */
1086: yy_did_buffer_switch_on_eof = 1;
1087: }
1088:
1089:
1090: %-
1091: #ifdef YY_USE_PROTOS
1092: void yy_load_buffer_state( void )
1093: #else
1094: void yy_load_buffer_state()
1095: #endif
1096: %+
1097: void yyFlexLexer::yy_load_buffer_state()
1098: %*
1099: {
1100: yy_n_chars = yy_current_buffer->yy_n_chars;
1101: yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1102: yyin = yy_current_buffer->yy_input_file;
1103: yy_hold_char = *yy_c_buf_p;
1104: }
1105:
1106:
1107: %-
1108: #ifdef YY_USE_PROTOS
1109: YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1110: #else
1111: YY_BUFFER_STATE yy_create_buffer( file, size )
1112: FILE *file;
1113: int size;
1114: #endif
1115: %+
1116: YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( istream* file, int size )
1117: %*
1118: {
1119: YY_BUFFER_STATE b;
1120:
1121: b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1122: if ( ! b )
1123: YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1124:
1125: b->yy_buf_size = size;
1126:
1127: /* yy_ch_buf has to be 2 characters longer than the size given because
1128: * we need to put in 2 end-of-buffer characters.
1129: */
1130: b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1131: if ( ! b->yy_ch_buf )
1132: YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1133:
1134: b->yy_is_our_buffer = 1;
1135:
1136: yy_init_buffer( b, file );
1137:
1138: return b;
1139: }
1140:
1141:
1142: %-
1143: #ifdef YY_USE_PROTOS
1144: void yy_delete_buffer( YY_BUFFER_STATE b )
1145: #else
1146: void yy_delete_buffer( b )
1147: YY_BUFFER_STATE b;
1148: #endif
1149: %+
1150: void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
1151: %*
1152: {
1153: if ( ! b )
1154: return;
1155:
1156: if ( b == yy_current_buffer )
1157: yy_current_buffer = (YY_BUFFER_STATE) 0;
1158:
1159: if ( b->yy_is_our_buffer )
1160: yy_flex_free( (void *) b->yy_ch_buf );
1161:
1162: yy_flex_free( (void *) b );
1163: }
1164:
1165:
1166: %-
1167: #ifndef YY_ALWAYS_INTERACTIVE
1168: #ifndef YY_NEVER_INTERACTIVE
1169: extern int isatty YY_PROTO(( int ));
1170: #endif
1171: #endif
1172:
1173: #ifdef YY_USE_PROTOS
1174: void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1175: #else
1176: void yy_init_buffer( b, file )
1177: YY_BUFFER_STATE b;
1178: FILE *file;
1179: #endif
1180:
1181: %+
1182: extern "C" int isatty YY_PROTO(( int ));
1183: void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, istream* file )
1184: %*
1185:
1186: {
1187: yy_flush_buffer( b );
1188:
1189: b->yy_input_file = file;
1190: b->yy_fill_buffer = 1;
1191:
1192: %-
1193: #if YY_ALWAYS_INTERACTIVE
1194: b->yy_is_interactive = 1;
1195: #else
1196: #if YY_NEVER_INTERACTIVE
1197: b->yy_is_interactive = 0;
1198: #else
1199: b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1200: #endif
1201: #endif
1202: %+
1203: b->yy_is_interactive = 0;
1204: %*
1205: }
1206:
1207:
1208: %-
1209: #ifdef YY_USE_PROTOS
1210: void yy_flush_buffer( YY_BUFFER_STATE b )
1211: #else
1212: void yy_flush_buffer( b )
1213: YY_BUFFER_STATE b;
1214: #endif
1215:
1216: %+
1217: void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
1218: %*
1219: {
1220: b->yy_n_chars = 0;
1221:
1222: /* We always need two end-of-buffer characters. The first causes
1223: * a transition to the end-of-buffer state. The second causes
1224: * a jam in that state.
1225: */
1226: b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1227: b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1228:
1229: b->yy_buf_pos = &b->yy_ch_buf[0];
1230:
1231: b->yy_at_bol = 1;
1232: b->yy_buffer_status = YY_BUFFER_NEW;
1233:
1234: if ( b == yy_current_buffer )
1235: yy_load_buffer_state();
1236: }
1237: %*
1238:
1239:
1240: #ifndef YY_NO_SCAN_BUFFER
1241: %-
1242: #ifdef YY_USE_PROTOS
1243: YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1244: #else
1245: YY_BUFFER_STATE yy_scan_buffer( base, size )
1246: char *base;
1247: yy_size_t size;
1248: #endif
1249: {
1250: YY_BUFFER_STATE b;
1251:
1252: if ( size < 2 ||
1253: base[size-2] != YY_END_OF_BUFFER_CHAR ||
1254: base[size-1] != YY_END_OF_BUFFER_CHAR )
1255: /* They forgot to leave room for the EOB's. */
1256: return 0;
1257:
1258: b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1259: if ( ! b )
1260: YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1261:
1262: b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1263: b->yy_buf_pos = b->yy_ch_buf = base;
1264: b->yy_is_our_buffer = 0;
1265: b->yy_input_file = 0;
1266: b->yy_n_chars = b->yy_buf_size;
1267: b->yy_is_interactive = 0;
1268: b->yy_at_bol = 1;
1269: b->yy_fill_buffer = 0;
1270: b->yy_buffer_status = YY_BUFFER_NEW;
1271:
1272: yy_switch_to_buffer( b );
1273:
1274: return b;
1275: }
1276: %*
1277: #endif
1278:
1279:
1280: #ifndef YY_NO_SCAN_STRING
1281: %-
1282: #ifdef YY_USE_PROTOS
1283: YY_BUFFER_STATE yy_scan_string( yyconst char *str )
1284: #else
1285: YY_BUFFER_STATE yy_scan_string( str )
1286: yyconst char *str;
1287: #endif
1288: {
1289: int len;
1290: for ( len = 0; str[len]; ++len )
1291: ;
1292:
1293: return yy_scan_bytes( str, len );
1294: }
1295: %*
1296: #endif
1297:
1298:
1299: #ifndef YY_NO_SCAN_BYTES
1300: %-
1301: #ifdef YY_USE_PROTOS
1302: YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1303: #else
1304: YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1305: yyconst char *bytes;
1306: int len;
1307: #endif
1308: {
1309: YY_BUFFER_STATE b;
1310: char *buf;
1311: yy_size_t n;
1312: int i;
1313:
1314: /* Get memory for full buffer, including space for trailing EOB's. */
1315: n = len + 2;
1316: buf = (char *) yy_flex_alloc( n );
1317: if ( ! buf )
1318: YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1319:
1320: for ( i = 0; i < len; ++i )
1321: buf[i] = bytes[i];
1322:
1323: buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1324:
1325: b = yy_scan_buffer( buf, n );
1326: if ( ! b )
1327: YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1328:
1329: /* It's okay to grow etc. this buffer, and we should throw it
1330: * away when we're done.
1331: */
1332: b->yy_is_our_buffer = 1;
1333:
1334: return b;
1335: }
1336: %*
1337: #endif
1338:
1339:
1340: #ifndef YY_NO_PUSH_STATE
1341: %-
1342: #ifdef YY_USE_PROTOS
1343: static void yy_push_state( int new_state )
1344: #else
1345: static void yy_push_state( new_state )
1346: int new_state;
1347: #endif
1348: %+
1349: void yyFlexLexer::yy_push_state( int new_state )
1350: %*
1351: {
1352: if ( yy_start_stack_ptr >= yy_start_stack_depth )
1353: {
1354: yy_size_t new_size;
1355:
1356: yy_start_stack_depth += YY_START_STACK_INCR;
1357: new_size = yy_start_stack_depth * sizeof( int );
1358:
1359: if ( ! yy_start_stack )
1360: yy_start_stack = (int *) yy_flex_alloc( new_size );
1361:
1362: else
1363: yy_start_stack = (int *) yy_flex_realloc(
1364: (void *) yy_start_stack, new_size );
1365:
1366: if ( ! yy_start_stack )
1367: YY_FATAL_ERROR(
1368: "out of memory expanding start-condition stack" );
1369: }
1370:
1371: yy_start_stack[yy_start_stack_ptr++] = YY_START;
1372:
1373: BEGIN(new_state);
1374: }
1375: #endif
1376:
1377:
1378: #ifndef YY_NO_POP_STATE
1379: %-
1380: static void yy_pop_state()
1381: %+
1382: void yyFlexLexer::yy_pop_state()
1383: %*
1384: {
1385: if ( --yy_start_stack_ptr < 0 )
1386: YY_FATAL_ERROR( "start-condition stack underflow" );
1387:
1388: BEGIN(yy_start_stack[yy_start_stack_ptr]);
1389: }
1390: #endif
1391:
1392:
1393: #ifndef YY_NO_TOP_STATE
1394: %-
1395: static int yy_top_state()
1396: %+
1397: int yyFlexLexer::yy_top_state()
1398: %*
1399: {
1400: return yy_start_stack[yy_start_stack_ptr - 1];
1401: }
1402: #endif
1403:
1404: #ifndef YY_EXIT_FAILURE
1405: #define YY_EXIT_FAILURE 2
1406: #endif
1407:
1408: %-
1409: #ifdef YY_USE_PROTOS
1410: static void yy_fatal_error( yyconst char msg[] )
1411: #else
1412: static void yy_fatal_error( msg )
1413: char msg[];
1414: #endif
1415: {
1416: (void) fprintf( stderr, "%s\n", msg );
1417: exit( YY_EXIT_FAILURE );
1418: }
1419:
1420: %+
1421:
1422: void yyFlexLexer::LexerError( yyconst char msg[] )
1423: {
1424: cerr << msg << '\n';
1425: exit( YY_EXIT_FAILURE );
1426: }
1427: %*
1428:
1429:
1430: /* Redefine yyless() so it works in section 3 code. */
1431:
1432: #undef yyless
1433: #define yyless(n) \
1434: do \
1435: { \
1436: /* Undo effects of setting up yytext. */ \
1437: yytext[yyleng] = yy_hold_char; \
1438: yy_c_buf_p = yytext + n - YY_MORE_ADJ; \
1439: yy_hold_char = *yy_c_buf_p; \
1440: *yy_c_buf_p = '\0'; \
1441: yyleng = n; \
1442: } \
1443: while ( 0 )
1444:
1445:
1446: /* Internal utility routines. */
1447:
1448: #ifndef yytext_ptr
1449: #ifdef YY_USE_PROTOS
1450: static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1451: #else
1452: static void yy_flex_strncpy( s1, s2, n )
1453: char *s1;
1454: yyconst char *s2;
1455: int n;
1456: #endif
1457: {
1458: register int i;
1459: for ( i = 0; i < n; ++i )
1460: s1[i] = s2[i];
1461: }
1462: #endif
1463:
1464:
1465: #ifdef YY_USE_PROTOS
1466: static void *yy_flex_alloc( yy_size_t size )
1467: #else
1468: static void *yy_flex_alloc( size )
1469: yy_size_t size;
1470: #endif
1471: {
1472: return (void *) malloc( size );
1473: }
1474:
1475: #ifdef YY_USE_PROTOS
1476: static void *yy_flex_realloc( void *ptr, yy_size_t size )
1477: #else
1478: static void *yy_flex_realloc( ptr, size )
1479: void *ptr;
1480: yy_size_t size;
1481: #endif
1482: {
1483: /* The cast to (char *) in the following accommodates both
1484: * implementations that use char* generic pointers, and those
1485: * that use void* generic pointers. It works with the latter
1486: * because both ANSI C and C++ allow castless assignment from
1487: * any pointer type to void*, and deal with argument conversions
1488: * as though doing an assignment.
1489: */
1490: return (void *) realloc( (char *) ptr, size );
1491: }
1492:
1493: #ifdef YY_USE_PROTOS
1494: static void yy_flex_free( void *ptr )
1495: #else
1496: static void yy_flex_free( ptr )
1497: void *ptr;
1498: #endif
1499: {
1500: free( ptr );
1501: }
1502:
1503: #if YY_MAIN
1504: int main()
1505: {
1506: yylex();
1507: return 0;
1508: }
1509: #endif