Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: bison/src/bison/2.4.1/bison-2.4.1-src/examples/calc++/calc++-scanner.cc

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

Powered by Google App Engine
This is Rietveld 408576698