new files of 0.5.2
[fw/sdcc] / sim / ucsim / cmd.src / cmdlex.cc
1 #line 2 "cmdlex.cc"
2
3 #line 4 "cmdlex.cc"
4
5 #define  YY_INT_ALIGNED short int
6
7 /* A lexical scanner generated by flex */
8
9 #define FLEX_SCANNER
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 31
13 #if YY_FLEX_SUBMINOR_VERSION > 0
14 #define FLEX_BETA
15 #endif
16
17     /* The c++ scanner is a mess. The FlexLexer.h header file relies on the
18      * following macro.
19      */
20     #define yyFlexLexer yyFlexLexer
21
22 /* First, we deal with  platform-specific or compiler-specific issues. */
23
24 /* begin standard C headers. */
25
26 /* end standard C headers. */
27
28 /* flex integer type definitions */
29
30 #ifndef FLEXINT_H
31 #define FLEXINT_H
32
33 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
34
35 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
36 #include <inttypes.h>
37 typedef int8_t flex_int8_t;
38 typedef uint8_t flex_uint8_t;
39 typedef int16_t flex_int16_t;
40 typedef uint16_t flex_uint16_t;
41 typedef int32_t flex_int32_t;
42 typedef uint32_t flex_uint32_t;
43 #else
44 typedef signed char flex_int8_t;
45 typedef short int flex_int16_t;
46 typedef int flex_int32_t;
47 typedef unsigned char flex_uint8_t; 
48 typedef unsigned short int flex_uint16_t;
49 typedef unsigned int flex_uint32_t;
50 #endif /* ! C99 */
51
52 /* Limits of integral types. */
53 #ifndef INT8_MIN
54 #define INT8_MIN               (-128)
55 #endif
56 #ifndef INT16_MIN
57 #define INT16_MIN              (-32767-1)
58 #endif
59 #ifndef INT32_MIN
60 #define INT32_MIN              (-2147483647-1)
61 #endif
62 #ifndef INT8_MAX
63 #define INT8_MAX               (127)
64 #endif
65 #ifndef INT16_MAX
66 #define INT16_MAX              (32767)
67 #endif
68 #ifndef INT32_MAX
69 #define INT32_MAX              (2147483647)
70 #endif
71 #ifndef UINT8_MAX
72 #define UINT8_MAX              (255U)
73 #endif
74 #ifndef UINT16_MAX
75 #define UINT16_MAX             (65535U)
76 #endif
77 #ifndef UINT32_MAX
78 #define UINT32_MAX             (4294967295U)
79 #endif
80
81 #endif /* ! FLEXINT_H */
82
83 /* begin standard C++ headers. */
84 #include <iostream> 
85 #include <errno.h>
86 #include <cstdlib>
87 #include <cstring>
88 /* end standard C++ headers. */
89
90 #ifdef __cplusplus
91
92 /* The "const" storage-class-modifier is valid. */
93 #define YY_USE_CONST
94
95 #else   /* ! __cplusplus */
96
97 #if __STDC__
98
99 #define YY_USE_CONST
100
101 #endif  /* __STDC__ */
102 #endif  /* ! __cplusplus */
103
104 #ifdef YY_USE_CONST
105 #define yyconst const
106 #else
107 #define yyconst
108 #endif
109
110 /* Returned upon end-of-file. */
111 #define YY_NULL 0
112
113 /* Promotes a possibly negative, possibly signed char to an unsigned
114  * integer for use as an array index.  If the signed char is negative,
115  * we want to instead treat it as an 8-bit unsigned char, hence the
116  * double cast.
117  */
118 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
119
120 /* Enter a start condition.  This macro really ought to take a parameter,
121  * but we do it the disgusting crufty way forced on us by the ()-less
122  * definition of BEGIN.
123  */
124 #define BEGIN (yy_start) = 1 + 2 *
125
126 /* Translate the current start state into a value that can be later handed
127  * to BEGIN to return to the state.  The YYSTATE alias is for lex
128  * compatibility.
129  */
130 #define YY_START (((yy_start) - 1) / 2)
131 #define YYSTATE YY_START
132
133 /* Action number for EOF rule of a given start state. */
134 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
135
136 /* Special action meaning "start processing a new file". */
137 #define YY_NEW_FILE yyrestart( yyin  )
138
139 #define YY_END_OF_BUFFER_CHAR 0
140
141 /* Size of default input buffer. */
142 #ifndef YY_BUF_SIZE
143 #define YY_BUF_SIZE 16384
144 #endif
145
146 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
147 #define YY_TYPEDEF_YY_BUFFER_STATE
148 typedef struct yy_buffer_state *YY_BUFFER_STATE;
149 #endif
150
151 extern int yyleng;
152
153 #define EOB_ACT_CONTINUE_SCAN 0
154 #define EOB_ACT_END_OF_FILE 1
155 #define EOB_ACT_LAST_MATCH 2
156
157     #define YY_LESS_LINENO(n)
158     
159 /* Return all but the first "n" matched characters back to the input stream. */
160 #define yyless(n) \
161         do \
162                 { \
163                 /* Undo effects of setting up yytext. */ \
164         int yyless_macro_arg = (n); \
165         YY_LESS_LINENO(yyless_macro_arg);\
166                 *yy_cp = (yy_hold_char); \
167                 YY_RESTORE_YY_MORE_OFFSET \
168                 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
169                 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
170                 } \
171         while ( 0 )
172
173 #define unput(c) yyunput( c, (yytext_ptr)  )
174
175 /* The following is because we cannot portably get our hands on size_t
176  * (without autoconf's help, which isn't available because we want
177  * flex-generated scanners to compile on their own).
178  */
179
180 #ifndef YY_TYPEDEF_YY_SIZE_T
181 #define YY_TYPEDEF_YY_SIZE_T
182 typedef unsigned int yy_size_t;
183 #endif
184
185 #ifndef YY_STRUCT_YY_BUFFER_STATE
186 #define YY_STRUCT_YY_BUFFER_STATE
187 struct yy_buffer_state
188         {
189
190         std::istream* yy_input_file;
191
192         char *yy_ch_buf;                /* input buffer */
193         char *yy_buf_pos;               /* current position in input buffer */
194
195         /* Size of input buffer in bytes, not including room for EOB
196          * characters.
197          */
198         yy_size_t yy_buf_size;
199
200         /* Number of characters read into yy_ch_buf, not including EOB
201          * characters.
202          */
203         int yy_n_chars;
204
205         /* Whether we "own" the buffer - i.e., we know we created it,
206          * and can realloc() it to grow it, and should free() it to
207          * delete it.
208          */
209         int yy_is_our_buffer;
210
211         /* Whether this is an "interactive" input source; if so, and
212          * if we're using stdio for input, then we want to use getc()
213          * instead of fread(), to make sure we stop fetching input after
214          * each newline.
215          */
216         int yy_is_interactive;
217
218         /* Whether we're considered to be at the beginning of a line.
219          * If so, '^' rules will be active on the next match, otherwise
220          * not.
221          */
222         int yy_at_bol;
223
224     int yy_bs_lineno; /**< The line count. */
225     int yy_bs_column; /**< The column count. */
226     
227         /* Whether to try to fill the input buffer when we reach the
228          * end of it.
229          */
230         int yy_fill_buffer;
231
232         int yy_buffer_status;
233
234 #define YY_BUFFER_NEW 0
235 #define YY_BUFFER_NORMAL 1
236         /* When an EOF's been seen but there's still some text to process
237          * then we mark the buffer as YY_EOF_PENDING, to indicate that we
238          * shouldn't try reading from the input source any more.  We might
239          * still have a bunch of tokens to match, though, because of
240          * possible backing-up.
241          *
242          * When we actually see the EOF, we change the status to "new"
243          * (via yyrestart()), so that the user can continue scanning by
244          * just pointing yyin at a new input file.
245          */
246 #define YY_BUFFER_EOF_PENDING 2
247
248         };
249 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
250
251 /* We provide macros for accessing buffer states in case in the
252  * future we want to put the buffer states in a more general
253  * "scanner state".
254  *
255  * Returns the top of the stack, or NULL.
256  */
257 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
258                           ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
259                           : NULL)
260
261 /* Same as previous macro, but useful when we know that the buffer stack is not
262  * NULL or when we need an lvalue. For internal use only.
263  */
264 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
265
266 void *yyalloc (yy_size_t  );
267 void *yyrealloc (void *,yy_size_t  );
268 void yyfree (void *  );
269
270 #define yy_new_buffer yy_create_buffer
271
272 #define yy_set_interactive(is_interactive) \
273         { \
274         if ( ! YY_CURRENT_BUFFER ){ \
275         yyensure_buffer_stack (); \
276                 YY_CURRENT_BUFFER_LVALUE =    \
277             yy_create_buffer( yyin, YY_BUF_SIZE ); \
278         } \
279         YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
280         }
281
282 #define yy_set_bol(at_bol) \
283         { \
284         if ( ! YY_CURRENT_BUFFER ){\
285         yyensure_buffer_stack (); \
286                 YY_CURRENT_BUFFER_LVALUE =    \
287             yy_create_buffer( yyin, YY_BUF_SIZE ); \
288         } \
289         YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
290         }
291
292 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
293
294 /* Begin user sect3 */
295
296 typedef unsigned char YY_CHAR;
297
298 #define yytext_ptr yytext
299 #define YY_INTERACTIVE
300
301 #include <FlexLexer.h>
302
303 /* Done after the current pattern has been matched and before the
304  * corresponding action - sets up yytext.
305  */
306 #define YY_DO_BEFORE_ACTION \
307         (yytext_ptr) = yy_bp; \
308         yyleng = (size_t) (yy_cp - yy_bp); \
309         (yy_hold_char) = *yy_cp; \
310         *yy_cp = '\0'; \
311         (yy_c_buf_p) = yy_cp;
312
313 #define YY_NUM_RULES 16
314 #define YY_END_OF_BUFFER 17
315 /* This struct is not used in this scanner,
316    but its presence is necessary. */
317 struct yy_trans_info
318         {
319         flex_int32_t yy_verify;
320         flex_int32_t yy_nxt;
321         };
322 static yyconst flex_int16_t yy_accept[27] =
323     {   0,
324         1,    1,   17,   15,    1,   16,   12,    6,    7,    4,
325         2,    3,   11,    5,   13,   13,   10,   14,    8,    9,
326         1,   13,    0,   14,   13,    0
327     } ;
328
329 static yyconst flex_int32_t yy_ec[256] =
330     {   0,
331         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
332         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
333         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
334         1,    2,    1,    1,    1,    1,    1,    4,    1,    5,
335         6,    7,    8,    1,    9,   10,   11,   12,   13,   13,
336        13,   13,   13,   13,   13,   13,   13,    1,    1,    1,
337        14,    1,    1,    1,   15,   15,   15,   15,   15,   15,
338        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
339        16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
340        17,    1,   18,    1,   16,    1,   15,   15,   15,   15,
341
342        15,   15,   16,   16,   16,   16,   16,   16,   16,   16,
343        16,   16,   16,   16,   16,   16,   16,   16,   16,   19,
344        16,   16,    1,    1,    1,    1,    1,    1,    1,    1,
345         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
346         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
347         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
348         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
349         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
350         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
351         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
352
353         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
354         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
355         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
356         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
357         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
358         1,    1,    1,    1,    1
359     } ;
360
361 static yyconst flex_int32_t yy_meta[20] =
362     {   0,
363         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
364         1,    2,    2,    1,    3,    4,    1,    1,    5
365     } ;
366
367 static yyconst flex_int16_t yy_base[30] =
368     {   0,
369         0,    0,   35,   36,   32,   36,   36,   36,   36,   36,
370        36,   36,   36,   36,    7,    8,   36,    0,   36,   36,
371        23,   10,    0,    0,    0,   36,   22,   26,   30
372     } ;
373
374 static yyconst flex_int16_t yy_def[30] =
375     {   0,
376        26,    1,   26,   26,   26,   26,   26,   26,   26,   26,
377        26,   26,   26,   26,   27,   26,   26,   28,   26,   26,
378        26,   26,   29,   28,   29,    0,   26,   26,   26
379     } ;
380
381 static yyconst flex_int16_t yy_nxt[56] =
382     {   0,
383         4,    5,    6,    7,    8,    9,   10,   11,   12,   13,
384        14,   15,   16,   17,   18,   18,   19,   20,   18,   22,
385        22,   22,   22,   22,   21,   23,   22,   24,   24,   24,
386        24,   25,   25,   21,   26,    3,   26,   26,   26,   26,
387        26,   26,   26,   26,   26,   26,   26,   26,   26,   26,
388        26,   26,   26,   26,   26
389     } ;
390
391 static yyconst flex_int16_t yy_chk[56] =
392     {   0,
393         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
394         1,    1,    1,    1,    1,    1,    1,    1,    1,   16,
395        16,   22,   22,   27,   21,   15,   27,   28,   28,   28,
396        28,   29,   29,    5,    3,   26,   26,   26,   26,   26,
397        26,   26,   26,   26,   26,   26,   26,   26,   26,   26,
398        26,   26,   26,   26,   26
399     } ;
400
401 /* The intent behind this definition is that it'll catch
402  * any uses of REJECT which flex missed.
403  */
404 #define REJECT reject_used_but_not_detected
405 #define yymore() yymore_used_but_not_detected
406 #define YY_MORE_ADJ 0
407 #define YY_RESTORE_YY_MORE_OFFSET
408 #line 1 "cmdlex.l"
409 #line 2 "cmdlex.l"
410 #include "cmdlexcl.h"
411 #include "cmdpars.h"
412
413 static YY_cl_ucsim_parser_STYPE *yylval;
414
415 int yywrap(void);
416
417 #define tok(x) (YY_cl_ucsim_parser_CLASS::x)
418 #define lexer_obj (dynamic_cast<class cl_ucsim_lexer *>(this))
419
420 #line 421 "cmdlex.cc"
421
422 #define INITIAL 0
423
424 #ifndef YY_NO_UNISTD_H
425 /* Special case for "unistd.h", since it is non-ANSI. We include it way
426  * down here because we want the user's section 1 to have been scanned first.
427  * The user has a chance to override it with an option.
428  */
429 #include <unistd.h>
430 #endif
431
432 #ifndef YY_EXTRA_TYPE
433 #define YY_EXTRA_TYPE void *
434 #endif
435
436 #ifndef yytext_ptr
437 static void yy_flex_strncpy (char *,yyconst char *,int );
438 #endif
439
440 #ifdef YY_NEED_STRLEN
441 static int yy_flex_strlen (yyconst char * );
442 #endif
443
444 #ifndef YY_NO_INPUT
445
446 #endif
447
448 /* Amount of stuff to slurp up with each read. */
449 #ifndef YY_READ_BUF_SIZE
450 #define YY_READ_BUF_SIZE 8192
451 #endif
452
453 /* Copy whatever the last rule matched to the standard output. */
454 #ifndef ECHO
455 #define ECHO LexerOutput( yytext, yyleng )
456 #endif
457
458 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
459  * is returned in "result".
460  */
461 #ifndef YY_INPUT
462 #define YY_INPUT(buf,result,max_size) \
463 \
464         if ( (result = LexerInput( (char *) buf, max_size )) < 0 ) \
465                 YY_FATAL_ERROR( "input in flex scanner failed" );
466
467 #endif
468
469 /* No semi-colon after return; correct usage is to write "yyterminate();" -
470  * we don't want an extra ';' after the "return" because that will cause
471  * some compilers to complain about unreachable statements.
472  */
473 #ifndef yyterminate
474 #define yyterminate() return YY_NULL
475 #endif
476
477 /* Number of entries by which start-condition stack grows. */
478 #ifndef YY_START_STACK_INCR
479 #define YY_START_STACK_INCR 25
480 #endif
481
482 /* Report a fatal error. */
483 #ifndef YY_FATAL_ERROR
484 #define YY_FATAL_ERROR(msg) LexerError( msg )
485 #endif
486
487 /* end tables serialization structures and prototypes */
488
489 /* Default declaration of generated scanner - a define so the user can
490  * easily add parameters.
491  */
492 #ifndef YY_DECL
493 #define YY_DECL_IS_OURS 1
494 #define YY_DECL int yyFlexLexer::yylex()
495 #endif /* !YY_DECL */
496
497 /* Code executed at the beginning of each rule, after yytext and yyleng
498  * have been set up.
499  */
500 #ifndef YY_USER_ACTION
501 #define YY_USER_ACTION
502 #endif
503
504 /* Code executed at the end of each rule. */
505 #ifndef YY_BREAK
506 #define YY_BREAK break;
507 #endif
508
509 #define YY_RULE_SETUP \
510         YY_USER_ACTION
511
512 /** The main scanner function which does all the work.
513  */
514 YY_DECL
515 {
516         register yy_state_type yy_current_state;
517         register char *yy_cp, *yy_bp;
518         register int yy_act;
519     
520 #line 14 "cmdlex.l"
521
522
523 #line 524 "cmdlex.cc"
524
525         if ( (yy_init) )
526                 {
527                 (yy_init) = 0;
528
529 #ifdef YY_USER_INIT
530                 YY_USER_INIT;
531 #endif
532
533                 if ( ! (yy_start) )
534                         (yy_start) = 1; /* first start state */
535
536                 if ( ! yyin )
537                         yyin = & std::cin;
538
539                 if ( ! yyout )
540                         yyout = & std::cout;
541
542                 if ( ! YY_CURRENT_BUFFER ) {
543                         yyensure_buffer_stack ();
544                         YY_CURRENT_BUFFER_LVALUE =
545                                 yy_create_buffer( yyin, YY_BUF_SIZE );
546                 }
547
548                 yy_load_buffer_state(  );
549                 }
550
551         while ( 1 )             /* loops until end-of-file is reached */
552                 {
553                 yy_cp = (yy_c_buf_p);
554
555                 /* Support of yytext. */
556                 *yy_cp = (yy_hold_char);
557
558                 /* yy_bp points to the position in yy_ch_buf of the start of
559                  * the current run.
560                  */
561                 yy_bp = yy_cp;
562
563                 yy_current_state = (yy_start);
564 yy_match:
565                 do
566                         {
567                         register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
568                         if ( yy_accept[yy_current_state] )
569                                 {
570                                 (yy_last_accepting_state) = yy_current_state;
571                                 (yy_last_accepting_cpos) = yy_cp;
572                                 }
573                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
574                                 {
575                                 yy_current_state = (int) yy_def[yy_current_state];
576                                 if ( yy_current_state >= 27 )
577                                         yy_c = yy_meta[(unsigned int) yy_c];
578                                 }
579                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
580                         ++yy_cp;
581                         }
582                 while ( yy_base[yy_current_state] != 36 );
583
584 yy_find_action:
585                 yy_act = yy_accept[yy_current_state];
586                 if ( yy_act == 0 )
587                         { /* have to back up */
588                         yy_cp = (yy_last_accepting_cpos);
589                         yy_current_state = (yy_last_accepting_state);
590                         yy_act = yy_accept[yy_current_state];
591                         }
592
593                 YY_DO_BEFORE_ACTION;
594
595 do_action:      /* This label is used only to access EOF actions. */
596
597                 switch ( yy_act )
598         { /* beginning of action switch */
599                         case 0: /* must back up */
600                         /* undo the effects of YY_DO_BEFORE_ACTION */
601                         *yy_cp = (yy_hold_char);
602                         yy_cp = (yy_last_accepting_cpos);
603                         yy_current_state = (yy_last_accepting_state);
604                         goto yy_find_action;
605
606 case 1:
607 YY_RULE_SETUP
608 #line 16 "cmdlex.l"
609 ;
610         YY_BREAK
611 case 2:
612 YY_RULE_SETUP
613 #line 18 "cmdlex.l"
614 return(tok(PTOK_PLUS));
615         YY_BREAK
616 case 3:
617 YY_RULE_SETUP
618 #line 19 "cmdlex.l"
619 return(tok(PTOK_MINUS));
620         YY_BREAK
621 case 4:
622 YY_RULE_SETUP
623 #line 20 "cmdlex.l"
624 return(tok(PTOK_ASTERIX));
625         YY_BREAK
626 case 5:
627 YY_RULE_SETUP
628 #line 21 "cmdlex.l"
629 return(tok(PTOK_SLASH));
630         YY_BREAK
631 case 6:
632 YY_RULE_SETUP
633 #line 22 "cmdlex.l"
634 return(tok(PTOK_LEFT_PAREN));
635         YY_BREAK
636 case 7:
637 YY_RULE_SETUP
638 #line 23 "cmdlex.l"
639 return(tok(PTOK_RIGHT_PAREN));
640         YY_BREAK
641 case 8:
642 YY_RULE_SETUP
643 #line 24 "cmdlex.l"
644 return(tok(PTOK_LEFT_BRACKET));
645         YY_BREAK
646 case 9:
647 YY_RULE_SETUP
648 #line 25 "cmdlex.l"
649 return(tok(PTOK_RIGHT_BRACKET));
650         YY_BREAK
651 case 10:
652 YY_RULE_SETUP
653 #line 26 "cmdlex.l"
654 return(tok(PTOK_EQUAL));
655         YY_BREAK
656 case 11:
657 YY_RULE_SETUP
658 #line 27 "cmdlex.l"
659 return(tok(PTOK_DOT));
660         YY_BREAK
661 case 12:
662 YY_RULE_SETUP
663 #line 28 "cmdlex.l"
664 return(tok(PTOK_AMPERSAND));
665         YY_BREAK
666 case 13:
667 YY_RULE_SETUP
668 #line 30 "cmdlex.l"
669 {
670   yylval->number= strtol(yytext, 0, 0);
671   return(YY_cl_ucsim_parser_CLASS::PTOK_NUMBER);
672 }
673         YY_BREAK
674 case 14:
675 YY_RULE_SETUP
676 #line 35 "cmdlex.l"
677 return(lexer_obj->check_id(yytext));
678         YY_BREAK
679 case 15:
680 YY_RULE_SETUP
681 #line 37 "cmdlex.l"
682 ;
683         YY_BREAK
684 case 16:
685 YY_RULE_SETUP
686 #line 39 "cmdlex.l"
687 ECHO;
688         YY_BREAK
689 #line 690 "cmdlex.cc"
690 case YY_STATE_EOF(INITIAL):
691         yyterminate();
692
693         case YY_END_OF_BUFFER:
694                 {
695                 /* Amount of text matched not including the EOB char. */
696                 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
697
698                 /* Undo the effects of YY_DO_BEFORE_ACTION. */
699                 *yy_cp = (yy_hold_char);
700                 YY_RESTORE_YY_MORE_OFFSET
701
702                 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
703                         {
704                         /* We're scanning a new file or input source.  It's
705                          * possible that this happened because the user
706                          * just pointed yyin at a new source and called
707                          * yylex().  If so, then we have to assure
708                          * consistency between YY_CURRENT_BUFFER and our
709                          * globals.  Here is the right place to do so, because
710                          * this is the first action (other than possibly a
711                          * back-up) that will match for the new input source.
712                          */
713                         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
714                         YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
715                         YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
716                         }
717
718                 /* Note that here we test for yy_c_buf_p "<=" to the position
719                  * of the first EOB in the buffer, since yy_c_buf_p will
720                  * already have been incremented past the NUL character
721                  * (since all states make transitions on EOB to the
722                  * end-of-buffer state).  Contrast this with the test
723                  * in input().
724                  */
725                 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
726                         { /* This was really a NUL. */
727                         yy_state_type yy_next_state;
728
729                         (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
730
731                         yy_current_state = yy_get_previous_state(  );
732
733                         /* Okay, we're now positioned to make the NUL
734                          * transition.  We couldn't have
735                          * yy_get_previous_state() go ahead and do it
736                          * for us because it doesn't know how to deal
737                          * with the possibility of jamming (and we don't
738                          * want to build jamming into it because then it
739                          * will run more slowly).
740                          */
741
742                         yy_next_state = yy_try_NUL_trans( yy_current_state );
743
744                         yy_bp = (yytext_ptr) + YY_MORE_ADJ;
745
746                         if ( yy_next_state )
747                                 {
748                                 /* Consume the NUL. */
749                                 yy_cp = ++(yy_c_buf_p);
750                                 yy_current_state = yy_next_state;
751                                 goto yy_match;
752                                 }
753
754                         else
755                                 {
756                                 yy_cp = (yy_c_buf_p);
757                                 goto yy_find_action;
758                                 }
759                         }
760
761                 else switch ( yy_get_next_buffer(  ) )
762                         {
763                         case EOB_ACT_END_OF_FILE:
764                                 {
765                                 (yy_did_buffer_switch_on_eof) = 0;
766
767                                 if ( yywrap(  ) )
768                                         {
769                                         /* Note: because we've taken care in
770                                          * yy_get_next_buffer() to have set up
771                                          * yytext, we can now set up
772                                          * yy_c_buf_p so that if some total
773                                          * hoser (like flex itself) wants to
774                                          * call the scanner after we return the
775                                          * YY_NULL, it'll still work - another
776                                          * YY_NULL will get returned.
777                                          */
778                                         (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
779
780                                         yy_act = YY_STATE_EOF(YY_START);
781                                         goto do_action;
782                                         }
783
784                                 else
785                                         {
786                                         if ( ! (yy_did_buffer_switch_on_eof) )
787                                                 YY_NEW_FILE;
788                                         }
789                                 break;
790                                 }
791
792                         case EOB_ACT_CONTINUE_SCAN:
793                                 (yy_c_buf_p) =
794                                         (yytext_ptr) + yy_amount_of_matched_text;
795
796                                 yy_current_state = yy_get_previous_state(  );
797
798                                 yy_cp = (yy_c_buf_p);
799                                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
800                                 goto yy_match;
801
802                         case EOB_ACT_LAST_MATCH:
803                                 (yy_c_buf_p) =
804                                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
805
806                                 yy_current_state = yy_get_previous_state(  );
807
808                                 yy_cp = (yy_c_buf_p);
809                                 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
810                                 goto yy_find_action;
811                         }
812                 break;
813                 }
814
815         default:
816                 YY_FATAL_ERROR(
817                         "fatal flex scanner internal error--no action found" );
818         } /* end of action switch */
819                 } /* end of scanning one token */
820 } /* end of yylex */
821
822 yyFlexLexer::yyFlexLexer( std::istream* arg_yyin, std::ostream* arg_yyout )
823 {
824         yyin = arg_yyin;
825         yyout = arg_yyout;
826         yy_c_buf_p = 0;
827         yy_init = 1;
828         yy_start = 0;
829         yy_flex_debug = 0;
830         yylineno = 1;   // this will only get updated if %option yylineno
831
832         yy_did_buffer_switch_on_eof = 0;
833
834         yy_looking_for_trail_begin = 0;
835         yy_more_flag = 0;
836         yy_more_len = 0;
837         yy_more_offset = yy_prev_more_offset = 0;
838
839         yy_start_stack_ptr = yy_start_stack_depth = 0;
840         yy_start_stack = 0;
841
842     (yy_buffer_stack) = 0;
843     (yy_buffer_stack_top) = 0;
844     (yy_buffer_stack_max) = 0;
845
846         yy_state_buf = 0;
847
848 }
849
850 yyFlexLexer::~yyFlexLexer()
851 {
852         delete [] yy_state_buf;
853         yyfree(yy_start_stack  );
854         yy_delete_buffer( YY_CURRENT_BUFFER );
855 }
856
857 void yyFlexLexer::switch_streams( std::istream* new_in, std::ostream* new_out )
858 {
859         if ( new_in )
860                 {
861                 yy_delete_buffer( YY_CURRENT_BUFFER );
862                 yy_switch_to_buffer( yy_create_buffer( new_in, YY_BUF_SIZE  ) );
863                 }
864
865         if ( new_out )
866                 yyout = new_out;
867 }
868
869 #ifdef YY_INTERACTIVE
870 int yyFlexLexer::LexerInput( char* buf, int /* max_size */ )
871 #else
872 int yyFlexLexer::LexerInput( char* buf, int max_size )
873 #endif
874 {
875         if ( yyin->eof() || yyin->fail() )
876                 return 0;
877
878 #ifdef YY_INTERACTIVE
879         yyin->get( buf[0] );
880
881         if ( yyin->eof() )
882                 return 0;
883
884         if ( yyin->bad() )
885                 return -1;
886
887         return 1;
888
889 #else
890         (void) yyin->read( buf, max_size );
891
892         if ( yyin->bad() )
893                 return -1;
894         else
895                 return yyin->gcount();
896 #endif
897 }
898
899 void yyFlexLexer::LexerOutput( const char* buf, int size )
900 {
901         (void) yyout->write( buf, size );
902 }
903
904 /* yy_get_next_buffer - try to read in a new buffer
905  *
906  * Returns a code representing an action:
907  *      EOB_ACT_LAST_MATCH -
908  *      EOB_ACT_CONTINUE_SCAN - continue scanning from current position
909  *      EOB_ACT_END_OF_FILE - end of file
910  */
911 int yyFlexLexer::yy_get_next_buffer()
912 {
913         register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
914         register char *source = (yytext_ptr);
915         register int number_to_move, i;
916         int ret_val;
917
918         if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
919                 YY_FATAL_ERROR(
920                 "fatal flex scanner internal error--end of buffer missed" );
921
922         if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
923                 { /* Don't try to fill the buffer, so this is an EOF. */
924                 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
925                         {
926                         /* We matched a single character, the EOB, so
927                          * treat this as a final EOF.
928                          */
929                         return EOB_ACT_END_OF_FILE;
930                         }
931
932                 else
933                         {
934                         /* We matched some text prior to the EOB, first
935                          * process it.
936                          */
937                         return EOB_ACT_LAST_MATCH;
938                         }
939                 }
940
941         /* Try to read more data. */
942
943         /* First move last chars to start of buffer. */
944         number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
945
946         for ( i = 0; i < number_to_move; ++i )
947                 *(dest++) = *(source++);
948
949         if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
950                 /* don't do the read, it's not guaranteed to return an EOF,
951                  * just force an EOF
952                  */
953                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
954
955         else
956                 {
957                         size_t num_to_read =
958                         YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
959
960                 while ( num_to_read <= 0 )
961                         { /* Not enough room in the buffer - grow it. */
962
963                         /* just a shorter name for the current buffer */
964                         YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
965
966                         int yy_c_buf_p_offset =
967                                 (int) ((yy_c_buf_p) - b->yy_ch_buf);
968
969                         if ( b->yy_is_our_buffer )
970                                 {
971                                 int new_size = b->yy_buf_size * 2;
972
973                                 if ( new_size <= 0 )
974                                         b->yy_buf_size += b->yy_buf_size / 8;
975                                 else
976                                         b->yy_buf_size *= 2;
977
978                                 b->yy_ch_buf = (char *)
979                                         /* Include room in for 2 EOB chars. */
980                                         yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
981                                 }
982                         else
983                                 /* Can't grow it, we don't own it. */
984                                 b->yy_ch_buf = 0;
985
986                         if ( ! b->yy_ch_buf )
987                                 YY_FATAL_ERROR(
988                                 "fatal error - scanner input buffer overflow" );
989
990                         (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
991
992                         num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
993                                                 number_to_move - 1;
994
995                         }
996
997                 if ( num_to_read > YY_READ_BUF_SIZE )
998                         num_to_read = YY_READ_BUF_SIZE;
999
1000                 /* Read in more data. */
1001                 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1002                         (yy_n_chars), num_to_read );
1003
1004                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1005                 }
1006
1007         if ( (yy_n_chars) == 0 )
1008                 {
1009                 if ( number_to_move == YY_MORE_ADJ )
1010                         {
1011                         ret_val = EOB_ACT_END_OF_FILE;
1012                         yyrestart( yyin  );
1013                         }
1014
1015                 else
1016                         {
1017                         ret_val = EOB_ACT_LAST_MATCH;
1018                         YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1019                                 YY_BUFFER_EOF_PENDING;
1020                         }
1021                 }
1022
1023         else
1024                 ret_val = EOB_ACT_CONTINUE_SCAN;
1025
1026         (yy_n_chars) += number_to_move;
1027         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1028         YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1029
1030         (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1031
1032         return ret_val;
1033 }
1034
1035 /* yy_get_previous_state - get the state just before the EOB char was reached */
1036
1037     yy_state_type yyFlexLexer::yy_get_previous_state()
1038 {
1039         register yy_state_type yy_current_state;
1040         register char *yy_cp;
1041     
1042         yy_current_state = (yy_start);
1043
1044         for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1045                 {
1046                 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1047                 if ( yy_accept[yy_current_state] )
1048                         {
1049                         (yy_last_accepting_state) = yy_current_state;
1050                         (yy_last_accepting_cpos) = yy_cp;
1051                         }
1052                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1053                         {
1054                         yy_current_state = (int) yy_def[yy_current_state];
1055                         if ( yy_current_state >= 27 )
1056                                 yy_c = yy_meta[(unsigned int) yy_c];
1057                         }
1058                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1059                 }
1060
1061         return yy_current_state;
1062 }
1063
1064 /* yy_try_NUL_trans - try to make a transition on the NUL character
1065  *
1066  * synopsis
1067  *      next_state = yy_try_NUL_trans( current_state );
1068  */
1069     yy_state_type yyFlexLexer::yy_try_NUL_trans( yy_state_type yy_current_state )
1070 {
1071         register int yy_is_jam;
1072         register char *yy_cp = (yy_c_buf_p);
1073
1074         register YY_CHAR yy_c = 1;
1075         if ( yy_accept[yy_current_state] )
1076                 {
1077                 (yy_last_accepting_state) = yy_current_state;
1078                 (yy_last_accepting_cpos) = yy_cp;
1079                 }
1080         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1081                 {
1082                 yy_current_state = (int) yy_def[yy_current_state];
1083                 if ( yy_current_state >= 27 )
1084                         yy_c = yy_meta[(unsigned int) yy_c];
1085                 }
1086         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1087         yy_is_jam = (yy_current_state == 26);
1088
1089         return yy_is_jam ? 0 : yy_current_state;
1090 }
1091
1092     void yyFlexLexer::yyunput( int c, register char* yy_bp)
1093 {
1094         register char *yy_cp;
1095     
1096     yy_cp = (yy_c_buf_p);
1097
1098         /* undo effects of setting up yytext */
1099         *yy_cp = (yy_hold_char);
1100
1101         if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1102                 { /* need to shift things up to make room */
1103                 /* +2 for EOB chars. */
1104                 register int number_to_move = (yy_n_chars) + 2;
1105                 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1106                                         YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1107                 register char *source =
1108                                 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1109
1110                 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1111                         *--dest = *--source;
1112
1113                 yy_cp += (int) (dest - source);
1114                 yy_bp += (int) (dest - source);
1115                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1116                         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1117
1118                 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1119                         YY_FATAL_ERROR( "flex scanner push-back overflow" );
1120                 }
1121
1122         *--yy_cp = (char) c;
1123
1124         (yytext_ptr) = yy_bp;
1125         (yy_hold_char) = *yy_cp;
1126         (yy_c_buf_p) = yy_cp;
1127 }
1128
1129     int yyFlexLexer::yyinput()
1130 {
1131         int c;
1132     
1133         *(yy_c_buf_p) = (yy_hold_char);
1134
1135         if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1136                 {
1137                 /* yy_c_buf_p now points to the character we want to return.
1138                  * If this occurs *before* the EOB characters, then it's a
1139                  * valid NUL; if not, then we've hit the end of the buffer.
1140                  */
1141                 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1142                         /* This was really a NUL. */
1143                         *(yy_c_buf_p) = '\0';
1144
1145                 else
1146                         { /* need more input */
1147                         int offset = (yy_c_buf_p) - (yytext_ptr);
1148                         ++(yy_c_buf_p);
1149
1150                         switch ( yy_get_next_buffer(  ) )
1151                                 {
1152                                 case EOB_ACT_LAST_MATCH:
1153                                         /* This happens because yy_g_n_b()
1154                                          * sees that we've accumulated a
1155                                          * token and flags that we need to
1156                                          * try matching the token before
1157                                          * proceeding.  But for input(),
1158                                          * there's no matching to consider.
1159                                          * So convert the EOB_ACT_LAST_MATCH
1160                                          * to EOB_ACT_END_OF_FILE.
1161                                          */
1162
1163                                         /* Reset buffer status. */
1164                                         yyrestart( yyin );
1165
1166                                         /*FALLTHROUGH*/
1167
1168                                 case EOB_ACT_END_OF_FILE:
1169                                         {
1170                                         if ( yywrap(  ) )
1171                                                 return EOF;
1172
1173                                         if ( ! (yy_did_buffer_switch_on_eof) )
1174                                                 YY_NEW_FILE;
1175 #ifdef __cplusplus
1176                                         return yyinput();
1177 #else
1178                                         return input();
1179 #endif
1180                                         }
1181
1182                                 case EOB_ACT_CONTINUE_SCAN:
1183                                         (yy_c_buf_p) = (yytext_ptr) + offset;
1184                                         break;
1185                                 }
1186                         }
1187                 }
1188
1189         c = *(unsigned char *) (yy_c_buf_p);    /* cast for 8-bit char's */
1190         *(yy_c_buf_p) = '\0';   /* preserve yytext */
1191         (yy_hold_char) = *++(yy_c_buf_p);
1192
1193         return c;
1194 }
1195
1196 /** Immediately switch to a different input stream.
1197  * @param input_file A readable stream.
1198  * 
1199  * @note This function does not reset the start condition to @c INITIAL .
1200  */
1201     void yyFlexLexer::yyrestart( std::istream* input_file )
1202 {
1203     
1204         if ( ! YY_CURRENT_BUFFER ){
1205         yyensure_buffer_stack ();
1206                 YY_CURRENT_BUFFER_LVALUE =
1207             yy_create_buffer( yyin, YY_BUF_SIZE );
1208         }
1209
1210         yy_init_buffer( YY_CURRENT_BUFFER, input_file );
1211         yy_load_buffer_state(  );
1212 }
1213
1214 /** Switch to a different input buffer.
1215  * @param new_buffer The new input buffer.
1216  * 
1217  */
1218     void yyFlexLexer::yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1219 {
1220     
1221         /* TODO. We should be able to replace this entire function body
1222          * with
1223          *              yypop_buffer_state();
1224          *              yypush_buffer_state(new_buffer);
1225      */
1226         yyensure_buffer_stack ();
1227         if ( YY_CURRENT_BUFFER == new_buffer )
1228                 return;
1229
1230         if ( YY_CURRENT_BUFFER )
1231                 {
1232                 /* Flush out information for old buffer. */
1233                 *(yy_c_buf_p) = (yy_hold_char);
1234                 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1235                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1236                 }
1237
1238         YY_CURRENT_BUFFER_LVALUE = new_buffer;
1239         yy_load_buffer_state(  );
1240
1241         /* We don't actually know whether we did this switch during
1242          * EOF (yywrap()) processing, but the only time this flag
1243          * is looked at is after yywrap() is called, so it's safe
1244          * to go ahead and always set it.
1245          */
1246         (yy_did_buffer_switch_on_eof) = 1;
1247 }
1248
1249     void yyFlexLexer::yy_load_buffer_state()
1250 {
1251         (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1252         (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1253         yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1254         (yy_hold_char) = *(yy_c_buf_p);
1255 }
1256
1257 /** Allocate and initialize an input buffer state.
1258  * @param file A readable stream.
1259  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1260  * 
1261  * @return the allocated buffer state.
1262  */
1263     YY_BUFFER_STATE yyFlexLexer::yy_create_buffer( std::istream* file, int size )
1264 {
1265         YY_BUFFER_STATE b;
1266     
1267         b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1268         if ( ! b )
1269                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1270
1271         b->yy_buf_size = size;
1272
1273         /* yy_ch_buf has to be 2 characters longer than the size given because
1274          * we need to put in 2 end-of-buffer characters.
1275          */
1276         b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
1277         if ( ! b->yy_ch_buf )
1278                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1279
1280         b->yy_is_our_buffer = 1;
1281
1282         yy_init_buffer( b, file );
1283
1284         return b;
1285 }
1286
1287 /** Destroy the buffer.
1288  * @param b a buffer created with yy_create_buffer()
1289  * 
1290  */
1291     void yyFlexLexer::yy_delete_buffer( YY_BUFFER_STATE b )
1292 {
1293     
1294         if ( ! b )
1295                 return;
1296
1297         if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1298                 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1299
1300         if ( b->yy_is_our_buffer )
1301                 yyfree((void *) b->yy_ch_buf  );
1302
1303         yyfree((void *) b  );
1304 }
1305
1306 extern "C" int isatty (int );
1307
1308 /* Initializes or reinitializes a buffer.
1309  * This function is sometimes called more than once on the same buffer,
1310  * such as during a yyrestart() or at EOF.
1311  */
1312     void yyFlexLexer::yy_init_buffer( YY_BUFFER_STATE b, std::istream* file )
1313
1314 {
1315         int oerrno = errno;
1316     
1317         yy_flush_buffer( b );
1318
1319         b->yy_input_file = file;
1320         b->yy_fill_buffer = 1;
1321
1322     /* If b is the current buffer, then yy_init_buffer was _probably_
1323      * called from yyrestart() or through yy_get_next_buffer.
1324      * In that case, we don't want to reset the lineno or column.
1325      */
1326     if (b != YY_CURRENT_BUFFER){
1327         b->yy_bs_lineno = 1;
1328         b->yy_bs_column = 0;
1329     }
1330
1331         b->yy_is_interactive = 0;
1332         errno = oerrno;
1333 }
1334
1335 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1336  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1337  * 
1338  */
1339     void yyFlexLexer::yy_flush_buffer( YY_BUFFER_STATE b )
1340 {
1341         if ( ! b )
1342                 return;
1343
1344         b->yy_n_chars = 0;
1345
1346         /* We always need two end-of-buffer characters.  The first causes
1347          * a transition to the end-of-buffer state.  The second causes
1348          * a jam in that state.
1349          */
1350         b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1351         b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1352
1353         b->yy_buf_pos = &b->yy_ch_buf[0];
1354
1355         b->yy_at_bol = 1;
1356         b->yy_buffer_status = YY_BUFFER_NEW;
1357
1358         if ( b == YY_CURRENT_BUFFER )
1359                 yy_load_buffer_state(  );
1360 }
1361
1362 /** Pushes the new state onto the stack. The new state becomes
1363  *  the current state. This function will allocate the stack
1364  *  if necessary.
1365  *  @param new_buffer The new state.
1366  *  
1367  */
1368 void yyFlexLexer::yypush_buffer_state (YY_BUFFER_STATE new_buffer)
1369 {
1370         if (new_buffer == NULL)
1371                 return;
1372
1373         yyensure_buffer_stack();
1374
1375         /* This block is copied from yy_switch_to_buffer. */
1376         if ( YY_CURRENT_BUFFER )
1377                 {
1378                 /* Flush out information for old buffer. */
1379                 *(yy_c_buf_p) = (yy_hold_char);
1380                 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1381                 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1382                 }
1383
1384         /* Only push if top exists. Otherwise, replace top. */
1385         if (YY_CURRENT_BUFFER)
1386                 (yy_buffer_stack_top)++;
1387         YY_CURRENT_BUFFER_LVALUE = new_buffer;
1388
1389         /* copied from yy_switch_to_buffer. */
1390         yy_load_buffer_state(  );
1391         (yy_did_buffer_switch_on_eof) = 1;
1392 }
1393
1394 /** Removes and deletes the top of the stack, if present.
1395  *  The next element becomes the new top.
1396  *  
1397  */
1398 void yyFlexLexer::yypop_buffer_state (void)
1399 {
1400         if (!YY_CURRENT_BUFFER)
1401                 return;
1402
1403         yy_delete_buffer(YY_CURRENT_BUFFER );
1404         YY_CURRENT_BUFFER_LVALUE = NULL;
1405         if ((yy_buffer_stack_top) > 0)
1406                 --(yy_buffer_stack_top);
1407
1408         if (YY_CURRENT_BUFFER) {
1409                 yy_load_buffer_state(  );
1410                 (yy_did_buffer_switch_on_eof) = 1;
1411         }
1412 }
1413
1414 /* Allocates the stack if it does not exist.
1415  *  Guarantees space for at least one push.
1416  */
1417 void yyFlexLexer::yyensure_buffer_stack(void)
1418 {
1419         int num_to_alloc;
1420     
1421         if (!(yy_buffer_stack)) {
1422
1423                 /* First allocation is just for 2 elements, since we don't know if this
1424                  * scanner will even need a stack. We use 2 instead of 1 to avoid an
1425                  * immediate realloc on the next call.
1426          */
1427                 num_to_alloc = 1;
1428                 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1429                                                                 (num_to_alloc * sizeof(struct yy_buffer_state*)
1430                                                                 );
1431                 
1432                 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1433                                 
1434                 (yy_buffer_stack_max) = num_to_alloc;
1435                 (yy_buffer_stack_top) = 0;
1436                 return;
1437         }
1438
1439         if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1440
1441                 /* Increase the buffer to prepare for a possible push. */
1442                 int grow_size = 8 /* arbitrary grow size */;
1443
1444                 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1445                 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1446                                                                 ((yy_buffer_stack),
1447                                                                 num_to_alloc * sizeof(struct yy_buffer_state*)
1448                                                                 );
1449
1450                 /* zero only the new slots.*/
1451                 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1452                 (yy_buffer_stack_max) = num_to_alloc;
1453         }
1454 }
1455
1456     void yyFlexLexer::yy_push_state( int new_state )
1457 {
1458         if ( (yy_start_stack_ptr) >= (yy_start_stack_depth) )
1459                 {
1460                 yy_size_t new_size;
1461
1462                 (yy_start_stack_depth) += YY_START_STACK_INCR;
1463                 new_size = (yy_start_stack_depth) * sizeof( int );
1464
1465                 if ( ! (yy_start_stack) )
1466                         (yy_start_stack) = (int *) yyalloc(new_size  );
1467
1468                 else
1469                         (yy_start_stack) = (int *) yyrealloc((void *) (yy_start_stack),new_size  );
1470
1471                 if ( ! (yy_start_stack) )
1472                         YY_FATAL_ERROR(
1473                         "out of memory expanding start-condition stack" );
1474                 }
1475
1476         (yy_start_stack)[(yy_start_stack_ptr)++] = YY_START;
1477
1478         BEGIN(new_state);
1479 }
1480
1481     void yyFlexLexer::yy_pop_state()
1482 {
1483         if ( --(yy_start_stack_ptr) < 0 )
1484                 YY_FATAL_ERROR( "start-condition stack underflow" );
1485
1486         BEGIN((yy_start_stack)[(yy_start_stack_ptr)]);
1487 }
1488
1489     int yyFlexLexer::yy_top_state()
1490 {
1491         return (yy_start_stack)[(yy_start_stack_ptr) - 1];
1492 }
1493
1494 #ifndef YY_EXIT_FAILURE
1495 #define YY_EXIT_FAILURE 2
1496 #endif
1497
1498 void yyFlexLexer::LexerError( yyconst char msg[] )
1499 {
1500         std::cerr << msg << std::endl;
1501         exit( YY_EXIT_FAILURE );
1502 }
1503
1504 /* Redefine yyless() so it works in section 3 code. */
1505
1506 #undef yyless
1507 #define yyless(n) \
1508         do \
1509                 { \
1510                 /* Undo effects of setting up yytext. */ \
1511         int yyless_macro_arg = (n); \
1512         YY_LESS_LINENO(yyless_macro_arg);\
1513                 yytext[yyleng] = (yy_hold_char); \
1514                 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1515                 (yy_hold_char) = *(yy_c_buf_p); \
1516                 *(yy_c_buf_p) = '\0'; \
1517                 yyleng = yyless_macro_arg; \
1518                 } \
1519         while ( 0 )
1520
1521 /* Accessor  methods (get/set functions) to struct members. */
1522
1523 /*
1524  * Internal utility routines.
1525  */
1526
1527 #ifndef yytext_ptr
1528 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1529 {
1530         register int i;
1531         for ( i = 0; i < n; ++i )
1532                 s1[i] = s2[i];
1533 }
1534 #endif
1535
1536 #ifdef YY_NEED_STRLEN
1537 static int yy_flex_strlen (yyconst char * s )
1538 {
1539         register int n;
1540         for ( n = 0; s[n]; ++n )
1541                 ;
1542
1543         return n;
1544 }
1545 #endif
1546
1547 void *yyalloc (yy_size_t  size )
1548 {
1549         return (void *) malloc( size );
1550 }
1551
1552 void *yyrealloc  (void * ptr, yy_size_t  size )
1553 {
1554         /* The cast to (char *) in the following accommodates both
1555          * implementations that use char* generic pointers, and those
1556          * that use void* generic pointers.  It works with the latter
1557          * because both ANSI C and C++ allow castless assignment from
1558          * any pointer type to void*, and deal with argument conversions
1559          * as though doing an assignment.
1560          */
1561         return (void *) realloc( (char *) ptr, size );
1562 }
1563
1564 void yyfree (void * ptr )
1565 {
1566         free( (char *) ptr );   /* see yyrealloc() for (char *) cast */
1567 }
1568
1569 #define YYTABLES_NAME "yytables"
1570
1571 #undef YY_NEW_FILE
1572 #undef YY_FLUSH_BUFFER
1573 #undef yy_set_bol
1574 #undef yy_new_buffer
1575 #undef yy_set_interactive
1576 #undef yytext_ptr
1577 #undef YY_DO_BEFORE_ACTION
1578
1579 #ifdef YY_DECL_IS_OURS
1580 #undef YY_DECL_IS_OURS
1581 #undef YY_DECL
1582 #endif
1583 #line 39 "cmdlex.l"
1584
1585
1586
1587 #undef lexer_obj
1588
1589 int
1590 yywrap(void)
1591 {
1592   return(1);
1593 }
1594
1595 #include "cmdlexcl.h"
1596 #include "globals.h"
1597
1598 int
1599 cl_ucsim_lexer::LexerInput(char *buf, int max_size)
1600 {
1601   if (!string_to_parse)
1602     return(yyFlexLexer::LexerInput(buf, max_size));
1603   int lrem= strlen(string_ptr);
1604   int n= max_size;
1605   if (lrem < max_size)
1606     n= lrem;
1607   strncpy(buf, string_ptr, n);
1608   string_ptr+= n;
1609   return(n);
1610 }
1611
1612 void
1613 cl_ucsim_lexer::activate_lexer_to_parse_into(void *yylv)
1614 {
1615   yylval= (YY_cl_ucsim_parser_STYPE *)yylv;
1616 }
1617
1618 int
1619 cl_ucsim_lexer::check_id(char *token)
1620 {
1621   class cl_uc *uc= application->get_uc();
1622   //printf("checking id=\"%s\"\n",token);
1623
1624   if (uc)
1625     {
1626       class cl_memory *mem= uc->memory(token);
1627       if (mem)
1628         {
1629           yylval->memory_object= mem;
1630           return(tok(PTOK_MEMORY_OBJECT));
1631         }
1632       
1633       t_addr addr;
1634       bool found= uc->symbol2address(yytext, uc->sfr_tbl(), &addr);
1635       if (found)
1636         {
1637           /*yylval->number= addr;
1638             return(tok(PTOK_NUMBER));*/
1639           yylval->memory.memory= uc->address_space(MEM_SFR_ID);
1640           yylval->memory.address= addr;
1641           return(tok(PTOK_MEMORY));
1642         }
1643
1644       found= uc->symbol2address(yytext, uc->bit_tbl(), &addr);
1645       if (found)
1646         {
1647           t_addr memaddr;
1648           t_mem mask;
1649           yylval->bit.memory= uc->bit2mem(addr, &memaddr, &mask);
1650           yylval->bit.mem_address= memaddr;
1651           yylval->bit.bit_address= addr;
1652           yylval->bit.mask= mask;
1653           return(tok(PTOK_BIT));
1654         }
1655     }
1656
1657   return(0);
1658 }
1659