/* A Bison parser, made by GNU Bison 1.875d.  */

/* Skeleton parser for Yacc-like parsing with Bison,
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.  */

/* As a special exception, when this file is copied by Bison into a
   Bison output file, you may use that output file without restriction.
   This special exception was added by the Free Software Foundation
   in version 1.24 of Bison.  */

/* Written by Richard Stallman by simplifying the original so called
   ``semantic'' parser.  */

/* All symbols defined below should begin with yy or YY, to avoid
   infringing on user name space.  This should be done even for local
   variables, as they might otherwise be expanded by user macros.
   There are some unavoidable exceptions within include files to
   define necessary library symbols; they are noted "INFRINGES ON
   USER NAME SPACE" below.  */

/* Identify Bison output.  */
#define YYBISON 1

/* Skeleton name.  */
#define YYSKELETON_NAME "yacc.c"

/* Pure parsers.  */
#define YYPURE 0

/* Using locations.  */
#define YYLSP_NEEDED 0

/* If NAME_PREFIX is specified substitute the variables and functions
   names.  */
#define yyparse octave_parse
#define yylex   octave_lex
#define yyerror octave_error
#define yylval  octave_lval
#define yychar  octave_char
#define yydebug octave_debug
#define yynerrs octave_nerrs


/* Tokens.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
   /* Put the tokens into the symbol table, so that GDB and other debuggers
      know about them.  */
   enum yytokentype {
     ADD_EQ = 258,
     SUB_EQ = 259,
     MUL_EQ = 260,
     DIV_EQ = 261,
     LEFTDIV_EQ = 262,
     POW_EQ = 263,
     EMUL_EQ = 264,
     EDIV_EQ = 265,
     ELEFTDIV_EQ = 266,
     EPOW_EQ = 267,
     AND_EQ = 268,
     OR_EQ = 269,
     LSHIFT_EQ = 270,
     RSHIFT_EQ = 271,
     LSHIFT = 272,
     RSHIFT = 273,
     EXPR_AND_AND = 274,
     EXPR_OR_OR = 275,
     EXPR_AND = 276,
     EXPR_OR = 277,
     EXPR_NOT = 278,
     EXPR_LT = 279,
     EXPR_LE = 280,
     EXPR_EQ = 281,
     EXPR_NE = 282,
     EXPR_GE = 283,
     EXPR_GT = 284,
     LEFTDIV = 285,
     EMUL = 286,
     EDIV = 287,
     ELEFTDIV = 288,
     EPLUS = 289,
     EMINUS = 290,
     QUOTE = 291,
     TRANSPOSE = 292,
     PLUS_PLUS = 293,
     MINUS_MINUS = 294,
     POW = 295,
     EPOW = 296,
     NUM = 297,
     IMAG_NUM = 298,
     STRUCT_ELT = 299,
     NAME = 300,
     END = 301,
     PLOT = 302,
     STRING = 303,
     STYLE = 304,
     AXES_TAG = 305,
     FOR = 306,
     WHILE = 307,
     DO = 308,
     UNTIL = 309,
     IF = 310,
     ELSEIF = 311,
     ELSE = 312,
     SWITCH = 313,
     CASE = 314,
     OTHERWISE = 315,
     BREAK = 316,
     CONTINUE = 317,
     FUNC_RET = 318,
     UNWIND = 319,
     CLEANUP = 320,
     TRY = 321,
     CATCH = 322,
     GLOBAL = 323,
     STATIC = 324,
     FCN_HANDLE = 325,
     END_OF_INPUT = 326,
     LEXICAL_ERROR = 327,
     FCN = 328,
     VARARGIN = 329,
     VARARGOUT = 330,
     ALL_VA_ARGS = 331,
     USING = 332,
     TITLE = 333,
     WITH = 334,
     AXES = 335,
     COLON = 336,
     OPEN_BRACE = 337,
     CLOSE_BRACE = 338,
     CLEAR = 339,
     UNARY = 340
   };
#endif
#define ADD_EQ 258
#define SUB_EQ 259
#define MUL_EQ 260
#define DIV_EQ 261
#define LEFTDIV_EQ 262
#define POW_EQ 263
#define EMUL_EQ 264
#define EDIV_EQ 265
#define ELEFTDIV_EQ 266
#define EPOW_EQ 267
#define AND_EQ 268
#define OR_EQ 269
#define LSHIFT_EQ 270
#define RSHIFT_EQ 271
#define LSHIFT 272
#define RSHIFT 273
#define EXPR_AND_AND 274
#define EXPR_OR_OR 275
#define EXPR_AND 276
#define EXPR_OR 277
#define EXPR_NOT 278
#define EXPR_LT 279
#define EXPR_LE 280
#define EXPR_EQ 281
#define EXPR_NE 282
#define EXPR_GE 283
#define EXPR_GT 284
#define LEFTDIV 285
#define EMUL 286
#define EDIV 287
#define ELEFTDIV 288
#define EPLUS 289
#define EMINUS 290
#define QUOTE 291
#define TRANSPOSE 292
#define PLUS_PLUS 293
#define MINUS_MINUS 294
#define POW 295
#define EPOW 296
#define NUM 297
#define IMAG_NUM 298
#define STRUCT_ELT 299
#define NAME 300
#define END 301
#define PLOT 302
#define STRING 303
#define STYLE 304
#define AXES_TAG 305
#define FOR 306
#define WHILE 307
#define DO 308
#define UNTIL 309
#define IF 310
#define ELSEIF 311
#define ELSE 312
#define SWITCH 313
#define CASE 314
#define OTHERWISE 315
#define BREAK 316
#define CONTINUE 317
#define FUNC_RET 318
#define UNWIND 319
#define CLEANUP 320
#define TRY 321
#define CATCH 322
#define GLOBAL 323
#define STATIC 324
#define FCN_HANDLE 325
#define END_OF_INPUT 326
#define LEXICAL_ERROR 327
#define FCN 328
#define VARARGIN 329
#define VARARGOUT 330
#define ALL_VA_ARGS 331
#define USING 332
#define TITLE 333
#define WITH 334
#define AXES 335
#define COLON 336
#define OPEN_BRACE 337
#define CLOSE_BRACE 338
#define CLEAR 339
#define UNARY 340




/* Copy the first part of user declarations.  */
#line 27 "parse.y"

#define YYDEBUG 1

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <cassert>
#include <cstdio>

#ifdef YYBYACC
#include <cstdlib>
#endif

#include "Cell.h"
#include "Matrix.h"
#include "cmd-edit.h"
#include "cmd-hist.h"
#include "file-ops.h"
#include "file-stat.h"
#include "lo-sstream.h"
#include "oct-env.h"
#include "oct-time.h"
#include "quit.h"

#include "comment-list.h"
#include "defaults.h"
#include "defun.h"
#include "dirfns.h"
#include "dynamic-ld.h"
#include "error.h"
#include "input.h"
#include "lex.h"
#include "oct-hist.h"
#include "ov-fcn-handle.h"
#include "ov-usr-fcn.h"
#include "toplev.h"
#include "pager.h"
#include "parse.h"
#include "pt-all.h"
#include "symtab.h"
#include "token.h"
#include "unwind-prot.h"
#include "utils.h"
#include "variables.h"

// If TRUE, generate a warning for the assignment in things like
//
//   octave> if (a = 2 < n)
//
// but not
//
//   octave> if ((a = 2) < n)
//
static bool Vwarn_assign_as_truth_value;

// If TRUE, generate warning about the meaning of code changing due to
// changes in associativity for various ops (typically for Matlab
// compatibility).
static bool Vwarn_associativity_change;

// If TRUE, generate warning if declared function name disagrees with
// the name of the file in which it is defined.
static bool Vwarn_function_name_clash;

// TRUE means warn about function files that have time stamps in the future.
bool Vwarn_future_time_stamp;

// If TRUE, generate warning if a statement in a function is not
// terminated with a semicolon.  Useful for checking functions that
// should only produce output using explicit printing statements.
static bool Vwarn_missing_semicolon;

// If TRUE, generate warning about the meaning of code changing due to
// changes in precedence levels for various ops (typically for Matlab
// compatibility).
static bool Vwarn_precedence_change;

// If TRUE, generate a warning for variable switch labels.
static bool Vwarn_variable_switch_label;

// Temporary symbol table pointer used to cope with bogus function syntax.
symbol_table *tmp_local_sym_tab = 0;

// The current input line number.
int input_line_number = 0;

// The column of the current token.
int current_input_column = 1;

// Buffer for help text snagged from function files.
std::stack<std::string> help_buf;

// Buffer for comments appearing before a function statement.
static std::string fcn_comment_header;

// TRUE means we are using readline.
// (--no-line-editing)
bool line_editing = true;

// TRUE means we printed messages about reading startup files.
bool reading_startup_message_printed = false;

// TRUE means input is coming from startup file.
bool input_from_startup_file = false;

// TRUE means that input is coming from a file that was named on
// the command line.
bool input_from_command_line_file = true;

// TRUE means that we are in the process of evaluating a function
// body.  The parser might be called in that case if we are looking at
// an eval() statement.
bool evaluating_function_body = false;

// Keep a count of how many END tokens we expect.
int end_tokens_expected = 0;

// Keep track of symbol table information when parsing functions.
std::stack<symbol_table*> symtab_context;

// Name of parent function when parsing function files that might
// contain nested functions.
std::string parent_function_name;

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

// Generic error messages.
static void
yyerror (const char *s);

// Error mesages for mismatched end tokens.
static void
end_error (const char *type, token::end_tok_type ettype, int l, int c);

// Check to see that end tokens are properly matched.
static bool
end_token_ok (token *tok, token::end_tok_type expected);

// Print a warning if we are looking at a "replot" command with
// arguments.
static void
maybe_warn_replot_with_args (token *tok);

// Maybe print a warning if an assignment expression is used as the
// test in a logical expression.
static void
maybe_warn_assign_as_truth_value (tree_expression *expr);

// Maybe print a warning about switch labels that aren't constants.
static void
maybe_warn_variable_switch_label (tree_expression *expr);

// Create a plot command.
static tree_plot_command *
make_plot_command (token *tok, plot_limits *range, subplot_list *list);

// Finish building a range.
static tree_expression *
finish_colon_expression (tree_colon_expression *e);

// Build a constant.
static tree_constant *
make_constant (int op, token *tok_val);

// Build a function handle.
static tree_fcn_handle *
make_fcn_handle (token *tok_val);

// Build an anonymous function handle.
static tree_constant *
make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt);

// Build a binary expression.
static tree_expression *
make_binary_op (int op, tree_expression *op1, token *tok_val,
		tree_expression *op2);

// Build a boolean expression.
static tree_expression *
make_boolean_op (int op, tree_expression *op1, token *tok_val,
		 tree_expression *op2);

// Build a prefix expression.
static tree_expression *
make_prefix_op (int op, tree_expression *op1, token *tok_val);

// Build a postfix expression.
static tree_expression *
make_postfix_op (int op, tree_expression *op1, token *tok_val);

// Build an unwind-protect command.
static tree_command *
make_unwind_command (token *unwind_tok, tree_statement_list *body,
		     tree_statement_list *cleanup, token *end_tok,
		     octave_comment_list *lc, octave_comment_list *mc);

// Build a try-catch command.
static tree_command *
make_try_command (token *try_tok, tree_statement_list *body,
		  tree_statement_list *cleanup, token *end_tok,
		  octave_comment_list *lc, octave_comment_list *mc);

// Build a while command.
static tree_command *
make_while_command (token *while_tok, tree_expression *expr,
		    tree_statement_list *body, token *end_tok,
		    octave_comment_list *lc);

// Build a do-until command.
static tree_command *
make_do_until_command (token *do_tok, tree_statement_list *body,
		       tree_expression *expr, octave_comment_list *lc);

// Build a for command.
static tree_command *
make_for_command (token *for_tok, tree_argument_list *lhs,
		  tree_expression *expr, tree_statement_list *body,
		  token *end_tok, octave_comment_list *lc);

// Build a break command.
static tree_command *
make_break_command (token *break_tok);

// Build a continue command.
static tree_command *
make_continue_command (token *continue_tok);

// Build a return command.
static tree_command *
make_return_command (token *return_tok);

// Start an if command.
static tree_if_command_list *
start_if_command (tree_expression *expr, tree_statement_list *list);

// Finish an if command.
static tree_if_command *
finish_if_command (token *if_tok, tree_if_command_list *list,
		   token *end_tok, octave_comment_list *lc);

// Build an elseif clause.
static tree_if_clause *
make_elseif_clause (tree_expression *expr, tree_statement_list *list,
		    octave_comment_list *lc);

// Finish a switch command.
static tree_switch_command *
finish_switch_command (token *switch_tok, tree_expression *expr,
		       tree_switch_case_list *list, token *end_tok,
		       octave_comment_list *lc);

// Build a switch case.
static tree_switch_case *
make_switch_case (tree_expression *expr, tree_statement_list *list,
		  octave_comment_list *lc);

// Build an assignment to a variable.
static tree_expression *
make_assign_op (int op, tree_argument_list *lhs, token *eq_tok,
		tree_expression *rhs);

// Begin defining a function.
static octave_user_function *
start_function (tree_parameter_list *param_list, tree_statement_list *body);

// Do most of the work for defining a function.
static octave_user_function *
frob_function (const std::string& fname, octave_user_function *fcn);

// Finish defining a function.
static octave_user_function *
finish_function (tree_identifier *id, octave_user_function *fcn,
		 octave_comment_list *lc);

// Finish defining a function a different way.
static octave_user_function *
finish_function (tree_parameter_list *ret_list,
		 octave_user_function *fcn, octave_comment_list *lc);

// Reset state after parsing function.
static void
recover_from_parsing_function (void);

// Make an index expression.
static tree_index_expression *
make_index_expression (tree_expression *expr,
		       tree_argument_list *args, char type);

// Make an indirect reference expression.
static tree_index_expression *
make_indirect_ref (tree_expression *expr, const std::string&);

// Make an indirect reference expression with dynamic field name.
static tree_index_expression *
make_indirect_ref (tree_expression *expr, tree_expression *field);

// Make a declaration command.
static tree_decl_command *
make_decl_command (int tok, token *tok_val, tree_decl_init_list *lst);

// Finish building a matrix list.
static tree_expression *
finish_matrix (tree_matrix *m);

// Finish building a cell list.
static tree_expression *
finish_cell (tree_cell *c);

// Maybe print a warning.  Duh.
static void
maybe_warn_missing_semi (tree_statement_list *);

// Set the print flag for a statement based on the separator type.
static void
set_stmt_print_flag (tree_statement_list *, char, bool);

#define ABORT_PARSE \
  do \
    { \
      global_command = 0; \
      yyerrok; \
      if (! symtab_context.empty ()) \
        { \
	  curr_sym_tab = symtab_context.top (); \
	  symtab_context.pop (); \
        } \
      if (interactive || forced_interactive) \
	YYACCEPT; \
      else \
	YYABORT; \
    } \
  while (0)



/* Enabling traces.  */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif

/* Enabling verbose error messages.  */
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif

#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 372 "parse.y"
typedef union YYSTYPE {
  // The type of the basic tokens returned by the lexer.
  token *tok_val;

  // Comment strings that we need to deal with mid-rule.
  octave_comment_list *comment_type;

  // Types for the nonterminals we generate.
  char sep_type;
  tree *tree_type;
  tree_matrix *tree_matrix_type;
  tree_cell *tree_cell_type;
  tree_expression *tree_expression_type;
  tree_constant *tree_constant_type;
  tree_fcn_handle *tree_fcn_handle_type;
  tree_identifier *tree_identifier_type;
  tree_index_expression *tree_index_expression_type;
  tree_colon_expression *tree_colon_expression_type;
  tree_argument_list *tree_argument_list_type;
  tree_parameter_list *tree_parameter_list_type;
  tree_command *tree_command_type;
  tree_if_command *tree_if_command_type;
  tree_if_clause *tree_if_clause_type;
  tree_if_command_list *tree_if_command_list_type;
  tree_switch_command *tree_switch_command_type;
  tree_switch_case *tree_switch_case_type;
  tree_switch_case_list *tree_switch_case_list_type;
  tree_decl_elt *tree_decl_elt_type;
  tree_decl_init_list *tree_decl_init_list_type;
  tree_decl_command *tree_decl_command_type;
  tree_statement *tree_statement_type;
  tree_statement_list *tree_statement_list_type;
  tree_plot_command *tree_plot_command_type;
  subplot *subplot_type;
  subplot_list *subplot_list_type;
  plot_limits *plot_limits_type;
  plot_range *plot_range_type;
  subplot_using *subplot_using_type;
  subplot_style *subplot_style_type;
  subplot_axes *subplot_axes_type;
  octave_user_function *octave_user_function_type;
} YYSTYPE;
/* Line 191 of yacc.c.  */
#line 635 "y.tab.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif



/* Copy the second part of user declarations.  */


/* Line 214 of yacc.c.  */
#line 647 "y.tab.c"

#if ! defined (yyoverflow) || YYERROR_VERBOSE

# ifndef YYFREE
#  define YYFREE free
# endif
# ifndef YYMALLOC
#  define YYMALLOC malloc
# endif

/* The parser invokes alloca or malloc; define the necessary symbols.  */

# ifdef YYSTACK_USE_ALLOCA
#  if YYSTACK_USE_ALLOCA
#   define YYSTACK_ALLOC alloca
#  endif
# else
#  if defined (alloca) || defined (_ALLOCA_H)
#   define YYSTACK_ALLOC alloca
#  else
#   ifdef __GNUC__
#    define YYSTACK_ALLOC __builtin_alloca
#   endif
#  endif
# endif

# ifdef YYSTACK_ALLOC
   /* Pacify GCC's `empty if-body' warning. */
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
# else
#  if defined (__STDC__) || defined (__cplusplus)
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
#   define YYSIZE_T size_t
#  endif
#  define YYSTACK_ALLOC YYMALLOC
#  define YYSTACK_FREE YYFREE
# endif
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */


#if (! defined (yyoverflow) \
     && (! defined (__cplusplus) \
	 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))

/* A type that is properly aligned for any stack member.  */
union yyalloc
{
  short int yyss;
  YYSTYPE yyvs;
  };

/* The size of the maximum gap between one aligned stack and the next.  */
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)

/* The size of an array large to enough to hold all stacks, each with
   N elements.  */
# define YYSTACK_BYTES(N) \
     ((N) * (sizeof (short int) + sizeof (YYSTYPE))			\
      + YYSTACK_GAP_MAXIMUM)

/* Copy COUNT objects from FROM to TO.  The source and destination do
   not overlap.  */
# ifndef YYCOPY
#  if defined (__GNUC__) && 1 < __GNUC__
#   define YYCOPY(To, From, Count) \
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
#  else
#   define YYCOPY(To, From, Count)		\
      do					\
	{					\
	  register YYSIZE_T yyi;		\
	  for (yyi = 0; yyi < (Count); yyi++)	\
	    (To)[yyi] = (From)[yyi];		\
	}					\
      while (0)
#  endif
# endif

/* Relocate STACK from its old location to the new one.  The
   local variables YYSIZE and YYSTACKSIZE give the old and new number of
   elements in the stack, and YYPTR gives the new location of the
   stack.  Advance YYPTR to a properly aligned location for the next
   stack.  */
# define YYSTACK_RELOCATE(Stack)					\
    do									\
      {									\
	YYSIZE_T yynewbytes;						\
	YYCOPY (&yyptr->Stack, Stack, yysize);				\
	Stack = &yyptr->Stack;						\
	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
	yyptr += yynewbytes / sizeof (*yyptr);				\
      }									\
    while (0)

#endif

#if defined (__STDC__) || defined (__cplusplus)
   typedef signed char yysigned_char;
#else
   typedef short int yysigned_char;
#endif

/* YYFINAL -- State number of the termination state. */
#define YYFINAL  111
/* YYLAST -- Last index in YYTABLE.  */
#define YYLAST   1213

/* YYNTOKENS -- Number of terminals. */
#define YYNTOKENS  103
/* YYNNTS -- Number of nonterminals. */
#define YYNNTS  94
/* YYNRULES -- Number of rules. */
#define YYNRULES  254
/* YYNRULES -- Number of states. */
#define YYNSTATES  429

/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
#define YYUNDEFTOK  2
#define YYMAXUTOK   340

#define YYTRANSLATE(YYX) 						\
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)

/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
static const unsigned char yytranslate[] =
{
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      93,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      95,   102,     7,     6,    92,     5,    96,     8,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     4,    91,
       2,     3,     2,     2,   101,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,    98,     2,    99,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,    97,     2,   100,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       2,     2,     2,     2,     2,     2,     1,     2,     9,    10,
      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
      21,    22,    23,    24,    25,    26,    27,    28,    29,    30,
      31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
      41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
      51,    52,    53,    54,    55,    56,    57,    58,    59,    60,
      61,    62,    63,    64,    65,    66,    67,    68,    69,    70,
      71,    72,    73,    74,    75,    76,    77,    78,    79,    80,
      81,    82,    83,    84,    85,    86,    87,    88,    89,    90,
      94
};

#if YYDEBUG
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
   YYRHS.  */
static const unsigned short int yyprhs[] =
{
       0,     0,     3,     5,     8,    10,    12,    14,    16,    19,
      22,    25,    27,    31,    32,    34,    37,    39,    43,    45,
      47,    50,    52,    54,    56,    58,    59,    62,    66,    71,
      73,    76,    78,    82,    85,    89,    93,    95,    98,   100,
     104,   106,   109,   112,   116,   118,   120,   122,   124,   126,
     130,   132,   134,   136,   138,   142,   146,   150,   152,   153,
     154,   156,   161,   167,   172,   178,   183,   188,   193,   198,
     204,   212,   216,   218,   221,   224,   227,   230,   233,   237,
     241,   245,   249,   253,   257,   261,   265,   269,   273,   277,
     281,   283,   285,   289,   291,   295,   299,   303,   307,   311,
     315,   319,   323,   327,   331,   335,   339,   341,   346,   350,
     354,   358,   362,   366,   370,   374,   378,   382,   386,   390,
     394,   398,   402,   406,   409,   411,   414,   416,   418,   420,
     422,   424,   426,   428,   430,   432,   434,   436,   439,   442,
     444,   447,   449,   453,   455,   457,   462,   464,   467,   471,
     474,   481,   486,   493,   494,   496,   499,   501,   504,   511,
     516,   523,   530,   539,   550,   552,   554,   556,   566,   576,
     577,   578,   579,   580,   582,   584,   588,   591,   592,   594,
     596,   600,   602,   606,   610,   613,   617,   619,   623,   629,
     631,   635,   638,   643,   646,   650,   654,   658,   661,   664,
     667,   669,   673,   675,   677,   679,   683,   686,   689,   693,
     695,   698,   702,   708,   713,   718,   722,   725,   727,   731,
     733,   736,   738,   740,   742,   744,   747,   750,   753,   756,
     759,   761,   764,   767,   771,   774,   777,   781,   786,   787,
     789,   791,   793,   795,   798,   801,   802,   804,   806,   808,
     810,   813,   816,   819,   820
};

