Mercurial > octave
diff libinterp/corefcn/input.h @ 27527:73be3c628eac
refactor input_reader class and its use in lexer
* input.h, input.cc (base_reader::get_input, file_reader::get_input,
terminal_reader::get_input, eval_string_reader::get_input):
Accept prompt as argument. Change all uses.
(base_reader::octave_gets): Accept prompt as argument instead of
getting it from input_system. Change all uses.
* interpreter.cc (interpreter::main_loop): Get promptflag from parser,
prompt string from input_system, decode it here, and pass to the input
reader.
* lex.h, lex.ll (base_lexer::m_promptflag): New data member.
(base_lexer::reset): Also reset m_promptflag.
(base_lexer::increment_promptflag, base_lexer::decrement_promptflag,
base_lexer::promptflag): No longer virtual.
(lexer::increment_promptflag, lexer::decrement_promptflag,
lexer::promptflag): Delete.
(push_lexer::m_pflag): Delete.
(push_lexer::increment_promptflag, push_lexer::decrement_promptflag,
push_lexer::promptflag): Delete.
(push_lexer::reset): Delete.
(lexer::fill_flex_buffer): Get prompt string from input_system, decode
it here, and pass to the input reader.
* parse.h (base_parser::increment_promptflag,
base_parser::decrement_promptflag, base_parser::promptflag):
New convenience functions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 18 Oct 2019 09:08:06 -0400 |
parents | 1bc237447e56 |
children | e51284fc0a51 |
line wrap: on
line diff
--- a/libinterp/corefcn/input.h Fri Oct 18 07:41:02 2019 -0400 +++ b/libinterp/corefcn/input.h Fri Oct 18 09:08:06 2019 -0400 @@ -207,7 +207,7 @@ virtual ~base_reader (void) = default; - virtual std::string get_input (bool& eof) = 0; + virtual std::string get_input (const std::string& prompt, bool& eof) = 0; virtual std::string input_source (void) const { return s_in_src; } @@ -226,7 +226,7 @@ return retval; } - std::string octave_gets (bool& eof); + std::string octave_gets (const std::string& prompt, bool& eof); virtual bool input_from_terminal (void) const { return false; } @@ -271,9 +271,9 @@ int promptflag (int n) { return m_rep->promptflag (n); } - std::string get_input (bool& eof) + std::string get_input (const std::string& prompt, bool& eof) { - return m_rep->get_input (eof); + return m_rep->get_input (prompt, eof); } std::string input_source (void) const