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