1 /* A lexical scanner generated by flex */
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 $
8 #define YY_FLEX_MAJOR_VERSION 2
9 #define YY_FLEX_MINOR_VERSION 5
14 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
27 /* Use prototypes in function declarations. */
30 /* The "const" storage-class-modifier is valid. */
33 #else /* ! __cplusplus */
41 #endif /* ! __cplusplus */
60 #define YY_PROTO(proto) proto
62 #define YY_PROTO(proto) ()
65 /* Returned upon end-of-file. */
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
73 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
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.
79 #define BEGIN yy_start = 1 + 2 *
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
85 #define YY_START ((yy_start - 1) / 2)
86 #define YYSTATE YY_START
88 /* Action number for EOF rule of a given start state. */
89 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
91 /* Special action meaning "start processing a new file". */
92 #define YY_NEW_FILE yyrestart( yyin )
94 #define YY_END_OF_BUFFER_CHAR 0
96 /* Size of default input buffer. */
97 #define YY_BUF_SIZE 16384
99 typedef struct yy_buffer_state *YY_BUFFER_STATE;
102 extern FILE *yyin, *yyout;
104 #define EOB_ACT_CONTINUE_SCAN 0
105 #define EOB_ACT_END_OF_FILE 1
106 #define EOB_ACT_LAST_MATCH 2
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:
112 * if ( condition_holds )
115 * do_something_else();
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.
122 /* Return all but the first 'n' matched characters back to the input stream. */
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 */ \
135 #define unput(c) yyunput( c, yytext_ptr )
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).
141 typedef unsigned int yy_size_t;
144 struct yy_buffer_state
148 char *yy_ch_buf; /* input buffer */
149 char *yy_buf_pos; /* current position in input buffer */
151 /* Size of input buffer in bytes, not including room for EOB
154 yy_size_t yy_buf_size;
156 /* Number of characters read into yy_ch_buf, not including EOB
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
165 int yy_is_our_buffer;
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
172 int yy_is_interactive;
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
180 /* Whether to try to fill the input buffer when we reach the
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.
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.
198 #define YY_BUFFER_EOF_PENDING 2
201 static YY_BUFFER_STATE yy_current_buffer = 0;
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
207 #define YY_CURRENT_BUFFER yy_current_buffer
210 /* yy_hold_char holds the character lost when yytext is formed. */
211 static char yy_hold_char;
213 static int yy_n_chars; /* number of characters read into yy_ch_buf */
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 */
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 ...
226 static int yy_did_buffer_switch_on_eof;
228 void yyrestart YY_PROTO(( FILE *input_file ));
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 )
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 ));
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 * ));
246 #define yy_new_buffer yy_create_buffer
248 #define yy_set_interactive(is_interactive) \
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; \
255 #define yy_set_bol(at_bol) \
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; \
262 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
264 typedef unsigned char YY_CHAR;
265 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
266 typedef int yy_state_type;
268 #define yytext_ptr yytext
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[] ));
275 /* Done after the current pattern has been matched and before the
276 * corresponding action - sets up yytext.
278 #define YY_DO_BEFORE_ACTION \
279 yytext_ptr = yy_bp; \
280 yyleng = (int) (yy_cp - yy_bp); \
281 yy_hold_char = *yy_cp; \
285 #define YY_NUM_RULES 33
286 #define YY_END_OF_BUFFER 34
287 static yyconst short int yy_accept[120] =
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,
300 31, 31, 31, 12, 17, 14, 31, 10, 31, 31,
301 7, 31, 31, 31, 31, 31, 15, 6, 0
304 static yyconst int yy_ec[256] =
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,
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,
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,
336 static yyconst int yy_meta[46] =
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,
345 static yyconst short int yy_base[123] =
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,
358 57, 75, 53, 0, 0, 0, 58, 0, 63, 53,
359 0, 54, 47, 49, 32, 43, 0, 0, 169, 101,
363 static yyconst short int yy_def[123] =
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,
376 121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
377 121, 121, 121, 121, 121, 121, 121, 121, 0, 119,
381 static yyconst short int yy_nxt[215] =
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,
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,
405 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
409 static yyconst short int yy_chk[215] =
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,
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,
433 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
437 static yy_state_type yy_last_accepting_state;
438 static char *yy_last_accepting_cpos;
440 /* The intent behind this definition is that it'll catch
441 * any uses of REJECT which flex missed.
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
448 #line 1 "ginsh_lexer.ll"
450 /** @file ginsh_lexer.ll
452 * Lexical analyzer definition for ginsh.
453 * This file must be processed with flex.
455 * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
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.
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.
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
474 #line 29 "ginsh_lexer.ll"
479 #include <readline/readline.h>
480 #include <readline/history.h>
484 #include <ginac/ginac.h>
487 #include "ginsh_parser.h"
489 #define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size))
491 // Table of all used symbols
494 // lex input function
495 static int ginsh_input(char *buf, int max_size);
502 /* Macros after this point can all be overridden by user definitions in
506 #ifndef YY_SKIP_YYWRAP
508 extern "C" int yywrap YY_PROTO(( void ));
510 extern int yywrap YY_PROTO(( void ));
515 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
519 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
522 #ifdef YY_NEED_STRLEN
523 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
528 static int yyinput YY_PROTO(( void ));
530 static int input YY_PROTO(( void ));
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 ));
541 #ifndef YY_NO_POP_STATE
542 static void yy_pop_state YY_PROTO(( void ));
544 #ifndef YY_NO_TOP_STATE
545 static int yy_top_state YY_PROTO(( void ));
549 #define YY_NO_PUSH_STATE 1
550 #define YY_NO_POP_STATE 1
551 #define YY_NO_TOP_STATE 1
554 #ifdef YY_MALLOC_DECL
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).
569 /* Amount of stuff to slurp up with each read. */
570 #ifndef YY_READ_BUF_SIZE
571 #define YY_READ_BUF_SIZE 8192
574 /* Copy whatever the last rule matched to the standard output. */
577 /* This used to be an fputs(), but since the string might contain NUL's,
578 * we now use fwrite().
580 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
583 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
584 * is returned in "result".
587 #define YY_INPUT(buf,result,max_size) \
588 if ( yy_current_buffer->yy_is_interactive ) \
591 for ( n = 0; n < max_size && \
592 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
595 buf[n++] = (char) c; \
596 if ( c == EOF && ferror( yyin ) ) \
597 YY_FATAL_ERROR( "input in flex scanner failed" ); \
600 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
601 && ferror( yyin ) ) \
602 YY_FATAL_ERROR( "input in flex scanner failed" );
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.
610 #define yyterminate() return YY_NULL
613 /* Number of entries by which start-condition stack grows. */
614 #ifndef YY_START_STACK_INCR
615 #define YY_START_STACK_INCR 25
618 /* Report a fatal error. */
619 #ifndef YY_FATAL_ERROR
620 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
623 /* Default declaration of generated scanner - a define so the user can
624 * easily add parameters.
627 #define YY_DECL int yylex YY_PROTO(( void ))
630 /* Code executed at the beginning of each rule, after yytext and yyleng
633 #ifndef YY_USER_ACTION
634 #define YY_USER_ACTION
637 /* Code executed at the end of each rule. */
639 #define YY_BREAK break;
642 #define YY_RULE_SETUP \
644 yy_current_buffer->yy_at_bol = \
645 (yytext[yyleng - 1] == '\n'); \
650 register yy_state_type yy_current_state;
651 register char *yy_cp, *yy_bp;
654 #line 63 "ginsh_lexer.ll"
667 yy_start = 1; /* first start state */
675 if ( ! yy_current_buffer )
677 yy_create_buffer( yyin, YY_BUF_SIZE );
679 yy_load_buffer_state();
682 while ( 1 ) /* loops until end-of-file is reached */
686 /* Support of yytext. */
687 *yy_cp = yy_hold_char;
689 /* yy_bp points to the position in yy_ch_buf of the start of
694 yy_current_state = yy_start;
695 yy_current_state += YY_AT_BOL();
699 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
700 if ( yy_accept[yy_current_state] )
702 yy_last_accepting_state = yy_current_state;
703 yy_last_accepting_cpos = yy_cp;
705 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
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];
711 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
714 while ( yy_base[yy_current_state] != 169 );
717 yy_act = yy_accept[yy_current_state];
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];
728 do_action: /* This label is used only to access EOF actions. */
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;
742 #line 64 "ginsh_lexer.ll"
743 /* skip whitespace */
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 */
750 #line 65 "ginsh_lexer.ll"
751 /* skip line continuations */
755 #line 66 "ginsh_lexer.ll"
756 /* skip comments starting with "#" */
760 #line 67 "ginsh_lexer.ll"
761 system(yytext + 1); /* execute shell command */
766 #line 70 "ginsh_lexer.ll"
767 yylval = Pi; return T_LITERAL;
771 #line 71 "ginsh_lexer.ll"
772 yylval = EulerGamma; return T_LITERAL;
776 #line 72 "ginsh_lexer.ll"
777 yylval = Catalan; return T_LITERAL;
781 #line 73 "ginsh_lexer.ll"
782 yylval = *new fail(); return T_LITERAL;
786 #line 74 "ginsh_lexer.ll"
787 yylval = I; return T_NUMBER;
791 #line 75 "ginsh_lexer.ll"
792 yylval = (long)Digits; return T_DIGITS;
797 #line 78 "ginsh_lexer.ll"
802 #line 79 "ginsh_lexer.ll"
807 #line 80 "ginsh_lexer.ll"
812 #line 81 "ginsh_lexer.ll"
817 #line 82 "ginsh_lexer.ll"
822 #line 83 "ginsh_lexer.ll"
827 #line 84 "ginsh_lexer.ll"
833 #line 87 "ginsh_lexer.ll"
838 #line 88 "ginsh_lexer.ll"
843 #line 89 "ginsh_lexer.ll"
848 #line 90 "ginsh_lexer.ll"
851 /* last 1..3 expressions */
854 #line 93 "ginsh_lexer.ll"
859 #line 94 "ginsh_lexer.ll"
864 #line 95 "ginsh_lexer.ll"
867 /* matrix delimiters */
870 #line 98 "ginsh_lexer.ll"
871 return T_MATRIX_BEGIN;
875 #line 99 "ginsh_lexer.ll"
880 #line 103 "ginsh_lexer.ll"
882 #line 104 "ginsh_lexer.ll"
884 #line 105 "ginsh_lexer.ll"
887 #line 105 "ginsh_lexer.ll"
888 yylval = numeric(yytext); return T_NUMBER;
893 #line 108 "ginsh_lexer.ll"
895 if (syms.find(yytext) == syms.end())
896 syms[yytext] = *(new symbol(yytext));
897 yylval = syms[yytext];
901 /* everything else */
904 #line 116 "ginsh_lexer.ll"
909 #line 118 "ginsh_lexer.ll"
913 case YY_STATE_EOF(INITIAL):
916 case YY_END_OF_BUFFER:
918 /* Amount of text matched not including the EOB char. */
919 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
921 /* Undo the effects of YY_DO_BEFORE_ACTION. */
922 *yy_cp = yy_hold_char;
923 YY_RESTORE_YY_MORE_OFFSET
925 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
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.
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;
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
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;
952 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
954 yy_current_state = yy_get_previous_state();
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).
965 yy_next_state = yy_try_NUL_trans( yy_current_state );
967 yy_bp = yytext_ptr + YY_MORE_ADJ;
971 /* Consume the NUL. */
972 yy_cp = ++yy_c_buf_p;
973 yy_current_state = yy_next_state;
984 else switch ( yy_get_next_buffer() )
986 case EOB_ACT_END_OF_FILE:
988 yy_did_buffer_switch_on_eof = 0;
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.
1001 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1003 yy_act = YY_STATE_EOF(YY_START);
1009 if ( ! yy_did_buffer_switch_on_eof )
1015 case EOB_ACT_CONTINUE_SCAN:
1017 yytext_ptr + yy_amount_of_matched_text;
1019 yy_current_state = yy_get_previous_state();
1022 yy_bp = yytext_ptr + YY_MORE_ADJ;
1025 case EOB_ACT_LAST_MATCH:
1027 &yy_current_buffer->yy_ch_buf[yy_n_chars];
1029 yy_current_state = yy_get_previous_state();
1032 yy_bp = yytext_ptr + YY_MORE_ADJ;
1033 goto yy_find_action;
1040 "fatal flex scanner internal error--no action found" );
1041 } /* end of action switch */
1042 } /* end of scanning one token */
1043 } /* end of yylex */
1046 /* yy_get_next_buffer - try to read in a new buffer
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
1054 static int yy_get_next_buffer()
1056 register char *dest = yy_current_buffer->yy_ch_buf;
1057 register char *source = yytext_ptr;
1058 register int number_to_move, i;
1061 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
1063 "fatal flex scanner internal error--end of buffer missed" );
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 )
1069 /* We matched a single character, the EOB, so
1070 * treat this as a final EOF.
1072 return EOB_ACT_END_OF_FILE;
1077 /* We matched some text prior to the EOB, first
1080 return EOB_ACT_LAST_MATCH;
1084 /* Try to read more data. */
1086 /* First move last chars to start of buffer. */
1087 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1089 for ( i = 0; i < number_to_move; ++i )
1090 *(dest++) = *(source++);
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,
1096 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1101 yy_current_buffer->yy_buf_size - number_to_move - 1;
1103 while ( num_to_read <= 0 )
1104 { /* Not enough room in the buffer - grow it. */
1105 #ifdef YY_USES_REJECT
1107 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1110 /* just a shorter name for the current buffer */
1111 YY_BUFFER_STATE b = yy_current_buffer;
1113 int yy_c_buf_p_offset =
1114 (int) (yy_c_buf_p - b->yy_ch_buf);
1116 if ( b->yy_is_our_buffer )
1118 int new_size = b->yy_buf_size * 2;
1120 if ( new_size <= 0 )
1121 b->yy_buf_size += b->yy_buf_size / 8;
1123 b->yy_buf_size *= 2;
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 );
1131 /* Can't grow it, we don't own it. */
1134 if ( ! b->yy_ch_buf )
1136 "fatal error - scanner input buffer overflow" );
1138 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1140 num_to_read = yy_current_buffer->yy_buf_size -
1145 if ( num_to_read > YY_READ_BUF_SIZE )
1146 num_to_read = YY_READ_BUF_SIZE;
1148 /* Read in more data. */
1149 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1150 yy_n_chars, num_to_read );
1152 yy_current_buffer->yy_n_chars = yy_n_chars;
1155 if ( yy_n_chars == 0 )
1157 if ( number_to_move == YY_MORE_ADJ )
1159 ret_val = EOB_ACT_END_OF_FILE;
1165 ret_val = EOB_ACT_LAST_MATCH;
1166 yy_current_buffer->yy_buffer_status =
1167 YY_BUFFER_EOF_PENDING;
1172 ret_val = EOB_ACT_CONTINUE_SCAN;
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;
1178 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1184 /* yy_get_previous_state - get the state just before the EOB char was reached */
1186 static yy_state_type yy_get_previous_state()
1188 register yy_state_type yy_current_state;
1189 register char *yy_cp;
1191 yy_current_state = yy_start;
1192 yy_current_state += YY_AT_BOL();
1194 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1196 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1197 if ( yy_accept[yy_current_state] )
1199 yy_last_accepting_state = yy_current_state;
1200 yy_last_accepting_cpos = yy_cp;
1202 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
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];
1208 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1211 return yy_current_state;
1215 /* yy_try_NUL_trans - try to make a transition on the NUL character
1218 * next_state = yy_try_NUL_trans( current_state );
1221 #ifdef YY_USE_PROTOS
1222 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1224 static yy_state_type yy_try_NUL_trans( yy_current_state )
1225 yy_state_type yy_current_state;
1228 register int yy_is_jam;
1229 register char *yy_cp = yy_c_buf_p;
1231 register YY_CHAR yy_c = 1;
1232 if ( yy_accept[yy_current_state] )
1234 yy_last_accepting_state = yy_current_state;
1235 yy_last_accepting_cpos = yy_cp;
1237 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
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];
1243 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1244 yy_is_jam = (yy_current_state == 119);
1246 return yy_is_jam ? 0 : yy_current_state;
1251 #ifdef YY_USE_PROTOS
1252 static void yyunput( int c, register char *yy_bp )
1254 static void yyunput( c, yy_bp )
1256 register char *yy_bp;
1259 register char *yy_cp = yy_c_buf_p;
1261 /* undo effects of setting up yytext */
1262 *yy_cp = yy_hold_char;
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];
1273 while ( source > yy_current_buffer->yy_ch_buf )
1274 *--dest = *--source;
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;
1281 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1282 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1285 *--yy_cp = (char) c;
1289 yy_hold_char = *yy_cp;
1292 #endif /* ifndef YY_NO_UNPUT */
1296 static int yyinput()
1303 *yy_c_buf_p = yy_hold_char;
1305 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
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.
1311 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1312 /* This was really a NUL. */
1316 { /* need more input */
1317 int offset = yy_c_buf_p - yytext_ptr;
1320 switch ( yy_get_next_buffer() )
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.
1333 /* Reset buffer status. */
1338 case EOB_ACT_END_OF_FILE:
1343 if ( ! yy_did_buffer_switch_on_eof )
1352 case EOB_ACT_CONTINUE_SCAN:
1353 yy_c_buf_p = yytext_ptr + offset;
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;
1363 yy_current_buffer->yy_at_bol = (c == '\n');
1369 #ifdef YY_USE_PROTOS
1370 void yyrestart( FILE *input_file )
1372 void yyrestart( input_file )
1376 if ( ! yy_current_buffer )
1377 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1379 yy_init_buffer( yy_current_buffer, input_file );
1380 yy_load_buffer_state();
1384 #ifdef YY_USE_PROTOS
1385 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1387 void yy_switch_to_buffer( new_buffer )
1388 YY_BUFFER_STATE new_buffer;
1391 if ( yy_current_buffer == new_buffer )
1394 if ( yy_current_buffer )
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;
1402 yy_current_buffer = new_buffer;
1403 yy_load_buffer_state();
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.
1410 yy_did_buffer_switch_on_eof = 1;
1414 #ifdef YY_USE_PROTOS
1415 void yy_load_buffer_state( void )
1417 void yy_load_buffer_state()
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;
1427 #ifdef YY_USE_PROTOS
1428 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1430 YY_BUFFER_STATE yy_create_buffer( file, size )
1437 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1439 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1441 b->yy_buf_size = size;
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.
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()" );
1450 b->yy_is_our_buffer = 1;
1452 yy_init_buffer( b, file );
1458 #ifdef YY_USE_PROTOS
1459 void yy_delete_buffer( YY_BUFFER_STATE b )
1461 void yy_delete_buffer( b )
1468 if ( b == yy_current_buffer )
1469 yy_current_buffer = (YY_BUFFER_STATE) 0;
1471 if ( b->yy_is_our_buffer )
1472 yy_flex_free( (void *) b->yy_ch_buf );
1474 yy_flex_free( (void *) b );
1478 #ifndef YY_ALWAYS_INTERACTIVE
1479 #ifndef YY_NEVER_INTERACTIVE
1480 extern int isatty YY_PROTO(( int ));
1484 #ifdef YY_USE_PROTOS
1485 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1487 void yy_init_buffer( b, file )
1494 yy_flush_buffer( b );
1496 b->yy_input_file = file;
1497 b->yy_fill_buffer = 1;
1499 #if YY_ALWAYS_INTERACTIVE
1500 b->yy_is_interactive = 1;
1502 #if YY_NEVER_INTERACTIVE
1503 b->yy_is_interactive = 0;
1505 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1511 #ifdef YY_USE_PROTOS
1512 void yy_flush_buffer( YY_BUFFER_STATE b )
1514 void yy_flush_buffer( b )
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.
1528 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1529 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1531 b->yy_buf_pos = &b->yy_ch_buf[0];
1534 b->yy_buffer_status = YY_BUFFER_NEW;
1536 if ( b == yy_current_buffer )
1537 yy_load_buffer_state();
1541 #ifndef YY_NO_SCAN_BUFFER
1542 #ifdef YY_USE_PROTOS
1543 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1545 YY_BUFFER_STATE yy_scan_buffer( base, size )
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. */
1558 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1560 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
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;
1569 b->yy_fill_buffer = 0;
1570 b->yy_buffer_status = YY_BUFFER_NEW;
1572 yy_switch_to_buffer( b );
1579 #ifndef YY_NO_SCAN_STRING
1580 #ifdef YY_USE_PROTOS
1581 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1583 YY_BUFFER_STATE yy_scan_string( yy_str )
1584 yyconst char *yy_str;
1588 for ( len = 0; yy_str[len]; ++len )
1591 return yy_scan_bytes( yy_str, len );
1596 #ifndef YY_NO_SCAN_BYTES
1597 #ifdef YY_USE_PROTOS
1598 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1600 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1601 yyconst char *bytes;
1610 /* Get memory for full buffer, including space for trailing EOB's. */
1612 buf = (char *) yy_flex_alloc( n );
1614 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1616 for ( i = 0; i < len; ++i )
1619 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1621 b = yy_scan_buffer( buf, n );
1623 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1625 /* It's okay to grow etc. this buffer, and we should throw it
1626 * away when we're done.
1628 b->yy_is_our_buffer = 1;
1635 #ifndef YY_NO_PUSH_STATE
1636 #ifdef YY_USE_PROTOS
1637 static void yy_push_state( int new_state )
1639 static void yy_push_state( new_state )
1643 if ( yy_start_stack_ptr >= yy_start_stack_depth )
1647 yy_start_stack_depth += YY_START_STACK_INCR;
1648 new_size = yy_start_stack_depth * sizeof( int );
1650 if ( ! yy_start_stack )
1651 yy_start_stack = (int *) yy_flex_alloc( new_size );
1654 yy_start_stack = (int *) yy_flex_realloc(
1655 (void *) yy_start_stack, new_size );
1657 if ( ! yy_start_stack )
1659 "out of memory expanding start-condition stack" );
1662 yy_start_stack[yy_start_stack_ptr++] = YY_START;
1669 #ifndef YY_NO_POP_STATE
1670 static void yy_pop_state()
1672 if ( --yy_start_stack_ptr < 0 )
1673 YY_FATAL_ERROR( "start-condition stack underflow" );
1675 BEGIN(yy_start_stack[yy_start_stack_ptr]);
1680 #ifndef YY_NO_TOP_STATE
1681 static int yy_top_state()
1683 return yy_start_stack[yy_start_stack_ptr - 1];
1687 #ifndef YY_EXIT_FAILURE
1688 #define YY_EXIT_FAILURE 2
1691 #ifdef YY_USE_PROTOS
1692 static void yy_fatal_error( yyconst char msg[] )
1694 static void yy_fatal_error( msg )
1698 (void) fprintf( stderr, "%s\n", msg );
1699 exit( YY_EXIT_FAILURE );
1704 /* Redefine yyless() so it works in section 3 code. */
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'; \
1720 /* Internal utility routines. */
1723 #ifdef YY_USE_PROTOS
1724 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
1726 static void yy_flex_strncpy( s1, s2, n )
1733 for ( i = 0; i < n; ++i )
1738 #ifdef YY_NEED_STRLEN
1739 #ifdef YY_USE_PROTOS
1740 static int yy_flex_strlen( yyconst char *s )
1742 static int yy_flex_strlen( s )
1747 for ( n = 0; s[n]; ++n )
1755 #ifdef YY_USE_PROTOS
1756 static void *yy_flex_alloc( yy_size_t size )
1758 static void *yy_flex_alloc( size )
1762 return (void *) malloc( size );
1765 #ifdef YY_USE_PROTOS
1766 static void *yy_flex_realloc( void *ptr, yy_size_t size )
1768 static void *yy_flex_realloc( ptr, size )
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.
1780 return (void *) realloc( (char *) ptr, size );
1783 #ifdef YY_USE_PROTOS
1784 static void yy_flex_free( void *ptr )
1786 static void yy_flex_free( ptr )
1800 #line 118 "ginsh_lexer.ll"
1808 static int line_length = 0;
1809 static char *line_read = NULL;
1810 static char *line_ptr;
1812 // Input function that uses libreadline for interactive input
1813 static int ginsh_input(char *buf, int max_size)
1816 if (yy_current_buffer->yy_is_interactive) {
1819 // Do we need to read a new line?
1820 if (line_length == 0) {
1826 // Read new line, prompt "> "
1827 line_read = line_ptr = readline("> ");
1835 // Add non-empty lines to history
1836 line_length = strlen(line_read) + 1;
1837 if (line_length > 1)
1838 add_history(line_read);
1840 // Reappend trailing '\n' which is stripped by readline()
1841 line_read[line_length - 1] = '\n';
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;
1851 } else if (((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin))
1852 YY_FATAL_ERROR("input in flex scanner failed");
1857 // Scanner terminates on EOF