/* YYRHS -- A `-1'-separated list of the rules' RHS. */
static const short int yyrhs[] =
{
     104,     0,    -1,   105,    -1,   106,   192,    -1,   192,    -1,
      93,    -1,    77,    -1,   106,    -1,   106,    93,    -1,   106,
      77,    -1,   107,   194,    -1,   111,    -1,   107,   193,   111,
      -1,    -1,   109,    -1,   110,   196,    -1,   111,    -1,   110,
     195,   111,    -1,   140,    -1,   141,    -1,    53,    90,    -1,
      51,    -1,    48,    -1,    49,    -1,    54,    -1,    -1,    98,
      99,    -1,    98,    91,    99,    -1,    98,   114,   116,    99,
      -1,   117,    -1,   117,    91,    -1,   121,    -1,   117,    91,
     121,    -1,    97,   100,    -1,    97,    91,   100,    -1,    97,
     119,   100,    -1,   120,    -1,   120,    91,    -1,   121,    -1,
     120,    91,   121,    -1,   126,    -1,   126,    92,    -1,   101,
      76,    -1,   101,   165,   111,    -1,   112,    -1,   113,    -1,
     122,    -1,   115,    -1,   118,    -1,    95,   140,   102,    -1,
       4,    -1,   140,    -1,   125,    -1,    82,    -1,   126,    92,
     125,    -1,   126,    92,   140,    -1,   126,    92,    82,    -1,
      96,    -1,    -1,    -1,   124,    -1,   130,   128,    95,   102,
      -1,   130,   128,    95,   126,   102,    -1,   130,   128,    97,
     100,    -1,   130,   128,    97,   126,   100,    -1,   130,   128,
      44,   129,    -1,   130,   128,    45,   129,    -1,   130,   128,
      42,   129,    -1,   130,   128,    43,   129,    -1,   130,   128,
     127,   129,    50,    -1,   130,   128,   127,   129,    95,   140,
     102,    -1,   130,   128,   129,    -1,   132,    -1,    44,   131,
      -1,    45,   131,    -1,    29,   131,    -1,     6,   131,    -1,
       5,   131,    -1,   131,    46,   131,    -1,   131,    47,   131,
      -1,   131,     6,   131,    -1,   131,     5,   131,    -1,   131,
       7,   131,    -1,   131,     8,   131,    -1,   131,    40,   131,
      -1,   131,    41,   131,    -1,   131,    37,   131,    -1,   131,
      38,   131,    -1,   131,    36,   131,    -1,   131,    39,   131,
      -1,   134,    -1,   131,    -1,   134,     4,   131,    -1,   133,
      -1,   135,    23,   135,    -1,   135,    24,   135,    -1,   135,
      30,   135,    -1,   135,    31,   135,    -1,   135,    32,   135,
      -1,   135,    34,   135,    -1,   135,    35,   135,    -1,   135,
      33,   135,    -1,   135,    27,   135,    -1,   135,    28,   135,
      -1,   135,    25,   135,    -1,   135,    26,   135,    -1,   135,
      -1,    98,   114,   126,    89,    -1,   136,     3,   140,    -1,
     136,     9,   140,    -1,   136,    10,   140,    -1,   136,    11,
     140,    -1,   136,    12,   140,    -1,   136,    13,   140,    -1,
     136,    14,   140,    -1,   136,    21,   140,    -1,   136,    22,
     140,    -1,   136,    15,   140,    -1,   136,    16,   140,    -1,
     136,    17,   140,    -1,   136,    18,   140,    -1,   136,    19,
     140,    -1,   136,    20,   140,    -1,   112,   139,    -1,    54,
      -1,   139,    54,    -1,   135,    -1,   138,    -1,   137,    -1,
     123,    -1,   142,    -1,   145,    -1,   156,    -1,   157,    -1,
     158,    -1,   173,    -1,   180,    -1,    74,   143,    -1,    75,
     143,    -1,   144,    -1,   143,   144,    -1,   112,    -1,   112,
       3,   140,    -1,   146,    -1,   151,    -1,    61,   191,   147,
      52,    -1,   148,    -1,   148,   150,    -1,   140,   196,   108,
      -1,   148,   149,    -1,    62,   191,   196,   140,   196,   108,
      -1,    63,   191,   196,   108,    -1,    64,   191,   140,   196,
     152,    52,    -1,    -1,   153,    -1,   153,   155,    -1,   154,
      -1,   153,   154,    -1,    65,   191,   196,   140,   196,   108,
      -1,    66,   191,   196,   108,    -1,    58,   191,   140,   196,
     108,    52,    -1,    59,   191,   196,   108,    60,   140,    -1,
      57,   191,   136,     3,   140,   196,   108,    52,    -1,    57,
     191,    95,   136,     3,   140,   102,   196,   108,    52,    -1,
      67,    -1,    68,    -1,    69,    -1,    70,   191,   196,   108,
      71,   191,   196,   108,    52,    -1,    72,   191,   196,   108,
      73,   191,   196,   108,    52,    -1,    -1,    -1,    -1,    -1,
      95,    -1,   102,    -1,   163,   166,   164,    -1,   163,     1,
      -1,    -1,   167,    -1,    80,    -1,   167,    92,    80,    -1,
     112,    -1,   167,    92,   112,    -1,    98,   162,   161,    -1,
     168,   171,    -1,   168,    81,   171,    -1,    81,    -1,   168,
     170,   171,    -1,   168,   170,    92,    81,   171,    -1,   112,
      -1,   170,    92,   112,    -1,   160,    99,    -1,   159,    79,
     160,   191,    -1,   172,   176,    -1,   172,   112,   174,    -1,
     172,   169,   174,    -1,   160,     3,   176,    -1,   112,   161,
      -1,   175,   177,    -1,   165,   178,    -1,   178,    -1,   196,
     108,   179,    -1,    52,    -1,    77,    -1,    53,    -1,    53,
      95,   102,    -1,    53,   181,    -1,    53,   183,    -1,    53,
     181,   183,    -1,   182,    -1,   182,   182,    -1,   182,   182,
     182,    -1,    88,   140,    87,   140,    89,    -1,    88,    87,
     140,    89,    -1,    88,   140,    87,    89,    -1,    88,    87,
      89,    -1,    88,    89,    -1,   184,    -1,   183,    92,   184,
      -1,   140,    -1,   140,   185,    -1,   187,    -1,   189,    -1,
     190,    -1,   186,    -1,   185,   187,    -1,   185,   189,    -1,
     185,   190,    -1,   185,   186,    -1,    86,    56,    -1,   188,
      -1,   188,   140,    -1,    83,   140,    -1,   188,    87,   140,
      -1,    84,   140,    -1,    85,    55,    -1,    85,    55,   140,
      -1,    85,    55,   140,   140,    -1,    -1,    78,    -1,     1,
      -1,    92,    -1,    91,    -1,   193,    92,    -1,   193,    91,
      -1,    -1,   193,    -1,    92,    -1,    91,    -1,    93,    -1,
     195,    92,    -1,   195,    91,    -1,   195,    93,    -1,    -1,
     195,    -1
};

/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
static const unsigned short int yyrline[] =
{
       0,   514,   514,   520,   522,   526,   528,   533,   535,   537,
     541,   548,   550,   559,   560,   564,   571,   576,   584,   591,
     598,   614,   621,   623,   625,   631,   634,   636,   638,   645,
     647,   651,   653,   660,   662,   664,   668,   670,   674,   676,
     684,   686,   690,   697,   701,   703,   705,   707,   709,   711,
     715,   722,   724,   726,   732,   737,   742,   751,   763,   767,
     770,   772,   777,   782,   787,   792,   794,   796,   798,   800,
     802,   806,   808,   810,   812,   814,   816,   818,   822,   824,
     826,   828,   830,   832,   834,   836,   838,   840,   842,   844,
     848,   852,   854,   861,   863,   865,   867,   869,   871,   873,
     875,   877,   879,   881,   883,   885,   892,   894,   901,   903,
     905,   907,   909,   911,   913,   915,   917,   919,   921,   923,
     925,   927,   929,   933,   937,   942,   950,   952,   954,   956,
     964,   966,   968,   970,   972,   974,   976,   984,   986,   990,
     992,   999,  1001,  1009,  1011,  1019,  1026,  1028,  1035,  1037,
    1044,  1048,  1058,  1066,  1067,  1069,  1076,  1078,  1085,  1089,
    1099,  1104,  1109,  1114,  1125,  1130,  1135,  1146,  1152,  1165,
    1169,  1173,  1177,  1184,  1201,  1205,  1210,  1219,  1220,  1225,
    1231,  1239,  1241,  1252,  1255,  1260,  1267,  1274,  1279,  1287,
    1289,  1296,  1303,  1307,  1313,  1319,  1327,  1331,  1346,  1357,
    1359,  1363,  1367,  1372,  1387,  1392,  1397,  1403,  1409,  1417,
    1419,  1421,  1425,  1427,  1429,  1431,  1433,  1437,  1439,  1446,
    1448,  1452,  1457,  1462,  1467,  1472,  1480,  1488,  1496,  1506,
    1513,  1518,  1525,  1530,  1534,  1538,  1540,  1542,  1551,  1554,
    1556,  1559,  1561,  1563,  1565,  1570,  1571,  1575,  1577,  1579,
    1581,  1583,  1585,  1590,  1591
};
#endif

#if YYDEBUG || YYERROR_VERBOSE
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
  "$end", "error", "$undefined", "'='", "':'", "'-'", "'+'", "'*'", "'/'",
  "ADD_EQ", "SUB_EQ", "MUL_EQ", "DIV_EQ", "LEFTDIV_EQ", "POW_EQ",
  "EMUL_EQ", "EDIV_EQ", "ELEFTDIV_EQ", "EPOW_EQ", "AND_EQ", "OR_EQ",
  "LSHIFT_EQ", "RSHIFT_EQ", "LSHIFT", "RSHIFT", "EXPR_AND_AND",
  "EXPR_OR_OR", "EXPR_AND", "EXPR_OR", "EXPR_NOT", "EXPR_LT", "EXPR_LE",
  "EXPR_EQ", "EXPR_NE", "EXPR_GE", "EXPR_GT", "LEFTDIV", "EMUL", "EDIV",
  "ELEFTDIV", "EPLUS", "EMINUS", "QUOTE", "TRANSPOSE", "PLUS_PLUS",
  "MINUS_MINUS", "POW", "EPOW", "NUM", "IMAG_NUM", "STRUCT_ELT", "NAME",
  "END", "PLOT", "STRING", "STYLE", "AXES_TAG", "FOR", "WHILE", "DO",
  "UNTIL", "IF", "ELSEIF", "ELSE", "SWITCH", "CASE", "OTHERWISE", "BREAK",
  "CONTINUE", "FUNC_RET", "UNWIND", "CLEANUP", "TRY", "CATCH", "GLOBAL",
  "STATIC", "FCN_HANDLE", "END_OF_INPUT", "LEXICAL_ERROR", "FCN",
  "VARARGIN", "VARARGOUT", "ALL_VA_ARGS", "USING", "TITLE", "WITH", "AXES",
  "COLON", "OPEN_BRACE", "CLOSE_BRACE", "CLEAR", "';'", "','", "'\\n'",
  "UNARY", "'('", "'.'", "'{'", "'['", "']'", "'}'", "'@'", "')'",
  "$accept", "input", "input1", "simple_list", "simple_list1", "opt_list",
  "list", "list1", "statement", "identifier", "constant",
  "in_matrix_or_assign_lhs", "matrix", "matrix_rows", "matrix_rows1",
  "cell", "cell_rows", "cell_rows1", "cell_or_matrix_row", "fcn_handle",
  "anon_fcn_handle", "primary_expr", "magic_colon", "arg_list",
  "indirect_ref_op", "begin_obj_idx", "cancel_obj_idx", "postfix_expr",
  "prefix_expr", "binary_expr", "colon_expr", "colon_expr1", "simple_expr",
  "assign_lhs", "assign_expr", "word_list_cmd", "word_list", "expression",
  "command", "declaration", "decl1", "decl2", "select_command",
  "if_command", "if_cmd_list", "if_cmd_list1", "elseif_clause",
  "else_clause", "switch_command", "case_list", "case_list1",
  "switch_case", "default_case", "loop_command", "jump_command",
  "except_command", "save_symtab", "function_symtab", "local_symtab",
  "in_return_list", "param_list_beg", "param_list_end", "param_list",
  "param_list1", "param_list2", "return_list_beg", "return_list",
  "return_list1", "return_list_end", "function_beg", "function",
  "function1", "fcn_name", "function2", "function3", "function4",
  "function_end", "plot_command", "ranges", "ranges1", "plot_command1",
  "plot_command2", "plot_options", "axes", "using", "using1", "title",
  "style", "stash_comment", "parse_error", "sep_no_nl", "opt_sep_no_nl",
  "sep", "opt_sep", 0
};
#endif

# ifdef YYPRINT
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
   token YYLEX-NUM.  */
static const unsigned short int yytoknum[] =
{
       0,   256,   257,    61,    58,    45,    43,    42,    47,   258,
     259,   260,   261,   262,   263,   264,   265,   266,   267,   268,
     269,   270,   271,   272,   273,   274,   275,   276,   277,   278,
     279,   280,   281,   282,   283,   284,   285,   286,   287,   288,
     289,   290,   291,   292,   293,   294,   295,   296,   297,   298,
     299,   300,   301,   302,   303,   304,   305,   306,   307,   308,
     309,   310,   311,   312,   313,   314,   315,   316,   317,   318,
     319,   320,   321,   322,   323,   324,   325,   326,   327,   328,
     329,   330,   331,   332,   333,   334,   335,   336,   337,   338,
     339,    59,    44,    10,   340,    40,    46,   123,    91,    93,
     125,    64,    41
};
# endif

/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
static const unsigned char yyr1[] =
{
       0,   103,   104,   104,   104,   105,   105,   105,   105,   105,
     106,   107,   107,   108,   108,   109,   110,   110,   111,   111,
     111,   112,   113,   113,   113,   114,   115,   115,   115,   116,
     116,   117,   117,   118,   118,   118,   119,   119,   120,   120,
     121,   121,   122,   123,   124,   124,   124,   124,   124,   124,
     125,   126,   126,   126,   126,   126,   126,   127,   128,   129,
     130,   130,   130,   130,   130,   130,   130,   130,   130,   130,
     130,   131,   131,   131,   131,   131,   131,   131,   132,   132,
     132,   132,   132,   132,   132,   132,   132,   132,   132,   132,
     133,   134,   134,   135,   135,   135,   135,   135,   135,   135,
     135,   135,   135,   135,   135,   135,   136,   136,   137,   137,
     137,   137,   137,   137,   137,   137,   137,   137,   137,   137,
     137,   137,   137,   138,   139,   139,   140,   140,   140,   140,
     141,   141,   141,   141,   141,   141,   141,   142,   142,   143,
     143,   144,   144,   145,   145,   146,   147,   147,   148,   148,
     149,   150,   151,   152,   152,   152,   153,   153,   154,   155,
     156,   156,   156,   156,   157,   157,   157,   158,   158,   159,
     160,   161,   162,   163,   164,   165,   165,   166,   166,   166,
     166,   167,   167,   168,   169,   169,   169,   169,   169,   170,
     170,   171,   172,   173,   173,   173,   174,   175,   176,   177,
     177,   178,   179,   179,   180,   180,   180,   180,   180,   181,
     181,   181,   182,   182,   182,   182,   182,   183,   183,   184,
     184,   185,   185,   185,   185,   185,   185,   185,   185,   186,
     187,   187,   188,   188,   189,   190,   190,   190,   191,   192,
     192,   193,   193,   193,   193,   194,   194,   195,   195,   195,
     195,   195,   195,   196,   196
};

/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
static const unsigned char yyr2[] =
{
       0,     2,     1,     2,     1,     1,     1,     1,     2,     2,
       2,     1,     3,     0,     1,     2,     1,     3,     1,     1,
       2,     1,     1,     1,     1,     0,     2,     3,     4,     1,
       2,     1,     3,     2,     3,     3,     1,     2,     1,     3,
       1,     2,     2,     3,     1,     1,     1,     1,     1,     3,
       1,     1,     1,     1,     3,     3,     3,     1,     0,     0,
       1,     4,     5,     4,     5,     4,     4,     4,     4,     5,
       7,     3,     1,     2,     2,     2,     2,     2,     3,     3,
       3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
       1,     1,     3,     1,     3,     3,     3,     3,     3,     3,
       3,     3,     3,     3,     3,     3,     1,     4,     3,     3,
       3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
       3,     3,     3,     2,     1,     2,     1,     1,     1,     1,
       1,     1,     1,     1,     1,     1,     1,     2,     2,     1,
       2,     1,     3,     1,     1,     4,     1,     2,     3,     2,
       6,     4,     6,     0,     1,     2,     1,     2,     6,     4,
       6,     6,     8,    10,     1,     1,     1,     9,     9,     0,
       0,     0,     0,     1,     1,     3,     2,     0,     1,     1,
       3,     1,     3,     3,     2,     3,     1,     3,     5,     1,
       3,     2,     4,     2,     3,     3,     3,     2,     2,     2,
       1,     3,     1,     1,     1,     3,     2,     2,     3,     1,
       2,     3,     5,     4,     4,     3,     2,     1,     3,     1,
       2,     1,     1,     1,     1,     2,     2,     2,     2,     2,
       1,     2,     2,     3,     2,     2,     3,     4,     0,     1,
       1,     1,     1,     2,     2,     0,     1,     1,     1,     1,
       2,     2,     2,     0,     1
};

/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
   means the default is an error.  */
static const unsigned char yydefact[] =
{
       0,   240,     0,     0,     0,     0,     0,    22,    23,    21,
     204,    24,   238,   238,   238,   238,   238,   164,   165,   166,
     238,   238,     0,     0,     6,   239,     5,     0,     0,    25,
       0,     0,     2,     0,   245,    11,    44,    45,    47,    48,
      46,   129,    60,    58,    91,    72,    93,    90,   126,     0,
     128,   127,    18,    19,   130,   131,   143,   144,   132,   133,
     134,     0,     0,   135,   136,     4,    25,     0,    44,    77,
      76,    75,    73,    74,     0,    20,     0,   219,   206,   209,
     207,   217,     0,     0,   253,     0,     0,   253,   253,   141,
     137,   139,   138,     0,    50,    53,     0,    33,     0,    36,
      38,    52,    40,    51,     0,    26,     0,    42,   173,     0,
     169,     1,     9,     8,     3,   242,   241,   246,    10,   124,
     123,    59,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,     0,   170,   186,   172,   171,   170,   170,   253,   193,
       0,     0,   216,     0,   205,     0,     0,     0,     0,   220,
     224,   221,   230,   222,   223,   208,   210,     0,     0,   106,
       0,   253,   248,   247,   249,   254,    13,   253,     0,   146,
     253,    13,    13,     0,   140,    49,    34,    35,    37,    41,
      27,     0,    29,    31,    40,   176,   179,   181,     0,   178,
      43,   244,   243,    12,   125,    59,    59,    59,    59,     0,
      57,     0,    59,    71,    81,    80,    82,    83,    88,    86,
      87,    89,    84,    85,    78,    79,    92,    94,    95,   104,
     105,   102,   103,    96,    97,    98,   101,    99,   100,   108,
     109,   110,   111,   112,   113,   114,   117,   118,   119,   120,
     121,   122,   115,   116,   238,   171,     0,   197,   194,   170,
     189,     0,   170,   184,   195,   253,   198,   200,    13,   215,
       0,     0,   232,   234,   235,   229,   228,   225,   226,   227,
       0,   231,   211,   218,     0,     0,    13,   251,   250,   252,
       0,    14,   253,    16,    13,   145,   238,   238,   149,   147,
     153,     0,     0,   142,    39,    56,    54,    55,    28,    30,
     107,   174,   175,     0,    67,    68,    65,    66,    61,     0,
      63,     0,     0,   192,   183,     0,   185,   191,     0,   187,
     199,     0,   213,   214,     0,   236,   233,     0,   253,     0,
       0,   254,    15,   148,   253,   253,   238,     0,   154,   156,
     238,   238,    32,   180,   182,     0,    62,    64,    69,     0,
     171,   196,   170,   190,   202,   203,   201,   212,   237,     0,
      13,   160,   161,    17,     0,    13,   253,   152,   238,   157,
     155,   253,   253,     0,   188,   253,     0,   253,   151,     0,
     253,    13,    13,    70,    13,   162,    13,   253,    13,     0,
       0,     0,   150,    13,   159,   167,   168,   163,   158
};

/* YYDEFGOTO[NTERM-NUM]. */
static const short int yydefgoto[] =
{
      -1,    31,    32,    33,    34,   310,   311,   312,   313,    36,
      37,   106,    38,   211,   212,    39,    98,    99,   213,    40,
      41,    42,   101,   102,   232,   121,   233,    43,    44,    45,
      46,    47,    48,    49,    50,    51,   120,    52,    53,    54,
      90,    91,    55,    56,   198,   199,   318,   319,    57,   367,
     368,   369,   400,    58,    59,    60,    61,   281,   277,   275,
     109,   332,   110,   218,   219,   166,   167,   282,   283,    62,
      63,   278,   168,   169,   286,   287,   386,    64,    78,    79,
      80,    81,   179,   180,   181,   182,   183,   184,    82,    65,
     117,   118,   195,   288
};

/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
   STATE-NUM.  */
#define YYPACT_NINF -267
static const short int yypact[] =
{
     395,  -267,  1009,  1009,  1009,  1009,  1009,  -267,  -267,  -267,
     861,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,
    -267,  -267,    -9,    -9,  -267,  -267,  -267,  1026,   493,   -59,
     -54,    65,  -267,    33,    11,  -267,    13,  -267,  -267,  -267,
    -267,  -267,  -267,  -267,   627,  -267,  -267,    93,  1131,   394,
    -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,
    -267,    30,   -37,  -267,  -267,  -267,   -59,    43,  -267,    10,
      10,    10,    10,    10,   887,  -267,   592,    69,  1026,    35,
      29,  -267,  1084,  1026,   -44,  1026,  1026,   -44,   -44,   132,
      -9,  -267,    -9,    56,  -267,  -267,    59,  -267,    63,    76,
    -267,  -267,    77,  -267,    71,  -267,   519,  -267,  -267,    18,
     827,  -267,  -267,  -267,  -267,  -267,  -267,   707,  -267,  -267,
     120,    -6,  1009,  1009,  1009,  1009,  1009,  1009,  1009,  1009,
    1009,  1009,  1009,  1009,  1009,  1009,  1009,  1009,  1009,  1009,
    1009,  1009,  1009,  1009,  1009,  1009,  1009,  1026,  1026,  1026,
    1026,  1026,  1026,  1026,  1026,  1026,  1026,  1026,  1026,  1026,
    1026,  1026,  -267,  -267,  -267,   172,   -31,  -267,   -21,  -267,
     519,   921,  -267,    89,  -267,  1026,  1026,   124,   125,    69,
    -267,  -267,   942,  -267,  -267,    29,    35,  1026,  1026,  1178,
     177,   -44,  -267,  -267,  -267,    21,   767,   -44,   130,     0,
     -44,   767,   767,  1026,  -267,  -267,  -267,  -267,   519,   574,
    -267,    84,    94,  -267,   -62,  -267,  -267,  -267,    86,    97,
    -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,   432,
    -267,   507,  -267,  -267,   262,   262,    10,    10,    10,    10,
      10,    10,   262,   262,  -267,  -267,   627,  -267,  -267,   700,
     398,   241,   307,   104,   104,   104,   104,   104,   104,  -267,
    -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,
    -267,  -267,  -267,  -267,  -267,  -267,   187,  -267,  -267,  -267,
    -267,    92,   103,  -267,  -267,   -44,  -267,  -267,   767,  -267,
     107,   997,  -267,  -267,  1026,  -267,  -267,  -267,  -267,  -267,
    1026,  -267,  -267,  -267,  1177,  1026,   767,  -267,  -267,  -267,
     137,  -267,   -44,  -267,   767,  -267,  -267,  -267,  -267,  -267,
     135,   131,   128,  -267,  -267,  -267,  -267,  -267,  -267,   519,
    -267,  -267,  -267,   -28,  -267,  -267,  -267,  -267,  -267,   -67,
    -267,   -46,   -35,  -267,  -267,    -9,  -267,  -267,   -30,  -267,
    -267,   -24,  -267,  -267,   114,  1026,  -267,  1026,   -44,   152,
    1026,   647,  -267,  -267,   -44,   -44,  -267,   154,    91,  -267,
    -267,  -267,  -267,  -267,  -267,   574,  -267,  -267,  -267,  1026,
    -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,   105,
     767,  -267,  -267,  -267,  1026,   767,   -44,  -267,  -267,  -267,
    -267,   -44,   -44,   106,  -267,   -44,   157,   -44,  -267,  1026,
     -44,   767,   767,  -267,   767,  -267,   767,   -44,   767,   158,
     160,   162,  -267,   767,  -267,  -267,  -267,  -267,  -267
};

