Logo Search packages:      
Sourcecode: octave2.0 version File versions

lex.cc

/* A lexical scanner generated by flex */

/* Scanner skeleton version:
 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
 */

#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5

#include <stdio.h>
#include <errno.h>

/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifndef __cplusplus
#define __cplusplus
#endif
#endif


#ifdef __cplusplus

#include <stdlib.h>
#ifndef _Win32
#include <unistd.h>
#else
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int ));
#endif
#endif
#endif

/* 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 59
#define YY_END_OF_BUFFER 60
static yyconst short int yy_accept[201] =
    {   0,
       16,   16,   16,   16,   16,   16,   60,   58,   16,   21,
       58,   52,   23,   25,   40,   22,   55,   56,   43,   53,
       47,   54,   57,   44,   15,   15,   24,   46,   41,   49,
       42,   20,   11,   45,   12,   48,   39,   52,    4,    1,
        4,    4,    3,    4,    4,    3,    4,    4,    4,    4,
        2,    4,    4,    4,    4,    4,    4,    2,    4,    4,
        4,    4,    4,    4,    4,    4,    4,    4,    7,   10,
       58,   25,    6,    8,    5,   16,   21,   37,   51,   48,
       33,   34,   32,   28,   26,   27,    0,   29,   15,   30,
       31,   15,   15,    0,   13,    0,   35,   36,   38,   20,

       20,   11,    0,   17,    0,    0,   50,    4,    4,    1,
        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
        4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
        4,    4,    4,    4,    4,    4,    4,    4,    4,    7,
       10,    0,    0,    6,    8,    5,   10,    0,    0,   10,
        0,    9,    0,    6,    8,    0,    0,    5,   19,    0,
       14,   15,    0,   15,   15,    0,   18,    0,    4,    4,
        4,    4,    4,    4,    4,    4,    4,    4,    0,   10,
        0,    9,    0,    0,    9,    0,    8,    0,    0,   15,
       18,    4,    4,   10,    0,    9,    0,    8,    9,    0

    } ;

static yyconst int yy_ec[256] =
    {   0,
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
        1,    1,    4,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
        1,    2,    5,    6,    7,    1,    7,    8,    9,   10,
       11,   12,   13,   14,   15,   16,   17,   18,   19,   19,
       19,   19,   19,   19,   19,   19,   19,   20,   21,   22,
       23,   24,    1,    1,   25,   25,   25,   26,   26,   25,
       27,   27,   28,   28,   27,   27,   27,   27,   27,   27,
       27,   27,   27,   27,   27,   27,   27,   29,   27,   27,
       30,   31,   32,   33,   27,    1,   25,   25,   25,   26,

       26,   25,   27,   27,   28,   28,   27,   27,   27,   27,
       27,   27,   27,   27,   27,   27,   27,   27,   27,   29,
       27,   27,    1,   34,    1,   35,    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[36] =
    {   0,
        1,    2,    3,    1,    1,    1,    1,    1,    1,    1,
        1,    1,    1,    3,    1,    1,    1,    2,    2,    1,
        3,    1,    1,    1,    2,    2,    2,    2,    2,    1,
        1,    1,    1,    1,    1
    } ;

static yyconst short int yy_base[209] =
    {   0,
        0,    0,   35,    0,   69,    0,  455,  456,  452,  456,
      450,  429,  456,  456,  443,  456,  456,  456,  438,  436,
      456,  433,   93,  456,  111,   59,  456,  456,   56,  424,
      423,  443,  442,   89,  456,  456,  409,  419,  439,  456,
       79,   72,  456,  438,   86,  456,  437,  436,   87,   84,
      456,   98,  139,  435,  171,  407,  433,  456,   96,  102,
      105,  199,  432,  114,  431,  430,  101,  113,  227,  258,
      428,  119,  428,  140,  406,  405,  456,  456,  456,  456,
      456,  456,  456,  393,  456,  456,  388,  456,  141,  456,
      456,  282,  158,  189,  456,  187,  456,  456,  456,  395,

      390,  389,  159,  456,  387,  128,  456,  382,  380,  456,
      378,  371,  367,  337,  335,  333,  163,  330,  327,  148,
      325,  214,  316,  312,  307,  269,  196,  282,  218,  280,
      267,  247,  233,    0,  221,  176,  131,  189,  217,    0,
        0,  193,  142,  186,  243,  183,    0,  168,  178,    0,
      191,  339,  218,  166,  249,  150,  235,  147,  264,  257,
      456,  255,  236,  259,  267,  254,  456,  260,  300,  315,
      136,  293,  278,  329,  370,  347,  350,  360,  285,    0,
      302,    0,  111,  317,    0,  341,  363,  352,  340,  357,
      456,  375,  381,    0,  375,    0,  383,  399,    0,  456,

       82,  409,  411,  414,  417,  420,  423,  426
    } ;

static yyconst short int yy_def[209] =
    {   0,
      200,    1,  200,    3,    1,    5,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  201,  200,  200,  200,  200,  200,  200,  202,  200,
      202,  202,  200,  202,  202,  200,  202,  202,  202,  202,
      200,  202,  202,  202,  202,   55,  202,  200,  202,  202,
      202,  202,  202,  202,  202,  202,  202,  202,  200,  200,
      200,  203,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,

      201,  200,  200,  200,  200,  204,  200,  202,  200,  200,
      202,  202,  202,  202,  202,  202,  202,  202,  202,  202,
      202,  202,  202,  202,   55,   55,  202,  202,  202,  202,
      202,  202,  200,   62,  200,  200,  202,  205,  202,   69,
       70,  200,  203,  200,  200,  200,   70,  200,  206,   70,
      203,  200,  203,  200,  200,  200,  207,  200,  200,  200,
      200,  200,  200,  200,  200,  204,  200,  204,  202,  202,
      202,   55,  202,  202,  202,  205,  204,  205,  206,   70,
      206,  152,  200,  208,  152,  207,  200,  207,  200,  200,
      200,  202,  202,   70,  208,  152,  208,  200,  152,    0,

      200,  200,  200,  200,  200,  200,  200,  200
    } ;

static yyconst short int yy_nxt[492] =
    {   0,
        8,    9,   10,   11,   12,   13,   14,   15,   16,   17,
       18,   19,   20,   21,   22,   23,   24,   25,   26,   27,
       28,   29,   30,   31,   32,   32,   32,   32,   32,   33,
       34,   35,   36,   37,   38,   39,    9,   40,   41,   42,
       43,   44,   45,   46,   47,   48,   49,   50,   51,   52,
       53,   54,   55,   56,   57,   58,   59,   60,   61,   62,
       62,   62,   62,   62,   63,   64,   65,   66,   67,   68,
       69,   70,   71,  109,   92,   72,   93,   93,   97,   78,
      109,  110,   73,  101,   94,  109,   95,  109,  109,   74,
      103,  104,  105,  112,  111,  106,  114,  109,  113,  109,

       75,   83,  109,  109,   84,   85,  109,   86,   87,   88,
       89,   89,  115,  182,  109,  136,  104,  137,  130,  111,
      138,  152,  153,   90,  131,   91,   92,  132,   93,   93,
      167,  168,  109,  104,  139,  111,   94,  109,   95,   96,
      109,  155,  155,  156,  152,  153,  157,  116,  158,  109,
      117,  118,  155,  119,  120,  121,  122,  122,   89,   89,
      103,  104,  105,  169,  109,  106,  160,  154,   95,  123,
      147,  124,  109,   92,  124,   93,   93,  136,  104,  105,
      180,  181,  106,   94,  158,   95,  125,  154,  126,  126,
      177,  167,  178,  152,  153,  141,  127,  109,  128,  129,

      133,  163,  166,  163,  165,  165,  164,  164,  173,  166,
      173,  165,  165,  174,  174,  109,  134,  134,  109,  109,
      185,  153,  135,  134,  134,  134,  134,  134,  140,  141,
      142,  122,  122,  143,  133,  175,  175,  187,  188,  170,
      144,  128,  175,  175,  155,  155,  156,  145,  109,  157,
      155,  155,  156,  164,  164,  157,  167,  168,  146,  147,
      147,  148,  191,  168,  149,  103,  104,  105,  109,  189,
      106,  189,  162,  162,  190,  190,  164,  164,  145,  109,
       94,  109,   95,  109,  165,  165,   95,  180,  181,  146,
      161,  165,  165,  161,   95,  174,  174,  108,  161,  162,

      162,  136,  104,  137,  194,  181,  138,   94,  108,   95,
      172,  172,  161,  109,  161,  171,  109,  109,  171,  196,
      197,  108,  108,  171,  172,  172,  109,  192,  109,  192,
      109,  109,  193,  193,  109,  108,  109,  171,  109,  171,
      182,  182,  183,  187,  188,  184,  174,  174,  177,  167,
      178,  177,  167,  168,  198,  188,  128,  190,  190,  145,
      166,  177,  191,  178,  155,  155,  156,  166,  109,  157,
      146,  109,  109,  166,  190,  190,  109,  196,  197,  109,
      166,  109,  109,  109,   95,  199,  197,  175,  175,  104,
      102,  100,  193,  193,  175,  175,  100,  128,  193,  193,

      155,  155,  156,  159,   91,  157,   76,  158,  128,  108,
      108,  151,  151,  151,  166,  166,  166,  176,  176,  176,
      179,  179,  179,  186,  186,  186,  195,  195,  195,  154,
      150,  109,  109,  135,  109,  108,  109,  109,  109,  109,
      109,   78,  107,  102,  100,   99,   98,   82,   81,   80,
       79,   78,   77,   76,  200,    7,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200

    } ;

static yyconst short int yy_chk[492] =
    {   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,    3,    3,    3,    3,    3,
        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
        3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
        5,    5,    5,   42,   26,    5,   26,   26,   29,   29,
       41,   41,    5,  201,   26,   50,   26,   45,   49,    5,
       34,   34,   34,   45,   42,   34,   50,   59,   49,   52,

        5,   23,   67,   60,   23,   23,   61,   23,   23,   23,
       23,   23,   52,  183,   68,   64,   64,   64,   59,   59,
       64,   72,   72,   23,   60,   23,   25,   61,   25,   25,
      106,  106,  137,  137,   67,   68,   25,  171,   25,   25,
       53,   74,   74,   74,  143,  143,   74,   53,  158,  120,
       53,   53,  156,   53,   53,   53,   53,   53,   89,   89,
      103,  103,  103,  120,  117,  103,   89,  154,   89,   53,
      148,   53,   55,   93,  117,   93,   93,  136,  136,  136,
      149,  149,  136,   93,  146,   93,   55,  144,   55,   55,
      138,  138,  138,  151,  151,  142,   55,  127,   55,   55,

       62,   94,  138,   94,   96,   96,   94,   94,  127,  138,
      127,   96,   96,  127,  127,  122,   62,   62,  139,  129,
      153,  153,  135,   62,   62,   62,   62,   62,   69,   69,
       69,  122,  122,   69,  133,  129,  129,  157,  157,  122,
       69,  122,  129,  129,  145,  145,  145,   69,  132,  145,
      155,  155,  155,  163,  163,  155,  166,  166,   69,   70,
       70,   70,  168,  168,   70,  159,  159,  159,  131,  160,
      159,  160,  162,  162,  160,  160,  164,  164,   70,  173,
      162,  130,  162,  128,  165,  165,  164,  179,  179,   70,
       92,  165,  165,   92,  165,  173,  173,  126,   92,   92,

       92,  169,  169,  169,  181,  181,  169,   92,  172,   92,
      172,  172,   92,  124,   92,  125,  170,  123,  125,  184,
      184,  172,  125,  125,  125,  125,  121,  170,  119,  170,
      174,  118,  170,  170,  116,  125,  115,  125,  114,  125,
      152,  152,  152,  186,  186,  152,  174,  174,  176,  176,
      176,  177,  177,  177,  188,  188,  174,  189,  189,  152,
      176,  178,  178,  178,  187,  187,  187,  176,  113,  187,
      152,  175,  112,  178,  190,  190,  192,  195,  195,  111,
      178,  109,  193,  108,  190,  197,  197,  175,  175,  105,
      102,  101,  192,  192,  175,  175,  100,  175,  193,  193,

      198,  198,  198,   87,   84,  198,   76,   75,  193,  202,
      202,  203,  203,  203,  204,  204,  204,  205,  205,  205,
      206,  206,  206,  207,  207,  207,  208,  208,  208,   73,
       71,   66,   65,   63,   57,   56,   54,   48,   47,   44,
       39,   38,   37,   33,   32,   31,   30,   22,   20,   19,
       15,   12,   11,    9,    7,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200,  200,  200,  200,  200,  200,  200,  200,  200,  200,
      200

    } ;

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 "lex.l"
#define INITIAL 0
/*

Copyright (C) 1996 John W. Eaton

This file is part of Octave.

Octave 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.

Octave 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 GNU CC; see the file COPYING.  If not, write to the Free
Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/
#define TEXT_FCN 1

#define MATRIX 2

#line 27 "lex.l"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <cctype>
#include <cstring>

#include <string>

#include <strstream.h>

#include "SLStack.h"

// These would be alphabetical, but y.tab.h must be included before
// oct-gperf.h and y.tab.h must be included after token.h and the tree
// class declarations.  We can't include y.tab.h in oct-gperf.h
// because it may not be protected to allow it to be included multiple
// times.

#include "defun.h"
#include "error.h"
#include "input.h"
#include "lex.h"
#include "toplev.h"
#include "parse.h"
#include "symtab.h"
#include "token.h"
#include "pt-base.h"
#include "pt-cmd.h"
#include "ov.h"
#include "pt-exp.h"
#include "pt-mat.h"
#include "pt-misc.h"
#include "pt-plot.h"
#include "utils.h"
#include "variables.h"
#include <y.tab.h>
#include <oct-gperf.h>

#if ! (defined (FLEX_SCANNER) \
       && defined (YY_FLEX_MAJOR_VERSION) && YY_FLEX_MAJOR_VERSION >= 2 \
       && defined (YY_FLEX_MINOR_VERSION) && YY_FLEX_MINOR_VERSION >= 5)
#error lex.l requires flex version 2.5.4 or later
#endif

// Flags that need to be shared between the lexer and parser.
lexical_feedback lexer_flags;

// Stack to hold tokens so that we can delete them when the parser is
// reset and avoid growing forever just because we are stashing some
// information.  This has to appear before lex.h is included, because
// one of the macros defined there uses token_stack.
//
// XXX FIXME XXX -- this should really be static, but that causes
// problems on some systems.
SLStack <token*> token_stack;

// Did eat_whitespace() eat a space or tab, or a newline, or both?

typedef int yum_yum;

const yum_yum ATE_NOTHING = 0;
const yum_yum ATE_SPACE_OR_TAB = 1;
const yum_yum ATE_NEWLINE = 2;

// Is the closest nesting level a square brace or a paren?

class brace_paren_nesting_level : public SLStack <int>
{
public:

  brace_paren_nesting_level (void) : SLStack<int> () { }

  ~brace_paren_nesting_level (void) { }

  void brace (void) { push (BRACE); }
  bool is_brace (void) { return ! empty () && top () == BRACE; }

  void paren (void) { push (PAREN); }
  bool is_paren (void) { return ! empty () && top () == PAREN; }

  bool none (void) { return empty (); }

  void remove (void) { if (! empty ()) SLStack<int>::pop (); }

private:

  enum { BRACE = 1, PAREN = 2 };

  brace_paren_nesting_level (const brace_paren_nesting_level&);

  brace_paren_nesting_level& operator = (const brace_paren_nesting_level&);
};

static brace_paren_nesting_level nesting_level;

// Should whitespace in a literal matrix list be automatically
// converted to commas and semicolons?
//
//   user specifies   value of var
//   --------------   ------------
//   "ignore"              2
//   "traditional"         1
//   anything else         0
//
// Octave will never insert a comma in a literal matrix list if the
// user specifies "ignore".  For example, the statement [1 2] will
// result in an error instead of being treated the same as [1, 2], and
// the statement
//
//   [ 1, 2,
//     3, 4 ]
//
// will result in the vector [1 2 3 4] instead of a matrix.
//
// Traditional behavior makes Octave convert spaces to a comma between
// identifiers and `('.  For example, the statement
//
//   [eye (2)]
//
// will be parsed as
//
//   [eye, (2)]
//
// and will result in an error since the `eye' function will be
// called with no arguments.  To get around this, you would have to
// omit the space between `eye' and the `('.
//
// The default value is 0, which results in behavior that is the same
// as traditional, except that Octave does not convert spaces to a
// comma between identifiers and `('.  For example, the statement
//
//   [eye (2)]
//
// will result in a call to `eye' with the argument `2'.

static int Vwhitespace_in_literal_matrix;

// Forward declarations for functions defined at the bottom of this
// file.

static void fixup_column_count (char *s);
static void do_comma_insert_check (void);
static int is_plot_keyword (const string& s);
static int is_keyword (const string& s);
static string plot_style_token (const string& s);
static symbol_record *lookup_identifier (const string& s);
static void grab_help_text (void);
static int match_any (char c, char *s);
static int next_token_is_sep_op (void);
static int next_token_is_bin_op (int spc_prev, char *yytext);
static int next_token_is_postfix_unary_op (int spc_prev, char *yytext);
static string strip_trailing_whitespace (char *s);
static void handle_number (char *yytext);
static int handle_string (char delim, int text_style = 0);
static int handle_close_brace (int spc_gobbled);
static int handle_identifier (const string& tok, int spc_gobbled);
static int have_continuation (int trailing_comments_ok = 1);
static int have_ellipsis_continuation (int trailing_comments_ok = 1);
static yum_yum eat_whitespace (void);
static yum_yum eat_continuation (void);


/* 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 \
            { \
            errno=0; \
            while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
                  { \
                  if( errno != EINTR) \
                        { \
                        YY_FATAL_ERROR( "input in flex scanner failed" ); \
                        break; \
                        } \
                  errno=0; \
                  clearerr(yyin); \
                  } \
            }
#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 \
      YY_USER_ACTION

YY_DECL
      {
      register yy_state_type yy_current_state;
      register char *yy_cp, *yy_bp;
      register int yy_act;

#line 209 "lex.l"



// Help and other text-style functions are a pain in the ass.  This
// stuff needs to be simplified.  May require some changes in the
// parser too.



      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_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 >= 201 )
                              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] != 456 );

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 217 "lex.l"
{
    BEGIN 0;
    current_input_column = 1;
    lexer_flags.quote_is_transpose = 0;
    lexer_flags.cant_be_identifier = 0;
    lexer_flags.convert_spaces_to_comma = 1;
    return '\n';
  }
      YY_BREAK
case 2:
YY_RULE_SETUP
#line 226 "lex.l"
{
    if (lexer_flags.doing_set && strcmp (yytext, ",") == 0)
      {
      TOK_PUSH_AND_RETURN (yytext, TEXT);
      }
    else
      {
      BEGIN 0;
      if (strcmp (yytext, ",") == 0)
        TOK_RETURN (',');
      else
        TOK_RETURN (';');
      }
  }
      YY_BREAK
case 3:
YY_RULE_SETUP
#line 241 "lex.l"
{
    current_input_column++;
    return handle_string (yytext[0], 1);
  }
      YY_BREAK
case 4:
YY_RULE_SETUP
#line 246 "lex.l"
{
    string tok = strip_trailing_whitespace (yytext);
    TOK_PUSH_AND_RETURN (tok, TEXT);
  }
      YY_BREAK

// For this and the next two rules, we're looking at ']', and we
// need to know if the next token is `=' or `=='.
//
// It would have been so much easier if the delimiters were simply
// different for the expression on the left hand side of the equals
// operator.
//
// It's also a pain in the ass to decide whether to insert a comma
// after seeing a ']' character...

case 5:
YY_RULE_SETUP
#line 263 "lex.l"
{
    fixup_column_count (yytext);
    int c = yytext[yyleng-1];
    int cont_is_spc = eat_continuation ();
    int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t');
    return handle_close_brace (spc_gobbled);
  }
      YY_BREAK

// Commas are element separators in matrix constants.  If we don't
// check for continuations here we can end up inserting too many
// commas.

case 6:
YY_RULE_SETUP
#line 277 "lex.l"
{
    current_input_column += yyleng;
    int tmp = eat_continuation ();
    lexer_flags.quote_is_transpose = 0;
    lexer_flags.cant_be_identifier = 0;
    lexer_flags.convert_spaces_to_comma = 1;
    if (Vwhitespace_in_literal_matrix != 2
      && (tmp & ATE_NEWLINE) == ATE_NEWLINE)
      unput (';');
    return (',');
  }
      YY_BREAK

// In some cases, spaces in matrix constants can turn into commas.
// If commas are required, spaces are not important in matrix
// constants so we just eat them.  If we don't check for continuations
// here we can end up inserting too many commas.

case 7:
YY_RULE_SETUP
#line 296 "lex.l"
{
    current_input_column += yyleng;
    if (Vwhitespace_in_literal_matrix != 2)
      {
      int tmp = eat_continuation ();
      int bin_op = next_token_is_bin_op (1, yytext);
      int postfix_un_op = next_token_is_postfix_unary_op (1, yytext);

      if (! (postfix_un_op || bin_op)
          && nesting_level.is_brace ()
          && lexer_flags.convert_spaces_to_comma)
        {
          lexer_flags.quote_is_transpose = 0;
          lexer_flags.cant_be_identifier = 0;
          lexer_flags.convert_spaces_to_comma = 1;
          if ((tmp & ATE_NEWLINE) == ATE_NEWLINE)
            unput (';');
          return (',');
        }
      }
  }
      YY_BREAK

// Semicolons are handled as row seprators in matrix constants.  If we
// don't eat whitespace here we can end up inserting too many
// semicolons.

case 8:
YY_RULE_SETUP
#line 324 "lex.l"
{
    fixup_column_count (yytext);
    eat_whitespace ();
    lexer_flags.quote_is_transpose = 0;
    lexer_flags.cant_be_identifier = 0;
    lexer_flags.convert_spaces_to_comma = 1;
    return ';';
  }
      YY_BREAK

// In some cases, new lines can also become row separators.  If we
// don't eat whitespace here we can end up inserting too many
// semicolons.

case 9:
#line 340 "lex.l"
case 10:
YY_RULE_SETUP
#line 340 "lex.l"
{
    fixup_column_count (yytext);
    eat_whitespace ();
    if (Vwhitespace_in_literal_matrix != 2)
      {
      lexer_flags.quote_is_transpose = 0;
      lexer_flags.cant_be_identifier = 0;
      lexer_flags.convert_spaces_to_comma = 1;

      if (nesting_level.none ())
        return LEXICAL_ERROR;

      if (nesting_level.is_brace ())
        return ';';
      }
  }
      YY_BREAK

// Open and close brace are handled differently if we are in the range
// part of a plot command.
//

case 11:
YY_RULE_SETUP
#line 363 "lex.l"
{
    nesting_level.brace ();

    current_input_column += yyleng;
    lexer_flags.quote_is_transpose = 0;
    lexer_flags.cant_be_identifier = 0;
    lexer_flags.convert_spaces_to_comma = 1;

    promptflag--;
    eat_whitespace ();

    if (lexer_flags.plotting && ! lexer_flags.past_plot_range)
      {
      lexer_flags.in_plot_range = 1;
      return OPEN_BRACE;
      }
    else
      {
      lexer_flags.braceflag++;
      BEGIN MATRIX;
      return '[';
      }
  }
      YY_BREAK
case 12:
YY_RULE_SETUP
#line 387 "lex.l"
{
    nesting_level.remove ();

    if (lexer_flags.plotting && ! lexer_flags.past_plot_range)
      {
      lexer_flags.in_plot_range = 0;
      TOK_RETURN (CLOSE_BRACE);
      }
    else
      TOK_RETURN (']');
  }
      YY_BREAK

// Imaginary numbers.

case 13:
YY_RULE_SETUP
#line 403 "lex.l"
{
    handle_number (yytext);
    return IMAG_NUM;
  }
      YY_BREAK

// Real numbers.  Don't grab the `.' part of a dot operator as part of
// the constant.

case 14:
*yy_cp = yy_hold_char; /* undo effects of setting up yytext */
yy_c_buf_p = yy_cp -= 2;
YY_DO_BEFORE_ACTION; /* set up yytext again */
#line 414 "lex.l"
case 15:
YY_RULE_SETUP
#line 414 "lex.l"
{
    handle_number (yytext);
    return NUM;
  }
      YY_BREAK

