# HG changeset patch # User John W. Eaton # Date 1361999159 18000 # Node ID edddf8903f15f47c2ea37810d9a974e80bd87af7 # Parent 8f1f8a5cdc9695dcef8b994632e40ee86925ea01 maint: reorder functions in oct-parse.yy diff -r 8f1f8a5cdc96 -r edddf8903f15 libinterp/parse-tree/oct-parse.yy --- a/libinterp/parse-tree/oct-parse.yy Wed Feb 27 15:58:06 2013 -0500 +++ b/libinterp/parse-tree/oct-parse.yy Wed Feb 27 16:05:59 2013 -0500 @@ -1499,51 +1499,6 @@ curr_parser->bison_error (s); } -void -octave_parser::bison_error (const char *s) -{ - int err_col = curr_lexer->current_input_column - 1; - - std::ostringstream output_buf; - - if (reading_fcn_file || reading_script_file || reading_classdef_file) - output_buf << "parse error near line " << curr_lexer->input_line_number - << " of file " << curr_fcn_file_full_name; - else - output_buf << "parse error:"; - - if (s && strcmp (s, "parse error") != 0) - output_buf << "\n\n " << s; - - output_buf << "\n\n"; - - if (! current_input_line.empty ()) - { - size_t len = current_input_line.length (); - - if (current_input_line[len-1] == '\n') - current_input_line.resize (len-1); - - // Print the line, maybe with a pointer near the error token. - - output_buf << ">>> " << current_input_line << "\n"; - - if (err_col == 0) - err_col = len; - - for (int i = 0; i < err_col + 3; i++) - output_buf << " "; - - output_buf << "^"; - } - - output_buf << "\n"; - - std::string msg = output_buf.str (); - - parse_error ("%s", msg.c_str ()); -} - int octave_parser::run (void) { @@ -3105,6 +3060,51 @@ return list; } +void +octave_parser::bison_error (const char *s) +{ + int err_col = curr_lexer->current_input_column - 1; + + std::ostringstream output_buf; + + if (reading_fcn_file || reading_script_file || reading_classdef_file) + output_buf << "parse error near line " << curr_lexer->input_line_number + << " of file " << curr_fcn_file_full_name; + else + output_buf << "parse error:"; + + if (s && strcmp (s, "parse error") != 0) + output_buf << "\n\n " << s; + + output_buf << "\n\n"; + + if (! current_input_line.empty ()) + { + size_t len = current_input_line.length (); + + if (current_input_line[len-1] == '\n') + current_input_line.resize (len-1); + + // Print the line, maybe with a pointer near the error token. + + output_buf << ">>> " << current_input_line << "\n"; + + if (err_col == 0) + err_col = len; + + for (int i = 0; i < err_col + 3; i++) + output_buf << " "; + + output_buf << "^"; + } + + output_buf << "\n"; + + std::string msg = output_buf.str (); + + parse_error ("%s", msg.c_str ()); +} + static void safe_fclose (FILE *f) {