changeset 16289:bde729ba8381 classdef

maint: periodic merge of default to classdef
author John W. Eaton <jwe@octave.org>
date Tue, 12 Mar 2013 00:46:47 -0400
parents f58257a6d18c (current diff) fe3b9a51e625 (diff)
children 2ed5bc680c71
files libinterp/parse-tree/oct-parse.in.yy libinterp/parse-tree/parse.h
diffstat 4 files changed, 483 insertions(+), 490 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/interpfcn/input.cc	Mon Mar 11 18:24:50 2013 -0400
+++ b/libinterp/interpfcn/input.cc	Tue Mar 12 00:46:47 2013 -0400
@@ -123,7 +123,7 @@
 void
 octave_base_reader::do_input_echo (const std::string& input_string) const
 {
-  int do_echo = CURR_LEXER->reading_script_file ?
+  int do_echo = LEXER->reading_script_file ?
     (Vecho_executing_commands & ECHO_SCRIPTS)
       : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive;
 
@@ -495,17 +495,17 @@
   VPS1 = prompt;
 
   if (! (interactive || forced_interactive)
-      || CURR_LEXER->reading_fcn_file
-      || CURR_LEXER->reading_classdef_file
-      || CURR_LEXER->reading_script_file
-      || CURR_LEXER->input_from_eval_string ())
+      || LEXER->reading_fcn_file
+      || LEXER->reading_classdef_file
+      || LEXER->reading_script_file
+      || LEXER->input_from_eval_string ())
     {
       frame.protect_var (forced_interactive);
       forced_interactive = true;
     }
 
   // octave_parser constructor sets this for us.
-  frame.protect_var (CURR_LEXER);
+  frame.protect_var (LEXER);
 
   octave_parser curr_parser;
 
--- a/libinterp/interpfcn/toplev.cc	Mon Mar 11 18:24:50 2013 -0400
+++ b/libinterp/interpfcn/toplev.cc	Tue Mar 12 00:46:47 2013 -0400
@@ -560,9 +560,9 @@
   unwind_protect frame;
 
   // octave_parser constructor sets this for us.
-  frame.protect_var (CURR_LEXER);
+  frame.protect_var (LEXER);
 
-  octave_parser curr_parser;
+  octave_parser parser;
 
   int retval = 0;
   do
@@ -573,18 +573,18 @@
 
           reset_error_handler ();
 
-          curr_parser.reset ();
+          parser.reset ();
 
           if (symbol_table::at_top_level ())
             tree_evaluator::reset_debug_state ();
 
-          retval = curr_parser.run ();
+          retval = parser.run ();
 
           if (retval == 0)
             {
-              if (curr_parser.stmt_list)
+              if (parser.stmt_list)
                 {
-                  curr_parser.stmt_list->accept (*current_evaluator);
+                  parser.stmt_list->accept (*current_evaluator);
 
                   octave_quit ();
 
@@ -620,7 +620,7 @@
                         command_editor::increment_current_command_number ();
                     }
                 }
-              else if (curr_parser.curr_lexer->end_of_input)
+              else if (parser.lexer.end_of_input)
                 break;
             }
         }
--- a/libinterp/parse-tree/oct-parse.in.yy	Mon Mar 11 18:24:50 2013 -0400
+++ b/libinterp/parse-tree/oct-parse.in.yy	Tue Mar 12 00:46:47 2013 -0400
@@ -86,7 +86,7 @@
 
 // Global access to currently active lexer.
 // FIXME -- to be removed after more parser+lexer refactoring.
-octave_lexer *CURR_LEXER = 0;
+octave_lexer *LEXER = 0;
 
 #if defined (GNULIB_NAMESPACE)
 // Calls to the following functions appear in the generated output from
@@ -109,7 +109,7 @@
 // Forward declarations for some functions defined at the bottom of
 // the file.
 
-static void yyerror (octave_parser& curr_parser, const char *s);
+static void yyerror (octave_base_parser& parser, const char *s);
 
 // Finish building a statement.
 template <class T>
@@ -128,15 +128,15 @@
       if (! parser_symtab_context.empty ()) \
         parser_symtab_context.pop (); \
       if ((interactive || forced_interactive)   \
-          && ! (curr_lexer)->input_from_eval_string ()) \
+          && ! lexer.input_from_eval_string ()) \
         YYACCEPT; \
       else \
         YYABORT; \
     } \
   while (0)
 
-#define curr_lexer curr_parser.curr_lexer
-#define scanner curr_lexer->scanner
+#define lexer parser.lexer
+#define scanner lexer.scanner
 
 %}
 
@@ -158,7 +158,7 @@
 
 %define api.pure
 %PUSH_PULL_DECL%
-%parse-param { octave_parser& curr_parser }
+%parse-param { octave_base_parser& parser }
 %lex-param { void *scanner }
 
 %union
@@ -338,7 +338,7 @@
 
 input           : input1
                   {
-                    curr_parser.stmt_list = $1;
+                    parser.stmt_list = $1;
                     YYACCEPT;
                   }
                 | simple_list parse_error
@@ -351,7 +351,7 @@
                   { $$ = 0; }
                 | END_OF_INPUT
                   {
-                    curr_lexer->end_of_input = true;
+                    lexer.end_of_input = true;
                     $$ = 0;
                   }
                 | simple_list
@@ -363,13 +363,13 @@
                 ;
 
 simple_list     : simple_list1 opt_sep_no_nl
-                  { $$ = curr_parser.set_stmt_print_flag ($1, $2, false); }
+                  { $$ = parser.set_stmt_print_flag ($1, $2, false); }
                 ;
 
 simple_list1    : statement
-                  { $$ = curr_parser.make_statement_list ($1); }
+                  { $$ = parser.make_statement_list ($1); }
                 | simple_list1 sep_no_nl statement
-                  { $$ = curr_parser.append_statement_list ($1, $2, $3, false); }
+                  { $$ = parser.append_statement_list ($1, $2, $3, false); }
                 ;
 
 opt_list        : // empty
@@ -379,13 +379,13 @@
                 ;
 
 list            : list1 opt_sep
-                  { $$ = curr_parser.set_stmt_print_flag ($1, $2, true); }
+                  { $$ = parser.set_stmt_print_flag ($1, $2, true); }
                 ;
 
 list1           : statement
-                  { $$ = curr_parser.make_statement_list ($1); }
+                  { $$ = parser.make_statement_list ($1); }
                 | list1 sep statement
-                  { $$ = curr_parser.append_statement_list ($1, $2, $3, true); }
+                  { $$ = parser.append_statement_list ($1, $2, $3, true); }
                 ;
 
 statement       : expression
@@ -405,7 +405,7 @@
 // WHILE, etc.
 
 word_list_cmd   : identifier word_list
-                  { $$ = curr_parser.make_index_expression ($1, $2, '('); }
+                  { $$ = parser.make_index_expression ($1, $2, '('); }
                 ;
 
 word_list       : string
@@ -435,7 +435,7 @@
                     std::string package_nm = $1->superclass_package_name ();
                     std::string class_nm = $1->superclass_class_name ();
 
-                    $$ = curr_parser.make_superclass_ref
+                    $$ = parser.make_superclass_ref
                                        (method_nm, package_nm, class_nm,
                                         $1->line (), $1->column ());
                   }
@@ -446,22 +446,22 @@
                     std::string package_nm = $1->meta_package_name ();
                     std::string class_nm = $1->meta_class_name ();
 
-                    $$ = curr_parser.make_meta_class_query
+                    $$ = parser.make_meta_class_query
                                        (package_nm, class_nm,
                                         $1->line (), $1->column ());
                   }
                 ;
 
 string          : DQ_STRING
-                  { $$ = curr_parser.make_constant (DQ_STRING, $1); }
+                  { $$ = parser.make_constant (DQ_STRING, $1); }
                 | SQ_STRING
-                  { $$ = curr_parser.make_constant (SQ_STRING, $1); }
+                  { $$ = parser.make_constant (SQ_STRING, $1); }
                 ;
 
 constant        : NUM
-                  { $$ = curr_parser.make_constant (NUM, $1); }
+                  { $$ = parser.make_constant (NUM, $1); }
                 | IMAG_NUM
-                  { $$ = curr_parser.make_constant (IMAG_NUM, $1); }
+                  { $$ = parser.make_constant (IMAG_NUM, $1); }
                 | string
                   { $$ = $1; }
                 ;
@@ -473,7 +473,7 @@
                 | '[' ',' ']'
                   { $$ = new tree_constant (octave_null_matrix::instance); }
                 | '[' matrix_rows ']'
-                  { $$ = curr_parser.finish_matrix ($2); }
+                  { $$ = parser.finish_matrix ($2); }
                 ;
 
 matrix_rows     : matrix_rows1
@@ -496,7 +496,7 @@
                 | '{' ';' '}'
                   { $$ = new tree_constant (octave_value (Cell ())); }
                 | '{' cell_rows '}'
-                  { $$ = curr_parser.finish_cell ($2); }
+                  { $$ = parser.finish_cell ($2); }
                 ;
 
 cell_rows       : cell_rows1
@@ -523,15 +523,15 @@
 
 fcn_handle      : '@' FCN_HANDLE
                   {
-                    $$ = curr_parser.make_fcn_handle ($2);
-                    curr_lexer->looking_at_function_handle--;
+                    $$ = parser.make_fcn_handle ($2);
+                    lexer.looking_at_function_handle--;
                   }
                 ;
 
 anon_fcn_handle : '@' param_list statement
                   {
-                    $$ = curr_parser.make_anon_fcn_handle ($2, $3);
-                    curr_lexer->nesting_level.remove ();
+                    $$ = parser.make_anon_fcn_handle ($2, $3);
+                    lexer.nesting_level.remove ();
                   }
                 ;
 
@@ -543,7 +543,7 @@
                   { $$ = $1; }
                 | matrix
                   {
-                    curr_lexer->looking_at_matrix_or_assign_lhs = false;
+                    lexer.looking_at_matrix_or_assign_lhs = false;
                     $$ = $1;
                   }
                 | cell
@@ -593,69 +593,69 @@
                 ;
 
 indirect_ref_op : '.'
-                  { curr_lexer->looking_at_indirect_ref = true; }
+                  { lexer.looking_at_indirect_ref = true; }
                 ;
 
 oper_expr       : primary_expr
                   { $$ = $1; }
                 | oper_expr PLUS_PLUS