// Eat whitespace.  Whitespace inside matrix constants is handled by
// the <MATRIX> start state code above.

case 16:
YY_RULE_SETUP
#line 424 "lex.l"
{
    current_input_column += yyleng;
  }
      YY_BREAK

// Continuation lines.  Allow comments after continuations.

case 17:
#line 433 "lex.l"
case 18:
YY_RULE_SETUP
#line 433 "lex.l"
{
    promptflag--;
    current_input_column = 1;
  }
      YY_BREAK

// An ellipsis not at the end of a line is not a continuation, but
// does have another meaning.

case 19:
YY_RULE_SETUP
#line 443 "lex.l"
{
    return ELLIPSIS;
  }
      YY_BREAK

// End of file.

case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(TEXT_FCN):
case YY_STATE_EOF(MATRIX):
#line 451 "lex.l"
{
    TOK_RETURN (END_OF_INPUT);
  }
      YY_BREAK

// Identifiers.  Truncate the token at the first space or tab but
// don't write directly on yytext.

case 20:
YY_RULE_SETUP
#line 460 "lex.l"
{
    string tok = strip_trailing_whitespace (yytext);
    int c = yytext[yyleng-1];
    int cont_is_spc = eat_continuation ();
    int spc_gobbled = (cont_is_spc || c == ' ' || c == '\t');
    return handle_identifier (tok, spc_gobbled);
  }
      YY_BREAK

