diff options
| author | Richard M. Stallman | 1997-02-10 09:47:12 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-02-10 09:47:12 +0000 |
| commit | 7bf5e9e404469594957082b47edbdcb696cead3a (patch) | |
| tree | 8cbd59900527b71a1c3868458d24605bfee9b6fc /src/syntax.c | |
| parent | 2d955a501c3c97999224aabf104c606ac8553013 (diff) | |
| download | emacs-7bf5e9e404469594957082b47edbdcb696cead3a.tar.gz emacs-7bf5e9e404469594957082b47edbdcb696cead3a.zip | |
(scan_lists): Signal errors using scan-error.
(syms_of_syntax): Set up Qscan_error.
Diffstat (limited to 'src/syntax.c')
| -rw-r--r-- | src/syntax.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/syntax.c b/src/syntax.c index 22339930b2b..1404bfab249 100644 --- a/src/syntax.c +++ b/src/syntax.c | |||
| @@ -26,7 +26,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 26 | #include "buffer.h" | 26 | #include "buffer.h" |
| 27 | #include "syntax.h" | 27 | #include "syntax.h" |
| 28 | 28 | ||
| 29 | Lisp_Object Qsyntax_table_p, Qsyntax_table; | 29 | Lisp_Object Qsyntax_table_p, Qsyntax_table, Qscan_error; |
| 30 | 30 | ||
| 31 | static void scan_sexps_forward (); | 31 | static void scan_sexps_forward (); |
| 32 | static int char_quoted (); | 32 | static int char_quoted (); |
| @@ -943,6 +943,7 @@ scan_lists (from, count, depth, sexpflag) | |||
| 943 | register enum syntaxcode code; | 943 | register enum syntaxcode code; |
| 944 | int min_depth = depth; /* Err out if depth gets less than this. */ | 944 | int min_depth = depth; /* Err out if depth gets less than this. */ |
| 945 | int comstyle = 0; /* style of comment encountered */ | 945 | int comstyle = 0; /* style of comment encountered */ |
| 946 | int last_good = from; | ||
| 946 | 947 | ||
| 947 | if (depth > 0) min_depth = 0; | 948 | if (depth > 0) min_depth = 0; |
| 948 | 949 | ||
| @@ -956,6 +957,8 @@ scan_lists (from, count, depth, sexpflag) | |||
| 956 | { | 957 | { |
| 957 | c = FETCH_CHAR (from); | 958 | c = FETCH_CHAR (from); |
| 958 | code = SYNTAX (c); | 959 | code = SYNTAX (c); |
| 960 | if (depth == min_depth) | ||
| 961 | last_good = from; | ||
| 959 | from++; | 962 | from++; |
| 960 | if (from < stop && SYNTAX_COMSTART_FIRST (c) | 963 | if (from < stop && SYNTAX_COMSTART_FIRST (c) |
| 961 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from)) | 964 | && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from)) |
| @@ -1053,7 +1056,10 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1053 | close1: | 1056 | close1: |
| 1054 | if (!--depth) goto done; | 1057 | if (!--depth) goto done; |
| 1055 | if (depth < min_depth) | 1058 | if (depth < min_depth) |
| 1056 | error ("Containing expression ends prematurely"); | 1059 | Fsignal (Qscan_error, |
| 1060 | Fcons (build_string ("Containing expression ends prematurely"), | ||
| 1061 | Fcons (make_number (last_good), | ||
| 1062 | Fcons (make_number (from), Qnil)))); | ||
| 1057 | break; | 1063 | break; |
| 1058 | 1064 | ||
| 1059 | case Sstring: | 1065 | case Sstring: |
| @@ -1097,6 +1103,8 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1097 | from--; | 1103 | from--; |
| 1098 | c = FETCH_CHAR (from); | 1104 | c = FETCH_CHAR (from); |
| 1099 | code = SYNTAX (c); | 1105 | code = SYNTAX (c); |
| 1106 | if (depth == min_depth) | ||
| 1107 | last_good = from; | ||
| 1100 | comstyle = 0; | 1108 | comstyle = 0; |
| 1101 | if (code == Sendcomment) | 1109 | if (code == Sendcomment) |
| 1102 | comstyle = SYNTAX_COMMENT_STYLE (c); | 1110 | comstyle = SYNTAX_COMMENT_STYLE (c); |
| @@ -1155,7 +1163,10 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1155 | open2: | 1163 | open2: |
| 1156 | if (!--depth) goto done2; | 1164 | if (!--depth) goto done2; |
| 1157 | if (depth < min_depth) | 1165 | if (depth < min_depth) |
| 1158 | error ("Containing expression ends prematurely"); | 1166 | Fsignal (Qscan_error, |
| 1167 | Fcons (build_string ("Containing expression ends prematurely"), | ||
| 1168 | Fcons (make_number (last_good), | ||
| 1169 | Fcons (make_number (from), Qnil)))); | ||
| 1159 | break; | 1170 | break; |
| 1160 | 1171 | ||
| 1161 | case Sendcomment: | 1172 | case Sendcomment: |
| @@ -1331,7 +1342,11 @@ scan_lists (from, count, depth, sexpflag) | |||
| 1331 | return val; | 1342 | return val; |
| 1332 | 1343 | ||
| 1333 | lose: | 1344 | lose: |
| 1334 | error ("Unbalanced parentheses"); | 1345 | Fsignal (Qscan_error, |
| 1346 | Fcons (build_string ("Unbalanced parentheses"), | ||
| 1347 | Fcons (make_number (last_good), | ||
| 1348 | Fcons (make_number (from), Qnil)))); | ||
| 1349 | |||
| 1335 | /* NOTREACHED */ | 1350 | /* NOTREACHED */ |
| 1336 | } | 1351 | } |
| 1337 | 1352 | ||
| @@ -1796,6 +1811,13 @@ syms_of_syntax () | |||
| 1796 | Qsyntax_table_p = intern ("syntax-table-p"); | 1811 | Qsyntax_table_p = intern ("syntax-table-p"); |
| 1797 | staticpro (&Qsyntax_table_p); | 1812 | staticpro (&Qsyntax_table_p); |
| 1798 | 1813 | ||
| 1814 | Qscan_error = intern ("scan-error"); | ||
| 1815 | staticpro (&Qscan_error); | ||
| 1816 | Fput (Qscan_error, Qerror_conditions, | ||
| 1817 | Fcons (Qerror, Qnil)); | ||
| 1818 | Fput (Qscan_error, Qerror_message, | ||
| 1819 | build_string ("Scan error")); | ||
| 1820 | |||
| 1799 | DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments, | 1821 | DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments, |
| 1800 | "Non-nil means `forward-sexp', etc., should treat comments as whitespace."); | 1822 | "Non-nil means `forward-sexp', etc., should treat comments as whitespace."); |
| 1801 | 1823 | ||