/* YYPGOTO[NTERM-NUM].  */
static const short int yypgoto[] =
{
    -267,  -267,  -267,  -267,  -267,  -101,  -267,  -267,     5,   102,
    -267,   149,  -267,  -267,  -267,  -267,  -267,  -267,   -22,  -267,
    -267,  -267,  -202,   -95,  -267,  -267,  -133,  -267,   127,  -267,
    -267,  -267,   -58,   -70,  -267,  -267,  -267,   -10,  -267,  -267,
     193,   -47,  -267,  -267,  -267,  -267,  -267,  -267,  -267,  -267,
    -267,  -151,  -267,  -267,  -267,  -267,  -267,  -136,   -57,  -267,
    -267,  -267,    52,  -267,  -267,  -267,  -267,  -267,  -266,  -267,
    -267,    55,  -267,  -122,  -267,   -19,  -267,  -267,  -267,   -69,
     185,    80,  -267,    98,    99,  -267,   100,   101,   -12,   249,
    -267,  -267,   -27,   -29
};

/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
   positive, shift that token.  If negative, reduce the rule which
   number is the opposite.  If zero, do what YYDEFACT says.
   If YYTABLE_NINF, syntax error.  */
#define YYTABLE_NINF -178
static const short int yytable[] =
{
      77,    83,    84,    85,    86,    35,   100,   326,    87,    88,
     186,   214,   190,   346,     9,   378,   349,    93,   103,   215,
       9,     9,   107,     9,   189,   375,   274,   330,   384,   276,
     209,   276,   104,    -7,     1,   376,   225,   226,   227,   228,
     105,   108,     9,   204,   163,   204,   375,   192,   193,   194,
     279,   382,   373,   385,   377,   196,   132,   133,   201,   202,
     379,   164,   316,   317,   173,   111,    93,   119,    77,     9,
     192,   193,   194,   191,   108,   197,   200,   247,   248,   249,
     250,   251,   252,   253,   254,   255,   256,   257,   258,   229,
     230,   231,   334,   335,   336,   337,   103,   134,   216,   342,
     321,   322,   115,   116,    68,    68,    68,    68,    68,   162,
     112,    25,   307,   308,   309,   220,   404,   302,   304,   107,
    -177,   187,   223,    74,    89,    89,   113,   135,   136,    69,
      70,    71,    72,    73,   339,   203,   341,   259,   260,   261,
     262,   263,   264,   265,   266,   267,   268,   269,   270,   271,
     272,   273,   175,   176,   177,   178,   366,   398,   205,   206,
     103,   290,   306,   207,   165,   292,   293,   208,   314,   209,
     210,   320,   301,   326,   224,  -170,   291,    77,    93,   294,
     305,   295,   315,   328,    68,   329,   324,   351,   331,   333,
     345,   347,    89,   323,    89,   348,   352,   360,   103,   327,
     366,   371,   370,   387,   391,   359,   397,   405,   413,   415,
     425,   217,   426,   363,   427,   170,    92,   399,   344,   103,
     285,   103,   284,   381,    68,    68,    68,    68,    68,    68,
      68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
      68,    68,    68,    68,    68,    68,    68,    68,    68,   234,
     235,   236,   237,   238,   239,   240,   241,   242,   243,   244,
     245,   246,   343,   185,   135,   136,   350,   303,   280,   124,
     125,   141,   142,   143,   144,   145,   146,   296,   297,   298,
     299,   354,   114,   362,   355,   361,     0,     0,     0,   406,
     356,     0,     0,     0,   408,   358,     0,     0,   126,   127,
     128,   129,     0,     0,   364,   365,     0,   372,   132,   133,
     419,   420,     0,   421,     0,   422,     0,   424,     0,   103,
       0,     0,   428,     0,     0,     0,     0,     0,     0,   390,
     135,   136,     0,     0,   139,   394,   395,   141,   142,   143,
     144,   145,   146,     0,     0,   388,     0,   389,     0,     0,
     392,     0,     0,     0,   396,     0,     0,     0,   401,   402,
       0,     0,     0,     0,     0,   327,   393,   409,     0,   403,
       0,     0,   411,   412,     0,     0,   414,     0,   416,     0,
       0,   418,     0,     0,   407,     0,   410,     0,   423,     0,
       0,     0,     0,     0,     0,     0,     1,   147,     0,   417,
       2,     3,     0,   148,   149,   150,   151,   152,   153,   154,
     155,   156,   157,   158,   159,   160,   161,     0,     0,     0,
       0,   135,   136,   137,     4,   139,   140,     0,   141,   142,
     143,   144,   145,   146,     0,   374,    94,     2,     3,     5,
       6,     0,     0,     7,     8,     0,     9,   380,    10,    11,
     383,     0,    12,    13,    14,     0,    15,     0,     0,    16,
       0,     4,    17,    18,    19,    20,     0,    21,     0,    22,
      23,     0,    24,    25,  -169,     0,     5,     6,     0,     0,
       7,     8,     0,     9,     0,     0,    11,     0,    26,     0,
      27,     0,    28,    29,     0,     0,    30,    94,     2,     3,
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
       0,    94,     2,     3,    95,     0,     0,     0,     0,     0,
       0,     0,     4,    94,     2,     3,     0,    27,     0,    28,
      29,     0,     0,    30,   338,     0,     4,     5,     6,     0,
       0,     7,     8,     0,     9,     0,     0,    11,     4,     0,
       0,     5,     6,     0,     0,     7,     8,     0,     9,     0,
       0,    11,     0,     5,     6,     0,     0,     7,     8,     0,
       9,     0,     0,    11,     0,    95,     0,     0,    94,     2,
       3,     0,     0,     0,    96,     0,     0,     0,    27,    95,
      28,    29,     0,    97,    30,     0,     0,     2,     3,     0,
       0,    95,    27,     4,    28,    29,     0,   340,    30,     0,
       0,     0,     0,     0,    27,     0,    28,    29,     5,     6,
      30,     4,     7,     8,     0,     9,     0,     0,    11,     0,
       0,     0,   122,   123,   124,   125,     5,     6,     0,     0,
       7,     8,     0,     9,     0,     0,    11,     0,     0,     0,
       0,     0,     2,     3,     0,     0,   325,     0,     0,     0,
       0,     0,     0,   126,   127,   128,   129,   130,   131,    27,
       0,    28,    29,   132,   133,    30,     4,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,    27,     0,    28,
      29,     5,     6,    30,   174,     7,     8,     0,     9,     0,
      10,    11,     0,     0,    12,    13,    14,     0,    15,     0,
       0,    16,     2,     3,    17,    18,    19,    20,     0,    21,
       0,    22,    23,   135,   136,     0,  -169,   139,   140,     0,
     141,   142,   143,   144,   145,   146,     4,     0,   307,   308,
     309,     0,    27,     0,    28,    29,     0,     0,    30,     0,
       0,     5,     6,     0,     0,     7,     8,     0,     9,     0,
      10,    11,     0,     0,    12,    13,    14,     0,    15,     0,
       0,    16,     2,     3,    17,    18,    19,    20,     0,    21,
       0,    22,    23,     0,     0,     0,  -169,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     4,     0,   221,   222,
       0,     0,    27,     0,    28,    29,     0,     0,    30,     0,
       0,     5,     6,     0,     0,     7,     8,     0,     9,     0,
      10,    11,     0,     0,    12,    13,    14,     0,    15,     0,
       0,    16,     2,     3,    17,    18,    19,    20,     0,    21,
       0,    22,    23,     0,     0,     0,  -169,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     4,     0,     0,     0,
       0,     0,    27,     0,    28,    29,     2,     3,    30,     0,
       0,     5,     6,     0,     0,     7,     8,     0,     9,     0,
      10,    11,     0,     0,    12,    13,    14,     0,    15,     0,
       4,    16,     2,     3,    17,    18,    19,    20,     0,    21,
       0,    22,    23,     0,     0,     5,     6,     0,     0,     7,
       8,     0,     9,     0,     0,    11,     4,     0,     0,     0,
       0,     0,    27,     0,    28,    29,     2,     3,    30,     0,
       0,     5,     6,     0,     0,     7,     8,     0,     9,     0,
       0,    11,     0,     0,     0,     0,     0,     2,     3,    74,
       4,    75,     0,     0,     0,     0,    76,     0,    28,    29,
       0,     0,    30,     0,     0,     5,     6,     0,     0,     7,
       8,     4,     9,     0,   171,    11,   172,     0,     0,     0,
       0,     0,    27,     0,    28,    29,     5,     6,    30,     0,
       7,     8,     0,     9,     0,     0,    11,     0,     0,     0,
       0,     0,     2,     3,     0,     0,     0,     0,     0,     0,
     289,     0,     0,     0,     2,     3,    27,     0,    28,    29,
       0,     0,    30,     0,     0,     0,     4,     0,     0,   300,
       0,     2,     3,     0,     0,     0,     0,    27,     4,    28,
      29,     5,     6,    30,     0,     7,     8,     0,     9,     0,
       0,    11,     0,     5,     6,     4,     0,     7,     8,     0,
       9,     0,     0,    11,     0,     0,     0,     0,     0,     0,
       5,     6,     0,     0,     7,     8,     0,     9,     0,     0,
      11,     0,     0,     0,     0,     0,   353,     0,     0,     2,
       3,     0,    27,     0,    28,    29,     0,     0,    30,     0,
       0,     0,     0,     0,    27,     0,    28,    66,     0,     0,
      67,     0,     0,     4,     0,     0,     0,     0,     0,     0,
       0,    27,     0,    28,    29,     0,     0,    30,     5,     6,
       0,     0,     7,     8,  -106,     9,     0,     0,    11,     0,
    -106,  -106,  -106,  -106,  -106,  -106,  -106,  -106,  -106,  -106,
    -106,  -106,  -106,  -106,   135,   136,   137,   138,   139,   140,
       0,   141,   142,   143,   144,   145,   146,     0,     0,     0,
       0,     0,     0,     0,     0,     0,     0,     0,     0,   188,
     357,    28,    29,     0,     0,    67,   148,   149,   150,   151,
     152,   153,   154,   155,   156,   157,   158,   159,   160,   161,
       0,   135,   136,   137,   138,   139,   140,     0,   141,   142,
     143,   144,   145,   146
};

static const short int yycheck[] =
{
      10,    13,    14,    15,    16,     0,    28,   209,    20,    21,
      79,   106,    82,   279,    51,    50,   282,    27,    28,     1,
      51,    51,    76,    51,    82,    92,   162,    89,    52,   165,
      92,   167,    91,     0,     1,   102,    42,    43,    44,    45,
      99,    95,    51,    90,    81,    92,    92,    91,    92,    93,
      81,    81,    80,    77,   100,    84,    46,    47,    87,    88,
      95,    98,    62,    63,    74,     0,    76,    54,    78,    51,
      91,    92,    93,    83,    95,    85,    86,   135,   136,   137,
     138,   139,   140,   141,   142,   143,   144,   145,   146,    95,
      96,    97,   225,   226,   227,   228,   106,     4,    80,   232,
     201,   202,    91,    92,     2,     3,     4,     5,     6,    79,
      77,    78,    91,    92,    93,   110,   382,   186,   188,    76,
     102,    92,   117,    88,    22,    23,    93,    23,    24,     2,
       3,     4,     5,     6,   229,     3,   231,   147,   148,   149,
     150,   151,   152,   153,   154,   155,   156,   157,   158,   159,
     160,   161,    83,    84,    85,    86,    65,    66,   102,   100,
     170,   171,   191,   100,    62,   175,   176,    91,   197,    92,
      99,   200,   182,   375,    54,     3,    87,   187,   188,    55,
       3,    56,    52,    99,    82,    91,   208,   288,   102,    92,
       3,    99,    90,   203,    92,    92,    89,    60,   208,   209,
      65,    73,    71,    89,    52,   306,    52,   102,   102,    52,
      52,   109,    52,   314,    52,    66,    23,   368,   275,   229,
     168,   231,   167,   345,   122,   123,   124,   125,   126,   127,
     128,   129,   130,   131,   132,   133,   134,   135,   136,   137,
     138,   139,   140,   141,   142,   143,   144,   145,   146,   122,
     123,   124,   125,   126,   127,   128,   129,   130,   131,   132,
     133,   134,   274,    78,    23,    24,   285,   187,   166,     7,
       8,    30,    31,    32,    33,    34,    35,   179,   179,   179,
     179,   291,    33,   312,   294,   312,    -1,    -1,    -1,   390,
     300,    -1,    -1,    -1,   395,   305,    -1,    -1,    36,    37,
      38,    39,    -1,    -1,   316,   317,    -1,   329,    46,    47,
     411,   412,    -1,   414,    -1,   416,    -1,   418,    -1,   329,
      -1,    -1,   423,    -1,    -1,    -1,    -1,    -1,    -1,   358,
      23,    24,    -1,    -1,    27,   364,   365,    30,    31,    32,
      33,    34,    35,    -1,    -1,   355,    -1,   357,    -1,    -1,
     360,    -1,    -1,    -1,   366,    -1,    -1,    -1,   370,   371,
      -1,    -1,    -1,    -1,    -1,   375,   361,   396,    -1,   379,
      -1,    -1,   401,   402,    -1,    -1,   405,    -1,   407,    -1,
      -1,   410,    -1,    -1,   394,    -1,   398,    -1,   417,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,     1,     3,    -1,   409,
       5,     6,    -1,     9,    10,    11,    12,    13,    14,    15,
      16,    17,    18,    19,    20,    21,    22,    -1,    -1,    -1,
      -1,    23,    24,    25,    29,    27,    28,    -1,    30,    31,
      32,    33,    34,    35,    -1,   333,     4,     5,     6,    44,
      45,    -1,    -1,    48,    49,    -1,    51,   345,    53,    54,
     348,    -1,    57,    58,    59,    -1,    61,    -1,    -1,    64,
      -1,    29,    67,    68,    69,    70,    -1,    72,    -1,    74,
      75,    -1,    77,    78,    79,    -1,    44,    45,    -1,    -1,
      48,    49,    -1,    51,    -1,    -1,    54,    -1,    93,    -1,
      95,    -1,    97,    98,    -1,    -1,   101,     4,     5,     6,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,     4,     5,     6,    82,    -1,    -1,    -1,    -1,    -1,
      -1,    -1,    29,     4,     5,     6,    -1,    95,    -1,    97,
      98,    -1,    -1,   101,   102,    -1,    29,    44,    45,    -1,
      -1,    48,    49,    -1,    51,    -1,    -1,    54,    29,    -1,
      -1,    44,    45,    -1,    -1,    48,    49,    -1,    51,    -1,
      -1,    54,    -1,    44,    45,    -1,    -1,    48,    49,    -1,
      51,    -1,    -1,    54,    -1,    82,    -1,    -1,     4,     5,
       6,    -1,    -1,    -1,    91,    -1,    -1,    -1,    95,    82,
      97,    98,    -1,   100,   101,    -1,    -1,     5,     6,    -1,
      -1,    82,    95,    29,    97,    98,    -1,   100,   101,    -1,
      -1,    -1,    -1,    -1,    95,    -1,    97,    98,    44,    45,
     101,    29,    48,    49,    -1,    51,    -1,    -1,    54,    -1,
      -1,    -1,     5,     6,     7,     8,    44,    45,    -1,    -1,
      48,    49,    -1,    51,    -1,    -1,    54,    -1,    -1,    -1,
      -1,    -1,     5,     6,    -1,    -1,    82,    -1,    -1,    -1,
      -1,    -1,    -1,    36,    37,    38,    39,    40,    41,    95,
      -1,    97,    98,    46,    47,   101,    29,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    95,    -1,    97,
      98,    44,    45,   101,   102,    48,    49,    -1,    51,    -1,
      53,    54,    -1,    -1,    57,    58,    59,    -1,    61,    -1,
      -1,    64,     5,     6,    67,    68,    69,    70,    -1,    72,
      -1,    74,    75,    23,    24,    -1,    79,    27,    28,    -1,
      30,    31,    32,    33,    34,    35,    29,    -1,    91,    92,
      93,    -1,    95,    -1,    97,    98,    -1,    -1,   101,    -1,
      -1,    44,    45,    -1,    -1,    48,    49,    -1,    51,    -1,
      53,    54,    -1,    -1,    57,    58,    59,    -1,    61,    -1,
      -1,    64,     5,     6,    67,    68,    69,    70,    -1,    72,
      -1,    74,    75,    -1,    -1,    -1,    79,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    29,    -1,    91,    92,
      -1,    -1,    95,    -1,    97,    98,    -1,    -1,   101,    -1,
      -1,    44,    45,    -1,    -1,    48,    49,    -1,    51,    -1,
      53,    54,    -1,    -1,    57,    58,    59,    -1,    61,    -1,
      -1,    64,     5,     6,    67,    68,    69,    70,    -1,    72,
      -1,    74,    75,    -1,    -1,    -1,    79,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    29,    -1,    -1,    -1,
      -1,    -1,    95,    -1,    97,    98,     5,     6,   101,    -1,
      -1,    44,    45,    -1,    -1,    48,    49,    -1,    51,    -1,
      53,    54,    -1,    -1,    57,    58,    59,    -1,    61,    -1,
      29,    64,     5,     6,    67,    68,    69,    70,    -1,    72,
      -1,    74,    75,    -1,    -1,    44,    45,    -1,    -1,    48,
      49,    -1,    51,    -1,    -1,    54,    29,    -1,    -1,    -1,
      -1,    -1,    95,    -1,    97,    98,     5,     6,   101,    -1,
      -1,    44,    45,    -1,    -1,    48,    49,    -1,    51,    -1,
      -1,    54,    -1,    -1,    -1,    -1,    -1,     5,     6,    88,
      29,    90,    -1,    -1,    -1,    -1,    95,    -1,    97,    98,
      -1,    -1,   101,    -1,    -1,    44,    45,    -1,    -1,    48,
      49,    29,    51,    -1,    87,    54,    89,    -1,    -1,    -1,
      -1,    -1,    95,    -1,    97,    98,    44,    45,   101,    -1,
      48,    49,    -1,    51,    -1,    -1,    54,    -1,    -1,    -1,
      -1,    -1,     5,     6,    -1,    -1,    -1,    -1,    -1,    -1,
      89,    -1,    -1,    -1,     5,     6,    95,    -1,    97,    98,
      -1,    -1,   101,    -1,    -1,    -1,    29,    -1,    -1,    87,
      -1,     5,     6,    -1,    -1,    -1,    -1,    95,    29,    97,
      98,    44,    45,   101,    -1,    48,    49,    -1,    51,    -1,
      -1,    54,    -1,    44,    45,    29,    -1,    48,    49,    -1,
      51,    -1,    -1,    54,    -1,    -1,    -1,    -1,    -1,    -1,
      44,    45,    -1,    -1,    48,    49,    -1,    51,    -1,    -1,
      54,    -1,    -1,    -1,    -1,    -1,    89,    -1,    -1,     5,
       6,    -1,    95,    -1,    97,    98,    -1,    -1,   101,    -1,
      -1,    -1,    -1,    -1,    95,    -1,    97,    98,    -1,    -1,
     101,    -1,    -1,    29,    -1,    -1,    -1,    -1,    -1,    -1,
      -1,    95,    -1,    97,    98,    -1,    -1,   101,    44,    45,
      -1,    -1,    48,    49,     3,    51,    -1,    -1,    54,    -1,
       9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
      19,    20,    21,    22,    23,    24,    25,    26,    27,    28,
      -1,    30,    31,    32,    33,    34,    35,    -1,    -1,    -1,
      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    95,
       3,    97,    98,    -1,    -1,   101,     9,    10,    11,    12,
      13,    14,    15,    16,    17,    18,    19,    20,    21,    22,
      -1,    23,    24,    25,    26,    27,    28,    -1,    30,    31,
      32,    33,    34,    35
};

/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
   symbol of state STATE-NUM.  */
static const unsigned char yystos[] =
{
       0,     1,     5,     6,    29,    44,    45,    48,    49,    51,
      53,    54,    57,    58,    59,    61,    64,    67,    68,    69,
      70,    72,    74,    75,    77,    78,    93,    95,    97,    98,
     101,   104,   105,   106,   107,   111,   112,   113,   115,   118,
     122,   123,   124,   130,   131,   132,   133,   134,   135,   136,
     137,   138,   140,   141,   142,   145,   146,   151,   156,   157,
     158,   159,   172,   173,   180,   192,    98,   101,   112,   131,
     131,   131,   131,   131,    88,    90,    95,   140,   181,   182,
     183,   184,   191,   191,   191,   191,   191,   191,   191,   112,
     143,   144,   143,   140,     4,    82,    91,   100,   119,   120,
     121,   125,   126,   140,    91,    99,   114,    76,    95,   163,
     165,     0,    77,    93,   192,    91,    92,   193,   194,    54,
     139,   128,     5,     6,     7,     8,    36,    37,    38,    39,
      40,    41,    46,    47,     4,    23,    24,    25,    26,    27,
      28,    30,    31,    32,    33,    34,    35,     3,     9,    10,
      11,    12,    13,    14,    15,    16,    17,    18,    19,    20,
      21,    22,    79,    81,    98,   112,   168,   169,   175,   176,
     114,    87,    89,   140,   102,    83,    84,    85,    86,   185,
     186,   187,   188,   189,   190,   183,   182,    92,    95,   135,
     136,   140,    91,    92,    93,   195,   196,   140,   147,   148,
     140,   196,   196,     3,   144,   102,   100,   100,    91,    92,
      99,   116,   117,   121,   126,     1,    80,   112,   166,   167,
     111,    91,    92,   111,    54,    42,    43,    44,    45,    95,
      96,    97,   127,   129,   131,   131,   131,   131,   131,   131,
     131,   131,   131,   131,   131,   131,   131,   135,   135,   135,
     135,   135,   135,   135,   135,   135,   135,   135,   135,   140,
     140,   140,   140,   140,   140,   140,   140,   140,   140,   140,
     140,   140,   140,   140,   160,   162,   160,   161,   174,    81,
     112,   160,   170,   171,   174,   165,   177,   178,   196,    89,
     140,    87,   140,   140,    55,    56,   186,   187,   189,   190,
      87,   140,   182,   184,   136,     3,   196,    91,    92,    93,
     108,   109,   110,   111,   196,    52,    62,    63,   149,   150,
     196,   108,   108,   140,   121,    82,   125,   140,    99,    91,
      89,   102,   164,    92,   129,   129,   129,   129,   102,   126,
     100,   126,   129,   191,   161,     3,   171,    99,    92,   171,
     178,   108,    89,    89,   140,   140,   140,     3,   140,   108,
      60,   195,   196,   108,   191,   191,    65,   152,   153,   154,
      71,    73,   121,    80,   112,    92,   102,   100,    50,    95,
     112,   176,    81,   112,    52,    77,   179,    89,   140,   140,
     196,    52,   140,   111,   196,   196,   191,    52,    66,   154,
     155,   191,   191,   140,   171,   102,   108,   140,   108,   196,
     191,   196,   196,   102,   196,    52,   196,   140,   196,   108,
     108,   108,   108,   196,   108,    52,    52,    52,   108
};

#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
# define YYSIZE_T __SIZE_TYPE__
#endif
#if ! defined (YYSIZE_T) && defined (size_t)
# define YYSIZE_T size_t
#endif
#if ! defined (YYSIZE_T)
# if defined (__STDC__) || defined (__cplusplus)
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
#  define YYSIZE_T size_t
# endif
#endif
#if ! defined (YYSIZE_T)
# define YYSIZE_T unsigned int
#endif

#define yyerrok		(yyerrstatus = 0)
#define yyclearin	(yychar = YYEMPTY)
#define YYEMPTY		(-2)
#define YYEOF		0

#define YYACCEPT	goto yyacceptlab
#define YYABORT		goto yyabortlab
#define YYERROR		goto yyerrorlab


/* Like YYERROR except do call yyerror.  This remains here temporarily
   to ease the transition to the new meaning of YYERROR, for GCC.
   Once GCC version 2 has supplanted version 1, this can go.  */

#define YYFAIL		goto yyerrlab

#define YYRECOVERING()  (!!yyerrstatus)

#define YYBACKUP(Token, Value)					\
do								\
  if (yychar == YYEMPTY && yylen == 1)				\
    {								\
      yychar = (Token);						\
      yylval = (Value);						\
      yytoken = YYTRANSLATE (yychar);				\
      YYPOPSTACK;						\
      goto yybackup;						\
    }								\
  else								\
    { 								\
      yyerror ("syntax error: cannot back up");\
      YYERROR;							\
    }								\