// A new line character.  New line characters inside matrix constants
// are handled by the <MATRIX> start state code above.  If closest
// nesting is inside parentheses, don't return a row separator.

case 21:
YY_RULE_SETUP
#line 474 "lex.l"
{
    current_input_column = 1;
    lexer_flags.quote_is_transpose = 0;
    lexer_flags.cant_be_identifier = 0;
    lexer_flags.convert_spaces_to_comma = 1;

    if (nesting_level.none ())
      return '\n';

    if (nesting_level.is_brace ())
      return LEXICAL_ERROR;
  }
      YY_BREAK

// Single quote can either be the beginning of a string or a transpose
// operator. 

case 22:
YY_RULE_SETUP
#line 492 "lex.l"
{
    current_input_column++;
    lexer_flags.convert_spaces_to_comma = 1;

    if (lexer_flags.quote_is_transpose)
      {
      do_comma_insert_check ();
      return QUOTE;
      }
    else
      return handle_string ('\'');
  }
      YY_BREAK

// Double quotes always begin strings.

case 23:
YY_RULE_SETUP
#line 509 "lex.l"
{
    current_input_column++;
    return handle_string ('"');
}
      YY_BREAK

// The colon operator is handled differently if we are in the range
// part of a plot command.

case 24:
YY_RULE_SETUP
#line 519 "lex.l"
{
    if (lexer_flags.plotting
      && (lexer_flags.in_plot_range || lexer_flags.in_plot_using))
      BIN_OP_RETURN (COLON, 1);
    else
      BIN_OP_RETURN (':', 0);
  }
      YY_BREAK

// Gobble comments.  If closest nesting is inside parentheses, don't
// return a new line.

case 25:
YY_RULE_SETUP
#line 532 "lex.l"
{
    if (help_buf.empty ()
      && lexer_flags.beginning_of_function
      && nesting_level.none ())
      {
      grab_help_text ();
      lexer_flags.beginning_of_function = 0;
      }
    else
      {
      int c;
      while ((c = yyinput ()) != EOF && c != '\n')
        ; // Eat comment.
      }

    current_input_column = 1;
    lexer_flags.quote_is_transpose = 0;
    lexer_flags.cant_be_identifier = 0;
    lexer_flags.convert_spaces_to_comma = 1;

    if (nesting_level.none ())
      return '\n';
    else if (nesting_level.is_brace ())
      return ';';
  }
      YY_BREAK

// Other operators.

case 26:
YY_RULE_SETUP
#line 562 "lex.l"
{ BIN_OP_RETURN (EPLUS, 0); }
      YY_BREAK
case 27:
YY_RULE_SETUP
#line 563 "lex.l"
{ BIN_OP_RETURN (EMINUS, 0); }
      YY_BREAK
case 28:
YY_RULE_SETUP
#line 564 "lex.l"
{ BIN_OP_RETURN (EMUL, 0); }
      YY_BREAK
case 29:
YY_RULE_SETUP
#line 565 "lex.l"
{ BIN_OP_RETURN (EDIV, 0); }
      YY_BREAK
case 30:
YY_RULE_SETUP
#line 566 "lex.l"
{ BIN_OP_RETURN (ELEFTDIV, 0); }
      YY_BREAK
case 31:
YY_RULE_SETUP
#line 567 "lex.l"
{ BIN_OP_RETURN (EPOW, 0); }
      YY_BREAK
case 32:
YY_RULE_SETUP
#line 568 "lex.l"
{ do_comma_insert_check (); BIN_OP_RETURN (TRANSPOSE, 1); }
      YY_BREAK
case 33:
YY_RULE_SETUP
#line 569 "lex.l"
{ do_comma_insert_check (); BIN_OP_RETURN (PLUS_PLUS, 1); }
      YY_BREAK
case 34:
YY_RULE_SETUP
#line 570 "lex.l"
{ do_comma_insert_check (); BIN_OP_RETURN (MINUS_MINUS, 1); }
      YY_BREAK
case 35:
YY_RULE_SETUP
#line 571 "lex.l"
{ BIN_OP_RETURN (EXPR_LE, 0); }
      YY_BREAK
case 36:
YY_RULE_SETUP
#line 572 "lex.l"
{ BIN_OP_RETURN (EXPR_EQ, 0); }
      YY_BREAK
case 37:
YY_RULE_SETUP
#line 573 "lex.l"
{ BIN_OP_RETURN (EXPR_NE, 0); }
      YY_BREAK
case 38:
YY_RULE_SETUP
#line 574 "lex.l"
{ BIN_OP_RETURN (EXPR_GE, 0); }
      YY_BREAK
case 39:
YY_RULE_SETUP
#line 575 "lex.l"
{ BIN_OP_RETURN (EXPR_OR, 0); }
      YY_BREAK
case 40:
YY_RULE_SETUP
#line 576 "lex.l"
{ BIN_OP_RETURN (EXPR_AND, 0); }
      YY_BREAK
case 41:
YY_RULE_SETUP
#line 577 "lex.l"
{ BIN_OP_RETURN (EXPR_LT, 0); }
      YY_BREAK
case 42:
YY_RULE_SETUP
#line 578 "lex.l"
{ BIN_OP_RETURN (EXPR_GT, 0); }
      YY_BREAK
case 43:
YY_RULE_SETUP
#line 579 "lex.l"
{ BIN_OP_RETURN ('*', 0); }
      YY_BREAK
case 44:
YY_RULE_SETUP
#line 580 "lex.l"
{ BIN_OP_RETURN ('/', 0); }
      YY_BREAK
case 45:
YY_RULE_SETUP
#line 581 "lex.l"
{ BIN_OP_RETURN (LEFTDIV, 0); }
      YY_BREAK
case 46:
YY_RULE_SETUP
#line 582 "lex.l"
{ BIN_OP_RETURN (';', 1); }
      YY_BREAK
case 47:
YY_RULE_SETUP
#line 583 "lex.l"
{ BIN_OP_RETURN (',', 1); }
      YY_BREAK
case 48:
YY_RULE_SETUP
#line 584 "lex.l"
{ BIN_OP_RETURN (POW, 0); }
      YY_BREAK
case 49:
YY_RULE_SETUP
#line 585 "lex.l"
{ BIN_OP_RETURN ('=', 1); }
      YY_BREAK
case 50:
YY_RULE_SETUP
#line 586 "lex.l"
{ BIN_OP_RETURN (EXPR_OR_OR, 0); }
      YY_BREAK
case 51:
YY_RULE_SETUP
#line 587 "lex.l"
{ BIN_OP_RETURN (EXPR_AND_AND, 0); }
      YY_BREAK
case 52:
YY_RULE_SETUP
#line 589 "lex.l"
{
    if (lexer_flags.plotting && ! lexer_flags.in_plot_range)
      lexer_flags.past_plot_range = 1;
    BIN_OP_RETURN (EXPR_NOT, 0);
  }
      YY_BREAK
case 53:
YY_RULE_SETUP
#line 595 "lex.l"
{ 
    if (lexer_flags.plotting && ! lexer_flags.in_plot_range)
      lexer_flags.past_plot_range = 1;
    BIN_OP_RETURN ('+', 0);
  }
      YY_BREAK
case 54:
YY_RULE_SETUP
#line 601 "lex.l"
{ 
    if (lexer_flags.plotting && ! lexer_flags.in_plot_range)
      lexer_flags.past_plot_range = 1;
    BIN_OP_RETURN ('-', 0);
  }
      YY_BREAK
case 55:
YY_RULE_SETUP
#line 607 "lex.l"
{
    if (lexer_flags.plotting && ! lexer_flags.in_plot_range)
      lexer_flags.past_plot_range = 1;
    nesting_level.paren ();
    promptflag--;
    TOK_RETURN ('(');
  }
      YY_BREAK
case 56:
YY_RULE_SETUP
#line 615 "lex.l"
{
    nesting_level.remove ();

    current_input_column++;
    lexer_flags.cant_be_identifier = 1;
    lexer_flags.quote_is_transpose = 1;
    lexer_flags.convert_spaces_to_comma = nesting_level.is_brace ();
    do_comma_insert_check ();
    return ')';
  }
      YY_BREAK
case 57:
YY_RULE_SETUP
#line 626 "lex.l"
{
    TOK_RETURN ('.');
  }
      YY_BREAK

// Unrecognized input is a lexical error.

case 58:
YY_RULE_SETUP
#line 634 "lex.l"
{
    current_input_column++;

    error ("invalid character `%s' near line %d, column %d",
         undo_string_escape (yytext[0]), input_line_number,
         current_input_column);

    return LEXICAL_ERROR;
  }
      YY_BREAK
case 59:
YY_RULE_SETUP
#line 644 "lex.l"
ECHO;
      YY_BREAK

      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;

      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 >= 201 )
                        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 >= 201 )
                  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 == 200);

      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;


      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 _Win32
#include <unistd.h>
#else
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int ));
#endif
#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 644 "lex.l"


// GAG.
//
// If we're reading a matrix and the next character is '[', make sure
// that we insert a comma ahead of it.

void
do_comma_insert_check (void)
{
  int spc_gobbled = eat_continuation ();
  int c = yyinput ();
  yyunput (c, yytext);
  if (spc_gobbled)
    yyunput (' ', yytext);
  lexer_flags.do_comma_insert = (lexer_flags.braceflag && c == '[');
}

// Fix things up for errors or interrupts.  The parser is never called
// recursively, so it is always safe to reinitialize its state before
// doing any parsing.

void
reset_parser (void)
{
  // Start off on the right foot.
  BEGIN 0;
  error_state = 0;

  // We do want a prompt by default.
  promptflag = 1;

  // Error may have occurred inside some parentheses or braces.
  nesting_level.clear ();

  // Clear out the stack of token info used to track line and column
  // numbers.
  while (! token_stack.empty ())
    delete token_stack.pop ();

  // Can be reset by defining a function.
  if (! (reading_script_file || reading_fcn_file))
    {
      current_input_column = 1;
      input_line_number = current_command_number - 1;
    }

  // Only ask for input from stdin if we are expecting interactive
  // input.
  if ((interactive || forced_interactive)
      && ! (reading_fcn_file || get_input_from_eval_string
          || input_from_startup_file))
    yyrestart (stdin);

  // Clear the buffer for help text.
  help_buf.resize (0);

  // Reset other flags.
  lexer_flags.init ();
}

// If we read some newlines, we need figure out what column we're
// really looking at.

static void
fixup_column_count (char *s)
{
  char c;
  while ((c = *s++) != '\0')
    {
      if (c == '\n')
        current_input_column = 1;
      else
      current_input_column++;
    }
}

// Include these so that we don't have to link to libfl.a.

#ifdef yywrap
#undef yywrap
#endif
int
yywrap (void)
{
  return 1;
}

// Tell us all what the current buffer is.

YY_BUFFER_STATE
current_buffer (void)
{
  return YY_CURRENT_BUFFER;
}

// Create a new buffer.

YY_BUFFER_STATE
create_buffer (FILE *f)
{
  return yy_create_buffer (f, YY_BUF_SIZE);
}

// Start reading a new buffer.

void
switch_to_buffer (YY_BUFFER_STATE buf)
{
  yy_switch_to_buffer (buf);
}

// Delete a buffer.

void
delete_buffer (YY_BUFFER_STATE buf)
{
  yy_delete_buffer (buf);
}

// Restore a buffer (for unwind-prot).

void
restore_input_buffer (void *buf)
{
  switch_to_buffer ((YY_BUFFER_STATE) buf);
}

// Delete a buffer (for unwind-prot).

void
delete_input_buffer (void *buf)
{
  delete_buffer ((YY_BUFFER_STATE) buf);
}

// Check to see if a character string matches any of the possible line
// styles for plots.

static string
plot_style_token (const string& s)
{
  string retval;

  static char *plot_styles[] = 
    {
      "boxes",
      "boxerrorbars",
      "boxxyerrorbars",
      "candlesticks",
      "dots",
      "errorbars",
      "financebars",
      "fsteps",
      "histeps",
      "impulses",
      "lines",
      "linespoints",
      "points",
      "steps",
      "vector",
      "xerrorbars",
      "xyerrorbars",
      "yerrorbars",
      0,
    };

  char **tmp = plot_styles;
  while (*tmp)
    {
      if (almost_match (*tmp, s.c_str ()))
      {
        retval = *tmp;
        break;
      }

      tmp++;
    }

  return retval;
}

// Check to see if a character string matches any of the possible axes
// tags for plots.

static string
plot_axes_token (const string& s)
{
  string retval;

  static char *plot_axes[] = 
    {
      "x1y1",
      "x1y2",
      "x2y1",
      "x2y2",
      0,
    };

  char **tmp = plot_axes;
  while (*tmp)
    {
      if (almost_match (*tmp, s.c_str ()))
      {
        retval = *tmp;
        break;
      }

      tmp++;
    }

  return retval;
}

// Check to see if a character string matches any one of the plot
// option keywords.  Don't match abbreviations for clear, since that's
// not a gnuplot keyword (users will probably only expect to be able
// to abbreviate actual gnuplot keywords).

static int
is_plot_keyword (const string& s)
{
  const char *t = s.c_str ();
  if (almost_match ("title", t))
    {
      return TITLE;
    }
  else if (almost_match ("using", t))
    {
      lexer_flags.in_plot_using = 1;
      return USING;
    }
  else if (almost_match ("with", t))
    {
      lexer_flags.in_plot_style = 1;
      return WITH;
    }
  else if (almost_match ("axes", t) || almost_match ("axis", t))
    {
      lexer_flags.in_plot_axes = 1;
      return AXES;
    }
  else if (strcmp ("clear", t) == 0)
    {
      return CLEAR;
    }
  else
    {
      return 0;
    }
}

// Handle keywords.  Could probably be more efficient...