-                  { $$ = curr_parser.make_postfix_op (PLUS_PLUS, $1, $2); }
+                  { $$ = parser.make_postfix_op (PLUS_PLUS, $1, $2); }
                 | oper_expr MINUS_MINUS
-                  { $$ = curr_parser.make_postfix_op (MINUS_MINUS, $1, $2); }
+                  { $$ = parser.make_postfix_op (MINUS_MINUS, $1, $2); }
                 | oper_expr '(' ')'
-                  { $$ = curr_parser.make_index_expression ($1, 0, '('); }
+                  { $$ = parser.make_index_expression ($1, 0, '('); }
                 | oper_expr '(' arg_list ')'
-                  { $$ = curr_parser.make_index_expression ($1, $3, '('); }
+                  { $$ = parser.make_index_expression ($1, $3, '('); }
                 | oper_expr '{' '}'
-                  { $$ = curr_parser.make_index_expression ($1, 0, '{'); }
+                  { $$ = parser.make_index_expression ($1, 0, '{'); }
                 | oper_expr '{' arg_list '}'
-                  { $$ = curr_parser.make_index_expression ($1, $3, '{'); }
+                  { $$ = parser.make_index_expression ($1, $3, '{'); }
                 | oper_expr HERMITIAN
-                  { $$ = curr_parser.make_postfix_op (HERMITIAN, $1, $2); }
+                  { $$ = parser.make_postfix_op (HERMITIAN, $1, $2); }
                 | oper_expr TRANSPOSE
-                  { $$ = curr_parser.make_postfix_op (TRANSPOSE, $1, $2); }
+                  { $$ = parser.make_postfix_op (TRANSPOSE, $1, $2); }
                 | oper_expr indirect_ref_op STRUCT_ELT
-                  { $$ = curr_parser.make_indirect_ref ($1, $3->text ()); }
+                  { $$ = parser.make_indirect_ref ($1, $3->text ()); }
                 | oper_expr indirect_ref_op '(' expression ')'
-                  { $$ = curr_parser.make_indirect_ref ($1, $4); }
+                  { $$ = parser.make_indirect_ref ($1, $4); }
                 | PLUS_PLUS oper_expr %prec UNARY
-                  { $$ = curr_parser.make_prefix_op (PLUS_PLUS, $2, $1); }
+                  { $$ = parser.make_prefix_op (PLUS_PLUS, $2, $1); }
                 | MINUS_MINUS oper_expr %prec UNARY
-                  { $$ = curr_parser.make_prefix_op (MINUS_MINUS, $2, $1); }
+                  { $$ = parser.make_prefix_op (MINUS_MINUS, $2, $1); }
                 | EXPR_NOT oper_expr %prec UNARY
-                  { $$ = curr_parser.make_prefix_op (EXPR_NOT, $2, $1); }
+                  { $$ = parser.make_prefix_op (EXPR_NOT, $2, $1); }
                 | '+' oper_expr %prec UNARY
-                  { $$ = curr_parser.make_prefix_op ('+', $2, $1); }
+                  { $$ = parser.make_prefix_op ('+', $2, $1); }
                 | '-' oper_expr %prec UNARY
-                  { $$ = curr_parser.make_prefix_op ('-', $2, $1); }
+                  { $$ = parser.make_prefix_op ('-', $2, $1); }
                 | oper_expr POW oper_expr
-                  { $$ = curr_parser.make_binary_op (POW, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (POW, $1, $2, $3); }
                 | oper_expr EPOW oper_expr
-                  { $$ = curr_parser.make_binary_op (EPOW, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EPOW, $1, $2, $3); }
                 | oper_expr '+' oper_expr
-                  { $$ = curr_parser.make_binary_op ('+', $1, $2, $3); }
+                  { $$ = parser.make_binary_op ('+', $1, $2, $3); }
                 | oper_expr '-' oper_expr
-                  { $$ = curr_parser.make_binary_op ('-', $1, $2, $3); }
+                  { $$ = parser.make_binary_op ('-', $1, $2, $3); }
                 | oper_expr '*' oper_expr
-                  { $$ = curr_parser.make_binary_op ('*', $1, $2, $3); }
+                  { $$ = parser.make_binary_op ('*', $1, $2, $3); }
                 | oper_expr '/' oper_expr
-                  { $$ = curr_parser.make_binary_op ('/', $1, $2, $3); }
+                  { $$ = parser.make_binary_op ('/', $1, $2, $3); }
                 | oper_expr EPLUS oper_expr
-                  { $$ = curr_parser.make_binary_op ('+', $1, $2, $3); }
+                  { $$ = parser.make_binary_op ('+', $1, $2, $3); }
                 | oper_expr EMINUS oper_expr
-                  { $$ = curr_parser.make_binary_op ('-', $1, $2, $3); }
+                  { $$ = parser.make_binary_op ('-', $1, $2, $3); }
                 | oper_expr EMUL oper_expr
-                  { $$ = curr_parser.make_binary_op (EMUL, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EMUL, $1, $2, $3); }
                 | oper_expr EDIV oper_expr
-                  { $$ = curr_parser.make_binary_op (EDIV, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EDIV, $1, $2, $3); }
                 | oper_expr LEFTDIV oper_expr
-                  { $$ = curr_parser.make_binary_op (LEFTDIV, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (LEFTDIV, $1, $2, $3); }
                 | oper_expr ELEFTDIV oper_expr
-                  { $$ = curr_parser.make_binary_op (ELEFTDIV, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (ELEFTDIV, $1, $2, $3); }
                 ;
 
 colon_expr      : colon_expr1
-                  { $$ = curr_parser.finish_colon_expression ($1); }
+                  { $$ = parser.finish_colon_expression ($1); }
                 ;
 
 colon_expr1     : oper_expr
@@ -670,37 +670,37 @@
 simple_expr     : colon_expr
                   { $$ = $1; }
                 | simple_expr LSHIFT simple_expr
-                  { $$ = curr_parser.make_binary_op (LSHIFT, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (LSHIFT, $1, $2, $3); }
                 | simple_expr RSHIFT simple_expr
-                  { $$ = curr_parser.make_binary_op (RSHIFT, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (RSHIFT, $1, $2, $3); }
                 | simple_expr EXPR_LT simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_LT, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_LT, $1, $2, $3); }
                 | simple_expr EXPR_LE simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_LE, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_LE, $1, $2, $3); }
                 | simple_expr EXPR_EQ simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_EQ, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_EQ, $1, $2, $3); }
                 | simple_expr EXPR_GE simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_GE, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_GE, $1, $2, $3); }
                 | simple_expr EXPR_GT simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_GT, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_GT, $1, $2, $3); }
                 | simple_expr EXPR_NE simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_NE, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_NE, $1, $2, $3); }
                 | simple_expr EXPR_AND simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_AND, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_AND, $1, $2, $3); }
                 | simple_expr EXPR_OR simple_expr
-                  { $$ = curr_parser.make_binary_op (EXPR_OR, $1, $2, $3); }
+                  { $$ = parser.make_binary_op (EXPR_OR, $1, $2, $3); }
                 | simple_expr EXPR_AND_AND simple_expr
-                  { $$ = curr_parser.make_boolean_op (EXPR_AND_AND, $1, $2, $3); }
+                  { $$ = parser.make_boolean_op (EXPR_AND_AND, $1, $2, $3); }
                 | simple_expr EXPR_OR_OR simple_expr