while (0)

#define YYTERROR	1
#define YYERRCODE	256

/* YYLLOC_DEFAULT -- Compute the default location (before the actions
   are run).  */

#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N)		\
   ((Current).first_line   = (Rhs)[1].first_line,	\
    (Current).first_column = (Rhs)[1].first_column,	\
    (Current).last_line    = (Rhs)[N].last_line,	\
    (Current).last_column  = (Rhs)[N].last_column)
#endif

/* YYLEX -- calling `yylex' with the right arguments.  */

#ifdef YYLEX_PARAM
# define YYLEX yylex (YYLEX_PARAM)
#else
# define YYLEX yylex ()
#endif

/* Enable debugging if requested.  */
#if YYDEBUG

# ifndef YYFPRINTF
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
#  define YYFPRINTF fprintf
# endif

# define YYDPRINTF(Args)			\
do {						\
  if (yydebug)					\
    YYFPRINTF Args;				\
} while (0)

# define YYDSYMPRINT(Args)			\
do {						\
  if (yydebug)					\
    yysymprint Args;				\
} while (0)

# define YYDSYMPRINTF(Title, Token, Value, Location)		\
do {								\
  if (yydebug)							\
    {								\
      YYFPRINTF (stderr, "%s ", Title);				\
      yysymprint (stderr, 					\
                  Token, Value);	\
      YYFPRINTF (stderr, "\n");					\
    }								\
} while (0)

/*------------------------------------------------------------------.
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
| TOP (included).                                                   |
`------------------------------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yy_stack_print (short int *bottom, short int *top)
#else
static void
yy_stack_print (bottom, top)
    short int *bottom;
    short int *top;
#endif
{
  YYFPRINTF (stderr, "Stack now");
  for (/* Nothing. */; bottom <= top; ++bottom)
    YYFPRINTF (stderr, " %d", *bottom);
  YYFPRINTF (stderr, "\n");
}

# define YY_STACK_PRINT(Bottom, Top)				\
do {								\
  if (yydebug)							\
    yy_stack_print ((Bottom), (Top));				\
} while (0)


/*------------------------------------------------.
| Report that the YYRULE is going to be reduced.  |
`------------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yy_reduce_print (int yyrule)
#else
static void
yy_reduce_print (yyrule)
    int yyrule;
#endif
{
  int yyi;
  unsigned int yylno = yyrline[yyrule];
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
             yyrule - 1, yylno);
  /* Print the symbols being reduced, and their result.  */
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
}

# define YY_REDUCE_PRINT(Rule)		\
do {					\
  if (yydebug)				\
    yy_reduce_print (Rule);		\
} while (0)

/* Nonzero means print parse trace.  It is left uninitialized so that
   multiple parsers can coexist.  */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
# define YYDSYMPRINT(Args)
# define YYDSYMPRINTF(Title, Token, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */


/* YYINITDEPTH -- initial size of the parser's stacks.  */
#ifndef	YYINITDEPTH
# define YYINITDEPTH 200
#endif

/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
   if the built-in stack extension method is used).

   Do not make this value too large; the results are undefined if
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
   evaluated with infinite-precision integer arithmetic.  */

#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
# undef YYMAXDEPTH
#endif

#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif



#if YYERROR_VERBOSE

# ifndef yystrlen
#  if defined (__GLIBC__) && defined (_STRING_H)
#   define yystrlen strlen
#  else
/* Return the length of YYSTR.  */
static YYSIZE_T
#   if defined (__STDC__) || defined (__cplusplus)
yystrlen (const char *yystr)
#   else
yystrlen (yystr)
     const char *yystr;
#   endif
{
  register const char *yys = yystr;

  while (*yys++ != '\0')
    continue;

  return yys - yystr - 1;
}
#  endif
# endif

# ifndef yystpcpy
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
#   define yystpcpy stpcpy
#  else
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
   YYDEST.  */
static char *
#   if defined (__STDC__) || defined (__cplusplus)
yystpcpy (char *yydest, const char *yysrc)
#   else
yystpcpy (yydest, yysrc)
     char *yydest;
     const char *yysrc;
#   endif
{
  register char *yyd = yydest;
  register const char *yys = yysrc;

  while ((*yyd++ = *yys++) != '\0')
    continue;

  return yyd - 1;
}
#  endif
# endif

#endif /* !YYERROR_VERBOSE */



#if YYDEBUG
/*--------------------------------.
| Print this symbol on YYOUTPUT.  |
`--------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
#else
static void
yysymprint (yyoutput, yytype, yyvaluep)
    FILE *yyoutput;
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;

  if (yytype < YYNTOKENS)
    {
      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
# ifdef YYPRINT
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# endif
    }
  else
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);

  switch (yytype)
    {
      default:
        break;
    }
  YYFPRINTF (yyoutput, ")");
}

#endif /* ! YYDEBUG */
/*-----------------------------------------------.
| Release the memory associated to this symbol.  |
`-----------------------------------------------*/

#if defined (__STDC__) || defined (__cplusplus)
static void
yydestruct (int yytype, YYSTYPE *yyvaluep)
#else
static void
yydestruct (yytype, yyvaluep)
    int yytype;
    YYSTYPE *yyvaluep;
#endif
{
  /* Pacify ``unused variable'' warnings.  */
  (void) yyvaluep;

  switch (yytype)
    {

      default:
        break;
    }
}


/* Prevent warnings from -Wmissing-prototypes.  */

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM);
# else
int yyparse ();
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */



/* The lookahead symbol.  */
int yychar;

/* The semantic value of the lookahead symbol.  */
YYSTYPE yylval;

/* Number of syntax errors so far.  */
int yynerrs;



/*----------.
| yyparse.  |
`----------*/

#ifdef YYPARSE_PARAM
# if defined (__STDC__) || defined (__cplusplus)
int yyparse (void *YYPARSE_PARAM)
# else
int yyparse (YYPARSE_PARAM)
  void *YYPARSE_PARAM;
# endif
#else /* ! YYPARSE_PARAM */
#if defined (__STDC__) || defined (__cplusplus)
int
yyparse (void)
#else
int
yyparse ()

#endif
#endif
{
  
  register int yystate;
  register int yyn;
  int yyresult;
  /* Number of tokens to shift before error messages enabled.  */
  int yyerrstatus;
  /* Lookahead token as an internal (translated) token number.  */
  int yytoken = 0;

  /* Three stacks and their tools:
     `yyss': related to states,
     `yyvs': related to semantic values,
     `yyls': related to locations.

     Refer to the stacks thru separate pointers, to allow yyoverflow
     to reallocate them elsewhere.  */

  /* The state stack.  */
  short int yyssa[YYINITDEPTH];
  short int *yyss = yyssa;
  register short int *yyssp;

  /* The semantic value stack.  */
  YYSTYPE yyvsa[YYINITDEPTH];
  YYSTYPE *yyvs = yyvsa;
  register YYSTYPE *yyvsp;



#define YYPOPSTACK   (yyvsp--, yyssp--)

  YYSIZE_T yystacksize = YYINITDEPTH;

  /* The variables used to return semantic value and location from the
     action routines.  */
  YYSTYPE yyval;


  /* When reducing, the number of symbols on the RHS of the reduced
     rule.  */
  int yylen;

  YYDPRINTF ((stderr, "Starting parse\n"));

  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = YYEMPTY;		/* Cause a token to be read.  */

  /* Initialize stack pointers.
     Waste one element of value and location stack
     so that they stay on the same level as the state stack.
     The wasted elements are never initialized.  */

  yyssp = yyss;
  yyvsp = yyvs;


  goto yysetstate;

/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate.  |
`------------------------------------------------------------*/
 yynewstate:
  /* In all cases, when you get here, the value and location stacks
     have just been pushed. so pushing a state here evens the stacks.
     */
  yyssp++;

 yysetstate:
  *yyssp = yystate;

  if (yyss + yystacksize - 1 <= yyssp)
    {
      /* Get the current used size of the three stacks, in elements.  */
      YYSIZE_T yysize = yyssp - yyss + 1;

#ifdef yyoverflow
      {
	/* Give user a chance to reallocate the stack. Use copies of
	   these so that the &'s don't force the real ones into
	   memory.  */
	YYSTYPE *yyvs1 = yyvs;
	short int *yyss1 = yyss;


	/* Each stack pointer address is followed by the size of the
	   data in use in that stack, in bytes.  This used to be a
	   conditional around just the two extra args, but that might
	   be undefined if yyoverflow is a macro.  */
	yyoverflow ("parser stack overflow",
		    &yyss1, yysize * sizeof (*yyssp),
		    &yyvs1, yysize * sizeof (*yyvsp),

		    &yystacksize);

	yyss = yyss1;
	yyvs = yyvs1;
      }
#else /* no yyoverflow */
# ifndef YYSTACK_RELOCATE
      goto yyoverflowlab;
# else
      /* Extend the stack our own way.  */
      if (YYMAXDEPTH <= yystacksize)
	goto yyoverflowlab;
      yystacksize *= 2;
      if (YYMAXDEPTH < yystacksize)
	yystacksize = YYMAXDEPTH;

      {
	short int *yyss1 = yyss;
	union yyalloc *yyptr =
	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
	if (! yyptr)
	  goto yyoverflowlab;
	YYSTACK_RELOCATE (yyss);
	YYSTACK_RELOCATE (yyvs);

#  undef YYSTACK_RELOCATE
	if (yyss1 != yyssa)
	  YYSTACK_FREE (yyss1);
      }
# endif
#endif /* no yyoverflow */

      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;


      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
		  (unsigned long int) yystacksize));

      if (yyss + yystacksize - 1 <= yyssp)
	YYABORT;
    }

  YYDPRINTF ((stderr, "Entering state %d\n", yystate));

  goto yybackup;

/*-----------.
| yybackup.  |
`-----------*/
yybackup:

/* Do appropriate processing given the current state.  */
/* Read a lookahead token if we need one and don't already have one.  */
/* yyresume: */

  /* First try to decide what to do without reference to lookahead token.  */

  yyn = yypact[yystate];
  if (yyn == YYPACT_NINF)
    goto yydefault;

  /* Not known => get a lookahead token if don't already have one.  */

  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
  if (yychar == YYEMPTY)
    {
      YYDPRINTF ((stderr, "Reading a token: "));
      yychar = YYLEX;
    }

  if (yychar <= YYEOF)
    {
      yychar = yytoken = YYEOF;
      YYDPRINTF ((stderr, "Now at end of input.\n"));
    }
  else
    {
      yytoken = YYTRANSLATE (yychar);
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
    }

  /* If the proper action on seeing token YYTOKEN is to reduce or to
     detect an error, take that action.  */
  yyn += yytoken;
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (yyn == 0 || yyn == YYTABLE_NINF)
	goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }

  if (yyn == YYFINAL)
    YYACCEPT;

  /* Shift the lookahead token.  */
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));

  /* Discard the token being shifted unless it is eof.  */
  if (yychar != YYEOF)
    yychar = YYEMPTY;

  *++yyvsp = yylval;


  /* Count tokens shifted since error; after three, turn off error
     status.  */
  if (yyerrstatus)
    yyerrstatus--;

  yystate = yyn;
  goto yynewstate;


