|
From: | Rik |
Subject: | Re: Modifications to error handling for the command suggestion feature |
Date: | Sat, 19 May 2018 13:35:44 -0700 |
On 05/19/2018 11:46 AM, Nicholas
Jankowski wrote:
Providing a list of suggestions and then returning to the CLI is going to be easier then changing the parser--which has already gone down an error path--to accept new input, backup, and re-parse the new command. The latter can be done, but for the moment I would concentrate on just offering the user some suggestions. You did correctly find the code in pt-id.cc to modify. The complete routine is void tree_identifier::eval_undefined_error (void) { int l = line (); int c = column (); maybe_missing_function_hook (name ()); if (l == -1 && c == -1) error_with_id ("Octave:undefined-function", "'%s' undefined", name ().c_str ()); else error_with_id ("Octave:undefined-function", "'%s' undefined near line %d column %d", name ().c_str (), l, c); } What you want to do is print out an error message first, then call maybe_missing_function_hook, and then return to the prompt. You can't use error_with_id because it is based on exceptions and will return to the prompt as soon as it is done. However, you can print the warning to stderr, which is what the error() function is doing anyways. Try this void tree_identifier::eval_undefined_error (void) { int l = line (); int c = column (); if (l == -1 && c == -1) std::cerr << "'" << name () << "' undefined\n"; else std::cerr << "'" << name () << "' undefined near " << "line " << l << " column " << c << "\n"; maybe_missing_function_hook (name ()); error_with_id ("Octave:undefined-function", ""); }
I agree. At least in C++ you can check whether you are at the top-level scope, i.e., the command line. There is probably a way to do so within Octave, jwe might know of a particular variable to check. --Rik |
[Prev in Thread] | Current Thread | [Next in Thread] |