Mercurial > octave
diff libinterp/corefcn/input.cc @ 17731:f79bf671a493
eliminate global LEXER variable
* input.h, input.cc (octave_base_reader::lexer): New member variable.
(octave_base_reader::octave_base_reader): Initialize lexer.
(octave_base_reader::octave_base_reader (const octave_base_reader&)):
Also copy pflag and lexer.
(octave_base_reader::reading_fcn_file,
octave_base_reader::reading_classdef_file,
octave_base_reader::reading_script_file): New functions.
(octave_base_reader::do_input_echo): Call reading_script file instead
of using global LEXER variable.
(get_user_input): Don't user global LEXER variable. Only check
interactive and forced_interactive to decide whether to temporarily
set forced_interactive to true.
(octave_terminal_reader::octave_terminal_reader,
octave_file_reader::octave_file_reader,
octave_eval_string_reader::octave_eval_string_reader,
octave_input_reader::octave_input_reader):
New optional arg, lexer.
* toplev.cc (main_loop): Don't user global LEXER variable. Eliminate
unused unwind_protect frame.
* lex.h, lex.ll (octave_base_lexer::cleanup): Delete unused function.
(octave_lexer::octave_lexer): Pass this to input_reader initializer.
* parse.h, oct-parse.in.yy (octave_base_parser::init):
Delete unneded function.
(octave_base_parser::octave_base_parser, octave_push_parser::init, octave_push_parser::octave_push_parser):
Don't call octave_base_parser::init.
(eval_string): Don't use global LEXER variable. Eliminate unused
unwind_protect frame.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 22 Oct 2013 18:43:36 -0400 |
parents | aa662d2e5829 |
children | d63878346099 |
line wrap: on
line diff
--- a/libinterp/corefcn/input.cc Tue Oct 22 14:32:21 2013 -0700 +++ b/libinterp/corefcn/input.cc Tue Oct 22 18:43:36 2013 -0400 @@ -147,7 +147,7 @@ void octave_base_reader::do_input_echo (const std::string& input_string) const { - int do_echo = (LEXER && LEXER->reading_script_file) ? + int do_echo = reading_script_file () ? (Vecho_executing_commands & ECHO_SCRIPTS) : (Vecho_executing_commands & ECHO_CMD_LINE) && ! forced_interactive; @@ -295,6 +295,24 @@ return retval; } +bool +octave_base_reader::reading_fcn_file (void) const +{ + return lexer ? lexer->reading_fcn_file : false; +} + +bool +octave_base_reader::reading_classdef_file (void) const +{ + return lexer ? lexer->reading_classdef_file : false; +} + +bool +octave_base_reader::reading_script_file (void) const +{ + return lexer ? lexer->reading_script_file : false; +} + // Fix things up so that input can come from the standard input. This // may need to become much more complicated, which is why it's in a // separate function. @@ -553,19 +571,12 @@ frame.protect_var (VPS1); VPS1 = prompt; - if (! (interactive || forced_interactive) - || (LEXER && (LEXER->reading_fcn_file - || LEXER->reading_classdef_file - || LEXER->reading_script_file - || LEXER->input_from_eval_string ()))) + if (! (interactive || forced_interactive)) { frame.protect_var (forced_interactive); forced_interactive = true; } - // octave_parser constructor sets this for us. - frame.protect_var (LEXER); - octave_parser curr_parser; while (Vdebugging)