/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state.  |
`-----------------------------------------------------------*/
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;


/*-----------------------------.
| yyreduce -- Do a reduction.  |
`-----------------------------*/
yyreduce:
  /* yyn is the number of a rule to reduce with.  */
  yylen = yyr2[yyn];

  /* If YYLEN is nonzero, implement the default value of the action:
     `$$ = $1'.

     Otherwise, the following line sets YYVAL to garbage.
     This behavior is undocumented and Bison
     users should not rely upon it.  Assigning to YYVAL
     unconditionally makes the parser a bit smaller, and it avoids a
     GCC warning that YYVAL may be used uninitialized.  */
  yyval = yyvsp[1-yylen];


  YY_REDUCE_PRINT (yyn);
  switch (yyn)
    {
        case 2:
#line 515 "parse.y"
    {
		    global_command = yyvsp[0].tree_statement_list_type;
		    promptflag = 1;
		    YYACCEPT;
		  }
    break;

  case 3:
#line 521 "parse.y"
    { ABORT_PARSE; }
    break;

  case 4:
#line 523 "parse.y"
    { ABORT_PARSE; }
    break;

  case 5:
#line 527 "parse.y"
    { yyval.tree_statement_list_type = 0; }
    break;

  case 6:
#line 529 "parse.y"
    {
		    parser_end_of_input = 1;
		    yyval.tree_statement_list_type = 0;
		  }
    break;

  case 7:
#line 534 "parse.y"
    { yyval.tree_statement_list_type = yyvsp[0].tree_statement_list_type; }
    break;

  case 8:
#line 536 "parse.y"
    { yyval.tree_statement_list_type = yyvsp[-1].tree_statement_list_type; }
    break;

  case 9:
#line 538 "parse.y"
    { yyval.tree_statement_list_type = yyvsp[-1].tree_statement_list_type; }
    break;

  case 10:
#line 542 "parse.y"
    {
		    set_stmt_print_flag (yyvsp[-1].tree_statement_list_type, yyvsp[0].sep_type, false);
		    yyval.tree_statement_list_type = yyvsp[-1].tree_statement_list_type;
		  }
    break;

  case 11:
#line 549 "parse.y"
    { yyval.tree_statement_list_type = new tree_statement_list (yyvsp[0].tree_statement_type); }
    break;

  case 12:
#line 551 "parse.y"
    {
		    set_stmt_print_flag (yyvsp[-2].tree_statement_list_type, yyvsp[-1].sep_type, false);
		    yyvsp[-2].tree_statement_list_type->append (yyvsp[0].tree_statement_type);
		    yyval.tree_statement_list_type = yyvsp[-2].tree_statement_list_type;
		  }
    break;

  case 13:
#line 559 "parse.y"
    { yyval.tree_statement_list_type = new tree_statement_list (); }
    break;

  case 14:
#line 561 "parse.y"
    { yyval.tree_statement_list_type = yyvsp[0].tree_statement_list_type; }
    break;

  case 15:
#line 565 "parse.y"
    {
		    set_stmt_print_flag (yyvsp[-1].tree_statement_list_type, yyvsp[0].sep_type, true);
		    yyval.tree_statement_list_type = yyvsp[-1].tree_statement_list_type;
		  }
    break;

  case 16:
#line 572 "parse.y"
    {
		    lexer_flags.beginning_of_function = false;
		    yyval.tree_statement_list_type = new tree_statement_list (yyvsp[0].tree_statement_type);
		  }
    break;

  case 17:
#line 577 "parse.y"
    {
		    set_stmt_print_flag (yyvsp[-2].tree_statement_list_type, yyvsp[-1].sep_type, true);
		    yyvsp[-2].tree_statement_list_type->append (yyvsp[0].tree_statement_type);
		    yyval.tree_statement_list_type = yyvsp[-2].tree_statement_list_type;
		  }
    break;

  case 18:
#line 585 "parse.y"
    {
		    octave_comment_list *comment
		      = octave_comment_buffer::get_comment ();

		    yyval.tree_statement_type = new tree_statement (yyvsp[0].tree_expression_type, comment);
		  }
    break;

  case 19:
#line 592 "parse.y"
    {
		    octave_comment_list *comment
		      = octave_comment_buffer::get_comment ();

		    yyval.tree_statement_type = new tree_statement (yyvsp[0].tree_command_type, comment);
		  }
    break;

  case 20:
#line 599 "parse.y"
    {
		    symbol_record *sr = lookup_by_name ("clearplot", 0);
		    tree_identifier *id = new tree_identifier (sr);

		    octave_comment_list *comment
		      = octave_comment_buffer::get_comment ();

		    yyval.tree_statement_type = new tree_statement (id, comment);
		  }
    break;

  case 21:
#line 615 "parse.y"
    {
		    yyval.tree_identifier_type = new tree_identifier
		      (yyvsp[0].tok_val->sym_rec (), yyvsp[0].tok_val->line (), yyvsp[0].tok_val->column ());
		  }
    break;

  case 22:
#line 622 "parse.y"
    { yyval.tree_constant_type = make_constant (NUM, yyvsp[0].tok_val); }
    break;

  case 23:
#line 624 "parse.y"
    { yyval.tree_constant_type = make_constant (IMAG_NUM, yyvsp[0].tok_val); }
    break;

  case 24:
#line 626 "parse.y"
    { yyval.tree_constant_type = make_constant (STRING, yyvsp[0].tok_val); }
    break;

  case 25:
#line 631 "parse.y"
    { lexer_flags.looking_at_matrix_or_assign_lhs = true; }
    break;

  case 26:
#line 635 "parse.y"
    { yyval.tree_expression_type = new tree_constant (octave_value (Matrix ())); }
    break;

  case 27:
#line 637 "parse.y"
    { yyval.tree_expression_type = new tree_constant (octave_value (Matrix ())); }
    break;

  case 28:
#line 639 "parse.y"
    {
		    yyval.tree_expression_type = finish_matrix (yyvsp[-1].tree_matrix_type);
		    lexer_flags.looking_at_matrix_or_assign_lhs = false;
		  }
    break;

  case 29:
#line 646 "parse.y"
    { yyval.tree_matrix_type = yyvsp[0].tree_matrix_type; }
    break;

  case 30:
#line 648 "parse.y"
    { yyval.tree_matrix_type = yyvsp[-1].tree_matrix_type; }
    break;

  case 31:
#line 652 "parse.y"
    { yyval.tree_matrix_type = new tree_matrix (yyvsp[0].tree_argument_list_type); }
    break;

  case 32:
#line 654 "parse.y"
    {
		    yyvsp[-2].tree_matrix_type->append (yyvsp[0].tree_argument_list_type);
		    yyval.tree_matrix_type = yyvsp[-2].tree_matrix_type;
		  }
    break;

  case 33:
#line 661 "parse.y"
    { yyval.tree_expression_type = new tree_constant (octave_value (Cell ())); }
    break;

  case 34:
#line 663 "parse.y"
    { yyval.tree_expression_type = new tree_constant (octave_value (Cell ())); }
    break;

  case 35:
#line 665 "parse.y"
    { yyval.tree_expression_type = finish_cell (yyvsp[-1].tree_cell_type); }
    break;

  case 36:
#line 669 "parse.y"
    { yyval.tree_cell_type = yyvsp[0].tree_cell_type; }
    break;

  case 37:
#line 671 "parse.y"
    { yyval.tree_cell_type = yyvsp[-1].tree_cell_type; }
    break;

  case 38:
#line 675 "parse.y"
    { yyval.tree_cell_type = new tree_cell (yyvsp[0].tree_argument_list_type); }
    break;

  case 39:
#line 677 "parse.y"
    {
		    yyvsp[-2].tree_cell_type->append (yyvsp[0].tree_argument_list_type);
		    yyval.tree_cell_type = yyvsp[-2].tree_cell_type;
		  }
    break;

  case 40:
#line 685 "parse.y"
    { yyval.tree_argument_list_type = yyvsp[0].tree_argument_list_type; }
    break;

  case 41:
#line 687 "parse.y"
    { yyval.tree_argument_list_type = yyvsp[-1].tree_argument_list_type; }
    break;

  case 42:
#line 691 "parse.y"
    {
		    yyval.tree_fcn_handle_type = make_fcn_handle (yyvsp[0].tok_val);
		    lexer_flags.looking_at_function_handle--;
		  }
    break;

  case 43:
#line 698 "parse.y"
    { yyval.tree_constant_type = make_anon_fcn_handle (yyvsp[-1].tree_parameter_list_type, yyvsp[0].tree_statement_type); }
    break;

  case 44:
#line 702 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_identifier_type; }
    break;

  case 45:
#line 704 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_constant_type; }
    break;

  case 46:
#line 706 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_fcn_handle_type; }
    break;

  case 47:
#line 708 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 48:
#line 710 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 49:
#line 712 "parse.y"
    { yyval.tree_expression_type = yyvsp[-1].tree_expression_type->mark_in_parens (); }
    break;

  case 50:
#line 716 "parse.y"
    {
		    octave_value tmp (octave_value::magic_colon_t);
		    yyval.tree_constant_type = new tree_constant (tmp);
		  }
    break;

  case 51:
#line 723 "parse.y"
    { yyval.tree_argument_list_type = new tree_argument_list (yyvsp[0].tree_expression_type); }
    break;

  case 52:
#line 725 "parse.y"
    { yyval.tree_argument_list_type = new tree_argument_list (yyvsp[0].tree_constant_type); }
    break;

  case 53:
#line 727 "parse.y"
    {
		    octave_value tmp (octave_value::all_va_args_t);
		    tree_constant *all_va_args = new tree_constant (tmp);
		    yyval.tree_argument_list_type = new tree_argument_list (all_va_args);
		  }
    break;

  case 54:
#line 733 "parse.y"
    {
		    yyvsp[-2].tree_argument_list_type->append (yyvsp[0].tree_constant_type);
		    yyval.tree_argument_list_type = yyvsp[-2].tree_argument_list_type;
		  }
    break;

  case 55:
#line 738 "parse.y"
    {
		    yyvsp[-2].tree_argument_list_type->append (yyvsp[0].tree_expression_type);
		    yyval.tree_argument_list_type = yyvsp[-2].tree_argument_list_type;
		  }
    break;

  case 56:
#line 743 "parse.y"
    {
		    octave_value tmp (octave_value::all_va_args_t);
		    tree_constant *all_va_args = new tree_constant (tmp);
		    yyvsp[-2].tree_argument_list_type->append (all_va_args);
		    yyval.tree_argument_list_type = yyvsp[-2].tree_argument_list_type;
		  }
    break;

  case 57:
#line 752 "parse.y"
    { lexer_flags.looking_at_indirect_ref = true; }
    break;

  case 58:
#line 763 "parse.y"
    { lexer_flags.looking_at_object_index++; }
    break;

  case 59:
#line 767 "parse.y"
    { lexer_flags.looking_at_object_index--; }
    break;

  case 60:
#line 771 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 61:
#line 773 "parse.y"
    {
		    yyval.tree_expression_type = make_index_expression (yyvsp[-3].tree_expression_type, 0, '(');
		    lexer_flags.looking_at_object_index--;
		  }
    break;

  case 62:
#line 778 "parse.y"
    {
		    yyval.tree_expression_type = make_index_expression (yyvsp[-4].tree_expression_type, yyvsp[-1].tree_argument_list_type, '(');
		    lexer_flags.looking_at_object_index--;
		  }
    break;

  case 63:
#line 783 "parse.y"
    {
		    yyval.tree_expression_type = make_index_expression (yyvsp[-3].tree_expression_type, 0, '{');
		    lexer_flags.looking_at_object_index--;
		  }
    break;

  case 64:
#line 788 "parse.y"
    {
		    yyval.tree_expression_type = make_index_expression (yyvsp[-4].tree_expression_type, yyvsp[-1].tree_argument_list_type, '{');
		    lexer_flags.looking_at_object_index--;
		  }
    break;

  case 65:
#line 793 "parse.y"
    { yyval.tree_expression_type = make_postfix_op (PLUS_PLUS, yyvsp[-3].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 66:
#line 795 "parse.y"
    { yyval.tree_expression_type = make_postfix_op (MINUS_MINUS, yyvsp[-3].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 67:
#line 797 "parse.y"
    { yyval.tree_expression_type = make_postfix_op (QUOTE, yyvsp[-3].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 68:
#line 799 "parse.y"
    { yyval.tree_expression_type = make_postfix_op (TRANSPOSE, yyvsp[-3].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 69:
#line 801 "parse.y"
    { yyval.tree_expression_type = make_indirect_ref (yyvsp[-4].tree_expression_type, yyvsp[0].tok_val->text ()); }
    break;

  case 70:
#line 803 "parse.y"
    { yyval.tree_expression_type = make_indirect_ref (yyvsp[-6].tree_expression_type, yyvsp[-1].tree_expression_type); }
    break;

  case 71:
#line 807 "parse.y"
    { yyval.tree_expression_type = yyvsp[-2].tree_expression_type; }
    break;

  case 72:
#line 809 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 73:
#line 811 "parse.y"
    { yyval.tree_expression_type = make_prefix_op (PLUS_PLUS, yyvsp[0].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 74:
#line 813 "parse.y"
    { yyval.tree_expression_type = make_prefix_op (MINUS_MINUS, yyvsp[0].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 75:
#line 815 "parse.y"
    { yyval.tree_expression_type = make_prefix_op (EXPR_NOT, yyvsp[0].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 76:
#line 817 "parse.y"
    { yyval.tree_expression_type = make_prefix_op ('+', yyvsp[0].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 77:
#line 819 "parse.y"
    { yyval.tree_expression_type = make_prefix_op ('-', yyvsp[0].tree_expression_type, yyvsp[-1].tok_val); }
    break;

  case 78:
#line 823 "parse.y"
    { yyval.tree_expression_type = make_binary_op (POW, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 79:
#line 825 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EPOW, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 80:
#line 827 "parse.y"
    { yyval.tree_expression_type = make_binary_op ('+', yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 81:
#line 829 "parse.y"
    { yyval.tree_expression_type = make_binary_op ('-', yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 82:
#line 831 "parse.y"
    { yyval.tree_expression_type = make_binary_op ('*', yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 83:
#line 833 "parse.y"
    { yyval.tree_expression_type = make_binary_op ('/', yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 84:
#line 835 "parse.y"
    { yyval.tree_expression_type = make_binary_op ('+', yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 85:
#line 837 "parse.y"
    { yyval.tree_expression_type = make_binary_op ('-', yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 86:
#line 839 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EMUL, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 87:
#line 841 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EDIV, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 88:
#line 843 "parse.y"
    { yyval.tree_expression_type = make_binary_op (LEFTDIV, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 89:
#line 845 "parse.y"
    { yyval.tree_expression_type = make_binary_op (ELEFTDIV, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 90:
#line 849 "parse.y"
    { yyval.tree_expression_type = finish_colon_expression (yyvsp[0].tree_colon_expression_type); }
    break;

  case 91:
#line 853 "parse.y"
    { yyval.tree_colon_expression_type = new tree_colon_expression (yyvsp[0].tree_expression_type); }
    break;

  case 92:
#line 855 "parse.y"
    {
		    if (! (yyval.tree_colon_expression_type = yyvsp[-2].tree_colon_expression_type->append (yyvsp[0].tree_expression_type)))
		      ABORT_PARSE;
		  }
    break;

  case 93:
#line 862 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 94:
#line 864 "parse.y"
    { yyval.tree_expression_type = make_binary_op (LSHIFT, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 95:
#line 866 "parse.y"
    { yyval.tree_expression_type = make_binary_op (RSHIFT, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 96:
#line 868 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_LT, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 97:
#line 870 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_LE, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 98:
#line 872 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_EQ, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 99:
#line 874 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_GE, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 100:
#line 876 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_GT, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 101:
#line 878 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_NE, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 102:
#line 880 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_AND, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 103:
#line 882 "parse.y"
    { yyval.tree_expression_type = make_binary_op (EXPR_OR, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 104:
#line 884 "parse.y"
    { yyval.tree_expression_type = make_boolean_op (EXPR_AND_AND, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 105:
#line 886 "parse.y"
    { yyval.tree_expression_type = make_boolean_op (EXPR_OR_OR, yyvsp[-2].tree_expression_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 106:
#line 893 "parse.y"
    { yyval.tree_argument_list_type = new tree_argument_list (yyvsp[0].tree_expression_type); }
    break;

  case 107:
#line 895 "parse.y"
    {
		    yyval.tree_argument_list_type = yyvsp[-1].tree_argument_list_type;
		    lexer_flags.looking_at_matrix_or_assign_lhs = false;
		  }
    break;

  case 108:
#line 902 "parse.y"
    { yyval.tree_expression_type = make_assign_op ('=', yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 109:
#line 904 "parse.y"
    { yyval.tree_expression_type = make_assign_op (ADD_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 110:
#line 906 "parse.y"
    { yyval.tree_expression_type = make_assign_op (SUB_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 111:
#line 908 "parse.y"
    { yyval.tree_expression_type = make_assign_op (MUL_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 112:
#line 910 "parse.y"
    { yyval.tree_expression_type = make_assign_op (DIV_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 113:
#line 912 "parse.y"
    { yyval.tree_expression_type = make_assign_op (LEFTDIV_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 114:
#line 914 "parse.y"
    { yyval.tree_expression_type = make_assign_op (POW_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 115:
#line 916 "parse.y"
    { yyval.tree_expression_type = make_assign_op (LSHIFT_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 116:
#line 918 "parse.y"
    { yyval.tree_expression_type = make_assign_op (RSHIFT_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 117:
#line 920 "parse.y"
    { yyval.tree_expression_type = make_assign_op (EMUL_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 118:
#line 922 "parse.y"
    { yyval.tree_expression_type = make_assign_op (EDIV_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 119:
#line 924 "parse.y"
    { yyval.tree_expression_type = make_assign_op (ELEFTDIV_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 120:
#line 926 "parse.y"
    { yyval.tree_expression_type = make_assign_op (EPOW_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 121:
#line 928 "parse.y"
    { yyval.tree_expression_type = make_assign_op (AND_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 122:
#line 930 "parse.y"
    { yyval.tree_expression_type = make_assign_op (OR_EQ, yyvsp[-2].tree_argument_list_type, yyvsp[-1].tok_val, yyvsp[0].tree_expression_type); }
    break;

  case 123:
#line 934 "parse.y"
    { yyval.tree_index_expression_type = make_index_expression (yyvsp[-1].tree_identifier_type, yyvsp[0].tree_argument_list_type, '('); }
    break;

  case 124:
#line 938 "parse.y"
    {
		    tree_constant *tmp = make_constant (STRING, yyvsp[0].tok_val);
		    yyval.tree_argument_list_type = new tree_argument_list (tmp);
		  }
    break;

  case 125:
#line 943 "parse.y"
    {
		    tree_constant *tmp = make_constant (STRING, yyvsp[0].tok_val);
		    yyvsp[-1].tree_argument_list_type->append (tmp);
		    yyval.tree_argument_list_type = yyvsp[-1].tree_argument_list_type;
		  }
    break;

  case 126:
#line 951 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 127:
#line 953 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_index_expression_type; }
    break;

  case 128:
#line 955 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 129:
#line 957 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_constant_type; }
    break;

  case 130:
#line 965 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_decl_command_type; }
    break;

  case 131:
#line 967 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_command_type; }
    break;

  case 132:
#line 969 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_command_type; }
    break;

  case 133:
#line 971 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_command_type; }
    break;

  case 134:
#line 973 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_command_type; }
    break;

  case 135:
#line 975 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_command_type; }
    break;

  case 136:
#line 977 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_plot_command_type; }
    break;

  case 137:
#line 985 "parse.y"
    { yyval.tree_decl_command_type = make_decl_command (GLOBAL, yyvsp[-1].tok_val, yyvsp[0].tree_decl_init_list_type); }
    break;

  case 138:
#line 987 "parse.y"
    { yyval.tree_decl_command_type = make_decl_command (STATIC, yyvsp[-1].tok_val, yyvsp[0].tree_decl_init_list_type); }
    break;

  case 139:
#line 991 "parse.y"
    { yyval.tree_decl_init_list_type = new tree_decl_init_list (yyvsp[0].tree_decl_elt_type); }
    break;

  case 140:
#line 993 "parse.y"
    {
		    yyvsp[-1].tree_decl_init_list_type->append (yyvsp[0].tree_decl_elt_type);
		    yyval.tree_decl_init_list_type = yyvsp[-1].tree_decl_init_list_type;
		  }
    break;

  case 141:
#line 1000 "parse.y"
    { yyval.tree_decl_elt_type = new tree_decl_elt (yyvsp[0].tree_identifier_type); }
    break;

  case 142:
#line 1002 "parse.y"
    { yyval.tree_decl_elt_type = new tree_decl_elt (yyvsp[-2].tree_identifier_type, yyvsp[0].tree_expression_type); }
    break;

  case 143:
#line 1010 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_if_command_type; }
    break;

  case 144:
#line 1012 "parse.y"
    { yyval.tree_command_type = yyvsp[0].tree_switch_command_type; }
    break;

  case 145:
#line 1020 "parse.y"
    {
		    if (! (yyval.tree_if_command_type = finish_if_command (yyvsp[-3].tok_val, yyvsp[-1].tree_if_command_list_type, yyvsp[0].tok_val, yyvsp[-2].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 146:
#line 1027 "parse.y"
    { yyval.tree_if_command_list_type = yyvsp[0].tree_if_command_list_type; }
    break;

  case 147:
#line 1029 "parse.y"
    {
		    yyvsp[-1].tree_if_command_list_type->append (yyvsp[0].tree_if_clause_type);
		    yyval.tree_if_command_list_type = yyvsp[-1].tree_if_command_list_type;
		  }
    break;

  case 148:
#line 1036 "parse.y"
    { yyval.tree_if_command_list_type = start_if_command (yyvsp[-2].tree_expression_type, yyvsp[0].tree_statement_list_type); }
    break;

  case 149:
#line 1038 "parse.y"
    {
		    yyvsp[-1].tree_if_command_list_type->append (yyvsp[0].tree_if_clause_type);
		    yyval.tree_if_command_list_type = yyvsp[-1].tree_if_command_list_type;
		  }
    break;

  case 150:
#line 1045 "parse.y"
    { yyval.tree_if_clause_type = make_elseif_clause (yyvsp[-2].tree_expression_type, yyvsp[0].tree_statement_list_type, yyvsp[-4].comment_type); }
    break;

  case 151:
#line 1049 "parse.y"
    {
		    yyval.tree_if_clause_type = new tree_if_clause (yyvsp[0].tree_statement_list_type, yyvsp[-2].comment_type);
		  }
    break;

  case 152:
#line 1059 "parse.y"
    {
		    if (! (yyval.tree_switch_command_type = finish_switch_command (yyvsp[-5].tok_val, yyvsp[-3].tree_expression_type, yyvsp[-1].tree_switch_case_list_type, yyvsp[0].tok_val, yyvsp[-4].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 153:
#line 1066 "parse.y"
    { yyval.tree_switch_case_list_type = new tree_switch_case_list (); }
    break;

  case 154:
#line 1068 "parse.y"
    { yyval.tree_switch_case_list_type = yyvsp[0].tree_switch_case_list_type; }
    break;

  case 155:
#line 1070 "parse.y"
    {
		    yyvsp[-1].tree_switch_case_list_type->append (yyvsp[0].tree_switch_case_type);
		    yyval.tree_switch_case_list_type = yyvsp[-1].tree_switch_case_list_type;
		  }
    break;

  case 156:
#line 1077 "parse.y"
    { yyval.tree_switch_case_list_type = new tree_switch_case_list (yyvsp[0].tree_switch_case_type); }
    break;

  case 157:
#line 1079 "parse.y"
    {
		    yyvsp[-1].tree_switch_case_list_type->append (yyvsp[0].tree_switch_case_type);
		    yyval.tree_switch_case_list_type = yyvsp[-1].tree_switch_case_list_type;
		  }
    break;

  case 158:
#line 1086 "parse.y"
    { yyval.tree_switch_case_type = make_switch_case (yyvsp[-2].tree_expression_type, yyvsp[0].tree_statement_list_type, yyvsp[-4].comment_type); }
    break;

  case 159:
#line 1090 "parse.y"
    {
		    yyval.tree_switch_case_type = new tree_switch_case (yyvsp[0].tree_statement_list_type, yyvsp[-2].comment_type);
		  }
    break;

  case 160:
#line 1100 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_while_command (yyvsp[-5].tok_val, yyvsp[-3].tree_expression_type, yyvsp[-1].tree_statement_list_type, yyvsp[0].tok_val, yyvsp[-4].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 161:
#line 1105 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_do_until_command (yyvsp[-5].tok_val, yyvsp[-2].tree_statement_list_type, yyvsp[0].tree_expression_type, yyvsp[-4].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 162:
#line 1110 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_for_command (yyvsp[-7].tok_val, yyvsp[-5].tree_argument_list_type, yyvsp[-3].tree_expression_type, yyvsp[-1].tree_statement_list_type, yyvsp[0].tok_val, yyvsp[-6].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 163:
#line 1115 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_for_command (yyvsp[-9].tok_val, yyvsp[-6].tree_argument_list_type, yyvsp[-4].tree_expression_type, yyvsp[-1].tree_statement_list_type, yyvsp[0].tok_val, yyvsp[-8].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 164:
#line 1126 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_break_command (yyvsp[0].tok_val)))
		      ABORT_PARSE;
		  }
    break;

  case 165:
#line 1131 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_continue_command (yyvsp[0].tok_val)))
		      ABORT_PARSE;
		  }
    break;

  case 166:
#line 1136 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_return_command (yyvsp[0].tok_val)))
		      ABORT_PARSE;
		  }
    break;

  case 167:
#line 1148 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_unwind_command (yyvsp[-8].tok_val, yyvsp[-5].tree_statement_list_type, yyvsp[-1].tree_statement_list_type, yyvsp[0].tok_val, yyvsp[-7].comment_type, yyvsp[-3].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 168:
#line 1154 "parse.y"
    {
		    if (! (yyval.tree_command_type = make_try_command (yyvsp[-8].tok_val, yyvsp[-5].tree_statement_list_type, yyvsp[-1].tree_statement_list_type, yyvsp[0].tok_val, yyvsp[-7].comment_type, yyvsp[-3].comment_type)))
		      ABORT_PARSE;
		  }
    break;

  case 169:
#line 1165 "parse.y"
    { symtab_context.push (curr_sym_tab); }
    break;

  case 170:
#line 1169 "parse.y"
    { curr_sym_tab = fbi_sym_tab; }
    break;

  case 171:
#line 1173 "parse.y"
    { curr_sym_tab = tmp_local_sym_tab; }
    break;

  case 172:
#line 1177 "parse.y"
    { lexer_flags.looking_at_return_list = true; }
    break;

  case 173:
#line 1185 "parse.y"
    {
		    lexer_flags.looking_at_parameter_list = true;

		    if (lexer_flags.looking_at_function_handle)
		      {
		        symtab_context.push (curr_sym_tab);

			tmp_local_sym_tab = new symbol_table ();

			curr_sym_tab = tmp_local_sym_tab;

			lexer_flags.looking_at_function_handle--;
		      }
		  }
    break;

  case 174:
#line 1202 "parse.y"
    { lexer_flags.looking_at_parameter_list = false; }
    break;

  case 175:
#line 1206 "parse.y"
    {
		    lexer_flags.quote_is_transpose = false;
		    yyval.tree_parameter_list_type = yyvsp[-1].tree_parameter_list_type;
		  }
    break;

  case 176:
#line 1211 "parse.y"
    {
		    yyerror ("invalid parameter list");
		    yyval.tree_parameter_list_type = 0;
		    ABORT_PARSE;
		  }
    break;

  case 177:
#line 1219 "parse.y"
    { yyval.tree_parameter_list_type = 0; }
    break;

  case 178:
#line 1221 "parse.y"
    {
		    yyvsp[0].tree_parameter_list_type->mark_as_formal_parameters ();
		    yyval.tree_parameter_list_type = yyvsp[0].tree_parameter_list_type;
		  }
    break;

  case 179:
#line 1226 "parse.y"
    {
		    tree_parameter_list *tmp = new tree_parameter_list ();
		    tmp->mark_varargs_only ();
		    yyval.tree_parameter_list_type = tmp;
		  }
    break;

  case 180:
#line 1232 "parse.y"
    {
		    yyvsp[-2].tree_parameter_list_type->mark_as_formal_parameters ();
		    yyvsp[-2].tree_parameter_list_type->mark_varargs ();
		    yyval.tree_parameter_list_type = yyvsp[-2].tree_parameter_list_type;
		  }
    break;

  case 181:
#line 1240 "parse.y"
    { yyval.tree_parameter_list_type = new tree_parameter_list (yyvsp[0].tree_identifier_type); }
    break;

  case 182:
#line 1242 "parse.y"
    {
		    yyvsp[-2].tree_parameter_list_type->append (yyvsp[0].tree_identifier_type);
		    yyval.tree_parameter_list_type = yyvsp[-2].tree_parameter_list_type;
		  }
    break;

  case 184:
#line 1256 "parse.y"
    {
		    lexer_flags.looking_at_return_list = false;
		    yyval.tree_parameter_list_type = new tree_parameter_list ();
		  }
    break;

  case 185:
#line 1261 "parse.y"
    {
		    lexer_flags.looking_at_return_list = false;
		    tree_parameter_list *tmp = new tree_parameter_list ();
		    tmp->mark_varargs_only ();
		    yyval.tree_parameter_list_type = tmp;
		  }
    break;

  case 186:
#line 1268 "parse.y"
    {
		    lexer_flags.looking_at_return_list = false;
		    tree_parameter_list *tmp = new tree_parameter_list ();
		    tmp->mark_varargs_only ();
		    yyval.tree_parameter_list_type = tmp;
		  }
    break;

  case 187:
#line 1275 "parse.y"
    {
		    lexer_flags.looking_at_return_list = false;
		    yyval.tree_parameter_list_type = yyvsp[-1].tree_parameter_list_type;
		  }
    break;

  case 188:
#line 1280 "parse.y"
    {
		    lexer_flags.looking_at_return_list = false;
		    yyvsp[-3].tree_parameter_list_type->mark_varargs ();
		    yyval.tree_parameter_list_type = yyvsp[-3].tree_parameter_list_type;
		  }
    break;

  case 189:
#line 1288 "parse.y"
    { yyval.tree_parameter_list_type = new tree_parameter_list (yyvsp[0].tree_identifier_type); }
    break;

  case 190:
#line 1290 "parse.y"
    {
		    yyvsp[-2].tree_parameter_list_type->append (yyvsp[0].tree_identifier_type);
		    yyval.tree_parameter_list_type = yyvsp[-2].tree_parameter_list_type;
		  }
    break;

  case 192:
#line 1304 "parse.y"
    { yyval.comment_type = yyvsp[0].comment_type; }
    break;

  case 193:
#line 1308 "parse.y"
    {
		    yyvsp[0].octave_user_function_type->stash_leading_comment (yyvsp[-1].comment_type);
		    recover_from_parsing_function ();
		    yyval.tree_command_type = 0;
		  }
    break;

  case 194:
#line 1314 "parse.y"
    {
		    finish_function (yyvsp[-1].tree_identifier_type, yyvsp[0].octave_user_function_type, yyvsp[-2].comment_type);
		    recover_from_parsing_function ();
		    yyval.tree_command_type = 0;
		  }
    break;

  case 195:
#line 1320 "parse.y"
    {
		    finish_function (yyvsp[-1].tree_parameter_list_type, yyvsp[0].octave_user_function_type, yyvsp[-2].comment_type);
		    recover_from_parsing_function ();
		    yyval.tree_command_type = 0;
		  }
    break;

  case 196:
#line 1328 "parse.y"
    { yyval.octave_user_function_type = yyvsp[0].octave_user_function_type; }
    break;

  case 197:
#line 1332 "parse.y"
    {
		    std::string id_name = yyvsp[-1].tree_identifier_type->name ();

		    if (reading_fcn_file
		        && ! lexer_flags.parsing_nested_function)
		      parent_function_name = (curr_fcn_file_name == id_name)
			? id_name : curr_fcn_file_name;

		    lexer_flags.parsed_function_name = true;

		    yyval.tree_identifier_type = yyvsp[-1].tree_identifier_type;
		  }
    break;

  case 198:
#line 1347 "parse.y"
    {
		    std::string fname = yyvsp[-1].tree_identifier_type->name ();

		    delete yyvsp[-1].tree_identifier_type;

		    if (! (yyval.octave_user_function_type = frob_function (fname, yyvsp[0].octave_user_function_type)))
		      ABORT_PARSE;
		  }
    break;

  case 199:
#line 1358 "parse.y"
    { yyval.octave_user_function_type = start_function (yyvsp[-1].tree_parameter_list_type, yyvsp[0].tree_statement_list_type); }
    break;

  case 200:
#line 1360 "parse.y"
    { yyval.octave_user_function_type = start_function (0, yyvsp[0].tree_statement_list_type); }
    break;

  case 201:
#line 1364 "parse.y"
    { yyval.tree_statement_list_type = yyvsp[-1].tree_statement_list_type; }
    break;

  case 202:
#line 1368 "parse.y"
    {
		    if (! end_token_ok (yyvsp[0].tok_val, token::function_end))
		      ABORT_PARSE;
		  }
    break;

  case 203:
#line 1373 "parse.y"
    {
		    if (lexer_flags.parsing_nested_function)
		      lexer_flags.parsing_nested_function = -1;

		    if (! (reading_fcn_file || reading_script_file
			   || get_input_from_eval_string))
		      YYABORT;
		  }
    break;

  case 204:
#line 1388 "parse.y"
    {
		    if (! (yyval.tree_plot_command_type = make_plot_command (yyvsp[0].tok_val, 0, 0)))
		      ABORT_PARSE;
		  }
    break;

  case 205:
#line 1393 "parse.y"
    {
		    if (! (yyval.tree_plot_command_type = make_plot_command (yyvsp[-2].tok_val, 0, 0)))
		      ABORT_PARSE;
		  }
    break;

  case 206:
#line 1398 "parse.y"
    {
		    maybe_warn_replot_with_args (yyvsp[-1].tok_val);
		    if (! (yyval.tree_plot_command_type = make_plot_command (yyvsp[-1].tok_val, yyvsp[0].plot_limits_type, 0)))
		      ABORT_PARSE;
		  }
    break;

  case 207:
#line 1404 "parse.y"
    {
		    maybe_warn_replot_with_args (yyvsp[-1].tok_val);
		    if (! (yyval.tree_plot_command_type = make_plot_command (yyvsp[-1].tok_val, 0, yyvsp[0].subplot_list_type)))
		      ABORT_PARSE;
		  }
    break;

  case 208:
#line 1410 "parse.y"
    {
		    maybe_warn_replot_with_args (yyvsp[-2].tok_val);
		    if (! (yyval.tree_plot_command_type = make_plot_command (yyvsp[-2].tok_val, yyvsp[-1].plot_limits_type, yyvsp[0].subplot_list_type)))
		      ABORT_PARSE;
		  }
    break;

  case 209:
#line 1418 "parse.y"
    { yyval.plot_limits_type = new plot_limits (yyvsp[0].plot_range_type); }
    break;

  case 210:
#line 1420 "parse.y"
    { yyval.plot_limits_type = new plot_limits (yyvsp[-1].plot_range_type, yyvsp[0].plot_range_type); }
    break;

  case 211:
#line 1422 "parse.y"
    { yyval.plot_limits_type = new plot_limits (yyvsp[-2].plot_range_type, yyvsp[-1].plot_range_type, yyvsp[0].plot_range_type); }
    break;

  case 212:
#line 1426 "parse.y"
    { yyval.plot_range_type = new plot_range (yyvsp[-3].tree_expression_type, yyvsp[-1].tree_expression_type); }
    break;

  case 213:
#line 1428 "parse.y"
    { yyval.plot_range_type = new plot_range (0, yyvsp[-1].tree_expression_type); }
    break;

  case 214:
#line 1430 "parse.y"
    { yyval.plot_range_type = new plot_range (yyvsp[-2].tree_expression_type, 0); }
    break;

  case 215:
#line 1432 "parse.y"
    { yyval.plot_range_type = new plot_range (); }
    break;

  case 216:
#line 1434 "parse.y"
    { yyval.plot_range_type = new plot_range (); }
    break;

  case 217:
#line 1438 "parse.y"
    { yyval.subplot_list_type = new subplot_list (yyvsp[0].subplot_type); }
    break;

  case 218:
#line 1440 "parse.y"
    {
		    yyvsp[-2].subplot_list_type->append (yyvsp[0].subplot_type);
		    yyval.subplot_list_type = yyvsp[-2].subplot_list_type;
		  }
    break;

  case 219:
#line 1447 "parse.y"
    { yyval.subplot_type = new subplot (yyvsp[0].tree_expression_type); }
    break;

  case 220:
#line 1449 "parse.y"
    { yyval.subplot_type = yyvsp[0].subplot_type->add_data (yyvsp[-1].tree_expression_type); }
    break;

  case 221:
#line 1453 "parse.y"
    {
		    subplot *tmp = new subplot ();
		    yyval.subplot_type = tmp->add_clause (yyvsp[0].subplot_using_type);
		  }
    break;

  case 222:
#line 1458 "parse.y"
    {
		    subplot *tmp = new subplot ();
		    yyval.subplot_type = tmp->add_clause (yyvsp[0].tree_expression_type);
		  }
    break;

  case 223:
#line 1463 "parse.y"
    {
		    subplot *tmp = new subplot ();
		    yyval.subplot_type = tmp->add_clause (yyvsp[0].subplot_style_type);
		  }
    break;

  case 224:
#line 1468 "parse.y"
    {
		    subplot *tmp = new subplot ();
		    yyval.subplot_type = tmp->add_clause (yyvsp[0].subplot_axes_type);
		  }
    break;

  case 225:
#line 1473 "parse.y"
    {
		    if (! (yyval.subplot_type = yyvsp[-1].subplot_type->add_clause (yyvsp[0].subplot_using_type)))
		      {
			yyerror ("only one using option may be specified");
			ABORT_PARSE;
		      }
		  }
    break;

  case 226:
#line 1481 "parse.y"
    {
		    if (! (yyval.subplot_type = yyvsp[-1].subplot_type->add_clause (yyvsp[0].tree_expression_type)))
		      {
			yyerror ("only one title option my be specified");
			ABORT_PARSE;
		      }
		  }
    break;

  case 227:
#line 1489 "parse.y"
    {
		    if (! (yyval.subplot_type = yyvsp[-1].subplot_type->add_clause (yyvsp[0].subplot_style_type)))
		      {
			yyerror ("only one style option my be specified");
			ABORT_PARSE;
		      }
		  }
    break;

  case 228:
#line 1497 "parse.y"
    {
		    if (! (yyval.subplot_type = yyvsp[-1].subplot_type->add_clause (yyvsp[0].subplot_axes_type)))
		      {
			yyerror ("only one axes option may be specified");
			ABORT_PARSE;
		      }
		  }
    break;

  case 229:
#line 1507 "parse.y"
    {
		    lexer_flags.in_plot_axes = false;
		    yyval.subplot_axes_type = new subplot_axes (yyvsp[0].tok_val->text ());
		  }
    break;

  case 230:
#line 1514 "parse.y"
    {
		    lexer_flags.in_plot_using = false;
		    yyval.subplot_using_type = yyvsp[0].subplot_using_type;
		  }
    break;

  case 231:
#line 1519 "parse.y"
    {
		    lexer_flags.in_plot_using = false;
		    yyval.subplot_using_type = yyvsp[-1].subplot_using_type->set_format (yyvsp[0].tree_expression_type);
		  }
    break;

  case 232:
#line 1526 "parse.y"
    {
		    subplot_using *tmp = new subplot_using ();
		    yyval.subplot_using_type = tmp->add_qualifier (yyvsp[0].tree_expression_type);
		  }
    break;

  case 233:
#line 1531 "parse.y"
    { yyval.subplot_using_type = yyvsp[-2].subplot_using_type->add_qualifier (yyvsp[0].tree_expression_type); }
    break;

  case 234:
#line 1535 "parse.y"
    { yyval.tree_expression_type = yyvsp[0].tree_expression_type; }
    break;

  case 235:
#line 1539 "parse.y"
    { yyval.subplot_style_type = new subplot_style (yyvsp[0].tok_val->text ()); }
    break;

  case 236:
#line 1541 "parse.y"
    { yyval.subplot_style_type = new subplot_style (yyvsp[-1].tok_val->text (), yyvsp[0].tree_expression_type); }
    break;

  case 237:
#line 1543 "parse.y"
    { yyval.subplot_style_type = new subplot_style (yyvsp[-2].tok_val->text (), yyvsp[-1].tree_expression_type, yyvsp[0].tree_expression_type); }
    break;

  case 238:
#line 1551 "parse.y"
    { yyval.comment_type = octave_comment_buffer::get_comment (); }
    break;

  case 239:
#line 1555 "parse.y"
    { yyerror ("parse error"); }
    break;

  case 241:
#line 1560 "parse.y"
    { yyval.sep_type = ','; }
    break;

  case 242:
#line 1562 "parse.y"
    { yyval.sep_type = ';'; }
    break;

  case 243:
#line 1564 "parse.y"
    { yyval.sep_type = yyvsp[-1].sep_type; }
    break;

  case 244:
#line 1566 "parse.y"
    { yyval.sep_type = yyvsp[-1].sep_type; }
    break;

  case 245:
#line 1570 "parse.y"
    { yyval.sep_type = 0; }
    break;

  case 246:
#line 1572 "parse.y"
    { yyval.sep_type = yyvsp[0].sep_type; }
    break;

  case 247:
#line 1576 "parse.y"
    { yyval.sep_type = ','; }
    break;

  case 248:
#line 1578 "parse.y"
    { yyval.sep_type = ';'; }
    break;

  case 249:
#line 1580 "parse.y"
    { yyval.sep_type = '\n'; }
    break;

  case 250:
#line 1582 "parse.y"
    { yyval.sep_type = yyvsp[-1].sep_type; }
    break;

  case 251:
#line 1584 "parse.y"
    { yyval.sep_type = yyvsp[-1].sep_type; }
    break;

  case 252:
#line 1586 "parse.y"
    { yyval.sep_type = yyvsp[-1].sep_type; }
    break;

  case 253:
#line 1590 "parse.y"
    { yyval.sep_type = 0; }
    break;

  case 254:
#line 1592 "parse.y"
    { yyval.sep_type = yyvsp[0].sep_type; }
    break;


    }

/* Line 1010 of yacc.c.  */
#line 3705 "y.tab.c"

  yyvsp -= yylen;
  yyssp -= yylen;


  YY_STACK_PRINT (yyss, yyssp);

  *++yyvsp = yyval;


  /* Now `shift' the result of the reduction.  Determine what state
     that goes to, based on the state we popped back to and the rule
     number reduced by.  */

  yyn = yyr1[yyn];

  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
    yystate = yytable[yystate];
  else
    yystate = yydefgoto[yyn - YYNTOKENS];

  goto yynewstate;


/*------------------------------------.
| yyerrlab -- here on detecting error |
`------------------------------------*/
yyerrlab:
  /* If not already recovering from an error, report this error.  */
  if (!yyerrstatus)
    {
      ++yynerrs;
#if YYERROR_VERBOSE
      yyn = yypact[yystate];

      if (YYPACT_NINF < yyn && yyn < YYLAST)
	{
	  YYSIZE_T yysize = 0;
	  int yytype = YYTRANSLATE (yychar);
	  const char* yyprefix;
	  char *yymsg;
	  int yyx;

	  /* Start YYX at -YYN if negative to avoid negative indexes in
	     YYCHECK.  */
	  int yyxbegin = yyn < 0 ? -yyn : 0;

	  /* Stay within bounds of both yycheck and yytname.  */
	  int yychecklim = YYLAST - yyn;
	  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
	  int yycount = 0;

	  yyprefix = ", expecting ";
	  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
	    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
	      {
		yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
		yycount += 1;
		if (yycount == 5)
		  {
		    yysize = 0;
		    break;
		  }
	      }
	  yysize += (sizeof ("syntax error, unexpected ")
		     + yystrlen (yytname[yytype]));
	  yymsg = (char *) YYSTACK_ALLOC (yysize);
	  if (yymsg != 0)
	    {
	      char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
	      yyp = yystpcpy (yyp, yytname[yytype]);

	      if (yycount < 5)
		{
		  yyprefix = ", expecting ";
		  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
		    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
		      {
			yyp = yystpcpy (yyp, yyprefix);
			yyp = yystpcpy (yyp, yytname[yyx]);
			yyprefix = " or ";
		      }
		}
	      yyerror (yymsg);
	      YYSTACK_FREE (yymsg);
	    }
	  else
	    yyerror ("syntax error; also virtual memory exhausted");
	}
      else
#endif /* YYERROR_VERBOSE */
	yyerror ("syntax error");
    }



  if (yyerrstatus == 3)
    {
      /* If just tried and failed to reuse lookahead token after an
	 error, discard it.  */

      if (yychar <= YYEOF)
        {
          /* If at end of input, pop the error token,
	     then the rest of the stack, then return failure.  */
	  if (yychar == YYEOF)
	     for (;;)
	       {
		 YYPOPSTACK;
		 if (yyssp == yyss)
		   YYABORT;
		 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
		 yydestruct (yystos[*yyssp], yyvsp);
	       }
        }
      else
	{
	  YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
	  yydestruct (yytoken, &yylval);
	  yychar = YYEMPTY;

	}
    }

  /* Else will try to reuse lookahead token after shifting the error
     token.  */
  goto yyerrlab1;


/*---------------------------------------------------.
| yyerrorlab -- error raised explicitly by YYERROR.  |
`---------------------------------------------------*/
yyerrorlab:

#ifdef __GNUC__
  /* Pacify GCC when the user code never invokes YYERROR and the label
     yyerrorlab therefore never appears in user code.  */
  if (0)
     goto yyerrorlab;
#endif

  yyvsp -= yylen;
  yyssp -= yylen;
  yystate = *yyssp;
  goto yyerrlab1;


/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
`-------------------------------------------------------------*/
yyerrlab1:
  yyerrstatus = 3;	/* Each real token shifted decrements this.  */

  for (;;)
    {
      yyn = yypact[yystate];
      if (yyn != YYPACT_NINF)
	{
	  yyn += YYTERROR;
	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
	    {
	      yyn = yytable[yyn];
	      if (0 < yyn)
		break;
	    }
	}

      /* Pop the current state because it cannot handle the error token.  */
      if (yyssp == yyss)
	YYABORT;

      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
      yydestruct (yystos[yystate], yyvsp);
      YYPOPSTACK;
      yystate = *yyssp;
      YY_STACK_PRINT (yyss, yyssp);
    }

  if (yyn == YYFINAL)
    YYACCEPT;

  YYDPRINTF ((stderr, "Shifting error token, "));

  *++yyvsp = yylval;


  yystate = yyn;
  goto yynewstate;


/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here.  |
`-------------------------------------*/
yyacceptlab:
  yyresult = 0;
  goto yyreturn;

/*-----------------------------------.
| yyabortlab -- YYABORT comes here.  |
`-----------------------------------*/
yyabortlab:
  yyresult = 1;
  goto yyreturn;

#ifndef yyoverflow
/*----------------------------------------------.
| yyoverflowlab -- parser overflow comes here.  |
`----------------------------------------------*/
yyoverflowlab:
  yyerror ("parser stack overflow");
  yyresult = 2;
  /* Fall through.  */
#endif

yyreturn:
#ifndef yyoverflow
  if (yyss != yyssa)
    YYSTACK_FREE (yyss);
#endif
  return yyresult;
}


#line 1595 "parse.y"


// Generic error messages.

static void
yyerror (const char *s)
{
  int err_col = current_input_column - 1;

  OSSTREAM output_buf;

  if (reading_fcn_file || reading_script_file)
    output_buf << "parse error near line " << input_line_number
	       << " of file " << curr_fcn_file_full_name;
  else
    output_buf << "parse error:";

  if (s && strcmp (s, "parse error") != 0)
    output_buf << "\n\n  " << s;

  output_buf << "\n\n";

  if (! current_input_line.empty ())
    {
      size_t len = current_input_line.length ();

      if (current_input_line[len-1] == '\n')
        current_input_line.resize (len-1);

      // Print the line, maybe with a pointer near the error token.

      output_buf << ">>> " << current_input_line << "\n";

      if (err_col == 0)
	err_col = len;

      for (int i = 0; i < err_col + 3; i++)
	output_buf << " ";

      output_buf << "^";
    }

  output_buf << "\n" << OSSTREAM_ENDS;

  parse_error ("%s", OSSTREAM_C_STR (output_buf));

  OSSTREAM_FREEZE (output_buf);
}

// Error mesages for mismatched end tokens.

static void
end_error (const char *type, token::end_tok_type ettype, int l, int c)
{
  static const char *fmt
    = "`%s' command matched by `%s' near line %d column %d";

  switch (ettype)
    {
    case token::simple_end:
      error (fmt, type, "end", l, c);
      break;

    case token::for_end:
      error (fmt, type, "endfor", l, c);
      break;

    case token::function_end:
      error (fmt, type, "endfunction", l, c);
      break;

    case token::if_end:
      error (fmt, type, "endif", l, c);
      break;

    case token::switch_end:
      error (fmt, type, "endswitch", l, c); 
      break;

    case token::while_end:
      error (fmt, type, "endwhile", l, c); 
      break;

    case token::unwind_protect_end:
      error (fmt, type, "end_unwind_protect", l, c); 
      break;

    default:
      panic_impossible ();
      break;
    }
}

// Check to see that end tokens are properly matched.

static bool
end_token_ok (token *tok, token::end_tok_type expected)
{
  bool retval = true;

  token::end_tok_type ettype = tok->ettype ();

  if (ettype != expected && ettype != token::simple_end)
    {
      retval = false;

      yyerror ("parse error");

      int l = tok->line ();
      int c = tok->column ();

      switch (expected)
	{
	case token::for_end:
	  end_error ("for", ettype, l, c);
	  break;

	case token::function_end:
	  end_error ("function", ettype, l, c);
	  break;

	case token::if_end:
	  end_error ("if", ettype, l, c);
	  break;

	case token::try_catch_end:
	  end_error ("try", ettype, l, c);
	  break;

	case token::switch_end:
	  end_error ("switch", ettype, l, c);
	  break;

	case token::unwind_protect_end:
	  end_error ("unwind_protect", ettype, l, c);
	  break;

	case token::while_end:
	  end_error ("while", ettype, l, c);
	  break;

	default:
	  panic_impossible ();
	  break;
	}
    }

  return retval;
}

// Print a warning if we are looking at a "replot" command with
// arguments.
static void
maybe_warn_replot_with_args (token *tok)
{
  static bool warned = false;

  if (! warned && tok)
    {
      token::plot_tok_type pttype = tok->pttype ();

      if (pttype == token::replot)
	{
	  warned = true;
	  warning ("Passing arguments to replot is deprecated and.");
	  warning ("will not be allowed in a future version of Octave.");
	  warning ("If you must have this functionality, use");
	  warning ("__gnuplot_replot__ instead.");
	}
    }
}

// Maybe print a warning if an assignment expression is used as the
// test in a logical expression.

static void
maybe_warn_assign_as_truth_value (tree_expression *expr)
{
  if (Vwarn_assign_as_truth_value
      && expr->is_assignment_expression ()
      && expr->paren_count () < 2)
    {
      warning ("suggest parenthesis around assignment used as truth value");
    }
}

// Maybe print a warning about switch labels that aren't constants.

static void
maybe_warn_variable_switch_label (tree_expression *expr)
{
  if (Vwarn_variable_switch_label && ! expr->is_constant ())
    {
      warning ("variable switch label");
    }
}

// Create a plot command.

static tree_plot_command *
make_plot_command (token *tok, plot_limits *range, subplot_list *list)
{
  if (range)
    {
      if (tok->pttype () == token::replot
	  || tok->pttype () == token::gnuplot_replot)
	{
	  yyerror ("cannot specify new ranges with replot");
	  return 0;
	}
    }
  else if (! list
	   && ! (tok->pttype () == token::replot
		 || tok->pttype () == token::gnuplot_replot))
    {
      yyerror ("must have something to plot");
      return 0;
    }

  lexer_flags.plotting = false;
  lexer_flags.past_plot_range = false;
  lexer_flags.in_plot_range = false;
  lexer_flags.in_plot_using = false;
  lexer_flags.in_plot_style = false;
  
  return new tree_plot_command (list, range, tok->pttype ());
}

static tree_expression *
fold (tree_binary_expression *e)
{
  tree_expression *retval = e;

  unwind_protect::begin_frame ("fold_binary_expression");

  unwind_protect_int (error_state);
  unwind_protect_int (warning_state);

  unwind_protect_bool (discard_error_messages);
  unwind_protect_bool (discard_warning_messages);

  discard_error_messages = true;
  discard_warning_messages = true;

  tree_expression *op1 = e->lhs ();
  tree_expression *op2 = e->rhs ();

  octave_value::binary_op op_type = e->op_type ();

  if (op1->is_constant () && op2->is_constant ()
      && (! ((Vwarn_associativity_change
	      && (op_type == POW || op_type == EPOW))
	     || (Vwarn_precedence_change
		 && (op_type == EXPR_OR || op_type == EXPR_OR_OR)))))
    {
      octave_value tmp = e->rvalue ();

      if (! (error_state || warning_state))
	{
	  tree_constant *tc_retval = new tree_constant (tmp);

	  OSSTREAM buf;

	  tree_print_code tpc (buf);

	  e->accept (tpc);

	  buf << OSSTREAM_ENDS;

	  tc_retval->stash_original_text (OSSTREAM_STR (buf));

	  OSSTREAM_FREEZE (buf);

	  delete e;

	  retval = tc_retval;
	}
    }

  unwind_protect::run_frame ("fold_binary_expression");

  return retval;
}

static tree_expression *
fold (tree_unary_expression *e)
{
  tree_expression *retval = e;

  unwind_protect::begin_frame ("fold_unary_expression");

  unwind_protect_int (error_state);
  unwind_protect_int (warning_state);

  unwind_protect_bool (discard_error_messages);
  unwind_protect_bool (discard_warning_messages);

  discard_error_messages = true;
  discard_warning_messages = true;

  tree_expression *op = e->operand ();

  if (op->is_constant ())
    {
      octave_value tmp = e->rvalue ();

      if (! (error_state || warning_state))
	{
	  tree_constant *tc_retval = new tree_constant (tmp);

	  OSSTREAM buf;

	  tree_print_code tpc (buf);

	  e->accept (tpc);

	  buf << OSSTREAM_ENDS;

	  tc_retval->stash_original_text (OSSTREAM_STR (buf));

	  OSSTREAM_FREEZE (buf);

	  delete e;

	  retval = tc_retval;
	}
    }

  unwind_protect::run_frame ("fold_unary_expression");

  return retval;
}

// Finish building a range.

static tree_expression *
finish_colon_expression (tree_colon_expression *e)
{
  tree_expression *retval = e;

  unwind_protect::begin_frame ("finish_colon_expression");

  unwind_protect_int (error_state);
  unwind_protect_int (warning_state);

  unwind_protect_bool (discard_error_messages);
  unwind_protect_bool (discard_warning_messages);

  discard_error_messages = true;
  discard_warning_messages = true;

  tree_expression *base = e->base ();
  tree_expression *limit = e->limit ();
  tree_expression *incr = e->increment ();

  if (base)
    {
      if (limit)
	{
	  if (base->is_constant () && limit->is_constant ()
	      && (! incr || (incr && incr->is_constant ())))
	    {
	      octave_value tmp = e->rvalue ();

	      if (! (error_state || warning_state))
		{
		  tree_constant *tc_retval = new tree_constant (tmp);

		  OSSTREAM buf;

		  tree_print_code tpc (buf);

		  e->accept (tpc);

		  buf << OSSTREAM_ENDS;

		  tc_retval->stash_original_text (OSSTREAM_STR (buf));

		  OSSTREAM_FREEZE (buf);

		  delete e;

		  retval = tc_retval;
		}
	    }
	}
      else
	{
	  e->preserve_base ();
	  delete e;

	  // XXX FIXME XXX -- need to attempt constant folding here
	  // too (we need a generic way to do that).
	  retval = base;
	}
    }

  unwind_protect::run_frame ("finish_colon_expression");

  return retval;
}

// Make a constant.

static tree_constant *
make_constant (int op, token *tok_val)
{
  int l = tok_val->line ();
  int c = tok_val->column ();

  tree_constant *retval = 0;

  switch (op)
    {
    case NUM:
      {
	octave_value tmp (tok_val->number ());
	retval = new tree_constant (tmp, l, c);
	retval->stash_original_text (tok_val->text_rep ());
      }
      break;

    case IMAG_NUM:
      {
	octave_value tmp (Complex (0.0, tok_val->number ()));
	retval = new tree_constant (tmp, l, c);
	retval->stash_original_text (tok_val->text_rep ());
      }
      break;

    case STRING:
      {
	octave_value tmp (tok_val->text ());
	retval = new tree_constant (tmp, l, c);
      }
      break;

    default:
      panic_impossible ();
      break;
    }

  return retval;
}

// Make a function handle.

static tree_fcn_handle *
make_fcn_handle (token *tok_val)
{
  int l = tok_val->line ();
  int c = tok_val->column ();

  tree_fcn_handle *retval = new tree_fcn_handle (tok_val->text (), l, c);

  return retval;
}

// Make an anonymous function handle.

static tree_constant *
make_anon_fcn_handle (tree_parameter_list *param_list, tree_statement *stmt)
{
  // XXX FIXME XXX -- need to get these from the location of the @ symbol.

  int l = -1;
  int c = -1;

  tree_parameter_list *ret_list = 0;

  if (stmt && stmt->is_expression ())
    {
      symbol_record *sr = curr_sym_tab->lookup ("__retval__", true);

      tree_expression *e = stmt->expression ();

      tree_identifier *id = new tree_identifier (sr);

      tree_simple_assignment *asn = new tree_simple_assignment (id, e);

      stmt->set_expression (asn);

      stmt->set_print_flag (false);

      // XXX FIXME XXX -- would like to delete old_stmt here or
      // replace expression inside it with the new expression we just
      // created so we don't have to create a new statement at all.

      id = new tree_identifier (sr);

      ret_list = new tree_parameter_list (id);
    }

  tree_statement_list *body = new tree_statement_list (stmt);

  body->mark_as_function_body ();

  octave_value fcn (new octave_user_function (param_list, ret_list,
					      body, curr_sym_tab));

  if (symtab_context.empty ())
    panic_impossible ();

  curr_sym_tab = symtab_context.top ();
  symtab_context.pop ();

  octave_value fh (new octave_fcn_handle (fcn, "@<anonymous>"));

  tree_constant *retval = new tree_constant (fh, l, c);

  return retval;
}

static void
maybe_warn_associativity_change (tree_expression *op)
{
  if (Vwarn_associativity_change
      && op->paren_count () == 0 && op->is_binary_expression ())
    {
      tree_binary_expression *e
	= dynamic_cast<tree_binary_expression *> (op);

      octave_value::binary_op op_type = e->op_type ();

      if (op_type == octave_value::op_pow
	  || op_type == octave_value::op_el_pow)
	{
	  std::string op_str = octave_value::binary_op_as_string (op_type);

	  warning ("meaning may have changed due to change in associativity for %s operator", op_str.c_str ());
        }
    }
}

// Build a binary expression.

static tree_expression *
make_binary_op (int op, tree_expression *op1, token *tok_val,
		tree_expression *op2)
{
  octave_value::binary_op t = octave_value::unknown_binary_op;

  switch (op)
    {
    case POW:
      t = octave_value::op_pow;
      maybe_warn_associativity_change (op1);
      break;

    case EPOW:
      t = octave_value::op_el_pow;
      maybe_warn_associativity_change (op1);
      break;

    case '+':
      t = octave_value::op_add;
      break;

    case '-':
      t = octave_value::op_sub;
      break;

    case '*':
      t = octave_value::op_mul;
      break;

    case '/':
      t = octave_value::op_div;
      break;

    case EMUL:
      t = octave_value::op_el_mul;
      break;

    case EDIV:
      t = octave_value::op_el_div;
      break;

    case LEFTDIV:
      t = octave_value::op_ldiv;
      break;

    case ELEFTDIV:
      t = octave_value::op_el_ldiv;
      break;

    case LSHIFT:
      t = octave_value::op_lshift;
      break;

    case RSHIFT:
      t = octave_value::op_rshift;
      break;

    case EXPR_LT:
      t = octave_value::op_lt;
      break;

    case EXPR_LE:
      t = octave_value::op_le;
      break;

    case EXPR_EQ:
      t = octave_value::op_eq;
      break;

    case EXPR_GE:
      t = octave_value::op_ge;
      break;

    case EXPR_GT:
      t = octave_value::op_gt;
      break;

    case EXPR_NE:
      t = octave_value::op_ne;
      break;

    case EXPR_AND:
      t = octave_value::op_el_and;
      break;

    case EXPR_OR:
      t = octave_value::op_el_or;
      if (Vwarn_precedence_change
          && op2->paren_count () == 0 && op2->is_binary_expression ())
        {
	  tree_binary_expression *e
	    = dynamic_cast<tree_binary_expression *> (op2);

	  if (e->op_type () == octave_value::op_el_and)
	    warning ("meaning may have changed due to change in precedence for & and | operators");
        }
      break;

    default:
      panic_impossible ();
      break;
    }

  int l = tok_val->line ();
  int c = tok_val->column ();

  tree_binary_expression *e
    = new tree_binary_expression (op1, op2, l, c, t);

  return fold (e);
}

// Build a boolean expression.

static tree_expression *
make_boolean_op (int op, tree_expression *op1, token *tok_val,
		 tree_expression *op2)
{
  tree_boolean_expression::type t;

  switch (op)
    {
    case EXPR_AND_AND:
      t = tree_boolean_expression::bool_and;
      break;

    case EXPR_OR_OR:
      t = tree_boolean_expression::bool_or;
      if (Vwarn_precedence_change
          && op2->paren_count () == 0 && op2->is_boolean_expression ())
        {
	  tree_boolean_expression *e
	    = dynamic_cast<tree_boolean_expression *> (op2);

	  if (e->op_type () == tree_boolean_expression::bool_and)
	    warning ("meaning may have changed due to change in precedence for && and || operators");
        }
      break;

    default:
      panic_impossible ();
      break;
    }

  int l = tok_val->line ();
  int c = tok_val->column ();

  tree_boolean_expression *e
    = new tree_boolean_expression (op1, op2, l, c, t);

  return fold (e);
}

// Build a prefix expression.

static tree_expression *
make_prefix_op (int op, tree_expression *op1, token *tok_val)
{
  octave_value::unary_op t = octave_value::unknown_unary_op;

  switch (op)
    {
    case EXPR_NOT:
      t = octave_value::op_not;
      break;

    case '+':
      t = octave_value::op_uplus;
      break;

    case '-':
      t = octave_value::op_uminus;
      break;

    case PLUS_PLUS:
      t = octave_value::op_incr;
      break;

    case MINUS_MINUS:
      t = octave_value::op_decr;
      break;

    default:
      panic_impossible ();
      break;
    }

  int l = tok_val->line ();
  int c = tok_val->column ();

  tree_prefix_expression *e
    = new tree_prefix_expression (op1, l, c, t);

  return fold (e);
}

// Build a postfix expression.

static tree_expression *
make_postfix_op (int op, tree_expression *op1, token *tok_val)
{
  octave_value::unary_op t = octave_value::unknown_unary_op;

  switch (op)
    {
    case QUOTE:
      t = octave_value::op_hermitian;
      break;

    case TRANSPOSE:
      t = octave_value::op_transpose;
      break;

    case PLUS_PLUS:
      t = octave_value::op_incr;
      break;

    case MINUS_MINUS:
      t = octave_value::op_decr;
      break;

    default:
      panic_impossible ();
      break;
    }

  int l = tok_val->line ();
  int c = tok_val->column ();

  tree_postfix_expression *e
    = new tree_postfix_expression (op1, l, c, t);

  return fold (e);
}

// Build an unwind-protect command.

static tree_command *
make_unwind_command (token *unwind_tok, tree_statement_list *body,
		     tree_statement_list *cleanup, token *end_tok,
		     octave_comment_list *lc, octave_comment_list *mc)
{
  tree_command *retval = 0;

  if (end_token_ok (end_tok, token::unwind_protect_end))
    {
      octave_comment_list *tc = octave_comment_buffer::get_comment ();

      int l = unwind_tok->line ();
      int c = unwind_tok->column ();

      retval = new tree_unwind_protect_command (body, cleanup,
						lc, mc, tc, l, c);
    }

  return retval;
}

// Build a try-catch command.

static tree_command *
make_try_command (token *try_tok, tree_statement_list *body,
		  tree_statement_list *cleanup, token *end_tok,
		  octave_comment_list *lc, octave_comment_list *mc)
{
  tree_command *retval = 0;

  if (end_token_ok (end_tok, token::try_catch_end))
    {
      octave_comment_list *tc = octave_comment_buffer::get_comment ();

      int l = try_tok->line ();
      int c = try_tok->column ();

      retval = new tree_try_catch_command (body, cleanup,
					   lc, mc, tc, l, c);
    }

  return retval;
}

// Build a while command.

static tree_command *
make_while_command (token *while_tok, tree_expression *expr,
		    tree_statement_list *body, token *end_tok,
		    octave_comment_list *lc)
{
  tree_command *retval = 0;

  maybe_warn_assign_as_truth_value (expr);

  if (end_token_ok (end_tok, token::while_end))
    {
      octave_comment_list *tc = octave_comment_buffer::get_comment ();

      lexer_flags.looping--;

      int l = while_tok->line ();
      int c = while_tok->column ();

      retval = new tree_while_command (expr, body, lc, tc, l, c);
    }

  return retval;
}

// Build a do-until command.

static tree_command *
make_do_until_command (token *do_tok, tree_statement_list *body,
		       tree_expression *expr, octave_comment_list *lc)
{
  tree_command *retval = 0;

  maybe_warn_assign_as_truth_value (expr);

  octave_comment_list *tc = octave_comment_buffer::get_comment ();

  lexer_flags.looping--;

  int l = do_tok->line ();
  int c = do_tok->column ();

  retval = new tree_do_until_command (expr, body, lc, tc, l, c);

  return retval;
}

// Build a for command.

static tree_command *
make_for_command (token *for_tok, tree_argument_list *lhs,
		  tree_expression *expr, tree_statement_list *body,
		  token *end_tok, octave_comment_list *lc)
{
  tree_command *retval = 0;

  if (end_token_ok (end_tok, token::for_end))
    {
      octave_comment_list *tc = octave_comment_buffer::get_comment ();

      lexer_flags.looping--;

      int l = for_tok->line ();
      int c = for_tok->column ();

      if (lhs->length () == 1)
	{
	  tree_expression *tmp = lhs->remove_front ();

	  retval = new tree_simple_for_command (tmp, expr, body,
						lc, tc, l, c);

	  delete lhs;
	}
      else
	retval = new tree_complex_for_command (lhs, expr, body,
					       lc, tc, l, c);
    }

  return retval;
}

// Build a break command.

static tree_command *
make_break_command (token *break_tok)
{
  tree_command *retval = 0;

  int l = break_tok->line ();
  int c = break_tok->column ();

  if (lexer_flags.looping || lexer_flags.defining_func
      || reading_script_file || evaluating_function_body
      || evaluating_looping_command)
    retval = new tree_break_command (l, c);
  else
    retval = new tree_no_op_command ("break", l, c);

  return retval;
}

// Build a continue command.

static tree_command *
make_continue_command (token *continue_tok)
{
  tree_command *retval = 0;

  int l = continue_tok->line ();
  int c = continue_tok->column ();

  if (lexer_flags.looping || evaluating_looping_command)
    retval = new tree_continue_command (l, c);
  else
    retval = new tree_no_op_command ("continue", l, c);

  return retval;
}

// Build a return command.

static tree_command *
make_return_command (token *return_tok)
{
  tree_command *retval = 0;

  int l = return_tok->line ();
  int c = return_tok->column ();

  if (lexer_flags.defining_func || reading_script_file
      || evaluating_function_body)
    retval = new tree_return_command (l, c);
  else
    retval = new tree_no_op_command ("return", l, c);

  return retval;
}

// Start an if command.

static tree_if_command_list *
start_if_command (tree_expression *expr, tree_statement_list *list)
{
  maybe_warn_assign_as_truth_value (expr);

  tree_if_clause *t = new tree_if_clause (expr, list);

  return new tree_if_command_list (t);
}

// Finish an if command.

static tree_if_command *
finish_if_command (token *if_tok, tree_if_command_list *list,
		   token *end_tok, octave_comment_list *lc)
{
  tree_if_command *retval = 0;

  if (end_token_ok (end_tok, token::if_end))
    {
      octave_comment_list *tc = octave_comment_buffer::get_comment ();

      int l = if_tok->line ();
      int c = if_tok->column ();

      retval = new tree_if_command (list, lc, tc, l, c);
    }

  return retval;
}

// Build an elseif clause.

static tree_if_clause *
make_elseif_clause (tree_expression *expr, tree_statement_list *list,
		    octave_comment_list *lc)
{
  maybe_warn_assign_as_truth_value (expr);

  return new tree_if_clause (expr, list, lc);
}

// Finish a switch command.

static tree_switch_command *
finish_switch_command (token *switch_tok, tree_expression *expr,
		       tree_switch_case_list *list, token *end_tok,
		       octave_comment_list *lc)
{
  tree_switch_command *retval = 0;

  if (end_token_ok (end_tok, token::switch_end))
    {
      octave_comment_list *tc = octave_comment_buffer::get_comment ();

      int l = switch_tok->line ();
      int c = switch_tok->column ();

      retval = new tree_switch_command (expr, list, lc, tc, l, c);
    }

  return retval;
}

// Build a switch case.

static tree_switch_case *
make_switch_case (tree_expression *expr, tree_statement_list *list,
		  octave_comment_list *lc)
{
  maybe_warn_variable_switch_label (expr);

  return new tree_switch_case (expr, list, lc);
}

// Build an assignment to a variable.

static tree_expression *
make_assign_op (int op, tree_argument_list *lhs, token *eq_tok,
		tree_expression *rhs)
{
  tree_expression *retval = 0;

  octave_value::assign_op t = octave_value::unknown_assign_op;

  switch (op)
    {
    case '=':
      t = octave_value::op_asn_eq;
      break;

    case ADD_EQ:
      t = octave_value::op_add_eq;
      break;

    case SUB_EQ:
      t = octave_value::op_sub_eq;
      break;

    case MUL_EQ:
      t = octave_value::op_mul_eq;
      break;

    case DIV_EQ:
      t = octave_value::op_div_eq;
      break;

    case LEFTDIV_EQ:
      t = octave_value::op_ldiv_eq;
      break;

    case POW_EQ:
      t = octave_value::op_pow_eq;
      break;

    case LSHIFT_EQ:
      t = octave_value::op_lshift_eq;
      break;

    case RSHIFT_EQ:
      t = octave_value::op_rshift_eq;
      break;

    case EMUL_EQ:
      t = octave_value::op_el_mul_eq;
      break;

    case EDIV_EQ:
      t = octave_value::op_el_div_eq;
      break;

    case ELEFTDIV_EQ:
      t = octave_value::op_el_ldiv_eq;
      break;

    case EPOW_EQ:
      t = octave_value::op_el_pow_eq;
      break;

    case AND_EQ:
      t = octave_value::op_el_and_eq;
      break;

    case OR_EQ:
      t = octave_value::op_el_or_eq;
      break;

    default:
      panic_impossible ();
      break;
    }

  int l = eq_tok->line ();
  int c = eq_tok->column ();

  if (lhs->length () == 1)
    {
      tree_expression *tmp = lhs->remove_front ();

      retval = new tree_simple_assignment (tmp, rhs, false, l, c, t);

      delete lhs;
    }
  else
    return new tree_multi_assignment (lhs, rhs, false, l, c, t);

  return retval;
}

// Begin defining a function.

static octave_user_function *
start_function (tree_parameter_list *param_list, tree_statement_list *body)
{
  body->mark_as_function_body ();

  // We'll fill in the return list later.

  octave_user_function *fcn
    = new octave_user_function (param_list, 0, body, curr_sym_tab);

  if (fcn)
    {
      octave_comment_list *tc = octave_comment_buffer::get_comment ();

      fcn->stash_trailing_comment (tc);
    }

  return fcn;
}

// Do most of the work for defining a function.

static octave_user_function *
frob_function (const std::string& fname, octave_user_function *fcn)
{
  std::string id_name = fname;

  // If input is coming from a file, issue a warning if the name of
  // the file does not match the name of the function stated in the
  // file.  Matlab doesn't provide a diagnostic (it ignores the stated
  // name).

  if (reading_fcn_file)
    {
      if (! lexer_flags.parsing_nested_function
          && curr_fcn_file_name != id_name)
	{
	  if (Vwarn_function_name_clash)
	    warning ("function name `%s' does not agree with function\
 file name `%s'", id_name.c_str (), curr_fcn_file_full_name.c_str ());

	  id_name = curr_fcn_file_name;
	}

      octave_time now;

      fcn->stash_fcn_file_name (curr_fcn_file_full_name);
      fcn->stash_fcn_file_time (now);
      fcn->mark_as_system_fcn_file ();

      if (Vwarn_future_time_stamp)
	{
	  std::string nm = fcn->fcn_file_name ();

	  file_stat fs (nm);

	  if (fs && fs.is_newer (now))
	    warning ("time stamp for `%s' is in the future", nm.c_str ());
	}
    }
  else if (! (input_from_tmp_history_file || input_from_startup_file)
	   && reading_script_file
	   && curr_fcn_file_name == id_name)
    {
      warning ("function `%s' defined within script file `%s'",
	       id_name.c_str (), curr_fcn_file_full_name.c_str ());
    }

  fcn->stash_function_name (id_name);

  // Enter the new function in fbi_sym_tab.  If there is already a
  // variable of the same name in the current symbol table, we won't
  // find the new function when we try to call it, so we need to clear
  // the old symbol from the current symbol table.  Note that this
  // means that for things like
  //
  //   function f () eval ("function g () 1, end"); end
  //   g = 13;
  //   f ();
  //   g
  //
  // G will still refer to the variable G (with value 13) rather
  // than the function G, until the variable G is cleared.

  curr_sym_tab->clear (id_name);

  symbol_record *sr = fbi_sym_tab->lookup (id_name, true);

  if (sr)
    {
      fcn->stash_symtab_ptr (sr);

      if (lexer_flags.parsing_nested_function)
        fcn->mark_as_nested_function ();
    }
  else
    panic_impossible ();

  sr->define (fcn, symbol_record::USER_FUNCTION);

  if (! help_buf.empty ())
    {
      sr->document (help_buf.top ());
      help_buf.pop ();
    }

  if (lexer_flags.parsing_nested_function < 0)
    lexer_flags.parsing_nested_function = 0;

  return fcn;
}

// Finish defining a function.

static octave_user_function *
finish_function (tree_identifier *id, octave_user_function *fcn,
		 octave_comment_list *lc)
{
  tree_parameter_list *tpl = new tree_parameter_list (id);

  tpl->mark_as_formal_parameters ();

  fcn->stash_leading_comment (lc);

  return fcn->define_ret_list (tpl);
}

// Finish defining a function a different way.

static octave_user_function *
finish_function (tree_parameter_list *ret_list,
		 octave_user_function *fcn, octave_comment_list *lc)
{
  ret_list->mark_as_formal_parameters ();

  fcn->stash_leading_comment (lc);

  return fcn->define_ret_list (ret_list);
}

static void
recover_from_parsing_function (void)
{
  if (symtab_context.empty ())
    panic_impossible ();

  curr_sym_tab = symtab_context.top ();
  symtab_context.pop ();

  lexer_flags.defining_func = false;
  lexer_flags.beginning_of_function = false;
  lexer_flags.parsed_function_name = false;
  lexer_flags.looking_at_return_list = false;
  lexer_flags.looking_at_parameter_list = false;
}

// Make an index expression.

static tree_index_expression *
make_index_expression (tree_expression *expr, tree_argument_list *args,
		       char type)
{
  tree_index_expression *retval = 0;

  int l = expr->line ();
  int c = expr->column ();

  expr->mark_postfix_indexed ();

  if (expr->is_index_expression ())
    {
      tree_index_expression *tmp = static_cast<tree_index_expression *> (expr);

      tmp->append (args, type);

      retval = tmp;
    }
  else
    retval = new tree_index_expression (expr, args, l, c, type);

  return retval;
}

// Make an indirect reference expression.

static tree_index_expression *
make_indirect_ref (tree_expression *expr, const std::string& elt)
{
  tree_index_expression *retval = 0;

  int l = expr->line ();
  int c = expr->column ();

  if (expr->is_index_expression ())
    {
      tree_index_expression *tmp = static_cast<tree_index_expression *> (expr);

      tmp->append (elt);

      retval = tmp;
    }
  else
    retval = new tree_index_expression (expr, elt, l, c);

  lexer_flags.looking_at_indirect_ref = false;

  return retval;
}

// Make an indirect reference expression with dynamic field name.

static tree_index_expression *
make_indirect_ref (tree_expression *expr, tree_expression *elt)
{
  tree_index_expression *retval = 0;

  int l = expr->line ();
  int c = expr->column ();

  if (expr->is_index_expression ())
    {
      tree_index_expression *tmp = static_cast<tree_index_expression *> (expr);

      tmp->append (elt);

      retval = tmp;
    }
  else
    retval = new tree_index_expression (expr, elt, l, c);

  lexer_flags.looking_at_indirect_ref = false;

  return retval;
}

// Make a declaration command.

static tree_decl_command *
make_decl_command (int tok, token *tok_val, tree_decl_init_list *lst)
{
  tree_decl_command *retval = 0;

  int l = tok_val->line ();
  int c = tok_val->column ();

  switch (tok)
    {
    case GLOBAL:
      retval = new tree_global_command (lst, l, c);
      break;

    case STATIC:
      if (lexer_flags.defining_func)
	retval = new tree_static_command (lst, l, c);
      else
	{
	  if (reading_script_file)
	    warning ("ignoring persistent declaration near line %d of file `%s'",
		     l, curr_fcn_file_full_name.c_str ());
	  else
	    warning ("ignoring persistent declaration near line %d", l);
	}
      break;

    default:
      panic_impossible ();
      break;
    }

  return retval;
}

// Finish building a matrix list.

static tree_expression *
finish_matrix (tree_matrix *m)
{
  tree_expression *retval = m;

  unwind_protect::begin_frame ("finish_matrix");

  unwind_protect_int (error_state);
  unwind_protect_int (warning_state);

  unwind_protect_bool (discard_error_messages);
  unwind_protect_bool (discard_warning_messages);

  discard_error_messages = true;
  discard_warning_messages = true;

  if (m->all_elements_are_constant ())
    {
      octave_value tmp = m->rvalue ();

      if (! (error_state || warning_state))
	{
	  tree_constant *tc_retval = new tree_constant (tmp);

	  OSSTREAM buf;

	  tree_print_code tpc (buf);

	  m->accept (tpc);

	  buf << OSSTREAM_ENDS;

	  tc_retval->stash_original_text (OSSTREAM_STR (buf));

	  OSSTREAM_FREEZE (buf);

	  delete m;

	  retval = tc_retval;
	}
    }

  unwind_protect::run_frame ("finish_matrix");

  return retval;
}

// Finish building a cell list.

static tree_expression *
finish_cell (tree_cell *c)
{
  // For now, this doesn't do anything.

  return c;
}

static void
maybe_warn_missing_semi (tree_statement_list *t)
{
  if (lexer_flags.defining_func && Vwarn_missing_semicolon)
    {
      tree_statement *tmp = t->back();

      if (tmp->is_expression ())
	warning ("missing semicolon near line %d, column %d in file `%s'",
		 tmp->line (), tmp->column (),
		 curr_fcn_file_full_name.c_str ());
    }
}

static void
set_stmt_print_flag (tree_statement_list *list, char sep,
		     bool warn_missing_semi)
{
  switch (sep)
    {
    case ';':
      {
	tree_statement *tmp = list->back ();
	tmp->set_print_flag (0);
      }
      break;

    case 0:
    case ',':
    case '\n':
      if (warn_missing_semi)
	maybe_warn_missing_semi (list);
      break;

    default:
      warning ("unrecognized separator type!");
      break;
    }
}

void
parse_and_execute (FILE *f)
{
  unwind_protect::begin_frame ("parse_and_execute");

  YY_BUFFER_STATE old_buf = current_buffer ();
  YY_BUFFER_STATE new_buf = create_buffer (f);

  unwind_protect::add (restore_input_buffer, old_buf);
  unwind_protect::add (delete_input_buffer, new_buf);

  switch_to_buffer (new_buf);

  unwind_protect_bool (line_editing);
  unwind_protect_bool (input_from_command_line_file);
  unwind_protect_bool (get_input_from_eval_string);
  unwind_protect_bool (parser_end_of_input);

  line_editing = false;
  input_from_command_line_file = false;
  get_input_from_eval_string = false;
  parser_end_of_input = false;

  unwind_protect_ptr (curr_sym_tab);

  int retval;
  do
    {
      reset_parser ();

      retval = yyparse ();

      if (retval == 0)
        {
          if (global_command)
	    {
	      global_command->eval ();

	      delete global_command;

	      global_command = 0;

	      OCTAVE_QUIT;

	      bool quit = (tree_return_command::returning
			   || tree_break_command::breaking);

	      if (tree_return_command::returning)
		tree_return_command::returning = 0;

	      if (tree_break_command::breaking)
		tree_break_command::breaking--;

	      if (error_state)
		{
		  error ("near line %d of file `%s'", input_line_number,
			 curr_fcn_file_full_name.c_str ());

		  break;
		}

	      if (quit)
		break;
	    }
	  else if (parser_end_of_input)
	    break;
        }
    }
  while (retval == 0);

  unwind_protect::run_frame ("parse_and_execute");
}

static void
safe_fclose (void *f)
{
  // XXX FIXME XXX -- comments at the end of an input file are
  // discarded (otherwise, they would be appended to the next
  // statement, possibly from the command line or another file, which
  // can be quite confusing).

  octave_comment_buffer::get_comment ();

  if (f)
    fclose (static_cast<FILE *> (f));
}

void
parse_and_execute (const std::string& s, bool verbose, const char *warn_for)
{
  unwind_protect::begin_frame ("parse_and_execute_2");

  unwind_protect_bool (reading_script_file);
  unwind_protect_str (curr_fcn_file_full_name);

  reading_script_file = true;
  curr_fcn_file_full_name = s;

  FILE *f = get_input_from_file (s, 0);

  if (f)
    {
      unwind_protect::add (safe_fclose, f);

      unwind_protect_int (input_line_number);
      unwind_protect_int (current_input_column);

      input_line_number = 0;
      current_input_column = 1;

      if (verbose)
	{
	  std::cout << "reading commands from " << s << " ... ";
	  reading_startup_message_printed = true;
	  std::cout.flush ();
	}

      parse_and_execute (f);

      if (verbose)
	std::cout << "done." << std::endl;
    }
  else if (warn_for)
    error ("%s: unable to open file `%s'", warn_for, s.c_str ());

  unwind_protect::run_frame ("parse_and_execute_2");
}

static bool
looks_like_copyright (const std::string& s)
{
  // Perhaps someday we will want to do more here, so leave this as a
  // separate function.

  return (s.substr (0, 9) == "Copyright");
}

static int
text_getc (FILE *f)
{
  int c = getc (f);

  // Convert CRLF into just LF.

  if (c == '\r')
    {
      c = getc (f);

      if (c != '\n')
	{
	  ungetc (c, f);
	  c = '\r';
	}
    }

  return c;
}

// Eat whitespace and comments from FFILE, returning the text of the
// comments read if it doesn't look like a copyright notice.  If
// IN_PARTS, consider each block of comments separately; otherwise,
// grab them all at once.  If UPDATE_POS is TRUE, line and column
// number information is updated.  If SAVE_COPYRIGHT is TRUE, then
// comments that are recognized as a copyright notice are saved in the
// comment buffer.

// XXX FIXME XXX -- grab_help_text() in lex.l duplicates some of this
// code!

static std::string
gobble_leading_white_space (FILE *ffile, bool in_parts,
			    bool update_pos, bool save_copyright)
{
  std::string help_txt;

  // TRUE means we have already seen the first block of comments.
  bool first_comments_seen = false;

  // TRUE means we are at the beginning of a comment block.
  bool begin_comment = false;

  // TRUE means we have already cached the help text.
  bool have_help_text = false;

  // TRUE means we are currently reading a comment block.
  bool in_comment = false;

  // TRUE means we should discard the first space from the input
  // (used to strip leading spaces from the help text).
  bool discard_space = true;

  int c;

  while ((c = text_getc (ffile)) != EOF)
    {
      if (update_pos)
	current_input_column++;

      if (begin_comment)
	{
	  if (c == '%' || c == '#')
	    continue;
	  else if (discard_space && c == ' ')
	    {
	      discard_space = false;
	      continue;
	    }
	  else
	    begin_comment = false;
	}

      if (in_comment)
	{
	  if (! have_help_text)
	    {
	      first_comments_seen = true;
	      help_txt += (char) c;
	    }

	  if (c == '\n')
	    {
	      if (update_pos)
		{
		  input_line_number++;
		  current_input_column = 0;
		}

	      in_comment = false;
	      discard_space = true;

	      if (in_parts)
		{
		  if ((c = text_getc (ffile)) != EOF)
		    {
		      if (update_pos)
			current_input_column--;
		      ungetc (c, ffile);
		      if (c == '\n')
			break;
		    }
		  else
		    break;
		}
	    }
	}
      else
	{
	  switch (c)
	    {
	    case ' ':
	    case '\t':
	      if (first_comments_seen)
		have_help_text = true;
	      break;

	    case '%':
	    case '#':
	      begin_comment = true;
	      in_comment = true;
	      break;

	    case '\n':
	      if (first_comments_seen)
		have_help_text = true;
	      if (update_pos)
		{
		  input_line_number++;
		  current_input_column = 0;
		}
	      continue;

	    default:
	      if (update_pos)
		current_input_column--;
	      ungetc (c, ffile);
	      goto done;
	    }
	}
    }

 done:

  if (! help_txt.empty ())
    {
      if (looks_like_copyright (help_txt))
	{
	  if (save_copyright)
	    octave_comment_buffer::append (help_txt);

	  help_txt.resize (0);
	}

      if (in_parts && help_txt.empty ())
	help_txt = gobble_leading_white_space (ffile, in_parts,
					       update_pos, false);
    }

  return help_txt;
}

std::string
get_help_from_file (const std::string& path)
{
  std::string retval;

  if (! path.empty ())
    {
      FILE *fptr = fopen (path.c_str (), "r");

      if (fptr)
	{
	  unwind_protect::add (safe_fclose, (void *) fptr);

	  retval = gobble_leading_white_space (fptr, true, true, false);

	  unwind_protect::run ();
	}
    }

  return retval;
}

static int
is_function_file (FILE *ffile)
{
  int status = 0;

  long pos = ftell (ffile);

  gobble_leading_white_space (ffile, false, false, false);

  char buf [10];
  fgets (buf, 10, ffile);
  int len = strlen (buf);
  if (len > 8 && strncmp (buf, "function", 8) == 0
      && ! (isalnum (buf[8]) || buf[8] == '_'))
    status = 1;

  fseek (ffile, pos, SEEK_SET);

  return status;
}

static void
restore_command_history (void *)
{
  command_history::ignore_entries (! Vsaving_history);
}

static void
restore_input_stream (void *f)
{
  command_editor::set_input_stream (static_cast<FILE *> (f));
}

static void
clear_current_script_file_name (void *)
{
  bind_builtin_variable ("current_script_file_name", octave_value ());
}

static bool
parse_fcn_file (const std::string& ff, bool exec_script, bool force_script = false)
{
  unwind_protect::begin_frame ("parse_fcn_file");

  int script_file_executed = false;

  // Open function file and parse.

  bool old_reading_fcn_file_state = reading_fcn_file;

  FILE *in_stream = command_editor::get_input_stream ();

  unwind_protect::add (restore_input_stream, in_stream);

  unwind_protect_ptr (ff_instream);

  unwind_protect_int (input_line_number);
  unwind_protect_int (current_input_column);
  unwind_protect_int (end_tokens_expected);
  unwind_protect_bool (reading_fcn_file);
  unwind_protect_bool (line_editing);
  unwind_protect_str (parent_function_name);

  input_line_number = 0;
  current_input_column = 1;
  end_tokens_expected = 0;
  reading_fcn_file = true;
  line_editing = false;
  parent_function_name = "";

  FILE *ffile = get_input_from_file (ff, 0);

  unwind_protect::add (safe_fclose, ffile);

  if (ffile)
    {
      // Check to see if this file defines a function or is just a
      // list of commands.

      if (! force_script && is_function_file (ffile))
	{
	  // XXX FIXME XXX -- we shouldn't need both the
	  // command_history object and the
	  // Vsaving_history variable...
	  command_history::ignore_entries ();

	  unwind_protect::add (restore_command_history, 0);

	  unwind_protect_int (Vecho_executing_commands);
	  unwind_protect_bool (Vsaving_history);
	  unwind_protect_bool (reading_fcn_file);
	  unwind_protect_bool (input_from_command_line_file);
	  unwind_protect_bool (get_input_from_eval_string);
	  unwind_protect_bool (parser_end_of_input);

	  Vecho_executing_commands = ECHO_OFF;
	  Vsaving_history = false;
	  reading_fcn_file = true;
	  input_from_command_line_file = false;
	  get_input_from_eval_string = false;
	  parser_end_of_input = false;

	  YY_BUFFER_STATE old_buf = current_buffer ();
	  YY_BUFFER_STATE new_buf = create_buffer (ffile);

	  unwind_protect::add (restore_input_buffer, (void *) old_buf);
	  unwind_protect::add (delete_input_buffer, (void *) new_buf);

	  switch_to_buffer (new_buf);

	  unwind_protect_ptr (curr_sym_tab);

	  reset_parser ();

	  std::string txt
	    = gobble_leading_white_space (ffile, true, true, true);

	  help_buf.push (txt);

	  octave_comment_buffer::append (txt);

	  // XXX FIXME XXX -- this should not be necessary.
	  gobble_leading_white_space (ffile, false, true, false);

	  int status = yyparse ();

	  if (status != 0)
	    {
	      error ("parse error while reading function file %s",
		     ff.c_str ());
	      fbi_sym_tab->clear (curr_fcn_file_name);
	    }
	}
      else if (exec_script)
	{
	  // The value of `reading_fcn_file' will be restored to the
	  // proper value when we unwind from this frame.
	  reading_fcn_file = old_reading_fcn_file_state;

	  // XXX FIXME XXX -- we shouldn't need both the
	  // command_history object and the
	  // Vsaving_history variable...
	  command_history::ignore_entries ();

	  unwind_protect::add (restore_command_history, 0);

	  unwind_protect_bool (Vsaving_history);
	  unwind_protect_bool (reading_script_file);

	  Vsaving_history = false;
	  reading_script_file = true;

	  unwind_protect::add (clear_current_script_file_name, 0);

	  bind_builtin_variable ("current_script_file_name", ff);

	  parse_and_execute (ffile);

	  script_file_executed = true;
	}
    }
  else
    error ("no such file, `%s'", ff.c_str ());

  unwind_protect::run_frame ("parse_fcn_file");

  return script_file_executed;
}

bool
load_fcn_from_file (symbol_record *sym_rec, bool exec_script)
{
  bool script_file_executed = false;

  std::string nm = sym_rec->name ();

  string_vector names (2);

  names[0] = nm + ".oct";
  names[1] = nm + ".m";

  std::string file
   = octave_env::make_absolute (Vload_path_dir_path.find_first_of (names),
                                octave_env::getcwd ());

  int len = file.length ();

  if (len > 4 && file.substr (len-4, len-1) == ".oct")
    {
      if (octave_dynamic_loader::load (nm, file))
        force_link_to_function (nm);
    }
  else if (len > 2)
    {
      // These are needed by yyparse.

      unwind_protect::begin_frame ("load_fcn_from_file");

      unwind_protect_str (curr_fcn_file_name);
      unwind_protect_str (curr_fcn_file_full_name);

      curr_fcn_file_name = nm;
      curr_fcn_file_full_name = file;

      script_file_executed = parse_fcn_file (file, exec_script);

      if (! (error_state || script_file_executed))
	force_link_to_function (nm);

      unwind_protect::run_frame ("load_fcn_from_file");
    }

  return script_file_executed;
}

void
source_file (const std::string file_name)
{
  std::string file_full_name = file_ops::tilde_expand (file_name);

  unwind_protect::begin_frame ("source_file");

  unwind_protect_str (curr_fcn_file_name);
  unwind_protect_str (curr_fcn_file_full_name);

  curr_fcn_file_name = file_name;
  curr_fcn_file_full_name = file_full_name;

  parse_fcn_file (file_full_name, true, true);

  if (error_state)
    error ("source: error sourcing file `%s'",
	   file_full_name.c_str ());

  unwind_protect::run_frame ("source_file");
}

DEFUN (source, args, ,
  "-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} source (@var{file})\n\
Parse and execute the contents of @var{file}.  This is equivalent to\n\
executing commands from a script file, but without requiring the file to\n\
be named @file{@var{file}.m}.\n\
@end deftypefn")
{
  octave_value_list retval;

  int nargin = args.length ();

  if (nargin == 1)
    {
      std::string file_name = args(0).string_value ();

      if (! error_state)
        source_file (file_name);
      else
	error ("source: expecting file name as argument");
    }
  else
    print_usage ("source");

  return retval;
}

// Evaluate an Octave function (built-in or interpreted) and return
// the list of result values.  NAME is the name of the function to
// call.  ARGS are the arguments to the function.  NARGOUT is the
// number of output arguments expected. 

octave_value_list
feval (const std::string& name, const octave_value_list& args, int nargout)
{
  octave_value_list retval;

  octave_function *fcn = is_valid_function (name, "feval", 1);

  if (fcn)
    retval = fcn->do_multi_index_op (nargout, args);

  return retval;
}

octave_value_list
feval (octave_function *fcn, const octave_value_list& args, int nargout)
{
  octave_value_list retval;

  if (fcn)
    retval = fcn->do_multi_index_op (nargout, args);

  return retval;
}

static octave_value_list
get_feval_args (const octave_value_list& args)
{
  int tmp_nargin = args.length () - 1;

  octave_value_list retval (tmp_nargin, octave_value ());

  for (int i = 0; i < tmp_nargin; i++)
    retval(i) = args(i+1);

  string_vector arg_names = args.name_tags ();

  if (! arg_names.empty ())
    {
      // tmp_nargin and arg_names.length () - 1 may differ if
      // we are passed all_va_args.

      int n = arg_names.length () - 1;

      int len = n > tmp_nargin ? tmp_nargin : n;

      string_vector tmp_arg_names (len);

      for (int i = 0; i < len; i++)
	tmp_arg_names(i) = arg_names(i+1);

      retval.stash_name_tags (tmp_arg_names);
    }

  return retval;
}


// Evaluate an Octave function (built-in or interpreted) and return
// the list of result values.  The first element of ARGS should be a
// string containing the name of the function to call, then the rest
// are the actual arguments to the function.  NARGOUT is the number of
// output arguments expected.

octave_value_list
feval (const octave_value_list& args, int nargout)
{
  octave_value_list retval;

  int nargin = args.length ();

  if (nargin > 0)
    {
      octave_value f_arg = args(0);

      if (f_arg.is_string ())
        {
	  std::string name = f_arg.string_value ();

	  if (! error_state)
	    {
	      octave_value_list tmp_args = get_feval_args (args);

	      retval = feval (name, tmp_args, nargout);
	    }
	}
      else
	{
	  octave_function *fcn = f_arg.function_value ();

	  if (fcn)
	    {
	      octave_value_list tmp_args = get_feval_args (args);

	      retval = feval (fcn, tmp_args, nargout);
	    }
	}
    }

  return retval;
}

DEFUN (feval, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} feval (@var{name}, @dots{})\n\
Evaluate the function named @var{name}.  Any arguments after the first\n\
are passed on to the named function.  For example,\n\
\n\
@example\n\
feval (\"acos\", -1)\n\
     @result{} 3.1416\n\
@end example\n\
\n\
@noindent\n\
calls the function @code{acos} with the argument @samp{-1}.\n\
\n\
The function @code{feval} is necessary in order to be able to write\n\
functions that call user-supplied functions, because Octave does not\n\
have a way to declare a pointer to a function (like C) or to declare a\n\
special kind of variable that can be used to hold the name of a function\n\
(like @code{EXTERNAL} in Fortran).  Instead, you must refer to functions\n\
by name, and use @code{feval} to call them.\n\
@end deftypefn")
{
  octave_value_list retval;

  int nargin = args.length ();

  if (nargin > 0)
    retval = feval (args, nargout);
  else
    print_usage ("feval");

  return retval;
}

octave_value_list
eval_string (const std::string& s, bool silent, int& parse_status, int nargout)
{
  octave_value_list retval;

  unwind_protect::begin_frame ("eval_string");

  unwind_protect_bool (get_input_from_eval_string);
  unwind_protect_bool (input_from_eval_string_pending);
  unwind_protect_bool (input_from_command_line_file);
  unwind_protect_bool (parser_end_of_input);
  unwind_protect_str (current_eval_string);

  get_input_from_eval_string = true;
  input_from_eval_string_pending = true;
  input_from_command_line_file = false;
  parser_end_of_input = false;
  current_eval_string = s;

  unwind_protect_ptr (global_command);

  YY_BUFFER_STATE old_buf = current_buffer ();
  YY_BUFFER_STATE new_buf = create_buffer (0);

  unwind_protect::add (restore_input_buffer, old_buf);
  unwind_protect::add (delete_input_buffer, new_buf);

  switch_to_buffer (new_buf);

  unwind_protect_ptr (curr_sym_tab);

  do
    {
      reset_parser ();

      parse_status = yyparse ();

      tree_statement_list *command = global_command;

      if (parse_status == 0)
        {
	  if (command)
	    {
	      retval = command->eval (silent, nargout);

	      delete command;

	      command = 0;

	      if (error_state
		  || tree_return_command::returning
		  || tree_break_command::breaking
		  || tree_continue_command::continuing)
		break;
	    }
	  else if (parser_end_of_input)
	    break;
        }
    }
  while (parse_status == 0);

  unwind_protect::run_frame ("eval_string");

  return retval;
}

octave_value
eval_string (const std::string& s, bool silent, int& parse_status)
{
  octave_value retval;

  octave_value_list tmp = eval_string (s, silent, parse_status, 1);

  if (! tmp.empty ())
    retval = tmp(0);

  return retval;
}

static octave_value_list
eval_string (const octave_value& arg, bool silent, int& parse_status,
	     int nargout)
{
  std::string s = arg.string_value ();

  if (error_state)
    {
      error ("eval: expecting std::string argument");
      return octave_value (-1);
    }

  return eval_string (s, silent, parse_status, nargout);
}

DEFUN (eval, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} eval (@var{try}, @var{catch})\n\
Parse the string @var{try} and evaluate it as if it were an Octave\n\
program.  If that fails, evaluate the string @var{catch}.\n\
The string @var{try} is evaluated in the current context,\n\
so any results remain available after @code{eval} returns.\n\
@end deftypefn")
{
  octave_value_list retval;

  int nargin = args.length ();

  if (nargin > 0)
    {
      unwind_protect::begin_frame ("Feval");

      if (nargin > 1)
	{
	  unwind_protect_int (buffer_error_messages);
	  buffer_error_messages++;
	}

      int parse_status = 0;

      octave_value_list tmp = eval_string (args(0), nargout > 0,
					   parse_status, nargout);

      if (nargout > 0)
	retval = tmp;

      if (nargin > 1 && (parse_status != 0 || error_state))
	{
	  error_state = 0;

	  // Set up for letting the user print any messages from
	  // errors that occurred in the first part of this eval().

	  buffer_error_messages--;

	  eval_string (args(1), 0, parse_status, nargout);

	  retval = octave_value_list ();
	}

      unwind_protect::run_frame ("Feval");
    }
  else
    print_usage ("eval");

  return retval;
}

DEFUN (assignin, args, ,
  "-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} assignin (@var{context}, @var{varname}, @var{value})\n\
Assign @var{value} to @var{varname} in context @var{context}, which\n\
may be either @code{\"base\"} or @code{\"caller\"}.\n\
@end deftypefn")
{
  octave_value_list retval;

  int nargin = args.length ();

  if (nargin == 3)
    {
      std::string context = args(0).string_value ();

      if (! error_state)
        {
	  unwind_protect::begin_frame ("Fassignin");

	  unwind_protect_ptr (curr_sym_tab);

	  if (context == "caller")
	    curr_sym_tab = curr_caller_sym_tab;
	  else if (context == "base")
	    curr_sym_tab = top_level_sym_tab;
	  else
	    error ("assignin: context must be \"caller\" or \"base\"");

	  if (! error_state)
	    {
	      std::string nm = args(1).string_value ();

	      if (! error_state)
		{
		  if (valid_identifier (nm))
		    {
		      symbol_record *sr = curr_sym_tab->lookup (nm, true);

		      if (sr)
			{
			  tree_identifier *id = new tree_identifier (sr);
			  tree_constant *rhs = new tree_constant (args(2));
		      
			  tree_simple_assignment tsa (id, rhs);

			  tsa.rvalue ();
			}
		    }
		  else
		    error ("assignin: invalid variable name");
		}
	      else
		error ("assignin: expecting variable name as second argument");
	    }

	  unwind_protect::run_frame ("Fassignin");
	}
      else
        error ("assignin: expecting string as first argument");
    }
  else
    print_usage ("assignin");

  return retval;
}

DEFUN (evalin, args, nargout,
  "-*- texinfo -*-\n\
@deftypefn {Built-in Function} {} evalin (@var{context}, @var{try}, @var{catch})\n\
Like @code{eval}, except that the expressions are evaluated in the\n\
context @var{context}, which may be either @code{\"caller\"} or\n\
@code{\"base\"}.\n\
@end deftypefn")
{
  octave_value_list retval;

  int nargin = args.length ();

  if (nargin > 1)
    {
      std::string context = args(0).string_value ();

      if (! error_state)
        {
	  unwind_protect::begin_frame ("Fevalin");

	  unwind_protect_ptr (curr_sym_tab);

	  if (context == "caller")
	    curr_sym_tab = curr_caller_sym_tab;
	  else if (context == "base")
	    curr_sym_tab = top_level_sym_tab;
	  else
	    error ("evalin: context must be \"caller\" or \"base\"");

	  if (! error_state)
	    {
	      if (nargin > 2)
	        {
		  unwind_protect_int (buffer_error_messages);
		  buffer_error_messages++;
		}

	      int parse_status = 0;

	      octave_value_list tmp = eval_string (args(1), nargout > 0,
						   parse_status, nargout);

	      if (nargout > 0)
		retval = tmp;

	      if (nargin > 2 && (parse_status != 0 || error_state))
		{
		  error_state = 0;

		  // Set up for letting the user print any messages from
		  // errors that occurred in the first part of this eval().

		  buffer_error_messages--;

		  eval_string (args(2), 0, parse_status, nargout);

		  retval = octave_value_list ();
		}
	    }

	  unwind_protect::run_frame ("Fevalin");
	}
      else
        error ("evalin: expecting string as first argument");
    }
  else
    print_usage ("evalin");

  return retval;
}

static int
warn_assign_as_truth_value (void)
{
  Vwarn_assign_as_truth_value
    = check_preference ("warn_assign_as_truth_value");

  return 0;
}

static int
warn_associativity_change (void)
{
  Vwarn_associativity_change = check_preference ("warn_associativity_change");

  return 0;
}

static int
warn_function_name_clash (void)
{
  Vwarn_function_name_clash = check_preference ("warn_function_name_clash");

  return 0;
}

static int
warn_future_time_stamp (void)
{
  Vwarn_future_time_stamp = check_preference ("warn_future_time_stamp");

  return 0;
}

static int
warn_missing_semicolon (void)
{
  Vwarn_missing_semicolon = check_preference ("warn_missing_semicolon");

  return 0;
}

static int
warn_precedence_change (void)
{
  Vwarn_precedence_change = check_preference ("warn_precedence_change");

  return 0;
}

static int
warn_variable_switch_label (void)
{
  Vwarn_variable_switch_label
    = check_preference ("warn_variable_switch_label");

  return 0;
}

void
symbols_of_parse (void)
{
  DEFVAR (warn_assign_as_truth_value, true, warn_assign_as_truth_value,
    "-*- texinfo -*-\n\
@defvr {Built-in Variable} warn_assign_as_truth_value\n\
If the value of @code{warn_assign_as_truth_value} is nonzero, a\n\
warning is issued for statements like\n\
\n\
@example\n\
if (s = t)\n\
  ...\n\
@end example\n\
\n\
@noindent\n\
since such statements are not common, and it is likely that the intent\n\
was to write\n\
\n\
@example\n\
if (s == t)\n\
  ...\n\
@end example\n\
\n\
@noindent\n\
instead.\n\
\n\
There are times when it is useful to write code that contains\n\
assignments within the condition of a @code{while} or @code{if}\n\
statement.  For example, statements like\n\
\n\
@example\n\
while (c = getc())\n\
  ...\n\
@end example\n\
\n\
@noindent\n\
are common in C programming.\n\
\n\
It is possible to avoid all warnings about such statements by setting\n\
@code{warn_assign_as_truth_value} to 0, but that may also\n\
let real errors like\n\
\n\
@example\n\
if (x = 1)  # intended to test (x == 1)!\n\
  ...\n\
@end example\n\
\n\
@noindent\n\
slip by.\n\
\n\
In such cases, it is possible suppress errors for specific statements by\n\
writing them with an extra set of parentheses.  For example, writing the\n\
previous example as\n\
\n\
@example\n\
while ((c = getc()))\n\
  ...\n\
@end example\n\
\n\
@noindent\n\
will prevent the warning from being printed for this statement, while\n\
allowing Octave to warn about other assignments used in conditional\n\
contexts.\n\
\n\
The default value of @code{warn_assign_as_truth_value} is 1.\n\
@end defvr");

  DEFVAR (warn_associativity_change, true, warn_associativity_change,
    "-*- texinfo -*-\n\
@defvr {Built-in Variable} warn_associativity_change\n\
If the value of this variable is nonzero, Octave will warn about\n\
possible changes in the meaning of some code due to changes in\n\
associativity for some operators.  Associativity changes have typically\n\
been made for Matlab compatibility.  The default value is 1.\n\
@end defvr");

  DEFVAR (warn_function_name_clash, true, warn_function_name_clash,
    "-*- texinfo -*-\n\
@defvr {Built-in Variable} warn_function_name_clash\n\
If the value of @code{warn_function_name_clash} is nonzero, a warning is\n\
issued when Octave finds that the name of a function defined in a\n\
function file differs from the name of the file.  (If the names\n\
disagree, the name declared inside the file is ignored.)  If the value\n\
is 0, the warning is omitted.  The default value is 1.\n\
@end defvr");

  DEFVAR (warn_future_time_stamp, true, warn_future_time_stamp,
    "-*- texinfo -*-\n\
@defvr {Built-in Variable} warn_future_time_stamp\n\
If the value of this variable is nonzero, Octave will print a warning\n\
if it finds a function file with a time stamp that is in the future.\n\
@end defvr");

  DEFVAR (warn_missing_semicolon, false, warn_missing_semicolon,
    "-*- texinfo -*-\n\
@defvr {Built-in Variable} warn_missing_semicolon\n\
If the value of this variable is nonzero, Octave will warn when\n\
statements in function definitions don't end in semicolons.  The default\n\
value is 0.\n\
@end defvr");

  DEFVAR (warn_precedence_change, true, warn_precedence_change,
    "-*- texinfo -*-\n\
@defvr {Built-in Variable} warn_precedence_change\n\
If the value of this variable is nonzero, Octave will warn about\n\
possible changes in the meaning of some code due to changes in\n\
precedence for some operators.  Precedence changes have typically\n\
been made for Matlab compatibility.  The default value is 1.\n\
@end defvr");

  DEFVAR (warn_variable_switch_label, false, warn_variable_switch_label,
    "-*- texinfo -*-\n\
@defvr {Built-in Variable} warn_variable_switch_label\n\
If the value of this variable is nonzero, Octave will print a warning if\n\
a switch label is not a constant or constant expression\n\
@end defvr");

}

/*
;;; Local Variables: ***
;;; mode: text ***
;;; End: ***
*/

