Upload Tizen:Base source
[external/gmp.git] / demos / calc / calclex.c
1 /* A lexical scanner generated by flex */
2
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 $
6  */
7
8 #if defined(__FreeBSD__)
9 #include <sys/cdefs.h>
10 #else
11 #define __unused
12 #endif
13
14 #define FLEX_SCANNER
15 #define YY_FLEX_MAJOR_VERSION 2
16 #define YY_FLEX_MINOR_VERSION 5
17
18 #include <stdio.h>
19
20
21 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
22 #ifdef c_plusplus
23 #ifndef __cplusplus
24 #define __cplusplus
25 #endif
26 #endif
27
28
29 #ifdef __cplusplus
30
31 #include <stdlib.h>
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 extern FILE *yyin, *yyout;
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_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 */ \
139                 } \
140         while ( 0 )
141
142 #define unput(c) yyunput( c, yytext_ptr )
143
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).
147  */
148 typedef unsigned int yy_size_t;
149
150
151 struct yy_buffer_state
152         {
153         FILE *yy_input_file;
154
155         char *yy_ch_buf;                /* input buffer */
156         char *yy_buf_pos;               /* current position in input buffer */
157
158         /* Size of input buffer in bytes, not including room for EOB
159          * characters.
160          */
161         yy_size_t yy_buf_size;
162
163         /* Number of characters read into yy_ch_buf, not including EOB
164          * characters.
165          */
166         int yy_n_chars;
167
168         /* Whether we "own" the buffer - i.e., we know we created it,
169          * and can realloc() it to grow it, and should free() it to
170          * delete it.
171          */
172         int yy_is_our_buffer;
173
174         /* Whether this is an "interactive" input source; if so, and
175          * if we're using stdio for input, then we want to use getc()
176          * instead of fread(), to make sure we stop fetching input after
177          * each newline.
178          */
179         int yy_is_interactive;
180
181         /* Whether we're considered to be at the beginning of a line.
182          * If so, '^' rules will be active on the next match, otherwise
183          * not.
184          */
185         int yy_at_bol;
186
187         /* Whether to try to fill the input buffer when we reach the
188          * end of it.
189          */
190         int yy_fill_buffer;
191
192         int yy_buffer_status;
193 #define YY_BUFFER_NEW 0
194 #define YY_BUFFER_NORMAL 1
195         /* When an EOF's been seen but there's still some text to process
196          * then we mark the buffer as YY_EOF_PENDING, to indicate that we
197          * shouldn't try reading from the input source any more.  We might
198          * still have a bunch of tokens to match, though, because of
199          * possible backing-up.
200          *
201          * When we actually see the EOF, we change the status to "new"
202          * (via yyrestart()), so that the user can continue scanning by
203          * just pointing yyin at a new input file.
204          */
205 #define YY_BUFFER_EOF_PENDING 2
206         };
207
208 static YY_BUFFER_STATE yy_current_buffer = 0;
209
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
212  * "scanner state".
213  */
214 #define YY_CURRENT_BUFFER yy_current_buffer
215
216
217 /* yy_hold_char holds the character lost when yytext is formed. */
218 static char yy_hold_char;
219
220 static int yy_n_chars;          /* number of characters read into yy_ch_buf */
221
222
223 int yyleng;
224
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 */
229
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 ...
232  */
233 static int yy_did_buffer_switch_on_eof;
234
235 void yyrestart YY_PROTO(( FILE *input_file ));
236
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 )
244
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 ));
248
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 * ));
252
253 #define yy_new_buffer yy_create_buffer
254
255 #define yy_set_interactive(is_interactive) \
256         { \
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; \
260         }
261
262 #define yy_set_bol(at_bol) \
263         { \
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; \
267         }
268
269 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
270
271 typedef unsigned char YY_CHAR;
272 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
273 typedef int yy_state_type;
274 extern char *yytext;
275 #define yytext_ptr yytext
276
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[] ));
281
282 /* Done after the current pattern has been matched and before the
283  * corresponding action - sets up yytext.
284  */
285 #define YY_DO_BEFORE_ACTION \
286         yytext_ptr = yy_bp; \
287         yyleng = (int) (yy_cp - yy_bp); \
288         yy_hold_char = *yy_cp; \
289         *yy_cp = '\0'; \
290         yy_c_buf_p = yy_cp;
291
292 #define YY_NUM_RULES 19
293 #define YY_END_OF_BUFFER 20
294 static yyconst short int yy_accept[39] =
295     {   0,
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
300     } ;
301
302 static yyconst int yy_ec[256] =
303     {   0,
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,
314
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,
325
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,
331         1,    1,    1,    1,    1
332     } ;
333
334 static yyconst int yy_meta[19] =
335     {   0,
336         1,    1,    1,    1,    1,    1,    1,    2,    2,    1,
337         1,    1,    1,    2,    3,    2,    1,    1
338     } ;
339
340 static yyconst short int yy_base[43] =
341     {   0,
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,
346        43,   45
347     } ;
348
349 static yyconst short int yy_def[43] =
350     {   0,
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,
355        38,   38
356     } ;
357
358 static yyconst short int yy_nxt[68] =
359     {   0,
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
367     } ;
368
369 static yyconst short int yy_chk[68] =
370     {   0,
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
378     } ;
379
380 static yy_state_type yy_last_accepting_state;
381 static char *yy_last_accepting_cpos;
382
383 /* The intent behind this definition is that it'll catch
384  * any uses of REJECT which flex missed.
385  */
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
390 char *yytext;
391 #line 1 "calclex.l"
392 #define INITIAL 0
393 /* Lexical analyzer for calc program.
394
395 Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
396
397 This file is part of the GNU MP Library.
398
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
402 version.
403
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.
407
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/.  */
410 #line 20 "calclex.l"
411 #include <string.h>
412 #include "calc-common.h"
413
414
415 #if WITH_READLINE
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);
420 #endif
421
422
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;
426
427
428 const struct calc_keywords_t  calc_keywords[] = {
429   { "abs",       ABS },
430   { "bin",       BIN },
431   { "decimal",   DECIMAL },
432   { "fib",       FIB },
433   { "hex",       HEX },
434   { "help",      HELP },
435   { "gcd",       GCD },
436   { "kron",      KRON },
437   { "lcm",       LCM },
438   { "lucnum",    LUCNUM },
439   { "nextprime", NEXTPRIME },
440   { "powm",      POWM },
441   { "quit",      QUIT },
442   { "root",      ROOT },
443   { "sqrt",      SQRT },
444   { NULL }
445 };
446 #line 447 "calclex.c"
447
448 /* Macros after this point can all be overridden by user definitions in
449  * section 1.
450  */
451
452 #ifndef YY_SKIP_YYWRAP
453 #ifdef __cplusplus
454 extern "C" int yywrap YY_PROTO(( void ));
455 #else
456 extern int yywrap YY_PROTO(( void ));
457 #endif
458 #endif
459
460 #ifndef YY_NO_UNPUT
461 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
462 #endif
463
464 #ifndef yytext_ptr
465 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
466 #endif
467
468 #ifdef YY_NEED_STRLEN
469 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
470 #endif
471
472 #ifndef YY_NO_INPUT
473 #ifdef __cplusplus
474 static int yyinput YY_PROTO(( void ));
475 #else
476 static int input YY_PROTO(( void ));
477 #endif
478 #endif
479
480 #if YY_STACK_USED
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 ));
486 #endif
487 #ifndef YY_NO_POP_STATE
488 static void yy_pop_state YY_PROTO(( void ));
489 #endif
490 #ifndef YY_NO_TOP_STATE
491 static int yy_top_state YY_PROTO(( void ));
492 #endif
493
494 #else
495 #define YY_NO_PUSH_STATE 1
496 #define YY_NO_POP_STATE 1
497 #define YY_NO_TOP_STATE 1
498 #endif
499
500 #ifdef YY_MALLOC_DECL
501 YY_MALLOC_DECL
502 #else
503 #if __STDC__
504 #ifndef __cplusplus
505 #include <stdlib.h>
506 #endif
507 #else
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).
511  */
512 #endif
513 #endif
514
515 /* Amount of stuff to slurp up with each read. */
516 #ifndef YY_READ_BUF_SIZE
517 #define YY_READ_BUF_SIZE 8192
518 #endif
519
520 /* Copy whatever the last rule matched to the standard output. */
521
522 #ifndef ECHO
523 /* This used to be an fputs(), but since the string might contain NUL's,
524  * we now use fwrite().
525  */
526 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
527 #endif
528
529 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
530  * is returned in "result".
531  */
532 #ifndef YY_INPUT
533 #define YY_INPUT(buf,result,max_size) \
534         if ( yy_current_buffer->yy_is_interactive ) \
535                 { \
536                 int c = '*', n; \
537                 for ( n = 0; n < max_size && \
538                              (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
539                         buf[n] = (char) c; \
540                 if ( c == '\n' ) \
541                         buf[n++] = (char) c; \
542                 if ( c == EOF && ferror( yyin ) ) \
543                         YY_FATAL_ERROR( "input in flex scanner failed" ); \
544                 result = n; \
545                 } \
546         else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
547                   && ferror( yyin ) ) \
548                 YY_FATAL_ERROR( "input in flex scanner failed" );
549 #endif
550
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.
554  */
555 #ifndef yyterminate
556 #define yyterminate() return YY_NULL
557 #endif
558
559 /* Number of entries by which start-condition stack grows. */
560 #ifndef YY_START_STACK_INCR
561 #define YY_START_STACK_INCR 25
562 #endif
563
564 /* Report a fatal error. */
565 #ifndef YY_FATAL_ERROR
566 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
567 #endif
568
569 /* Default declaration of generated scanner - a define so the user can
570  * easily add parameters.
571  */
572 #ifndef YY_DECL
573 #define YY_DECL int yylex YY_PROTO(( void ))
574 #endif
575
576 /* Code executed at the beginning of each rule, after yytext and yyleng
577  * have been set up.
578  */
579 #ifndef YY_USER_ACTION
580 #define YY_USER_ACTION
581 #endif
582
583 /* Code executed at the end of each rule. */
584 #ifndef YY_BREAK
585 #define YY_BREAK break;
586 #endif
587
588 #define YY_RULE_SETUP \
589         YY_USER_ACTION
590
591 YY_DECL
592         {
593         register yy_state_type yy_current_state;
594         register char *yy_cp, *yy_bp;
595         register int yy_act;
596
597 #line 57 "calclex.l"
598
599
600 #line 601 "calclex.c"
601
602         if ( yy_init )
603                 {
604                 yy_init = 0;
605
606 #ifdef YY_USER_INIT
607                 YY_USER_INIT;
608 #endif
609
610                 if ( ! yy_start )
611                         yy_start = 1;   /* first start state */
612
613                 if ( ! yyin )
614                         yyin = stdin;
615
616                 if ( ! yyout )
617                         yyout = stdout;
618
619                 if ( ! yy_current_buffer )
620                         yy_current_buffer =
621                                 yy_create_buffer( yyin, YY_BUF_SIZE );
622
623                 yy_load_buffer_state();
624                 }
625
626         while ( 1 )             /* loops until end-of-file is reached */
627                 {
628                 yy_cp = yy_c_buf_p;
629
630                 /* Support of yytext. */
631                 *yy_cp = yy_hold_char;
632
633                 /* yy_bp points to the position in yy_ch_buf of the start of
634                  * the current run.
635                  */
636                 yy_bp = yy_cp;
637
638                 yy_current_state = yy_start;
639 yy_match:
640                 do
641                         {
642                         register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
643                         if ( yy_accept[yy_current_state] )
644                                 {
645                                 yy_last_accepting_state = yy_current_state;
646                                 yy_last_accepting_cpos = yy_cp;
647                                 }
648                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
649                                 {
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];
653                                 }
654                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
655                         ++yy_cp;
656                         }
657                 while ( yy_base[yy_current_state] != 49 );
658
659 yy_find_action:
660                 yy_act = yy_accept[yy_current_state];
661                 if ( yy_act == 0 )
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];
666                         }
667
668                 YY_DO_BEFORE_ACTION;
669
670
671 do_action:      /* This label is used only to access EOF actions. */
672
673
674                 switch ( yy_act )
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;
681                         goto yy_find_action;
682
683 case 1:
684 YY_RULE_SETUP
685 #line 59 "calclex.l"
686 { /* white space is skipped */ }
687         YY_BREAK
688 case 2:
689 YY_RULE_SETUP
690 #line 61 "calclex.l"
691 { /* semicolon or newline separates statements */
692           calc_more_input = 0;
693           return EOS; }
694         YY_BREAK
695 case 3:
696 YY_RULE_SETUP
697 #line 64 "calclex.l"
698 { /* escaped newlines are skipped */ }
699         YY_BREAK
700 case 4:
701 YY_RULE_SETUP
702 #line 67 "calclex.l"
703 {
704             /* comment through to escaped newline is skipped */ }
705         YY_BREAK
706 case 5:
707 YY_RULE_SETUP
708 #line 69 "calclex.l"
709 { /* comment through to newline is a separator */
710             calc_more_input = 0;
711             return EOS; }
712         YY_BREAK
713 case 6:
714 YY_RULE_SETUP
715 #line 72 "calclex.l"
716 {   /* comment through to EOF skipped */ }
717         YY_BREAK
718 case 7:
719 YY_RULE_SETUP
720 #line 75 "calclex.l"
721 { return yytext[0]; }
722         YY_BREAK
723 case 8:
724 YY_RULE_SETUP
725 #line 76 "calclex.l"
726 { return LE; }
727         YY_BREAK
728 case 9:
729 YY_RULE_SETUP
730 #line 77 "calclex.l"
731 { return GE; }
732         YY_BREAK
733 case 10:
734 YY_RULE_SETUP
735 #line 78 "calclex.l"
736 { return EQ; }
737         YY_BREAK
738 case 11:
739 YY_RULE_SETUP
740 #line 79 "calclex.l"
741 { return NE; }
742         YY_BREAK
743 case 12:
744 YY_RULE_SETUP
745 #line 80 "calclex.l"
746 { return LSHIFT; }
747         YY_BREAK
748 case 13:
749 YY_RULE_SETUP
750 #line 81 "calclex.l"
751 { return RSHIFT; }
752         YY_BREAK
753 case 14:
754 YY_RULE_SETUP
755 #line 82 "calclex.l"
756 { return LAND; }
757         YY_BREAK
758 case 15:
759 YY_RULE_SETUP
760 #line 83 "calclex.l"
761 { return LOR; }
762         YY_BREAK
763 case 16:
764 YY_RULE_SETUP
765 #line 85 "calclex.l"
766 {
767         yylval.str = yytext;
768         return NUMBER; }
769         YY_BREAK
770 case 17:
771 YY_RULE_SETUP
772 #line 89 "calclex.l"
773 {
774         int  i;
775
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;
779
780         if (yytext[0] >= 'a' && yytext[0] <= 'z' && yytext[1] == '\0')
781           {
782             yylval.var = yytext[0] - 'a';
783             return VARIABLE;
784           }
785
786         return BAD;
787 }
788         YY_BREAK
789 case 18:
790 YY_RULE_SETUP
791 #line 105 "calclex.l"
792 { return BAD; }
793         YY_BREAK
794 case 19:
795 YY_RULE_SETUP
796 #line 107 "calclex.l"
797 ECHO;
798         YY_BREAK
799 #line 800 "calclex.c"
800 case YY_STATE_EOF(INITIAL):
801         yyterminate();
802
803         case YY_END_OF_BUFFER:
804                 {
805                 /* Amount of text matched not including the EOB char. */
806                 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
807
808                 /* Undo the effects of YY_DO_BEFORE_ACTION. */
809                 *yy_cp = yy_hold_char;
810                 YY_RESTORE_YY_MORE_OFFSET
811
812                 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
813                         {
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.
822                          */
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;
826                         }
827
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
833                  * in input().
834                  */
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;
838
839                         yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
840
841                         yy_current_state = yy_get_previous_state();
842
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).
850                          */
851
852                         yy_next_state = yy_try_NUL_trans( yy_current_state );
853
854                         yy_bp = yytext_ptr + YY_MORE_ADJ;
855
856                         if ( yy_next_state )
857                                 {
858                                 /* Consume the NUL. */
859                                 yy_cp = ++yy_c_buf_p;
860                                 yy_current_state = yy_next_state;
861                                 goto yy_match;
862                                 }
863
864                         else
865                                 {
866                                 yy_cp = yy_c_buf_p;
867                                 goto yy_find_action;
868                                 }
869                         }
870
871                 else switch ( yy_get_next_buffer() )
872                         {
873                         case EOB_ACT_END_OF_FILE:
874                                 {
875                                 yy_did_buffer_switch_on_eof = 0;
876
877                                 if ( yywrap() )
878                                         {
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.
887                                          */
888                                         yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
889
890                                         yy_act = YY_STATE_EOF(YY_START);
891                                         goto do_action;
892                                         }
893
894                                 else
895                                         {
896                                         if ( ! yy_did_buffer_switch_on_eof )
897                                                 YY_NEW_FILE;
898                                         }
899                                 break;
900                                 }
901
902                         case EOB_ACT_CONTINUE_SCAN:
903                                 yy_c_buf_p =
904                                         yytext_ptr + yy_amount_of_matched_text;
905
906                                 yy_current_state = yy_get_previous_state();
907
908                                 yy_cp = yy_c_buf_p;
909                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
910                                 goto yy_match;
911
912                         case EOB_ACT_LAST_MATCH:
913                                 yy_c_buf_p =
914                                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
915
916                                 yy_current_state = yy_get_previous_state();
917
918                                 yy_cp = yy_c_buf_p;
919                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
920                                 goto yy_find_action;
921                         }
922                 break;
923                 }
924
925         default:
926                 YY_FATAL_ERROR(
927                         "fatal flex scanner internal error--no action found" );
928         } /* end of action switch */
929                 } /* end of scanning one token */
930         } /* end of yylex */
931
932
933 /* yy_get_next_buffer - try to read in a new buffer
934  *
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
939  */
940
941 static int yy_get_next_buffer()
942         {
943         register char *dest = yy_current_buffer->yy_ch_buf;
944         register char *source = yytext_ptr;
945         register int number_to_move, i;
946         int ret_val;
947
948         if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
949                 YY_FATAL_ERROR(
950                 "fatal flex scanner internal error--end of buffer missed" );
951
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 )
955                         {
956                         /* We matched a single character, the EOB, so
957                          * treat this as a final EOF.
958                          */
959                         return EOB_ACT_END_OF_FILE;
960                         }
961
962                 else
963                         {
964                         /* We matched some text prior to the EOB, first
965                          * process it.
966                          */
967                         return EOB_ACT_LAST_MATCH;
968                         }
969                 }
970
971         /* Try to read more data. */
972
973         /* First move last chars to start of buffer. */
974         number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
975
976         for ( i = 0; i < number_to_move; ++i )
977                 *(dest++) = *(source++);
978
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,
981                  * just force an EOF
982                  */
983                 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
984
985         else
986                 {
987                 int num_to_read =
988                         yy_current_buffer->yy_buf_size - number_to_move - 1;
989
990                 while ( num_to_read <= 0 )
991                         { /* Not enough room in the buffer - grow it. */
992 #ifdef YY_USES_REJECT
993                         YY_FATAL_ERROR(
994 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
995 #else
996
997                         /* just a shorter name for the current buffer */
998                         YY_BUFFER_STATE b = yy_current_buffer;
999
1000                         int yy_c_buf_p_offset =
1001                                 (int) (yy_c_buf_p - b->yy_ch_buf);
1002
1003                         if ( b->yy_is_our_buffer )
1004                                 {
1005                                 int new_size = b->yy_buf_size * 2;
1006
1007                                 if ( new_size <= 0 )
1008                                         b->yy_buf_size += b->yy_buf_size / 8;
1009                                 else
1010                                         b->yy_buf_size *= 2;
1011
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 );
1016                                 }
1017                         else
1018                                 /* Can't grow it, we don't own it. */
1019                                 b->yy_ch_buf = 0;
1020
1021                         if ( ! b->yy_ch_buf )
1022                                 YY_FATAL_ERROR(
1023                                 "fatal error - scanner input buffer overflow" );
1024
1025                         yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1026
1027                         num_to_read = yy_current_buffer->yy_buf_size -
1028                                                 number_to_move - 1;
1029 #endif
1030                         }
1031
1032                 if ( num_to_read > YY_READ_BUF_SIZE )
1033                         num_to_read = YY_READ_BUF_SIZE;
1034
1035                 /* Read in more data. */
1036                 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1037                         yy_n_chars, num_to_read );
1038
1039                 yy_current_buffer->yy_n_chars = yy_n_chars;
1040                 }
1041
1042         if ( yy_n_chars == 0 )
1043                 {
1044                 if ( number_to_move == YY_MORE_ADJ )
1045                         {
1046                         ret_val = EOB_ACT_END_OF_FILE;
1047                         yyrestart( yyin );
1048                         }
1049
1050                 else
1051                         {
1052                         ret_val = EOB_ACT_LAST_MATCH;
1053                         yy_current_buffer->yy_buffer_status =
1054                                 YY_BUFFER_EOF_PENDING;
1055                         }
1056                 }
1057
1058         else
1059                 ret_val = EOB_ACT_CONTINUE_SCAN;
1060
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;
1064
1065         yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1066
1067         return ret_val;
1068         }
1069
1070
1071 /* yy_get_previous_state - get the state just before the EOB char was reached */
1072
1073 static yy_state_type yy_get_previous_state()
1074         {
1075         register yy_state_type yy_current_state;
1076         register char *yy_cp;
1077
1078         yy_current_state = yy_start;
1079
1080         for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1081                 {
1082                 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1083                 if ( yy_accept[yy_current_state] )
1084                         {
1085                         yy_last_accepting_state = yy_current_state;
1086                         yy_last_accepting_cpos = yy_cp;
1087                         }
1088                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1089                         {
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];
1093                         }
1094                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1095                 }
1096
1097         return yy_current_state;
1098         }
1099
1100
1101 /* yy_try_NUL_trans - try to make a transition on the NUL character
1102  *
1103  * synopsis
1104  *      next_state = yy_try_NUL_trans( current_state );
1105  */
1106
1107 #ifdef YY_USE_PROTOS
1108 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1109 #else
1110 static yy_state_type yy_try_NUL_trans( yy_current_state )
1111 yy_state_type yy_current_state;
1112 #endif
1113         {
1114         register int yy_is_jam;
1115         register char *yy_cp = yy_c_buf_p;
1116
1117         register YY_CHAR yy_c = 1;
1118         if ( yy_accept[yy_current_state] )
1119                 {
1120                 yy_last_accepting_state = yy_current_state;
1121                 yy_last_accepting_cpos = yy_cp;
1122                 }
1123         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1124                 {
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];
1128                 }
1129         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1130         yy_is_jam = (yy_current_state == 38);
1131
1132         return yy_is_jam ? 0 : yy_current_state;
1133         }
1134
1135
1136 #ifndef YY_NO_UNPUT
1137 #ifdef YY_USE_PROTOS
1138 static void yyunput( int c, register char *yy_bp )
1139 #else
1140 static void yyunput( c, yy_bp )
1141 int c;
1142 register char *yy_bp;
1143 #endif
1144         {
1145         register char *yy_cp = yy_c_buf_p;
1146
1147         /* undo effects of setting up yytext */
1148         *yy_cp = yy_hold_char;
1149
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];
1158
1159                 while ( source > yy_current_buffer->yy_ch_buf )
1160                         *--dest = *--source;
1161
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;
1166
1167                 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1168                         YY_FATAL_ERROR( "flex scanner push-back overflow" );
1169                 }
1170
1171         *--yy_cp = (char) c;
1172
1173
1174         yytext_ptr = yy_bp;
1175         yy_hold_char = *yy_cp;
1176         yy_c_buf_p = yy_cp;
1177         }
1178 #endif  /* ifndef YY_NO_UNPUT */
1179
1180
1181 #ifdef __cplusplus
1182 static int yyinput()
1183 #else
1184 static int input()
1185 #endif
1186         {
1187         int c;
1188
1189         *yy_c_buf_p = yy_hold_char;
1190
1191         if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1192                 {
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.
1196                  */
1197                 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1198                         /* This was really a NUL. */
1199                         *yy_c_buf_p = '\0';
1200
1201                 else
1202                         { /* need more input */
1203                         int offset = yy_c_buf_p - yytext_ptr;
1204                         ++yy_c_buf_p;
1205
1206                         switch ( yy_get_next_buffer() )
1207                                 {
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.
1217                                          */
1218
1219                                         /* Reset buffer status. */
1220                                         yyrestart( yyin );
1221
1222                                         /* fall through */
1223
1224                                 case EOB_ACT_END_OF_FILE:
1225                                         {
1226                                         if ( yywrap() )
1227                                                 return EOF;
1228
1229                                         if ( ! yy_did_buffer_switch_on_eof )
1230                                                 YY_NEW_FILE;
1231 #ifdef __cplusplus
1232                                         return yyinput();
1233 #else
1234                                         return input();
1235 #endif
1236                                         }
1237
1238                                 case EOB_ACT_CONTINUE_SCAN:
1239                                         yy_c_buf_p = yytext_ptr + offset;
1240                                         break;
1241                                 }
1242                         }
1243                 }
1244
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;
1248
1249
1250         return c;
1251         }
1252
1253
1254 #ifdef YY_USE_PROTOS
1255 void yyrestart( FILE *input_file )
1256 #else
1257 void yyrestart( input_file )
1258 FILE *input_file;
1259 #endif
1260         {
1261         if ( ! yy_current_buffer )
1262                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1263
1264         yy_init_buffer( yy_current_buffer, input_file );
1265         yy_load_buffer_state();
1266         }
1267
1268
1269 #ifdef YY_USE_PROTOS
1270 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1271 #else
1272 void yy_switch_to_buffer( new_buffer )
1273 YY_BUFFER_STATE new_buffer;
1274 #endif
1275         {
1276         if ( yy_current_buffer == new_buffer )
1277                 return;
1278
1279         if ( yy_current_buffer )
1280                 {
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;
1285                 }
1286
1287         yy_current_buffer = new_buffer;
1288         yy_load_buffer_state();
1289
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.
1294          */
1295         yy_did_buffer_switch_on_eof = 1;
1296         }
1297
1298
1299 #ifdef YY_USE_PROTOS
1300 void yy_load_buffer_state( void )
1301 #else
1302 void yy_load_buffer_state()
1303 #endif
1304         {
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;
1309         }
1310
1311
1312 #ifdef YY_USE_PROTOS
1313 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1314 #else
1315 YY_BUFFER_STATE yy_create_buffer( file, size )
1316 FILE *file;
1317 int size;
1318 #endif
1319         {
1320         YY_BUFFER_STATE b;
1321
1322         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1323         if ( ! b )
1324                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1325
1326         b->yy_buf_size = size;
1327
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.
1330          */
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()" );
1334
1335         b->yy_is_our_buffer = 1;
1336
1337         yy_init_buffer( b, file );
1338
1339         return b;
1340         }
1341
1342
1343 #ifdef YY_USE_PROTOS
1344 void yy_delete_buffer( YY_BUFFER_STATE b )
1345 #else
1346 void yy_delete_buffer( b )
1347 YY_BUFFER_STATE b;
1348 #endif
1349         {
1350         if ( ! b )
1351                 return;
1352
1353         if ( b == yy_current_buffer )
1354                 yy_current_buffer = (YY_BUFFER_STATE) 0;
1355
1356         if ( b->yy_is_our_buffer )
1357                 yy_flex_free( (void *) b->yy_ch_buf );
1358
1359         yy_flex_free( (void *) b );
1360         }
1361
1362
1363 #ifndef YY_ALWAYS_INTERACTIVE
1364 #ifndef YY_NEVER_INTERACTIVE
1365 extern int isatty YY_PROTO(( int ));
1366 #endif
1367 #endif
1368
1369 #ifdef YY_USE_PROTOS
1370 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1371 #else
1372 void yy_init_buffer( b, file )
1373 YY_BUFFER_STATE b;
1374 FILE *file;
1375 #endif
1376
1377
1378         {
1379         yy_flush_buffer( b );
1380
1381         b->yy_input_file = file;
1382         b->yy_fill_buffer = 1;
1383
1384 #if YY_ALWAYS_INTERACTIVE
1385         b->yy_is_interactive = 1;
1386 #else
1387 #if YY_NEVER_INTERACTIVE
1388         b->yy_is_interactive = 0;
1389 #else
1390         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1391 #endif
1392 #endif
1393         }
1394
1395
1396 #ifdef YY_USE_PROTOS
1397 void yy_flush_buffer( YY_BUFFER_STATE b )
1398 #else
1399 void yy_flush_buffer( b )
1400 YY_BUFFER_STATE b;
1401 #endif
1402
1403         {
1404         if ( ! b )
1405                 return;
1406
1407         b->yy_n_chars = 0;
1408
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.
1412          */
1413         b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1414         b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1415
1416         b->yy_buf_pos = &b->yy_ch_buf[0];
1417
1418         b->yy_at_bol = 1;
1419         b->yy_buffer_status = YY_BUFFER_NEW;
1420
1421         if ( b == yy_current_buffer )
1422                 yy_load_buffer_state();
1423         }
1424
1425
1426 #ifndef YY_NO_SCAN_BUFFER
1427 #ifdef YY_USE_PROTOS
1428 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1429 #else
1430 YY_BUFFER_STATE yy_scan_buffer( base, size )
1431 char *base;
1432 yy_size_t size;
1433 #endif
1434         {
1435         YY_BUFFER_STATE b;
1436
1437         if ( size < 2 ||
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. */
1441                 return 0;
1442
1443         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1444         if ( ! b )
1445                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1446
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;
1453         b->yy_at_bol = 1;
1454         b->yy_fill_buffer = 0;
1455         b->yy_buffer_status = YY_BUFFER_NEW;
1456
1457         yy_switch_to_buffer( b );
1458
1459         return b;
1460         }
1461 #endif
1462
1463
1464 #ifndef YY_NO_SCAN_STRING
1465 #ifdef YY_USE_PROTOS
1466 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1467 #else
1468 YY_BUFFER_STATE yy_scan_string( yy_str )
1469 yyconst char *yy_str;
1470 #endif
1471         {
1472         int len;
1473         for ( len = 0; yy_str[len]; ++len )
1474                 ;
1475
1476         return yy_scan_bytes( yy_str, len );
1477         }
1478 #endif
1479
1480
1481 #ifndef YY_NO_SCAN_BYTES
1482 #ifdef YY_USE_PROTOS
1483 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1484 #else
1485 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1486 yyconst char *bytes;
1487 int len;
1488 #endif
1489         {
1490         YY_BUFFER_STATE b;
1491         char *buf;
1492         yy_size_t n;
1493         int i;
1494
1495         /* Get memory for full buffer, including space for trailing EOB's. */
1496         n = len + 2;
1497         buf = (char *) yy_flex_alloc( n );
1498         if ( ! buf )
1499                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1500
1501         for ( i = 0; i < len; ++i )
1502                 buf[i] = bytes[i];
1503
1504         buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1505
1506         b = yy_scan_buffer( buf, n );
1507         if ( ! b )
1508                 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1509
1510         /* It's okay to grow etc. this buffer, and we should throw it
1511          * away when we're done.
1512          */
1513         b->yy_is_our_buffer = 1;
1514
1515         return b;
1516         }
1517 #endif
1518
1519
1520 #ifndef YY_NO_PUSH_STATE
1521 #ifdef YY_USE_PROTOS
1522 static void yy_push_state( int new_state )
1523 #else
1524 static void yy_push_state( new_state )
1525 int new_state;
1526 #endif
1527         {
1528         if ( yy_start_stack_ptr >= yy_start_stack_depth )
1529                 {
1530                 yy_size_t new_size;
1531
1532                 yy_start_stack_depth += YY_START_STACK_INCR;
1533                 new_size = yy_start_stack_depth * sizeof( int );
1534
1535                 if ( ! yy_start_stack )
1536                         yy_start_stack = (int *) yy_flex_alloc( new_size );
1537
1538                 else
1539                         yy_start_stack = (int *) yy_flex_realloc(
1540                                         (void *) yy_start_stack, new_size );
1541
1542                 if ( ! yy_start_stack )
1543                         YY_FATAL_ERROR(
1544                         "out of memory expanding start-condition stack" );
1545                 }
1546
1547         yy_start_stack[yy_start_stack_ptr++] = YY_START;
1548
1549         BEGIN(new_state);
1550         }
1551 #endif
1552
1553
1554 #ifndef YY_NO_POP_STATE
1555 static void yy_pop_state()
1556         {
1557         if ( --yy_start_stack_ptr < 0 )
1558                 YY_FATAL_ERROR( "start-condition stack underflow" );
1559
1560         BEGIN(yy_start_stack[yy_start_stack_ptr]);
1561         }
1562 #endif
1563
1564
1565 #ifndef YY_NO_TOP_STATE
1566 static int yy_top_state()
1567         {
1568         return yy_start_stack[yy_start_stack_ptr - 1];
1569         }
1570 #endif
1571
1572 #ifndef YY_EXIT_FAILURE
1573 #define YY_EXIT_FAILURE 2
1574 #endif
1575
1576 #ifdef YY_USE_PROTOS
1577 static void yy_fatal_error( yyconst char msg[] )
1578 #else
1579 static void yy_fatal_error( msg )
1580 char msg[];
1581 #endif
1582         {
1583         (void) fprintf( stderr, "%s\n", msg );
1584         exit( YY_EXIT_FAILURE );
1585         }
1586
1587
1588
1589 /* Redefine yyless() so it works in section 3 code. */
1590
1591 #undef yyless
1592 #define yyless(n) \
1593         do \
1594                 { \
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'; \
1600                 yyleng = n; \
1601                 } \
1602         while ( 0 )
1603
1604
1605 /* Internal utility routines. */
1606
1607 #ifndef yytext_ptr
1608 #ifdef YY_USE_PROTOS
1609 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1610 #else
1611 static void yy_flex_strncpy( s1, s2, n )
1612 char *s1;
1613 yyconst char *s2;
1614 int n;
1615 #endif
1616         {
1617         register int i;
1618         for ( i = 0; i < n; ++i )
1619                 s1[i] = s2[i];
1620         }
1621 #endif
1622
1623 #ifdef YY_NEED_STRLEN
1624 #ifdef YY_USE_PROTOS
1625 static int yy_flex_strlen( yyconst char *s )
1626 #else
1627 static int yy_flex_strlen( s )
1628 yyconst char *s;
1629 #endif
1630         {
1631         register int n;
1632         for ( n = 0; s[n]; ++n )
1633                 ;
1634
1635         return n;
1636         }
1637 #endif
1638
1639
1640 #ifdef YY_USE_PROTOS
1641 static void *yy_flex_alloc( yy_size_t size )
1642 #else
1643 static void *yy_flex_alloc( size )
1644 yy_size_t size;
1645 #endif
1646         {
1647         return (void *) malloc( size );
1648         }
1649
1650 #ifdef YY_USE_PROTOS
1651 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1652 #else
1653 static void *yy_flex_realloc( ptr, size )
1654 void *ptr;
1655 yy_size_t size;
1656 #endif
1657         {
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.
1664          */
1665         return (void *) realloc( (char *) ptr, size );
1666         }
1667
1668 #ifdef YY_USE_PROTOS
1669 static void yy_flex_free( void *ptr )
1670 #else
1671 static void yy_flex_free( ptr )
1672 void *ptr;
1673 #endif
1674         {
1675         free( ptr );
1676         }
1677
1678 #if YY_MAIN
1679 int main()
1680         {
1681         yylex();
1682         return 0;
1683         }
1684 #endif
1685 #line 107 "calclex.l"
1686
1687
1688 int
1689 yywrap ()
1690 {
1691   return 1;
1692 }