static int
is_keyword (const string& s)
{
  if (lexer_flags.plotting)
    {
      if (lexer_flags.in_plot_style)
      {
        string sty = plot_style_token (s);

        if (! sty.empty ())
          {
            lexer_flags.in_plot_style = 0;
            yylval.tok_val = new token (sty);
            token_stack.push (yylval.tok_val);
            return STYLE;
          }
      }
      else if (lexer_flags.in_plot_axes)
      {
        string axes = plot_axes_token (s);

        if (! axes.empty ())
          {
            lexer_flags.in_plot_axes = 0;
            yylval.tok_val = new token (axes);
            token_stack.push (yylval.tok_val);
            return AXES_TAG;
          }
      }     
    }

  int l = input_line_number;
  int c = current_input_column;

  int len = s.length ();

  const octave_kw *kw = octave_kw_lookup (s.c_str (), len);

  if (kw)
    {
      yylval.tok_val = 0;

      switch (kw->kw_id)
      {
      case all_va_args_kw:
      case break_kw:
      case case_kw:
      case catch_kw:
      case continue_kw:
      case else_kw:
      case elseif_kw:
      case global_kw:
      case otherwise_kw:
      case return_kw:
      case unwind_protect_cleanup_kw:
        break;

      case end_kw:
        yylval.tok_val = new token (token::simple_end, l, c);
        break;

      case end_try_catch_kw:
        yylval.tok_val = new token (token::try_catch_end, l, c);
        break;

      case end_unwind_protect_kw:
        yylval.tok_val = new token (token::unwind_protect_end, l, c);
        break;

      case endfor_kw:
        yylval.tok_val = new token (token::for_end, l, c);
        break;

      case endfunction_kw:
        yylval.tok_val = new token (token::function_end, l, c);
        break;

      case endif_kw:
        yylval.tok_val = new token (token::if_end, l, c);
        break;

      case endswitch_kw:
        yylval.tok_val = new token (token::switch_end, l, c);
        break;

      case endwhile_kw:
        yylval.tok_val = new token (token::while_end, l, c);
        break;

      case for_kw:
      case while_kw:
        promptflag--;
        lexer_flags.looping++;
        break;

      case if_kw:
      case try_kw:
      case switch_kw:
      case unwind_protect_kw:
        promptflag--;
        break;

      case gplot_kw:
        lexer_flags.plotting = 1;
        yylval.tok_val = new token (token::two_dee, l, c);
        break;

      case gsplot_kw:
        lexer_flags.plotting = 1;
        yylval.tok_val = new token (token::three_dee, l, c);
        break;

      case replot_kw:
        lexer_flags.plotting = 1;
        yylval.tok_val = new token (token::replot, l, c);
        break;

      case function_kw:
        if (lexer_flags.defining_func)
          {
            error ("function keyword invalid within a function body");

            if ((reading_fcn_file || reading_script_file)
              && ! curr_fcn_file_name.empty ())
            error ("defining new function near line %d of file `%s.m'",
                   input_line_number, curr_fcn_file_name.c_str ());
            else
            error ("defining new function near line %d",
                   input_line_number);

            return LEXICAL_ERROR;
          }
        else
          {
            tmp_local_sym_tab = new symbol_table ();
            curr_sym_tab = tmp_local_sym_tab;
            lexer_flags.defining_func = 1;
            promptflag--;
            lexer_flags.beginning_of_function = 1;
            if (! (reading_fcn_file || reading_script_file))
            input_line_number = 1;
          }
        break;

        case magic_file_kw:
        {
          if ((reading_fcn_file || reading_script_file)
            && ! curr_fcn_file_full_name.empty ())
            yylval.tok_val = new token (curr_fcn_file_full_name, l, c);
          else
            yylval.tok_val = new token ("stdin", l, c);
        }
        break;

        case magic_line_kw:
        yylval.tok_val = new token ((double) l, "", l, c);
        break;

      default:
        panic_impossible ();
      }

      if (! yylval.tok_val)
      yylval.tok_val = new token (l, c);

      token_stack.push (yylval.tok_val);

      return kw->tok;
    }

  return 0;
}

// Try to find an identifier.  All binding to global or builtin
// variables occurs when expressions are evaluated.

static symbol_record *
lookup_identifier (const string& name)
{
  return curr_sym_tab->lookup (name, 1, 0);
}

static bool
is_variable (const string& name)
{
  symbol_record *sr = curr_sym_tab->lookup (name, 0, 0);

  return sr && sr->is_variable ();
}

static void
force_local_variable (const string& name)
{
  symbol_record *sr = curr_sym_tab->lookup (name, 1, 0);

  if (sr)
    sr->define (octave_value ());
}

// Grab the help text from an function file.  Always overwrites the
// current contents of help_buf.

// XXX FIXME XXX -- gobble_leading_white_space() in variables.cc
// duplicates some of this code!

static void
grab_help_text (void)
{
  help_buf.resize (0);

  bool begin_comment = true;
  bool in_comment = true;
  int c = 0;

  while ((c = yyinput ()) != EOF)
    {
      if (begin_comment)
      {
        if (c == '%' || c == '#')
          continue;
        else
          begin_comment = false;
      }     

      if (in_comment)
      {
        help_buf += (char) c;

        if (c == '\n')
          in_comment = false;
      }
      else
      {
        switch (c)
          {
          case '%':
          case '#':
            in_comment = true;
            begin_comment = true;
            break;

          case ' ':
          case '\t':
            break;

          default:
            goto done;
          }
      }
    }

 done:

  if (c)
    yyunput (c, yytext);
}

// Return 1 if the given character matches any character in the given
// string.

static int
match_any (char c, char *s)
{
  char tmp;
  while ((tmp = *s++) != '\0')
    {
      if (c == tmp)
      return 1;
    }
  return 0;
}

// Given information about the spacing surrounding an operator,
// return 1 if it looks like it should be treated as a binary
// operator.  For example,
//
//   [ 1 + 2 ]  or  [ 1+ 2]  or  [ 1+2 ]  ==> binary

static int
looks_like_bin_op (int spc_prev, int spc_next)
{
  return ((spc_prev && spc_next) || ! spc_prev);
}

// Recognize separators.  If the separator is a CRLF pair, it is
// replaced by a single LF.

static int
next_token_is_sep_op (void)
{
  int retval = 0;

  int c1 = yyinput ();

  if (c1 == '\r')
    {
      int c2 = yyinput ();

      if (c2 == '\n')
      {
        c1 = '\n';

        retval = true;
      }
      else
      unput (c2);
    }
  else
    retval = match_any (c1, ",;\n]");

  unput (c1);

  return retval;
}

// Try to determine if the next token should be treated as a postfix
// unary operator.  This is ugly, but it seems to do the right thing.

static int
next_token_is_postfix_unary_op (int spc_prev, char *yytext)
{
  int un_op = 0;

  int c0 = yyinput ();
  int c1 = yyinput ();

  yyunput (c1, yytext);
  yyunput (c0, yytext);

  int transpose = (c0 == '.' && c1 == '\'');
  int hermitian = (c0 == '\'');

  un_op = (transpose || (hermitian && ! spc_prev));

  return un_op;
}

// Try to determine if the next token should be treated as a binary
// operator.  This is even uglier, but it also seems to do the right
// thing.  Note that it is only necessary to check the spacing for `+'
// and `-', since those are the only tokens that can appear as unary
// ops too.
//
// Note that this never returns true for `.', even though it can be a
// binary operator (the structure reference thing).  The only time
// this appears to matter is for things like
//
//   [ a . b ]
//
// which probably doesn't occur that often, can be worked around by
// eliminating the whitespace, putting the expression in parentheses,
// or using `whitespace_in_literal_matrix = "ignored"', so I think it
// is an acceptable change.  It would be quite a bit harder to `fix'
// this.  (Well, maybe not.  the best fix would be to do away with the
// specialness of whitespace inside of `[ ... ]').
//
// However, we still do check for `.+', `.*', etc.

static int
next_token_is_bin_op (int spc_prev, char *yytext)
{
  int bin_op = 0;

  int c0 = yyinput ();

  switch (c0)
    {
    case '+':
    case '-':
      {
      int c1 = yyinput ();
      yyunput (c1, yytext);
      int spc_next = (c1 == ' ' || c1 == '\t');
      bin_op = looks_like_bin_op (spc_prev, spc_next);
      }
      break;

    case '.':
      {
      int c1 = yyinput ();
      yyunput (c1, yytext);
      bin_op = match_any (c1, "+-*/\\^");
      }
      break;

    case '/':
    case ':':
    case '\\':
    case '^':
    case '&':
    case '*':
    case '|':
    case '<':
    case '>':
    case '~':
    case '!':
    case '=':
      bin_op = 1;
      break;

    default:
      break;
    }

  yyunput (c0, yytext);

  return bin_op;
}

// Used to delete trailing white space from tokens.

static string
strip_trailing_whitespace (char *s)
{
  string retval = s;

  size_t pos = retval.find_first_of (" \t");

  if (pos != NPOS)
    retval.resize (pos);

  return retval;
}

