1
2#line 3 "calc++-scanner.cc"
3
4#define  YY_INT_ALIGNED short int
5
6/* A lexical scanner generated by flex */
7
8/* %not-for-header */
9
10/* %if-c-only */
11/* %if-not-reentrant */
12
13/* %endif */
14/* %endif */
15/* %ok-for-header */
16
17#define FLEX_SCANNER
18#define YY_FLEX_MAJOR_VERSION 2
19#define YY_FLEX_MINOR_VERSION 5
20#define YY_FLEX_SUBMINOR_VERSION 37
21#if YY_FLEX_SUBMINOR_VERSION > 0
22#define FLEX_BETA
23#endif
24
25/* %if-c++-only */
26/* %endif */
27
28/* %if-c-only */
29
30/* %endif */
31
32/* %if-c-only */
33
34/* %endif */
35
36/* First, we deal with  platform-specific or compiler-specific issues. */
37
38/* begin standard C headers. */
39/* %if-c-only */
40#include <stdio.h>
41#include <string.h>
42#include <errno.h>
43#include <stdlib.h>
44/* %endif */
45
46/* %if-tables-serialization */
47/* %endif */
48/* end standard C headers. */
49
50/* %if-c-or-c++ */
51/* flex integer type definitions */
52
53#ifndef FLEXINT_H
54#define FLEXINT_H
55
56/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
57
58#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
59
60/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
61 * if you want the limit (max/min) macros for int types.
62 */
63#ifndef __STDC_LIMIT_MACROS
64#define __STDC_LIMIT_MACROS 1
65#endif
66
67#include <inttypes.h>
68typedef int8_t flex_int8_t;
69typedef uint8_t flex_uint8_t;
70typedef int16_t flex_int16_t;
71typedef uint16_t flex_uint16_t;
72typedef int32_t flex_int32_t;
73typedef uint32_t flex_uint32_t;
74#else
75typedef signed char flex_int8_t;
76typedef short int flex_int16_t;
77typedef int flex_int32_t;
78typedef unsigned char flex_uint8_t;
79typedef unsigned short int flex_uint16_t;
80typedef unsigned int flex_uint32_t;
81
82/* Limits of integral types. */
83#ifndef INT8_MIN
84#define INT8_MIN               (-128)
85#endif
86#ifndef INT16_MIN
87#define INT16_MIN              (-32767-1)
88#endif
89#ifndef INT32_MIN
90#define INT32_MIN              (-2147483647-1)
91#endif
92#ifndef INT8_MAX
93#define INT8_MAX               (127)
94#endif
95#ifndef INT16_MAX
96#define INT16_MAX              (32767)
97#endif
98#ifndef INT32_MAX
99#define INT32_MAX              (2147483647)
100#endif
101#ifndef UINT8_MAX
102#define UINT8_MAX              (255U)
103#endif
104#ifndef UINT16_MAX
105#define UINT16_MAX             (65535U)
106#endif
107#ifndef UINT32_MAX
108#define UINT32_MAX             (4294967295U)
109#endif
110
111#endif /* ! C99 */
112
113#endif /* ! FLEXINT_H */
114
115/* %endif */
116
117/* %if-c++-only */
118/* %endif */
119
120#ifdef __cplusplus
121
122/* The "const" storage-class-modifier is valid. */
123#define YY_USE_CONST
124
125#else	/* ! __cplusplus */
126
127/* C99 requires __STDC__ to be defined as 1. */
128#if defined (__STDC__)
129
130#define YY_USE_CONST
131
132#endif	/* defined (__STDC__) */
133#endif	/* ! __cplusplus */
134
135#ifdef YY_USE_CONST
136#define yyconst const
137#else
138#define yyconst
139#endif
140
141/* %not-for-header */
142
143/* Returned upon end-of-file. */
144#define YY_NULL 0
145/* %ok-for-header */
146
147/* %not-for-header */
148
149/* Promotes a possibly negative, possibly signed char to an unsigned
150 * integer for use as an array index.  If the signed char is negative,
151 * we want to instead treat it as an 8-bit unsigned char, hence the
152 * double cast.
153 */
154#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
155/* %ok-for-header */
156
157/* %if-reentrant */
158/* %endif */
159
160/* %if-not-reentrant */
161
162/* %endif */
163
164/* Enter a start condition.  This macro really ought to take a parameter,
165 * but we do it the disgusting crufty way forced on us by the ()-less
166 * definition of BEGIN.
167 */
168#define BEGIN (yy_start) = 1 + 2 *
169
170/* Translate the current start state into a value that can be later handed
171 * to BEGIN to return to the state.  The YYSTATE alias is for lex
172 * compatibility.
173 */
174#define YY_START (((yy_start) - 1) / 2)
175#define YYSTATE YY_START
176
177/* Action number for EOF rule of a given start state. */
178#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
179
180/* Special action meaning "start processing a new file". */
181#define YY_NEW_FILE yyrestart(yyin  )
182
183#define YY_END_OF_BUFFER_CHAR 0
184
185/* Size of default input buffer. */
186#ifndef YY_BUF_SIZE
187#define YY_BUF_SIZE 16384
188#endif
189
190/* The state buf must be large enough to hold one state per character in the main buffer.
191 */
192#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
193
194#ifndef YY_TYPEDEF_YY_BUFFER_STATE
195#define YY_TYPEDEF_YY_BUFFER_STATE
196typedef struct yy_buffer_state *YY_BUFFER_STATE;
197#endif
198
199#ifndef YY_TYPEDEF_YY_SIZE_T
200#define YY_TYPEDEF_YY_SIZE_T
201typedef size_t yy_size_t;
202#endif
203
204/* %if-not-reentrant */
205extern yy_size_t yyleng;
206/* %endif */
207
208/* %if-c-only */
209/* %if-not-reentrant */
210extern FILE *yyin, *yyout;
211/* %endif */
212/* %endif */
213
214#define EOB_ACT_CONTINUE_SCAN 0
215#define EOB_ACT_END_OF_FILE 1
216#define EOB_ACT_LAST_MATCH 2
217
218    #define YY_LESS_LINENO(n)
219
220/* Return all but the first "n" matched characters back to the input stream. */
221#define yyless(n) \
222	do \
223		{ \
224		/* Undo effects of setting up yytext. */ \
225        int yyless_macro_arg = (n); \
226        YY_LESS_LINENO(yyless_macro_arg);\
227		*yy_cp = (yy_hold_char); \
228		YY_RESTORE_YY_MORE_OFFSET \
229		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
230		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
231		} \
232	while ( 0 )
233
234#define unput(c) yyunput( c, (yytext_ptr)  )
235
236#ifndef YY_STRUCT_YY_BUFFER_STATE
237#define YY_STRUCT_YY_BUFFER_STATE
238struct yy_buffer_state
239	{
240/* %if-c-only */
241	FILE *yy_input_file;
242/* %endif */
243
244/* %if-c++-only */
245/* %endif */
246
247	char *yy_ch_buf;		/* input buffer */
248	char *yy_buf_pos;		/* current position in input buffer */
249
250	/* Size of input buffer in bytes, not including room for EOB
251	 * characters.
252	 */
253	yy_size_t yy_buf_size;
254
255	/* Number of characters read into yy_ch_buf, not including EOB
256	 * characters.
257	 */
258	yy_size_t yy_n_chars;
259
260	/* Whether we "own" the buffer - i.e., we know we created it,
261	 * and can realloc() it to grow it, and should free() it to
262	 * delete it.
263	 */
264	int yy_is_our_buffer;
265
266	/* Whether this is an "interactive" input source; if so, and
267	 * if we're using stdio for input, then we want to use getc()
268	 * instead of fread(), to make sure we stop fetching input after
269	 * each newline.
270	 */
271	int yy_is_interactive;
272
273	/* Whether we're considered to be at the beginning of a line.
274	 * If so, '^' rules will be active on the next match, otherwise
275	 * not.
276	 */
277	int yy_at_bol;
278
279    int yy_bs_lineno; /**< The line count. */
280    int yy_bs_column; /**< The column count. */
281
282	/* Whether to try to fill the input buffer when we reach the
283	 * end of it.
284	 */
285	int yy_fill_buffer;
286
287	int yy_buffer_status;
288
289#define YY_BUFFER_NEW 0
290#define YY_BUFFER_NORMAL 1
291	/* When an EOF's been seen but there's still some text to process
292	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
293	 * shouldn't try reading from the input source any more.  We might
294	 * still have a bunch of tokens to match, though, because of
295	 * possible backing-up.
296	 *
297	 * When we actually see the EOF, we change the status to "new"
298	 * (via yyrestart()), so that the user can continue scanning by
299	 * just pointing yyin at a new input file.
300	 */
301#define YY_BUFFER_EOF_PENDING 2
302
303	};
304#endif /* !YY_STRUCT_YY_BUFFER_STATE */
305
306/* %if-c-only Standard (non-C++) definition */
307/* %not-for-header */
308
309/* %if-not-reentrant */
310
311/* Stack of input buffers. */
312static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
313static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
314static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
315/* %endif */
316/* %ok-for-header */
317
318/* %endif */
319
320/* We provide macros for accessing buffer states in case in the
321 * future we want to put the buffer states in a more general
322 * "scanner state".
323 *
324 * Returns the top of the stack, or NULL.
325 */
326#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
327                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
328                          : NULL)
329
330/* Same as previous macro, but useful when we know that the buffer stack is not
331 * NULL or when we need an lvalue. For internal use only.
332 */
333#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
334
335/* %if-c-only Standard (non-C++) definition */
336
337/* %if-not-reentrant */
338/* %not-for-header */
339
340/* yy_hold_char holds the character lost when yytext is formed. */
341static char yy_hold_char;
342static yy_size_t yy_n_chars;		/* number of characters read into yy_ch_buf */
343yy_size_t yyleng;
344
345/* Points to current character in buffer. */
346static char *yy_c_buf_p = (char *) 0;
347static int yy_init = 0;		/* whether we need to initialize */
348static int yy_start = 0;	/* start state number */
349
350/* Flag which is used to allow yywrap()'s to do buffer switches
351 * instead of setting up a fresh yyin.  A bit of a hack ...
352 */
353static int yy_did_buffer_switch_on_eof;
354/* %ok-for-header */
355
356/* %endif */
357
358void yyrestart (FILE *input_file  );
359void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
360YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
361void yy_delete_buffer (YY_BUFFER_STATE b  );
362void yy_flush_buffer (YY_BUFFER_STATE b  );
363void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
364void yypop_buffer_state (void );
365
366static void yyensure_buffer_stack (void );
367static void yy_load_buffer_state (void );
368static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
369
370#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
371
372YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
373YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
374YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len  );
375
376/* %endif */
377
378void *yyalloc (yy_size_t  );
379void *yyrealloc (void *,yy_size_t  );
380void yyfree (void *  );
381
382#define yy_new_buffer yy_create_buffer
383
384#define yy_set_interactive(is_interactive) \
385	{ \
386	if ( ! YY_CURRENT_BUFFER ){ \
387        yyensure_buffer_stack (); \
388		YY_CURRENT_BUFFER_LVALUE =    \
389            yy_create_buffer(yyin,YY_BUF_SIZE ); \
390	} \
391	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
392	}
393
394#define yy_set_bol(at_bol) \
395	{ \
396	if ( ! YY_CURRENT_BUFFER ){\
397        yyensure_buffer_stack (); \
398		YY_CURRENT_BUFFER_LVALUE =    \
399            yy_create_buffer(yyin,YY_BUF_SIZE ); \
400	} \
401	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
402	}
403
404#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
405
406/* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
407/* Begin user sect3 */
408
409#define yywrap() 1
410#define YY_SKIP_YYWRAP
411
412#define FLEX_DEBUG
413
414typedef unsigned char YY_CHAR;
415
416FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
417
418typedef int yy_state_type;
419
420extern int yylineno;
421
422int yylineno = 1;
423
424extern char *yytext;
425#define yytext_ptr yytext
426
427/* %if-c-only Standard (non-C++) definition */
428
429static yy_state_type yy_get_previous_state (void );
430static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
431static int yy_get_next_buffer (void );
432static void yy_fatal_error (yyconst char msg[]  );
433
434/* %endif */
435
436/* Done after the current pattern has been matched and before the
437 * corresponding action - sets up yytext.
438 */
439#define YY_DO_BEFORE_ACTION \
440	(yytext_ptr) = yy_bp; \
441/* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
442	yyleng = (size_t) (yy_cp - yy_bp); \
443	(yy_hold_char) = *yy_cp; \
444	*yy_cp = '\0'; \
445/* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
446	(yy_c_buf_p) = yy_cp;
447
448/* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
449#define YY_NUM_RULES 8
450#define YY_END_OF_BUFFER 9
451/* This struct is not used in this scanner,
452   but its presence is necessary. */
453struct yy_trans_info
454	{
455	flex_int32_t yy_verify;
456	flex_int32_t yy_nxt;
457	};
458static yyconst flex_int16_t yy_accept[17] =
459    {   0,
460        0,    0,    9,    7,    1,    2,    3,    5,    7,    6,
461        1,    2,    5,    4,    6,    0
462    } ;
463
464static yyconst flex_int32_t yy_ec[256] =
465    {   0,
466        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
467        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
468        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
469        1,    2,    1,    1,    1,    1,    1,    1,    1,    1,
470        1,    4,    4,    1,    4,    1,    4,    5,    5,    5,
471        5,    5,    5,    5,    5,    5,    5,    6,    1,    1,
472        7,    1,    1,    1,    8,    8,    8,    8,    8,    8,
473        8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
474        8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
475        1,    1,    1,    1,    9,    1,    8,    8,    8,    8,
476
477        8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
478        8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
479        8,    8,    1,    1,    1,    1,    1,    1,    1,    1,
480        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
481        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
482        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
483        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
484        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
485        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
486        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
487
488        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
489        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
490        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
491        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
492        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
493        1,    1,    1,    1,    1
494    } ;
495
496static yyconst flex_int32_t yy_meta[10] =
497    {   0,
498        1,    1,    1,    1,    2,    1,    1,    2,    2
499    } ;
500
501static yyconst flex_int16_t yy_base[18] =
502    {   0,
503        0,    0,   18,   19,   15,   13,   19,   10,    7,    0,
504       11,    9,    6,   19,    0,   19,    8
505    } ;
506
507static yyconst flex_int16_t yy_def[18] =
508    {   0,
509       16,    1,   16,   16,   16,   16,   16,   16,   16,   17,
510       16,   16,   16,   16,   17,    0,   16
511    } ;
512
513static yyconst flex_int16_t yy_nxt[29] =
514    {   0,
515        4,    5,    6,    7,    8,    9,    4,   10,    4,   15,
516       13,   12,   11,   14,   13,   12,   11,   16,    3,   16,
517       16,   16,   16,   16,   16,   16,   16,   16
518    } ;
519
520static yyconst flex_int16_t yy_chk[29] =
521    {   0,
522        1,    1,    1,    1,    1,    1,    1,    1,    1,   17,
523       13,   12,   11,    9,    8,    6,    5,    3,   16,   16,
524       16,   16,   16,   16,   16,   16,   16,   16
525    } ;
526
527static yy_state_type yy_last_accepting_state;
528static char *yy_last_accepting_cpos;
529
530extern int yy_flex_debug;
531int yy_flex_debug = 1;
532
533static yyconst flex_int16_t yy_rule_linenum[8] =
534    {   0,
535       37,   38,   44,   46,   49,   60,   66
536    } ;
537
538/* The intent behind this definition is that it'll catch
539 * any uses of REJECT which flex missed.
540 */
541#define REJECT reject_used_but_not_detected
542#define yymore() yymore_used_but_not_detected
543#define YY_MORE_ADJ 0
544#define YY_RESTORE_YY_MORE_OFFSET
545char *yytext;
546#line 1 "calc++-scanner.ll"
547#line 2 "calc++-scanner.ll"
548# include <cstdlib>
549# include <cerrno>
550# include <climits>
551# include <string>
552# include "calc++-driver.hh"
553# include "calc++-parser.hh"
554
555/* Work around an incompatibility in flex (at least versions
556   2.5.31 through 2.5.33): it generates code that does
557   not conform to C89.  See Debian bug 333231
558   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>.  */
559# undef yywrap
560# define yywrap() 1
561
562/* By default yylex returns int, we use token_type.
563   Unfortunately yyterminate by default returns 0, which is
564   not of token_type.  */
565#define yyterminate() return token::END
566#line 30 "calc++-scanner.ll"
567# define YY_USER_ACTION  yylloc->columns (yyleng);
568#line 569 "calc++-scanner.cc"
569
570#define INITIAL 0
571
572#ifndef YY_NO_UNISTD_H
573/* Special case for "unistd.h", since it is non-ANSI. We include it way
574 * down here because we want the user's section 1 to have been scanned first.
575 * The user has a chance to override it with an option.
576 */
577/* %if-c-only */
578#include <unistd.h>
579/* %endif */
580/* %if-c++-only */
581/* %endif */
582#endif
583
584#ifndef YY_EXTRA_TYPE
585#define YY_EXTRA_TYPE void *
586#endif
587
588/* %if-c-only Reentrant structure and macros (non-C++). */
589/* %if-reentrant */
590/* %if-c-only */
591
592static int yy_init_globals (void );
593
594/* %endif */
595/* %if-reentrant */
596/* %endif */
597/* %endif End reentrant structures and macros. */
598
599/* Accessor methods to globals.
600   These are made visible to non-reentrant scanners for convenience. */
601
602int yylex_destroy (void );
603
604int yyget_debug (void );
605
606void yyset_debug (int debug_flag  );
607
608YY_EXTRA_TYPE yyget_extra (void );
609
610void yyset_extra (YY_EXTRA_TYPE user_defined  );
611
612FILE *yyget_in (void );
613
614void yyset_in  (FILE * in_str  );
615
616FILE *yyget_out (void );
617
618void yyset_out  (FILE * out_str  );
619
620yy_size_t yyget_leng (void );
621
622char *yyget_text (void );
623
624int yyget_lineno (void );
625
626void yyset_lineno (int line_number  );
627
628/* %if-bison-bridge */
629/* %endif */
630
631/* Macros after this point can all be overridden by user definitions in
632 * section 1.
633 */
634
635#ifndef YY_SKIP_YYWRAP
636#ifdef __cplusplus
637extern "C" int yywrap (void );
638#else
639extern int yywrap (void );
640#endif
641#endif
642
643/* %not-for-header */
644
645/* %ok-for-header */
646
647/* %endif */
648
649#ifndef yytext_ptr
650static void yy_flex_strncpy (char *,yyconst char *,int );
651#endif
652
653#ifdef YY_NEED_STRLEN
654static int yy_flex_strlen (yyconst char * );
655#endif
656
657#ifndef YY_NO_INPUT
658/* %if-c-only Standard (non-C++) definition */
659/* %not-for-header */
660
661#ifdef __cplusplus
662static int yyinput (void );
663#else
664static int input (void );
665#endif
666/* %ok-for-header */
667
668/* %endif */
669#endif
670
671/* %if-c-only */
672
673/* %endif */
674
675/* Amount of stuff to slurp up with each read. */
676#ifndef YY_READ_BUF_SIZE
677#define YY_READ_BUF_SIZE 8192
678#endif
679
680/* Copy whatever the last rule matched to the standard output. */
681#ifndef ECHO
682/* %if-c-only Standard (non-C++) definition */
683/* This used to be an fputs(), but since the string might contain NUL's,
684 * we now use fwrite().
685 */
686#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
687/* %endif */
688/* %if-c++-only C++ definition */
689/* %endif */
690#endif
691
692/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
693 * is returned in "result".
694 */
695#ifndef YY_INPUT
696#define YY_INPUT(buf,result,max_size) \
697/* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
698	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
699		{ \
700		int c = '*'; \
701		size_t n; \
702		for ( n = 0; n < max_size && \
703			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
704			buf[n] = (char) c; \
705		if ( c == '\n' ) \
706			buf[n++] = (char) c; \
707		if ( c == EOF && ferror( yyin ) ) \
708			YY_FATAL_ERROR( "input in flex scanner failed" ); \
709		result = n; \
710		} \
711	else \
712		{ \
713		errno=0; \
714		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
715			{ \
716			if( errno != EINTR) \
717				{ \
718				YY_FATAL_ERROR( "input in flex scanner failed" ); \
719				break; \
720				} \
721			errno=0; \
722			clearerr(yyin); \
723			} \
724		}\
725\
726/* %if-c++-only C++ definition \ */\
727/* %endif */
728
729#endif
730
731/* No semi-colon after return; correct usage is to write "yyterminate();" -
732 * we don't want an extra ';' after the "return" because that will cause
733 * some compilers to complain about unreachable statements.
734 */
735#ifndef yyterminate
736#define yyterminate() return YY_NULL
737#endif
738
739/* Number of entries by which start-condition stack grows. */
740#ifndef YY_START_STACK_INCR
741#define YY_START_STACK_INCR 25
742#endif
743
744/* Report a fatal error. */
745#ifndef YY_FATAL_ERROR
746/* %if-c-only */
747#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
748/* %endif */
749/* %if-c++-only */
750/* %endif */
751#endif
752
753/* %if-tables-serialization structures and prototypes */
754/* %not-for-header */
755
756/* %ok-for-header */
757
758/* %not-for-header */
759
760/* %tables-yydmap generated elements */
761/* %endif */
762/* end tables serialization structures and prototypes */
763
764/* %ok-for-header */
765
766/* Default declaration of generated scanner - a define so the user can
767 * easily add parameters.
768 */
769#ifndef YY_DECL
770#define YY_DECL_IS_OURS 1
771/* %if-c-only Standard (non-C++) definition */
772
773extern int yylex (void);
774
775#define YY_DECL int yylex (void)
776/* %endif */
777/* %if-c++-only C++ definition */
778/* %endif */
779#endif /* !YY_DECL */
780
781/* Code executed at the beginning of each rule, after yytext and yyleng
782 * have been set up.
783 */
784#ifndef YY_USER_ACTION
785#define YY_USER_ACTION
786#endif
787
788/* Code executed at the end of each rule. */
789#ifndef YY_BREAK
790#define YY_BREAK break;
791#endif
792
793/* %% [6.0] YY_RULE_SETUP definition goes here */
794#define YY_RULE_SETUP \
795	YY_USER_ACTION
796
797/* %not-for-header */
798
799/** The main scanner function which does all the work.
800 */
801YY_DECL
802{
803	register yy_state_type yy_current_state;
804	register char *yy_cp, *yy_bp;
805	register int yy_act;
806
807/* %% [7.0] user's declarations go here */
808#line 33 "calc++-scanner.ll"
809
810
811  yylloc->step ();
812
813#line 814 "calc++-scanner.cc"
814
815	if ( !(yy_init) )
816		{
817		(yy_init) = 1;
818
819#ifdef YY_USER_INIT
820		YY_USER_INIT;
821#endif
822
823		if ( ! (yy_start) )
824			(yy_start) = 1;	/* first start state */
825
826		if ( ! yyin )
827/* %if-c-only */
828			yyin = stdin;
829/* %endif */
830/* %if-c++-only */
831/* %endif */
832
833		if ( ! yyout )
834/* %if-c-only */
835			yyout = stdout;
836/* %endif */
837/* %if-c++-only */
838/* %endif */
839
840		if ( ! YY_CURRENT_BUFFER ) {
841			yyensure_buffer_stack ();
842			YY_CURRENT_BUFFER_LVALUE =
843				yy_create_buffer(yyin,YY_BUF_SIZE );
844		}
845
846		yy_load_buffer_state( );
847		}
848
849	while ( 1 )		/* loops until end-of-file is reached */
850		{
851/* %% [8.0] yymore()-related code goes here */
852		yy_cp = (yy_c_buf_p);
853
854		/* Support of yytext. */
855		*yy_cp = (yy_hold_char);
856
857		/* yy_bp points to the position in yy_ch_buf of the start of
858		 * the current run.
859		 */
860		yy_bp = yy_cp;
861
862/* %% [9.0] code to set up and find next match goes here */
863		yy_current_state = (yy_start);
864yy_match:
865		do
866			{
867			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
868			if ( yy_accept[yy_current_state] )
869				{
870				(yy_last_accepting_state) = yy_current_state;
871				(yy_last_accepting_cpos) = yy_cp;
872				}
873			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
874				{
875				yy_current_state = (int) yy_def[yy_current_state];
876				if ( yy_current_state >= 17 )
877					yy_c = yy_meta[(unsigned int) yy_c];
878				}
879			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
880			++yy_cp;
881			}
882		while ( yy_current_state != 16 );
883		yy_cp = (yy_last_accepting_cpos);
884		yy_current_state = (yy_last_accepting_state);
885
886yy_find_action:
887/* %% [10.0] code to find the action number goes here */
888		yy_act = yy_accept[yy_current_state];
889
890		YY_DO_BEFORE_ACTION;
891
892/* %% [11.0] code for yylineno update goes here */
893
894do_action:	/* This label is used only to access EOF actions. */
895
896/* %% [12.0] debug code goes here */
897		if ( yy_flex_debug )
898			{
899			if ( yy_act == 0 )
900				fprintf( stderr, "--scanner backing up\n" );
901			else if ( yy_act < 8 )
902				fprintf( stderr, "--accepting rule at line %ld (\"%s\")\n",
903				         (long)yy_rule_linenum[yy_act], yytext );
904			else if ( yy_act == 8 )
905				fprintf( stderr, "--accepting default rule (\"%s\")\n",
906				         yytext );
907			else if ( yy_act == 9 )
908				fprintf( stderr, "--(end of buffer or a NUL)\n" );
909			else
910				fprintf( stderr, "--EOF (start condition %d)\n", YY_START );
911			}
912
913		switch ( yy_act )
914	{ /* beginning of action switch */
915/* %% [13.0] actions go here */
916			case 0: /* must back up */
917			/* undo the effects of YY_DO_BEFORE_ACTION */
918			*yy_cp = (yy_hold_char);
919			yy_cp = (yy_last_accepting_cpos);
920			yy_current_state = (yy_last_accepting_state);
921			goto yy_find_action;
922
923case 1:
924YY_RULE_SETUP
925#line 37 "calc++-scanner.ll"
926yylloc->step ();
927	YY_BREAK
928case 2:
929/* rule 2 can match eol */
930YY_RULE_SETUP
931#line 38 "calc++-scanner.ll"
932yylloc->lines (yyleng); yylloc->step ();
933	YY_BREAK
934
935  typedef yy::calcxx_parser::token token;
936
937/* Convert ints to the actual type of tokens.  */
938case 3:
939YY_RULE_SETUP
940#line 44 "calc++-scanner.ll"
941return yy::calcxx_parser::token_type (yytext[0]);
942	YY_BREAK
943case 4:
944YY_RULE_SETUP
945#line 46 "calc++-scanner.ll"
946return token::ASSIGN;
947	YY_BREAK
948case 5:
949YY_RULE_SETUP
950#line 49 "calc++-scanner.ll"
951{
952           errno = 0;
953           long n = strtol (yytext, NULL, 10);
954           if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
955             driver.error (*yylloc, "integer is out of range");
956           yylval->ival = n;
957           return token::NUMBER;
958         }
959	YY_BREAK
960case 6:
961YY_RULE_SETUP
962#line 60 "calc++-scanner.ll"
963{
964           yylval->sval = new std::string (yytext);
965           return token::IDENTIFIER;
966         }
967	YY_BREAK
968case 7:
969YY_RULE_SETUP
970#line 66 "calc++-scanner.ll"
971driver.error (*yylloc, "invalid character");
972	YY_BREAK
973case 8:
974YY_RULE_SETUP
975#line 67 "calc++-scanner.ll"
976ECHO;
977	YY_BREAK
978#line 979 "calc++-scanner.cc"
979case YY_STATE_EOF(INITIAL):
980	yyterminate();
981
982	case YY_END_OF_BUFFER:
983		{
984		/* Amount of text matched not including the EOB char. */
985		int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
986
987		/* Undo the effects of YY_DO_BEFORE_ACTION. */
988		*yy_cp = (yy_hold_char);
989		YY_RESTORE_YY_MORE_OFFSET
990
991		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
992			{
993			/* We're scanning a new file or input source.  It's
994			 * possible that this happened because the user
995			 * just pointed yyin at a new source and called
996			 * yylex().  If so, then we have to assure
997			 * consistency between YY_CURRENT_BUFFER and our
998			 * globals.  Here is the right place to do so, because
999			 * this is the first action (other than possibly a
1000			 * back-up) that will match for the new input source.
1001			 */
1002			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1003			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1004			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1005			}
1006
1007		/* Note that here we test for yy_c_buf_p "<=" to the position
1008		 * of the first EOB in the buffer, since yy_c_buf_p will
1009		 * already have been incremented past the NUL character
1010		 * (since all states make transitions on EOB to the
1011		 * end-of-buffer state).  Contrast this with the test
1012		 * in input().
1013		 */
1014		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1015			{ /* This was really a NUL. */
1016			yy_state_type yy_next_state;
1017
1018			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1019
1020			yy_current_state = yy_get_previous_state(  );
1021
1022			/* Okay, we're now positioned to make the NUL
1023			 * transition.  We couldn't have
1024			 * yy_get_previous_state() go ahead and do it
1025			 * for us because it doesn't know how to deal
1026			 * with the possibility of jamming (and we don't
1027			 * want to build jamming into it because then it
1028			 * will run more slowly).
1029			 */
1030
1031			yy_next_state = yy_try_NUL_trans( yy_current_state );
1032
1033			yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1034
1035			if ( yy_next_state )
1036				{
1037				/* Consume the NUL. */
1038				yy_cp = ++(yy_c_buf_p);
1039				yy_current_state = yy_next_state;
1040				goto yy_match;
1041				}
1042
1043			else
1044				{
1045/* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
1046				yy_cp = (yy_last_accepting_cpos);
1047				yy_current_state = (yy_last_accepting_state);
1048				goto yy_find_action;
1049				}
1050			}
1051
1052		else switch ( yy_get_next_buffer(  ) )
1053			{
1054			case EOB_ACT_END_OF_FILE:
1055				{
1056				(yy_did_buffer_switch_on_eof) = 0;
1057
1058				if ( yywrap( ) )
1059					{
1060					/* Note: because we've taken care in
1061					 * yy_get_next_buffer() to have set up
1062					 * yytext, we can now set up
1063					 * yy_c_buf_p so that if some total
1064					 * hoser (like flex itself) wants to
1065					 * call the scanner after we return the
1066					 * YY_NULL, it'll still work - another
1067					 * YY_NULL will get returned.
1068					 */
1069					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1070
1071					yy_act = YY_STATE_EOF(YY_START);
1072					goto do_action;
1073					}
1074
1075				else
1076					{
1077					if ( ! (yy_did_buffer_switch_on_eof) )
1078						YY_NEW_FILE;
1079					}
1080				break;
1081				}
1082
1083			case EOB_ACT_CONTINUE_SCAN:
1084				(yy_c_buf_p) =
1085					(yytext_ptr) + yy_amount_of_matched_text;
1086
1087				yy_current_state = yy_get_previous_state(  );
1088
1089				yy_cp = (yy_c_buf_p);
1090				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1091				goto yy_match;
1092
1093			case EOB_ACT_LAST_MATCH:
1094				(yy_c_buf_p) =
1095				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1096
1097				yy_current_state = yy_get_previous_state(  );
1098
1099				yy_cp = (yy_c_buf_p);
1100				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1101				goto yy_find_action;
1102			}
1103		break;
1104		}
1105
1106	default:
1107		YY_FATAL_ERROR(
1108			"fatal flex scanner internal error--no action found" );
1109	} /* end of action switch */
1110		} /* end of scanning one token */
1111} /* end of yylex */
1112/* %ok-for-header */
1113
1114/* %if-c++-only */
1115/* %not-for-header */
1116
1117/* %ok-for-header */
1118
1119/* %endif */
1120
1121/* yy_get_next_buffer - try to read in a new buffer
1122 *
1123 * Returns a code representing an action:
1124 *	EOB_ACT_LAST_MATCH -
1125 *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1126 *	EOB_ACT_END_OF_FILE - end of file
1127 */
1128/* %if-c-only */
1129static int yy_get_next_buffer (void)
1130/* %endif */
1131/* %if-c++-only */
1132/* %endif */
1133{
1134    	register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1135	register char *source = (yytext_ptr);
1136	register int number_to_move, i;
1137	int ret_val;
1138
1139	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1140		YY_FATAL_ERROR(
1141		"fatal flex scanner internal error--end of buffer missed" );
1142
1143	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1144		{ /* Don't try to fill the buffer, so this is an EOF. */
1145		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1146			{
1147			/* We matched a single character, the EOB, so
1148			 * treat this as a final EOF.
1149			 */
1150			return EOB_ACT_END_OF_FILE;
1151			}
1152
1153		else
1154			{
1155			/* We matched some text prior to the EOB, first
1156			 * process it.
1157			 */
1158			return EOB_ACT_LAST_MATCH;
1159			}
1160		}
1161
1162	/* Try to read more data. */
1163
1164	/* First move last chars to start of buffer. */
1165	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1166
1167	for ( i = 0; i < number_to_move; ++i )
1168		*(dest++) = *(source++);
1169
1170	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1171		/* don't do the read, it's not guaranteed to return an EOF,
1172		 * just force an EOF
1173		 */
1174		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1175
1176	else
1177		{
1178			yy_size_t num_to_read =
1179			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1180
1181		while ( num_to_read <= 0 )
1182			{ /* Not enough room in the buffer - grow it. */
1183
1184			/* just a shorter name for the current buffer */
1185			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1186
1187			int yy_c_buf_p_offset =
1188				(int) ((yy_c_buf_p) - b->yy_ch_buf);
1189
1190			if ( b->yy_is_our_buffer )
1191				{
1192				yy_size_t new_size = b->yy_buf_size * 2;
1193
1194				if ( new_size <= 0 )
1195					b->yy_buf_size += b->yy_buf_size / 8;
1196				else
1197					b->yy_buf_size *= 2;
1198
1199				b->yy_ch_buf = (char *)
1200					/* Include room in for 2 EOB chars. */
1201					yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
1202				}
1203			else
1204				/* Can't grow it, we don't own it. */
1205				b->yy_ch_buf = 0;
1206
1207			if ( ! b->yy_ch_buf )
1208				YY_FATAL_ERROR(
1209				"fatal error - scanner input buffer overflow" );
1210
1211			(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1212
1213			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1214						number_to_move - 1;
1215
1216			}
1217
1218		if ( num_to_read > YY_READ_BUF_SIZE )
1219			num_to_read = YY_READ_BUF_SIZE;
1220
1221		/* Read in more data. */
1222		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1223			(yy_n_chars), num_to_read );
1224
1225		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1226		}
1227
1228	if ( (yy_n_chars) == 0 )
1229		{
1230		if ( number_to_move == YY_MORE_ADJ )
1231			{
1232			ret_val = EOB_ACT_END_OF_FILE;
1233			yyrestart(yyin  );
1234			}
1235
1236		else
1237			{
1238			ret_val = EOB_ACT_LAST_MATCH;
1239			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1240				YY_BUFFER_EOF_PENDING;
1241			}
1242		}
1243
1244	else
1245		ret_val = EOB_ACT_CONTINUE_SCAN;
1246
1247	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1248		/* Extend the array by 50%, plus the number we really need. */
1249		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1250		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
1251		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1252			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1253	}
1254
1255	(yy_n_chars) += number_to_move;
1256	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1257	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1258
1259	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1260
1261	return ret_val;
1262}
1263
1264/* yy_get_previous_state - get the state just before the EOB char was reached */
1265
1266/* %if-c-only */
1267/* %not-for-header */
1268
1269    static yy_state_type yy_get_previous_state (void)
1270/* %endif */
1271/* %if-c++-only */
1272/* %endif */
1273{
1274	register yy_state_type yy_current_state;
1275	register char *yy_cp;
1276
1277/* %% [15.0] code to get the start state into yy_current_state goes here */
1278	yy_current_state = (yy_start);
1279
1280	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1281		{
1282/* %% [16.0] code to find the next state goes here */
1283		register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1284		if ( yy_accept[yy_current_state] )
1285			{
1286			(yy_last_accepting_state) = yy_current_state;
1287			(yy_last_accepting_cpos) = yy_cp;
1288			}
1289		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1290			{
1291			yy_current_state = (int) yy_def[yy_current_state];
1292			if ( yy_current_state >= 17 )
1293				yy_c = yy_meta[(unsigned int) yy_c];
1294			}
1295		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1296		}
1297
1298	return yy_current_state;
1299}
1300
1301/* yy_try_NUL_trans - try to make a transition on the NUL character
1302 *
1303 * synopsis
1304 *	next_state = yy_try_NUL_trans( current_state );
1305 */
1306/* %if-c-only */
1307    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
1308/* %endif */
1309/* %if-c++-only */
1310/* %endif */
1311{
1312	register int yy_is_jam;
1313    /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
1314	register char *yy_cp = (yy_c_buf_p);
1315
1316	register YY_CHAR yy_c = 1;
1317	if ( yy_accept[yy_current_state] )
1318		{
1319		(yy_last_accepting_state) = yy_current_state;
1320		(yy_last_accepting_cpos) = yy_cp;
1321		}
1322	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1323		{
1324		yy_current_state = (int) yy_def[yy_current_state];
1325		if ( yy_current_state >= 17 )
1326			yy_c = yy_meta[(unsigned int) yy_c];
1327		}
1328	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1329	yy_is_jam = (yy_current_state == 16);
1330
1331		return yy_is_jam ? 0 : yy_current_state;
1332}
1333
1334/* %if-c-only */
1335
1336/* %endif */
1337
1338/* %if-c-only */
1339#ifndef YY_NO_INPUT
1340#ifdef __cplusplus
1341    static int yyinput (void)
1342#else
1343    static int input  (void)
1344#endif
1345
1346/* %endif */
1347/* %if-c++-only */
1348/* %endif */
1349{
1350	int c;
1351
1352	*(yy_c_buf_p) = (yy_hold_char);
1353
1354	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1355		{
1356		/* yy_c_buf_p now points to the character we want to return.
1357		 * If this occurs *before* the EOB characters, then it's a
1358		 * valid NUL; if not, then we've hit the end of the buffer.
1359		 */
1360		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1361			/* This was really a NUL. */
1362			*(yy_c_buf_p) = '\0';
1363
1364		else
1365			{ /* need more input */
1366			yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1367			++(yy_c_buf_p);
1368
1369			switch ( yy_get_next_buffer(  ) )
1370				{
1371				case EOB_ACT_LAST_MATCH:
1372					/* This happens because yy_g_n_b()
1373					 * sees that we've accumulated a
1374					 * token and flags that we need to
1375					 * try matching the token before
1376					 * proceeding.  But for input(),
1377					 * there's no matching to consider.
1378					 * So convert the EOB_ACT_LAST_MATCH
1379					 * to EOB_ACT_END_OF_FILE.
1380					 */
1381
1382					/* Reset buffer status. */
1383					yyrestart(yyin );
1384
1385					/*FALLTHROUGH*/
1386
1387				case EOB_ACT_END_OF_FILE:
1388					{
1389					if ( yywrap( ) )
1390						return EOF;
1391
1392					if ( ! (yy_did_buffer_switch_on_eof) )
1393						YY_NEW_FILE;
1394#ifdef __cplusplus
1395					return yyinput();
1396#else
1397					return input();
1398#endif
1399					}
1400
1401				case EOB_ACT_CONTINUE_SCAN:
1402					(yy_c_buf_p) = (yytext_ptr) + offset;
1403					break;
1404				}
1405			}
1406		}
1407
1408	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
1409	*(yy_c_buf_p) = '\0';	/* preserve yytext */
1410	(yy_hold_char) = *++(yy_c_buf_p);
1411
1412/* %% [19.0] update BOL and yylineno */
1413
1414	return c;
1415}
1416/* %if-c-only */
1417#endif	/* ifndef YY_NO_INPUT */
1418/* %endif */
1419
1420/** Immediately switch to a different input stream.
1421 * @param input_file A readable stream.
1422 *
1423 * @note This function does not reset the start condition to @c INITIAL .
1424 */
1425/* %if-c-only */
1426    void yyrestart  (FILE * input_file )
1427/* %endif */
1428/* %if-c++-only */
1429/* %endif */
1430{
1431
1432	if ( ! YY_CURRENT_BUFFER ){
1433        yyensure_buffer_stack ();
1434		YY_CURRENT_BUFFER_LVALUE =
1435            yy_create_buffer(yyin,YY_BUF_SIZE );
1436	}
1437
1438	yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1439	yy_load_buffer_state( );
1440}
1441
1442/** Switch to a different input buffer.
1443 * @param new_buffer The new input buffer.
1444 *
1445 */
1446/* %if-c-only */
1447    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1448/* %endif */
1449/* %if-c++-only */
1450/* %endif */
1451{
1452
1453	/* TODO. We should be able to replace this entire function body
1454	 * with
1455	 *		yypop_buffer_state();
1456	 *		yypush_buffer_state(new_buffer);
1457     */
1458	yyensure_buffer_stack ();
1459	if ( YY_CURRENT_BUFFER == new_buffer )
1460		return;
1461
1462	if ( YY_CURRENT_BUFFER )
1463		{
1464		/* Flush out information for old buffer. */
1465		*(yy_c_buf_p) = (yy_hold_char);
1466		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1467		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1468		}
1469
1470	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1471	yy_load_buffer_state( );
1472
1473	/* We don't actually know whether we did this switch during
1474	 * EOF (yywrap()) processing, but the only time this flag
1475	 * is looked at is after yywrap() is called, so it's safe
1476	 * to go ahead and always set it.
1477	 */
1478	(yy_did_buffer_switch_on_eof) = 1;
1479}
1480
1481/* %if-c-only */
1482static void yy_load_buffer_state  (void)
1483/* %endif */
1484/* %if-c++-only */
1485/* %endif */
1486{
1487    	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1488	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1489	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1490	(yy_hold_char) = *(yy_c_buf_p);
1491}
1492
1493/** Allocate and initialize an input buffer state.
1494 * @param file A readable stream.
1495 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1496 *
1497 * @return the allocated buffer state.
1498 */
1499/* %if-c-only */
1500    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
1501/* %endif */
1502/* %if-c++-only */
1503/* %endif */
1504{
1505	YY_BUFFER_STATE b;
1506
1507	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1508	if ( ! b )
1509		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1510
1511	b->yy_buf_size = size;
1512
1513	/* yy_ch_buf has to be 2 characters longer than the size given because
1514	 * we need to put in 2 end-of-buffer characters.
1515	 */
1516	b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
1517	if ( ! b->yy_ch_buf )
1518		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1519
1520	b->yy_is_our_buffer = 1;
1521
1522	yy_init_buffer(b,file );
1523
1524	return b;
1525}
1526
1527/** Destroy the buffer.
1528 * @param b a buffer created with yy_create_buffer()
1529 *
1530 */
1531/* %if-c-only */
1532    void yy_delete_buffer (YY_BUFFER_STATE  b )
1533/* %endif */
1534/* %if-c++-only */
1535/* %endif */
1536{
1537
1538	if ( ! b )
1539		return;
1540
1541	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1542		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1543
1544	if ( b->yy_is_our_buffer )
1545		yyfree((void *) b->yy_ch_buf  );
1546
1547	yyfree((void *) b  );
1548}
1549
1550/* Initializes or reinitializes a buffer.
1551 * This function is sometimes called more than once on the same buffer,
1552 * such as during a yyrestart() or at EOF.
1553 */
1554/* %if-c-only */
1555    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1556/* %endif */
1557/* %if-c++-only */
1558/* %endif */
1559
1560{
1561	int oerrno = errno;
1562
1563	yy_flush_buffer(b );
1564
1565	b->yy_input_file = file;
1566	b->yy_fill_buffer = 1;
1567
1568    /* If b is the current buffer, then yy_init_buffer was _probably_
1569     * called from yyrestart() or through yy_get_next_buffer.
1570     * In that case, we don't want to reset the lineno or column.
1571     */
1572    if (b != YY_CURRENT_BUFFER){
1573        b->yy_bs_lineno = 1;
1574        b->yy_bs_column = 0;
1575    }
1576
1577/* %if-c-only */
1578
1579        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1580
1581/* %endif */
1582/* %if-c++-only */
1583/* %endif */
1584	errno = oerrno;
1585}
1586
1587/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1588 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1589 *
1590 */
1591/* %if-c-only */
1592    void yy_flush_buffer (YY_BUFFER_STATE  b )
1593/* %endif */
1594/* %if-c++-only */
1595/* %endif */
1596{
1597    	if ( ! b )
1598		return;
1599
1600	b->yy_n_chars = 0;
1601
1602	/* We always need two end-of-buffer characters.  The first causes
1603	 * a transition to the end-of-buffer state.  The second causes
1604	 * a jam in that state.
1605	 */
1606	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1607	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1608
1609	b->yy_buf_pos = &b->yy_ch_buf[0];
1610
1611	b->yy_at_bol = 1;
1612	b->yy_buffer_status = YY_BUFFER_NEW;
1613
1614	if ( b == YY_CURRENT_BUFFER )
1615		yy_load_buffer_state( );
1616}
1617
1618/* %if-c-or-c++ */
1619/** Pushes the new state onto the stack. The new state becomes
1620 *  the current state. This function will allocate the stack
1621 *  if necessary.
1622 *  @param new_buffer The new state.
1623 *
1624 */
1625/* %if-c-only */
1626void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1627/* %endif */
1628/* %if-c++-only */
1629/* %endif */
1630{
1631    	if (new_buffer == NULL)
1632		return;
1633
1634	yyensure_buffer_stack();
1635
1636	/* This block is copied from yy_switch_to_buffer. */
1637	if ( YY_CURRENT_BUFFER )
1638		{
1639		/* Flush out information for old buffer. */
1640		*(yy_c_buf_p) = (yy_hold_char);
1641		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1642		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1643		}
1644
1645	/* Only push if top exists. Otherwise, replace top. */
1646	if (YY_CURRENT_BUFFER)
1647		(yy_buffer_stack_top)++;
1648	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1649
1650	/* copied from yy_switch_to_buffer. */
1651	yy_load_buffer_state( );
1652	(yy_did_buffer_switch_on_eof) = 1;
1653}
1654/* %endif */
1655
1656/* %if-c-or-c++ */
1657/** Removes and deletes the top of the stack, if present.
1658 *  The next element becomes the new top.
1659 *
1660 */
1661/* %if-c-only */
1662void yypop_buffer_state (void)
1663/* %endif */
1664/* %if-c++-only */
1665/* %endif */
1666{
1667    	if (!YY_CURRENT_BUFFER)
1668		return;
1669
1670	yy_delete_buffer(YY_CURRENT_BUFFER );
1671	YY_CURRENT_BUFFER_LVALUE = NULL;
1672	if ((yy_buffer_stack_top) > 0)
1673		--(yy_buffer_stack_top);
1674
1675	if (YY_CURRENT_BUFFER) {
1676		yy_load_buffer_state( );
1677		(yy_did_buffer_switch_on_eof) = 1;
1678	}
1679}
1680/* %endif */
1681
1682/* %if-c-or-c++ */
1683/* Allocates the stack if it does not exist.
1684 *  Guarantees space for at least one push.
1685 */
1686/* %if-c-only */
1687static void yyensure_buffer_stack (void)
1688/* %endif */
1689/* %if-c++-only */
1690/* %endif */
1691{
1692	yy_size_t num_to_alloc;
1693
1694	if (!(yy_buffer_stack)) {
1695
1696		/* First allocation is just for 2 elements, since we don't know if this
1697		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1698		 * immediate realloc on the next call.
1699         */
1700		num_to_alloc = 1;
1701		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1702								(num_to_alloc * sizeof(struct yy_buffer_state*)
1703								);
1704		if ( ! (yy_buffer_stack) )
1705			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1706
1707		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1708
1709		(yy_buffer_stack_max) = num_to_alloc;
1710		(yy_buffer_stack_top) = 0;
1711		return;
1712	}
1713
1714	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1715
1716		/* Increase the buffer to prepare for a possible push. */
1717		int grow_size = 8 /* arbitrary grow size */;
1718
1719		num_to_alloc = (yy_buffer_stack_max) + grow_size;
1720		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1721								((yy_buffer_stack),
1722								num_to_alloc * sizeof(struct yy_buffer_state*)
1723								);
1724		if ( ! (yy_buffer_stack) )
1725			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1726
1727		/* zero only the new slots.*/
1728		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1729		(yy_buffer_stack_max) = num_to_alloc;
1730	}
1731}
1732/* %endif */
1733
1734/* %if-c-only */
1735/** Setup the input buffer state to scan directly from a user-specified character buffer.
1736 * @param base the character buffer
1737 * @param size the size in bytes of the character buffer
1738 *
1739 * @return the newly allocated buffer state object.
1740 */
1741YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
1742{
1743	YY_BUFFER_STATE b;
1744
1745	if ( size < 2 ||
1746	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
1747	     base[size-1] != YY_END_OF_BUFFER_CHAR )
1748		/* They forgot to leave room for the EOB's. */
1749		return 0;
1750
1751	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1752	if ( ! b )
1753		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1754
1755	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
1756	b->yy_buf_pos = b->yy_ch_buf = base;
1757	b->yy_is_our_buffer = 0;
1758	b->yy_input_file = 0;
1759	b->yy_n_chars = b->yy_buf_size;
1760	b->yy_is_interactive = 0;
1761	b->yy_at_bol = 1;
1762	b->yy_fill_buffer = 0;
1763	b->yy_buffer_status = YY_BUFFER_NEW;
1764
1765	yy_switch_to_buffer(b  );
1766
1767	return b;
1768}
1769/* %endif */
1770
1771/* %if-c-only */
1772/** Setup the input buffer state to scan a string. The next call to yylex() will
1773 * scan from a @e copy of @a str.
1774 * @param yystr a NUL-terminated string to scan
1775 *
1776 * @return the newly allocated buffer state object.
1777 * @note If you want to scan bytes that may contain NUL values, then use
1778 *       yy_scan_bytes() instead.
1779 */
1780YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1781{
1782
1783	return yy_scan_bytes(yystr,strlen(yystr) );
1784}
1785/* %endif */
1786
1787/* %if-c-only */
1788/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1789 * scan from a @e copy of @a bytes.
1790 * @param yybytes the byte buffer to scan
1791 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1792 *
1793 * @return the newly allocated buffer state object.
1794 */
1795YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
1796{
1797	YY_BUFFER_STATE b;
1798	char *buf;
1799	yy_size_t n;
1800	int i;
1801
1802	/* Get memory for full buffer, including space for trailing EOB's. */
1803	n = _yybytes_len + 2;
1804	buf = (char *) yyalloc(n  );
1805	if ( ! buf )
1806		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1807
1808	for ( i = 0; i < _yybytes_len; ++i )
1809		buf[i] = yybytes[i];
1810
1811	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1812
1813	b = yy_scan_buffer(buf,n );
1814	if ( ! b )
1815		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1816
1817	/* It's okay to grow etc. this buffer, and we should throw it
1818	 * away when we're done.
1819	 */
1820	b->yy_is_our_buffer = 1;
1821
1822	return b;
1823}
1824/* %endif */
1825
1826#ifndef YY_EXIT_FAILURE
1827#define YY_EXIT_FAILURE 2
1828#endif
1829
1830/* %if-c-only */
1831static void yy_fatal_error (yyconst char* msg )
1832{
1833    	(void) fprintf( stderr, "%s\n", msg );
1834	exit( YY_EXIT_FAILURE );
1835}
1836/* %endif */
1837/* %if-c++-only */
1838/* %endif */
1839
1840/* Redefine yyless() so it works in section 3 code. */
1841
1842#undef yyless
1843#define yyless(n) \
1844	do \
1845		{ \
1846		/* Undo effects of setting up yytext. */ \
1847        int yyless_macro_arg = (n); \
1848        YY_LESS_LINENO(yyless_macro_arg);\
1849		yytext[yyleng] = (yy_hold_char); \
1850		(yy_c_buf_p) = yytext + yyless_macro_arg; \
1851		(yy_hold_char) = *(yy_c_buf_p); \
1852		*(yy_c_buf_p) = '\0'; \
1853		yyleng = yyless_macro_arg; \
1854		} \
1855	while ( 0 )
1856
1857/* Accessor  methods (get/set functions) to struct members. */
1858
1859/* %if-c-only */
1860/* %if-reentrant */
1861/* %endif */
1862
1863/** Get the current line number.
1864 *
1865 */
1866int yyget_lineno  (void)
1867{
1868
1869    return yylineno;
1870}
1871
1872/** Get the input stream.
1873 *
1874 */
1875FILE *yyget_in  (void)
1876{
1877        return yyin;
1878}
1879
1880/** Get the output stream.
1881 *
1882 */
1883FILE *yyget_out  (void)
1884{
1885        return yyout;
1886}
1887
1888/** Get the length of the current token.
1889 *
1890 */
1891yy_size_t yyget_leng  (void)
1892{
1893        return yyleng;
1894}
1895
1896/** Get the current token.
1897 *
1898 */
1899
1900char *yyget_text  (void)
1901{
1902        return yytext;
1903}
1904
1905/* %if-reentrant */
1906/* %endif */
1907
1908/** Set the current line number.
1909 * @param line_number
1910 *
1911 */
1912void yyset_lineno (int  line_number )
1913{
1914
1915    yylineno = line_number;
1916}
1917
1918/** Set the input stream. This does not discard the current
1919 * input buffer.
1920 * @param in_str A readable stream.
1921 *
1922 * @see yy_switch_to_buffer
1923 */
1924void yyset_in (FILE *  in_str )
1925{
1926        yyin = in_str ;
1927}
1928
1929void yyset_out (FILE *  out_str )
1930{
1931        yyout = out_str ;
1932}
1933
1934int yyget_debug  (void)
1935{
1936        return yy_flex_debug;
1937}
1938
1939void yyset_debug (int  bdebug )
1940{
1941        yy_flex_debug = bdebug ;
1942}
1943
1944/* %endif */
1945
1946/* %if-reentrant */
1947/* %if-bison-bridge */
1948/* %endif */
1949/* %endif if-c-only */
1950
1951/* %if-c-only */
1952static int yy_init_globals (void)
1953{
1954        /* Initialization is the same as for the non-reentrant scanner.
1955     * This function is called from yylex_destroy(), so don't allocate here.
1956     */
1957
1958    (yy_buffer_stack) = 0;
1959    (yy_buffer_stack_top) = 0;
1960    (yy_buffer_stack_max) = 0;
1961    (yy_c_buf_p) = (char *) 0;
1962    (yy_init) = 0;
1963    (yy_start) = 0;
1964
1965/* Defined in main.c */
1966#ifdef YY_STDINIT
1967    yyin = stdin;
1968    yyout = stdout;
1969#else
1970    yyin = (FILE *) 0;
1971    yyout = (FILE *) 0;
1972#endif
1973
1974    /* For future reference: Set errno on error, since we are called by
1975     * yylex_init()
1976     */
1977    return 0;
1978}
1979/* %endif */
1980
1981/* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
1982/* yylex_destroy is for both reentrant and non-reentrant scanners. */
1983int yylex_destroy  (void)
1984{
1985
1986    /* Pop the buffer stack, destroying each element. */
1987	while(YY_CURRENT_BUFFER){
1988		yy_delete_buffer(YY_CURRENT_BUFFER  );
1989		YY_CURRENT_BUFFER_LVALUE = NULL;
1990		yypop_buffer_state();
1991	}
1992
1993	/* Destroy the stack itself. */
1994	yyfree((yy_buffer_stack) );
1995	(yy_buffer_stack) = NULL;
1996
1997    /* Reset the globals. This is important in a non-reentrant scanner so the next time
1998     * yylex() is called, initialization will occur. */
1999    yy_init_globals( );
2000
2001/* %if-reentrant */
2002/* %endif */
2003    return 0;
2004}
2005/* %endif */
2006
2007/*
2008 * Internal utility routines.
2009 */
2010
2011#ifndef yytext_ptr
2012static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2013{
2014	register int i;
2015	for ( i = 0; i < n; ++i )
2016		s1[i] = s2[i];
2017}
2018#endif
2019
2020#ifdef YY_NEED_STRLEN
2021static int yy_flex_strlen (yyconst char * s )
2022{
2023	register int n;
2024	for ( n = 0; s[n]; ++n )
2025		;
2026
2027	return n;
2028}
2029#endif
2030
2031void *yyalloc (yy_size_t  size )
2032{
2033	return (void *) malloc( size );
2034}
2035
2036void *yyrealloc  (void * ptr, yy_size_t  size )
2037{
2038	/* The cast to (char *) in the following accommodates both
2039	 * implementations that use char* generic pointers, and those
2040	 * that use void* generic pointers.  It works with the latter
2041	 * because both ANSI C and C++ allow castless assignment from
2042	 * any pointer type to void*, and deal with argument conversions
2043	 * as though doing an assignment.
2044	 */
2045	return (void *) realloc( (char *) ptr, size );
2046}
2047
2048void yyfree (void * ptr )
2049{
2050	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
2051}
2052
2053/* %if-tables-serialization definitions */
2054/* %define-yytables   The name for this specific scanner's tables. */
2055#define YYTABLES_NAME "yytables"
2056/* %endif */
2057
2058/* %ok-for-header */
2059
2060#line 67 "calc++-scanner.ll"
2061
2062
2063
2064
2065void
2066calcxx_driver::scan_begin ()
2067{
2068  yy_flex_debug = trace_scanning;
2069  if (file.empty () || file == "-")
2070    yyin = stdin;
2071  else if (!(yyin = fopen (file.c_str (), "r")))
2072    {
2073      error ("cannot open " + file + ": " + strerror(errno));
2074      exit (EXIT_FAILURE);
2075    }
2076}
2077
2078
2079
2080void
2081calcxx_driver::scan_end ()
2082{
2083  fclose (yyin);
2084}
2085
2086
2087