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.8.26.1 2008/11/25 02:59:29 kensmith Exp $
8 #if defined(__FreeBSD__)
15 #define YY_FLEX_MAJOR_VERSION 2
16 #define YY_FLEX_MINOR_VERSION 5
21 /* 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 */
48 #endif /* ! __cplusplus */
67 #define YY_PROTO(proto) proto
69 #define YY_PROTO(proto) ()
72 /* Returned upon end-of-file. */
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
80 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
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.
86 #define BEGIN yy_start = 1 + 2 *
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
92 #define YY_START ((yy_start - 1) / 2)
93 #define YYSTATE YY_START
95 /* Action number for EOF rule of a given start state. */
96 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
98 /* Special action meaning "start processing a new file". */
99 #define YY_NEW_FILE yyrestart( yyin )
101 #define YY_END_OF_BUFFER_CHAR 0
103 /* Size of default input buffer. */
104 #define YY_BUF_SIZE 16384
106 typedef struct yy_buffer_state *YY_BUFFER_STATE;
109 extern FILE *yyin, *yyout;
111 #define EOB_ACT_CONTINUE_SCAN 0
112 #define EOB_ACT_END_OF_FILE 1
113 #define EOB_ACT_LAST_MATCH 2
115 /* The funky do-while in the following #define is used to turn the definition
116 * int a single C statement (which needs a semi-colon terminator). This
117 * avoids problems with code like:
119 * if ( condition_holds )
122 * do_something_else();
124 * Prior to using the do-while the compiler would get upset at the
125 * "else" because it interpreted the "if" statement as being all
126 * done when it reached the ';' after the yyless() call.
129 /* Return all but the first 'n' matched characters back to the input stream. */
134 /* Undo effects of setting up yytext. */ \
135 *yy_cp = yy_hold_char; \
136 YY_RESTORE_YY_MORE_OFFSET \
137 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
138 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
142 #define unput(c) yyunput( c, yytext_ptr )
144 /* The following is because we cannot portably get our hands on size_t
145 * (without autoconf's help, which isn't available because we want
146 * flex-generated scanners to compile on their own).
148 typedef unsigned int yy_size_t;
151 struct yy_buffer_state
155 char *yy_ch_buf; /* input buffer */
156 char *yy_buf_pos; /* current position in input buffer */
158 /* Size of input buffer in bytes, not including room for EOB
161 yy_size_t yy_buf_size;
163 /* Number of characters read into yy_ch_buf, not including EOB
168 /* Whether we "own" the buffer - i.e., we know we created it,
169 * and can realloc() it to grow it, and should free() it to
172 int yy_is_our_buffer;
174 /* Whether this is an "interactive" input source; if so, and
175 * if we're using stdio for input, then we want to use getc()
176 * instead of fread(), to make sure we stop fetching input after
179 int yy_is_interactive;
181 /* Whether we're considered to be at the beginning of a line.
182 * If so, '^' rules will be active on the next match, otherwise
187 /* Whether to try to fill the input buffer when we reach the
192 int yy_buffer_status;
193 #define YY_BUFFER_NEW 0
194 #define YY_BUFFER_NORMAL 1
195 /* When an EOF's been seen but there's still some text to process
196 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
197 * shouldn't try reading from the input source any more. We might
198 * still have a bunch of tokens to match, though, because of
199 * possible backing-up.
201 * When we actually see the EOF, we change the status to "new"
202 * (via yyrestart()), so that the user can continue scanning by
203 * just pointing yyin at a new input file.
205 #define YY_BUFFER_EOF_PENDING 2
208 static YY_BUFFER_STATE yy_current_buffer = 0;
210 /* We provide macros for accessing buffer states in case in the
211 * future we want to put the buffer states in a more general
214 #define YY_CURRENT_BUFFER yy_current_buffer
217 /* yy_hold_char holds the character lost when yytext is formed. */
218 static char yy_hold_char;
220 static int yy_n_chars; /* number of characters read into yy_ch_buf */
225 /* Points to current character in buffer. */
226 static char *yy_c_buf_p = (char *) 0;
227 static int yy_init = 1; /* whether we need to initialize */
228 static int yy_start = 0; /* start state number */
230 /* Flag which is used to allow yywrap()'s to do buffer switches
231 * instead of setting up a fresh yyin. A bit of a hack ...
233 static int yy_did_buffer_switch_on_eof;
235 void yyrestart YY_PROTO(( FILE *input_file ));
237 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
238 void yy_load_buffer_state YY_PROTO(( void ));
239 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
240 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
241 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
242 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
243 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
245 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
246 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
247 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 )) __unused;
251 static void yy_flex_free YY_PROTO(( void * ));
253 #define yy_new_buffer yy_create_buffer
255 #define yy_set_interactive(is_interactive) \
257 if ( ! yy_current_buffer ) \
258 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
259 yy_current_buffer->yy_is_interactive = is_interactive; \
262 #define yy_set_bol(at_bol) \
264 if ( ! yy_current_buffer ) \
265 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
266 yy_current_buffer->yy_at_bol = at_bol; \
269 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
271 typedef unsigned char YY_CHAR;
272 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
273 typedef int yy_state_type;
275 #define yytext_ptr yytext
277 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
278 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
279 static int yy_get_next_buffer YY_PROTO(( void ));
280 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
282 /* Done after the current pattern has been matched and before the
283 * corresponding action - sets up yytext.
285 #define YY_DO_BEFORE_ACTION \
286 yytext_ptr = yy_bp; \
287 yyleng = (int) (yy_cp - yy_bp); \
288 yy_hold_char = *yy_cp; \
292 #define YY_NUM_RULES 19
293 #define YY_END_OF_BUFFER 20
294 static yyconst short int yy_accept[39] =
296 0, 0, 20, 18, 1, 2, 7, 6, 7, 18,
297 16, 16, 2, 7, 7, 7, 16, 17, 18, 18,
298 11, 6, 5, 6, 14, 16, 0, 12, 8, 10,
299 9, 13, 16, 17, 3, 15, 4, 0
302 static yyconst int yy_ec[256] =
304 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
305 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
306 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
307 1, 2, 4, 1, 5, 1, 6, 7, 1, 6,
308 6, 6, 6, 6, 6, 1, 6, 8, 9, 9,
309 9, 9, 9, 9, 9, 9, 9, 1, 10, 11,
310 12, 13, 1, 1, 14, 14, 14, 14, 14, 14,
311 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
312 15, 15, 15, 15, 15, 15, 15, 16, 15, 15,
313 1, 17, 1, 6, 1, 1, 15, 15, 15, 15,
315 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
316 15, 15, 15, 15, 15, 15, 15, 15, 15, 16,
317 15, 15, 1, 18, 1, 1, 1, 1, 1, 1,
318 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
319 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
320 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
321 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
322 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
323 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
324 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
326 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
327 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
330 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
334 static yyconst int yy_meta[19] =
336 1, 1, 1, 1, 1, 1, 1, 2, 2, 1,
337 1, 1, 1, 2, 3, 2, 1, 1
340 static yyconst short int yy_base[43] =
342 0, 0, 39, 49, 49, 49, 26, 16, 49, 30,
343 20, 19, 49, 9, 22, 10, 9, 0, 29, 13,
344 49, 23, 49, 24, 49, 0, 0, 49, 49, 49,
345 49, 49, 13, 0, 49, 49, 49, 49, 41, 28,
349 static yyconst short int yy_def[43] =
351 38, 1, 38, 38, 38, 38, 38, 39, 38, 38,
352 40, 40, 38, 38, 38, 38, 41, 42, 38, 38,
353 38, 39, 38, 39, 38, 12, 12, 38, 38, 38,
354 38, 38, 41, 42, 38, 38, 38, 0, 38, 38,
358 static yyconst short int yy_nxt[68] =
360 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
361 14, 15, 16, 17, 18, 18, 19, 20, 23, 28,
362 29, 31, 32, 34, 34, 23, 37, 34, 34, 26,
363 36, 35, 24, 30, 38, 27, 25, 21, 38, 24,
364 24, 22, 22, 22, 33, 33, 34, 34, 3, 38,
365 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
366 38, 38, 38, 38, 38, 38, 38
369 static yyconst short int yy_chk[68] =
371 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
372 1, 1, 1, 1, 1, 1, 1, 1, 8, 14,
373 14, 16, 16, 17, 17, 22, 24, 33, 33, 40,
374 20, 19, 8, 15, 12, 11, 10, 7, 3, 22,
375 24, 39, 39, 39, 41, 41, 42, 42, 38, 38,
376 38, 38, 38, 38, 38, 38, 38, 38, 38, 38,
377 38, 38, 38, 38, 38, 38, 38
380 static yy_state_type yy_last_accepting_state;
381 static char *yy_last_accepting_cpos;
383 /* The intent behind this definition is that it'll catch
384 * any uses of REJECT which flex missed.
386 #define REJECT reject_used_but_not_detected
387 #define yymore() yymore_used_but_not_detected
388 #define YY_MORE_ADJ 0
389 #define YY_RESTORE_YY_MORE_OFFSET
393 /* Lexical analyzer for calc program.
395 Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
397 This file is part of the GNU MP Library.
399 This program is free software; you can redistribute it and/or modify it under
400 the terms of the GNU General Public License as published by the Free Software
401 Foundation; either version 3 of the License, or (at your option) any later
404 This program is distributed in the hope that it will be useful, but WITHOUT ANY
405 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
406 PARTICULAR PURPOSE. See the GNU General Public License for more details.
408 You should have received a copy of the GNU General Public License along with
409 this program. If not, see http://www.gnu.org/licenses/. */
412 #include "calc-common.h"
416 /* Let GNU flex use readline. See the calcread.c redefined input() for a
417 way that might work for a standard lex too. */
418 #define YY_INPUT(buf,result,max_size) \
419 result = calc_input (buf, max_size);
423 /* Non-zero when reading the second or subsequent line of an expression,
424 used to give a different prompt when using readline. */
425 int calc_more_input = 0;
428 const struct calc_keywords_t calc_keywords[] = {
431 { "decimal", DECIMAL },
438 { "lucnum", LUCNUM },
439 { "nextprime", NEXTPRIME },
446 #line 447 "calclex.c"
448 /* Macros after this point can all be overridden by user definitions in
452 #ifndef YY_SKIP_YYWRAP
454 extern "C" int yywrap YY_PROTO(( void ));
456 extern int yywrap YY_PROTO(( void ));
461 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
465 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
468 #ifdef YY_NEED_STRLEN
469 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
474 static int yyinput YY_PROTO(( void ));
476 static int input YY_PROTO(( void ));
481 static int yy_start_stack_ptr = 0;
482 static int yy_start_stack_depth = 0;
483 static int *yy_start_stack = 0;
484 #ifndef YY_NO_PUSH_STATE
485 static void yy_push_state YY_PROTO(( int new_state ));
487 #ifndef YY_NO_POP_STATE
488 static void yy_pop_state YY_PROTO(( void ));
490 #ifndef YY_NO_TOP_STATE
491 static int yy_top_state YY_PROTO(( void ));
495 #define YY_NO_PUSH_STATE 1
496 #define YY_NO_POP_STATE 1
497 #define YY_NO_TOP_STATE 1
500 #ifdef YY_MALLOC_DECL
508 /* Just try to get by without declaring the routines. This will fail
509 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
510 * or sizeof(void*) != sizeof(int).
515 /* Amount of stuff to slurp up with each read. */
516 #ifndef YY_READ_BUF_SIZE
517 #define YY_READ_BUF_SIZE 8192
520 /* Copy whatever the last rule matched to the standard output. */
523 /* This used to be an fputs(), but since the string might contain NUL's,
524 * we now use fwrite().
526 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
529 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
530 * is returned in "result".
533 #define YY_INPUT(buf,result,max_size) \
534 if ( yy_current_buffer->yy_is_interactive ) \
537 for ( n = 0; n < max_size && \
538 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
541 buf[n++] = (char) c; \
542 if ( c == EOF && ferror( yyin ) ) \
543 YY_FATAL_ERROR( "input in flex scanner failed" ); \
546 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
547 && ferror( yyin ) ) \
548 YY_FATAL_ERROR( "input in flex scanner failed" );
551 /* No semi-colon after return; correct usage is to write "yyterminate();" -
552 * we don't want an extra ';' after the "return" because that will cause
553 * some compilers to complain about unreachable statements.
556 #define yyterminate() return YY_NULL
559 /* Number of entries by which start-condition stack grows. */
560 #ifndef YY_START_STACK_INCR
561 #define YY_START_STACK_INCR 25
564 /* Report a fatal error. */
565 #ifndef YY_FATAL_ERROR
566 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
569 /* Default declaration of generated scanner - a define so the user can
570 * easily add parameters.
573 #define YY_DECL int yylex YY_PROTO(( void ))
576 /* Code executed at the beginning of each rule, after yytext and yyleng
579 #ifndef YY_USER_ACTION
580 #define YY_USER_ACTION
583 /* Code executed at the end of each rule. */
585 #define YY_BREAK break;
588 #define YY_RULE_SETUP \
593 register yy_state_type yy_current_state;
594 register char *yy_cp, *yy_bp;
600 #line 601 "calclex.c"
611 yy_start = 1; /* first start state */
619 if ( ! yy_current_buffer )
621 yy_create_buffer( yyin, YY_BUF_SIZE );
623 yy_load_buffer_state();
626 while ( 1 ) /* loops until end-of-file is reached */
630 /* Support of yytext. */
631 *yy_cp = yy_hold_char;
633 /* yy_bp points to the position in yy_ch_buf of the start of
638 yy_current_state = yy_start;
642 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
643 if ( yy_accept[yy_current_state] )
645 yy_last_accepting_state = yy_current_state;
646 yy_last_accepting_cpos = yy_cp;
648 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
650 yy_current_state = (int) yy_def[yy_current_state];
651 if ( yy_current_state >= 39 )
652 yy_c = yy_meta[(unsigned int) yy_c];
654 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
657 while ( yy_base[yy_current_state] != 49 );
660 yy_act = yy_accept[yy_current_state];
662 { /* have to back up */
663 yy_cp = yy_last_accepting_cpos;
664 yy_current_state = yy_last_accepting_state;
665 yy_act = yy_accept[yy_current_state];
671 do_action: /* This label is used only to access EOF actions. */
675 { /* beginning of action switch */
676 case 0: /* must back up */
677 /* undo the effects of YY_DO_BEFORE_ACTION */
678 *yy_cp = yy_hold_char;
679 yy_cp = yy_last_accepting_cpos;
680 yy_current_state = yy_last_accepting_state;
686 { /* white space is skipped */ }
691 { /* semicolon or newline separates statements */
698 { /* escaped newlines are skipped */ }
704 /* comment through to escaped newline is skipped */ }
709 { /* comment through to newline is a separator */
716 { /* comment through to EOF skipped */ }
721 { return yytext[0]; }
776 for (i = 0; calc_keywords[i].name != NULL; i++)
777 if (strcmp (yytext, calc_keywords[i].name) == 0)
778 return calc_keywords[i].value;
780 if (yytext[0] >= 'a' && yytext[0] <= 'z' && yytext[1] == '\0')
782 yylval.var = yytext[0] - 'a';
791 #line 105 "calclex.l"
796 #line 107 "calclex.l"
799 #line 800 "calclex.c"
800 case YY_STATE_EOF(INITIAL):
803 case YY_END_OF_BUFFER:
805 /* Amount of text matched not including the EOB char. */
806 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
808 /* Undo the effects of YY_DO_BEFORE_ACTION. */
809 *yy_cp = yy_hold_char;
810 YY_RESTORE_YY_MORE_OFFSET
812 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
814 /* We're scanning a new file or input source. It's
815 * possible that this happened because the user
816 * just pointed yyin at a new source and called
817 * yylex(). If so, then we have to assure
818 * consistency between yy_current_buffer and our
819 * globals. Here is the right place to do so, because
820 * this is the first action (other than possibly a
821 * back-up) that will match for the new input source.
823 yy_n_chars = yy_current_buffer->yy_n_chars;
824 yy_current_buffer->yy_input_file = yyin;
825 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
828 /* Note that here we test for yy_c_buf_p "<=" to the position
829 * of the first EOB in the buffer, since yy_c_buf_p will
830 * already have been incremented past the NUL character
831 * (since all states make transitions on EOB to the
832 * end-of-buffer state). Contrast this with the test
835 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
836 { /* This was really a NUL. */
837 yy_state_type yy_next_state;
839 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
841 yy_current_state = yy_get_previous_state();
843 /* Okay, we're now positioned to make the NUL
844 * transition. We couldn't have
845 * yy_get_previous_state() go ahead and do it
846 * for us because it doesn't know how to deal
847 * with the possibility of jamming (and we don't
848 * want to build jamming into it because then it
849 * will run more slowly).
852 yy_next_state = yy_try_NUL_trans( yy_current_state );
854 yy_bp = yytext_ptr + YY_MORE_ADJ;
858 /* Consume the NUL. */
859 yy_cp = ++yy_c_buf_p;
860 yy_current_state = yy_next_state;
871 else switch ( yy_get_next_buffer() )
873 case EOB_ACT_END_OF_FILE:
875 yy_did_buffer_switch_on_eof = 0;
879 /* Note: because we've taken care in
880 * yy_get_next_buffer() to have set up
881 * yytext, we can now set up
882 * yy_c_buf_p so that if some total
883 * hoser (like flex itself) wants to
884 * call the scanner after we return the
885 * YY_NULL, it'll still work - another
886 * YY_NULL will get returned.
888 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
890 yy_act = YY_STATE_EOF(YY_START);
896 if ( ! yy_did_buffer_switch_on_eof )
902 case EOB_ACT_CONTINUE_SCAN:
904 yytext_ptr + yy_amount_of_matched_text;
906 yy_current_state = yy_get_previous_state();
909 yy_bp = yytext_ptr + YY_MORE_ADJ;
912 case EOB_ACT_LAST_MATCH:
914 &yy_current_buffer->yy_ch_buf[yy_n_chars];
916 yy_current_state = yy_get_previous_state();
919 yy_bp = yytext_ptr + YY_MORE_ADJ;
927 "fatal flex scanner internal error--no action found" );
928 } /* end of action switch */
929 } /* end of scanning one token */
933 /* yy_get_next_buffer - try to read in a new buffer
935 * Returns a code representing an action:
936 * EOB_ACT_LAST_MATCH -
937 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
938 * EOB_ACT_END_OF_FILE - end of file
941 static int yy_get_next_buffer()
943 register char *dest = yy_current_buffer->yy_ch_buf;
944 register char *source = yytext_ptr;
945 register int number_to_move, i;
948 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
950 "fatal flex scanner internal error--end of buffer missed" );
952 if ( yy_current_buffer->yy_fill_buffer == 0 )
953 { /* Don't try to fill the buffer, so this is an EOF. */
954 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
956 /* We matched a single character, the EOB, so
957 * treat this as a final EOF.
959 return EOB_ACT_END_OF_FILE;
964 /* We matched some text prior to the EOB, first
967 return EOB_ACT_LAST_MATCH;
971 /* Try to read more data. */
973 /* First move last chars to start of buffer. */
974 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
976 for ( i = 0; i < number_to_move; ++i )
977 *(dest++) = *(source++);
979 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
980 /* don't do the read, it's not guaranteed to return an EOF,
983 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
988 yy_current_buffer->yy_buf_size - number_to_move - 1;
990 while ( num_to_read <= 0 )
991 { /* Not enough room in the buffer - grow it. */
992 #ifdef YY_USES_REJECT
994 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
997 /* just a shorter name for the current buffer */
998 YY_BUFFER_STATE b = yy_current_buffer;
1000 int yy_c_buf_p_offset =
1001 (int) (yy_c_buf_p - b->yy_ch_buf);
1003 if ( b->yy_is_our_buffer )
1005 int new_size = b->yy_buf_size * 2;
1007 if ( new_size <= 0 )
1008 b->yy_buf_size += b->yy_buf_size / 8;
1010 b->yy_buf_size *= 2;
1012 b->yy_ch_buf = (char *)
1013 /* Include room in for 2 EOB chars. */
1014 yy_flex_realloc( (void *) b->yy_ch_buf,
1015 b->yy_buf_size + 2 );
1018 /* Can't grow it, we don't own it. */
1021 if ( ! b->yy_ch_buf )
1023 "fatal error - scanner input buffer overflow" );
1025 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1027 num_to_read = yy_current_buffer->yy_buf_size -
1032 if ( num_to_read > YY_READ_BUF_SIZE )
1033 num_to_read = YY_READ_BUF_SIZE;
1035 /* Read in more data. */
1036 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1037 yy_n_chars, num_to_read );
1039 yy_current_buffer->yy_n_chars = yy_n_chars;
1042 if ( yy_n_chars == 0 )
1044 if ( number_to_move == YY_MORE_ADJ )
1046 ret_val = EOB_ACT_END_OF_FILE;
1052 ret_val = EOB_ACT_LAST_MATCH;
1053 yy_current_buffer->yy_buffer_status =
1054 YY_BUFFER_EOF_PENDING;
1059 ret_val = EOB_ACT_CONTINUE_SCAN;
1061 yy_n_chars += number_to_move;
1062 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1063 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1065 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1071 /* yy_get_previous_state - get the state just before the EOB char was reached */
1073 static yy_state_type yy_get_previous_state()
1075 register yy_state_type yy_current_state;
1076 register char *yy_cp;
1078 yy_current_state = yy_start;
1080 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1082 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1083 if ( yy_accept[yy_current_state] )
1085 yy_last_accepting_state = yy_current_state;
1086 yy_last_accepting_cpos = yy_cp;
1088 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1090 yy_current_state = (int) yy_def[yy_current_state];
1091 if ( yy_current_state >= 39 )
1092 yy_c = yy_meta[(unsigned int) yy_c];
1094 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1097 return yy_current_state;
1101 /* yy_try_NUL_trans - try to make a transition on the NUL character
1104 * next_state = yy_try_NUL_trans( current_state );
1107 #ifdef YY_USE_PROTOS
1108 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1110 static yy_state_type yy_try_NUL_trans( yy_current_state )
1111 yy_state_type yy_current_state;
1114 register int yy_is_jam;
1115 register char *yy_cp = yy_c_buf_p;
1117 register YY_CHAR yy_c = 1;
1118 if ( yy_accept[yy_current_state] )
1120 yy_last_accepting_state = yy_current_state;
1121 yy_last_accepting_cpos = yy_cp;
1123 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1125 yy_current_state = (int) yy_def[yy_current_state];
1126 if ( yy_current_state >= 39 )
1127 yy_c = yy_meta[(unsigned int) yy_c];
1129 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1130 yy_is_jam = (yy_current_state == 38);
1132 return yy_is_jam ? 0 : yy_current_state;
1137 #ifdef YY_USE_PROTOS
1138 static void yyunput( int c, register char *yy_bp )
1140 static void yyunput( c, yy_bp )
1142 register char *yy_bp;
1145 register char *yy_cp = yy_c_buf_p;
1147 /* undo effects of setting up yytext */
1148 *yy_cp = yy_hold_char;
1150 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1151 { /* need to shift things up to make room */
1152 /* +2 for EOB chars. */
1153 register int number_to_move = yy_n_chars + 2;
1154 register char *dest = &yy_current_buffer->yy_ch_buf[
1155 yy_current_buffer->yy_buf_size + 2];
1156 register char *source =
1157 &yy_current_buffer->yy_ch_buf[number_to_move];
1159 while ( source > yy_current_buffer->yy_ch_buf )
1160 *--dest = *--source;
1162 yy_cp += (int) (dest - source);
1163 yy_bp += (int) (dest - source);
1164 yy_current_buffer->yy_n_chars =
1165 yy_n_chars = yy_current_buffer->yy_buf_size;
1167 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1168 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1171 *--yy_cp = (char) c;
1175 yy_hold_char = *yy_cp;
1178 #endif /* ifndef YY_NO_UNPUT */
1182 static int yyinput()
1189 *yy_c_buf_p = yy_hold_char;
1191 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1193 /* yy_c_buf_p now points to the character we want to return.
1194 * If this occurs *before* the EOB characters, then it's a
1195 * valid NUL; if not, then we've hit the end of the buffer.
1197 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1198 /* This was really a NUL. */
1202 { /* need more input */
1203 int offset = yy_c_buf_p - yytext_ptr;
1206 switch ( yy_get_next_buffer() )
1208 case EOB_ACT_LAST_MATCH:
1209 /* This happens because yy_g_n_b()
1210 * sees that we've accumulated a
1211 * token and flags that we need to
1212 * try matching the token before
1213 * proceeding. But for input(),
1214 * there's no matching to consider.
1215 * So convert the EOB_ACT_LAST_MATCH
1216 * to EOB_ACT_END_OF_FILE.
1219 /* Reset buffer status. */
1224 case EOB_ACT_END_OF_FILE:
1229 if ( ! yy_did_buffer_switch_on_eof )
1238 case EOB_ACT_CONTINUE_SCAN:
1239 yy_c_buf_p = yytext_ptr + offset;
1245 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1246 *yy_c_buf_p = '\0'; /* preserve yytext */
1247 yy_hold_char = *++yy_c_buf_p;
1254 #ifdef YY_USE_PROTOS
1255 void yyrestart( FILE *input_file )
1257 void yyrestart( input_file )
1261 if ( ! yy_current_buffer )
1262 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1264 yy_init_buffer( yy_current_buffer, input_file );
1265 yy_load_buffer_state();
1269 #ifdef YY_USE_PROTOS
1270 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1272 void yy_switch_to_buffer( new_buffer )
1273 YY_BUFFER_STATE new_buffer;
1276 if ( yy_current_buffer == new_buffer )
1279 if ( yy_current_buffer )
1281 /* Flush out information for old buffer. */
1282 *yy_c_buf_p = yy_hold_char;
1283 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1284 yy_current_buffer->yy_n_chars = yy_n_chars;
1287 yy_current_buffer = new_buffer;
1288 yy_load_buffer_state();
1290 /* We don't actually know whether we did this switch during
1291 * EOF (yywrap()) processing, but the only time this flag
1292 * is looked at is after yywrap() is called, so it's safe
1293 * to go ahead and always set it.
1295 yy_did_buffer_switch_on_eof = 1;
1299 #ifdef YY_USE_PROTOS
1300 void yy_load_buffer_state( void )
1302 void yy_load_buffer_state()
1305 yy_n_chars = yy_current_buffer->yy_n_chars;
1306 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1307 yyin = yy_current_buffer->yy_input_file;
1308 yy_hold_char = *yy_c_buf_p;
1312 #ifdef YY_USE_PROTOS
1313 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1315 YY_BUFFER_STATE yy_create_buffer( file, size )
1322 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1324 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1326 b->yy_buf_size = size;
1328 /* yy_ch_buf has to be 2 characters longer than the size given because
1329 * we need to put in 2 end-of-buffer characters.
1331 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1332 if ( ! b->yy_ch_buf )
1333 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1335 b->yy_is_our_buffer = 1;
1337 yy_init_buffer( b, file );
1343 #ifdef YY_USE_PROTOS
1344 void yy_delete_buffer( YY_BUFFER_STATE b )
1346 void yy_delete_buffer( b )
1353 if ( b == yy_current_buffer )
1354 yy_current_buffer = (YY_BUFFER_STATE) 0;
1356 if ( b->yy_is_our_buffer )
1357 yy_flex_free( (void *) b->yy_ch_buf );
1359 yy_flex_free( (void *) b );
1363 #ifndef YY_ALWAYS_INTERACTIVE
1364 #ifndef YY_NEVER_INTERACTIVE
1365 extern int isatty YY_PROTO(( int ));
1369 #ifdef YY_USE_PROTOS
1370 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1372 void yy_init_buffer( b, file )
1379 yy_flush_buffer( b );
1381 b->yy_input_file = file;
1382 b->yy_fill_buffer = 1;
1384 #if YY_ALWAYS_INTERACTIVE
1385 b->yy_is_interactive = 1;
1387 #if YY_NEVER_INTERACTIVE
1388 b->yy_is_interactive = 0;
1390 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1396 #ifdef YY_USE_PROTOS
1397 void yy_flush_buffer( YY_BUFFER_STATE b )
1399 void yy_flush_buffer( b )
1409 /* We always need two end-of-buffer characters. The first causes
1410 * a transition to the end-of-buffer state. The second causes
1411 * a jam in that state.
1413 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1414 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1416 b->yy_buf_pos = &b->yy_ch_buf[0];
1419 b->yy_buffer_status = YY_BUFFER_NEW;
1421 if ( b == yy_current_buffer )
1422 yy_load_buffer_state();
1426 #ifndef YY_NO_SCAN_BUFFER
1427 #ifdef YY_USE_PROTOS
1428 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1430 YY_BUFFER_STATE yy_scan_buffer( base, size )
1438 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1439 base[size-1] != YY_END_OF_BUFFER_CHAR )
1440 /* They forgot to leave room for the EOB's. */
1443 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1445 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1447 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1448 b->yy_buf_pos = b->yy_ch_buf = base;
1449 b->yy_is_our_buffer = 0;
1450 b->yy_input_file = 0;
1451 b->yy_n_chars = b->yy_buf_size;
1452 b->yy_is_interactive = 0;
1454 b->yy_fill_buffer = 0;
1455 b->yy_buffer_status = YY_BUFFER_NEW;
1457 yy_switch_to_buffer( b );
1464 #ifndef YY_NO_SCAN_STRING
1465 #ifdef YY_USE_PROTOS
1466 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1468 YY_BUFFER_STATE yy_scan_string( yy_str )
1469 yyconst char *yy_str;
1473 for ( len = 0; yy_str[len]; ++len )
1476 return yy_scan_bytes( yy_str, len );
1481 #ifndef YY_NO_SCAN_BYTES
1482 #ifdef YY_USE_PROTOS
1483 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1485 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1486 yyconst char *bytes;
1495 /* Get memory for full buffer, including space for trailing EOB's. */
1497 buf = (char *) yy_flex_alloc( n );
1499 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1501 for ( i = 0; i < len; ++i )
1504 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1506 b = yy_scan_buffer( buf, n );
1508 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1510 /* It's okay to grow etc. this buffer, and we should throw it
1511 * away when we're done.
1513 b->yy_is_our_buffer = 1;
1520 #ifndef YY_NO_PUSH_STATE
1521 #ifdef YY_USE_PROTOS
1522 static void yy_push_state( int new_state )
1524 static void yy_push_state( new_state )
1528 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1532 yy_start_stack_depth += YY_START_STACK_INCR;
1533 new_size = yy_start_stack_depth * sizeof( int );
1535 if ( ! yy_start_stack )
1536 yy_start_stack = (int *) yy_flex_alloc( new_size );
1539 yy_start_stack = (int *) yy_flex_realloc(
1540 (void *) yy_start_stack, new_size );
1542 if ( ! yy_start_stack )
1544 "out of memory expanding start-condition stack" );
1547 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1554 #ifndef YY_NO_POP_STATE
1555 static void yy_pop_state()
1557 if ( --yy_start_stack_ptr < 0 )
1558 YY_FATAL_ERROR( "start-condition stack underflow" );
1560 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1565 #ifndef YY_NO_TOP_STATE
1566 static int yy_top_state()
1568 return yy_start_stack[yy_start_stack_ptr - 1];
1572 #ifndef YY_EXIT_FAILURE
1573 #define YY_EXIT_FAILURE 2
1576 #ifdef YY_USE_PROTOS
1577 static void yy_fatal_error( yyconst char msg[] )
1579 static void yy_fatal_error( msg )
1583 (void) fprintf( stderr, "%s\n", msg );
1584 exit( YY_EXIT_FAILURE );
1589 /* Redefine yyless() so it works in section 3 code. */
1595 /* Undo effects of setting up yytext. */ \
1596 yytext[yyleng] = yy_hold_char; \
1597 yy_c_buf_p = yytext + n; \
1598 yy_hold_char = *yy_c_buf_p; \
1599 *yy_c_buf_p = '\0'; \
1605 /* Internal utility routines. */
1608 #ifdef YY_USE_PROTOS
1609 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1611 static void yy_flex_strncpy( s1, s2, n )
1618 for ( i = 0; i < n; ++i )
1623 #ifdef YY_NEED_STRLEN
1624 #ifdef YY_USE_PROTOS
1625 static int yy_flex_strlen( yyconst char *s )
1627 static int yy_flex_strlen( s )
1632 for ( n = 0; s[n]; ++n )
1640 #ifdef YY_USE_PROTOS
1641 static void *yy_flex_alloc( yy_size_t size )
1643 static void *yy_flex_alloc( size )
1647 return (void *) malloc( size );
1650 #ifdef YY_USE_PROTOS
1651 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1653 static void *yy_flex_realloc( ptr, size )
1658 /* The cast to (char *) in the following accommodates both
1659 * implementations that use char* generic pointers, and those
1660 * that use void* generic pointers. It works with the latter
1661 * because both ANSI C and C++ allow castless assignment from
1662 * any pointer type to void*, and deal with argument conversions
1663 * as though doing an assignment.
1665 return (void *) realloc( (char *) ptr, size );
1668 #ifdef YY_USE_PROTOS
1669 static void yy_flex_free( void *ptr )
1671 static void yy_flex_free( ptr )
1685 #line 107 "calclex.l"