// Discard whitespace, including comments and continuations.
//
// Return value is logical OR of the following values:
//
//  ATE_NOTHING      : no spaces to eat
//  ATE_SPACE_OR_TAB : space or tab in input
//  ATE_NEWLINE      : bare new line in input

static yum_yum
eat_whitespace (void)
{
  yum_yum retval = ATE_NOTHING;
  int in_comment = 0;
  int c;
  while ((c = yyinput ()) != EOF)
    {
      current_input_column++;

      switch (c)
      {
      case ' ':
      case '\t':
        retval |= ATE_SPACE_OR_TAB;
        break;

      case '\n':
        retval |= ATE_NEWLINE;
        in_comment = 0;
        current_input_column = 0;
        break;

      case '#':
      case '%':
        in_comment = 1;
        break;

      case '.':
        if (in_comment)
          break;
        else
          {
            if (have_ellipsis_continuation ())
            break;
            else
            goto done;
          }

      case '\\':
        if (in_comment)
          break;
        else
          {
            if (have_continuation ())
            break;
            else
            goto done;
          }

      default:
        if (in_comment)
          break;
        else
          goto done;
      }
    }

 done:
  yyunput (c, yytext);
  current_input_column--;
  return retval;
}

static inline bool
looks_like_hex (const char *s, int len)
{
  return (len > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X'));
}

static void
handle_number (char *yytext)
{
  double value = 0.0;
  int nread = 0;

  if (looks_like_hex (yytext, strlen (yytext)))
    {
      unsigned long ival;

      nread = sscanf (yytext, "%lx", &ival);

      value = static_cast<double> (ival);
    }
  else
    {
      char *tmp = strsave (yytext);

      char *idx = strpbrk (tmp, "Dd");

      if (idx)
      *idx = 'e';

      nread = sscanf (tmp, "%lf", &value);

      delete [] tmp;
    }

  // If yytext doesn't contain a valid number, we are in deep doo doo.

  assert (nread == 1);

  lexer_flags.quote_is_transpose = 1;
  lexer_flags.cant_be_identifier = 1;
  lexer_flags.convert_spaces_to_comma = 1;

  if (lexer_flags.plotting && ! lexer_flags.in_plot_range)
    lexer_flags.past_plot_range = 1;

  yylval.tok_val = new token (value, yytext, input_line_number,
                        current_input_column);

  token_stack.push (yylval.tok_val);

  current_input_column += yyleng;

  do_comma_insert_check ();
}

// We have seen a backslash and need to find out if it should be
// treated as a continuation character.  If so, this eats it, up to
// and including the new line character.
//
// Match whitespace only, followed by a comment character or newline.
// Once a comment character is found, discard all input until newline.
// If non-whitespace characters are found before comment
// characters, return 0.  Otherwise, return 1.

static int
have_continuation (int trailing_comments_ok)
{
  ostrstream buf;

  int in_comment = 0;
  int c;
  while ((c = yyinput ()) != EOF)
    {
      buf << (char) c;

      switch (c)
      {
      case ' ':
      case '\t':
        break;

      case '%':
      case '#':
        if (trailing_comments_ok)
          in_comment = 1;
        else
          goto cleanup;
        break;

      case '\n':
        current_input_column = 0;
        promptflag--;
        return 1;

      case '\r':
        c = yyinput ();
        if (c == EOF)
          break;
        else if (c == '\n')
          {
            current_input_column = 0;
            promptflag--;
            return 1;
          }   

      default:
        if (! in_comment)
          goto cleanup;
        break;
      }
    }

  yyunput (c, yytext);
  return 0;

 cleanup:
  buf << ends;
  char *s = buf.str ();
  if (s)
    {
      int len = strlen (s);
      while (len--)
      yyunput (s[len], yytext);
    }
  delete [] s;
  return 0;
}

// We have seen a `.' and need to see if it is the start of a
// continuation.  If so, this eats it, up to and including the new
// line character.

static int
have_ellipsis_continuation (int trailing_comments_ok)
{
  char c1 = yyinput ();
  if (c1 == '.')
    {
      char c2 = yyinput ();
      if (c2 == '.' && have_continuation (trailing_comments_ok))
      return 1;
      else
      {
        yyunput (c2, yytext);
        yyunput (c1, yytext);
      }
    }
  else
    yyunput (c1, yytext);

  return 0;
}

// See if we have a continuation line.  If so, eat it and the leading
// whitespace on the next line.
//
// Return value is the same as described for eat_whitespace().

static yum_yum
eat_continuation (void)
{
  int retval = ATE_NOTHING;
  int c = yyinput ();
  if ((c == '.' && have_ellipsis_continuation ())
      || (c == '\\' && have_continuation ()))
    retval = eat_whitespace ();
  else
    yyunput (c, yytext);

  return retval;
}

static int
handle_string (char delim, int text_style)
{
  ostrstream buf;

  int c;
  int escape_pending = 0;

  while ((c = yyinput ()) != EOF)
    {
      current_input_column++;

      if (c == '\\')
      {
        if (escape_pending)
          {
            buf << (char) c;
            escape_pending = 0;
          }
        else
          {
            if (have_continuation (0))
            escape_pending = 0;
            else
            {
              buf << (char) c;
              escape_pending = 1;
            }
          }
        continue;
      }
      else if (c == '.')
      {
        if (! have_ellipsis_continuation (0))
          buf << (char) c;
      }
      else if (c == '\n')
      {
        error ("unterminated string constant");
        break;
      }
      else if (c == delim)
      {
        if (escape_pending)
          buf << (char) c;
        else
          {
            c = yyinput ();
            if (c == delim)
            buf << (char) c;
            else
            {
              yyunput (c, yytext);
              buf << ends;
              char *t = buf.str ();
              string s = do_string_escapes (t);
              delete [] t;

              if (text_style && lexer_flags.doing_set)
                {
                  s = string (1, delim) + s + string (1, delim);
                }
              else
                {
                  lexer_flags.quote_is_transpose = 1;
                  lexer_flags.cant_be_identifier = 1;
                  lexer_flags.convert_spaces_to_comma = 1;
                }

              yylval.tok_val = new token (s);
              token_stack.push (yylval.tok_val);
              return TEXT;
            }
          }
      }
      else
      {
        buf << (char) c;
      }

      escape_pending = 0;
    }

  return LEXICAL_ERROR;
}

static int
handle_close_brace (int spc_gobbled)
{
  if (! nesting_level.none ())
    {
      nesting_level.remove ();
      lexer_flags.braceflag--;
    }

  if (lexer_flags.braceflag == 0)
    BEGIN 0;

  int c1 = yyinput ();
  if (c1 == '=')
    {
      lexer_flags.quote_is_transpose = 0;
      lexer_flags.cant_be_identifier = 0;
      lexer_flags.convert_spaces_to_comma = 1;

      int c2 = yyinput ();
      unput (c2);
      unput (c1);

      if (c2 != '=' && lexer_flags.maybe_screwed_again)
      return SCREW_TWO;
      else
      return ']';
    }
  else
    {
      unput (c1);

      if (lexer_flags.braceflag && Vwhitespace_in_literal_matrix != 2)
      {
        int bin_op = next_token_is_bin_op (spc_gobbled, yytext);

        int postfix_un_op = next_token_is_postfix_unary_op
          (spc_gobbled, yytext);

        int sep_op = next_token_is_sep_op ();

        if (! (postfix_un_op || bin_op || sep_op)
            && nesting_level.is_brace ()
            && lexer_flags.convert_spaces_to_comma)
          {
            unput (',');
            return ']';
          }
      }
    }

  lexer_flags.quote_is_transpose = 1;
  lexer_flags.cant_be_identifier = 0;
  lexer_flags.convert_spaces_to_comma = 1;
  return ']';
}

static void
maybe_unput_comma (int spc_gobbled)
{
  if (Vwhitespace_in_literal_matrix != 2
      && nesting_level.is_brace ())
    {
      int bin_op = next_token_is_bin_op (spc_gobbled, yytext);

      int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled,
                                            yytext);

      int c1 = yyinput ();
      int c2 = yyinput ();

      unput (c2);
      unput (c1);

      int sep_op = next_token_is_sep_op ();

      int dot_op = (c1 == '.'
                && (isalpha (c2) || isspace (c2) || c2 == '_'));

      int index_op = (c1 == '('
                  && (Vwhitespace_in_literal_matrix == 0
                    || ! spc_gobbled));

      if (! (postfix_un_op || bin_op || sep_op || dot_op || index_op))
      unput (',');
    }
}

