Mercurial > octave-nkf
diff libinterp/parse-tree/oct-parse.in.yy @ 16199:810a71122c25
move more global variables to octave_lexical_feedback class
* help.cc (raw_help_from_file): Don't protect and set
reading_script_file.
* octave.cc (likewise):
* oct_parse.in.yy (parse_fcn_file): Don't protect
reading_script_file.
* input.cc (get_debug_input): Don't protect and set reading_fcn_file,
reading_classdef_file, or reading_script_file.
* lex.h, lex.ll, input.h, input.cc (reading_fcn_file,
reading_classdef_file, reading_script_file): Declare as members of the
lexical_feedback class. Change all uses.
(lexical_feedback::lexical_feedback, lexical_feedback::reset):
Initialize and set them.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 05 Mar 2013 17:50:37 -0500 |
parents | 2c5c538be353 |
children | 127cccb037bf |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy Tue Mar 05 17:43:00 2013 -0500 +++ b/libinterp/parse-tree/oct-parse.in.yy Tue Mar 05 17:50:37 2013 -0500 @@ -1013,11 +1013,11 @@ curr_parser.function_scopes.push_back (symbol_table::current_scope ()); - if (! reading_script_file && curr_parser.curr_fcn_depth == 1 + 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 (reading_script_file && curr_parser.curr_fcn_depth > 1) + if (curr_lexer->reading_script_file && curr_parser.curr_fcn_depth > 1) curr_parser.bison_error ("nested functions not implemented in this context"); } ; @@ -1154,7 +1154,7 @@ { $$ = $3; - if (reading_classdef_file || curr_lexer->parsing_classdef) + if (curr_lexer->reading_classdef_file || curr_lexer->parsing_classdef) curr_lexer->maybe_classdef_get_set_method = true; } ; @@ -1222,7 +1222,7 @@ | END_OF_INPUT { // A lot of tests are based on the assumption that this is OK -// if (reading_script_file) +// if (curr_lexer->reading_script_file) // { // curr_parser.bison_error ("function body open at end of script"); // YYABORT; @@ -1236,14 +1236,14 @@ YYABORT; } - if (! (reading_fcn_file || reading_script_file + if (! (curr_lexer->reading_fcn_file || curr_lexer->reading_script_file || (curr_lexer)->input_from_eval_string ())) { curr_parser.bison_error ("function body open at end of input"); YYABORT; } - if (reading_classdef_file) + if (curr_lexer->reading_classdef_file) { curr_parser.bison_error ("classdef body open at end of input"); YYABORT; @@ -2654,7 +2654,7 @@ // 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 && reading_fcn_file + if (! autoloading && curr_lexer->reading_fcn_file && curr_fcn_depth == 1 && ! parsing_subfunctions) { // FIXME -- should curr_fcn_file_name already be @@ -2679,7 +2679,7 @@ } } - if (reading_fcn_file || reading_classdef_file || autoloading) + if (curr_lexer->reading_fcn_file || curr_lexer->reading_classdef_file || autoloading) { octave_time now; @@ -2719,7 +2719,7 @@ "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_lexer->reading_script_file && curr_fcn_file_name == id_name) { warning ("function '%s' defined within script file '%s'", @@ -2738,7 +2738,7 @@ help_buf.pop (); } - if (reading_fcn_file && curr_fcn_depth == 1 + if (curr_lexer->reading_fcn_file && curr_fcn_depth == 1 && ! parsing_subfunctions) primary_fcn_ptr = fcn; @@ -2791,7 +2791,7 @@ if (curr_fcn_depth == 1 && fcn) symbol_table::update_nest (fcn->scope ()); - if (! reading_fcn_file && curr_fcn_depth == 1) + if (! curr_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 @@ -2824,7 +2824,7 @@ parser_symtab_context.pop (); - if (reading_fcn_file && curr_fcn_depth == 1 + if (curr_lexer->reading_fcn_file && curr_fcn_depth == 1 && ! parsing_subfunctions) parsing_subfunctions = true; @@ -2945,7 +2945,7 @@ retval = new tree_persistent_command (lst, l, c); else { - if (reading_script_file) + if (curr_lexer->reading_script_file) warning ("ignoring persistent declaration near line %d of file '%s'", l, curr_fcn_file_full_name.c_str ()); else @@ -3098,7 +3098,7 @@ std::ostringstream output_buf; - if (reading_fcn_file || reading_script_file || reading_classdef_file) + 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_fcn_file_full_name; else @@ -3375,10 +3375,8 @@ frame.add_fcn (command_editor::set_input_stream, in_stream); - frame.protect_var (reading_fcn_file); frame.protect_var (line_editing); - reading_fcn_file = true; line_editing = false; frame.add_fcn (command_history::ignore_entries, @@ -3402,6 +3400,8 @@ octave_parser curr_parser (ffile); + curr_parser.curr_lexer->reading_fcn_file = true; + curr_parser.curr_class_name = dispatch_type; curr_parser.autoloading = autoload; curr_parser.fcn_file_from_relative_lookup = relative_lookup; @@ -3419,44 +3419,36 @@ { std::string file_type; - frame.protect_var (reading_fcn_file); - frame.protect_var (reading_script_file); - frame.protect_var (reading_classdef_file); frame.protect_var (Vecho_executing_commands); + Vecho_executing_commands = ECHO_OFF; + if (! force_script && looking_at_function_keyword (ffile)) { file_type = "function"; - - Vecho_executing_commands = ECHO_OFF; - - reading_classdef_file = false; - reading_fcn_file = true; - reading_script_file = false; - } - else if (! force_script && looking_at_classdef_keyword (ffile)) - { - file_type = "classdef"; - - Vecho_executing_commands = ECHO_OFF; - - reading_classdef_file = true; - reading_fcn_file = false; - // FIXME -- Should classdef files be handled as - // scripts or separately? Currently, without setting up - // for reading script files, parsing classdef files - // fails. - reading_script_file = true; } else { - file_type = "script"; - - Vecho_executing_commands = ECHO_OFF; - - reading_classdef_file = false; - reading_fcn_file = false; - reading_script_file = true; + curr_parser.curr_lexer->reading_fcn_file = false; + + if (! force_script && looking_at_classdef_keyword (ffile)) + { + file_type = "classdef"; + + curr_parser.curr_lexer->reading_classdef_file = true; + + // FIXME -- Should classdef files be handled as + // scripts or separately? Currently, without + // setting up for reading script files, parsing + // classdef files fails. + curr_parser.curr_lexer->reading_script_file = true; + } + else + { + file_type = "script"; + + curr_parser.curr_lexer->reading_script_file = true; + } } // Do this with an unwind-protect cleanup function so that @@ -3468,7 +3460,7 @@ if (! help_txt.empty ()) help_buf.push (help_txt); - if (reading_script_file) + if (curr_parser.curr_lexer->reading_script_file) curr_parser.curr_lexer->prep_for_script_file (); else curr_parser.curr_lexer->prep_for_function_file (); @@ -4192,14 +4184,8 @@ octave_parser curr_parser (eval_str); frame.protect_var (line_editing); - frame.protect_var (reading_fcn_file); - frame.protect_var (reading_script_file); - frame.protect_var (reading_classdef_file); line_editing = false; - reading_fcn_file = false; - reading_script_file = false; - reading_classdef_file = false; do {