Skip to content

Commit

Permalink
Add new error ID "Octave:parse-error" (bug #45967).
Browse files Browse the repository at this point in the history
* error_ids.m: Document new Octave:parse-error ID.

* oct-parse.yy (base_parser::bison_error): Delete error stack information
from error message.
* oct-parse.yy (parser::run, push_parser::run): Call parse_error_with_id()
and supply argument "Octave:parse-error" for ID.

* classdef.tst: Update BIST test to look for new error message format.
  • Loading branch information
Rik committed Jan 18, 2024
1 parent eebbfe1 commit 7a5bad2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 3 additions & 6 deletions libinterp/parse-tree/oct-parse.yy
Original file line number Diff line number Diff line change
Expand Up @@ -5525,10 +5525,7 @@ OCTAVE_BEGIN_NAMESPACE(octave)
if (in_file)
{
output_buf << str
<< " near line " << err_line << ", column " << err_col << "\n"
<< "error: called from\n"
<< " " << m_lexer.m_fcn_file_name
<< " at line " << err_line << " column " << err_col << "\n";
<< " near line " << err_line << ", column " << err_col << "\n";
}
else
{
Expand Down Expand Up @@ -5620,7 +5617,7 @@ OCTAVE_BEGIN_NAMESPACE(octave)
}

if (status != 0)
parse_error ("%s", m_parse_error_msg.c_str ());
parse_error_with_id ("Octave:parse-error", "%s", m_parse_error_msg.c_str ());

return status;
}
Expand Down Expand Up @@ -5692,7 +5689,7 @@ OCTAVE_BEGIN_NAMESPACE(octave)
while (status == YYPUSH_MORE || ! m_lexer.at_end_of_buffer ());

if (status != 0)
parse_error ("%s", m_parse_error_msg.c_str ());
parse_error_with_id ("Octave:parse-error", "%s", m_parse_error_msg.c_str ());

return status;
}
Expand Down
3 changes: 3 additions & 0 deletions scripts/help/error_ids.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
## @item Octave:invalid-input-arg
## Indicates that a function was called with invalid input arguments.
##
## @item Octave:parse-error
## The interpreter failed to parse (read) specified code.
##
## @item Octave:undefined-function
## Indicates a call to a function that is not defined. The function may exist
## but Octave is unable to find it in the search path.
Expand Down
2 changes: 1 addition & 1 deletion test/classdef/classdef.tst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
%! obj = obj.move_element_to_end (2);
%! assert (isequal (obj.element, [1 3 2]));

%!error <parse error> plist_t1
%!error <syntax error> plist_t1
%!assert (strcmp (class (plist_t2), 'plist_t2'))
%!assert (strcmp (class (plist_t3), 'plist_t3'))

Expand Down

0 comments on commit 7a5bad2

Please sign in to comment.