comparison src/syntax.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents 3bb7ccffb0c0
children a2f645c6b9f8
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
72 int no_quit_in_re_search; 72 int no_quit_in_re_search;
73 73
74 /* Tell the regex routines which buffer to access for SYNTAX() lookups 74 /* Tell the regex routines which buffer to access for SYNTAX() lookups
75 and the like. */ 75 and the like. */
76 struct buffer *regex_emacs_buffer; 76 struct buffer *regex_emacs_buffer;
77 77
78 Lisp_Object Vstandard_syntax_table; 78 Lisp_Object Vstandard_syntax_table;
79 79
80 Lisp_Object Vsyntax_designator_chars_string; 80 Lisp_Object Vsyntax_designator_chars_string;
81 81
82 /* This is the internal form of the parse state used in parse-partial-sexp. */ 82 /* This is the internal form of the parse state used in parse-partial-sexp. */
352 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf); 352 Bufpos limit = count > 0 ? BUF_ZV (buf) : BUF_BEGV (buf);
353 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table); 353 struct Lisp_Char_Table *mirrortab = XCHAR_TABLE (buf->mirror_syntax_table);
354 while (count > 0) 354 while (count > 0)
355 { 355 {
356 QUIT; 356 QUIT;
357 357
358 while (1) 358 while (1)
359 { 359 {
360 if (from == limit) 360 if (from == limit)
361 return 0; 361 return 0;
362 if (word_constituent_p (buf, from, mirrortab)) 362 if (word_constituent_p (buf, from, mirrortab))
370 { 370 {
371 from++; 371 from++;
372 } 372 }
373 count--; 373 count--;
374 } 374 }
375 375
376 while (count < 0) 376 while (count < 0)
377 { 377 {
378 QUIT; 378 QUIT;
379 379
380 while (1) 380 while (1)
419 return Qt; 419 return Qt;
420 } 420 }
421 421
422 static void scan_sexps_forward (struct buffer *buf, 422 static void scan_sexps_forward (struct buffer *buf,
423 struct lisp_parse_state *, 423 struct lisp_parse_state *,
424 Bufpos from, Bufpos end, 424 Bufpos from, Bufpos end,
425 int targetdepth, int stopbefore, 425 int targetdepth, int stopbefore,
426 Lisp_Object oldstate, 426 Lisp_Object oldstate,
427 int commentstop); 427 int commentstop);
428 428
429 static int 429 static int
436 /* Look back, counting the parity of string-quotes, 436 /* Look back, counting the parity of string-quotes,
437 and recording the comment-starters seen. 437 and recording the comment-starters seen.
438 When we reach a safe place, assume that's not in a string; 438 When we reach a safe place, assume that's not in a string;
439 then step the main scan to the earliest comment-starter seen 439 then step the main scan to the earliest comment-starter seen
440 an even number of string quotes away from the safe place. 440 an even number of string quotes away from the safe place.
441 441
442 OFROM[I] is position of the earliest comment-starter seen 442 OFROM[I] is position of the earliest comment-starter seen
443 which is I+2X quotes from the comment-end. 443 which is I+2X quotes from the comment-end.
444 PARITY is current parity of quotes from the comment end. */ 444 PARITY is current parity of quotes from the comment end. */
445 int parity = 0; 445 int parity = 0;
446 Emchar my_stringend = 0; 446 Emchar my_stringend = 0;
475 styles_match_p = 475 styles_match_p =
476 SYNTAX_STYLES_MATCH_END_P (mirrortab, c, 476 SYNTAX_STYLES_MATCH_END_P (mirrortab, c,
477 BUF_FETCH_CHAR (buf, from+1), 477 BUF_FETCH_CHAR (buf, from+1),
478 mask); 478 mask);
479 } 479 }
480 480
481 /* or are we looking at a 1-char comment start sequence 481 /* or are we looking at a 1-char comment start sequence
482 of the style matching mask? */ 482 of the style matching mask? */
483 else if (code == Scomment 483 else if (code == Scomment
484 && SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask)) 484 && SYNTAX_STYLES_MATCH_1CHAR_P (mirrortab, c, mask))
485 { 485 {
486 styles_match_p = 1; 486 styles_match_p = 1;
487 } 487 }
488 488
489 /* or possibly, a 2-char comment start sequence */ 489 /* or possibly, a 2-char comment start sequence */
490 else if (from >= stop 490 else if (from >= stop
491 && SYNTAX_STYLES_MATCH_START_P (mirrortab, c, 491 && SYNTAX_STYLES_MATCH_START_P (mirrortab, c,
492 BUF_FETCH_CHAR (buf, from+1), 492 BUF_FETCH_CHAR (buf, from+1),
493 mask)) 493 mask))
654 } 654 }
655 655
656 else if (from < stop 656 else if (from < stop
657 && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from+1))) 657 && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from+1)))
658 { 658 {
659 /* we have encountered a 2char comment start sequence and we 659 /* we have encountered a 2char comment start sequence and we
660 are ignoring all text inside comments. we must record 660 are ignoring all text inside comments. we must record
661 the comment style this sequence begins so that later, 661 the comment style this sequence begins so that later,
662 only a comment end of the same style actually ends 662 only a comment end of the same style actually ends
663 the comment section */ 663 the comment section */
664 code = Scomment; 664 code = Scomment;
710 if (char_quoted (buf, from)) 710 if (char_quoted (buf, from))
711 { 711 {
712 from--; 712 from--;
713 continue; 713 continue;
714 } 714 }
715 715
716 c = BUF_FETCH_CHAR (buf, from); 716 c = BUF_FETCH_CHAR (buf, from);
717 code = SYNTAX (mirrortab, c); 717 code = SYNTAX (mirrortab, c);
718 718
719 if (code == Sendcomment) 719 if (code == Sendcomment)
720 { 720 {
798 /* else, a 2-char comment start sequence? */ 798 /* else, a 2-char comment start sequence? */
799 else if (from < stop 799 else if (from < stop
800 && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from)) 800 && SYNTAX_START_P (mirrortab, c, BUF_FETCH_CHAR (buf, from))
801 && parse_sexp_ignore_comments) 801 && parse_sexp_ignore_comments)
802 { 802 {
803 /* we have encountered a comment start sequence and we 803 /* we have encountered a comment start sequence and we
804 are ignoring all text inside comments. we must record 804 are ignoring all text inside comments. we must record
805 the comment style this sequence begins so that later, 805 the comment style this sequence begins so that later,
806 only a comment end of the same style actually ends 806 only a comment end of the same style actually ends
807 the comment section */ 807 the comment section */
808 code = Scomment; 808 code = Scomment;
809 mask = SYNTAX_COMMENT_MASK_START (mirrortab, c, 809 mask = SYNTAX_COMMENT_MASK_START (mirrortab, c,
810 BUF_FETCH_CHAR (buf, from)); 810 BUF_FETCH_CHAR (buf, from));
811 from++; 811 from++;
812 } 812 }
813 813
814 if (SYNTAX_PREFIX_UNSAFE (mirrortab, c)) 814 if (SYNTAX_PREFIX_UNSAFE (mirrortab, c))
815 continue; 815 continue;
816 816
817 switch (code) 817 switch (code)
818 { 818 {
898 898
899 if (CHARP (stermobj)) 899 if (CHARP (stermobj))
900 stringterm = XCHAR (stermobj); 900 stringterm = XCHAR (stermobj);
901 else 901 else
902 stringterm = ch; 902 stringterm = ch;
903 903
904 while (1) 904 while (1)
905 { 905 {
906 if (from >= stop) 906 if (from >= stop)
907 goto lose; 907 goto lose;
908 if (BUF_FETCH_CHAR (buf, from) == stringterm) 908 if (BUF_FETCH_CHAR (buf, from) == stringterm)
920 } 920 }
921 from++; 921 from++;
922 if (!depth && sexpflag) goto done; 922 if (!depth && sexpflag) goto done;
923 break; 923 break;
924 } 924 }
925 925
926 default: 926 default:
927 break; 927 break;
928 } 928 }
929 } 929 }
930 930
985 switch (((quoted) ? Sword : code)) 985 switch (((quoted) ? Sword : code))
986 { 986 {
987 case Sword: 987 case Sword:
988 case Ssymbol: 988 case Ssymbol:
989 if (depth || !sexpflag) break; 989 if (depth || !sexpflag) break;
990 /* This word counts as a sexp; count object finished after 990 /* This word counts as a sexp; count object finished after
991 passing it. */ 991 passing it. */
992 while (from > stop) 992 while (from > stop)
993 { 993 {
994 enum syntaxcode syncode; 994 enum syntaxcode syncode;
995 quoted = char_quoted (buf, from - 1); 995 quoted = char_quoted (buf, from - 1);
996 996
997 if (quoted) 997 if (quoted)
998 from--; 998 from--;
999 if (! (quoted 999 if (! (quoted
1000 || (syncode = 1000 || (syncode =
1001 SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from - 1))) 1001 SYNTAX (mirrortab, BUF_FETCH_CHAR (buf, from - 1)))
1162 return scan_lists (buf, XINT (from), XINT (count), 0, 1, !NILP (no_error)); 1162 return scan_lists (buf, XINT (from), XINT (count), 0, 1, !NILP (no_error));
1163 } 1163 }
1164 1164
1165 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, 0, 1, 0, /* 1165 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, 0, 1, 0, /*
1166 Move point backward over any number of chars with prefix syntax. 1166 Move point backward over any number of chars with prefix syntax.
1167 This includes chars with \"quote\" or \"prefix\" syntax (' or p). 1167 This includes chars with "quote" or "prefix" syntax (' or p).
1168 1168
1169 Optional arg BUFFER defaults to the current buffer. 1169 Optional arg BUFFER defaults to the current buffer.
1170 */ 1170 */
1171 (buffer)) 1171 (buffer))
1172 { 1172 {
1191 If STOPBEFORE is nonzero, stop at the start of an atom. 1191 If STOPBEFORE is nonzero, stop at the start of an atom.
1192 If COMMENTSTOP is nonzero, stop at the start of a comment. */ 1192 If COMMENTSTOP is nonzero, stop at the start of a comment. */
1193 1193
1194 static void 1194 static void
1195 scan_sexps_forward (struct buffer *buf, struct lisp_parse_state *stateptr, 1195 scan_sexps_forward (struct buffer *buf, struct lisp_parse_state *stateptr,
1196 Bufpos from, Bufpos end, 1196 Bufpos from, Bufpos end,
1197 int targetdepth, int stopbefore, 1197 int targetdepth, int stopbefore,
1198 Lisp_Object oldstate, 1198 Lisp_Object oldstate,
1199 int commentstop) 1199 int commentstop)
1200 { 1200 {
1201 struct lisp_parse_state state; 1201 struct lisp_parse_state state;
1285 mask = SYNTAX_COMMENT_1CHAR_MASK (mirrortab, 1285 mask = SYNTAX_COMMENT_1CHAR_MASK (mirrortab,
1286 BUF_FETCH_CHAR (buf, from-1)); 1286 BUF_FETCH_CHAR (buf, from-1));
1287 state.comstyle = (mask == SYNTAX_COMMENT_STYLE_B); 1287 state.comstyle = (mask == SYNTAX_COMMENT_STYLE_B);
1288 state.comstart = from - 1; 1288 state.comstart = from - 1;
1289 } 1289 }
1290 1290
1291 else if (from < end && 1291 else if (from < end &&
1292 SYNTAX_START_P (mirrortab, BUF_FETCH_CHAR (buf, from-1), 1292 SYNTAX_START_P (mirrortab, BUF_FETCH_CHAR (buf, from-1),
1293 BUF_FETCH_CHAR (buf, from))) 1293 BUF_FETCH_CHAR (buf, from)))
1294 { 1294 {
1295 /* Record the comment style we have entered so that only 1295 /* Record the comment style we have entered so that only
1575 static void 1575 static void
1576 update_just_this_syntax_table (struct Lisp_Char_Table *ct) 1576 update_just_this_syntax_table (struct Lisp_Char_Table *ct)
1577 { 1577 {
1578 struct chartab_range range; 1578 struct chartab_range range;
1579 struct cmst_arg arg; 1579 struct cmst_arg arg;
1580 1580
1581 arg.mirrortab = ct->mirror_table; 1581 arg.mirrortab = ct->mirror_table;
1582 arg.check_inherit = (CHAR_TABLEP (Vstandard_syntax_table) 1582 arg.check_inherit = (CHAR_TABLEP (Vstandard_syntax_table)
1583 && ct != XCHAR_TABLE (Vstandard_syntax_table)); 1583 && ct != XCHAR_TABLE (Vstandard_syntax_table));
1584 range.type = CHARTAB_RANGE_ALL; 1584 range.type = CHARTAB_RANGE_ALL;
1585 map_char_table (ct, &range, cmst_mapfun, &arg); 1585 map_char_table (ct, &range, cmst_mapfun, &arg);
1716 1716
1717 Fput_char_table (make_char ('"'), make_int ((int) Sstring), 1717 Fput_char_table (make_char ('"'), make_int ((int) Sstring),
1718 Vstandard_syntax_table); 1718 Vstandard_syntax_table);
1719 Fput_char_table (make_char ('\\'), make_int ((int) Sescape), 1719 Fput_char_table (make_char ('\\'), make_int ((int) Sescape),
1720 Vstandard_syntax_table); 1720 Vstandard_syntax_table);
1721 1721
1722 { 1722 {
1723 CONST char *p; 1723 CONST char *p;
1724 for (p = "_-+*/&|<>="; *p; p++) 1724 for (p = "_-+*/&|<>="; *p; p++)
1725 Fput_char_table (make_char (*p), make_int ((int) Ssymbol), 1725 Fput_char_table (make_char (*p), make_int ((int) Ssymbol),
1726 Vstandard_syntax_table); 1726 Vstandard_syntax_table);