comparison src/syntax.c @ 5125:b5df3737028a ben-lisp-object

merge
author Ben Wing <ben@xemacs.org>
date Wed, 24 Feb 2010 01:58:04 -0600
parents d1247f3cc363 ae48681c47fa
children 2a462149bd6a
comparison
equal deleted inserted replaced
5124:623d57b7fbe8 5125:b5df3737028a
66 66
67 Lisp_Object Vtemp_table_for_use_updating_syntax_tables; 67 Lisp_Object Vtemp_table_for_use_updating_syntax_tables;
68 68
69 /* A value that is guaranteed not be in a syntax table. */ 69 /* A value that is guaranteed not be in a syntax table. */
70 Lisp_Object Vbogus_syntax_table_value; 70 Lisp_Object Vbogus_syntax_table_value;
71
72 Lisp_Object Qscan_error;
71 73
72 static void syntax_cache_table_was_changed (struct buffer *buf); 74 static void syntax_cache_table_was_changed (struct buffer *buf);
73 75
74 /* This is the internal form of the parse state used in parse-partial-sexp. */ 76 /* This is the internal form of the parse state used in parse-partial-sexp. */
75 77
544 546
545 void 547 void
546 uninit_buffer_syntax_cache (struct buffer *UNUSED_IF_NEW_GC (buf)) 548 uninit_buffer_syntax_cache (struct buffer *UNUSED_IF_NEW_GC (buf))
547 { 549 {
548 #ifndef NEW_GC 550 #ifndef NEW_GC
549 xfree (buf->syntax_cache, struct syntax_cache *); 551 xfree (buf->syntax_cache);
550 buf->syntax_cache = 0; 552 buf->syntax_cache = 0;
551 #endif /* not NEW_GC */ 553 #endif /* not NEW_GC */
552 } 554 }
553 555
554 /* extent-specific APIs used in extents.c and insdel.c */ 556 /* extent-specific APIs used in extents.c and insdel.c */
1348 int mathexit = 0; 1350 int mathexit = 0;
1349 enum syntaxcode code; 1351 enum syntaxcode code;
1350 int syncode; 1352 int syncode;
1351 int min_depth = depth; /* Err out if depth gets less than this. */ 1353 int min_depth = depth; /* Err out if depth gets less than this. */
1352 struct syntax_cache *scache; 1354 struct syntax_cache *scache;
1355 Charbpos last_good = from;
1353 1356
1354 if (depth > 0) min_depth = 0; 1357 if (depth > 0) min_depth = 0;
1355 1358
1356 scache = setup_buffer_syntax_cache (buf, from, count); 1359 scache = setup_buffer_syntax_cache (buf, from, count);
1357 while (count > 0) 1360 while (count > 0)
1365 1368
1366 UPDATE_SYNTAX_CACHE_FORWARD (scache, from); 1369 UPDATE_SYNTAX_CACHE_FORWARD (scache, from);
1367 c = BUF_FETCH_CHAR (buf, from); 1370 c = BUF_FETCH_CHAR (buf, from);
1368 syncode = SYNTAX_CODE_FROM_CACHE (scache, c); 1371 syncode = SYNTAX_CODE_FROM_CACHE (scache, c);
1369 code = SYNTAX_FROM_CODE (syncode); 1372 code = SYNTAX_FROM_CODE (syncode);
1373 if (depth == min_depth)
1374 last_good = from;
1370 from++; 1375 from++;
1371 1376
1372 /* a 1-char comment start sequence */ 1377 /* a 1-char comment start sequence */
1373 if (code == Scomment && parse_sexp_ignore_comments) 1378 if (code == Scomment && parse_sexp_ignore_comments)
1374 { 1379 {
1478 if (!--depth) goto done; 1483 if (!--depth) goto done;
1479 if (depth < min_depth) 1484 if (depth < min_depth)
1480 { 1485 {
1481 if (noerror) 1486 if (noerror)
1482 return Qnil; 1487 return Qnil;
1483 syntax_error ("Containing expression ends prematurely", 1488 signal_error_2 (Qscan_error,
1484 Qunbound); 1489 "Containing expression ends prematurely",
1490 make_int (last_good), make_int (from));
1485 } 1491 }
1486 break; 1492 break;
1487 1493
1488 case Sstring_fence: 1494 case Sstring_fence:
1489 case Sstring: 1495 case Sstring:
1651 if (!--depth) goto done2; 1657 if (!--depth) goto done2;
1652 if (depth < min_depth) 1658 if (depth < min_depth)
1653 { 1659 {
1654 if (noerror) 1660 if (noerror)
1655 return Qnil; 1661 return Qnil;
1656 syntax_error ("Containing expression ends prematurely", 1662 signal_error_2 (Qscan_error,
1657 Qunbound); 1663 "Containing expression ends prematurely",
1664 make_int (last_good), make_int (from));
1658 } 1665 }
1659 break; 1666 break;
1660 1667
1661 case Scomment_fence: 1668 case Scomment_fence:
1662 comstyle = ST_COMMENT_STYLE; 1669 comstyle = ST_COMMENT_STYLE;
1722 1729
1723 return (make_int (from)); 1730 return (make_int (from));
1724 1731
1725 lose: 1732 lose:
1726 if (!noerror) 1733 if (!noerror)
1727 syntax_error ("Unbalanced parentheses", Qunbound); 1734 signal_error_2 (Qscan_error, "Unbalanced parentheses",
1735 make_int (last_good), make_int (from));
1728 return Qnil; 1736 return Qnil;
1729 } 1737 }
1730 1738
1731 int 1739 int
1732 char_quoted (struct buffer *buf, Charbpos pos) 1740 char_quoted (struct buffer *buf, Charbpos pos)
2285 2293
2286 static int 2294 static int
2287 copy_to_mirrortab (struct chartab_range *range, Lisp_Object UNUSED (table), 2295 copy_to_mirrortab (struct chartab_range *range, Lisp_Object UNUSED (table),
2288 Lisp_Object val, void *arg) 2296 Lisp_Object val, void *arg)
2289 { 2297 {
2290 Lisp_Object mirrortab = VOID_TO_LISP (arg); 2298 Lisp_Object mirrortab = GET_LISP_FROM_VOID (arg);
2291 2299
2292 if (CONSP (val)) 2300 if (CONSP (val))
2293 val = XCAR (val); 2301 val = XCAR (val);
2294 if (SYNTAX_FROM_CODE (XINT (val)) != Sinherit) 2302 if (SYNTAX_FROM_CODE (XINT (val)) != Sinherit)
2295 put_char_table (mirrortab, range, val); 2303 put_char_table (mirrortab, range, val);
2299 static int 2307 static int
2300 copy_if_not_already_present (struct chartab_range *range, 2308 copy_if_not_already_present (struct chartab_range *range,
2301 Lisp_Object UNUSED (table), 2309 Lisp_Object UNUSED (table),
2302 Lisp_Object val, void *arg) 2310 Lisp_Object val, void *arg)
2303 { 2311 {
2304 Lisp_Object mirrortab = VOID_TO_LISP (arg); 2312 Lisp_Object mirrortab = GET_LISP_FROM_VOID (arg);
2305 if (CONSP (val)) 2313 if (CONSP (val))
2306 val = XCAR (val); 2314 val = XCAR (val);
2307 if (SYNTAX_FROM_CODE (XINT (val)) != Sinherit) 2315 if (SYNTAX_FROM_CODE (XINT (val)) != Sinherit)
2308 { 2316 {
2309 Lisp_Object existing = 2317 Lisp_Object existing =
2344 over the standard table, copying values into the mirror table only if 2352 over the standard table, copying values into the mirror table only if
2345 entries don't already exist in that table. (The copying step requires 2353 entries don't already exist in that table. (The copying step requires
2346 another mapping.) 2354 another mapping.)
2347 */ 2355 */
2348 2356
2349 map_char_table (table, &range, copy_to_mirrortab, LISP_TO_VOID (mirrortab)); 2357 map_char_table (table, &range, copy_to_mirrortab, STORE_LISP_IN_VOID (mirrortab));
2350 /* second clause catches bootstrapping problems when initializing the 2358 /* second clause catches bootstrapping problems when initializing the
2351 standard syntax table */ 2359 standard syntax table */
2352 if (!EQ (table, Vstandard_syntax_table) && !NILP (Vstandard_syntax_table)) 2360 if (!EQ (table, Vstandard_syntax_table) && !NILP (Vstandard_syntax_table))
2353 map_char_table (Vstandard_syntax_table, &range, 2361 map_char_table (Vstandard_syntax_table, &range,
2354 copy_if_not_already_present, LISP_TO_VOID (mirrortab)); 2362 copy_if_not_already_present, STORE_LISP_IN_VOID (mirrortab));
2355 /* The resetting made the default be Qnil. Put it back to Sword. */ 2363 /* The resetting made the default be Qnil. Put it back to Sword. */
2356 set_char_table_default (mirrortab, make_int (Sword)); 2364 set_char_table_default (mirrortab, make_int (Sword));
2357 XCHAR_TABLE (mirrortab)->dirty = 0; 2365 XCHAR_TABLE (mirrortab)->dirty = 0;
2358 } 2366 }
2359 2367
2413 DEFSUBR (Fforward_comment); 2421 DEFSUBR (Fforward_comment);
2414 DEFSUBR (Fscan_lists); 2422 DEFSUBR (Fscan_lists);
2415 DEFSUBR (Fscan_sexps); 2423 DEFSUBR (Fscan_sexps);
2416 DEFSUBR (Fbackward_prefix_chars); 2424 DEFSUBR (Fbackward_prefix_chars);
2417 DEFSUBR (Fparse_partial_sexp); 2425 DEFSUBR (Fparse_partial_sexp);
2426
2427 DEFERROR_STANDARD (Qscan_error, Qsyntax_error);
2418 } 2428 }
2419 2429
2420 void 2430 void
2421 vars_of_syntax (void) 2431 vars_of_syntax (void)
2422 { 2432 {