OK. flex++ is evil. I may need to switch back to flex
[proto.git] / src / compiler / enumlexer.cpp
blob2f939139400e4231bff5773cf7185e185f6377ca
1 #line 2 "enumlexer.cpp"
3 #line 4 "enumlexer.cpp"
5 #define YY_INT_ALIGNED short int
7 /* A lexical scanner generated by flex */
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 33
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
17 /* The c++ scanner is a mess. The FlexLexer.h header file relies on the
18 * following macro. This is required in order to pass the c++-multiple-scanners
19 * test in the regression suite. We get reports that it breaks inheritance.
20 * We will address this in a future release of flex, or omit the C++ scanner
21 * altogether.
23 #define yyFlexLexer zzFlexLexer
25 /* First, we deal with platform-specific or compiler-specific issues. */
27 /* begin standard C headers. */
29 /* end standard C headers. */
31 /* flex integer type definitions */
33 #ifndef FLEXINT_H
34 #define FLEXINT_H
36 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
38 #if __STDC_VERSION__ >= 199901L
40 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
41 * if you want the limit (max/min) macros for int types.
43 #ifndef __STDC_LIMIT_MACROS
44 #define __STDC_LIMIT_MACROS 1
45 #endif
47 #include <inttypes.h>
48 typedef int8_t flex_int8_t;
49 typedef uint8_t flex_uint8_t;
50 typedef int16_t flex_int16_t;
51 typedef uint16_t flex_uint16_t;
52 typedef int32_t flex_int32_t;
53 typedef uint32_t flex_uint32_t;
54 #else
55 typedef signed char flex_int8_t;
56 typedef short int flex_int16_t;
57 typedef int flex_int32_t;
58 typedef unsigned char flex_uint8_t;
59 typedef unsigned short int flex_uint16_t;
60 typedef unsigned int flex_uint32_t;
61 #endif /* ! C99 */
63 /* Limits of integral types. */
64 #ifndef INT8_MIN
65 #define INT8_MIN (-128)
66 #endif
67 #ifndef INT16_MIN
68 #define INT16_MIN (-32767-1)
69 #endif
70 #ifndef INT32_MIN
71 #define INT32_MIN (-2147483647-1)
72 #endif
73 #ifndef INT8_MAX
74 #define INT8_MAX (127)
75 #endif
76 #ifndef INT16_MAX
77 #define INT16_MAX (32767)
78 #endif
79 #ifndef INT32_MAX
80 #define INT32_MAX (2147483647)
81 #endif
82 #ifndef UINT8_MAX
83 #define UINT8_MAX (255U)
84 #endif
85 #ifndef UINT16_MAX
86 #define UINT16_MAX (65535U)
87 #endif
88 #ifndef UINT32_MAX
89 #define UINT32_MAX (4294967295U)
90 #endif
92 #endif /* ! FLEXINT_H */
94 /* begin standard C++ headers. */
95 #include <iostream>
96 #include <errno.h>
97 #include <cstdlib>
98 #include <cstring>
99 /* end standard C++ headers. */
101 #ifdef __cplusplus
103 /* The "const" storage-class-modifier is valid. */
104 #define YY_USE_CONST
106 #else /* ! __cplusplus */
108 #if __STDC__
110 #define YY_USE_CONST
112 #endif /* __STDC__ */
113 #endif /* ! __cplusplus */
115 #ifdef YY_USE_CONST
116 #define yyconst const
117 #else
118 #define yyconst
119 #endif
121 /* Returned upon end-of-file. */
122 #define YY_NULL 0
124 /* Promotes a possibly negative, possibly signed char to an unsigned
125 * integer for use as an array index. If the signed char is negative,
126 * we want to instead treat it as an 8-bit unsigned char, hence the
127 * double cast.
129 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
131 /* Enter a start condition. This macro really ought to take a parameter,
132 * but we do it the disgusting crufty way forced on us by the ()-less
133 * definition of BEGIN.
135 #define BEGIN (yy_start) = 1 + 2 *
137 /* Translate the current start state into a value that can be later handed
138 * to BEGIN to return to the state. The YYSTATE alias is for lex
139 * compatibility.
141 #define YY_START (((yy_start) - 1) / 2)
142 #define YYSTATE YY_START
144 /* Action number for EOF rule of a given start state. */
145 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
147 /* Special action meaning "start processing a new file". */
148 #define YY_NEW_FILE yyrestart( yyin )
150 #define YY_END_OF_BUFFER_CHAR 0
152 /* Size of default input buffer. */
153 #ifndef YY_BUF_SIZE
154 #define YY_BUF_SIZE 16384
155 #endif
157 /* The state buf must be large enough to hold one state per character in the main buffer.
159 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
161 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
162 #define YY_TYPEDEF_YY_BUFFER_STATE
163 typedef struct yy_buffer_state *YY_BUFFER_STATE;
164 #endif
166 extern int yyleng;
168 #define EOB_ACT_CONTINUE_SCAN 0
169 #define EOB_ACT_END_OF_FILE 1
170 #define EOB_ACT_LAST_MATCH 2
172 #define YY_LESS_LINENO(n)
174 /* Return all but the first "n" matched characters back to the input stream. */
175 #define yyless(n) \
176 do \
178 /* Undo effects of setting up yytext. */ \
179 int yyless_macro_arg = (n); \
180 YY_LESS_LINENO(yyless_macro_arg);\
181 *yy_cp = (yy_hold_char); \
182 YY_RESTORE_YY_MORE_OFFSET \
183 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
184 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
186 while ( 0 )
188 #define unput(c) yyunput( c, (yytext_ptr) )
190 /* The following is because we cannot portably get our hands on size_t
191 * (without autoconf's help, which isn't available because we want
192 * flex-generated scanners to compile on their own).
195 #ifndef YY_TYPEDEF_YY_SIZE_T
196 #define YY_TYPEDEF_YY_SIZE_T
197 typedef unsigned int yy_size_t;
198 #endif
200 #ifndef YY_STRUCT_YY_BUFFER_STATE
201 #define YY_STRUCT_YY_BUFFER_STATE
202 struct yy_buffer_state
205 std::istream* yy_input_file;
207 char *yy_ch_buf; /* input buffer */
208 char *yy_buf_pos; /* current position in input buffer */
210 /* Size of input buffer in bytes, not including room for EOB
211 * characters.
213 yy_size_t yy_buf_size;
215 /* Number of characters read into yy_ch_buf, not including EOB
216 * characters.
218 int yy_n_chars;
220 /* Whether we "own" the buffer - i.e., we know we created it,
221 * and can realloc() it to grow it, and should free() it to
222 * delete it.
224 int yy_is_our_buffer;
226 /* Whether this is an "interactive" input source; if so, and
227 * if we're using stdio for input, then we want to use getc()
228 * instead of fread(), to make sure we stop fetching input after
229 * each newline.
231 int yy_is_interactive;
233 /* Whether we're considered to be at the beginning of a line.
234 * If so, '^' rules will be active on the next match, otherwise
235 * not.
237 int yy_at_bol;
239 int yy_bs_lineno; /**< The line count. */
240 int yy_bs_column; /**< The column count. */
242 /* Whether to try to fill the input buffer when we reach the
243 * end of it.
245 int yy_fill_buffer;
247 int yy_buffer_status;
249 #define YY_BUFFER_NEW 0
250 #define YY_BUFFER_NORMAL 1
251 /* When an EOF's been seen but there's still some text to process
252 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
253 * shouldn't try reading from the input source any more. We might
254 * still have a bunch of tokens to match, though, because of
255 * possible backing-up.
257 * When we actually see the EOF, we change the status to "new"
258 * (via yyrestart()), so that the user can continue scanning by
259 * just pointing yyin at a new input file.
261 #define YY_BUFFER_EOF_PENDING 2
264 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
266 /* We provide macros for accessing buffer states in case in the
267 * future we want to put the buffer states in a more general
268 * "scanner state".
270 * Returns the top of the stack, or NULL.
272 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
273 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
274 : NULL)
276 /* Same as previous macro, but useful when we know that the buffer stack is not
277 * NULL or when we need an lvalue. For internal use only.
279 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
281 void *zzalloc (yy_size_t );
282 void *zzrealloc (void *,yy_size_t );
283 void zzfree (void * );
285 #define yy_new_buffer yy_create_buffer
287 #define yy_set_interactive(is_interactive) \
289 if ( ! YY_CURRENT_BUFFER ){ \
290 yyensure_buffer_stack (); \
291 YY_CURRENT_BUFFER_LVALUE = \
292 yy_create_buffer( yyin, YY_BUF_SIZE ); \
294 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
297 #define yy_set_bol(at_bol) \
299 if ( ! YY_CURRENT_BUFFER ){\
300 yyensure_buffer_stack (); \
301 YY_CURRENT_BUFFER_LVALUE = \
302 yy_create_buffer( yyin, YY_BUF_SIZE ); \
304 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
307 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
309 /* Begin user sect3 */
311 typedef unsigned char YY_CHAR;
313 #define yytext_ptr yytext
314 #define YY_INTERACTIVE
316 #include <FlexLexer.h>
317 int yyFlexLexer::yylex()
319 LexerError( "yyFlexLexer::yylex invoked but %option yyclass used" );
320 return 0;
323 #define YY_DECL int EnumLexer::yylex()
325 /* Done after the current pattern has been matched and before the
326 * corresponding action - sets up yytext.
328 #define YY_DO_BEFORE_ACTION \
329 (yytext_ptr) = yy_bp; \
330 yyleng = (size_t) (yy_cp - yy_bp); \
331 (yy_hold_char) = *yy_cp; \
332 *yy_cp = '\0'; \
333 (yy_c_buf_p) = yy_cp;
335 #define YY_NUM_RULES 15
336 #define YY_END_OF_BUFFER 16
337 /* This struct is not used in this scanner,
338 but its presence is necessary. */
339 struct yy_trans_info
341 flex_int32_t yy_verify;
342 flex_int32_t yy_nxt;
344 static yyconst flex_int16_t yy_accept[70] =
345 { 0,
346 0, 0, 16, 15, 1, 13, 15, 14, 12, 7,
347 14, 14, 14, 14, 14, 6, 10, 1, 3, 0,
348 14, 14, 14, 14, 14, 14, 0, 2, 14, 14,
349 14, 14, 14, 14, 14, 14, 5, 14, 14, 14,
350 14, 14, 14, 14, 14, 14, 14, 14, 14, 4,
351 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
352 9, 14, 8, 14, 14, 14, 14, 11, 0
355 static yyconst flex_int32_t yy_ec[256] =
356 { 0,
357 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
358 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
360 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
361 1, 4, 1, 5, 1, 1, 6, 7, 7, 7,
362 7, 7, 7, 7, 7, 7, 7, 1, 8, 1,
363 9, 1, 1, 1, 10, 7, 11, 12, 13, 14,
364 7, 7, 7, 7, 7, 15, 16, 7, 17, 18,
365 7, 19, 20, 21, 7, 7, 7, 22, 7, 7,
366 1, 1, 1, 1, 23, 1, 7, 7, 7, 24,
368 25, 26, 7, 7, 7, 7, 7, 7, 27, 28,
369 7, 29, 7, 7, 7, 30, 31, 7, 7, 7,
370 32, 7, 33, 1, 34, 1, 1, 1, 1, 1,
371 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
372 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
373 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
374 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
375 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
376 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
377 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
381 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
382 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
383 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
384 1, 1, 1, 1, 1
387 static yyconst flex_int32_t yy_meta[35] =
388 { 0,
389 1, 1, 1, 1, 1, 1, 2, 1, 1, 2,
390 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
391 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
392 2, 2, 1, 1
395 static yyconst flex_int16_t yy_base[72] =
396 { 0,
397 0, 0, 91, 92, 33, 92, 33, 0, 92, 92,
398 73, 79, 73, 59, 54, 92, 92, 38, 92, 82,
399 0, 65, 61, 72, 50, 51, 76, 92, 65, 54,
400 55, 48, 49, 50, 61, 57, 0, 46, 58, 52,
401 50, 41, 49, 52, 44, 36, 49, 37, 43, 0,
402 35, 40, 33, 38, 36, 36, 34, 31, 32, 29,
403 0, 37, 0, 30, 34, 32, 24, 0, 92, 36,
407 static yyconst flex_int16_t yy_def[72] =
408 { 0,
409 69, 1, 69, 69, 69, 69, 69, 70, 69, 69,
410 70, 70, 70, 70, 70, 69, 69, 69, 69, 71,
411 70, 70, 70, 70, 70, 70, 71, 69, 70, 70,
412 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
413 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
414 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
415 70, 70, 70, 70, 70, 70, 70, 70, 0, 69,
419 static yyconst flex_int16_t yy_nxt[127] =
420 { 0,
421 4, 5, 5, 4, 6, 7, 8, 9, 10, 8,
422 11, 8, 8, 8, 8, 12, 8, 13, 8, 8,
423 8, 8, 8, 8, 14, 8, 8, 8, 8, 15,
424 8, 8, 16, 17, 18, 18, 19, 21, 20, 18,
425 18, 27, 27, 68, 67, 66, 65, 64, 63, 62,
426 61, 60, 59, 58, 57, 56, 55, 54, 53, 52,
427 51, 50, 49, 48, 47, 46, 45, 44, 43, 42,
428 41, 40, 39, 38, 37, 36, 35, 34, 28, 33,
429 32, 31, 30, 29, 28, 26, 25, 24, 23, 22,
430 69, 3, 69, 69, 69, 69, 69, 69, 69, 69,
432 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
433 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
434 69, 69, 69, 69, 69, 69
437 static yyconst flex_int16_t yy_chk[127] =
438 { 0,
439 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
440 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
441 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
442 1, 1, 1, 1, 5, 5, 7, 70, 7, 18,
443 18, 71, 71, 67, 66, 65, 64, 62, 60, 59,
444 58, 57, 56, 55, 54, 53, 52, 51, 49, 48,
445 47, 46, 45, 44, 43, 42, 41, 40, 39, 38,
446 36, 35, 34, 33, 32, 31, 30, 29, 27, 26,
447 25, 24, 23, 22, 20, 15, 14, 13, 12, 11,
448 3, 69, 69, 69, 69, 69, 69, 69, 69, 69,
450 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
451 69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
452 69, 69, 69, 69, 69, 69
455 /* The intent behind this definition is that it'll catch
456 * any uses of REJECT which flex missed.
458 #define REJECT reject_used_but_not_detected
459 #define yymore() yymore_used_but_not_detected
460 #define YY_MORE_ADJ 0
461 #define YY_RESTORE_YY_MORE_OFFSET
462 #line 1 "one_enum.flex"
463 /* a flex++ scanner for reading a C file containing one platform enum
464 Copyright (C) 2005-2008, Jonathan Bachrach, Jacob Beal, and contributors
465 listed in the AUTHORS file in the MIT Proto distribution's top directory.
467 This file is part of MIT Proto, and is distributed under the terms of
468 the GNU General Public License, with a linking exception, as described
469 in the file LICENSE in the MIT Proto distribution's top directory.
471 #line 13 "one_enum.flex"
472 #define YY_BREAK { if(error) return 1; } break;
474 #include <list>
475 #include <string>
476 #include "compiler-utils.h"
478 int zzwrap() { return 1; }
479 extern int yywrap();
481 class EnumLexer : public zzFlexLexer {
482 bool ready_for_entry, error; int step; list<string> *p_ops;
483 void read_error(string err) { *cperr << "Platform description file is not a parsable 'single enum' file: " << err << " .\n"; error=true; }
485 public:
486 EnumLexer(istream *in, ostream *out) : zzFlexLexer(in,out) {
487 ready_for_entry=true; error=false; step=0; p_ops = new list<string>;
489 virtual ~EnumLexer() {} // nothing to clean up: p_ops is somebody else's prob
491 // returns NULL on error
492 list<string>* tokenize() {
493 yylex();
494 if(!error && step<9) { read_error("file not closed by ';'"); }
495 if(error) { delete p_ops; return NULL;
496 } else { return p_ops; }
499 protected:
500 int yylex(); // prototype for lexing function
503 #line 504 "enumlexer.cpp"
505 #define INITIAL 0
507 #ifndef YY_NO_UNISTD_H
508 /* Special case for "unistd.h", since it is non-ANSI. We include it way
509 * down here because we want the user's section 1 to have been scanned first.
510 * The user has a chance to override it with an option.
512 #include <unistd.h>
513 #endif
515 #ifndef YY_EXTRA_TYPE
516 #define YY_EXTRA_TYPE void *
517 #endif
519 #ifndef yytext_ptr
520 static void yy_flex_strncpy (char *,yyconst char *,int );
521 #endif
523 #ifdef YY_NEED_STRLEN
524 static int yy_flex_strlen (yyconst char * );
525 #endif
527 #ifndef YY_NO_INPUT
529 #endif
531 /* Amount of stuff to slurp up with each read. */
532 #ifndef YY_READ_BUF_SIZE
533 #define YY_READ_BUF_SIZE 8192
534 #endif
536 /* Copy whatever the last rule matched to the standard output. */
537 #ifndef ECHO
538 #define ECHO LexerOutput( yytext, yyleng )
539 #endif
541 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
542 * is returned in "result".
544 #ifndef YY_INPUT
545 #define YY_INPUT(buf,result,max_size) \
547 if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
548 YY_FATAL_ERROR( "input in flex scanner failed" );
550 #endif
552 /* No semi-colon after return; correct usage is to write "yyterminate();" -
553 * we don't want an extra ';' after the "return" because that will cause
554 * some compilers to complain about unreachable statements.
556 #ifndef yyterminate
557 #define yyterminate() return YY_NULL
558 #endif
560 /* Number of entries by which start-condition stack grows. */
561 #ifndef YY_START_STACK_INCR
562 #define YY_START_STACK_INCR 25
563 #endif
565 /* Report a fatal error. */
566 #ifndef YY_FATAL_ERROR
567 #define YY_FATAL_ERROR(msg) LexerError( msg )
568 #endif
570 /* end tables serialization structures and prototypes */
572 /* Default declaration of generated scanner - a define so the user can
573 * easily add parameters.
575 #ifndef YY_DECL
576 #define YY_DECL_IS_OURS 1
577 #define YY_DECL int yyFlexLexer::yylex()
578 #endif /* !YY_DECL */
580 /* Code executed at the beginning of each rule, after yytext and yyleng
581 * have been set up.
583 #ifndef YY_USER_ACTION
584 #define YY_USER_ACTION
585 #endif
587 /* Code executed at the end of each rule. */
588 #ifndef YY_BREAK
589 #define YY_BREAK break;
590 #endif
592 #define YY_RULE_SETUP \
593 YY_USER_ACTION
595 /** The main scanner function which does all the work.
597 YY_DECL
599 register yy_state_type yy_current_state;
600 register char *yy_cp, *yy_bp;
601 register int yy_act;
603 #line 47 "one_enum.flex"
606 #line 607 "enumlexer.cpp"
608 if ( !(yy_init) )
610 (yy_init) = 1;
612 #ifdef YY_USER_INIT
613 YY_USER_INIT;
614 #endif
616 if ( ! (yy_start) )
617 (yy_start) = 1; /* first start state */
619 if ( ! yyin )
620 yyin = & std::cin;
622 if ( ! yyout )
623 yyout = & std::cout;
625 if ( ! YY_CURRENT_BUFFER ) {
626 yyensure_buffer_stack ();
627 YY_CURRENT_BUFFER_LVALUE =
628 yy_create_buffer( yyin, YY_BUF_SIZE );
631 yy_load_buffer_state( );
634 while ( 1 ) /* loops until end-of-file is reached */
636 yy_cp = (yy_c_buf_p);
638 /* Support of yytext. */
639 *yy_cp = (yy_hold_char);
641 /* yy_bp points to the position in yy_ch_buf of the start of
642 * the current run.
644 yy_bp = yy_cp;
646 yy_current_state = (yy_start);
647 yy_match:
650 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
651 if ( yy_accept[yy_current_state] )
653 (yy_last_accepting_state) = yy_current_state;
654 (yy_last_accepting_cpos) = yy_cp;
656 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
658 yy_current_state = (int) yy_def[yy_current_state];
659 if ( yy_current_state >= 70 )
660 yy_c = yy_meta[(unsigned int) yy_c];
662 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
663 ++yy_cp;
665 while ( yy_base[yy_current_state] != 92 );
667 yy_find_action:
668 yy_act = yy_accept[yy_current_state];
669 if ( yy_act == 0 )
670 { /* have to back up */
671 yy_cp = (yy_last_accepting_cpos);
672 yy_current_state = (yy_last_accepting_state);
673 yy_act = yy_accept[yy_current_state];
676 YY_DO_BEFORE_ACTION;
678 do_action: /* This label is used only to access EOF actions. */
680 switch ( yy_act )
681 { /* beginning of action switch */
682 case 0: /* must back up */
683 /* undo the effects of YY_DO_BEFORE_ACTION */
684 *yy_cp = (yy_hold_char);
685 yy_cp = (yy_last_accepting_cpos);
686 yy_current_state = (yy_last_accepting_state);
687 goto yy_find_action;
689 case 1:
690 /* rule 1 can match eol */
691 YY_RULE_SETUP
692 #line 49 "one_enum.flex"
693 /* consume whitespace */
694 YY_BREAK
695 case 2:
696 *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
697 (yy_c_buf_p) = yy_cp -= 1;
698 YY_DO_BEFORE_ACTION; /* set up yytext again */
699 YY_RULE_SETUP
700 #line 50 "one_enum.flex"
701 /* consume C++ comments */
702 YY_BREAK
703 case 3:
704 YY_RULE_SETUP
705 #line 51 "one_enum.flex"
706 { register int c; /* consume C comments */
707 for ( ; ; ) {
708 while ( (c = yyinput()) != '*' && c != EOF )
709 ; /* eat up text of comment */
710 if ( c == '*' ) {
711 while ( (c = yyinput()) == '*' ) ;
712 if ( c == '/' )
713 break; /* found the end */
715 if ( c == EOF ) {
716 read_error("file ended w. unclosed C comment");
717 break;
721 YY_BREAK
722 case 4:
723 YY_RULE_SETUP
724 #line 67 "one_enum.flex"
725 { if(step==0) step++; else read_error("wrong location of 'typedef'"); }
726 YY_BREAK
727 case 5:
728 YY_RULE_SETUP
729 #line 68 "one_enum.flex"
730 { if(step==1) step++; else read_error("wrong location of 'enum'"); }
731 YY_BREAK
732 case 6:
733 YY_RULE_SETUP
734 #line 69 "one_enum.flex"
735 { if(step==2) step++; else read_error("wrong location of '{'"); }
736 YY_BREAK
737 case 7:
738 YY_RULE_SETUP
739 #line 70 "one_enum.flex"
740 { if(step==3) step++; else read_error("wrong location of '='"); }
741 YY_BREAK
742 case 8:
743 YY_RULE_SETUP
744 #line 71 "one_enum.flex"
745 { if(step==4) step++; else read_error("wrong location of 'CORE_CMD_OPS'"); }
746 YY_BREAK
747 case 9:
748 YY_RULE_SETUP
749 #line 72 "one_enum.flex"
750 { if(step==5) step++; else read_error("wrong location of 'MAX_CMD_OPS'"); }
751 YY_BREAK
752 case 10:
753 YY_RULE_SETUP
754 #line 73 "one_enum.flex"
755 { if(step==6) step++; else read_error("wrong location of '}'"); }
756 YY_BREAK
757 case 11:
758 YY_RULE_SETUP
759 #line 74 "one_enum.flex"
760 { if(step==7) step++; else read_error("wrong location of 'PLATFORM_OPCODES'"); }
761 YY_BREAK
762 case 12:
763 YY_RULE_SETUP
764 #line 75 "one_enum.flex"
765 { if(step==8) step++; else read_error("wrong location of ';'"); }
766 YY_BREAK
767 case 13:
768 YY_RULE_SETUP
769 #line 77 "one_enum.flex"
770 { if(ready_for_entry) read_error("bad comma location"); else ready_for_entry=true; }
771 YY_BREAK
772 case 14:
773 YY_RULE_SETUP
774 #line 79 "one_enum.flex"
775 { if(!ready_for_entry ||
776 (step==2 && !p_ops->empty()) ||
777 (step==4 && p_ops->empty())) read_error("Bad constituent");
778 else { p_ops->push_back(string(YYText()));
779 ready_for_entry=false;
781 YY_BREAK
782 case 15:
783 YY_RULE_SETUP
784 #line 87 "one_enum.flex"
785 ECHO;
786 YY_BREAK
787 #line 788 "enumlexer.cpp"
788 case YY_STATE_EOF(INITIAL):
789 yyterminate();
791 case YY_END_OF_BUFFER:
793 /* Amount of text matched not including the EOB char. */
794 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
796 /* Undo the effects of YY_DO_BEFORE_ACTION. */
797 *yy_cp = (yy_hold_char);
798 YY_RESTORE_YY_MORE_OFFSET
800 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
802 /* We're scanning a new file or input source. It's
803 * possible that this happened because the user
804 * just pointed yyin at a new source and called
805 * yylex(). If so, then we have to assure
806 * consistency between YY_CURRENT_BUFFER and our
807 * globals. Here is the right place to do so, because
808 * this is the first action (other than possibly a
809 * back-up) that will match for the new input source.
811 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
812 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
813 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
816 /* Note that here we test for yy_c_buf_p "<=" to the position
817 * of the first EOB in the buffer, since yy_c_buf_p will
818 * already have been incremented past the NUL character
819 * (since all states make transitions on EOB to the
820 * end-of-buffer state). Contrast this with the test
821 * in input().
823 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
824 { /* This was really a NUL. */
825 yy_state_type yy_next_state;
827 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
829 yy_current_state = yy_get_previous_state( );
831 /* Okay, we're now positioned to make the NUL
832 * transition. We couldn't have
833 * yy_get_previous_state() go ahead and do it
834 * for us because it doesn't know how to deal
835 * with the possibility of jamming (and we don't
836 * want to build jamming into it because then it
837 * will run more slowly).
840 yy_next_state = yy_try_NUL_trans( yy_current_state );
842 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
844 if ( yy_next_state )
846 /* Consume the NUL. */
847 yy_cp = ++(yy_c_buf_p);
848 yy_current_state = yy_next_state;
849 goto yy_match;
852 else
854 yy_cp = (yy_c_buf_p);
855 goto yy_find_action;
859 else switch ( yy_get_next_buffer( ) )
861 case EOB_ACT_END_OF_FILE:
863 (yy_did_buffer_switch_on_eof) = 0;
865 if ( yywrap( ) )
867 /* Note: because we've taken care in
868 * yy_get_next_buffer() to have set up
869 * yytext, we can now set up
870 * yy_c_buf_p so that if some total
871 * hoser (like flex itself) wants to
872 * call the scanner after we return the
873 * YY_NULL, it'll still work - another
874 * YY_NULL will get returned.
876 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
878 yy_act = YY_STATE_EOF(YY_START);
879 goto do_action;
882 else
884 if ( ! (yy_did_buffer_switch_on_eof) )
885 YY_NEW_FILE;
887 break;
890 case EOB_ACT_CONTINUE_SCAN:
891 (yy_c_buf_p) =
892 (yytext_ptr) + yy_amount_of_matched_text;
894 yy_current_state = yy_get_previous_state( );
896 yy_cp = (yy_c_buf_p);
897 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
898 goto yy_match;
900 case EOB_ACT_LAST_MATCH:
901 (yy_c_buf_p) =
902 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
904 yy_current_state = yy_get_previous_state( );
906 yy_cp = (yy_c_buf_p);
907 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
908 goto yy_find_action;
910 break;
913 default:
914 YY_FATAL_ERROR(
915 "fatal flex scanner internal error--no action found" );
916 } /* end of action switch */
917 } /* end of scanning one token */
918 } /* end of yylex */
920 yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
922 yyin = arg_yyin;
923 yyout = arg_yyout;
924 yy_c_buf_p = 0;
925 yy_init = 0;
926 yy_start = 0;
927 yy_flex_debug = 0;
928 yylineno = 1; // this will only get updated if %option yylineno
930 yy_did_buffer_switch_on_eof = 0;
932 yy_looking_for_trail_begin = 0;
933 yy_more_flag = 0;
934 yy_more_len = 0;
935 yy_more_offset = yy_prev_more_offset = 0;
937 yy_start_stack_ptr = yy_start_stack_depth = 0;
938 yy_start_stack = NULL;
940 (yy_buffer_stack) = 0;
941 (yy_buffer_stack_top) = 0;
942 (yy_buffer_stack_max) = 0;
944 yy_state_buf = 0;
948 void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out )
950 if ( new_in )
952 yy_delete_buffer( YY_CURRENT_BUFFER );
953 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE ) );
956 if ( new_out )
957 yyout = new_out;
960 #ifdef YY_INTERACTIVE
961 int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
962 #else
963 int yyFlexLexer::LexerInput( char* buf, int max_size )
964 #endif
966 if ( yyin->eof() || yyin->fail() )
967 return 0;
969 #ifdef YY_INTERACTIVE
970 yyin->get( buf[0] );
972 if ( yyin->eof() )
973 return 0;
975 if ( yyin->bad() )
976 return -1;
978 return 1;
980 #else
981 (void) yyin->read( buf, max_size );
983 if ( yyin->bad() )
984 return -1;
985 else
986 return yyin->gcount();
987 #endif
990 void yyFlexLexer::LexerOutput( const char* buf, int size )
992 (void) yyout->write( buf, size );
995 /* yy_get_next_buffer - try to read in a new buffer
997 * Returns a code representing an action:
998 * EOB_ACT_LAST_MATCH -
999 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1000 * EOB_ACT_END_OF_FILE - end of file
1002 int yyFlexLexer::yy_get_next_buffer()
1004 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1005 register char *source = (yytext_ptr);
1006 register int number_to_move, i;
1007 int ret_val;
1009 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1010 YY_FATAL_ERROR(
1011 "fatal flex scanner internal error--end of buffer missed" );
1013 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1014 { /* Don't try to fill the buffer, so this is an EOF. */
1015 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1017 /* We matched a single character, the EOB, so
1018 * treat this as a final EOF.
1020 return EOB_ACT_END_OF_FILE;
1023 else
1025 /* We matched some text prior to the EOB, first
1026 * process it.
1028 return EOB_ACT_LAST_MATCH;
1032 /* Try to read more data. */
1034 /* First move last chars to start of buffer. */
1035 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1037 for ( i = 0; i < number_to_move; ++i )
1038 *(dest++) = *(source++);
1040 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1041 /* don't do the read, it's not guaranteed to return an EOF,
1042 * just force an EOF
1044 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1046 else
1048 int num_to_read =
1049 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1051 while ( num_to_read <= 0 )
1052 { /* Not enough room in the buffer - grow it. */
1054 /* just a shorter name for the current buffer */
1055 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1057 int yy_c_buf_p_offset =
1058 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1060 if ( b->yy_is_our_buffer )
1062 int new_size = b->yy_buf_size * 2;
1064 if ( new_size <= 0 )
1065 b->yy_buf_size += b->yy_buf_size / 8;
1066 else
1067 b->yy_buf_size *= 2;
1069 b->yy_ch_buf = (char *)
1070 /* Include room in for 2 EOB chars. */
1071 zzrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1073 else
1074 /* Can't grow it, we don't own it. */
1075 b->yy_ch_buf = 0;
1077 if ( ! b->yy_ch_buf )
1078 YY_FATAL_ERROR(
1079 "fatal error - scanner input buffer overflow" );
1081 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1083 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1084 number_to_move - 1;
1088 if ( num_to_read > YY_READ_BUF_SIZE )
1089 num_to_read = YY_READ_BUF_SIZE;
1091 /* Read in more data. */
1092 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1093 (yy_n_chars), (size_t) num_to_read );
1095 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1098 if ( (yy_n_chars) == 0 )
1100 if ( number_to_move == YY_MORE_ADJ )
1102 ret_val = EOB_ACT_END_OF_FILE;
1103 yyrestart( yyin );
1106 else
1108 ret_val = EOB_ACT_LAST_MATCH;
1109 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1110 YY_BUFFER_EOF_PENDING;
1114 else
1115 ret_val = EOB_ACT_CONTINUE_SCAN;
1117 (yy_n_chars) += number_to_move;
1118 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1119 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1121 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1123 return ret_val;
1126 /* yy_get_previous_state - get the state just before the EOB char was reached */
1128 yy_state_type yyFlexLexer::yy_get_previous_state()
1130 register yy_state_type yy_current_state;
1131 register char *yy_cp;
1133 yy_current_state = (yy_start);
1135 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1137 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1138 if ( yy_accept[yy_current_state] )
1140 (yy_last_accepting_state) = yy_current_state;
1141 (yy_last_accepting_cpos) = yy_cp;
1143 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1145 yy_current_state = (int) yy_def[yy_current_state];
1146 if ( yy_current_state >= 70 )
1147 yy_c = yy_meta[(unsigned int) yy_c];
1149 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1152 return yy_current_state;
1155 /* yy_try_NUL_trans - try to make a transition on the NUL character
1157 * synopsis
1158 * next_state = yy_try_NUL_trans( current_state );
1160 yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
1162 register int yy_is_jam;
1163 register char *yy_cp = (yy_c_buf_p);
1165 register YY_CHAR yy_c = 1;
1166 if ( yy_accept[yy_current_state] )
1168 (yy_last_accepting_state) = yy_current_state;
1169 (yy_last_accepting_cpos) = yy_cp;
1171 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1173 yy_current_state = (int) yy_def[yy_current_state];
1174 if ( yy_current_state >= 70 )
1175 yy_c = yy_meta[(unsigned int) yy_c];
1177 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1178 yy_is_jam = (yy_current_state == 69);
1180 return yy_is_jam ? 0 : yy_current_state;
1183 void yyFlexLexer::yyunput( int c, register char* yy_bp)
1185 register char *yy_cp;
1187 yy_cp = (yy_c_buf_p);
1189 /* undo effects of setting up yytext */
1190 *yy_cp = (yy_hold_char);
1192 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1193 { /* need to shift things up to make room */
1194 /* +2 for EOB chars. */
1195 register int number_to_move = (yy_n_chars) + 2;
1196 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1197 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1198 register char *source =
1199 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1201 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1202 *--dest = *--source;
1204 yy_cp += (int) (dest - source);
1205 yy_bp += (int) (dest - source);
1206 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1207 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1209 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1210 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1213 *--yy_cp = (char) c;
1215 (yytext_ptr) = yy_bp;
1216 (yy_hold_char) = *yy_cp;
1217 (yy_c_buf_p) = yy_cp;
1220 int yyFlexLexer::yyinput()
1222 int c;
1224 *(yy_c_buf_p) = (yy_hold_char);
1226 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1228 /* yy_c_buf_p now points to the character we want to return.
1229 * If this occurs *before* the EOB characters, then it's a
1230 * valid NUL; if not, then we've hit the end of the buffer.
1232 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1233 /* This was really a NUL. */
1234 *(yy_c_buf_p) = '\0';
1236 else
1237 { /* need more input */
1238 int offset = (yy_c_buf_p) - (yytext_ptr);
1239 ++(yy_c_buf_p);
1241 switch ( yy_get_next_buffer( ) )
1243 case EOB_ACT_LAST_MATCH:
1244 /* This happens because yy_g_n_b()
1245 * sees that we've accumulated a
1246 * token and flags that we need to
1247 * try matching the token before
1248 * proceeding. But for input(),
1249 * there's no matching to consider.
1250 * So convert the EOB_ACT_LAST_MATCH
1251 * to EOB_ACT_END_OF_FILE.
1254 /* Reset buffer status. */
1255 yyrestart( yyin );
1257 /*FALLTHROUGH*/
1259 case EOB_ACT_END_OF_FILE:
1261 if ( yywrap( ) )
1262 return EOF;
1264 if ( ! (yy_did_buffer_switch_on_eof) )
1265 YY_NEW_FILE;
1266 #ifdef __cplusplus
1267 return yyinput();
1268 #else
1269 return input();
1270 #endif
1273 case EOB_ACT_CONTINUE_SCAN:
1274 (yy_c_buf_p) = (yytext_ptr) + offset;
1275 break;
1280 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1281 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1282 (yy_hold_char) = *++(yy_c_buf_p);
1284 return c;
1287 /** Immediately switch to a different input stream.
1288 * @param input_file A readable stream.
1290 * @note This function does not reset the start condition to @c INITIAL .
1292 void yyFlexLexer::yyrestart( std::istream* input_file )
1295 if ( ! YY_CURRENT_BUFFER ){
1296 yyensure_buffer_stack ();
1297 YY_CURRENT_BUFFER_LVALUE =
1298 yy_create_buffer( yyin, YY_BUF_SIZE );
1301 yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1302 yy_load_buffer_state( );
1305 /** Switch to a different input buffer.
1306 * @param new_buffer The new input buffer.
1309 void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1312 /* TODO. We should be able to replace this entire function body
1313 * with
1314 * yypop_buffer_state();
1315 * yypush_buffer_state(new_buffer);
1317 yyensure_buffer_stack ();
1318 if ( YY_CURRENT_BUFFER == new_buffer )
1319 return;
1321 if ( YY_CURRENT_BUFFER )
1323 /* Flush out information for old buffer. */
1324 *(yy_c_buf_p) = (yy_hold_char);
1325 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1326 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1329 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1330 yy_load_buffer_state( );
1332 /* We don't actually know whether we did this switch during
1333 * EOF (yywrap()) processing, but the only time this flag
1334 * is looked at is after yywrap() is called, so it's safe
1335 * to go ahead and always set it.
1337 (yy_did_buffer_switch_on_eof) = 1;
1340 void yyFlexLexer::yy_load_buffer_state()
1342 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1343 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1344 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1345 (yy_hold_char) = *(yy_c_buf_p);
1348 /** Allocate and initialize an input buffer state.
1349 * @param file A readable stream.
1350 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1352 * @return the allocated buffer state.
1354 YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size )
1356 YY_BUFFER_STATE b;
1358 b = (YY_BUFFER_STATE) zzalloc(sizeof( struct yy_buffer_state ) );
1359 if ( ! b )
1360 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1362 b->yy_buf_size = size;
1364 /* yy_ch_buf has to be 2 characters longer than the size given because
1365 * we need to put in 2 end-of-buffer characters.
1367 b->yy_ch_buf = (char *) zzalloc(b->yy_buf_size + 2 );
1368 if ( ! b->yy_ch_buf )
1369 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1371 b->yy_is_our_buffer = 1;
1373 yy_init_buffer( b, file );
1375 return b;
1378 /** Destroy the buffer.
1379 * @param b a buffer created with yy_create_buffer()
1382 void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
1385 if ( ! b )
1386 return;
1388 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1389 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1391 if ( b->yy_is_our_buffer )
1392 zzfree((void *) b->yy_ch_buf );
1394 zzfree((void *) b );
1397 extern "C" int isatty (int );
1399 /* Initializes or reinitializes a buffer.
1400 * This function is sometimes called more than once on the same buffer,
1401 * such as during a yyrestart() or at EOF.
1403 void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
1406 int oerrno = errno;
1408 yy_flush_buffer( b );
1410 b->yy_input_file = file;
1411 b->yy_fill_buffer = 1;
1413 /* If b is the current buffer, then yy_init_buffer was _probably_
1414 * called from yyrestart() or through yy_get_next_buffer.
1415 * In that case, we don't want to reset the lineno or column.
1417 if (b != YY_CURRENT_BUFFER){
1418 b->yy_bs_lineno = 1;
1419 b->yy_bs_column = 0;
1422 b->yy_is_interactive = 0;
1423 errno = oerrno;
1426 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1427 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1430 void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
1432 if ( ! b )
1433 return;
1435 b->yy_n_chars = 0;
1437 /* We always need two end-of-buffer characters. The first causes
1438 * a transition to the end-of-buffer state. The second causes
1439 * a jam in that state.
1441 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1442 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1444 b->yy_buf_pos = &b->yy_ch_buf[0];
1446 b->yy_at_bol = 1;
1447 b->yy_buffer_status = YY_BUFFER_NEW;
1449 if ( b == YY_CURRENT_BUFFER )
1450 yy_load_buffer_state( );
1453 /** Pushes the new state onto the stack. The new state becomes
1454 * the current state. This function will allocate the stack
1455 * if necessary.
1456 * @param new_buffer The new state.
1459 void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer)
1461 if (new_buffer == NULL)
1462 return;
1464 yyensure_buffer_stack();
1466 /* This block is copied from yy_switch_to_buffer. */
1467 if ( YY_CURRENT_BUFFER )
1469 /* Flush out information for old buffer. */
1470 *(yy_c_buf_p) = (yy_hold_char);
1471 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1472 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1475 /* Only push if top exists. Otherwise, replace top. */
1476 if (YY_CURRENT_BUFFER)
1477 (yy_buffer_stack_top)++;
1478 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1480 /* copied from yy_switch_to_buffer. */
1481 yy_load_buffer_state( );
1482 (yy_did_buffer_switch_on_eof) = 1;
1485 /** Removes and deletes the top of the stack, if present.
1486 * The next element becomes the new top.
1489 void yyFlexLexer::yypop_buffer_state (void)
1491 if (!YY_CURRENT_BUFFER)
1492 return;
1494 yy_delete_buffer(YY_CURRENT_BUFFER );
1495 YY_CURRENT_BUFFER_LVALUE = NULL;
1496 if ((yy_buffer_stack_top) > 0)
1497 --(yy_buffer_stack_top);
1499 if (YY_CURRENT_BUFFER) {
1500 yy_load_buffer_state( );
1501 (yy_did_buffer_switch_on_eof) = 1;
1505 /* Allocates the stack if it does not exist.
1506 * Guarantees space for at least one push.
1508 void yyFlexLexer::yyensure_buffer_stack(void)
1510 int num_to_alloc;
1512 if (!(yy_buffer_stack)) {
1514 /* First allocation is just for 2 elements, since we don't know if this
1515 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1516 * immediate realloc on the next call.
1518 num_to_alloc = 1;
1519 (yy_buffer_stack) = (struct yy_buffer_state**)zzalloc
1520 (num_to_alloc * sizeof(struct yy_buffer_state*)
1523 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1525 (yy_buffer_stack_max) = num_to_alloc;
1526 (yy_buffer_stack_top) = 0;
1527 return;
1530 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1532 /* Increase the buffer to prepare for a possible push. */
1533 int grow_size = 8 /* arbitrary grow size */;
1535 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1536 (yy_buffer_stack) = (struct yy_buffer_state**)zzrealloc
1537 ((yy_buffer_stack),
1538 num_to_alloc * sizeof(struct yy_buffer_state*)
1541 /* zero only the new slots.*/
1542 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1543 (yy_buffer_stack_max) = num_to_alloc;
1547 void yyFlexLexer::yy_push_state( int new_state )
1549 if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) )
1551 yy_size_t new_size;
1553 (yy_start_stack_depth) += YY_START_STACK_INCR;
1554 new_size = (yy_start_stack_depth) * sizeof( int );
1556 if ( ! (yy_start_stack) )
1557 (yy_start_stack) = (int *) zzalloc(new_size );
1559 else
1560 (yy_start_stack) = (int *) zzrealloc((void *) (yy_start_stack),new_size );
1562 if ( ! (yy_start_stack) )
1563 YY_FATAL_ERROR(
1564 "out of memory expanding start-condition stack" );
1567 (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START;
1569 BEGIN(new_state);
1572 void yyFlexLexer::yy_pop_state()
1574 if ( --(yy_start_stack_ptr) < 0 )
1575 YY_FATAL_ERROR( "start-condition stack underflow" );
1577 BEGIN((yy_start_stack)[(yy_start_stack_ptr)]);
1580 int yyFlexLexer::yy_top_state()
1582 return (yy_start_stack)[(yy_start_stack_ptr) - 1];
1585 #ifndef YY_EXIT_FAILURE
1586 #define YY_EXIT_FAILURE 2
1587 #endif
1589 void yyFlexLexer::LexerError( yyconst char msg[] )
1591 std::cerr << msg << std::endl;
1592 exit( YY_EXIT_FAILURE );
1595 /* Redefine yyless() so it works in section 3 code. */
1597 #undef yyless
1598 #define yyless(n) \
1599 do \
1601 /* Undo effects of setting up yytext. */ \
1602 int yyless_macro_arg = (n); \
1603 YY_LESS_LINENO(yyless_macro_arg);\
1604 yytext[yyleng] = (yy_hold_char); \
1605 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1606 (yy_hold_char) = *(yy_c_buf_p); \
1607 *(yy_c_buf_p) = '\0'; \
1608 yyleng = yyless_macro_arg; \
1610 while ( 0 )
1612 /* Accessor methods (get/set functions) to struct members. */
1614 yyFlexLexer::~yyFlexLexer()
1617 /* Pop the buffer stack, destroying each element. */
1618 while(YY_CURRENT_BUFFER){
1619 yy_delete_buffer( YY_CURRENT_BUFFER );
1620 YY_CURRENT_BUFFER_LVALUE = NULL;
1621 yypop_buffer_state();
1624 /* Destroy the stack itself. */
1625 zzfree((yy_buffer_stack) );
1626 (yy_buffer_stack) = NULL;
1628 delete [] (yy_state_buf);
1629 zzfree((yy_start_stack) );
1634 * Internal utility routines.
1637 #ifndef yytext_ptr
1638 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1640 register int i;
1641 for ( i = 0; i < n; ++i )
1642 s1[i] = s2[i];
1644 #endif
1646 #ifdef YY_NEED_STRLEN
1647 static int yy_flex_strlen (yyconst char * s )
1649 register int n;
1650 for ( n = 0; s[n]; ++n )
1653 return n;
1655 #endif
1657 void *zzalloc (yy_size_t size )
1659 return (void *) malloc( size );
1662 void *zzrealloc (void * ptr, yy_size_t size )
1664 /* The cast to (char *) in the following accommodates both
1665 * implementations that use char* generic pointers, and those
1666 * that use void* generic pointers. It works with the latter
1667 * because both ANSI C and C++ allow castless assignment from
1668 * any pointer type to void*, and deal with argument conversions
1669 * as though doing an assignment.
1671 return (void *) realloc( (char *) ptr, size );
1674 void zzfree (void * ptr )
1676 free( (char *) ptr ); /* see zzrealloc() for (char *) cast */
1679 #define YYTABLES_NAME "yytables"
1681 #line 87 "one_enum.flex"
1685 list<string>* read_enum(istream* in, ostream* out=NULL) {
1686 string dump;
1687 if(out==NULL) out=new ostringstream();
1688 EnumLexer lex(in,out);
1689 return lex.tokenize();
1691 list<string>* read_enum(string in) {
1692 return read_enum(new istringstream(in));