// Figure out exactly what kind of token to return when we have seen
// an identifier.  Handles keywords.

static int
handle_identifier (const string& tok, int spc_gobbled)
{
  // It is almost always an error for an identifier to be followed
  // directly by another identifier.  Special cases are handled
  // below.

  lexer_flags.cant_be_identifier = 1;

  // If we are expecting a structure element, we just want to return
  // TEXT_ID, which is a string that is also a valid identifier.  But
  // first, we have to decide whether to insert a comma.

  if (lexer_flags.looking_at_indirect_ref)
    {
      maybe_unput_comma (spc_gobbled);

      yylval.tok_val = new token (tok, input_line_number,
                          current_input_column);

      token_stack.push (yylval.tok_val);

      lexer_flags.cant_be_identifier = 0;
      lexer_flags.quote_is_transpose = 1;
      lexer_flags.convert_spaces_to_comma = 1;

      current_input_column += yyleng;

      return TEXT_ID;
    }

  // If we have a regular keyword, or a plot STYLE, return it.
  // Keywords can be followed by identifiers (TOK_RETURN handles
  // that).

  int kw_token = is_keyword (tok);
  if (kw_token)
    {
      if (kw_token == STYLE)
      {
        current_input_column += yyleng;
        lexer_flags.quote_is_transpose = 0;
        lexer_flags.convert_spaces_to_comma = 1;
        return kw_token;
      }
      else
      TOK_RETURN (kw_token);
    }

  // See if we have a plot keyword (title, using, with, or clear).

  if (lexer_flags.plotting)
    {
      // Yes, we really do need both of these plot_range variables.
      // One is used to mark when we are past all possiblity of a plot
      // range, the other is used to mark when we are actually between
      // the square brackets that surround the range.

      if (! lexer_flags.in_plot_range)
      lexer_flags.past_plot_range = 1;

      // Option keywords can't appear in parentheses or braces.

      int plot_option_kw = 0;
      if (nesting_level.none ())
      plot_option_kw = is_plot_keyword (tok);

      if (lexer_flags.cant_be_identifier && plot_option_kw)
      TOK_RETURN (plot_option_kw);
    }

  int c = yyinput ();
  yyunput (c, yytext);
  bool next_tok_is_eq = (c == '=');
  bool next_tok_is_paren = (c == '(');

  // Make sure we put the return values of a function in the symbol
  // table that is local to the function.

  if (next_tok_is_eq
      && lexer_flags.defining_func && lexer_flags.maybe_screwed)
    curr_sym_tab = tmp_local_sym_tab;

  // Kluge alert.
  //
  // If we are looking at a text style function, set up to gobble its
  // arguments.
  //
  // If the following token is `=', or if we are parsing a function
  // return list or function parameter list, or if we are looking at
  // something like [ab,cd] = foo (), force the symbol to be inserted
  // as a variable in the current symbol table.

  if (is_text_function_name (tok) && ! is_variable (tok))
    {
      if (next_tok_is_eq
        || lexer_flags.maybe_screwed_again
        || lexer_flags.looking_at_return_list
        || lexer_flags.looking_at_parameter_list)
      {
        force_local_variable (tok);
      }
      else if (! next_tok_is_paren)
      {
        if (tok == "gset")
          lexer_flags.doing_set = 1;

        BEGIN TEXT_FCN;
      }
    }

  // Find the token in the symbol table.

  yylval.tok_val = new token (lookup_identifier (tok),
                        input_line_number,
                        current_input_column);

  token_stack.push (yylval.tok_val);

  // After seeing an identifer, it is ok to convert spaces to a comma
  // (if needed).

  lexer_flags.convert_spaces_to_comma = 1;

  // If we are defining a function and we have not seen the parameter
  // list yet and the next token is `=', return a token that
  // represents the only return value for the function.  For example,
  //
  //   function SCREW = f (args);
  //
  // The variable maybe_screwed is reset in parse.y.

  if (next_tok_is_eq)
    {
      current_input_column += yyleng;
      if (lexer_flags.defining_func && lexer_flags.maybe_screwed)
      return SCREW;
      else
      return NAME;
    }

  // At this point, we are only dealing with identifiers that are not
  // followed by `=' (if the next token is `=', there is no need to
  // check to see if we should insert a comma (invalid syntax), or
  // allow a following `'' to be treated as a transpose (the next
  // token is `=', so it can't be `''.

  lexer_flags.quote_is_transpose = 1;
  do_comma_insert_check ();

  maybe_unput_comma (spc_gobbled);

  current_input_column += yyleng;
  return NAME;
}

// Print a warning if a function file that defines a function has
// anything other than comments and whitespace following the END token
// that matches the FUNCTION statement.

void
check_for_garbage_after_fcn_def (void)
{
  // By making a newline be the next character to be read, we will
  // force the parser to return after reading the function.  Calling
  // yyunput with EOF seems not to work...

  int in_comment = 0;
  int lineno = input_line_number;
  int c;
  while ((c = yyinput ()) != EOF)
    {
      switch (c)
      {
      case ' ':
      case '\t':
      case ';':
      case ',':
        break;

      case '\n':
        if (in_comment)
          in_comment = 0;
        break;

      case '%':
      case '#':
        in_comment = 1;
        break;

      default:
        if (in_comment)
          break;
        else
          {
            warning ("ignoring trailing garbage after end of function\n\
         near line %d of file `%s.m'", lineno, curr_fcn_file_name.c_str ());
            
            yyunput ('\n', yytext);
            return;
          }
      }
    }
  yyunput ('\n', yytext);
}

void
lexical_feedback::init (void)
{
  // Not initially defining a function.
  beginning_of_function = 0;
  defining_func = 0;

  // Not parsing a function return or parameter list.
  looking_at_return_list = 0;
  looking_at_parameter_list = 0;

  // Not initially defining a matrix list.
  braceflag = 0;

  // Next token can be identifier.
  cant_be_identifier = 0;

  // No need to do comma insert or convert spaces to comma at
  // beginning of input. 
  convert_spaces_to_comma = 1;
  do_comma_insert = 0;

  // Not initially doing any plotting or setting of plot attributes.
  doing_set = 0;
  in_plot_range = 0;
  in_plot_style = 0;
  in_plot_axes = 0;
  in_plot_using = 0;
  past_plot_range = 0;
  plotting = 0;

  // Not initially inside a loop or if statement.
  looping = 0;

  // Not initially looking at indirect references.
  looking_at_indirect_ref = 0;

  // Not initially screwed by `function [...] = f (...)' syntax.
  maybe_screwed = 0;
  maybe_screwed_again = 0;

  // Quote marks strings intially.
  quote_is_transpose = 0;
}

int
whitespace_in_literal_matrix (void)
{
  int pref = 0;
  string val = builtin_string_variable ("whitespace_in_literal_matrix");
  if (! val.empty ())
    {
      if (val.compare ("ignore", 0, 6) == 0)
      pref = 2;
      else if (val.compare ("traditional", 0, 11) == 0)
      pref = 1;
    }
  Vwhitespace_in_literal_matrix = pref;
  return 0;
}

void
symbols_of_lex (void)
{
  DEFVAR (whitespace_in_literal_matrix, "", 0, whitespace_in_literal_matrix,
    "control auto-insertion of commas and semicolons in literal matrices");
}

// Maybe someday...
//
// "+="           return ADD_EQ;
// "-="           return SUB_EQ;
// "*="           return MUL_EQ;
// "/="           return DIV_EQ;
// "\\="    return LEFTDIV_EQ;
// ".+="    return ADD_EQ;
// ".-="    return SUB_EQ;
// ".*="    return EMUL_EQ;
// "./="    return EDIV_EQ;
// ".\\="   return ELEFTDIV_EQ;

/*
;;; Local Variables: ***
;;; mode: C++ ***
;;; End: ***
*/

Generated by  Doxygen 1.6.0   Back to index