#include "buffer.h"
#include "syntax.h"
-Lisp_Object Qsyntax_table_p, Qsyntax_table;
+Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error;
static void scan_sexps_forward ();
static int char_quoted ();
register enum syntaxcode code;
int min_depth = depth; /* Err out if depth gets less than this. */
int comstyle = 0; /* style of comment encountered */
+ int last_good = from;
if (depth > 0) min_depth = 0;
{
c = FETCH_CHAR (from);
code = SYNTAX (c);
+ if (depth == min_depth)
+ last_good = from;
from++;
if (from < stop && SYNTAX_COMSTART_FIRST (c)
&& SYNTAX_COMSTART_SECOND (FETCH_CHAR (from))
close1:
if (!--depth) goto done;
if (depth < min_depth)
- error ("Containing expression ends prematurely");
+ Fsignal (Qscan_error,
+ Fcons (build_string ("Containing expression ends prematurely"),
+ Fcons (make_number (last_good),
+ Fcons (make_number (from), Qnil))));
break;
case Sstring:
from--;
c = FETCH_CHAR (from);
code = SYNTAX (c);
+ if (depth == min_depth)
+ last_good = from;
comstyle = 0;
if (code == Sendcomment)
comstyle = SYNTAX_COMMENT_STYLE (c);
open2:
if (!--depth) goto done2;
if (depth < min_depth)
- error ("Containing expression ends prematurely");
+ Fsignal (Qscan_error,
+ Fcons (build_string ("Containing expression ends prematurely"),
+ Fcons (make_number (last_good),
+ Fcons (make_number (from), Qnil))));
break;
case Sendcomment:
return val;
lose:
- error ("Unbalanced parentheses");
+ Fsignal (Qscan_error,
+ Fcons (build_string ("Unbalanced parentheses"),
+ Fcons (make_number (last_good),
+ Fcons (make_number (from), Qnil))));
+
/* NOTREACHED */
}
Qsyntax_table_p = intern ("syntax-table-p");
staticpro (&Qsyntax_table_p);
+ Qscan_error = intern ("scan-error");
+ staticpro (&Qscan_error);
+ Fput (Qscan_error, Qerror_conditions,
+ Fcons (Qerror, Qnil));
+ Fput (Qscan_error, Qerror_message,
+ build_string ("Scan error"));
+
DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments,
"Non-nil means `forward-sexp', etc., should treat comments as whitespace.");