-                  { $$ = curr_parser.make_boolean_op (EXPR_OR_OR, $1, $2, $3); }
+                  { $$ = parser.make_boolean_op (EXPR_OR_OR, $1, $2, $3); }
                 ;
 
 assign_lhs      : simple_expr
                   {
-                    $$ = curr_parser.validate_matrix_for_assignment ($1);
+                    $$ = parser.validate_matrix_for_assignment ($1);
 
                     if ($$)
-                      { curr_lexer->looking_at_matrix_or_assign_lhs = false; }
+                      { lexer.looking_at_matrix_or_assign_lhs = false; }
                     else
                       {
                         // validate_matrix_for_assignment deleted $1.
@@ -710,42 +710,42 @@
                 ;
 
 assign_expr     : assign_lhs '=' expression
-                  { $$ = curr_parser.make_assign_op ('=', $1, $2, $3); }
+                  { $$ = parser.make_assign_op ('=', $1, $2, $3); }
                 | assign_lhs ADD_EQ expression
-                  { $$ = curr_parser.make_assign_op (ADD_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (ADD_EQ, $1, $2, $3); }
                 | assign_lhs SUB_EQ expression
-                  { $$ = curr_parser.make_assign_op (SUB_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (SUB_EQ, $1, $2, $3); }
                 | assign_lhs MUL_EQ expression
-                  { $$ = curr_parser.make_assign_op (MUL_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (MUL_EQ, $1, $2, $3); }
                 | assign_lhs DIV_EQ expression
-                  { $$ = curr_parser.make_assign_op (DIV_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (DIV_EQ, $1, $2, $3); }
                 | assign_lhs LEFTDIV_EQ expression
-                  { $$ = curr_parser.make_assign_op (LEFTDIV_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (LEFTDIV_EQ, $1, $2, $3); }
                 | assign_lhs POW_EQ expression
-                  { $$ = curr_parser.make_assign_op (POW_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (POW_EQ, $1, $2, $3); }
                 | assign_lhs LSHIFT_EQ expression
-                  { $$ = curr_parser.make_assign_op (LSHIFT_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (LSHIFT_EQ, $1, $2, $3); }
                 | assign_lhs RSHIFT_EQ expression
-                  { $$ = curr_parser.make_assign_op (RSHIFT_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (RSHIFT_EQ, $1, $2, $3); }
                 | assign_lhs EMUL_EQ expression
-                  { $$ = curr_parser.make_assign_op (EMUL_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (EMUL_EQ, $1, $2, $3); }
                 | assign_lhs EDIV_EQ expression
-                  { $$ = curr_parser.make_assign_op (EDIV_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (EDIV_EQ, $1, $2, $3); }
                 | assign_lhs ELEFTDIV_EQ expression
-                  { $$ = curr_parser.make_assign_op (ELEFTDIV_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (ELEFTDIV_EQ, $1, $2, $3); }
                 | assign_lhs EPOW_EQ expression
-                  { $$ = curr_parser.make_assign_op (EPOW_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (EPOW_EQ, $1, $2, $3); }
                 | assign_lhs AND_EQ expression
-                  { $$ = curr_parser.make_assign_op (AND_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (AND_EQ, $1, $2, $3); }
                 | assign_lhs OR_EQ expression
-                  { $$ = curr_parser.make_assign_op (OR_EQ, $1, $2, $3); }
+                  { $$ = parser.make_assign_op (OR_EQ, $1, $2, $3); }
                 ;
 
 expression      : simple_expr
                   {
                     if ($1 && ($1->is_matrix () || $1->is_cell ()))
                       {
-                        if (curr_parser.validate_array_list ($1))
+                        if (parser.validate_array_list ($1))
                           $$ = $1;
                         else
                           {
@@ -788,13 +788,13 @@
 
 declaration     : GLOBAL decl1
                   {
-                    $$ = curr_parser.make_decl_command (GLOBAL, $1, $2);
-                    curr_lexer->looking_at_decl_list = false;
+                    $$ = parser.make_decl_command (GLOBAL, $1, $2);
+                    lexer.looking_at_decl_list = false;
                   }
                 | PERSISTENT decl1
                   {
-                    $$ = curr_parser.make_decl_command (PERSISTENT, $1, $2);
-                    curr_lexer->looking_at_decl_list = false;
+                    $$ = parser.make_decl_command (PERSISTENT, $1, $2);
+                    lexer.looking_at_decl_list = false;
                   }
                 ;
 
@@ -808,13 +808,13 @@
                 ;
 
 decl_param_init : // empty
-                { curr_lexer->looking_at_initializer_expression = true; }
+                { lexer.looking_at_initializer_expression = true; }
 
 decl2           : identifier
                   { $$ = new tree_decl_elt ($1); }
                 | identifier '=' decl_param_init expression
                   {
-                    curr_lexer->looking_at_initializer_expression = false;
+                    lexer.looking_at_initializer_expression = false;
                     $$ = new tree_decl_elt ($1, $4);
                   }
                 | magic_tilde
@@ -839,7 +839,7 @@
 
 if_command      : IF stash_comment if_cmd_list END
                   {
-                    if (! ($$ = curr_parser.finish_if_command ($1, $3, $4, $2)))
+                    if (! ($$ = parser.finish_if_command ($1, $3, $4, $2)))
                       ABORT_PARSE;
                   }
                 ;
@@ -855,9 +855,9 @@
 
 if_cmd_list1    : expression opt_sep opt_list
                   {
-                    $1->mark_braindead_shortcircuit (curr_lexer->fcn_file_full_name);
-
-                    $$ = curr_parser.start_if_command ($1, $3);
+                    $1->mark_braindead_shortcircuit (lexer.fcn_file_full_name);
+
+                    $$ = parser.start_if_command ($1, $3);
                   }
                 | if_cmd_list1 elseif_clause
                   {
@@ -868,9 +868,9 @@
 
 elseif_clause   : ELSEIF stash_comment opt_sep expression opt_sep opt_list
                   {
-                    $4->mark_braindead_shortcircuit (curr_lexer->fcn_file_full_name);
-
-                    $$ = curr_parser.make_elseif_clause ($1, $4, $6, $2);
+                    $4->mark_braindead_shortcircuit (lexer.fcn_file_full_name);
+
+                    $$ = parser.make_elseif_clause ($1, $4, $6, $2);
                   }
                 ;
 
@@ -884,7 +884,7 @@
 
 switch_command  : SWITCH stash_comment expression opt_sep case_list END
                   {
-                    if (! ($$ = curr_parser.finish_switch_command ($1, $3, $5, $6, $2)))
+                    if (! ($$ = parser.finish_switch_command ($1, $3, $5, $6, $2)))
                       ABORT_PARSE;
                   }
                 ;
@@ -912,7 +912,7 @@
                 ;
 
 switch_case     : CASE stash_comment opt_sep expression opt_sep opt_list
-                  { $$ = curr_parser.make_switch_case ($1, $4, $6, $2); }
+                  { $$ = parser.make_switch_case ($1, $4, $6, $2); }
                 ;
 
 default_case    : OTHERWISE stash_comment opt_sep opt_list
@@ -927,37 +927,37 @@
 
 loop_command    : WHILE stash_comment expression opt_sep opt_list END
                   {
-                    $3->mark_braindead_shortcircuit (curr_lexer->fcn_file_full_name);
-
-                    if (! ($$ = curr_parser.make_while_command ($1, $3, $5, $6, $2)))
+                    $3->mark_braindead_shortcircuit (lexer.fcn_file_full_name);
+
+                    if (! ($$ = parser.make_while_command ($1, $3, $5, $6, $2)))
                       ABORT_PARSE;
                   }
                 | DO stash_comment opt_sep opt_list UNTIL expression
                   {
-                    if (! ($$ = curr_parser.make_do_until_command ($5, $4, $6, $2)))
+                    if (! ($$ = parser.make_do_until_command ($5, $4, $6, $2)))
                       ABORT_PARSE;
                   }
                 | FOR stash_comment assign_lhs '=' expression opt_sep opt_list END
                   {
-                    if (! ($$ = curr_parser.make_for_command (FOR, $1, $3, $5, 0,
+                    if (! ($$ = parser.make_for_command (FOR, $1, $3, $5, 0,
                                                   $7, $8, $2)))
                       ABORT_PARSE;
                   }
                 | FOR stash_comment '(' assign_lhs '=' expression ')' opt_sep opt_list END
                   {
-                    if (! ($$ = curr_parser.make_for_command (FOR, $1, $4, $6, 0,
+                    if (! ($$ = parser.make_for_command (FOR, $1, $4, $6, 0,
                                                   $9, $10, $2)))
                       ABORT_PARSE;
                   }
                 | PARFOR stash_comment assign_lhs '=' expression opt_sep opt_list END
                   {
-                    if (! ($$ = curr_parser.make_for_command (PARFOR, $1, $3, $5,
+                    if (! ($$ = parser.make_for_command (PARFOR, $1, $3, $5,
                                                   0, $7, $8, $2)))
                       ABORT_PARSE;
                   }
                 | PARFOR stash_comment '(' assign_lhs '=' expression ',' expression ')' opt_sep opt_list END
                   {
-                    if (! ($$ = curr_parser.make_for_command (PARFOR, $1, $4, $6,
+                    if (! ($$ = parser.make_for_command (PARFOR, $1, $4, $6,
                                                   $8, $11, $12, $2)))
                       ABORT_PARSE;
                   }
@@ -969,17 +969,17 @@
 
 jump_command    : BREAK
                   {
-                    if (! ($$ = curr_parser.make_break_command ($1)))
+                    if (! ($$ = parser.make_break_command ($1)))
                       ABORT_PARSE;
                   }
                 | CONTINUE
                   {
-                    if (! ($$ = curr_parser.make_continue_command ($1)))
+                    if (! ($$ = parser.make_continue_command ($1)))
                       ABORT_PARSE;
                   }
                 | FUNC_RET
                   {
-                    if (! ($$ = curr_parser.make_return_command ($1)))
+                    if (! ($$ = parser.make_return_command ($1)))
                       ABORT_PARSE;
                   }
                 ;
@@ -991,18 +991,18 @@
 except_command  : UNWIND stash_comment opt_sep opt_list CLEANUP
                   stash_comment opt_sep opt_list END
                   {
-                    if (! ($$ = curr_parser.make_unwind_command ($1, $4, $8, $9, $2, $6)))
+                    if (! ($$ = parser.make_unwind_command ($1, $4, $8, $9, $2, $6)))
                       ABORT_PARSE;
                   }
                 | TRY stash_comment opt_sep opt_list CATCH
                   stash_comment opt_sep opt_list END
                   {
-                    if (! ($$ = curr_parser.make_try_command ($1, $4, $8, $9, $2, $6)))
+                    if (! ($$ = parser.make_try_command ($1, $4, $8, $9, $2, $6)))
                       ABORT_PARSE;
                   }
                 | TRY stash_comment opt_sep opt_list END
                   {
-                    if (! ($$ = curr_parser.make_try_command ($1, $4, 0, $5, $2, 0)))
+                    if (! ($$ = parser.make_try_command ($1, $4, 0, $5, $2, 0)))
                       ABORT_PARSE;
                   }
                 ;
@@ -1013,25 +1013,25 @@
 
 push_fcn_symtab : // empty
                   {
-                    curr_parser.curr_fcn_depth++;
-
-                    if (curr_parser.max_fcn_depth < curr_parser.curr_fcn_depth)
-                      curr_parser.max_fcn_depth = curr_parser.curr_fcn_depth;
+                    parser.curr_fcn_depth++;
+
+                    if (parser.max_fcn_depth < parser.curr_fcn_depth)
+                      parser.max_fcn_depth = parser.curr_fcn_depth;
 
                     parser_symtab_context.push ();
 
                     symbol_table::set_scope (symbol_table::alloc_scope ());
 
-                    curr_parser.function_scopes.push_back (symbol_table::current_scope ());
-
-                    if (! curr_lexer->reading_script_file
-                        && curr_parser.curr_fcn_depth == 1
-                        && ! curr_parser.parsing_subfunctions)
-                      curr_parser.primary_fcn_scope = symbol_table::current_scope ();
-
-                    if (curr_lexer->reading_script_file
-                        && curr_parser.curr_fcn_depth > 1)
-                      curr_parser.bison_error ("nested functions not implemented in this context");
+                    parser.function_scopes.push_back (symbol_table::current_scope ());
+
+                    if (! lexer.reading_script_file
+                        && parser.curr_fcn_depth == 1
+                        && ! parser.parsing_subfunctions)
+                      parser.primary_fcn_scope = symbol_table::current_scope ();
+
+                    if (lexer.reading_script_file
+                        && parser.curr_fcn_depth > 1)
+                      parser.bison_error ("nested functions not implemented in this context");
                   }
                 ;
 
@@ -1041,22 +1041,22 @@
 
 param_list_beg  : '('
                   {
-                    curr_lexer->looking_at_parameter_list = true;
-
-                    if (curr_lexer->looking_at_function_handle)
+                    lexer.looking_at_parameter_list = true;
+
+                    if (lexer.looking_at_function_handle)
                       {
                         parser_symtab_context.push ();
                         symbol_table::set_scope (symbol_table::alloc_scope ());
-                        curr_lexer->looking_at_function_handle--;
-                        curr_lexer->looking_at_anon_fcn_args = true;
+                        lexer.looking_at_function_handle--;
+                        lexer.looking_at_anon_fcn_args = true;
                       }
                   }
                 ;
 
 param_list_end  : ')'
                   {
-                    curr_lexer->looking_at_parameter_list = false;
-                    curr_lexer->looking_for_object_index = false;
+                    lexer.looking_at_parameter_list = false;
+                    lexer.looking_for_object_index = false;
                   }
                 ;
 
@@ -1064,7 +1064,7 @@
                   { $$ = $2; }
                 | param_list_beg error
                   {
-                    curr_parser.bison_error ("invalid parameter list");
+                    parser.bison_error ("invalid parameter list");
                     $$ = 0;
                     ABORT_PARSE;
                   }
@@ -1097,12 +1097,12 @@
 
 return_list     : '[' ']'
                   {
-                    curr_lexer->looking_at_return_list = false;
+                    lexer.looking_at_return_list = false;
                     $$ = new tree_parameter_list ();
                   }
                 | return_list1
                   {
-                    curr_lexer->looking_at_return_list = false;
+                    lexer.looking_at_return_list = false;
                     if ($1->validate (tree_parameter_list::out))
                       $$ = $1;
                     else
@@ -1110,7 +1110,7 @@
                   }
                 | '[' return_list1 ']'
                   {
-                    curr_lexer->looking_at_return_list = false;
+                    lexer.looking_at_return_list = false;
                     if ($2->validate (tree_parameter_list::out))
                       $$ = $2;
                     else
@@ -1133,22 +1133,22 @@
 
 file            : INPUT_FILE opt_nl opt_list END_OF_INPUT
                   {
-                    if (! curr_lexer->reading_fcn_file)
+                    if (! lexer.reading_fcn_file)
                       {
                         tree_statement *end_of_script
-                          = curr_parser.make_end ("endscript",
-                                                  curr_lexer->input_line_number,
-                                                  curr_lexer->current_input_column);
-
-                        curr_parser.make_script ($3, end_of_script);
+                          = parser.make_end ("endscript",
+                                                  lexer.input_line_number,
+                                                  lexer.current_input_column);
+
+                        parser.make_script ($3, end_of_script);
                       }
 
                     $$ = 0;
                   }
                 | INPUT_FILE opt_nl classdef opt_sep END_OF_INPUT
                   {
-                    if (curr_lexer->reading_classdef_file)
-                      curr_parser.classdef_object = $3;
+                    if (lexer.reading_classdef_file)
+                      parser.classdef_object = $3;
 
                     $$ = 0;
                   }
@@ -1161,21 +1161,21 @@
 function_beg    : push_fcn_symtab FCN stash_comment
                   {
                     $$ = $3;
-                    if (curr_lexer->reading_classdef_file
-                        || curr_lexer->parsing_classdef)
-                      curr_lexer->maybe_classdef_get_set_method = true;
+                    if (lexer.reading_classdef_file
+                        || lexer.parsing_classdef)
+                      lexer.maybe_classdef_get_set_method = true;
                   }
                 ;
 
 function        : function_beg function1
                   {
-                    $$ = curr_parser.finish_function (0, $2, $1);
-                    curr_parser.recover_from_parsing_function ();
+                    $$ = parser.finish_function (0, $2, $1);
+                    parser.recover_from_parsing_function ();
                   }
                 | function_beg return_list '=' function1
                   {
-                    $$ = curr_parser.finish_function ($2, $4, $1);
-                    curr_parser.recover_from_parsing_function ();
+                    $$ = parser.finish_function ($2, $4, $1);
+                    parser.recover_from_parsing_function ();
                   }
                 ;
 
@@ -1183,23 +1183,23 @@
                   {
                     std::string id_name = $1->name ();
 
-                    curr_lexer->parsed_function_name.top () = true;
-                    curr_lexer->maybe_classdef_get_set_method = false;
+                    lexer.parsed_function_name.top () = true;
+                    lexer.maybe_classdef_get_set_method = false;
 
                     $$ = $1;
                   }
                 | GET '.' identifier
                   {
-                    curr_lexer->parsed_function_name.top () = true;
-                    curr_lexer->maybe_classdef_get_set_method = false;
-                    curr_lexer->parsing_classdef_get_method = true;
+                    lexer.parsed_function_name.top () = true;
+                    lexer.maybe_classdef_get_set_method = false;
+                    lexer.parsing_classdef_get_method = true;
                     $$ = $3;
                   }
                 | SET '.' identifier
                   {
-                    curr_lexer->parsed_function_name.top () = true;
-                    curr_lexer->maybe_classdef_get_set_method = false;
-                    curr_lexer->parsing_classdef_set_method = true;
+                    lexer.parsed_function_name.top () = true;
+                    lexer.maybe_classdef_get_set_method = false;
+                    lexer.parsing_classdef_set_method = true;
                     $$ = $3;
                   }
                 ;
@@ -1210,58 +1210,58 @@
 
                     delete $1;
 
-                    if (! ($$ = curr_parser.frob_function (fname, $2)))
+                    if (! ($$ = parser.frob_function (fname, $2)))
                       ABORT_PARSE;
                   }
                 ;
 
 function2       : param_list opt_sep opt_list function_end
-                  { $$ = curr_parser.start_function ($1, $3, $4); }
+                  { $$ = parser.start_function ($1, $3, $4); }
                 | opt_sep opt_list function_end
-                  { $$ = curr_parser.start_function (0, $2, $3); }
+                  { $$ = parser.start_function (0, $2, $3); }
                 ;
 
 function_end    : END
                   {
-                    curr_parser.endfunction_found = true;
-                    if (curr_parser.end_token_ok ($1, token::function_end))
-                      $$ = curr_parser.make_end ("endfunction", $1->line (), $1->column ());
+                    parser.endfunction_found = true;
+                    if (parser.end_token_ok ($1, token::function_end))
+                      $$ = parser.make_end ("endfunction", $1->line (), $1->column ());
                     else
                       ABORT_PARSE;
                   }
                 | END_OF_INPUT
                   {
 // A lot of tests are based on the assumption that this is OK
-//                  if (curr_lexer->reading_script_file)
+//                  if (lexer.reading_script_file)
 //                    {
-//                      curr_parser.bison_error ("function body open at end of script");
+//                      parser.bison_error ("function body open at end of script");
 //                      YYABORT;
 //                    }
 
-                    if (curr_parser.endfunction_found)
+                    if (parser.endfunction_found)
                       {
-                        curr_parser.bison_error ("inconsistent function endings -- "
+                        parser.bison_error ("inconsistent function endings -- "
                                  "if one function is explicitly ended, "
                                  "so must all the others");
                         YYABORT;
                       }
 
-                    if (! (curr_lexer->reading_fcn_file || curr_lexer->reading_script_file
-                           || (curr_lexer)->input_from_eval_string ()))
+                    if (! (lexer.reading_fcn_file || lexer.reading_script_file
+                           || lexer.input_from_eval_string ()))
                       {
-                        curr_parser.bison_error ("function body open at end of input");
+                        parser.bison_error ("function body open at end of input");
                         YYABORT;
                       }
 
-                    if (curr_lexer->reading_classdef_file)
+                    if (lexer.reading_classdef_file)
                       {
-                        curr_parser.bison_error ("classdef body open at end of input");
+                        parser.bison_error ("classdef body open at end of input");
                         YYABORT;
                       }
 
-                    $$ = curr_parser.make_end ("endfunction",
-                                                curr_lexer->input_line_number,
-                                                curr_lexer->current_input_column);
+                    $$ = parser.make_end ("endfunction",
+                                                lexer.input_line_number,
+                                                lexer.current_input_column);
                   }
                 ;
 
@@ -1271,21 +1271,21 @@
 
 classdef_beg    : CLASSDEF
                   {
-                    if (! curr_lexer->reading_classdef_file)
+                    if (! lexer.reading_classdef_file)
                       {
-                        curr_parser.bison_error ("classdef must appear inside a file containing only a class definition");
+                        parser.bison_error ("classdef must appear inside a file containing only a class definition");
                         YYABORT;
                       }
 
-                    curr_lexer->parsing_classdef = true;
+                    lexer.parsing_classdef = true;
                     $$ = $1;
                   }
                 ;
 
 classdef        : classdef_beg stash_comment opt_attr_list identifier opt_superclass_list opt_sep class_body opt_sep END
                   {
-                    curr_lexer->parsing_classdef = false;
-                    if (! ($$ = curr_parser.make_classdef ($1, $3, $4, $5, $7, $9, $2)))
+                    lexer.parsing_classdef = false;
+                    if (! ($$ = parser.make_classdef ($1, $3, $4, $5, $7, $9, $2)))
                       ABORT_PARSE;
                   }
                 ;
@@ -1309,7 +1309,7 @@
                   { $$ = new tree_classdef_attribute ($1); }
                 | identifier '=' decl_param_init expression
                   {
-                    curr_lexer->looking_at_initializer_expression = false;
+                    lexer.looking_at_initializer_expression = false;
                     $$ = new tree_classdef_attribute ($1, $4);
                   }
                 | EXPR_NOT identifier
@@ -1371,7 +1371,7 @@
 properties_block
                 : PROPERTIES stash_comment opt_attr_list opt_sep property_list opt_sep END
                   {
-                    if (! ($$ = curr_parser.make_classdef_properties_block
+                    if (! ($$ = parser.make_classdef_properties_block
                                               ($1, $3, $5, $7, $2)))
                       ABORT_PARSE;
                   }
@@ -1391,14 +1391,14 @@
                   { $$ = new tree_classdef_property ($1); }
                 | identifier '=' decl_param_init expression ';'
                   {
-                    curr_lexer->looking_at_initializer_expression = false;
+                    lexer.looking_at_initializer_expression = false;
                     $$ = new tree_classdef_property ($1, $4);
                   }
                 ;
 
 methods_block   : METHODS stash_comment opt_attr_list opt_sep methods_list opt_sep END
                   {
-                    if (! ($$ = curr_parser.make_classdef_methods_block
+                    if (! ($$ = parser.make_classdef_methods_block
                                               ($1, $3, $5, $7, $2)))
                       ABORT_PARSE;
                   }
@@ -1426,7 +1426,7 @@
 
 events_block    : EVENTS stash_comment opt_attr_list opt_sep events_list opt_sep END
                   {
-                    if (! ($$ = curr_parser.make_classdef_events_block
+                    if (! ($$ = parser.make_classdef_events_block
                                               ($1, $3, $5, $7, $2)))
                       ABORT_PARSE;
                   }
@@ -1447,7 +1447,7 @@
 
 enum_block      : ENUMERATION stash_comment opt_attr_list opt_sep enum_list opt_sep END
                   {
-                    if (! ($$ = curr_parser.make_classdef_enum_block
+                    if (! ($$ = parser.make_classdef_enum_block
                                               ($1, $3, $5, $7, $2)))
                       ABORT_PARSE;
                   }
@@ -1475,7 +1475,7 @@
                 ;
 
 parse_error     : LEXICAL_ERROR
-                  { curr_parser.bison_error ("parse error"); }
+                  { parser.bison_error ("parse error"); }
                 | error
                 ;
 
@@ -1531,15 +1531,15 @@
 
 // Generic error messages.
 
-#undef curr_lexer
+#undef lexer
 
 static void
-yyerror (octave_parser& curr_parser, const char *s)
+yyerror (octave_base_parser& parser, const char *s)
 {
-  curr_parser.bison_error (s);
+  parser.bison_error (s);
 }
 
-octave_parser::~octave_parser (void)
+octave_base_parser::~octave_base_parser (void)
 {
 #if defined (OCTAVE_USE_PUSH_PARSER)
   yypstate_delete (static_cast<yypstate *> (parser_state));
@@ -1547,60 +1547,33 @@
 
   delete stmt_list;
 
-  delete curr_lexer;
+  delete &lexer;
 }
-void octave_parser::init (void)
+
+void octave_base_parser::init (void)
 {
 #if defined (OCTAVE_USE_PUSH_PARSER)
   parser_state = yypstate_new ();
 #endif
 
-  CURR_LEXER = curr_lexer;
+  LEXER = &lexer;
 }
 
 void
-octave_parser::reset (void)
+octave_base_parser::reset (void)
 {
   delete stmt_list;
 
   stmt_list = 0;
 
-  curr_lexer->reset ();
-}
-
-int
-octave_parser::run (void)
-{
-  int status = 0;
-
-#if defined (OCTAVE_USE_PUSH_PARSER)
-
-  do
-    {
-      YYSTYPE lval;
-
-      int token = octave_lex (&lval, scanner);
-
-      yypstate *pstate = static_cast<yypstate *> (parser_state);
-
-      status = octave_push_parse (pstate, token, &lval, *this);
-    }
-  while (status == YYPUSH_MORE);
-
-#else
-
-  status = octave_parse (*this);
-
-#endif
-
-  return status;
+  lexer.reset ();
 }
 
 // Error mesages for mismatched end tokens.
 
 void
-octave_parser::end_error (const char *type, token::end_tok_type ettype,
-                          int l, int c)
+octave_base_parser::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";
@@ -1652,7 +1625,7 @@
 // Check to see that end tokens are properly matched.
 
 bool
-octave_parser::end_token_ok (token *tok, token::end_tok_type expected)
+octave_base_parser::end_token_ok (token *tok, token::end_tok_type expected)
 {
   bool retval = true;
 
@@ -1722,12 +1695,12 @@
 // test in a logical expression.
 
 void
-octave_parser::maybe_warn_assign_as_truth_value (tree_expression *expr)
+octave_base_parser::maybe_warn_assign_as_truth_value (tree_expression *expr)
 {
   if (expr->is_assignment_expression ()
       && expr->paren_count () < 2)
     {
-      if (curr_lexer->fcn_file_full_name.empty ())
+      if (lexer.fcn_file_full_name.empty ())
         warning_with_id
           ("Octave:assign-as-truth-value",
            "suggest parenthesis around assignment used as truth value");
@@ -1735,25 +1708,25 @@
         warning_with_id
           ("Octave:assign-as-truth-value",
            "suggest parenthesis around assignment used as truth value near line %d, column %d in file '%s'",
-           expr->line (), expr->column (), curr_lexer->fcn_file_full_name.c_str ());
+           expr->line (), expr->column (), lexer.fcn_file_full_name.c_str ());
     }
 }
 
 // Maybe print a warning about switch labels that aren't constants.
 
 void
-octave_parser::maybe_warn_variable_switch_label (tree_expression *expr)
+octave_base_parser::maybe_warn_variable_switch_label (tree_expression *expr)
 {
   if (! expr->is_constant ())
     {
-      if (curr_lexer->fcn_file_full_name.empty ())
+      if (lexer.fcn_file_full_name.empty ())
         warning_with_id ("Octave:variable-switch-label",
                          "variable switch label");
       else
         warning_with_id
           ("Octave:variable-switch-label",
            "variable switch label near line %d, column %d in file '%s'",
-           expr->line (), expr->column (), curr_lexer->fcn_file_full_name.c_str ());
+           expr->line (), expr->column (), lexer.fcn_file_full_name.c_str ());
     }
 }
 
@@ -1849,7 +1822,7 @@
 // Finish building a range.
 
 tree_expression *
-octave_parser::finish_colon_expression (tree_colon_expression *e)
+octave_base_parser::finish_colon_expression (tree_colon_expression *e)
 {
   tree_expression *retval = e;
 
@@ -1913,7 +1886,7 @@
 // Make a constant.
 
 tree_constant *
-octave_parser::make_constant (int op, token *tok_val)
+octave_base_parser::make_constant (int op, token *tok_val)
 {
   int l = tok_val->line ();
   int c = tok_val->column ();
@@ -1976,7 +1949,7 @@
 // Make a function handle.
 
 tree_fcn_handle *
-octave_parser::make_fcn_handle (token *tok_val)
+octave_base_parser::make_fcn_handle (token *tok_val)
 {
   int l = tok_val->line ();
   int c = tok_val->column ();
@@ -1989,12 +1962,12 @@
 // Make an anonymous function handle.
 
 tree_anon_fcn_handle *
-octave_parser::make_anon_fcn_handle (tree_parameter_list *param_list,
-                                     tree_statement *stmt)
+octave_base_parser::make_anon_fcn_handle (tree_parameter_list *param_list,
+                                          tree_statement *stmt)
 {
   // FIXME -- need to get these from the location of the @ symbol.
-  int l = curr_lexer->input_line_number;
-  int c = curr_lexer->current_input_column;
+  int l = lexer.input_line_number;
+  int c = lexer.current_input_column;
 
   tree_parameter_list *ret_list = 0;
 
@@ -2015,7 +1988,7 @@
     = new tree_anon_fcn_handle (param_list, ret_list, body, fcn_scope, l, c);
   // FIXME: Stash the filename.  This does not work and produces
   // errors when executed.
-  //retval->stash_file_name (curr_lexer->fcn_file_name);
+  //retval->stash_file_name (lexer.fcn_file_name);
 
   return retval;
 }
@@ -2023,8 +1996,8 @@
 // Build a binary expression.
 
 tree_expression *
-octave_parser::make_binary_op (int op, tree_expression *op1, token *tok_val,
-                               tree_expression *op2)
+octave_base_parser::make_binary_op (int op, tree_expression *op1,
+                                    token *tok_val, tree_expression *op2)
 {
   octave_value::binary_op t = octave_value::unknown_binary_op;
 
@@ -2127,8 +2100,8 @@
 // Build a boolean expression.
 
 tree_expression *
-octave_parser::make_boolean_op (int op, tree_expression *op1, token *tok_val,
-                                tree_expression *op2)
+octave_base_parser::make_boolean_op (int op, tree_expression *op1,
+                                     token *tok_val, tree_expression *op2)
 {
   tree_boolean_expression::type t;
 
@@ -2159,7 +2132,8 @@
 // Build a prefix expression.
 
 tree_expression *
-octave_parser::make_prefix_op (int op, tree_expression *op1, token *tok_val)
+octave_base_parser::make_prefix_op (int op, tree_expression *op1,
+                                    token *tok_val)
 {
   octave_value::unary_op t = octave_value::unknown_unary_op;
 
@@ -2202,7 +2176,8 @@
 // Build a postfix expression.
 
 tree_expression *
-octave_parser::make_postfix_op (int op, tree_expression *op1, token *tok_val)
+octave_base_parser::make_postfix_op (int op, tree_expression *op1,
+                                     token *tok_val)
 {
   octave_value::unary_op t = octave_value::unknown_unary_op;
 
@@ -2241,12 +2216,12 @@
 // Build an unwind-protect command.
 
 tree_command *
-octave_parser::make_unwind_command (token *unwind_tok,
-                                    tree_statement_list *body,
-                                    tree_statement_list *cleanup_stmts,
-                                    token *end_tok,
-                                    octave_comment_list *lc,
-                                    octave_comment_list *mc)
+octave_base_parser::make_unwind_command (token *unwind_tok,
+                                         tree_statement_list *body,
+                                         tree_statement_list *cleanup_stmts,
+                                         token *end_tok,
+                                         octave_comment_list *lc,
+                                         octave_comment_list *mc)
 {
   tree_command *retval = 0;
 
@@ -2267,11 +2242,12 @@
 // Build a try-catch command.
 
 tree_command *
-octave_parser::make_try_command (token *try_tok, tree_statement_list *body,
-                                 tree_statement_list *cleanup_stmts,
-                                 token *end_tok,
-                                 octave_comment_list *lc,
-                                 octave_comment_list *mc)
+octave_base_parser::make_try_command (token *try_tok,
+                                      tree_statement_list *body,
+                                      tree_statement_list *cleanup_stmts,
+                                      token *end_tok,
+                                      octave_comment_list *lc,
+                                      octave_comment_list *mc)
 {
   tree_command *retval = 0;
 
@@ -2292,9 +2268,11 @@
 // Build a while command.
 
 tree_command *
-octave_parser::make_while_command (token *while_tok, tree_expression *expr,
-                                   tree_statement_list *body, token *end_tok,
-                                   octave_comment_list *lc)
+octave_base_parser::make_while_command (token *while_tok,
+                                        tree_expression *expr,
+                                        tree_statement_list *body,
+                                        token *end_tok,
+                                        octave_comment_list *lc)
 {
   tree_command *retval = 0;
 
@@ -2304,7 +2282,7 @@
     {
       octave_comment_list *tc = octave_comment_buffer::get_comment ();
 
-      curr_lexer->looping--;
+      lexer.looping--;
 
       int l = while_tok->line ();
       int c = while_tok->column ();
@@ -2318,10 +2296,10 @@
 // Build a do-until command.
 
 tree_command *
-octave_parser::make_do_until_command (token *until_tok,
-                                      tree_statement_list *body,
-                                      tree_expression *expr,
-                                      octave_comment_list *lc)
+octave_base_parser::make_do_until_command (token *until_tok,
+                                           tree_statement_list *body,
+                                           tree_expression *expr,
+                                           octave_comment_list *lc)
 {
   tree_command *retval = 0;
 
@@ -2329,7 +2307,7 @@
 
   octave_comment_list *tc = octave_comment_buffer::get_comment ();
 
-  curr_lexer->looping--;
+  lexer.looping--;
 
   int l = until_tok->line ();
   int c = until_tok->column ();
@@ -2342,12 +2320,13 @@
 // Build a for command.
 
 tree_command *
-octave_parser::make_for_command (int tok_id, token *for_tok,
-                                 tree_argument_list *lhs,
-                                 tree_expression *expr,
-                                 tree_expression *maxproc,
-                                 tree_statement_list *body, token *end_tok,
-                                 octave_comment_list *lc)
+octave_base_parser::make_for_command (int tok_id, token *for_tok,
+                                      tree_argument_list *lhs,
+                                      tree_expression *expr,
+                                      tree_expression *maxproc,
+                                      tree_statement_list *body,
+                                      token *end_tok,
+                                      octave_comment_list *lc)
 {
   tree_command *retval = 0;
 
@@ -2357,7 +2336,7 @@
     {
       octave_comment_list *tc = octave_comment_buffer::get_comment ();
 
-      curr_lexer->looping--;
+      lexer.looping--;
 
       int l = for_tok->line ();
       int c = for_tok->column ();
@@ -2387,7 +2366,7 @@
 // Build a break command.
 
 tree_command *
-octave_parser::make_break_command (token *break_tok)
+octave_base_parser::make_break_command (token *break_tok)
 {
   tree_command *retval = 0;
 
@@ -2402,7 +2381,7 @@
 // Build a continue command.
 
 tree_command *
-octave_parser::make_continue_command (token *continue_tok)
+octave_base_parser::make_continue_command (token *continue_tok)
 {
   tree_command *retval = 0;
 
@@ -2417,7 +2396,7 @@
 // Build a return command.
 
 tree_command *
-octave_parser::make_return_command (token *return_tok)
+octave_base_parser::make_return_command (token *return_tok)
 {
   tree_command *retval = 0;
 
@@ -2432,8 +2411,8 @@
 // Start an if command.
 
 tree_if_command_list *
-octave_parser::start_if_command (tree_expression *expr,
-                                 tree_statement_list *list)
+octave_base_parser::start_if_command (tree_expression *expr,
+                                      tree_statement_list *list)
 {
   maybe_warn_assign_as_truth_value (expr);
 
@@ -2445,8 +2424,10 @@
 // Finish an if command.
 
 tree_if_command *
-octave_parser::finish_if_command (token *if_tok, tree_if_command_list *list,
-                                  token *end_tok, octave_comment_list *lc)
+octave_base_parser::finish_if_command (token *if_tok,
+                                       tree_if_command_list *list,
+                                       token *end_tok,
+                                       octave_comment_list *lc)
 {
   tree_if_command *retval = 0;
 
@@ -2477,9 +2458,10 @@
 // Build an elseif clause.
 
 tree_if_clause *
-octave_parser::make_elseif_clause (token *elseif_tok, tree_expression *expr,
-                                   tree_statement_list *list,
-                                   octave_comment_list *lc)
+octave_base_parser::make_elseif_clause (token *elseif_tok,
+                                        tree_expression *expr,
+                                        tree_statement_list *list,
+                                        octave_comment_list *lc)
 {
   maybe_warn_assign_as_truth_value (expr);
 
@@ -2492,9 +2474,11 @@
 // Finish a switch command.
 
 tree_switch_command *
-octave_parser::finish_switch_command (token *switch_tok, tree_expression *expr,
-                                      tree_switch_case_list *list,
-                                      token *end_tok, octave_comment_list *lc)
+octave_base_parser::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;
 
@@ -2525,9 +2509,10 @@
 // Build a switch case.
 
 tree_switch_case *
-octave_parser::make_switch_case (token *case_tok, tree_expression *expr,
-                                 tree_statement_list *list,
-                                 octave_comment_list *lc)
+octave_base_parser::make_switch_case (token *case_tok,
+                                      tree_expression *expr,
+                                      tree_statement_list *list,
+                                      octave_comment_list *lc)
 {
   maybe_warn_variable_switch_label (expr);
 
@@ -2540,8 +2525,8 @@
 // Build an assignment to a variable.
 
 tree_expression *
-octave_parser::make_assign_op (int op, tree_argument_list *lhs, token *eq_tok,
-                               tree_expression *rhs)
+octave_base_parser::make_assign_op (int op, tree_argument_list *lhs,
+                                    token *eq_tok, tree_expression *rhs)
 {
   tree_expression *retval = 0;
 
@@ -2636,8 +2621,8 @@
 // Define a script.
 
 void
-octave_parser::make_script (tree_statement_list *cmds,
-                            tree_statement *end_script)
+octave_base_parser::make_script (tree_statement_list *cmds,
+                                 tree_statement *end_script)
 {
   if (! cmds)
     cmds = new tree_statement_list ();
@@ -2645,11 +2630,11 @@
   cmds->append (end_script);
 
   octave_user_script *script
-    = new octave_user_script (curr_lexer->fcn_file_full_name,
-                              curr_lexer->fcn_file_name,
-                              cmds, curr_lexer->help_text);
-
-  curr_lexer->help_text = "";
+    = new octave_user_script (lexer.fcn_file_full_name,
+                              lexer.fcn_file_name,
+                              cmds, lexer.help_text);
+
+  lexer.help_text = "";
 
   octave_time now;
 
@@ -2661,9 +2646,9 @@
 // Begin defining a function.
 
 octave_user_function *
-octave_parser::start_function (tree_parameter_list *param_list,
-                               tree_statement_list *body,
-                               tree_statement *end_fcn_stmt)
+octave_base_parser::start_function (tree_parameter_list *param_list,
+                                    tree_statement_list *body,
+                                    tree_statement *end_fcn_stmt)
 {
   // We'll fill in the return list later.
 
@@ -2687,7 +2672,7 @@
 }
 
 tree_statement *
-octave_parser::make_end (const std::string& type, int l, int c)
+octave_base_parser::make_end (const std::string& type, int l, int c)
 {
   return make_statement (new tree_no_op_command (type, l, c));
 }
@@ -2695,8 +2680,8 @@
 // Do most of the work for defining a function.
 
 octave_user_function *
-octave_parser::frob_function (const std::string& fname,
-                              octave_user_function *fcn)
+octave_base_parser::frob_function (const std::string& fname,
+                                   octave_user_function *fcn)
 {
   std::string id_name = fname;
 
@@ -2704,36 +2689,36 @@
   // 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 (! autoloading && curr_lexer->reading_fcn_file
+  if (! autoloading && lexer.reading_fcn_file
       && curr_fcn_depth == 1 && ! parsing_subfunctions)
   {
-    // FIXME -- should curr_lexer->fcn_file_name already be
+    // FIXME -- should lexer.fcn_file_name already be
     // preprocessed when we get here?  It seems to only be a
     // problem with relative file names.
 
-    std::string nm = curr_lexer->fcn_file_name;
+    std::string nm = lexer.fcn_file_name;
 
     size_t pos = nm.find_last_of (file_ops::dir_sep_chars ());
 
     if (pos != std::string::npos)
-      nm = curr_lexer->fcn_file_name.substr (pos+1);
+      nm = lexer.fcn_file_name.substr (pos+1);
 
     if (nm != id_name)
       {
         warning_with_id
           ("Octave:function-name-clash",
            "function name '%s' does not agree with function file name '%s'",
-           id_name.c_str (), curr_lexer->fcn_file_full_name.c_str ());
+           id_name.c_str (), lexer.fcn_file_full_name.c_str ());
 
         id_name = nm;
       }
   }
 
-  if (curr_lexer->reading_fcn_file || curr_lexer->reading_classdef_file || autoloading)
+  if (lexer.reading_fcn_file || lexer.reading_classdef_file || autoloading)
     {
       octave_time now;
 
-      fcn->stash_fcn_file_name (curr_lexer->fcn_file_full_name);
+      fcn->stash_fcn_file_name (lexer.fcn_file_full_name);
       fcn->stash_fcn_file_time (now);
       fcn->mark_as_system_fcn_file ();
 
@@ -2742,7 +2727,7 @@
 
       if (curr_fcn_depth > 1 || parsing_subfunctions)
         {
-          fcn->stash_parent_fcn_name (curr_lexer->fcn_file_name);
+          fcn->stash_parent_fcn_name (lexer.fcn_file_name);
 
           if (curr_fcn_depth > 1)
             fcn->stash_parent_fcn_scope (function_scopes[function_scopes.size ()-2]);
@@ -2750,7 +2735,7 @@
             fcn->stash_parent_fcn_scope (primary_fcn_scope);
         }
 
-      if (curr_lexer->parsing_class_method)
+      if (lexer.parsing_class_method)
         {
           if (curr_class_name == id_name)
             fcn->mark_as_class_constructor ();
@@ -2769,27 +2754,27 @@
                          "time stamp for '%s' is in the future", nm.c_str ());
     }
   else if (! input_from_tmp_history_file
-           && ! curr_lexer->force_script
-           && curr_lexer->reading_script_file
-           && curr_lexer->fcn_file_name == id_name)
+           && ! lexer.force_script
+           && lexer.reading_script_file
+           && lexer.fcn_file_name == id_name)
     {
       warning ("function '%s' defined within script file '%s'",
-               id_name.c_str (), curr_lexer->fcn_file_full_name.c_str ());
+               id_name.c_str (), lexer.fcn_file_full_name.c_str ());
     }
 
   fcn->stash_function_name (id_name);
-  fcn->stash_fcn_location (curr_lexer->input_line_number,
-                           curr_lexer->current_input_column);
-
-  if (! curr_lexer->help_text.empty () && curr_fcn_depth == 1
+  fcn->stash_fcn_location (lexer.input_line_number,
+                           lexer.current_input_column);
+
+  if (! lexer.help_text.empty () && curr_fcn_depth == 1
       && ! parsing_subfunctions)
     {
-      fcn->document (curr_lexer->help_text);
-
-      curr_lexer->help_text = "";
+      fcn->document (lexer.help_text);
+
+      lexer.help_text = "";
     }
 
-  if (curr_lexer->reading_fcn_file && curr_fcn_depth == 1
+  if (lexer.reading_fcn_file && curr_fcn_depth == 1
       && ! parsing_subfunctions)
     primary_fcn_ptr = fcn;
 
@@ -2797,9 +2782,9 @@
 }
 
 tree_function_def *
-octave_parser::finish_function (tree_parameter_list *ret_list,
-                                octave_user_function *fcn,
-                                octave_comment_list *lc)
+octave_base_parser::finish_function (tree_parameter_list *ret_list,
+                                     octave_user_function *fcn,
+                                     octave_comment_list *lc)
 {
   tree_function_def *retval = 0;
 
@@ -2842,7 +2827,7 @@
       if (curr_fcn_depth == 1 && fcn)
         symbol_table::update_nest (fcn->scope ());
 
-      if (! curr_lexer->reading_fcn_file && curr_fcn_depth == 1)
+      if (! lexer.reading_fcn_file && curr_fcn_depth == 1)
         {
           // We are either reading a script file or defining a function
           // at the command line, so this definition creates a
@@ -2862,31 +2847,31 @@
 }
 
 void
-octave_parser::recover_from_parsing_function (void)
+octave_base_parser::recover_from_parsing_function (void)
 {
   if (parser_symtab_context.empty ())
     panic_impossible ();
 
   parser_symtab_context.pop ();
 
-  if (curr_lexer->reading_fcn_file && curr_fcn_depth == 1
+  if (lexer.reading_fcn_file && curr_fcn_depth == 1
       && ! parsing_subfunctions)
     parsing_subfunctions = true;
 
   curr_fcn_depth--;
   function_scopes.pop_back ();
 
-  curr_lexer->defining_func--;
-  curr_lexer->parsed_function_name.pop ();
-  curr_lexer->looking_at_return_list = false;
-  curr_lexer->looking_at_parameter_list = false;
+  lexer.defining_func--;
+  lexer.parsed_function_name.pop ();
+  lexer.looking_at_return_list = false;
+  lexer.looking_at_parameter_list = false;
 }
 
 tree_funcall *
-octave_parser::make_superclass_ref (const std::string& method_nm,
-                                    const std::string& package_nm,
-                                    const std::string& class_nm,
-                                    int l, int c)
+octave_base_parser::make_superclass_ref (const std::string& method_nm,
+                                         const std::string& package_nm,
+                                         const std::string& class_nm,
+                                         int l, int c)
 {
   octave_value_list args;
 
@@ -2901,9 +2886,9 @@
 }
 
 tree_funcall *
-octave_parser::make_meta_class_query (const std::string& package_nm,
-                                      const std::string& class_nm,
-                                      int l, int c)
+octave_base_parser::make_meta_class_query (const std::string& package_nm,
+                                           const std::string& class_nm,
+                                           int l, int c)
 {
   octave_value_list args;
 
@@ -2923,23 +2908,23 @@
 // a parse tree containing meta information about the class.
 
 tree_classdef *
-octave_parser::make_classdef (token *tok_val,
-                              tree_classdef_attribute_list *a,
-                              tree_identifier *id,
-                              tree_classdef_superclass_list *sc,
-                              tree_classdef_body *body, token *end_tok,
-                              octave_comment_list *lc)
+octave_base_parser::make_classdef (token *tok_val,
+                                   tree_classdef_attribute_list *a,
+                                   tree_identifier *id,
+                                   tree_classdef_superclass_list *sc,
+                                   tree_classdef_body *body, token *end_tok,
+                                   octave_comment_list *lc)
 {
   tree_classdef *retval = 0;
 
   std::string cls_name = id->name ();
 
-  std::string nm = curr_lexer->fcn_file_name;
+  std::string nm = lexer.fcn_file_name;
 
   size_t pos = nm.find_last_of (file_ops::dir_sep_chars ());
 
   if (pos != std::string::npos)
-    nm = curr_lexer->fcn_file_name.substr (pos+1);
+    nm = lexer.fcn_file_name.substr (pos+1);
 
   if (nm != cls_name)
     {
@@ -2961,11 +2946,11 @@
 }
 
 tree_classdef_properties_block *
-octave_parser::make_classdef_properties_block (token *tok_val,
-                                               tree_classdef_attribute_list *a,
-                                               tree_classdef_property_list *plist,
-                                               token *end_tok,
-                                               octave_comment_list *lc)
+octave_base_parser::make_classdef_properties_block (token *tok_val,
+                                                    tree_classdef_attribute_list *a,
+                                                    tree_classdef_property_list *plist,
+                                                    token *end_tok,
+                                                    octave_comment_list *lc)
 {
   tree_classdef_properties_block *retval = 0;
 
@@ -2983,11 +2968,11 @@
 }
 
 tree_classdef_methods_block *
-octave_parser::make_classdef_methods_block (token *tok_val,
-                                            tree_classdef_attribute_list *a,
-                                            tree_classdef_methods_list *mlist,
-                                            token *end_tok,
-                                            octave_comment_list *lc)
+octave_base_parser::make_classdef_methods_block (token *tok_val,
+                                                 tree_classdef_attribute_list *a,
+                                                 tree_classdef_methods_list *mlist,
+                                                 token *end_tok,
+                                                 octave_comment_list *lc)
 {
   tree_classdef_methods_block *retval = 0;
 
@@ -3005,11 +2990,11 @@
 }
 
 tree_classdef_events_block *
-octave_parser::make_classdef_events_block (token *tok_val,
-                                           tree_classdef_attribute_list *a,
-                                           tree_classdef_events_list *elist,
-                                           token *end_tok,
-                                           octave_comment_list *lc)
+octave_base_parser::make_classdef_events_block (token *tok_val,
+                                                tree_classdef_attribute_list *a,
+                                                tree_classdef_events_list *elist,
+                                                token *end_tok,
+                                                octave_comment_list *lc)
 {
   tree_classdef_events_block *retval = 0;
 
@@ -3027,11 +3012,11 @@
 }
 
 tree_classdef_enum_block *
-octave_parser::make_classdef_enum_block (token *tok_val,
-                                         tree_classdef_attribute_list *a,
-                                         tree_classdef_enum_list *elist,
-                                         token *end_tok,
-                                         octave_comment_list *lc)
+octave_base_parser::make_classdef_enum_block (token *tok_val,
+                                              tree_classdef_attribute_list *a,
+                                              tree_classdef_enum_list *elist,
+                                              token *end_tok,
+                                              octave_comment_list *lc)
 {
   tree_classdef_enum_block *retval = 0;
 
@@ -3051,8 +3036,9 @@
 // Make an index expression.
 
 tree_index_expression *
-octave_parser::make_index_expression (tree_expression *expr,
-                                      tree_argument_list *args, char type)
+octave_base_parser::make_index_expression (tree_expression *expr,
+                                           tree_argument_list *args,
+                                           char type)
 {
   tree_index_expression *retval = 0;
 
@@ -3085,8 +3071,8 @@
 // Make an indirect reference expression.
 
 tree_index_expression *
-octave_parser::make_indirect_ref (tree_expression *expr,
-                                  const std::string& elt)
+octave_base_parser::make_indirect_ref (tree_expression *expr,
+                                       const std::string& elt)
 {
   tree_index_expression *retval = 0;
 
@@ -3107,7 +3093,7 @@
   else
     retval = new tree_index_expression (expr, elt, l, c);
 
-  curr_lexer->looking_at_indirect_ref = false;
+  lexer.looking_at_indirect_ref = false;
 
   return retval;
 }
@@ -3115,7 +3101,8 @@
 // Make an indirect reference expression with dynamic field name.
 
 tree_index_expression *
-octave_parser::make_indirect_ref (tree_expression *expr, tree_expression *elt)
+octave_base_parser::make_indirect_ref (tree_expression *expr,
+                                       tree_expression *elt)
 {
   tree_index_expression *retval = 0;
 
@@ -3136,7 +3123,7 @@
   else
     retval = new tree_index_expression (expr, elt, l, c);
 
-  curr_lexer->looking_at_indirect_ref = false;
+  lexer.looking_at_indirect_ref = false;
 
   return retval;
 }
@@ -3144,8 +3131,8 @@
 // Make a declaration command.
 
 tree_decl_command *
-octave_parser::make_decl_command (int tok, token *tok_val,
-                                  tree_decl_init_list *lst)
+octave_base_parser::make_decl_command (int tok, token *tok_val,
+                                       tree_decl_init_list *lst)
 {
   tree_decl_command *retval = 0;
 
@@ -3163,9 +3150,9 @@
         retval = new tree_persistent_command (lst, l, c);
       else
         {
-          if (curr_lexer->reading_script_file)
+          if (lexer.reading_script_file)
             warning ("ignoring persistent declaration near line %d of file '%s'",
-                     l, curr_lexer->fcn_file_full_name.c_str ());
+                     l, lexer.fcn_file_full_name.c_str ());
           else
             warning ("ignoring persistent declaration near line %d", l);
         }
@@ -3180,7 +3167,7 @@
 }
 
 bool
-octave_parser::validate_array_list (tree_expression *e)
+octave_base_parser::validate_array_list (tree_expression *e)
 {
   bool retval = true;
 
@@ -3205,7 +3192,7 @@
 }
 
 tree_argument_list *
-octave_parser::validate_matrix_for_assignment (tree_expression *e)
+octave_base_parser::validate_matrix_for_assignment (tree_expression *e)
 {
   tree_argument_list *retval = 0;
 
@@ -3259,7 +3246,7 @@
 // Finish building an array_list.
 
 tree_expression *
-octave_parser::finish_array_list (tree_array_list *array_list)
+octave_base_parser::finish_array_list (tree_array_list *array_list)
 {
   tree_expression *retval = array_list;
 
@@ -3304,7 +3291,7 @@
 // Finish building a matrix list.
 
 tree_expression *
-octave_parser::finish_matrix (tree_matrix *m)
+octave_base_parser::finish_matrix (tree_matrix *m)
 {
   return finish_array_list (m);
 }
@@ -3312,13 +3299,13 @@
 // Finish building a cell list.
 
 tree_expression *
-octave_parser::finish_cell (tree_cell *c)
+octave_base_parser::finish_cell (tree_cell *c)
 {
   return finish_array_list (c);
 }
 
 void
-octave_parser::maybe_warn_missing_semi (tree_statement_list *t)
+octave_base_parser::maybe_warn_missing_semi (tree_statement_list *t)
 {
   if (curr_fcn_depth > 0)
     {
@@ -3328,13 +3315,13 @@
         warning_with_id
           ("Octave:missing-semicolon",
            "missing semicolon near line %d, column %d in file '%s'",
-            tmp->line (), tmp->column (), curr_lexer->fcn_file_full_name.c_str ());
+            tmp->line (), tmp->column (), lexer.fcn_file_full_name.c_str ());
     }
 }
 
 tree_statement_list *
-octave_parser::set_stmt_print_flag (tree_statement_list *list, char sep,
-                                    bool warn_missing_semi)
+octave_base_parser::set_stmt_print_flag (tree_statement_list *list,
+                                         char sep, bool warn_missing_semi)
 {
   tree_statement *tmp = list->back ();
 
@@ -3370,15 +3357,15 @@
 }
 
 tree_statement_list *
-octave_parser::make_statement_list (tree_statement *stmt)
+octave_base_parser::make_statement_list (tree_statement *stmt)
 {
   return new tree_statement_list (stmt);
 }
 
 tree_statement_list *
-octave_parser::append_statement_list (tree_statement_list *list, char sep,
-                                      tree_statement *stmt,
-                                      bool warn_missing_semi)
+octave_base_parser::append_statement_list (tree_statement_list *list,
+                                           char sep, tree_statement *stmt,
+                                           bool warn_missing_semi)
 {
   set_stmt_print_flag (list, sep, warn_missing_semi);
 
@@ -3388,16 +3375,15 @@
 }
 
 void
-octave_parser::bison_error (const char *s)
-
+octave_base_parser::bison_error (const char *s)
 {
-  int err_col = curr_lexer->current_input_column - 1;
+  int err_col = lexer.current_input_column - 1;
 
   std::ostringstream output_buf;
 
-  if (curr_lexer->reading_fcn_file || curr_lexer->reading_script_file || curr_lexer->reading_classdef_file)
-    output_buf << "parse error near line " << curr_lexer->input_line_number
-               << " of file " << curr_lexer->fcn_file_full_name;
+  if (lexer.reading_fcn_file || lexer.reading_script_file || lexer.reading_classdef_file)
+    output_buf << "parse error near line " << lexer.input_line_number
+               << " of file " << lexer.fcn_file_full_name;
   else
     output_buf << "parse error:";
 
@@ -3406,7 +3392,7 @@
 
   output_buf << "\n\n";
 
-  std::string curr_line = curr_lexer->current_input_line;
+  std::string curr_line = lexer.current_input_line;
 
   if (! curr_line.empty ())
     {
@@ -3435,6 +3421,12 @@
   parse_error ("%s", msg.c_str ());
 }
 
+int
+octave_parser::run (void)
+{
+  return octave_parse (*this);
+}
+
 static void
 safe_fclose (FILE *f)
 {
@@ -3481,30 +3473,30 @@
 
   if (ffile)
     {
-      // octave_parser constructor sets this for us.
-      frame.protect_var (CURR_LEXER);
-
-      octave_parser curr_parser (ffile);
-
-      curr_parser.curr_class_name = dispatch_type;
-      curr_parser.autoloading = autoload;
-      curr_parser.fcn_file_from_relative_lookup = relative_lookup;
-
-      curr_parser.curr_lexer->force_script = force_script;
-      curr_parser.curr_lexer->prep_for_file ();
-      curr_parser.curr_lexer->parsing_class_method = ! dispatch_type.empty ();
-
-      curr_parser.curr_lexer->fcn_file_name = file;
-      curr_parser.curr_lexer->fcn_file_full_name = full_file;
-
-      int status = curr_parser.run ();
-
-      fcn_ptr = curr_parser.primary_fcn_ptr;
+      // octave_base_parser constructor sets this for us.
+      frame.protect_var (LEXER);
+
+      octave_parser parser (ffile);
+
+      parser.curr_class_name = dispatch_type;
+      parser.autoloading = autoload;
+      parser.fcn_file_from_relative_lookup = relative_lookup;
+
+      parser.lexer.force_script = force_script;
+      parser.lexer.prep_for_file ();
+      parser.lexer.parsing_class_method = ! dispatch_type.empty ();
+
+      parser.lexer.fcn_file_name = file;
+      parser.lexer.fcn_file_full_name = full_file;
+
+      int status = parser.run ();
+
+      fcn_ptr = parser.primary_fcn_ptr;
 
       if (status == 0)
         {
-          if (curr_parser.curr_lexer->reading_classdef_file
-              && curr_parser.classdef_object)
+          if (parser.lexer.reading_classdef_file
+              && parser.classdef_object)
             {
               // Convert parse tree for classdef object to
               // meta.class info (and stash it in the symbol
@@ -3513,7 +3505,7 @@
               if (fcn_ptr)
                 panic_impossible ();
 
-              fcn_ptr = curr_parser.classdef_object->make_meta_class ();
+              fcn_ptr = parser.classdef_object->make_meta_class ();
             }
         }
       else
@@ -4192,28 +4184,28 @@
 
   unwind_protect frame;
 
-  // octave_parser constructor sets this for us.
-  frame.protect_var (CURR_LEXER);
-
-  octave_parser curr_parser (eval_str);
+  // octave_base_parser constructor sets this for us.
+  frame.protect_var (LEXER);
+
+  octave_parser parser (eval_str);
 
   do
     {
-      curr_parser.reset ();
-
-      parse_status = curr_parser.run ();
+      parser.reset ();
+
+      parse_status = parser.run ();
 
       // Unmark forced variables.
       frame.run (1);
 
       if (parse_status == 0)
         {
-          if (curr_parser.stmt_list)
+          if (parser.stmt_list)
             {
               tree_statement *stmt = 0;
 
-              if (curr_parser.stmt_list->length () == 1
-                  && (stmt = curr_parser.stmt_list->front ())
+              if (parser.stmt_list->length () == 1
+                  && (stmt = parser.stmt_list->front ())
                   && stmt->is_expression ())
                 {
                   tree_expression *expr = stmt->expression ();
@@ -4242,7 +4234,7 @@
                     retval = octave_value_list ();
                 }
               else if (nargout == 0)
-                curr_parser.stmt_list->accept (*current_evaluator);
+                parser.stmt_list->accept (*current_evaluator);
               else
                 error ("eval: invalid use of statement list");
 
@@ -4252,7 +4244,7 @@
                   || tree_continue_command::continuing)
                 break;
             }
-          else if (curr_parser.curr_lexer->end_of_input)
+          else if (parser.lexer.end_of_input)
             break;
         }
     }
--- a/libinterp/parse-tree/parse.h	Mon Mar 11 18:24:50 2013 -0400
+++ b/libinterp/parse-tree/parse.h	Tue Mar 12 00:46:47 2013 -0400
@@ -136,57 +136,31 @@
 
 // Global access to currently active lexer.
 // FIXME -- to be removed after more parser+lexer refactoring.
-extern octave_lexer *CURR_LEXER;
+extern octave_lexer *LEXER;
 
 class
-octave_parser
+octave_base_parser
 {
 public:
 
-  octave_parser (void)
+  octave_base_parser (octave_lexer& lxr)
     : endfunction_found (false),
       autoloading (false), fcn_file_from_relative_lookup (false),
       parsing_subfunctions (false), max_fcn_depth (0),
       curr_fcn_depth (0), primary_fcn_scope (-1),
       curr_class_name (), function_scopes (), primary_fcn_ptr (0),
       classdef_object (0), stmt_list (0),
-      curr_lexer (new octave_lexer ()), parser_state (0)
-  {
-    init ();
-  }
-
-  octave_parser (FILE *file)
-    : endfunction_found (false),
-      autoloading (false), fcn_file_from_relative_lookup (false),
-      parsing_subfunctions (false), max_fcn_depth (0),
-      curr_fcn_depth (0), primary_fcn_scope (-1),
-      curr_class_name (), function_scopes (), primary_fcn_ptr (0),
-      stmt_list (0),
-      curr_lexer (new octave_lexer (file)), parser_state (0)
+      lexer (lxr), parser_state (0)
   {
     init ();
   }
 
-  octave_parser (const std::string& eval_string)
-    : endfunction_found (false),
-      autoloading (false), fcn_file_from_relative_lookup (false),
-      parsing_subfunctions (false), max_fcn_depth (0),
-      curr_fcn_depth (0), primary_fcn_scope (-1),
-      curr_class_name (), function_scopes (), primary_fcn_ptr (0),
-      stmt_list (0),
-      curr_lexer (new octave_lexer (eval_string)), parser_state (0)
-  {
-    init ();
-  }
-
-  ~octave_parser (void);
+  virtual ~octave_base_parser (void);
 
   void init (void);
 
   void reset (void);
 
-  int run (void);
-
   // Error mesages for mismatched end tokens.
   void end_error (const char *type, token::end_tok_type ettype, int l, int c);
 
@@ -464,14 +438,41 @@
   tree_statement_list *stmt_list;
 
   // State of the lexer.
-  octave_lexer *curr_lexer;
+  octave_lexer& lexer;
 
   // Internal state of the parser.  Only used if USE_PUSH_PARSER is
   // defined.
   void *parser_state;
 
-  // For unwind protect.
-  static void cleanup (octave_parser *parser) { delete parser; }
+private:
+
+  // No copying!
+
+  octave_base_parser (const octave_base_parser&);
+
+  octave_base_parser& operator = (const octave_base_parser&);
+};
+
+class
+octave_parser : public octave_base_parser
+{
+public:
+
+  octave_parser (void)
+    : octave_base_parser (*(new octave_lexer ()))
+  { }
+
+  octave_parser (FILE *file)
+    : octave_base_parser (*(new octave_lexer (file)))
+  { }
+
+  octave_parser (const std::string& eval_string)
+    : octave_base_parser (*(new octave_lexer (eval_string)))
+  { }
+
+  ~octave_parser (void) { }
+
+  int run (void);
 
 private: