]> www.ginac.de Git - ginac.git/blob - ginsh/ginsh_lexer.cc
- docs now under automake control
[ginac.git] / ginsh / ginsh_lexer.cc
1 /* A lexical scanner generated by flex */
2
3 /* Scanner skeleton version:
4  * $Header: /home/cvs/GiNaC/ginsh/Attic/ginsh_lexer.cc,v 1.1 1999/11/10 16:36:04 cbauer Exp $
5  */
6
7 #define FLEX_SCANNER
8 #define YY_FLEX_MAJOR_VERSION 2
9 #define YY_FLEX_MINOR_VERSION 5
10
11 #include <stdio.h>
12
13
14 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
15 #ifdef c_plusplus
16 #ifndef __cplusplus
17 #define __cplusplus
18 #endif
19 #endif
20
21
22 #ifdef __cplusplus
23
24 #include <stdlib.h>
25 #include <unistd.h>
26
27 /* Use prototypes in function declarations. */
28 #define YY_USE_PROTOS
29
30 /* The "const" storage-class-modifier is valid. */
31 #define YY_USE_CONST
32
33 #else   /* ! __cplusplus */
34
35 #if __STDC__
36
37 #define YY_USE_PROTOS
38 #define YY_USE_CONST
39
40 #endif  /* __STDC__ */
41 #endif  /* ! __cplusplus */
42
43 #ifdef __TURBOC__
44  #pragma warn -rch
45  #pragma warn -use
46 #include <io.h>
47 #include <stdlib.h>
48 #define YY_USE_CONST
49 #define YY_USE_PROTOS
50 #endif
51
52 #ifdef YY_USE_CONST
53 #define yyconst const
54 #else
55 #define yyconst
56 #endif
57
58
59 #ifdef YY_USE_PROTOS
60 #define YY_PROTO(proto) proto
61 #else
62 #define YY_PROTO(proto) ()
63 #endif
64
65 /* Returned upon end-of-file. */
66 #define YY_NULL 0
67
68 /* Promotes a possibly negative, possibly signed char to an unsigned
69  * integer for use as an array index.  If the signed char is negative,
70  * we want to instead treat it as an 8-bit unsigned char, hence the
71  * double cast.
72  */
73 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
74
75 /* Enter a start condition.  This macro really ought to take a parameter,
76  * but we do it the disgusting crufty way forced on us by the ()-less
77  * definition of BEGIN.
78  */
79 #define BEGIN yy_start = 1 + 2 *
80
81 /* Translate the current start state into a value that can be later handed
82  * to BEGIN to return to the state.  The YYSTATE alias is for lex
83  * compatibility.
84  */
85 #define YY_START ((yy_start - 1) / 2)
86 #define YYSTATE YY_START
87
88 /* Action number for EOF rule of a given start state. */
89 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
90
91 /* Special action meaning "start processing a new file". */
92 #define YY_NEW_FILE yyrestart( yyin )
93
94 #define YY_END_OF_BUFFER_CHAR 0
95
96 /* Size of default input buffer. */
97 #define YY_BUF_SIZE 16384
98
99 typedef struct yy_buffer_state *YY_BUFFER_STATE;
100
101 extern int yyleng;
102 extern FILE *yyin, *yyout;
103
104 #define EOB_ACT_CONTINUE_SCAN 0
105 #define EOB_ACT_END_OF_FILE 1
106 #define EOB_ACT_LAST_MATCH 2
107
108 /* The funky do-while in the following #define is used to turn the definition
109  * int a single C statement (which needs a semi-colon terminator).  This
110  * avoids problems with code like:
111  *
112  *      if ( condition_holds )
113  *              yyless( 5 );
114  *      else
115  *              do_something_else();
116  *
117  * Prior to using the do-while the compiler would get upset at the
118  * "else" because it interpreted the "if" statement as being all
119  * done when it reached the ';' after the yyless() call.
120  */
121
122 /* Return all but the first 'n' matched characters back to the input stream. */
123
124 #define yyless(n) \
125         do \
126                 { \
127                 /* Undo effects of setting up yytext. */ \
128                 *yy_cp = yy_hold_char; \
129                 YY_RESTORE_YY_MORE_OFFSET \
130                 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
131                 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
132                 } \
133         while ( 0 )
134
135 #define unput(c) yyunput( c, yytext_ptr )
136
137 /* The following is because we cannot portably get our hands on size_t
138  * (without autoconf's help, which isn't available because we want
139  * flex-generated scanners to compile on their own).
140  */
141 typedef unsigned int yy_size_t;
142
143
144 struct yy_buffer_state
145         {
146         FILE *yy_input_file;
147
148         char *yy_ch_buf;                /* input buffer */
149         char *yy_buf_pos;               /* current position in input buffer */
150
151         /* Size of input buffer in bytes, not including room for EOB
152          * characters.
153          */
154         yy_size_t yy_buf_size;
155
156         /* Number of characters read into yy_ch_buf, not including EOB
157          * characters.
158          */
159         int yy_n_chars;
160
161         /* Whether we "own" the buffer - i.e., we know we created it,
162          * and can realloc() it to grow it, and should free() it to
163          * delete it.
164          */
165         int yy_is_our_buffer;
166
167         /* Whether this is an "interactive" input source; if so, and
168          * if we're using stdio for input, then we want to use getc()
169          * instead of fread(), to make sure we stop fetching input after
170          * each newline.
171          */
172         int yy_is_interactive;
173
174         /* Whether we're considered to be at the beginning of a line.
175          * If so, '^' rules will be active on the next match, otherwise
176          * not.
177          */
178         int yy_at_bol;
179
180         /* Whether to try to fill the input buffer when we reach the
181          * end of it.
182          */
183         int yy_fill_buffer;
184
185         int yy_buffer_status;
186 #define YY_BUFFER_NEW 0
187 #define YY_BUFFER_NORMAL 1
188         /* When an EOF's been seen but there's still some text to process
189          * then we mark the buffer as YY_EOF_PENDING, to indicate that we
190          * shouldn't try reading from the input source any more.  We might
191          * still have a bunch of tokens to match, though, because of
192          * possible backing-up.
193          *
194          * When we actually see the EOF, we change the status to "new"
195          * (via yyrestart()), so that the user can continue scanning by
196          * just pointing yyin at a new input file.
197          */
198 #define YY_BUFFER_EOF_PENDING 2
199         };
200
201 static YY_BUFFER_STATE yy_current_buffer = 0;
202
203 /* We provide macros for accessing buffer states in case in the
204  * future we want to put the buffer states in a more general
205  * "scanner state".
206  */
207 #define YY_CURRENT_BUFFER yy_current_buffer
208
209
210 /* yy_hold_char holds the character lost when yytext is formed. */
211 static char yy_hold_char;
212
213 static int yy_n_chars;          /* number of characters read into yy_ch_buf */
214
215
216 int yyleng;
217
218 /* Points to current character in buffer. */
219 static char *yy_c_buf_p = (char *) 0;
220 static int yy_init = 1;         /* whether we need to initialize */
221 static int yy_start = 0;        /* start state number */
222
223 /* Flag which is used to allow yywrap()'s to do buffer switches
224  * instead of setting up a fresh yyin.  A bit of a hack ...
225  */
226 static int yy_did_buffer_switch_on_eof;
227
228 void yyrestart YY_PROTO(( FILE *input_file ));
229
230 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
231 void yy_load_buffer_state YY_PROTO(( void ));
232 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
233 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
234 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
235 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
236 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
237
238 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
239 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
240 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
241
242 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
243 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
244 static void yy_flex_free YY_PROTO(( void * ));
245
246 #define yy_new_buffer yy_create_buffer
247
248 #define yy_set_interactive(is_interactive) \
249         { \
250         if ( ! yy_current_buffer ) \
251                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
252         yy_current_buffer->yy_is_interactive = is_interactive; \
253         }
254
255 #define yy_set_bol(at_bol) \
256         { \
257         if ( ! yy_current_buffer ) \
258                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
259         yy_current_buffer->yy_at_bol = at_bol; \
260         }
261
262 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
263
264 typedef unsigned char YY_CHAR;
265 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
266 typedef int yy_state_type;
267 extern char *yytext;
268 #define yytext_ptr yytext
269
270 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
271 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
272 static int yy_get_next_buffer YY_PROTO(( void ));
273 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
274
275 /* Done after the current pattern has been matched and before the
276  * corresponding action - sets up yytext.
277  */
278 #define YY_DO_BEFORE_ACTION \
279         yytext_ptr = yy_bp; \
280         yyleng = (int) (yy_cp - yy_bp); \
281         yy_hold_char = *yy_cp; \
282         *yy_cp = '\0'; \
283         yy_c_buf_p = yy_cp;
284
285 #define YY_NUM_RULES 33
286 #define YY_END_OF_BUFFER 34
287 static yyconst short int yy_accept[120] =
288     {   0,
289         0,    0,   34,   32,    1,    1,   32,   22,    3,   32,
290        27,   32,   32,   32,   31,   31,   31,   31,   31,    9,
291        31,   32,   32,   32,   31,   31,   31,   31,   31,   31,
292        31,   31,    4,    1,   19,   23,    3,   29,   28,   27,
293         0,   20,   18,   21,   31,   31,   31,   31,   31,    5,
294        25,    2,   26,   31,   31,   31,   31,   31,   31,   31,
295        31,    4,    4,   24,    0,   28,    0,    0,   30,   31,
296        31,   31,   31,   31,   31,   31,   31,   31,   31,   31,
297        31,    0,   29,    0,    0,   28,   31,   31,   31,    8,
298        11,   31,   16,   31,   31,   13,   31,    0,   28,   31,
299
300        31,   31,   31,   12,   17,   14,   31,   10,   31,   31,
301         7,   31,   31,   31,   31,   31,   15,    6,    0
302     } ;
303
304 static yyconst int yy_ec[256] =
305     {   0,
306         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
307         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
308         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
309         1,    2,    4,    5,    6,    1,    1,    1,    1,    1,
310         1,    1,    7,    1,    7,    8,    1,    9,    9,    9,
311         9,    9,    9,    9,    9,    9,    9,    1,    1,   10,
312        11,   12,    1,    1,   13,   14,   15,   16,   17,   18,
313        19,   14,   20,   14,   14,   21,   14,   14,   14,   22,
314        14,   14,   14,   14,   14,   14,   14,   14,   14,   14,
315        23,   24,   25,    1,   14,    1,   26,   14,   27,   14,
316
317        28,   14,   29,   14,   30,   14,   31,   32,   33,   34,
318        35,   36,   37,   38,   39,   40,   41,   42,   14,   43,
319        44,   45,    1,    1,    1,    1,    1,    1,    1,    1,
320         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
321         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
322         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
323         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
324         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
325         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
326         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
327
328         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
329         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
330         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
331         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
332         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
333         1,    1,    1,    1,    1
334     } ;
335
336 static yyconst int yy_meta[46] =
337     {   0,
338         1,    1,    2,    1,    1,    1,    1,    1,    3,    1,
339         1,    1,    3,    3,    3,    3,    3,    3,    3,    3,
340         3,    3,    1,    1,    1,    3,    3,    3,    3,    3,
341         3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
342         3,    3,    3,    3,    3
343     } ;
344
345 static yyconst short int yy_base[123] =
346     {   0,
347         0,  164,  167,  169,   44,   46,  155,  160,    0,  155,
348        42,  152,  151,  150,    0,  134,  129,  117,  144,    0,
349       126,  132,  151,  128,  109,  117,  115,  111,  107,  120,
350       116,  101,  133,   50,  169,  138,    0,   45,   47,   63,
351        48,  169,  169,  169,    0,  102,  112,  108,  119,    0,
352       169,  169,  169,  108,   95,  101,  105,  104,   98,   99,
353        86,    0,    0,  169,   51,   69,   58,  121,  120,  102,
354        97,   98,  104,   84,   95,   91,   87,   80,   81,   90,
355        72,  107,  106,   74,  105,  104,   80,   71,   72,    0,
356         0,   75,    0,   68,   78,    0,   59,   91,   90,   72,
357
358        57,   75,   53,    0,    0,    0,   58,    0,   63,   53,
359         0,   54,   47,   49,   32,   43,    0,    0,  169,  101,
360        58,  104
361     } ;
362
363 static yyconst short int yy_def[123] =
364     {   0,
365       119,    1,  119,  119,  119,  119,  119,  119,  120,  119,
366       119,  119,  119,  119,  121,  121,  121,  121,  121,  121,
367       121,  119,  119,  119,  121,  121,  121,  121,  121,  121,
368       121,  121,  122,  119,  119,  119,  120,  119,  119,  119,
369       119,  119,  119,  119,  121,  121,  121,  121,  121,  121,
370       119,  119,  119,  121,  121,  121,  121,  121,  121,  121,
371       121,  122,  122,  119,  119,  119,  119,  119,  119,  121,
372       121,  121,  121,  121,  121,  121,  121,  121,  121,  121,
373       121,  119,  119,  119,  119,  119,  121,  121,  121,  121,
374       121,  121,  121,  121,  121,  121,  121,  119,  119,  121,
375
376       121,  121,  121,  121,  121,  121,  121,  121,  121,  121,
377       121,  121,  121,  121,  121,  121,  121,  121,    0,  119,
378       119,  119
379     } ;
380
381 static yyconst short int yy_nxt[215] =
382     {   0,
383         4,    5,    6,    7,    8,    9,    4,   10,   11,   12,
384        13,   14,   15,   15,   16,   17,   18,   19,   15,   20,
385        15,   21,   22,   23,   24,   15,   15,   25,   15,   26,
386        15,   27,   15,   15,   15,   28,   29,   15,   30,   31,
387        15,   15,   32,   15,   15,   34,   34,   34,   34,   39,
388        40,   34,   34,   38,   68,   66,   69,   82,   41,   83,
389        45,   65,   41,   67,   85,   65,   86,   67,  118,   41,
390        39,   40,   65,   41,   67,  117,   65,   66,   67,   41,
391        98,  116,   99,   41,  115,   84,  114,  113,  112,   84,
392        41,  111,  110,  109,   41,  108,   84,  107,   99,   99,
393
394        84,   37,  106,   37,   62,  105,   62,  104,  103,  102,
395       101,  100,   86,   86,   83,   83,   97,   96,   95,   91,
396        94,   93,   92,   91,   90,   89,   88,   87,   69,   69,
397        81,   80,   79,   78,   77,   76,   75,   74,   73,   72,
398        71,   70,   64,   63,   61,   60,   59,   58,   57,   56,
399        55,   54,   53,   52,   51,   50,   49,   48,   47,   46,
400        44,   43,   42,   38,   36,   35,  119,   33,    3,  119,
401       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
402       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
403       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
404
405       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
406       119,  119,  119,  119
407     } ;
408
409 static yyconst short int yy_chk[215] =
410     {   0,
411         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
412         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
413         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
414         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
415         1,    1,    1,    1,    1,    5,    5,    6,    6,   11,
416        11,   34,   34,   38,   41,   39,   41,   65,   11,   65,
417       121,   38,   11,   39,   67,   38,   67,   39,  116,   11,
418        40,   40,   38,   11,   39,  115,   38,   66,   39,   40,
419        84,  114,   84,   40,  113,   66,  112,  110,  109,   66,
420        40,  107,  103,  102,   40,  101,   66,  100,   99,   98,
421
422        66,  120,   97,  120,  122,   95,  122,   94,   92,   89,
423        88,   87,   86,   85,   83,   82,   81,   80,   79,   78,
424        77,   76,   75,   74,   73,   72,   71,   70,   69,   68,
425        61,   60,   59,   58,   57,   56,   55,   54,   49,   48,
426        47,   46,   36,   33,   32,   31,   30,   29,   28,   27,
427        26,   25,   24,   23,   22,   21,   19,   18,   17,   16,
428        14,   13,   12,   10,    8,    7,    3,    2,  119,  119,
429       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
430       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
431       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
432
433       119,  119,  119,  119,  119,  119,  119,  119,  119,  119,
434       119,  119,  119,  119
435     } ;
436
437 static yy_state_type yy_last_accepting_state;
438 static char *yy_last_accepting_cpos;
439
440 /* The intent behind this definition is that it'll catch
441  * any uses of REJECT which flex missed.
442  */
443 #define REJECT reject_used_but_not_detected
444 #define yymore() yymore_used_but_not_detected
445 #define YY_MORE_ADJ 0
446 #define YY_RESTORE_YY_MORE_OFFSET
447 char *yytext;
448 #line 1 "ginsh_lexer.ll"
449 #define INITIAL 0
450 /** @file ginsh_lexer.ll
451  *
452  *  Lexical analyzer definition for ginsh.
453  *  This file must be processed with flex.
454  *
455  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
456  *
457  *  This program is free software; you can redistribute it and/or modify
458  *  it under the terms of the GNU General Public License as published by
459  *  the Free Software Foundation; either version 2 of the License, or
460  *  (at your option) any later version.
461  *
462  *  This program is distributed in the hope that it will be useful,
463  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
464  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
465  *  GNU General Public License for more details.
466  *
467  *  You should have received a copy of the GNU General Public License
468  *  along with this program; if not, write to the Free Software
469  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
470  */
471 /*
472  *  Definitions
473  */
474 #line 29 "ginsh_lexer.ll"
475 #include "config.h"
476
477 #include <stdio.h>
478 extern "C" {
479 #include <readline/readline.h>
480 #include <readline/history.h>
481 }
482 #include <map>
483
484 #include <ginac/ginac.h>
485 #include "ginsh.h"
486
487 #include "ginsh_parser.h"
488
489 #define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size))
490
491 // Table of all used symbols
492 sym_tab syms;
493
494 // lex input function
495 static int ginsh_input(char *buf, int max_size);
496 /* Abbreviations */
497 /*
498  *  Lexical rules
499  */
500 #line 501 "lex.yy.c"
501
502 /* Macros after this point can all be overridden by user definitions in
503  * section 1.
504  */
505
506 #ifndef YY_SKIP_YYWRAP
507 #ifdef __cplusplus
508 extern "C" int yywrap YY_PROTO(( void ));
509 #else
510 extern int yywrap YY_PROTO(( void ));
511 #endif
512 #endif
513
514 #ifndef YY_NO_UNPUT
515 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
516 #endif
517
518 #ifndef yytext_ptr
519 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
520 #endif
521
522 #ifdef YY_NEED_STRLEN
523 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
524 #endif
525
526 #ifndef YY_NO_INPUT
527 #ifdef __cplusplus
528 static int yyinput YY_PROTO(( void ));
529 #else
530 static int input YY_PROTO(( void ));
531 #endif
532 #endif
533
534 #if YY_STACK_USED
535 static int yy_start_stack_ptr = 0;
536 static int yy_start_stack_depth = 0;
537 static int *yy_start_stack = 0;
538 #ifndef YY_NO_PUSH_STATE
539 static void yy_push_state YY_PROTO(( int new_state ));
540 #endif
541 #ifndef YY_NO_POP_STATE
542 static void yy_pop_state YY_PROTO(( void ));
543 #endif
544 #ifndef YY_NO_TOP_STATE
545 static int yy_top_state YY_PROTO(( void ));
546 #endif
547
548 #else
549 #define YY_NO_PUSH_STATE 1
550 #define YY_NO_POP_STATE 1
551 #define YY_NO_TOP_STATE 1
552 #endif
553
554 #ifdef YY_MALLOC_DECL
555 YY_MALLOC_DECL
556 #else
557 #if __STDC__
558 #ifndef __cplusplus
559 #include <stdlib.h>
560 #endif
561 #else
562 /* Just try to get by without declaring the routines.  This will fail
563  * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
564  * or sizeof(void*) != sizeof(int).
565  */
566 #endif
567 #endif
568
569 /* Amount of stuff to slurp up with each read. */
570 #ifndef YY_READ_BUF_SIZE
571 #define YY_READ_BUF_SIZE 8192
572 #endif
573
574 /* Copy whatever the last rule matched to the standard output. */
575
576 #ifndef ECHO
577 /* This used to be an fputs(), but since the string might contain NUL's,
578  * we now use fwrite().
579  */
580 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
581 #endif
582
583 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
584  * is returned in "result".
585  */
586 #ifndef YY_INPUT
587 #define YY_INPUT(buf,result,max_size) \
588         if ( yy_current_buffer->yy_is_interactive ) \
589                 { \
590                 int c = '*', n; \
591                 for ( n = 0; n < max_size && \
592                              (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
593                         buf[n] = (char) c; \
594                 if ( c == '\n' ) \
595                         buf[n++] = (char) c; \
596                 if ( c == EOF && ferror( yyin ) ) \
597                         YY_FATAL_ERROR( "input in flex scanner failed" ); \
598                 result = n; \
599                 } \
600         else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
601                   && ferror( yyin ) ) \
602                 YY_FATAL_ERROR( "input in flex scanner failed" );
603 #endif
604
605 /* No semi-colon after return; correct usage is to write "yyterminate();" -
606  * we don't want an extra ';' after the "return" because that will cause
607  * some compilers to complain about unreachable statements.
608  */
609 #ifndef yyterminate
610 #define yyterminate() return YY_NULL
611 #endif
612
613 /* Number of entries by which start-condition stack grows. */
614 #ifndef YY_START_STACK_INCR
615 #define YY_START_STACK_INCR 25
616 #endif
617
618 /* Report a fatal error. */
619 #ifndef YY_FATAL_ERROR
620 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
621 #endif
622
623 /* Default declaration of generated scanner - a define so the user can
624  * easily add parameters.
625  */
626 #ifndef YY_DECL
627 #define YY_DECL int yylex YY_PROTO(( void ))
628 #endif
629
630 /* Code executed at the beginning of each rule, after yytext and yyleng
631  * have been set up.
632  */
633 #ifndef YY_USER_ACTION
634 #define YY_USER_ACTION
635 #endif
636
637 /* Code executed at the end of each rule. */
638 #ifndef YY_BREAK
639 #define YY_BREAK break;
640 #endif
641
642 #define YY_RULE_SETUP \
643         if ( yyleng > 0 ) \
644                 yy_current_buffer->yy_at_bol = \
645                                 (yytext[yyleng - 1] == '\n'); \
646         YY_USER_ACTION
647
648 YY_DECL
649         {
650         register yy_state_type yy_current_state;
651         register char *yy_cp, *yy_bp;
652         register int yy_act;
653
654 #line 63 "ginsh_lexer.ll"
655
656 #line 657 "lex.yy.c"
657
658         if ( yy_init )
659                 {
660                 yy_init = 0;
661
662 #ifdef YY_USER_INIT
663                 YY_USER_INIT;
664 #endif
665
666                 if ( ! yy_start )
667                         yy_start = 1;   /* first start state */
668
669                 if ( ! yyin )
670                         yyin = stdin;
671
672                 if ( ! yyout )
673                         yyout = stdout;
674
675                 if ( ! yy_current_buffer )
676                         yy_current_buffer =
677                                 yy_create_buffer( yyin, YY_BUF_SIZE );
678
679                 yy_load_buffer_state();
680                 }
681
682         while ( 1 )             /* loops until end-of-file is reached */
683                 {
684                 yy_cp = yy_c_buf_p;
685
686                 /* Support of yytext. */
687                 *yy_cp = yy_hold_char;
688
689                 /* yy_bp points to the position in yy_ch_buf of the start of
690                  * the current run.
691                  */
692                 yy_bp = yy_cp;
693
694                 yy_current_state = yy_start;
695                 yy_current_state += YY_AT_BOL();
696 yy_match:
697                 do
698                         {
699                         register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
700                         if ( yy_accept[yy_current_state] )
701                                 {
702                                 yy_last_accepting_state = yy_current_state;
703                                 yy_last_accepting_cpos = yy_cp;
704                                 }
705                         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
706                                 {
707                                 yy_current_state = (int) yy_def[yy_current_state];
708                                 if ( yy_current_state >= 120 )
709                                         yy_c = yy_meta[(unsigned int) yy_c];
710                                 }
711                         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
712                         ++yy_cp;
713                         }
714                 while ( yy_base[yy_current_state] != 169 );
715
716 yy_find_action:
717                 yy_act = yy_accept[yy_current_state];
718                 if ( yy_act == 0 )
719                         { /* have to back up */
720                         yy_cp = yy_last_accepting_cpos;
721                         yy_current_state = yy_last_accepting_state;
722                         yy_act = yy_accept[yy_current_state];
723                         }
724
725                 YY_DO_BEFORE_ACTION;
726
727
728 do_action:      /* This label is used only to access EOF actions. */
729
730
731                 switch ( yy_act )
732         { /* beginning of action switch */
733                         case 0: /* must back up */
734                         /* undo the effects of YY_DO_BEFORE_ACTION */
735                         *yy_cp = yy_hold_char;
736                         yy_cp = yy_last_accepting_cpos;
737                         yy_current_state = yy_last_accepting_state;
738                         goto yy_find_action;
739
740 case 1:
741 YY_RULE_SETUP
742 #line 64 "ginsh_lexer.ll"
743 /* skip whitespace */
744         YY_BREAK
745 case 2:
746 *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
747 yy_c_buf_p = yy_cp -= 1;
748 YY_DO_BEFORE_ACTION; /* set up yytext again */
749 YY_RULE_SETUP
750 #line 65 "ginsh_lexer.ll"
751 /* skip line continuations */
752         YY_BREAK
753 case 3:
754 YY_RULE_SETUP
755 #line 66 "ginsh_lexer.ll"
756 /* skip comments starting with "#" */
757         YY_BREAK
758 case 4:
759 YY_RULE_SETUP
760 #line 67 "ginsh_lexer.ll"
761 system(yytext + 1);     /* execute shell command */
762         YY_BREAK
763 /* special values */
764 case 5:
765 YY_RULE_SETUP
766 #line 70 "ginsh_lexer.ll"
767 yylval = Pi; return T_LITERAL;
768         YY_BREAK
769 case 6:
770 YY_RULE_SETUP
771 #line 71 "ginsh_lexer.ll"
772 yylval = EulerGamma; return T_LITERAL;
773         YY_BREAK
774 case 7:
775 YY_RULE_SETUP
776 #line 72 "ginsh_lexer.ll"
777 yylval = Catalan; return T_LITERAL;
778         YY_BREAK
779 case 8:
780 YY_RULE_SETUP
781 #line 73 "ginsh_lexer.ll"
782 yylval = *new fail(); return T_LITERAL;
783         YY_BREAK
784 case 9:
785 YY_RULE_SETUP
786 #line 74 "ginsh_lexer.ll"
787 yylval = I; return T_NUMBER;
788         YY_BREAK
789 case 10:
790 YY_RULE_SETUP
791 #line 75 "ginsh_lexer.ll"
792 yylval = (long)Digits; return T_DIGITS;
793         YY_BREAK
794 /* keywords */
795 case 11:
796 YY_RULE_SETUP
797 #line 78 "ginsh_lexer.ll"
798 return T_QUIT;
799         YY_BREAK
800 case 12:
801 YY_RULE_SETUP
802 #line 79 "ginsh_lexer.ll"
803 return T_PRINT;
804         YY_BREAK
805 case 13:
806 YY_RULE_SETUP
807 #line 80 "ginsh_lexer.ll"
808 return T_TIME;
809         YY_BREAK
810 case 14:
811 YY_RULE_SETUP
812 #line 81 "ginsh_lexer.ll"
813 return T_XYZZY;
814         YY_BREAK
815 case 15:
816 YY_RULE_SETUP
817 #line 82 "ginsh_lexer.ll"
818 return T_INVENTORY;
819         YY_BREAK
820 case 16:
821 YY_RULE_SETUP
822 #line 83 "ginsh_lexer.ll"
823 return T_LOOK;
824         YY_BREAK
825 case 17:
826 YY_RULE_SETUP
827 #line 84 "ginsh_lexer.ll"
828 return T_SCORE;
829         YY_BREAK
830 /* comparison */
831 case 18:
832 YY_RULE_SETUP
833 #line 87 "ginsh_lexer.ll"
834 return T_EQUAL;
835         YY_BREAK
836 case 19:
837 YY_RULE_SETUP
838 #line 88 "ginsh_lexer.ll"
839 return T_NOTEQ;
840         YY_BREAK
841 case 20:
842 YY_RULE_SETUP
843 #line 89 "ginsh_lexer.ll"
844 return T_LESSEQ;
845         YY_BREAK
846 case 21:
847 YY_RULE_SETUP
848 #line 90 "ginsh_lexer.ll"
849 return T_GREATEREQ;
850         YY_BREAK
851 /* last 1..3 expressions */
852 case 22:
853 YY_RULE_SETUP
854 #line 93 "ginsh_lexer.ll"
855 return T_QUOTE;
856         YY_BREAK
857 case 23:
858 YY_RULE_SETUP
859 #line 94 "ginsh_lexer.ll"
860 return T_QUOTE2;
861         YY_BREAK
862 case 24:
863 YY_RULE_SETUP
864 #line 95 "ginsh_lexer.ll"
865 return T_QUOTE3;
866         YY_BREAK
867 /* matrix delimiters */
868 case 25:
869 YY_RULE_SETUP
870 #line 98 "ginsh_lexer.ll"
871 return T_MATRIX_BEGIN;
872         YY_BREAK
873 case 26:
874 YY_RULE_SETUP
875 #line 99 "ginsh_lexer.ll"
876 return T_MATRIX_END;
877         YY_BREAK
878 /* numbers */
879 case 27:
880 #line 103 "ginsh_lexer.ll"
881 case 28:
882 #line 104 "ginsh_lexer.ll"
883 case 29:
884 #line 105 "ginsh_lexer.ll"
885 case 30:
886 YY_RULE_SETUP
887 #line 105 "ginsh_lexer.ll"
888 yylval = numeric(yytext); return T_NUMBER;
889         YY_BREAK
890 /* symbols */
891 case 31:
892 YY_RULE_SETUP
893 #line 108 "ginsh_lexer.ll"
894 {
895                                 if (syms.find(yytext) == syms.end())
896                                         syms[yytext] = *(new symbol(yytext));
897                                 yylval = syms[yytext];
898                                 return T_SYMBOL;
899                         }
900         YY_BREAK
901 /* everything else */
902 case 32:
903 YY_RULE_SETUP
904 #line 116 "ginsh_lexer.ll"
905 return *yytext;
906         YY_BREAK
907 case 33:
908 YY_RULE_SETUP
909 #line 118 "ginsh_lexer.ll"
910 ECHO;
911         YY_BREAK
912 #line 913 "lex.yy.c"
913 case YY_STATE_EOF(INITIAL):
914         yyterminate();
915
916         case YY_END_OF_BUFFER:
917                 {
918                 /* Amount of text matched not including the EOB char. */
919                 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
920
921                 /* Undo the effects of YY_DO_BEFORE_ACTION. */
922                 *yy_cp = yy_hold_char;
923                 YY_RESTORE_YY_MORE_OFFSET
924
925                 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
926                         {
927                         /* We're scanning a new file or input source.  It's
928                          * possible that this happened because the user
929                          * just pointed yyin at a new source and called
930                          * yylex().  If so, then we have to assure
931                          * consistency between yy_current_buffer and our
932                          * globals.  Here is the right place to do so, because
933                          * this is the first action (other than possibly a
934                          * back-up) that will match for the new input source.
935                          */
936                         yy_n_chars = yy_current_buffer->yy_n_chars;
937                         yy_current_buffer->yy_input_file = yyin;
938                         yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
939                         }
940
941                 /* Note that here we test for yy_c_buf_p "<=" to the position
942                  * of the first EOB in the buffer, since yy_c_buf_p will
943                  * already have been incremented past the NUL character
944                  * (since all states make transitions on EOB to the
945                  * end-of-buffer state).  Contrast this with the test
946                  * in input().
947                  */
948                 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
949                         { /* This was really a NUL. */
950                         yy_state_type yy_next_state;
951
952                         yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
953
954                         yy_current_state = yy_get_previous_state();
955
956                         /* Okay, we're now positioned to make the NUL
957                          * transition.  We couldn't have
958                          * yy_get_previous_state() go ahead and do it
959                          * for us because it doesn't know how to deal
960                          * with the possibility of jamming (and we don't
961                          * want to build jamming into it because then it
962                          * will run more slowly).
963                          */
964
965                         yy_next_state = yy_try_NUL_trans( yy_current_state );
966
967                         yy_bp = yytext_ptr + YY_MORE_ADJ;
968
969                         if ( yy_next_state )
970                                 {
971                                 /* Consume the NUL. */
972                                 yy_cp = ++yy_c_buf_p;
973                                 yy_current_state = yy_next_state;
974                                 goto yy_match;
975                                 }
976
977                         else
978                                 {
979                                 yy_cp = yy_c_buf_p;
980                                 goto yy_find_action;
981                                 }
982                         }
983
984                 else switch ( yy_get_next_buffer() )
985                         {
986                         case EOB_ACT_END_OF_FILE:
987                                 {
988                                 yy_did_buffer_switch_on_eof = 0;
989
990                                 if ( yywrap() )
991                                         {
992                                         /* Note: because we've taken care in
993                                          * yy_get_next_buffer() to have set up
994                                          * yytext, we can now set up
995                                          * yy_c_buf_p so that if some total
996                                          * hoser (like flex itself) wants to
997                                          * call the scanner after we return the
998                                          * YY_NULL, it'll still work - another
999                                          * YY_NULL will get returned.
1000                                          */
1001                                         yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1002
1003                                         yy_act = YY_STATE_EOF(YY_START);
1004                                         goto do_action;
1005                                         }
1006
1007                                 else
1008                                         {
1009                                         if ( ! yy_did_buffer_switch_on_eof )
1010                                                 YY_NEW_FILE;
1011                                         }
1012                                 break;
1013                                 }
1014
1015                         case EOB_ACT_CONTINUE_SCAN:
1016                                 yy_c_buf_p =
1017                                         yytext_ptr + yy_amount_of_matched_text;
1018
1019                                 yy_current_state = yy_get_previous_state();
1020
1021                                 yy_cp = yy_c_buf_p;
1022                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
1023                                 goto yy_match;
1024
1025                         case EOB_ACT_LAST_MATCH:
1026                                 yy_c_buf_p =
1027                                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
1028
1029                                 yy_current_state = yy_get_previous_state();
1030
1031                                 yy_cp = yy_c_buf_p;
1032                                 yy_bp = yytext_ptr + YY_MORE_ADJ;
1033                                 goto yy_find_action;
1034                         }
1035                 break;
1036                 }
1037
1038         default:
1039                 YY_FATAL_ERROR(
1040                         "fatal flex scanner internal error--no action found" );
1041         } /* end of action switch */
1042                 } /* end of scanning one token */
1043         } /* end of yylex */
1044
1045
1046 /* yy_get_next_buffer - try to read in a new buffer
1047  *
1048  * Returns a code representing an action:
1049  *      EOB_ACT_LAST_MATCH -
1050  *      EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1051  *      EOB_ACT_END_OF_FILE - end of file
1052  */
1053
1054 static int yy_get_next_buffer()
1055         {
1056         register char *dest = yy_current_buffer->yy_ch_buf;
1057         register char *source = yytext_ptr;
1058         register int number_to_move, i;
1059         int ret_val;
1060
1061         if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
1062                 YY_FATAL_ERROR(
1063                 "fatal flex scanner internal error--end of buffer missed" );
1064
1065         if ( yy_current_buffer->yy_fill_buffer == 0 )
1066                 { /* Don't try to fill the buffer, so this is an EOF. */
1067                 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
1068                         {
1069                         /* We matched a single character, the EOB, so
1070                          * treat this as a final EOF.
1071                          */
1072                         return EOB_ACT_END_OF_FILE;
1073                         }
1074
1075                 else
1076                         {
1077                         /* We matched some text prior to the EOB, first
1078                          * process it.
1079                          */
1080                         return EOB_ACT_LAST_MATCH;
1081                         }
1082                 }
1083
1084         /* Try to read more data. */
1085
1086         /* First move last chars to start of buffer. */
1087         number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1088
1089         for ( i = 0; i < number_to_move; ++i )
1090                 *(dest++) = *(source++);
1091
1092         if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1093                 /* don't do the read, it's not guaranteed to return an EOF,
1094                  * just force an EOF
1095                  */
1096                 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1097
1098         else
1099                 {
1100                 int num_to_read =
1101                         yy_current_buffer->yy_buf_size - number_to_move - 1;
1102
1103                 while ( num_to_read <= 0 )
1104                         { /* Not enough room in the buffer - grow it. */
1105 #ifdef YY_USES_REJECT
1106                         YY_FATAL_ERROR(
1107 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1108 #else
1109
1110                         /* just a shorter name for the current buffer */
1111                         YY_BUFFER_STATE b = yy_current_buffer;
1112
1113                         int yy_c_buf_p_offset =
1114                                 (int) (yy_c_buf_p - b->yy_ch_buf);
1115
1116                         if ( b->yy_is_our_buffer )
1117                                 {
1118                                 int new_size = b->yy_buf_size * 2;
1119
1120                                 if ( new_size <= 0 )
1121                                         b->yy_buf_size += b->yy_buf_size / 8;
1122                                 else
1123                                         b->yy_buf_size *= 2;
1124
1125                                 b->yy_ch_buf = (char *)
1126                                         /* Include room in for 2 EOB chars. */
1127                                         yy_flex_realloc( (void *) b->yy_ch_buf,
1128                                                          b->yy_buf_size + 2 );
1129                                 }
1130                         else
1131                                 /* Can't grow it, we don't own it. */
1132                                 b->yy_ch_buf = 0;
1133
1134                         if ( ! b->yy_ch_buf )
1135                                 YY_FATAL_ERROR(
1136                                 "fatal error - scanner input buffer overflow" );
1137
1138                         yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1139
1140                         num_to_read = yy_current_buffer->yy_buf_size -
1141                                                 number_to_move - 1;
1142 #endif
1143                         }
1144
1145                 if ( num_to_read > YY_READ_BUF_SIZE )
1146                         num_to_read = YY_READ_BUF_SIZE;
1147
1148                 /* Read in more data. */
1149                 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1150                         yy_n_chars, num_to_read );
1151
1152                 yy_current_buffer->yy_n_chars = yy_n_chars;
1153                 }
1154
1155         if ( yy_n_chars == 0 )
1156                 {
1157                 if ( number_to_move == YY_MORE_ADJ )
1158                         {
1159                         ret_val = EOB_ACT_END_OF_FILE;
1160                         yyrestart( yyin );
1161                         }
1162
1163                 else
1164                         {
1165                         ret_val = EOB_ACT_LAST_MATCH;
1166                         yy_current_buffer->yy_buffer_status =
1167                                 YY_BUFFER_EOF_PENDING;
1168                         }
1169                 }
1170
1171         else
1172                 ret_val = EOB_ACT_CONTINUE_SCAN;
1173
1174         yy_n_chars += number_to_move;
1175         yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1176         yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1177
1178         yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1179
1180         return ret_val;
1181         }
1182
1183
1184 /* yy_get_previous_state - get the state just before the EOB char was reached */
1185
1186 static yy_state_type yy_get_previous_state()
1187         {
1188         register yy_state_type yy_current_state;
1189         register char *yy_cp;
1190
1191         yy_current_state = yy_start;
1192         yy_current_state += YY_AT_BOL();
1193
1194         for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1195                 {
1196                 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1197                 if ( yy_accept[yy_current_state] )
1198                         {
1199                         yy_last_accepting_state = yy_current_state;
1200                         yy_last_accepting_cpos = yy_cp;
1201                         }
1202                 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1203                         {
1204                         yy_current_state = (int) yy_def[yy_current_state];
1205                         if ( yy_current_state >= 120 )
1206                                 yy_c = yy_meta[(unsigned int) yy_c];
1207                         }
1208                 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1209                 }
1210
1211         return yy_current_state;
1212         }
1213
1214
1215 /* yy_try_NUL_trans - try to make a transition on the NUL character
1216  *
1217  * synopsis
1218  *      next_state = yy_try_NUL_trans( current_state );
1219  */
1220
1221 #ifdef YY_USE_PROTOS
1222 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1223 #else
1224 static yy_state_type yy_try_NUL_trans( yy_current_state )
1225 yy_state_type yy_current_state;
1226 #endif
1227         {
1228         register int yy_is_jam;
1229         register char *yy_cp = yy_c_buf_p;
1230
1231         register YY_CHAR yy_c = 1;
1232         if ( yy_accept[yy_current_state] )
1233                 {
1234                 yy_last_accepting_state = yy_current_state;
1235                 yy_last_accepting_cpos = yy_cp;
1236                 }
1237         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1238                 {
1239                 yy_current_state = (int) yy_def[yy_current_state];
1240                 if ( yy_current_state >= 120 )
1241                         yy_c = yy_meta[(unsigned int) yy_c];
1242                 }
1243         yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1244         yy_is_jam = (yy_current_state == 119);
1245
1246         return yy_is_jam ? 0 : yy_current_state;
1247         }
1248
1249
1250 #ifndef YY_NO_UNPUT
1251 #ifdef YY_USE_PROTOS
1252 static void yyunput( int c, register char *yy_bp )
1253 #else
1254 static void yyunput( c, yy_bp )
1255 int c;
1256 register char *yy_bp;
1257 #endif
1258         {
1259         register char *yy_cp = yy_c_buf_p;
1260
1261         /* undo effects of setting up yytext */
1262         *yy_cp = yy_hold_char;
1263
1264         if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1265                 { /* need to shift things up to make room */
1266                 /* +2 for EOB chars. */
1267                 register int number_to_move = yy_n_chars + 2;
1268                 register char *dest = &yy_current_buffer->yy_ch_buf[
1269                                         yy_current_buffer->yy_buf_size + 2];
1270                 register char *source =
1271                                 &yy_current_buffer->yy_ch_buf[number_to_move];
1272
1273                 while ( source > yy_current_buffer->yy_ch_buf )
1274                         *--dest = *--source;
1275
1276                 yy_cp += (int) (dest - source);
1277                 yy_bp += (int) (dest - source);
1278                 yy_current_buffer->yy_n_chars =
1279                         yy_n_chars = yy_current_buffer->yy_buf_size;
1280
1281                 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1282                         YY_FATAL_ERROR( "flex scanner push-back overflow" );
1283                 }
1284
1285         *--yy_cp = (char) c;
1286
1287
1288         yytext_ptr = yy_bp;
1289         yy_hold_char = *yy_cp;
1290         yy_c_buf_p = yy_cp;
1291         }
1292 #endif  /* ifndef YY_NO_UNPUT */
1293
1294
1295 #ifdef __cplusplus
1296 static int yyinput()
1297 #else
1298 static int input()
1299 #endif
1300         {
1301         int c;
1302
1303         *yy_c_buf_p = yy_hold_char;
1304
1305         if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1306                 {
1307                 /* yy_c_buf_p now points to the character we want to return.
1308                  * If this occurs *before* the EOB characters, then it's a
1309                  * valid NUL; if not, then we've hit the end of the buffer.
1310                  */
1311                 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1312                         /* This was really a NUL. */
1313                         *yy_c_buf_p = '\0';
1314
1315                 else
1316                         { /* need more input */
1317                         int offset = yy_c_buf_p - yytext_ptr;
1318                         ++yy_c_buf_p;
1319
1320                         switch ( yy_get_next_buffer() )
1321                                 {
1322                                 case EOB_ACT_LAST_MATCH:
1323                                         /* This happens because yy_g_n_b()
1324                                          * sees that we've accumulated a
1325                                          * token and flags that we need to
1326                                          * try matching the token before
1327                                          * proceeding.  But for input(),
1328                                          * there's no matching to consider.
1329                                          * So convert the EOB_ACT_LAST_MATCH
1330                                          * to EOB_ACT_END_OF_FILE.
1331                                          */
1332
1333                                         /* Reset buffer status. */
1334                                         yyrestart( yyin );
1335
1336                                         /* fall through */
1337
1338                                 case EOB_ACT_END_OF_FILE:
1339                                         {
1340                                         if ( yywrap() )
1341                                                 return EOF;
1342
1343                                         if ( ! yy_did_buffer_switch_on_eof )
1344                                                 YY_NEW_FILE;
1345 #ifdef __cplusplus
1346                                         return yyinput();
1347 #else
1348                                         return input();
1349 #endif
1350                                         }
1351
1352                                 case EOB_ACT_CONTINUE_SCAN:
1353                                         yy_c_buf_p = yytext_ptr + offset;
1354                                         break;
1355                                 }
1356                         }
1357                 }
1358
1359         c = *(unsigned char *) yy_c_buf_p;      /* cast for 8-bit char's */
1360         *yy_c_buf_p = '\0';     /* preserve yytext */
1361         yy_hold_char = *++yy_c_buf_p;
1362
1363         yy_current_buffer->yy_at_bol = (c == '\n');
1364
1365         return c;
1366         }
1367
1368
1369 #ifdef YY_USE_PROTOS
1370 void yyrestart( FILE *input_file )
1371 #else
1372 void yyrestart( input_file )
1373 FILE *input_file;
1374 #endif
1375         {
1376         if ( ! yy_current_buffer )
1377                 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1378
1379         yy_init_buffer( yy_current_buffer, input_file );
1380         yy_load_buffer_state();
1381         }
1382
1383
1384 #ifdef YY_USE_PROTOS
1385 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1386 #else
1387 void yy_switch_to_buffer( new_buffer )
1388 YY_BUFFER_STATE new_buffer;
1389 #endif
1390         {
1391         if ( yy_current_buffer == new_buffer )
1392                 return;
1393
1394         if ( yy_current_buffer )
1395                 {
1396                 /* Flush out information for old buffer. */
1397                 *yy_c_buf_p = yy_hold_char;
1398                 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1399                 yy_current_buffer->yy_n_chars = yy_n_chars;
1400                 }
1401
1402         yy_current_buffer = new_buffer;
1403         yy_load_buffer_state();
1404
1405         /* We don't actually know whether we did this switch during
1406          * EOF (yywrap()) processing, but the only time this flag
1407          * is looked at is after yywrap() is called, so it's safe
1408          * to go ahead and always set it.
1409          */
1410         yy_did_buffer_switch_on_eof = 1;
1411         }
1412
1413
1414 #ifdef YY_USE_PROTOS
1415 void yy_load_buffer_state( void )
1416 #else
1417 void yy_load_buffer_state()
1418 #endif
1419         {
1420         yy_n_chars = yy_current_buffer->yy_n_chars;
1421         yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1422         yyin = yy_current_buffer->yy_input_file;
1423         yy_hold_char = *yy_c_buf_p;
1424         }
1425
1426
1427 #ifdef YY_USE_PROTOS
1428 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1429 #else
1430 YY_BUFFER_STATE yy_create_buffer( file, size )
1431 FILE *file;
1432 int size;
1433 #endif
1434         {
1435         YY_BUFFER_STATE b;
1436
1437         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1438         if ( ! b )
1439                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1440
1441         b->yy_buf_size = size;
1442
1443         /* yy_ch_buf has to be 2 characters longer than the size given because
1444          * we need to put in 2 end-of-buffer characters.
1445          */
1446         b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1447         if ( ! b->yy_ch_buf )
1448                 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1449
1450         b->yy_is_our_buffer = 1;
1451
1452         yy_init_buffer( b, file );
1453
1454         return b;
1455         }
1456
1457
1458 #ifdef YY_USE_PROTOS
1459 void yy_delete_buffer( YY_BUFFER_STATE b )
1460 #else
1461 void yy_delete_buffer( b )
1462 YY_BUFFER_STATE b;
1463 #endif
1464         {
1465         if ( ! b )
1466                 return;
1467
1468         if ( b == yy_current_buffer )
1469                 yy_current_buffer = (YY_BUFFER_STATE) 0;
1470
1471         if ( b->yy_is_our_buffer )
1472                 yy_flex_free( (void *) b->yy_ch_buf );
1473
1474         yy_flex_free( (void *) b );
1475         }
1476
1477
1478 #ifndef YY_ALWAYS_INTERACTIVE
1479 #ifndef YY_NEVER_INTERACTIVE
1480 extern int isatty YY_PROTO(( int ));
1481 #endif
1482 #endif
1483
1484 #ifdef YY_USE_PROTOS
1485 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1486 #else
1487 void yy_init_buffer( b, file )
1488 YY_BUFFER_STATE b;
1489 FILE *file;
1490 #endif
1491
1492
1493         {
1494         yy_flush_buffer( b );
1495
1496         b->yy_input_file = file;
1497         b->yy_fill_buffer = 1;
1498
1499 #if YY_ALWAYS_INTERACTIVE
1500         b->yy_is_interactive = 1;
1501 #else
1502 #if YY_NEVER_INTERACTIVE
1503         b->yy_is_interactive = 0;
1504 #else
1505         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1506 #endif
1507 #endif
1508         }
1509
1510
1511 #ifdef YY_USE_PROTOS
1512 void yy_flush_buffer( YY_BUFFER_STATE b )
1513 #else
1514 void yy_flush_buffer( b )
1515 YY_BUFFER_STATE b;
1516 #endif
1517
1518         {
1519         if ( ! b )
1520                 return;
1521
1522         b->yy_n_chars = 0;
1523
1524         /* We always need two end-of-buffer characters.  The first causes
1525          * a transition to the end-of-buffer state.  The second causes
1526          * a jam in that state.
1527          */
1528         b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1529         b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1530
1531         b->yy_buf_pos = &b->yy_ch_buf[0];
1532
1533         b->yy_at_bol = 1;
1534         b->yy_buffer_status = YY_BUFFER_NEW;
1535
1536         if ( b == yy_current_buffer )
1537                 yy_load_buffer_state();
1538         }
1539
1540
1541 #ifndef YY_NO_SCAN_BUFFER
1542 #ifdef YY_USE_PROTOS
1543 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1544 #else
1545 YY_BUFFER_STATE yy_scan_buffer( base, size )
1546 char *base;
1547 yy_size_t size;
1548 #endif
1549         {
1550         YY_BUFFER_STATE b;
1551
1552         if ( size < 2 ||
1553              base[size-2] != YY_END_OF_BUFFER_CHAR ||
1554              base[size-1] != YY_END_OF_BUFFER_CHAR )
1555                 /* They forgot to leave room for the EOB's. */
1556                 return 0;
1557
1558         b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1559         if ( ! b )
1560                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1561
1562         b->yy_buf_size = size - 2;      /* "- 2" to take care of EOB's */
1563         b->yy_buf_pos = b->yy_ch_buf = base;
1564         b->yy_is_our_buffer = 0;
1565         b->yy_input_file = 0;
1566         b->yy_n_chars = b->yy_buf_size;
1567         b->yy_is_interactive = 0;
1568         b->yy_at_bol = 1;
1569         b->yy_fill_buffer = 0;
1570         b->yy_buffer_status = YY_BUFFER_NEW;
1571
1572         yy_switch_to_buffer( b );
1573
1574         return b;
1575         }
1576 #endif
1577
1578
1579 #ifndef YY_NO_SCAN_STRING
1580 #ifdef YY_USE_PROTOS
1581 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1582 #else
1583 YY_BUFFER_STATE yy_scan_string( yy_str )
1584 yyconst char *yy_str;
1585 #endif
1586         {
1587         int len;
1588         for ( len = 0; yy_str[len]; ++len )
1589                 ;
1590
1591         return yy_scan_bytes( yy_str, len );
1592         }
1593 #endif
1594
1595
1596 #ifndef YY_NO_SCAN_BYTES
1597 #ifdef YY_USE_PROTOS
1598 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1599 #else
1600 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1601 yyconst char *bytes;
1602 int len;
1603 #endif
1604         {
1605         YY_BUFFER_STATE b;
1606         char *buf;
1607         yy_size_t n;
1608         int i;
1609
1610         /* Get memory for full buffer, including space for trailing EOB's. */
1611         n = len + 2;
1612         buf = (char *) yy_flex_alloc( n );
1613         if ( ! buf )
1614                 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1615
1616         for ( i = 0; i < len; ++i )
1617                 buf[i] = bytes[i];
1618
1619         buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1620
1621         b = yy_scan_buffer( buf, n );
1622         if ( ! b )
1623                 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1624
1625         /* It's okay to grow etc. this buffer, and we should throw it
1626          * away when we're done.
1627          */
1628         b->yy_is_our_buffer = 1;
1629
1630         return b;
1631         }
1632 #endif
1633
1634
1635 #ifndef YY_NO_PUSH_STATE
1636 #ifdef YY_USE_PROTOS
1637 static void yy_push_state( int new_state )
1638 #else
1639 static void yy_push_state( new_state )
1640 int new_state;
1641 #endif
1642         {
1643         if ( yy_start_stack_ptr >= yy_start_stack_depth )
1644                 {
1645                 yy_size_t new_size;
1646
1647                 yy_start_stack_depth += YY_START_STACK_INCR;
1648                 new_size = yy_start_stack_depth * sizeof( int );
1649
1650                 if ( ! yy_start_stack )
1651                         yy_start_stack = (int *) yy_flex_alloc( new_size );
1652
1653                 else
1654                         yy_start_stack = (int *) yy_flex_realloc(
1655                                         (void *) yy_start_stack, new_size );
1656
1657                 if ( ! yy_start_stack )
1658                         YY_FATAL_ERROR(
1659                         "out of memory expanding start-condition stack" );
1660                 }
1661
1662         yy_start_stack[yy_start_stack_ptr++] = YY_START;
1663
1664         BEGIN(new_state);
1665         }
1666 #endif
1667
1668
1669 #ifndef YY_NO_POP_STATE
1670 static void yy_pop_state()
1671         {
1672         if ( --yy_start_stack_ptr < 0 )
1673                 YY_FATAL_ERROR( "start-condition stack underflow" );
1674
1675         BEGIN(yy_start_stack[yy_start_stack_ptr]);
1676         }
1677 #endif
1678
1679
1680 #ifndef YY_NO_TOP_STATE
1681 static int yy_top_state()
1682         {
1683         return yy_start_stack[yy_start_stack_ptr - 1];
1684         }
1685 #endif
1686
1687 #ifndef YY_EXIT_FAILURE
1688 #define YY_EXIT_FAILURE 2
1689 #endif
1690
1691 #ifdef YY_USE_PROTOS
1692 static void yy_fatal_error( yyconst char msg[] )
1693 #else
1694 static void yy_fatal_error( msg )
1695 char msg[];
1696 #endif
1697         {
1698         (void) fprintf( stderr, "%s\n", msg );
1699         exit( YY_EXIT_FAILURE );
1700         }
1701
1702
1703
1704 /* Redefine yyless() so it works in section 3 code. */
1705
1706 #undef yyless
1707 #define yyless(n) \
1708         do \
1709                 { \
1710                 /* Undo effects of setting up yytext. */ \
1711                 yytext[yyleng] = yy_hold_char; \
1712                 yy_c_buf_p = yytext + n; \
1713                 yy_hold_char = *yy_c_buf_p; \
1714                 *yy_c_buf_p = '\0'; \
1715                 yyleng = n; \
1716                 } \
1717         while ( 0 )
1718
1719
1720 /* Internal utility routines. */
1721
1722 #ifndef yytext_ptr
1723 #ifdef YY_USE_PROTOS
1724 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1725 #else
1726 static void yy_flex_strncpy( s1, s2, n )
1727 char *s1;
1728 yyconst char *s2;
1729 int n;
1730 #endif
1731         {
1732         register int i;
1733         for ( i = 0; i < n; ++i )
1734                 s1[i] = s2[i];
1735         }
1736 #endif
1737
1738 #ifdef YY_NEED_STRLEN
1739 #ifdef YY_USE_PROTOS
1740 static int yy_flex_strlen( yyconst char *s )
1741 #else
1742 static int yy_flex_strlen( s )
1743 yyconst char *s;
1744 #endif
1745         {
1746         register int n;
1747         for ( n = 0; s[n]; ++n )
1748                 ;
1749
1750         return n;
1751         }
1752 #endif
1753
1754
1755 #ifdef YY_USE_PROTOS
1756 static void *yy_flex_alloc( yy_size_t size )
1757 #else
1758 static void *yy_flex_alloc( size )
1759 yy_size_t size;
1760 #endif
1761         {
1762         return (void *) malloc( size );
1763         }
1764
1765 #ifdef YY_USE_PROTOS
1766 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1767 #else
1768 static void *yy_flex_realloc( ptr, size )
1769 void *ptr;
1770 yy_size_t size;
1771 #endif
1772         {
1773         /* The cast to (char *) in the following accommodates both
1774          * implementations that use char* generic pointers, and those
1775          * that use void* generic pointers.  It works with the latter
1776          * because both ANSI C and C++ allow castless assignment from
1777          * any pointer type to void*, and deal with argument conversions
1778          * as though doing an assignment.
1779          */
1780         return (void *) realloc( (char *) ptr, size );
1781         }
1782
1783 #ifdef YY_USE_PROTOS
1784 static void yy_flex_free( void *ptr )
1785 #else
1786 static void yy_flex_free( ptr )
1787 void *ptr;
1788 #endif
1789         {
1790         free( ptr );
1791         }
1792
1793 #if YY_MAIN
1794 int main()
1795         {
1796         yylex();
1797         return 0;
1798         }
1799 #endif
1800 #line 118 "ginsh_lexer.ll"
1801
1802
1803
1804 /*
1805  *  Routines
1806  */
1807
1808 static int line_length = 0;
1809 static char *line_read = NULL;
1810 static char *line_ptr;
1811
1812 // Input function that uses libreadline for interactive input
1813 static int ginsh_input(char *buf, int max_size)
1814 {
1815         int result;
1816         if (yy_current_buffer->yy_is_interactive) {
1817                 int actual;
1818
1819                 // Do we need to read a new line?
1820                 if (line_length == 0) {
1821
1822                         // Free old line
1823                         if (line_read)
1824                                 free(line_read);
1825
1826                         // Read new line, prompt "> "
1827                         line_read = line_ptr = readline("> ");
1828
1829                         // EOF?
1830                         if (!line_read) {
1831                                 line_length = 0;
1832                                 return YY_NULL;
1833                         }
1834
1835                         // Add non-empty lines to history
1836                         line_length = strlen(line_read) + 1;
1837                         if (line_length > 1)
1838                                 add_history(line_read);
1839
1840                         // Reappend trailing '\n' which is stripped by readline()
1841                         line_read[line_length - 1] = '\n';
1842                 }
1843
1844                 // Copy data to lex buffer
1845                 actual = line_length > max_size ? max_size : line_length;
1846                 memcpy(buf, line_ptr, actual);
1847                 line_length -= actual;
1848                 line_ptr += actual;
1849                 result = actual;
1850
1851         } else if (((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin))
1852                 YY_FATAL_ERROR("input in flex scanner failed");
1853
1854         return result;
1855 }
1856
1857 // Scanner terminates on EOF
1858 int yywrap()
1859 {
1860         return 1;
1861 }