Mercurial > hg > octave-nkf
diff libinterp/octave.cc @ 16203:127cccb037bf
move more global parser and lexer variables to classes
* pt-check.h, pt-check.cc (tree_checker::file_name): New data member.
(tree_checker::gripe): Use it instead of curr_fcn_file_name.
* input.h, input.cc, octave.cc (input_from_command_line_file):
Delete global variable and all uses.
* parse.h, oct-parse.in.yy (input_from_startup_file): Delete global
variable and all uses.
* input.h, input.cc, lex.h, lex.ll (curr_fcn_file_name,
curr_fcn_file_full_name): Declare as members of lexical_feedback
class. Rename to fcn_file_name and fcn_file_full_name. Change all
uses.
* oct-parse.in.yy (parse_fcn_file): New arg, file. Set
curr_lexer->fcn_file_name and curr_lexer->fcn_file_full_name here.
(load_fcn_from_file): Pass short file name to parse_fcn_file.
* octave.cc (execute_command_line_file): Not here.
* lex.h, lex.ll (lexical_feedback::force_script): New data member.
* oct-parse.in.yy (parse_fcn_file): Set it here.
* lex.h, lex.ll (lexical_feedback::input_from_terminal,
lexical_feedback::input_from_file): New functions.
* lex.ll (octave_lexer::handle_keyword): Set reading_fcn_file,
reading_classdef_file, and reading_script_file.
* lex.h, lex.ll (lexical_feedback::token_count): New variable.
(COUNT_TOK_AND_RETURN): Increment it here. Don't count '\n' as a
token.
* lex.h, lex.ll (lexical_feedback::help_text):
New variable.
* parse.h, parse.in.yy (help_buf): Delete global variable and all uses.
(octave_parser::frob_function, octave_parser::make_script): Use help_text.
* lex.ll (octave_lexer::process_comment): Cache doc string directly in
help_text variable.
(looks_like_copyright): Move here from parse.in.yy.
* lex.h, lex.ll (octave_lexer::prep_for_file): New function.
(octave_lexer::prep_for_function_file,
octave_lexer::prep_for_script_file): Delete.
* parse.in.yy (INPUT_FILE_BEGIN): New start state. Delete
SCRIPT_FILE_BEGIN and FCN_FILE_BEGIN. Tentatively set
curr_lexer->reading_script_file to true.
(parse_fcn_file): Call curr_lexer->prep_for_file.
Don't call gobble_leading_whitespace. Don't attempt to determine
function script, or classdef file status here.
* parse.in.yy (INPUT_FILE): New token.
(SCRIPT_FILE, FUNCTION_FILE): Delete.
* lex.ll (octave_lexer::display_token): Update.
* parse.in.yy (nl, opt_nl): New non-terminals.
(function_file): Delete rule.
(file): Rename from script_file. Allow opt_nl before opt_list.
Don't make script if reading fcn file.
* parse.in.yy (text_getc, class stdio_stream_reader, skip_white_space,
looking_at_classdef_keyword, gobble_leading_white_space,
looking_at_function_keyword): Delete.
(get_help_from_file): Parse file to get help instead of calling
gobble_leading_white_space
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 06 Mar 2013 14:36:19 -0500 |
parents | 810a71122c25 |
children | a8f9eb92fa6e ed91ab4d4515 |
line wrap: on
line diff
--- a/libinterp/octave.cc +++ b/libinterp/octave.cc @@ -355,10 +355,6 @@ { unwind_protect frame; - frame.protect_var (input_from_startup_file); - - input_from_startup_file = true; - std::string context; bool verbose = (verbose_flag && ! inhibit_startup_message); @@ -488,28 +484,18 @@ octave_initialized = true; frame.protect_var (interactive); - frame.protect_var (input_from_command_line_file); - - frame.protect_var (curr_fcn_file_name); - frame.protect_var (curr_fcn_file_full_name); frame.protect_var (octave_program_invocation_name); frame.protect_var (octave_program_name); interactive = false; - input_from_command_line_file = true; - curr_fcn_file_name = fname; - curr_fcn_file_full_name = curr_fcn_file_name; - - octave_program_invocation_name = curr_fcn_file_name; + octave_program_invocation_name = fname; - size_t pos = curr_fcn_file_name.find_last_of (file_ops::dir_sep_chars ()); + size_t pos = fname.find_last_of (file_ops::dir_sep_chars ()); - std::string tmp = (pos != std::string::npos) - ? curr_fcn_file_name.substr (pos+1) : curr_fcn_file_name; - - octave_program_name = tmp; + octave_program_name + = (pos != std::string::npos) ? fname.substr (pos+1) : fname; std::string context; bool verbose = false;