+++ /dev/null
-/* A lexical scanner generated by flex */
-
-/* Scanner skeleton version:
- * $Header: /home/cvs/GiNaC/ginsh/Attic/ginsh_lexer.cc,v 1.1 1999/11/10 16:36:04 cbauer Exp $
- */
-
-#define FLEX_SCANNER
-#define YY_FLEX_MAJOR_VERSION 2
-#define YY_FLEX_MINOR_VERSION 5
-
-#include <stdio.h>
-
-
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
-#endif
-
-
-#ifdef __cplusplus
-
-#include <stdlib.h>
-#include <unistd.h>
-
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
-
-/* The "const" storage-class-modifier is valid. */
-#define YY_USE_CONST
-
-#else /* ! __cplusplus */
-
-#if __STDC__
-
-#define YY_USE_PROTOS
-#define YY_USE_CONST
-
-#endif /* __STDC__ */
-#endif /* ! __cplusplus */
-
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
-#ifdef YY_USE_CONST
-#define yyconst const
-#else
-#define yyconst
-#endif
-
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
-/* Returned upon end-of-file. */
-#define YY_NULL 0
-
-/* Promotes a possibly negative, possibly signed char to an unsigned
- * integer for use as an array index. If the signed char is negative,
- * we want to instead treat it as an 8-bit unsigned char, hence the
- * double cast.
- */
-#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
-
-/* Enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN.
- */
-#define BEGIN yy_start = 1 + 2 *
-
-/* Translate the current start state into a value that can be later handed
- * to BEGIN to return to the state. The YYSTATE alias is for lex
- * compatibility.
- */
-#define YY_START ((yy_start - 1) / 2)
-#define YYSTATE YY_START
-
-/* Action number for EOF rule of a given start state. */
-#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
-/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
-
-#define YY_END_OF_BUFFER_CHAR 0
-
-/* Size of default input buffer. */
-#define YY_BUF_SIZE 16384
-
-typedef struct yy_buffer_state *YY_BUFFER_STATE;
-
-extern int yyleng;
-extern FILE *yyin, *yyout;
-
-#define EOB_ACT_CONTINUE_SCAN 0
-#define EOB_ACT_END_OF_FILE 1
-#define EOB_ACT_LAST_MATCH 2
-
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
- YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- } \
- while ( 0 )
-
-#define unput(c) yyunput( c, yytext_ptr )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-typedef unsigned int yy_size_t;
-
-
-struct yy_buffer_state
- {
- FILE *yy_input_file;
-
- char *yy_ch_buf; /* input buffer */
- char *yy_buf_pos; /* current position in input buffer */
-
- /* Size of input buffer in bytes, not including room for EOB
- * characters.
- */
- yy_size_t yy_buf_size;
-
- /* Number of characters read into yy_ch_buf, not including EOB
- * characters.
- */
- int yy_n_chars;
-
- /* Whether we "own" the buffer - i.e., we know we created it,
- * and can realloc() it to grow it, and should free() it to
- * delete it.
- */
- int yy_is_our_buffer;
-
- /* Whether this is an "interactive" input source; if so, and
- * if we're using stdio for input, then we want to use getc()
- * instead of fread(), to make sure we stop fetching input after
- * each newline.
- */
- int yy_is_interactive;
-
- /* Whether we're considered to be at the beginning of a line.
- * If so, '^' rules will be active on the next match, otherwise
- * not.
- */
- int yy_at_bol;
-
- /* Whether to try to fill the input buffer when we reach the
- * end of it.
- */
- int yy_fill_buffer;
-
- int yy_buffer_status;
-#define YY_BUFFER_NEW 0
-#define YY_BUFFER_NORMAL 1
- /* When an EOF's been seen but there's still some text to process
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
- * shouldn't try reading from the input source any more. We might
- * still have a bunch of tokens to match, though, because of
- * possible backing-up.
- *
- * When we actually see the EOF, we change the status to "new"
- * (via yyrestart()), so that the user can continue scanning by
- * just pointing yyin at a new input file.
- */
-#define YY_BUFFER_EOF_PENDING 2
- };
-
-static YY_BUFFER_STATE yy_current_buffer = 0;
-
-/* We provide macros for accessing buffer states in case in the
- * future we want to put the buffer states in a more general
- * "scanner state".
- */
-#define YY_CURRENT_BUFFER yy_current_buffer
-
-
-/* yy_hold_char holds the character lost when yytext is formed. */
-static char yy_hold_char;
-
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
-int yyleng;
-
-/* Points to current character in buffer. */
-static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
-static int yy_start = 0; /* start state number */
-
-/* Flag which is used to allow yywrap()'s to do buffer switches
- * instead of setting up a fresh yyin. A bit of a hack ...
- */
-static int yy_did_buffer_switch_on_eof;
-
-void yyrestart YY_PROTO(( FILE *input_file ));
-
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
-
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
-
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
-
-#define yy_new_buffer yy_create_buffer
-
-#define yy_set_interactive(is_interactive) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_is_interactive = is_interactive; \
- }
-
-#define yy_set_bol(at_bol) \
- { \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_at_bol = at_bol; \
- }
-
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
-
-typedef unsigned char YY_CHAR;
-FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
-typedef int yy_state_type;
-extern char *yytext;
-#define yytext_ptr yytext
-
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
-
-/* Done after the current pattern has been matched and before the
- * corresponding action - sets up yytext.
- */
-#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
-#define YY_NUM_RULES 33
-#define YY_END_OF_BUFFER 34
-static yyconst short int yy_accept[120] =
- { 0,
- 0, 0, 34, 32, 1, 1, 32, 22, 3, 32,
- 27, 32, 32, 32, 31, 31, 31, 31, 31, 9,
- 31, 32, 32, 32, 31, 31, 31, 31, 31, 31,
- 31, 31, 4, 1, 19, 23, 3, 29, 28, 27,
- 0, 20, 18, 21, 31, 31, 31, 31, 31, 5,
- 25, 2, 26, 31, 31, 31, 31, 31, 31, 31,
- 31, 4, 4, 24, 0, 28, 0, 0, 30, 31,
- 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
- 31, 0, 29, 0, 0, 28, 31, 31, 31, 8,
- 11, 31, 16, 31, 31, 13, 31, 0, 28, 31,
-
- 31, 31, 31, 12, 17, 14, 31, 10, 31, 31,
- 7, 31, 31, 31, 31, 31, 15, 6, 0
- } ;
-
-static yyconst int yy_ec[256] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 4, 5, 6, 1, 1, 1, 1, 1,
- 1, 1, 7, 1, 7, 8, 1, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 1, 1, 10,
- 11, 12, 1, 1, 13, 14, 15, 16, 17, 18,
- 19, 14, 20, 14, 14, 21, 14, 14, 14, 22,
- 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
- 23, 24, 25, 1, 14, 1, 26, 14, 27, 14,
-
- 28, 14, 29, 14, 30, 14, 31, 32, 33, 34,
- 35, 36, 37, 38, 39, 40, 41, 42, 14, 43,
- 44, 45, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1
- } ;
-
-static yyconst int yy_meta[46] =
- { 0,
- 1, 1, 2, 1, 1, 1, 1, 1, 3, 1,
- 1, 1, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 1, 1, 1, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3
- } ;
-
-static yyconst short int yy_base[123] =
- { 0,
- 0, 164, 167, 169, 44, 46, 155, 160, 0, 155,
- 42, 152, 151, 150, 0, 134, 129, 117, 144, 0,
- 126, 132, 151, 128, 109, 117, 115, 111, 107, 120,
- 116, 101, 133, 50, 169, 138, 0, 45, 47, 63,
- 48, 169, 169, 169, 0, 102, 112, 108, 119, 0,
- 169, 169, 169, 108, 95, 101, 105, 104, 98, 99,
- 86, 0, 0, 169, 51, 69, 58, 121, 120, 102,
- 97, 98, 104, 84, 95, 91, 87, 80, 81, 90,
- 72, 107, 106, 74, 105, 104, 80, 71, 72, 0,
- 0, 75, 0, 68, 78, 0, 59, 91, 90, 72,
-
- 57, 75, 53, 0, 0, 0, 58, 0, 63, 53,
- 0, 54, 47, 49, 32, 43, 0, 0, 169, 101,
- 58, 104
- } ;
-
-static yyconst short int yy_def[123] =
- { 0,
- 119, 1, 119, 119, 119, 119, 119, 119, 120, 119,
- 119, 119, 119, 119, 121, 121, 121, 121, 121, 121,
- 121, 119, 119, 119, 121, 121, 121, 121, 121, 121,
- 121, 121, 122, 119, 119, 119, 120, 119, 119, 119,
- 119, 119, 119, 119, 121, 121, 121, 121, 121, 121,
- 119, 119, 119, 121, 121, 121, 121, 121, 121, 121,
- 121, 122, 122, 119, 119, 119, 119, 119, 119, 121,
- 121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
- 121, 119, 119, 119, 119, 119, 121, 121, 121, 121,
- 121, 121, 121, 121, 121, 121, 121, 119, 119, 121,
-
- 121, 121, 121, 121, 121, 121, 121, 121, 121, 121,
- 121, 121, 121, 121, 121, 121, 121, 121, 0, 119,
- 119, 119
- } ;
-
-static yyconst short int yy_nxt[215] =
- { 0,
- 4, 5, 6, 7, 8, 9, 4, 10, 11, 12,
- 13, 14, 15, 15, 16, 17, 18, 19, 15, 20,
- 15, 21, 22, 23, 24, 15, 15, 25, 15, 26,
- 15, 27, 15, 15, 15, 28, 29, 15, 30, 31,
- 15, 15, 32, 15, 15, 34, 34, 34, 34, 39,
- 40, 34, 34, 38, 68, 66, 69, 82, 41, 83,
- 45, 65, 41, 67, 85, 65, 86, 67, 118, 41,
- 39, 40, 65, 41, 67, 117, 65, 66, 67, 41,
- 98, 116, 99, 41, 115, 84, 114, 113, 112, 84,
- 41, 111, 110, 109, 41, 108, 84, 107, 99, 99,
-
- 84, 37, 106, 37, 62, 105, 62, 104, 103, 102,
- 101, 100, 86, 86, 83, 83, 97, 96, 95, 91,
- 94, 93, 92, 91, 90, 89, 88, 87, 69, 69,
- 81, 80, 79, 78, 77, 76, 75, 74, 73, 72,
- 71, 70, 64, 63, 61, 60, 59, 58, 57, 56,
- 55, 54, 53, 52, 51, 50, 49, 48, 47, 46,
- 44, 43, 42, 38, 36, 35, 119, 33, 3, 119,
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
-
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
- 119, 119, 119, 119
- } ;
-
-static yyconst short int yy_chk[215] =
- { 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 5, 5, 6, 6, 11,
- 11, 34, 34, 38, 41, 39, 41, 65, 11, 65,
- 121, 38, 11, 39, 67, 38, 67, 39, 116, 11,
- 40, 40, 38, 11, 39, 115, 38, 66, 39, 40,
- 84, 114, 84, 40, 113, 66, 112, 110, 109, 66,
- 40, 107, 103, 102, 40, 101, 66, 100, 99, 98,
-
- 66, 120, 97, 120, 122, 95, 122, 94, 92, 89,
- 88, 87, 86, 85, 83, 82, 81, 80, 79, 78,
- 77, 76, 75, 74, 73, 72, 71, 70, 69, 68,
- 61, 60, 59, 58, 57, 56, 55, 54, 49, 48,
- 47, 46, 36, 33, 32, 31, 30, 29, 28, 27,
- 26, 25, 24, 23, 22, 21, 19, 18, 17, 16,
- 14, 13, 12, 10, 8, 7, 3, 2, 119, 119,
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
-
- 119, 119, 119, 119, 119, 119, 119, 119, 119, 119,
- 119, 119, 119, 119
- } ;
-
-static yy_state_type yy_last_accepting_state;
-static char *yy_last_accepting_cpos;
-
-/* The intent behind this definition is that it'll catch
- * any uses of REJECT which flex missed.
- */
-#define REJECT reject_used_but_not_detected
-#define yymore() yymore_used_but_not_detected
-#define YY_MORE_ADJ 0
-#define YY_RESTORE_YY_MORE_OFFSET
-char *yytext;
-#line 1 "ginsh_lexer.ll"
-#define INITIAL 0
-/** @file ginsh_lexer.ll
- *
- * Lexical analyzer definition for ginsh.
- * This file must be processed with flex.
- *
- * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-/*
- * Definitions
- */
-#line 29 "ginsh_lexer.ll"
-#include "config.h"
-
-#include <stdio.h>
-extern "C" {
-#include <readline/readline.h>
-#include <readline/history.h>
-}
-#include <map>
-
-#include <ginac/ginac.h>
-#include "ginsh.h"
-
-#include "ginsh_parser.h"
-
-#define YY_INPUT(buf, result, max_size) (result = ginsh_input(buf, max_size))
-
-// Table of all used symbols
-sym_tab syms;
-
-// lex input function
-static int ginsh_input(char *buf, int max_size);
-/* Abbreviations */
-/*
- * Lexical rules
- */
-#line 501 "lex.yy.c"
-
-/* Macros after this point can all be overridden by user definitions in
- * section 1.
- */
-
-#ifndef YY_SKIP_YYWRAP
-#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
-#else
-extern int yywrap YY_PROTO(( void ));
-#endif
-#endif
-
-#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
-#endif
-
-#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
-#endif
-
-#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
-#endif
-
-#ifndef YY_NO_INPUT
-#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
-#else
-static int input YY_PROTO(( void ));
-#endif
-#endif
-
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
-#endif
-
-/* Amount of stuff to slurp up with each read. */
-#ifndef YY_READ_BUF_SIZE
-#define YY_READ_BUF_SIZE 8192
-#endif
-
-/* Copy whatever the last rule matched to the standard output. */
-
-#ifndef ECHO
-/* This used to be an fputs(), but since the string might contain NUL's,
- * we now use fwrite().
- */
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
-#endif
-
-/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
-#ifndef YY_INPUT
-#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
- { \
- int c = '*', n; \
- for ( n = 0; n < max_size && \
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
- buf[n] = (char) c; \
- if ( c == '\n' ) \
- buf[n++] = (char) c; \
- if ( c == EOF && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
- result = n; \
- } \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
-#endif
-
-/* No semi-colon after return; correct usage is to write "yyterminate();" -
- * we don't want an extra ';' after the "return" because that will cause
- * some compilers to complain about unreachable statements.
- */
-#ifndef yyterminate
-#define yyterminate() return YY_NULL
-#endif
-
-/* Number of entries by which start-condition stack grows. */
-#ifndef YY_START_STACK_INCR
-#define YY_START_STACK_INCR 25
-#endif
-
-/* Report a fatal error. */
-#ifndef YY_FATAL_ERROR
-#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
-#endif
-
-/* Default declaration of generated scanner - a define so the user can
- * easily add parameters.
- */
-#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
-
-/* Code executed at the beginning of each rule, after yytext and yyleng
- * have been set up.
- */
-#ifndef YY_USER_ACTION
-#define YY_USER_ACTION
-#endif
-
-/* Code executed at the end of each rule. */
-#ifndef YY_BREAK
-#define YY_BREAK break;
-#endif
-
-#define YY_RULE_SETUP \
- if ( yyleng > 0 ) \
- yy_current_buffer->yy_at_bol = \
- (yytext[yyleng - 1] == '\n'); \
- YY_USER_ACTION
-
-YY_DECL
- {
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
-#line 63 "ginsh_lexer.ll"
-
-#line 657 "lex.yy.c"
-
- if ( yy_init )
- {
- yy_init = 0;
-
-#ifdef YY_USER_INIT
- YY_USER_INIT;
-#endif
-
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_load_buffer_state();
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yy_c_buf_p;
-
- /* Support of yytext. */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of
- * the current run.
- */
- yy_bp = yy_cp;
-
- yy_current_state = yy_start;
- yy_current_state += YY_AT_BOL();
-yy_match:
- do
- {
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 120 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- ++yy_cp;
- }
- while ( yy_base[yy_current_state] != 169 );
-
-yy_find_action:
- yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
-
- YY_DO_BEFORE_ACTION;
-
-
-do_action: /* This label is used only to access EOF actions. */
-
-
- switch ( yy_act )
- { /* beginning of action switch */
- case 0: /* must back up */
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
- goto yy_find_action;
-
-case 1:
-YY_RULE_SETUP
-#line 64 "ginsh_lexer.ll"
-/* skip whitespace */
- YY_BREAK
-case 2:
-*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
-yy_c_buf_p = yy_cp -= 1;
-YY_DO_BEFORE_ACTION; /* set up yytext again */
-YY_RULE_SETUP
-#line 65 "ginsh_lexer.ll"
-/* skip line continuations */
- YY_BREAK
-case 3:
-YY_RULE_SETUP
-#line 66 "ginsh_lexer.ll"
-/* skip comments starting with "#" */
- YY_BREAK
-case 4:
-YY_RULE_SETUP
-#line 67 "ginsh_lexer.ll"
-system(yytext + 1); /* execute shell command */
- YY_BREAK
-/* special values */
-case 5:
-YY_RULE_SETUP
-#line 70 "ginsh_lexer.ll"
-yylval = Pi; return T_LITERAL;
- YY_BREAK
-case 6:
-YY_RULE_SETUP
-#line 71 "ginsh_lexer.ll"
-yylval = EulerGamma; return T_LITERAL;
- YY_BREAK
-case 7:
-YY_RULE_SETUP
-#line 72 "ginsh_lexer.ll"
-yylval = Catalan; return T_LITERAL;
- YY_BREAK
-case 8:
-YY_RULE_SETUP
-#line 73 "ginsh_lexer.ll"
-yylval = *new fail(); return T_LITERAL;
- YY_BREAK
-case 9:
-YY_RULE_SETUP
-#line 74 "ginsh_lexer.ll"
-yylval = I; return T_NUMBER;
- YY_BREAK
-case 10:
-YY_RULE_SETUP
-#line 75 "ginsh_lexer.ll"
-yylval = (long)Digits; return T_DIGITS;
- YY_BREAK
-/* keywords */
-case 11:
-YY_RULE_SETUP
-#line 78 "ginsh_lexer.ll"
-return T_QUIT;
- YY_BREAK
-case 12:
-YY_RULE_SETUP
-#line 79 "ginsh_lexer.ll"
-return T_PRINT;
- YY_BREAK
-case 13:
-YY_RULE_SETUP
-#line 80 "ginsh_lexer.ll"
-return T_TIME;
- YY_BREAK
-case 14:
-YY_RULE_SETUP
-#line 81 "ginsh_lexer.ll"
-return T_XYZZY;
- YY_BREAK
-case 15:
-YY_RULE_SETUP
-#line 82 "ginsh_lexer.ll"
-return T_INVENTORY;
- YY_BREAK
-case 16:
-YY_RULE_SETUP
-#line 83 "ginsh_lexer.ll"
-return T_LOOK;
- YY_BREAK
-case 17:
-YY_RULE_SETUP
-#line 84 "ginsh_lexer.ll"
-return T_SCORE;
- YY_BREAK
-/* comparison */
-case 18:
-YY_RULE_SETUP
-#line 87 "ginsh_lexer.ll"
-return T_EQUAL;
- YY_BREAK
-case 19:
-YY_RULE_SETUP
-#line 88 "ginsh_lexer.ll"
-return T_NOTEQ;
- YY_BREAK
-case 20:
-YY_RULE_SETUP
-#line 89 "ginsh_lexer.ll"
-return T_LESSEQ;
- YY_BREAK
-case 21:
-YY_RULE_SETUP
-#line 90 "ginsh_lexer.ll"
-return T_GREATEREQ;
- YY_BREAK
-/* last 1..3 expressions */
-case 22:
-YY_RULE_SETUP
-#line 93 "ginsh_lexer.ll"
-return T_QUOTE;
- YY_BREAK
-case 23:
-YY_RULE_SETUP
-#line 94 "ginsh_lexer.ll"
-return T_QUOTE2;
- YY_BREAK
-case 24:
-YY_RULE_SETUP
-#line 95 "ginsh_lexer.ll"
-return T_QUOTE3;
- YY_BREAK
-/* matrix delimiters */
-case 25:
-YY_RULE_SETUP
-#line 98 "ginsh_lexer.ll"
-return T_MATRIX_BEGIN;
- YY_BREAK
-case 26:
-YY_RULE_SETUP
-#line 99 "ginsh_lexer.ll"
-return T_MATRIX_END;
- YY_BREAK
-/* numbers */
-case 27:
-#line 103 "ginsh_lexer.ll"
-case 28:
-#line 104 "ginsh_lexer.ll"
-case 29:
-#line 105 "ginsh_lexer.ll"
-case 30:
-YY_RULE_SETUP
-#line 105 "ginsh_lexer.ll"
-yylval = numeric(yytext); return T_NUMBER;
- YY_BREAK
-/* symbols */
-case 31:
-YY_RULE_SETUP
-#line 108 "ginsh_lexer.ll"
-{
- if (syms.find(yytext) == syms.end())
- syms[yytext] = *(new symbol(yytext));
- yylval = syms[yytext];
- return T_SYMBOL;
- }
- YY_BREAK
-/* everything else */
-case 32:
-YY_RULE_SETUP
-#line 116 "ginsh_lexer.ll"
-return *yytext;
- YY_BREAK
-case 33:
-YY_RULE_SETUP
-#line 118 "ginsh_lexer.ll"
-ECHO;
- YY_BREAK
-#line 913 "lex.yy.c"
-case YY_STATE_EOF(INITIAL):
- yyterminate();
-
- case YY_END_OF_BUFFER:
- {
- /* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
-
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
- YY_RESTORE_YY_MORE_OFFSET
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
- {
- /* We're scanning a new file or input source. It's
- * possible that this happened because the user
- * just pointed yyin at a new source and called
- * yylex(). If so, then we have to assure
- * consistency between yy_current_buffer and our
- * globals. Here is the right place to do so, because
- * this is the first action (other than possibly a
- * back-up) that will match for the new input source.
- */
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
- }
-
- /* Note that here we test for yy_c_buf_p "<=" to the position
- * of the first EOB in the buffer, since yy_c_buf_p will
- * already have been incremented past the NUL character
- * (since all states make transitions on EOB to the
- * end-of-buffer state). Contrast this with the test
- * in input().
- */
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- { /* This was really a NUL. */
- yy_state_type yy_next_state;
-
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- /* Okay, we're now positioned to make the NUL
- * transition. We couldn't have
- * yy_get_previous_state() go ahead and do it
- * for us because it doesn't know how to deal
- * with the possibility of jamming (and we don't
- * want to build jamming into it because then it
- * will run more slowly).
- */
-
- yy_next_state = yy_try_NUL_trans( yy_current_state );
-
- yy_bp = yytext_ptr + YY_MORE_ADJ;
-
- if ( yy_next_state )
- {
- /* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
- yy_current_state = yy_next_state;
- goto yy_match;
- }
-
- else
- {
- yy_cp = yy_c_buf_p;
- goto yy_find_action;
- }
- }
-
- else switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- yy_did_buffer_switch_on_eof = 0;
-
- if ( yywrap() )
- {
- /* Note: because we've taken care in
- * yy_get_next_buffer() to have set up
- * yytext, we can now set up
- * yy_c_buf_p so that if some total
- * hoser (like flex itself) wants to
- * call the scanner after we return the
- * YY_NULL, it'll still work - another
- * YY_NULL will get returned.
- */
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
-
- yy_act = YY_STATE_EOF(YY_START);
- goto do_action;
- }
-
- else
- {
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
- }
- break;
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_match;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
- goto yy_find_action;
- }
- break;
- }
-
- default:
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--no action found" );
- } /* end of action switch */
- } /* end of scanning one token */
- } /* end of yylex */
-
-
-/* yy_get_next_buffer - try to read in a new buffer
- *
- * Returns a code representing an action:
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
- * EOB_ACT_END_OF_FILE - end of file
- */
-
-static int yy_get_next_buffer()
- {
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr;
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
- YY_FATAL_ERROR(
- "fatal flex scanner internal error--end of buffer missed" );
-
- if ( yy_current_buffer->yy_fill_buffer == 0 )
- { /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
- {
- /* We matched a single character, the EOB, so
- * treat this as a final EOF.
- */
- return EOB_ACT_END_OF_FILE;
- }
-
- else
- {
- /* We matched some text prior to the EOB, first
- * process it.
- */
- return EOB_ACT_LAST_MATCH;
- }
- }
-
- /* Try to read more data. */
-
- /* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
-
- else
- {
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
-
- while ( num_to_read <= 0 )
- { /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
- YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
-
- /* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
-
- int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
-
- if ( b->yy_is_our_buffer )
- {
- int new_size = b->yy_buf_size * 2;
-
- if ( new_size <= 0 )
- b->yy_buf_size += b->yy_buf_size / 8;
- else
- b->yy_buf_size *= 2;
-
- b->yy_ch_buf = (char *)
- /* Include room in for 2 EOB chars. */
- yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 );
- }
- else
- /* Can't grow it, we don't own it. */
- b->yy_ch_buf = 0;
-
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR(
- "fatal error - scanner input buffer overflow" );
-
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
-
- num_to_read = yy_current_buffer->yy_buf_size -
- number_to_move - 1;
-#endif
- }
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
-
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move == YY_MORE_ADJ )
- {
- ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
- }
-
- else
- {
- ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
- YY_BUFFER_EOF_PENDING;
- }
- }
-
- else
- ret_val = EOB_ACT_CONTINUE_SCAN;
-
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
-
- return ret_val;
- }
-
-
-/* yy_get_previous_state - get the state just before the EOB char was reached */
-
-static yy_state_type yy_get_previous_state()
- {
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- yy_current_state = yy_start;
- yy_current_state += YY_AT_BOL();
-
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 120 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- }
-
- return yy_current_state;
- }
-
-
-/* yy_try_NUL_trans - try to make a transition on the NUL character
- *
- * synopsis
- * next_state = yy_try_NUL_trans( current_state );
- */
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
- {
- register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
-
- register YY_CHAR yy_c = 1;
- if ( yy_accept[yy_current_state] )
- {
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
- }
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
- {
- yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 120 )
- yy_c = yy_meta[(unsigned int) yy_c];
- }
- yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 119);
-
- return yy_is_jam ? 0 : yy_current_state;
- }
-
-
-#ifndef YY_NO_UNPUT
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
- {
- register char *yy_cp = yy_c_buf_p;
-
- /* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- /* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
- register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
-
- while ( source > yy_current_buffer->yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += (int) (dest - source);
- yy_bp += (int) (dest - source);
- yy_current_buffer->yy_n_chars =
- yy_n_chars = yy_current_buffer->yy_buf_size;
-
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- *--yy_cp = (char) c;
-
-
- yytext_ptr = yy_bp;
- yy_hold_char = *yy_cp;
- yy_c_buf_p = yy_cp;
- }
-#endif /* ifndef YY_NO_UNPUT */
-
-
-#ifdef __cplusplus
-static int yyinput()
-#else
-static int input()
-#endif
- {
- int c;
-
- *yy_c_buf_p = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- {
- /* yy_c_buf_p now points to the character we want to return.
- * If this occurs *before* the EOB characters, then it's a
- * valid NUL; if not, then we've hit the end of the buffer.
- */
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
- /* This was really a NUL. */
- *yy_c_buf_p = '\0';
-
- else
- { /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_LAST_MATCH:
- /* This happens because yy_g_n_b()
- * sees that we've accumulated a
- * token and flags that we need to
- * try matching the token before
- * proceeding. But for input(),
- * there's no matching to consider.
- * So convert the EOB_ACT_LAST_MATCH
- * to EOB_ACT_END_OF_FILE.
- */
-
- /* Reset buffer status. */
- yyrestart( yyin );
-
- /* fall through */
-
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- return EOF;
-
- if ( ! yy_did_buffer_switch_on_eof )
- YY_NEW_FILE;
-#ifdef __cplusplus
- return yyinput();
-#else
- return input();
-#endif
- }
-
- case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
- break;
- }
- }
- }
-
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
-
- yy_current_buffer->yy_at_bol = (c == '\n');
-
- return c;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
- {
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
-
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
- {
- if ( yy_current_buffer == new_buffer )
- return;
-
- if ( yy_current_buffer )
- {
- /* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
- }
-
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
-
- /* We don't actually know whether we did this switch during
- * EOF (yywrap()) processing, but the only time this flag
- * is looked at is after yywrap() is called, so it's safe
- * to go ahead and always set it.
- */
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
-
-
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_buf_size = size;
-
- /* yy_ch_buf has to be 2 characters longer than the size given because
- * we need to put in 2 end-of-buffer characters.
- */
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
- if ( ! b->yy_ch_buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
-
- b->yy_is_our_buffer = 1;
-
- yy_init_buffer( b, file );
-
- return b;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
- {
- if ( ! b )
- return;
-
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
-
- if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf );
-
- yy_flex_free( (void *) b );
- }
-
-
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
-
-
- {
- yy_flush_buffer( b );
-
- b->yy_input_file = file;
- b->yy_fill_buffer = 1;
-
-#if YY_ALWAYS_INTERACTIVE
- b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
- b->yy_is_interactive = 0;
-#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
-
- {
- if ( ! b )
- return;
-
- b->yy_n_chars = 0;
-
- /* We always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
-
- b->yy_buf_pos = &b->yy_ch_buf[0];
-
- b->yy_at_bol = 1;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
- }
-
-
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
- {
- YY_BUFFER_STATE b;
-
- if ( size < 2 ||
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
- base[size-1] != YY_END_OF_BUFFER_CHAR )
- /* They forgot to leave room for the EOB's. */
- return 0;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
- if ( ! b )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
-
- b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
- b->yy_buf_pos = b->yy_ch_buf = base;
- b->yy_is_our_buffer = 0;
- b->yy_input_file = 0;
- b->yy_n_chars = b->yy_buf_size;
- b->yy_is_interactive = 0;
- b->yy_at_bol = 1;
- b->yy_fill_buffer = 0;
- b->yy_buffer_status = YY_BUFFER_NEW;
-
- yy_switch_to_buffer( b );
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
- {
- int len;
- for ( len = 0; yy_str[len]; ++len )
- ;
-
- return yy_scan_bytes( yy_str, len );
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
- {
- YY_BUFFER_STATE b;
- char *buf;
- yy_size_t n;
- int i;
-
- /* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
- buf = (char *) yy_flex_alloc( n );
- if ( ! buf )
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
-
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
-
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
-
- b = yy_scan_buffer( buf, n );
- if ( ! b )
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
-
- /* It's okay to grow etc. this buffer, and we should throw it
- * away when we're done.
- */
- b->yy_is_our_buffer = 1;
-
- return b;
- }
-#endif
-
-
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
- {
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
- {
- yy_size_t new_size;
-
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
-
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
-
- else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
-
- if ( ! yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
- }
-
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
-
- BEGIN(new_state);
- }
-#endif
-
-
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
- {
- if ( --yy_start_stack_ptr < 0 )
- YY_FATAL_ERROR( "start-condition stack underflow" );
-
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
- }
-#endif
-
-
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
- {
- return yy_start_stack[yy_start_stack_ptr - 1];
- }
-#endif
-
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
-
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
-#else
-static void yy_fatal_error( msg )
-char msg[];
-#endif
- {
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
- }
-
-
-
-/* Redefine yyless() so it works in section 3 code. */
-
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
- } \
- while ( 0 )
-
-
-/* Internal utility routines. */
-
-#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
- {
- register int i;
- for ( i = 0; i < n; ++i )
- s1[i] = s2[i];
- }
-#endif
-
-#ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
- {
- register int n;
- for ( n = 0; s[n]; ++n )
- ;
-
- return n;
- }
-#endif
-
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
- {
- return (void *) malloc( size );
- }
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
- {
- /* The cast to (char *) in the following accommodates both
- * implementations that use char* generic pointers, and those
- * that use void* generic pointers. It works with the latter
- * because both ANSI C and C++ allow castless assignment from
- * any pointer type to void*, and deal with argument conversions
- * as though doing an assignment.
- */
- return (void *) realloc( (char *) ptr, size );
- }
-
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
- {
- free( ptr );
- }
-
-#if YY_MAIN
-int main()
- {
- yylex();
- return 0;
- }
-#endif
-#line 118 "ginsh_lexer.ll"
-
-
-
-/*
- * Routines
- */
-
-static int line_length = 0;
-static char *line_read = NULL;
-static char *line_ptr;
-
-// Input function that uses libreadline for interactive input
-static int ginsh_input(char *buf, int max_size)
-{
- int result;
- if (yy_current_buffer->yy_is_interactive) {
- int actual;
-
- // Do we need to read a new line?
- if (line_length == 0) {
-
- // Free old line
- if (line_read)
- free(line_read);
-
- // Read new line, prompt "> "
- line_read = line_ptr = readline("> ");
-
- // EOF?
- if (!line_read) {
- line_length = 0;
- return YY_NULL;
- }
-
- // Add non-empty lines to history
- line_length = strlen(line_read) + 1;
- if (line_length > 1)
- add_history(line_read);
-
- // Reappend trailing '\n' which is stripped by readline()
- line_read[line_length - 1] = '\n';
- }
-
- // Copy data to lex buffer
- actual = line_length > max_size ? max_size : line_length;
- memcpy(buf, line_ptr, actual);
- line_length -= actual;
- line_ptr += actual;
- result = actual;
-
- } else if (((result = fread(buf, 1, max_size, yyin)) == 0) && ferror(yyin))
- YY_FATAL_ERROR("input in flex scanner failed");
-
- return result;
-}
-
-// Scanner terminates on EOF
-int yywrap()
-{
- return 1;
-}
+++ /dev/null
-
-/* A Bison parser, made from ginsh_parser.yy
- by GNU Bison version 1.25
- */
-
-#define YYBISON 1 /* Identify Bison output. */
-
-#define T_NUMBER 258
-#define T_SYMBOL 259
-#define T_LITERAL 260
-#define T_DIGITS 261
-#define T_QUOTE 262
-#define T_QUOTE2 263
-#define T_QUOTE3 264
-#define T_EQUAL 265
-#define T_NOTEQ 266
-#define T_LESSEQ 267
-#define T_GREATEREQ 268
-#define T_MATRIX_BEGIN 269
-#define T_MATRIX_END 270
-#define T_QUIT 271
-#define T_PRINT 272
-#define T_TIME 273
-#define T_XYZZY 274
-#define T_INVENTORY 275
-#define T_LOOK 276
-#define T_SCORE 277
-#define NEG 278
-
-#line 28 "ginsh_parser.yy"
-
-#include "config.h"
-
-#include <sys/resource.h>
-
-#if HAVE_UNISTD_H
-#include <sys/types.h>
-#include <unistd.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-extern "C" {
-#include <readline/readline.h>
-#include <readline/history.h>
-}
-
-#include <map>
-#include <string>
-#include <stdexcept>
-
-#include <ginac/ginac.h>
-#include "ginsh.h"
-
-// Original readline settings
-static int orig_completion_append_character;
-static char *orig_basic_word_break_characters;
-
-// Expression stack for ", "" and """
-static void push(const ex &e);
-static ex exstack[3];
-
-// Start and end time for the time() function
-static struct rusage start_time, end_time;
-
-// Table of functions (a multimap, because one function may appear with different
-// numbers of parameters)
-typedef ex (*fcnp)(const exprseq &e);
-typedef ex (*fcnp2)(const exprseq &e, int serial);
-
-struct fcn_desc {
- fcn_desc() : p(NULL), num_params(0) {}
- fcn_desc(fcnp func, int num) : p(func), num_params(num), is_ginac(false) {}
- fcn_desc(fcnp2 func, int num, int ser) : p((fcnp)func), num_params(num), is_ginac(true), serial(ser) {}
-
- fcnp p; // Pointer to function
- int num_params; // Number of parameters (0 = arbitrary)
- bool is_ginac; // Flag: function is GiNaC function
- int serial; // GiNaC function serial number (if is_ginac == true)
-};
-
-typedef multimap<string, fcn_desc> fcn_tab;
-static fcn_tab fcns;
-
-static fcn_tab::const_iterator find_function(const ex &sym, int req_params);
-
-static ex lst2matrix(const ex &l);
-#ifndef YYSTYPE
-#define YYSTYPE int
-#endif
-#include <stdio.h>
-
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
-#endif
-#endif
-
-
-
-#define YYFINAL 96
-#define YYFLAG -32768
-#define YYNTBASE 41
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 278 ? yytranslate[x] : 50)
-
-static const char yytranslate[] = { 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 33, 2, 2, 2, 30, 2, 37, 35,
- 36, 28, 26, 40, 27, 2, 29, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 34, 24,
- 23, 25, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 38, 2, 39, 32, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 31
-};
-
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 1, 4, 6, 9, 15, 17, 19, 21, 23,
- 25, 28, 30, 32, 36, 38, 40, 42, 44, 46,
- 47, 53, 58, 62, 66, 70, 74, 78, 82, 86,
- 90, 94, 98, 102, 106, 110, 113, 116, 120, 123,
- 127, 131, 135, 137, 141, 142, 144, 146, 150, 154,
- 160, 162
-};
-
-static const short yyrhs[] = { -1,
- 41, 42, 0, 34, 0, 43, 34, 0, 17, 35,
- 43, 36, 34, 0, 16, 0, 19, 0, 20, 0,
- 21, 0, 22, 0, 1, 34, 0, 3, 0, 4,
- 0, 37, 4, 37, 0, 5, 0, 6, 0, 7,
- 0, 8, 0, 9, 0, 0, 18, 44, 35, 43,
- 36, 0, 4, 35, 45, 36, 0, 6, 23, 3,
- 0, 4, 23, 43, 0, 43, 10, 43, 0, 43,
- 11, 43, 0, 43, 24, 43, 0, 43, 12, 43,
- 0, 43, 25, 43, 0, 43, 13, 43, 0, 43,
- 26, 43, 0, 43, 27, 43, 0, 43, 28, 43,
- 0, 43, 29, 43, 0, 43, 30, 43, 0, 27,
- 43, 0, 26, 43, 0, 43, 32, 43, 0, 43,
- 33, 0, 35, 43, 36, 0, 38, 46, 39, 0,
- 14, 48, 15, 0, 43, 0, 45, 40, 43, 0,
- 0, 47, 0, 43, 0, 47, 40, 43, 0, 14,
- 49, 15, 0, 48, 40, 14, 49, 15, 0, 43,
- 0, 49, 40, 43, 0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
- 114, 115, 118, 119, 129, 138, 139, 140, 141, 142,
- 148, 151, 152, 153, 154, 155, 156, 157, 158, 159,
- 159, 167, 176, 178, 180, 181, 182, 183, 184, 185,
- 186, 187, 188, 189, 190, 191, 192, 193, 194, 195,
- 196, 197, 200, 201, 204, 205, 208, 209, 212, 213,
- 216, 217
-};
-#endif
-
-
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
-
-static const char * const yytname[] = { "$","error","$undefined.","T_NUMBER",
-"T_SYMBOL","T_LITERAL","T_DIGITS","T_QUOTE","T_QUOTE2","T_QUOTE3","T_EQUAL",
-"T_NOTEQ","T_LESSEQ","T_GREATEREQ","T_MATRIX_BEGIN","T_MATRIX_END","T_QUIT",
-"T_PRINT","T_TIME","T_XYZZY","T_INVENTORY","T_LOOK","T_SCORE","'='","'<'","'>'",
-"'+'","'-'","'*'","'/'","'%'","NEG","'^'","'!'","';'","'('","')'","'''","'['",
-"']'","','","input","line","exp","@1","exprseq","list_or_empty","list","matrix",
-"row", NULL
-};
-#endif
-
-static const short yyr1[] = { 0,
- 41, 41, 42, 42, 42, 42, 42, 42, 42, 42,
- 42, 43, 43, 43, 43, 43, 43, 43, 43, 44,
- 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
- 43, 43, 43, 43, 43, 43, 43, 43, 43, 43,
- 43, 43, 45, 45, 46, 46, 47, 47, 48, 48,
- 49, 49
-};
-
-static const short yyr2[] = { 0,
- 0, 2, 1, 2, 5, 1, 1, 1, 1, 1,
- 2, 1, 1, 3, 1, 1, 1, 1, 1, 0,
- 5, 4, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 2, 2, 3, 2, 3,
- 3, 3, 1, 3, 0, 1, 1, 3, 3, 5,
- 1, 3
-};
-
-static const short yydefact[] = { 1,
- 0, 0, 12, 13, 15, 16, 17, 18, 19, 0,
- 6, 0, 20, 7, 8, 9, 10, 0, 0, 3,
- 0, 0, 45, 2, 0, 11, 0, 0, 0, 0,
- 0, 0, 0, 37, 36, 0, 0, 47, 0, 46,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 39, 4, 24, 43, 0, 23, 51, 0,
- 42, 0, 0, 0, 40, 14, 41, 0, 25, 26,
- 28, 30, 27, 29, 31, 32, 33, 34, 35, 38,
- 22, 0, 49, 0, 0, 0, 0, 48, 44, 52,
- 0, 5, 21, 50, 0, 0
-};
-
-static const short yydefgoto[] = { 1,
- 24, 59, 33, 57, 39, 40, 31, 60
-};
-
-static const short yypact[] = {-32768,
- 52, -21,-32768, -12,-32768, -15,-32768,-32768,-32768, 1,
--32768, -16,-32768,-32768,-32768,-32768,-32768, -2, -2,-32768,
- -2, 17, -2,-32768, 162,-32768, -2, -2, 25, -2,
- -6, -2, -5, 6, 6, 81, 27, 187, -7, 35,
- -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
- -2, -2,-32768,-32768, 187, 187, -26,-32768, 187, 14,
--32768, 51, 108, -2,-32768,-32768,-32768, -2, 197, 197,
- 69, 69, 69, 69, 94, 94, 6, 6, 6, 6,
--32768, -2,-32768, -2, -2, 42, 135, 187, 187, 187,
- 22,-32768,-32768,-32768, 77,-32768
-};
-
-static const short yypgoto[] = {-32768,
--32768, -1,-32768,-32768,-32768,-32768,-32768, -3
-};
-
-
-#define YYLAST 230
-
-
-static const short yytable[] = { 25,
- 3, 4, 5, 6, 7, 8, 9, 29, 61, 81,
- 27, 10, 26, 82, 30, 13, 34, 35, 32, 36,
- 37, 38, 28, 18, 19, 55, 56, 58, 83, 64,
- 63, 67, 21, 62, 22, 23, 94, 52, 53, 69,
- 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 95, 2, 84, 3, 4, 5, 6, 7, 8,
- 9, 84, 87, 66, 85, 10, 88, 11, 12, 13,
- 14, 15, 16, 17, 68, 92, 96, 18, 19, 0,
- 89, 91, 90, 0, 0, 20, 21, 0, 22, 23,
- 41, 42, 43, 44, 47, 48, 49, 50, 51, 0,
- 52, 53, 0, 0, 45, 46, 47, 48, 49, 50,
- 51, 0, 52, 53, 0, 0, 65, 41, 42, 43,
- 44, 49, 50, 51, 0, 52, 53, 0, 0, 0,
- 0, 45, 46, 47, 48, 49, 50, 51, 0, 52,
- 53, 0, 0, 86, 41, 42, 43, 44, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 45, 46,
- 47, 48, 49, 50, 51, 0, 52, 53, 0, 0,
- 93, 41, 42, 43, 44, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 45, 46, 47, 48, 49,
- 50, 51, 0, 52, 53, 54, 41, 42, 43, 44,
- 0, 0, 0, 0, 0, 0, 0, 0, 43, 44,
- 45, 46, 47, 48, 49, 50, 51, 0, 52, 53,
- 45, 46, 47, 48, 49, 50, 51, 0, 52, 53
-};
-
-static const short yycheck[] = { 1,
- 3, 4, 5, 6, 7, 8, 9, 23, 15, 36,
- 23, 14, 34, 40, 14, 18, 18, 19, 35, 21,
- 4, 23, 35, 26, 27, 27, 28, 3, 15, 35,
- 32, 39, 35, 40, 37, 38, 15, 32, 33, 41,
- 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
- 52, 0, 1, 40, 3, 4, 5, 6, 7, 8,
- 9, 40, 64, 37, 14, 14, 68, 16, 17, 18,
- 19, 20, 21, 22, 40, 34, 0, 26, 27, -1,
- 82, 85, 84, -1, -1, 34, 35, -1, 37, 38,
- 10, 11, 12, 13, 26, 27, 28, 29, 30, -1,
- 32, 33, -1, -1, 24, 25, 26, 27, 28, 29,
- 30, -1, 32, 33, -1, -1, 36, 10, 11, 12,
- 13, 28, 29, 30, -1, 32, 33, -1, -1, -1,
- -1, 24, 25, 26, 27, 28, 29, 30, -1, 32,
- 33, -1, -1, 36, 10, 11, 12, 13, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, 24, 25,
- 26, 27, 28, 29, 30, -1, 32, 33, -1, -1,
- 36, 10, 11, 12, 13, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, 24, 25, 26, 27, 28,
- 29, 30, -1, 32, 33, 34, 10, 11, 12, 13,
- -1, -1, -1, -1, -1, -1, -1, -1, 12, 13,
- 24, 25, 26, 27, 28, 29, 30, -1, 32, 33,
- 24, 25, 26, 27, 28, 29, 30, -1, 32, 33
-};
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/share/misc/bison.simple"
-
-/* Skeleton output parser for bison,
- Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
-#include <alloca.h>
-#else /* not sparc */
-#if defined (MSDOS) && !defined (__TURBOC__)
-#include <malloc.h>
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
-#include <malloc.h>
- #pragma alloca
-#else /* not MSDOS, __TURBOC__, or _AIX */
-#ifdef __hpux
-#ifdef __cplusplus
-extern "C" {
-void *alloca (unsigned int);
-};
-#else /* not __cplusplus */
-void *alloca ();
-#endif /* not __cplusplus */
-#endif /* __hpux */
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc. */
-#endif /* not GNU C. */
-#endif /* alloca not defined. */
-
-/* This is the parser code that is written into each bison parser
- when the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
-
-/* Note: there must be only one dollar sign in this file.
- It is replaced by the list of actions, each action
- as one case of the switch. */
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY -2
-#define YYEOF 0
-#define YYACCEPT return(0)
-#define YYABORT return(1)
-#define YYERROR goto yyerrlab1
-/* Like YYERROR except do call yyerror.
- This remains here temporarily to ease the
- transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-#define YYFAIL goto yyerrlab
-#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(token, value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { yychar = (token), yylval = (value); \
- yychar1 = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { yyerror ("syntax error: cannot back up"); YYERROR; } \
-while (0)
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-#ifndef YYPURE
-#define YYLEX yylex()
-#endif
-
-#ifdef YYPURE
-#ifdef YYLSP_NEEDED
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval, &yylloc)
-#endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval)
-#endif
-#endif /* not YYLSP_NEEDED */
-#endif
-
-/* If nonreentrant, generate the variables here */
-
-#ifndef YYPURE
-
-int yychar; /* the lookahead symbol */
-YYSTYPE yylval; /* the semantic value of the */
- /* lookahead symbol */
-
-#ifdef YYLSP_NEEDED
-YYLTYPE yylloc; /* location data for the lookahead */
- /* symbol */
-#endif
-
-int yynerrs; /* number of parse errors so far */
-#endif /* not YYPURE */
-
-#if YYDEBUG != 0
-int yydebug; /* nonzero means print parse trace */
-/* Since this is uninitialized, it does not stop multiple parsers
- from coexisting. */
-#endif
-
-/* YYINITDEPTH indicates the initial size of the parser's stacks */
-
-#ifndef YYINITDEPTH
-#define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH is the maximum size the stacks can grow to
- (effective only if the built-in stack extension method is used). */
-
-#if YYMAXDEPTH == 0
-#undef YYMAXDEPTH
-#endif
-
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH 10000
-#endif
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-#ifndef YYPARSE_PARAM
-int yyparse (void);
-#endif
-#endif
-\f
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else /* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- int count;
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#else /* __cplusplus */
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (char *to, char *from, int count)
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#endif
-#endif
-\f
-#line 196 "/usr/share/misc/bison.simple"
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-int
-yyparse(YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
-{
- register int yystate;
- register int yyn;
- register short *yyssp;
- register YYSTYPE *yyvsp;
- int yyerrstatus; /* number of tokens to shift before error messages enabled */
- int yychar1 = 0; /* lookahead token as an internal (translated) token number */
-
- short yyssa[YYINITDEPTH]; /* the state stack */
- YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
-
- short *yyss = yyssa; /* refer to the stacks thru separate pointers */
- YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
-
-#ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK (yyvsp--, yyssp--)
-#endif
-
- int yystacksize = YYINITDEPTH;
-
-#ifdef YYPURE
- int yychar;
- YYSTYPE yylval;
- int yynerrs;
-#ifdef YYLSP_NEEDED
- YYLTYPE yylloc;
-#endif
-#endif
-
- YYSTYPE yyval; /* the variable used to return */
- /* semantic values from the action */
- /* routines */
-
- int yylen;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Starting parse\n");
-#endif
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss - 1;
- yyvsp = yyvs;
-#ifdef YYLSP_NEEDED
- yylsp = yyls;
-#endif
-
-/* Push a new state, which is found in yystate . */
-/* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks. */
-yynewstate:
-
- *++yyssp = yystate;
-
- if (yyssp >= yyss + yystacksize - 1)
- {
- /* Give user a chance to reallocate the stack */
- /* Use copies of these so that the &'s don't force the real ones into memory. */
- YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
-#ifdef YYLSP_NEEDED
- YYLTYPE *yyls1 = yyls;
-#endif
-
- /* Get the current used size of the three stacks, in elements. */
- int size = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- /* Each stack pointer address is followed by the size of
- the data in use in that stack, in bytes. */
-#ifdef YYLSP_NEEDED
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
-#else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
-#endif
-
- yyss = yyss1; yyvs = yyvs1;
-#ifdef YYLSP_NEEDED
- yyls = yyls1;
-#endif
-#else /* no yyoverflow */
- /* Extend the stack our own way. */
- if (yystacksize >= YYMAXDEPTH)
- {
- yyerror("parser stack overflow");
- return 2;
- }
- yystacksize *= 2;
- if (yystacksize > YYMAXDEPTH)
- yystacksize = YYMAXDEPTH;
- yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
- __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
- yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
-#endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + size - 1;
- yyvsp = yyvs + size - 1;
-#ifdef YYLSP_NEEDED
- yylsp = yyls + size - 1;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Stack size increased to %d\n", yystacksize);
-#endif
-
- if (yyssp >= yyss + yystacksize - 1)
- YYABORT;
- }
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Entering state %d\n", yystate);
-#endif
-
- goto yybackup;
- yybackup:
-
-/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
-/* yyresume: */
-
- /* First try to decide what to do without reference to lookahead token. */
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* yychar is either YYEMPTY or YYEOF
- or a valid token in external form. */
-
- if (yychar == YYEMPTY)
- {
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Reading a token: ");
-#endif
- yychar = YYLEX;
- }
-
- /* Convert token to internal form (in yychar1) for indexing tables with */
-
- if (yychar <= 0) /* This means end of input. */
- {
- yychar1 = 0;
- yychar = YYEOF; /* Don't call YYLEX any more */
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Now at end of input.\n");
-#endif
- }
- else
- {
- yychar1 = YYTRANSLATE(yychar);
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
-#ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-#endif
- fprintf (stderr, ")\n");
- }
-#endif
- }
-
- yyn += yychar1;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
- goto yydefault;
-
- yyn = yytable[yyn];
-
- /* yyn is what to do for this token type in this state.
- Negative => reduce, -yyn is rule number.
- Positive => shift, yyn is new state.
- New state is final state => don't bother to shift,
- just return success.
- 0, or most negative number => error. */
-
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrlab;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Shift the lookahead token. */
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
-#endif
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- /* count tokens shifted since error; after three, turn off error status. */
- if (yyerrstatus) yyerrstatus--;
-
- yystate = yyn;
- goto yynewstate;
-
-/* Do the default action for the current state. */
-yydefault:
-
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
-
-/* Do a reduction. yyn is the number of a rule to reduce with. */
-yyreduce:
- yylen = yyr2[yyn];
- if (yylen > 0)
- yyval = yyvsp[1-yylen]; /* implement default value of the action */
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- int i;
-
- fprintf (stderr, "Reducing via rule %d (line %d), ",
- yyn, yyrline[yyn]);
-
- /* Print the symbols being reduced, and their result. */
- for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
- fprintf (stderr, "%s ", yytname[yyrhs[i]]);
- fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
- }
-#endif
-
-
- switch (yyn) {
-
-case 4:
-#line 120 "ginsh_parser.yy"
-{
- try {
- cout << yyvsp[-1] << endl;
- push(yyvsp[-1]);
- } catch (exception &e) {
- cerr << e.what() << endl;
- YYERROR;
- }
- ;
- break;}
-case 5:
-#line 130 "ginsh_parser.yy"
-{
- try {
- yyvsp[-2].printtree(cout);
- } catch (exception &e) {
- cerr << e.what() << endl;
- YYERROR;
- }
- ;
- break;}
-case 6:
-#line 138 "ginsh_parser.yy"
-{YYACCEPT;;
- break;}
-case 7:
-#line 139 "ginsh_parser.yy"
-{cout << "Nothing happens.\n";;
- break;}
-case 8:
-#line 140 "ginsh_parser.yy"
-{cout << "You're not carrying anything.\n";;
- break;}
-case 9:
-#line 141 "ginsh_parser.yy"
-{cout << "You're in a twisty little maze of passages, all alike.\n";;
- break;}
-case 10:
-#line 143 "ginsh_parser.yy"
-{
- cout << "If you were to quit now, you would score ";
- cout << (syms.size() > 350 ? 350 : syms.size());
- cout << " out of a possible 350.\n";
- ;
- break;}
-case 11:
-#line 148 "ginsh_parser.yy"
-{yyclearin; yyerrok;;
- break;}
-case 12:
-#line 151 "ginsh_parser.yy"
-{yyval = yyvsp[0];;
- break;}
-case 13:
-#line 152 "ginsh_parser.yy"
-{yyval = yyvsp[0].eval();;
- break;}
-case 14:
-#line 153 "ginsh_parser.yy"
-{yyval = yyvsp[-1];;
- break;}
-case 15:
-#line 154 "ginsh_parser.yy"
-{yyval = yyvsp[0];;
- break;}
-case 16:
-#line 155 "ginsh_parser.yy"
-{yyval = yyvsp[0];;
- break;}
-case 17:
-#line 156 "ginsh_parser.yy"
-{yyval = exstack[0];;
- break;}
-case 18:
-#line 157 "ginsh_parser.yy"
-{yyval = exstack[1];;
- break;}
-case 19:
-#line 158 "ginsh_parser.yy"
-{yyval = exstack[2];;
- break;}
-case 20:
-#line 159 "ginsh_parser.yy"
-{getrusage(RUSAGE_SELF, &start_time);;
- break;}
-case 21:
-#line 160 "ginsh_parser.yy"
-{
- getrusage(RUSAGE_SELF, &end_time);
- yyval = (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec) +
- (end_time.ru_stime.tv_sec - start_time.ru_stime.tv_sec) +
- double(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec) / 1e6 +
- double(end_time.ru_stime.tv_usec - start_time.ru_stime.tv_usec) / 1e6;
- ;
- break;}
-case 22:
-#line 168 "ginsh_parser.yy"
-{
- fcn_tab::const_iterator i = find_function(yyvsp[-3], yyvsp[-1].nops());
- if (i->second.is_ginac) {
- yyval = ((fcnp2)(i->second.p))(static_cast<const exprseq &>(*(yyvsp[-1].bp)), i->second.serial);
- } else {
- yyval = (i->second.p)(static_cast<const exprseq &>(*(yyvsp[-1].bp)));
- }
- ;
- break;}
-case 23:
-#line 177 "ginsh_parser.yy"
-{yyval = yyvsp[0]; Digits = ex_to_numeric(yyvsp[0]).to_int();;
- break;}
-case 24:
-#line 179 "ginsh_parser.yy"
-{yyval = yyvsp[0]; const_cast<symbol *>(&ex_to_symbol(yyvsp[-2]))->assign(yyvsp[0]);;
- break;}
-case 25:
-#line 180 "ginsh_parser.yy"
-{yyval = yyvsp[-2] == yyvsp[0];;
- break;}
-case 26:
-#line 181 "ginsh_parser.yy"
-{yyval = yyvsp[-2] != yyvsp[0];;
- break;}
-case 27:
-#line 182 "ginsh_parser.yy"
-{yyval = yyvsp[-2] < yyvsp[0];;
- break;}
-case 28:
-#line 183 "ginsh_parser.yy"
-{yyval = yyvsp[-2] <= yyvsp[0];;
- break;}
-case 29:
-#line 184 "ginsh_parser.yy"
-{yyval = yyvsp[-2] > yyvsp[0];;
- break;}
-case 30:
-#line 185 "ginsh_parser.yy"
-{yyval = yyvsp[-2] >= yyvsp[0];;
- break;}
-case 31:
-#line 186 "ginsh_parser.yy"
-{yyval = yyvsp[-2] + yyvsp[0];;
- break;}
-case 32:
-#line 187 "ginsh_parser.yy"
-{yyval = yyvsp[-2] - yyvsp[0];;
- break;}
-case 33:
-#line 188 "ginsh_parser.yy"
-{yyval = yyvsp[-2] * yyvsp[0];;
- break;}
-case 34:
-#line 189 "ginsh_parser.yy"
-{yyval = yyvsp[-2] / yyvsp[0];;
- break;}
-case 35:
-#line 190 "ginsh_parser.yy"
-{yyval = yyvsp[-2] % yyvsp[0];;
- break;}
-case 36:
-#line 191 "ginsh_parser.yy"
-{yyval = -yyvsp[0];;
- break;}
-case 37:
-#line 192 "ginsh_parser.yy"
-{yyval = yyvsp[0];;
- break;}
-case 38:
-#line 193 "ginsh_parser.yy"
-{yyval = power(yyvsp[-2], yyvsp[0]);;
- break;}
-case 39:
-#line 194 "ginsh_parser.yy"
-{yyval = factorial(yyvsp[-1]);;
- break;}
-case 40:
-#line 195 "ginsh_parser.yy"
-{yyval = yyvsp[-1];;
- break;}
-case 41:
-#line 196 "ginsh_parser.yy"
-{yyval = yyvsp[-1];;
- break;}
-case 42:
-#line 197 "ginsh_parser.yy"
-{yyval = lst2matrix(yyvsp[-1]);;
- break;}
-case 43:
-#line 200 "ginsh_parser.yy"
-{yyval = exprseq(yyvsp[0]);;
- break;}
-case 44:
-#line 201 "ginsh_parser.yy"
-{exprseq es(static_cast<exprseq &>(*(yyvsp[-2].bp))); yyval = es.append(yyvsp[0]);;
- break;}
-case 45:
-#line 204 "ginsh_parser.yy"
-{yyval = *new lst;;
- break;}
-case 46:
-#line 205 "ginsh_parser.yy"
-{yyval = yyvsp[0];;
- break;}
-case 47:
-#line 208 "ginsh_parser.yy"
-{yyval = lst(yyvsp[0]);;
- break;}
-case 48:
-#line 209 "ginsh_parser.yy"
-{lst l(static_cast<lst &>(*(yyvsp[-2].bp))); yyval = l.append(yyvsp[0]);;
- break;}
-case 49:
-#line 212 "ginsh_parser.yy"
-{yyval = lst(yyvsp[-1]);;
- break;}
-case 50:
-#line 213 "ginsh_parser.yy"
-{lst l(static_cast<lst &>(*(yyvsp[-4].bp))); yyval = l.append(yyvsp[-1]);;
- break;}
-case 51:
-#line 216 "ginsh_parser.yy"
-{yyval = lst(yyvsp[0]);;
- break;}
-case 52:
-#line 217 "ginsh_parser.yy"
-{lst l(static_cast<lst &>(*(yyvsp[-2].bp))); yyval = l.append(yyvsp[0]);;
- break;}
-}
- /* the action file gets copied in in place of this dollarsign */
-#line 498 "/usr/share/misc/bison.simple"
-\f
- yyvsp -= yylen;
- yyssp -= yylen;
-#ifdef YYLSP_NEEDED
- yylsp -= yylen;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
-#endif
-
- *++yyvsp = yyval;
-
-#ifdef YYLSP_NEEDED
- yylsp++;
- if (yylen == 0)
- {
- yylsp->first_line = yylloc.first_line;
- yylsp->first_column = yylloc.first_column;
- yylsp->last_line = (yylsp-1)->last_line;
- yylsp->last_column = (yylsp-1)->last_column;
- yylsp->text = 0;
- }
- else
- {
- yylsp->last_line = (yylsp+yylen-1)->last_line;
- yylsp->last_column = (yylsp+yylen-1)->last_column;
- }
-#endif
-
- /* Now "shift" the result of the reduction.
- Determine what state that goes to,
- based on the state we popped back to
- and the rule number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTBASE];
-
- goto yynewstate;
-
-yyerrlab: /* here on detecting error */
-
- if (! yyerrstatus)
- /* If not already recovering from an error, report this error. */
- {
- ++yynerrs;
-
-#ifdef YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (yyn > YYFLAG && yyn < YYLAST)
- {
- int size = 0;
- char *msg;
- int x, count;
-
- count = 0;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) malloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- {
- strcat(msg, count == 0 ? ", expecting `" : " or `");
- strcat(msg, yytname[x]);
- strcat(msg, "'");
- count++;
- }
- }
- yyerror(msg);
- free(msg);
- }
- else
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
- }
-
- goto yyerrlab1;
-yyerrlab1: /* here on error raised explicitly by an action */
-
- if (yyerrstatus == 3)
- {
- /* if just tried and failed to reuse lookahead token after an error, discard it. */
-
- /* return failure if at end of input */
- if (yychar == YYEOF)
- YYABORT;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
-#endif
-
- yychar = YYEMPTY;
- }
-
- /* Else will try to reuse lookahead token
- after shifting the error token. */
-
- yyerrstatus = 3; /* Each real token shifted decrements this */
-
- goto yyerrhandle;
-
-yyerrdefault: /* current state does not do anything special for the error token. */
-
-#if 0
- /* This is wrong; only states that explicitly want error tokens
- should shift them. */
- yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
- if (yyn) goto yydefault;
-#endif
-
-yyerrpop: /* pop the current state because it cannot handle the error token */
-
- if (yyssp == yyss) YYABORT;
- yyvsp--;
- yystate = *--yyssp;
-#ifdef YYLSP_NEEDED
- yylsp--;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "Error: state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
-#endif
-
-yyerrhandle:
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yyerrdefault;
-
- yyn += YYTERROR;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
- goto yyerrdefault;
-
- yyn = yytable[yyn];
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrpop;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrpop;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting error token, ");
-#endif
-
- *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- yystate = yyn;
- goto yynewstate;
-}
-#line 225 "ginsh_parser.yy"
-
-// Error print routine
-int yyerror(char *s)
-{
- cerr << s << " at " << yytext << endl;
- return 0;
-}
-
-// Push expression "e" onto the expression stack (for ", "" and """)
-static void push(const ex &e)
-{
- exstack[2] = exstack[1];
- exstack[1] = exstack[0];
- exstack[0] = e;
-}
-
-
-/*
- * Built-in functions
- */
-
-static ex f_beta(const exprseq &e) {return gamma(e[0])*gamma(e[1])/gamma(e[0]+e[1]);}
-static ex f_denom(const exprseq &e) {return e[0].denom();}
-static ex f_eval1(const exprseq &e) {return e[0].eval();}
-static ex f_evalf1(const exprseq &e) {return e[0].evalf();}
-static ex f_expand(const exprseq &e) {return e[0].expand();}
-static ex f_gcd(const exprseq &e) {return gcd(e[0], e[1]);}
-static ex f_lcm(const exprseq &e) {return lcm(e[0], e[1]);}
-static ex f_lsolve(const exprseq &e) {return lsolve(e[0], e[1]);}
-static ex f_nops(const exprseq &e) {return e[0].nops();}
-static ex f_normal1(const exprseq &e) {return e[0].normal();}
-static ex f_numer(const exprseq &e) {return e[0].numer();}
-static ex f_power(const exprseq &e) {return power(e[0], e[1]);}
-static ex f_sqrt(const exprseq &e) {return sqrt(e[0]);}
-static ex f_subs2(const exprseq &e) {return e[0].subs(e[1]);}
-
-#define CHECK_ARG(num, type, fcn) if (!is_ex_of_type(e[num], type)) throw(std::invalid_argument("argument " #num " to " #fcn " must be a " #type))
-
-static ex f_charpoly(const exprseq &e)
-{
- CHECK_ARG(0, matrix, charpoly);
- CHECK_ARG(1, symbol, charpoly);
- return ex_to_matrix(e[0]).charpoly(ex_to_symbol(e[1]));
-}
-
-static ex f_coeff(const exprseq &e)
-{
- CHECK_ARG(1, symbol, coeff);
- CHECK_ARG(2, numeric, coeff);
- return e[0].coeff(ex_to_symbol(e[1]), ex_to_numeric(e[2]).to_int());
-}
-
-static ex f_collect(const exprseq &e)
-{
- CHECK_ARG(1, symbol, collect);
- return e[0].collect(ex_to_symbol(e[1]));
-}
-
-static ex f_content(const exprseq &e)
-{
- CHECK_ARG(1, symbol, content);
- return e[0].content(ex_to_symbol(e[1]));
-}
-
-static ex f_degree(const exprseq &e)
-{
- CHECK_ARG(1, symbol, degree);
- return e[0].degree(ex_to_symbol(e[1]));
-}
-
-static ex f_determinant(const exprseq &e)
-{
- CHECK_ARG(0, matrix, determinant);
- return ex_to_matrix(e[0]).determinant();
-}
-
-static ex f_diag(const exprseq &e)
-{
- int dim = e.nops();
- matrix &m = *new matrix(dim, dim);
- for (int i=0; i<dim; i++)
- m.set(i, i, e.op(i));
- return m;
-}
-
-static ex f_diff2(const exprseq &e)
-{
- CHECK_ARG(1, symbol, diff);
- return e[0].diff(ex_to_symbol(e[1]));
-}
-
-static ex f_diff3(const exprseq &e)
-{
- CHECK_ARG(1, symbol, diff);
- CHECK_ARG(2, numeric, diff);
- return e[0].diff(ex_to_symbol(e[1]), ex_to_numeric(e[2]).to_int());
-}
-
-static ex f_divide(const exprseq &e)
-{
- ex q;
- if (divide(e[0], e[1], q))
- return q;
- else
- return *new fail();
-}
-
-static ex f_eval2(const exprseq &e)
-{
- CHECK_ARG(1, numeric, eval);
- return e[0].eval(ex_to_numeric(e[1]).to_int());
-}
-
-static ex f_evalf2(const exprseq &e)
-{
- CHECK_ARG(1, numeric, evalf);
- return e[0].evalf(ex_to_numeric(e[1]).to_int());
-}
-
-static ex f_has(const exprseq &e)
-{
- return e[0].has(e[1]) ? exONE() : exZERO();
-}
-
-static ex f_inverse(const exprseq &e)
-{
- CHECK_ARG(0, matrix, inverse);
- return ex_to_matrix(e[0]).inverse();
-}
-
-static ex f_is(const exprseq &e)
-{
- CHECK_ARG(0, relational, is);
- return (bool)ex_to_relational(e[0]) ? exONE() : exZERO();
-}
-
-static ex f_lcoeff(const exprseq &e)
-{
- CHECK_ARG(1, symbol, lcoeff);
- return e[0].lcoeff(ex_to_symbol(e[1]));
-}
-
-static ex f_ldegree(const exprseq &e)
-{
- CHECK_ARG(1, symbol, ldegree);
- return e[0].ldegree(ex_to_symbol(e[1]));
-}
-
-static ex f_normal2(const exprseq &e)
-{
- CHECK_ARG(1, numeric, normal);
- return e[0].normal(ex_to_numeric(e[1]).to_int());
-}
-
-static ex f_op(const exprseq &e)
-{
- CHECK_ARG(1, numeric, op);
- int n = ex_to_numeric(e[1]).to_int();
- if (n < 0 || n >= e[0].nops())
- throw(std::out_of_range("second argument to op() is out of range"));
- return e[0].op(n);
-}
-
-static ex f_prem(const exprseq &e)
-{
- CHECK_ARG(2, symbol, prem);
- return prem(e[0], e[1], ex_to_symbol(e[2]));
-}
-
-static ex f_primpart(const exprseq &e)
-{
- CHECK_ARG(1, symbol, primpart);
- return e[0].primpart(ex_to_symbol(e[1]));
-}
-
-static ex f_quo(const exprseq &e)
-{
- CHECK_ARG(2, symbol, quo);
- return quo(e[0], e[1], ex_to_symbol(e[2]));
-}
-
-static ex f_rem(const exprseq &e)
-{
- CHECK_ARG(2, symbol, rem);
- return rem(e[0], e[1], ex_to_symbol(e[2]));
-}
-
-static ex f_series2(const exprseq &e)
-{
- CHECK_ARG(1, symbol, series);
- return e[0].series(ex_to_symbol(e[1]), exZERO());
-}
-
-static ex f_series3(const exprseq &e)
-{
- CHECK_ARG(1, symbol, series);
- return e[0].series(ex_to_symbol(e[1]), e[2]);
-}
-
-static ex f_series4(const exprseq &e)
-{
- CHECK_ARG(1, symbol, series);
- CHECK_ARG(3, numeric, series);
- return e[0].series(ex_to_symbol(e[1]), e[2], ex_to_numeric(e[3]).to_int());
-}
-
-static ex f_sqrfree(const exprseq &e)
-{
- CHECK_ARG(1, symbol, sqrfree);
- return sqrfree(e[0], ex_to_symbol(e[1]));
-}
-
-static ex f_subs3(const exprseq &e)
-{
- CHECK_ARG(1, lst, subs);
- CHECK_ARG(2, lst, subs);
- return e[0].subs(ex_to_lst(e[1]), ex_to_lst(e[2]));
-}
-
-static ex f_tcoeff(const exprseq &e)
-{
- CHECK_ARG(1, symbol, tcoeff);
- return e[0].tcoeff(ex_to_symbol(e[1]));
-}
-
-static ex f_trace(const exprseq &e)
-{
- CHECK_ARG(0, matrix, trace);
- return ex_to_matrix(e[0]).trace();
-}
-
-static ex f_transpose(const exprseq &e)
-{
- CHECK_ARG(0, matrix, transpose);
- return ex_to_matrix(e[0]).transpose();
-}
-
-static ex f_unassign(const exprseq &e)
-{
- CHECK_ARG(0, symbol, unassign);
- (const_cast<symbol *>(&ex_to_symbol(e[0])))->unassign();
- return e[0];
-}
-
-static ex f_unit(const exprseq &e)
-{
- CHECK_ARG(1, symbol, unit);
- return e[0].unit(ex_to_symbol(e[1]));
-}
-
-static ex f_dummy(const exprseq &e)
-{
- throw(std::logic_error("dummy function called (shouldn't happen)"));
-}
-
-
-/*
- * Add all registered GiNaC functions to ginsh
- */
-
-static ex f_ginac_function(const exprseq &es, int serial)
-{
- return function(serial, es).eval(1);
-}
-
-void ginsh_get_ginac_functions(void)
-{
- vector<registered_function_info>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
- unsigned serial = 0;
- while (i != end) {
- fcns.insert(make_pair(i->name, fcn_desc(f_ginac_function, i->nparams, serial)));
- i++;
- serial++;
- }
-}
-
-
-/*
- * Find a function given a name and number of parameters. Throw exceptions on error.
- */
-
-static fcn_tab::const_iterator find_function(const ex &sym, int req_params)
-{
- const string &name = ex_to_symbol(sym).getname();
- typedef fcn_tab::const_iterator I;
- pair<I, I> b = fcns.equal_range(name);
- if (b.first == b.second)
- throw(std::logic_error("unknown function '" + name + "'"));
- else {
- for (I i=b.first; i!=b.second; i++)
- if ((i->second.num_params == 0) || (i->second.num_params == req_params))
- return i;
- }
- throw(std::logic_error("invalid number of arguments to " + name + "()"));
-}
-
-
-/*
- * Convert list of lists to matrix
- */
-
-static ex lst2matrix(const ex &l)
-{
- if (!is_ex_of_type(l, lst))
- throw(std::logic_error("internal error: argument to lst2matrix() is not a list"));
-
- // Find number of rows and columns
- int rows = l.nops(), cols = 0, i, j;
- for (i=0; i<rows; i++)
- if (l.op(i).nops() > cols)
- cols = l.op(i).nops();
-
- // Allocate and fill matrix
- matrix &m = *new matrix(rows, cols);
- for (i=0; i<rows; i++)
- for (j=0; j<cols; j++)
- if (l.op(i).nops() > j)
- m.set(i, j, l.op(i).op(j));
- else
- m.set(i, j, exZERO());
- return m;
-}
-
-
-/*
- * Function name completion functions for readline
- */
-
-static char *fcn_generator(char *text, int state)
-{
- static int len; // Length of word to complete
- static fcn_tab::const_iterator index; // Iterator to function being currently considered
-
- // If this is a new word to complete, initialize now
- if (state == 0) {
- index = fcns.begin();
- len = strlen(text);
- }
-
- // Return the next function which partially matches
- while (index != fcns.end()) {
- const char *fcn_name = index->first.c_str();
- index++;
- if (strncmp(fcn_name, text, len) == 0)
- return strdup(fcn_name);
- }
- return NULL;
-}
-
-static char **fcn_completion(char *text, int start, int end)
-{
- if (rl_line_buffer[0] == '!') {
- // For shell commands, revert back to filename completion
- rl_completion_append_character = orig_completion_append_character;
- rl_basic_word_break_characters = orig_basic_word_break_characters;
- return completion_matches(text, filename_completion_function);
- } else {
- // Otherwise, complete function names
- rl_completion_append_character = '(';
- rl_basic_word_break_characters = " \t\n\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~";
- return completion_matches(text, fcn_generator);
- }
-}
-
-
-/*
- * Main program
- */
-
-int main(int argc, char **argv)
-{
- // Print banner in interactive mode
- if (isatty(0)) {
- cout << "ginsh - GiNaC Interactive Shell (" << PACKAGE << " " << VERSION << ")\n";
- cout << "Copyright (C) 1999 Johannes Gutenberg Universitaet Mainz, Germany\n";
- cout << "This is free software, and you are welcome to redistribute it\n";
- cout << "under certain conditions; see the file COPYING for details.\n";
- }
-
- // Init table of built-in functions
- fcns.insert(make_pair(string("beta"), fcn_desc(f_beta, 2)));
- fcns.insert(make_pair(string("charpoly"), fcn_desc(f_charpoly, 2)));
- fcns.insert(make_pair(string("coeff"), fcn_desc(f_coeff, 3)));
- fcns.insert(make_pair(string("collect"), fcn_desc(f_collect, 2)));
- fcns.insert(make_pair(string("content"), fcn_desc(f_content, 2)));
- fcns.insert(make_pair(string("degree"), fcn_desc(f_degree, 2)));
- fcns.insert(make_pair(string("denom"), fcn_desc(f_denom, 1)));
- fcns.insert(make_pair(string("determinant"), fcn_desc(f_determinant, 1)));
- fcns.insert(make_pair(string("diag"), fcn_desc(f_diag, 0)));
- fcns.insert(make_pair(string("diff"), fcn_desc(f_diff2, 2)));
- fcns.insert(make_pair(string("diff"), fcn_desc(f_diff3, 3)));
- fcns.insert(make_pair(string("divide"), fcn_desc(f_divide, 2)));
- fcns.insert(make_pair(string("eval"), fcn_desc(f_eval1, 1)));
- fcns.insert(make_pair(string("eval"), fcn_desc(f_eval2, 2)));
- fcns.insert(make_pair(string("evalf"), fcn_desc(f_evalf1, 1)));
- fcns.insert(make_pair(string("evalf"), fcn_desc(f_evalf2, 2)));
- fcns.insert(make_pair(string("expand"), fcn_desc(f_expand, 1)));
- fcns.insert(make_pair(string("gcd"), fcn_desc(f_gcd, 2)));
- fcns.insert(make_pair(string("has"), fcn_desc(f_has, 2)));
- fcns.insert(make_pair(string("inverse"), fcn_desc(f_inverse, 1)));
- fcns.insert(make_pair(string("is"), fcn_desc(f_is, 1)));
- fcns.insert(make_pair(string("lcm"), fcn_desc(f_lcm, 2)));
- fcns.insert(make_pair(string("lcoeff"), fcn_desc(f_lcoeff, 2)));
- fcns.insert(make_pair(string("ldegree"), fcn_desc(f_ldegree, 2)));
- fcns.insert(make_pair(string("lsolve"), fcn_desc(f_lsolve, 2)));
- fcns.insert(make_pair(string("nops"), fcn_desc(f_nops, 1)));
- fcns.insert(make_pair(string("normal"), fcn_desc(f_normal1, 1)));
- fcns.insert(make_pair(string("normal"), fcn_desc(f_normal2, 2)));
- fcns.insert(make_pair(string("numer"), fcn_desc(f_numer, 1)));
- fcns.insert(make_pair(string("op"), fcn_desc(f_op, 2)));
- fcns.insert(make_pair(string("power"), fcn_desc(f_power, 2)));
- fcns.insert(make_pair(string("prem"), fcn_desc(f_prem, 3)));
- fcns.insert(make_pair(string("primpart"), fcn_desc(f_primpart, 2)));
- fcns.insert(make_pair(string("quo"), fcn_desc(f_quo, 3)));
- fcns.insert(make_pair(string("rem"), fcn_desc(f_rem, 3)));
- fcns.insert(make_pair(string("series"), fcn_desc(f_series2, 2)));
- fcns.insert(make_pair(string("series"), fcn_desc(f_series3, 3)));
- fcns.insert(make_pair(string("series"), fcn_desc(f_series4, 4)));
- fcns.insert(make_pair(string("sqrfree"), fcn_desc(f_sqrfree, 2)));
- fcns.insert(make_pair(string("sqrt"), fcn_desc(f_sqrt, 1)));
- fcns.insert(make_pair(string("subs"), fcn_desc(f_subs2, 2)));
- fcns.insert(make_pair(string("subs"), fcn_desc(f_subs3, 3)));
- fcns.insert(make_pair(string("tcoeff"), fcn_desc(f_tcoeff, 2)));
- fcns.insert(make_pair(string("time"), fcn_desc(f_dummy, 0)));
- fcns.insert(make_pair(string("trace"), fcn_desc(f_trace, 1)));
- fcns.insert(make_pair(string("transpose"), fcn_desc(f_transpose, 1)));
- fcns.insert(make_pair(string("unassign"), fcn_desc(f_unassign, 1)));
- fcns.insert(make_pair(string("unit"), fcn_desc(f_unit, 2)));
- ginsh_get_ginac_functions();
-
- // Init readline completer
- rl_readline_name = argv[0];
- rl_attempted_completion_function = (CPPFunction *)fcn_completion;
- orig_completion_append_character = rl_completion_append_character;
- orig_basic_word_break_characters = rl_basic_word_break_characters;
-
- // Parse input, catch all remaining exceptions
- int result;
-again: try {
- result = yyparse();
- } catch (exception &e) {
- cerr << e.what() << endl;
- goto again;
- }
- return result;
-}