1 /* GNU Emacs routines to deal with syntax tables; also word and list parsing.
2 Copyright (C) 1985, 1987, 1993, 1994, 1995 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
29 Lisp_Object Qsyntax_table_p
, Qsyntax_table
;
31 static void scan_sexps_forward ();
32 static int char_quoted ();
34 int words_include_escapes
;
36 /* Used as a temporary in SYNTAX_ENTRY and other macros in syntax.h,
37 if not compiled with GCC. No need to mark it, since it is used
38 only very temporarily. */
39 Lisp_Object syntax_temp
;
41 /* This is the internal form of the parse state used in parse-partial-sexp. */
43 struct lisp_parse_state
45 int depth
; /* Depth at end of parsing */
46 int instring
; /* -1 if not within string, else desired terminator. */
47 int incomment
; /* Nonzero if within a comment at end of parsing */
48 int comstyle
; /* comment style a=0, or b=1 */
49 int quoted
; /* Nonzero if just after an escape char at end of parsing */
50 int thislevelstart
; /* Char number of most recent start-of-expression at current level */
51 int prevlevelstart
; /* Char number of start of containing expression */
52 int location
; /* Char number at which parsing stopped. */
53 int mindepth
; /* Minimum depth seen while scanning. */
54 int comstart
; /* Position just after last comment starter. */
57 /* These variables are a cache for finding the start of a defun.
58 find_start_pos is the place for which the defun start was found.
59 find_start_value is the defun start position found for it.
60 find_start_buffer is the buffer it was found in.
61 find_start_begv is the BEGV value when it was found.
62 find_start_modiff is the value of MODIFF when it was found. */
64 static int find_start_pos
;
65 static int find_start_value
;
66 static struct buffer
*find_start_buffer
;
67 static int find_start_begv
;
68 static int find_start_modiff
;
70 /* Find a defun-start that is the last one before POS (or nearly the last).
71 We record what we find, so that another call in the same area
72 can return the same value right away. */
75 find_defun_start (pos
)
81 /* Use previous finding, if it's valid and applies to this inquiry. */
82 if (current_buffer
== find_start_buffer
83 /* Reuse the defun-start even if POS is a little farther on.
84 POS might be in the next defun, but that's ok.
85 Our value may not be the best possible, but will still be usable. */
86 && pos
<= find_start_pos
+ 1000
87 && pos
>= find_start_value
88 && BEGV
== find_start_begv
89 && MODIFF
== find_start_modiff
)
90 return find_start_value
;
92 /* Back up to start of line. */
93 tem
= scan_buffer ('\n', pos
, BEGV
, -1, &shortage
, 1);
97 /* Open-paren at start of line means we found our defun-start. */
98 if (SYNTAX (FETCH_CHAR (tem
)) == Sopen
)
100 /* Move to beg of previous line. */
101 tem
= scan_buffer ('\n', tem
, BEGV
, -2, &shortage
, 1);
104 /* Record what we found, for the next try. */
105 find_start_value
= tem
;
106 find_start_buffer
= current_buffer
;
107 find_start_modiff
= MODIFF
;
108 find_start_begv
= BEGV
;
109 find_start_pos
= pos
;
111 return find_start_value
;
114 DEFUN ("syntax-table-p", Fsyntax_table_p
, Ssyntax_table_p
, 1, 1, 0,
115 "Return t if OBJECT is a syntax table.\n\
116 Currently, any char-table counts as a syntax table.")
120 if (CHAR_TABLE_P (object
)
121 && XCHAR_TABLE (object
)->purpose
== Qsyntax_table
)
127 check_syntax_table (obj
)
130 if (!(CHAR_TABLE_P (obj
)
131 && XCHAR_TABLE (obj
)->purpose
== Qsyntax_table
))
132 wrong_type_argument (Qsyntax_table_p
, obj
);
135 DEFUN ("syntax-table", Fsyntax_table
, Ssyntax_table
, 0, 0, 0,
136 "Return the current syntax table.\n\
137 This is the one specified by the current buffer.")
140 return current_buffer
->syntax_table
;
143 DEFUN ("standard-syntax-table", Fstandard_syntax_table
,
144 Sstandard_syntax_table
, 0, 0, 0,
145 "Return the standard syntax table.\n\
146 This is the one used for new buffers.")
149 return Vstandard_syntax_table
;
152 DEFUN ("copy-syntax-table", Fcopy_syntax_table
, Scopy_syntax_table
, 0, 1, 0,
153 "Construct a new syntax table and return it.\n\
154 It is a copy of the TABLE, which defaults to the standard syntax table.")
161 check_syntax_table (table
);
163 table
= Vstandard_syntax_table
;
165 copy
= Fcopy_sequence (table
);
166 Fset_char_table_parent (copy
, Vstandard_syntax_table
);
170 DEFUN ("set-syntax-table", Fset_syntax_table
, Sset_syntax_table
, 1, 1, 0,
171 "Select a new syntax table for the current buffer.\n\
172 One argument, a syntax table.")
176 check_syntax_table (table
);
177 current_buffer
->syntax_table
= table
;
178 /* Indicate that this buffer now has a specified syntax table. */
179 current_buffer
->local_var_flags
180 |= XFASTINT (buffer_local_flags
.syntax_table
);
184 /* Convert a letter which signifies a syntax code
185 into the code it signifies.
186 This is used by modify-syntax-entry, and other things. */
188 unsigned char syntax_spec_code
[0400] =
189 { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
190 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
191 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
192 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
193 (char) Swhitespace
, 0377, (char) Sstring
, 0377,
194 (char) Smath
, 0377, 0377, (char) Squote
,
195 (char) Sopen
, (char) Sclose
, 0377, 0377,
196 0377, (char) Swhitespace
, (char) Spunct
, (char) Scharquote
,
197 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
198 0377, 0377, 0377, 0377,
199 (char) Scomment
, 0377, (char) Sendcomment
, 0377,
200 (char) Sinherit
, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* @, A ... */
201 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
202 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword
,
203 0377, 0377, 0377, 0377, (char) Sescape
, 0377, 0377, (char) Ssymbol
,
204 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377, /* `, a, ... */
205 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
206 0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword
,
207 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377
210 /* Indexed by syntax code, give the letter that describes it. */
212 char syntax_code_spec
[14] =
214 ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>', '@'
217 /* Look up the value for CHARACTER in syntax table TABLE's parent
218 and its parents. SYNTAX_ENTRY calls this, when TABLE itself has nil
219 for CHARACTER. It's actually used only when not compiled with GCC. */
222 syntax_parent_lookup (table
, character
)
230 table
= XCHAR_TABLE (table
)->parent
;
234 value
= XCHAR_TABLE (table
)->contents
[character
];
240 DEFUN ("char-syntax", Fchar_syntax
, Schar_syntax
, 1, 1, 0,
241 "Return the syntax code of CHARACTER, described by a character.\n\
242 For example, if CHARACTER is a word constituent,\n\
243 the character `w' is returned.\n\
244 The characters that correspond to various syntax codes\n\
245 are listed in the documentation of `modify-syntax-entry'.")
247 Lisp_Object character
;
250 CHECK_NUMBER (character
, 0);
251 char_int
= XINT (character
);
252 return make_number (syntax_code_spec
[(int) SYNTAX (char_int
)]);
255 DEFUN ("matching-paren", Fmatching_paren
, Smatching_paren
, 1, 1, 0,
256 "Return the matching parenthesis of CHARACTER, or nil if none.")
258 Lisp_Object character
;
261 CHECK_NUMBER (character
, 0);
262 char_int
= XINT (character
);
263 code
= SYNTAX (char_int
);
264 if (code
== Sopen
|| code
== Sclose
)
265 return make_number (SYNTAX_MATCH (char_int
));
269 /* This comment supplies the doc string for modify-syntax-entry,
270 for make-docfile to see. We cannot put this in the real DEFUN
271 due to limits in the Unix cpp.
273 DEFUN ("modify-syntax-entry", foo, bar, 2, 3, 0,
274 "Set syntax for character CHAR according to string S.\n\
275 The syntax is changed only for table TABLE, which defaults to\n\
276 the current buffer's syntax table.\n\
277 The first character of S should be one of the following:\n\
278 Space or - whitespace syntax. w word constituent.\n\
279 _ symbol constituent. . punctuation.\n\
280 ( open-parenthesis. ) close-parenthesis.\n\
281 \" string quote. \\ escape.\n\
282 $ paired delimiter. ' expression quote or prefix operator.\n\
283 < comment starter. > comment ender.\n\
284 / character-quote. @ inherit from `standard-syntax-table'.\n\
286 Only single-character comment start and end sequences are represented thus.\n\
287 Two-character sequences are represented as described below.\n\
288 The second character of S is the matching parenthesis,\n\
289 used only if the first character is `(' or `)'.\n\
290 Any additional characters are flags.\n\
291 Defined flags are the characters 1, 2, 3, 4, b, and p.\n\
292 1 means CHAR is the start of a two-char comment start sequence.\n\
293 2 means CHAR is the second character of such a sequence.\n\
294 3 means CHAR is the start of a two-char comment end sequence.\n\
295 4 means CHAR is the second character of such a sequence.\n\
297 There can be up to two orthogonal comment sequences. This is to support\n\
298 language modes such as C++. By default, all comment sequences are of style\n\
299 a, but you can set the comment sequence style to b (on the second character\n\
300 of a comment-start, or the first character of a comment-end sequence) using\n\
302 b means CHAR is part of comment sequence b.\n\
304 p means CHAR is a prefix character for `backward-prefix-chars';\n\
305 such characters are treated as whitespace when they occur\n\
306 between expressions.")
310 DEFUN ("modify-syntax-entry", Fmodify_syntax_entry
, Smodify_syntax_entry
, 2, 3,
311 /* I really don't know why this is interactive
312 help-form should at least be made useful whilst reading the second arg
314 "cSet syntax for character: \nsSet syntax for %s to: ",
315 0 /* See immediately above */)
316 (c
, newentry
, syntax_table
)
317 Lisp_Object c
, newentry
, syntax_table
;
319 register unsigned char *p
;
320 register enum syntaxcode code
;
325 CHECK_STRING (newentry
, 1);
327 if (NILP (syntax_table
))
328 syntax_table
= current_buffer
->syntax_table
;
330 check_syntax_table (syntax_table
);
332 p
= XSTRING (newentry
)->data
;
333 code
= (enum syntaxcode
) syntax_spec_code
[*p
++];
334 if (((int) code
& 0377) == 0377)
335 error ("invalid syntax description letter: %c", c
);
337 if (code
== Sinherit
)
339 SET_RAW_SYNTAX_ENTRY (syntax_table
, c
, Qnil
);
345 XSETINT (match
, *p
++);
346 if (XFASTINT (match
) == ' ')
381 SET_RAW_SYNTAX_ENTRY (syntax_table
, c
,
382 Fcons (make_number (val
), match
));
387 /* Dump syntax table to buffer in human-readable format */
390 describe_syntax (value
)
393 register enum syntaxcode code
;
394 char desc
, match
, start1
, start2
, end1
, end2
, prefix
, comstyle
;
396 Lisp_Object first
, match_lisp
;
398 Findent_to (make_number (16), make_number (1));
402 insert_string ("inherit");
408 insert_string ("invalid");
412 first
= XCONS (value
)->car
;
413 match_lisp
= XCONS (value
)->cdr
;
415 if (!INTEGERP (first
) || !(NILP (match_lisp
) || INTEGERP (match_lisp
)))
417 insert_string ("invalid");
421 code
= (enum syntaxcode
) (first
& 0377);
422 start1
= (XINT (first
) >> 16) & 1;
423 start2
= (XINT (first
) >> 17) & 1;
424 end1
= (XINT (first
) >> 18) & 1;
425 end2
= (XINT (first
) >> 19) & 1;
426 prefix
= (XINT (first
) >> 20) & 1;
427 comstyle
= (XINT (first
) >> 21) & 1;
429 if ((int) code
< 0 || (int) code
>= (int) Smax
)
431 insert_string ("invalid");
434 desc
= syntax_code_spec
[(int) code
];
436 str
[0] = desc
, str
[1] = 0;
439 str
[0] = !NILP (match_lisp
) ? XINT (match_lisp
) : ' ';
457 insert_string ("\twhich means: ");
459 switch (SWITCH_ENUM_CAST (code
))
462 insert_string ("whitespace"); break;
464 insert_string ("punctuation"); break;
466 insert_string ("word"); break;
468 insert_string ("symbol"); break;
470 insert_string ("open"); break;
472 insert_string ("close"); break;
474 insert_string ("quote"); break;
476 insert_string ("string"); break;
478 insert_string ("math"); break;
480 insert_string ("escape"); break;
482 insert_string ("charquote"); break;
484 insert_string ("comment"); break;
486 insert_string ("endcomment"); break;
488 insert_string ("invalid");
492 if (!NILP (match_lisp
))
494 insert_string (", matches ");
495 insert_char (XINT (match_lisp
));
499 insert_string (",\n\t is the first character of a comment-start sequence");
501 insert_string (",\n\t is the second character of a comment-start sequence");
504 insert_string (",\n\t is the first character of a comment-end sequence");
506 insert_string (",\n\t is the second character of a comment-end sequence");
508 insert_string (" (comment style b)");
511 insert_string (",\n\t is a prefix character for `backward-prefix-chars'");
513 insert_string ("\n");
517 describe_syntax_1 (vector
)
520 struct buffer
*old
= current_buffer
;
521 set_buffer_internal (XBUFFER (Vstandard_output
));
522 describe_vector (vector
, Qnil
, describe_syntax
, 0, Qnil
, Qnil
);
523 call0 (intern ("help-mode"));
524 set_buffer_internal (old
);
528 DEFUN ("describe-syntax", Fdescribe_syntax
, Sdescribe_syntax
, 0, 0, "",
529 "Describe the syntax specifications in the syntax table.\n\
530 The descriptions are inserted in a buffer, which is then displayed.")
533 internal_with_output_to_temp_buffer
534 ("*Help*", describe_syntax_1
, current_buffer
->syntax_table
);
539 /* Return the position across COUNT words from FROM.
540 If that many words cannot be found before the end of the buffer, return 0.
541 COUNT negative means scan backward and stop at word beginning. */
543 scan_words (from
, count
)
544 register int from
, count
;
546 register int beg
= BEGV
;
547 register int end
= ZV
;
563 charcode
= FETCH_CHAR (from
);
564 code
= SYNTAX (charcode
);
565 if (words_include_escapes
566 && (code
== Sescape
|| code
== Scharquote
))
574 if (from
== end
) break;
575 charcode
= FETCH_CHAR (from
);
576 code
= SYNTAX (charcode
);
577 if (!(words_include_escapes
578 && (code
== Sescape
|| code
== Scharquote
)))
594 charcode
= FETCH_CHAR (from
- 1);
595 code
= SYNTAX (charcode
);
596 if (words_include_escapes
597 && (code
== Sescape
|| code
== Scharquote
))
605 if (from
== beg
) break;
606 charcode
= FETCH_CHAR (from
- 1);
607 code
= SYNTAX (charcode
);
608 if (!(words_include_escapes
609 && (code
== Sescape
|| code
== Scharquote
)))
622 DEFUN ("forward-word", Fforward_word
, Sforward_word
, 1, 1, "p",
623 "Move point forward ARG words (backward if ARG is negative).\n\
624 Normally returns t.\n\
625 If an edge of the buffer is reached, point is left there\n\
626 and nil is returned.")
631 CHECK_NUMBER (count
, 0);
633 if (!(val
= scan_words (point
, XINT (count
))))
635 SET_PT (XINT (count
) > 0 ? ZV
: BEGV
);
642 DEFUN ("forward-comment", Fforward_comment
, Sforward_comment
, 1, 1, 0,
643 "Move forward across up to N comments. If N is negative, move backward.\n\
644 Stop scanning if we find something other than a comment or whitespace.\n\
645 Set point to where scanning stops.\n\
646 If N comments are found as expected, with nothing except whitespace\n\
647 between them, return t; otherwise return nil.")
654 register enum syntaxcode code
;
655 int comstyle
= 0; /* style of comment encountered */
659 CHECK_NUMBER (count
, 0);
660 count1
= XINT (count
);
678 c
= FETCH_CHAR (from
);
682 if (from
< stop
&& SYNTAX_COMSTART_FIRST (c
)
683 && (c1
= FETCH_CHAR (from
),
684 SYNTAX_COMSTART_SECOND (c1
)))
686 /* We have encountered a comment start sequence and we
687 are ignoring all text inside comments. We must record
688 the comment style this sequence begins so that later,
689 only a comment end of the same style actually ends
690 the comment section. */
692 comstyle
= SYNTAX_COMMENT_STYLE (c1
);
696 while (code
== Swhitespace
|| code
== Sendcomment
);
697 if (code
!= Scomment
)
703 /* We're at the start of a comment. */
712 c
= FETCH_CHAR (from
);
714 if (SYNTAX (c
) == Sendcomment
715 && SYNTAX_COMMENT_STYLE (c
) == comstyle
)
716 /* we have encountered a comment end of the same style
717 as the comment sequence which began this comment
720 if (from
< stop
&& SYNTAX_COMEND_FIRST (c
)
721 && (c1
= FETCH_CHAR (from
),
722 SYNTAX_COMEND_SECOND (c1
))
723 && SYNTAX_COMMENT_STYLE (c
) == comstyle
)
724 /* we have encountered a comment end of the same style
725 as the comment sequence which began this comment
729 /* We have skipped one comment. */
741 quoted
= char_quoted (from
);
744 c
= FETCH_CHAR (from
);
747 if (code
== Sendcomment
)
748 comstyle
= SYNTAX_COMMENT_STYLE (c
);
749 if (from
> stop
&& SYNTAX_COMEND_SECOND (c
)
750 && (c1
= FETCH_CHAR (from
- 1),
751 SYNTAX_COMEND_FIRST (c1
))
752 && !char_quoted (from
- 1))
754 /* We must record the comment style encountered so that
755 later, we can match only the proper comment begin
756 sequence of the same style. */
758 comstyle
= SYNTAX_COMMENT_STYLE (c1
);
762 if (code
== Sendcomment
&& !quoted
)
765 if (code
!= SYNTAX (c
))
766 /* For a two-char comment ender, we can assume
767 it does end a comment. So scan back in a simple way. */
769 if (from
!= stop
) from
--;
772 if ((c
= FETCH_CHAR (from
),
773 SYNTAX (c
) == Scomment
)
774 && SYNTAX_COMMENT_STYLE (c
) == comstyle
)
783 if (SYNTAX_COMSTART_SECOND (c
)
784 && (c1
= FETCH_CHAR (from
),
785 SYNTAX_COMSTART_FIRST (c1
))
786 && SYNTAX_COMMENT_STYLE (c
) == comstyle
787 && !char_quoted (from
))
794 /* Look back, counting the parity of string-quotes,
795 and recording the comment-starters seen.
796 When we reach a safe place, assume that's not in a string;
797 then step the main scan to the earliest comment-starter seen
798 an even number of string quotes away from the safe place.
800 OFROM[I] is position of the earliest comment-starter seen
801 which is I+2X quotes from the comment-end.
802 PARITY is current parity of quotes from the comment end. */
805 char my_stringend
= 0;
806 int string_lossage
= 0;
807 int comment_end
= from
;
808 int comstart_pos
= 0;
809 int comstart_parity
= 0;
810 int scanstart
= from
- 1;
812 /* At beginning of range to scan, we're outside of strings;
813 that determines quote parity to the comment-end. */
816 /* Move back and examine a character. */
819 c
= FETCH_CHAR (from
);
822 /* If this char is the second of a 2-char comment sequence,
823 back up and give the pair the appropriate syntax. */
824 if (from
> stop
&& SYNTAX_COMEND_SECOND (c
)
825 && SYNTAX_COMEND_FIRST (FETCH_CHAR (from
- 1)))
829 c
= FETCH_CHAR (from
);
832 /* If this char starts a 2-char comment start sequence,
833 treat it like a 1-char comment starter. */
834 if (from
< scanstart
&& SYNTAX_COMSTART_FIRST (c
)
835 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from
+ 1))
836 && comstyle
== SYNTAX_COMMENT_STYLE (FETCH_CHAR (from
+ 1)))
839 /* Ignore escaped characters. */
840 if (char_quoted (from
))
843 /* Track parity of quotes. */
847 if (my_stringend
== 0)
849 /* If we have two kinds of string delimiters.
850 There's no way to grok this scanning backwards. */
851 else if (my_stringend
!= c
)
855 /* Record comment-starters according to that
856 quote-parity to the comment-end. */
857 if (code
== Scomment
)
859 comstart_parity
= parity
;
863 /* If we find another earlier comment-ender,
864 any comment-starts earlier than that don't count
865 (because they go with the earlier comment-ender). */
866 if (code
== Sendcomment
867 && SYNTAX_COMMENT_STYLE (FETCH_CHAR (from
)) == comstyle
)
870 /* Assume a defun-start point is outside of strings. */
872 && (from
== stop
|| FETCH_CHAR (from
- 1) == '\n'))
876 if (comstart_pos
== 0)
878 /* If the earliest comment starter
879 is followed by uniform paired string quotes or none,
880 we know it can't be inside a string
881 since if it were then the comment ender would be inside one.
882 So it does start a comment. Skip back to it. */
883 else if (comstart_parity
== 0 && !string_lossage
)
887 /* We had two kinds of string delimiters mixed up
888 together. Decode this going forwards.
889 Scan fwd from the previous comment ender
890 to the one in question; this records where we
891 last passed a comment starter. */
892 struct lisp_parse_state state
;
893 scan_sexps_forward (&state
, find_defun_start (comment_end
),
894 comment_end
- 1, -10000, 0, Qnil
, 0);
896 from
= state
.comstart
;
898 /* We can't grok this as a comment; scan it normally. */
902 /* We have skipped one comment. */
905 else if ((code
!= Swhitespace
&& code
!= Scomment
) || quoted
)
921 int parse_sexp_ignore_comments
;
924 scan_lists (from
, count
, depth
, sexpflag
)
926 int count
, depth
, sexpflag
;
931 unsigned char stringterm
;
934 register enum syntaxcode code
;
935 int min_depth
= depth
; /* Err out if depth gets less than this. */
936 int comstyle
= 0; /* style of comment encountered */
938 if (depth
> 0) min_depth
= 0;
948 c
= FETCH_CHAR (from
);
951 if (from
< stop
&& SYNTAX_COMSTART_FIRST (c
)
952 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from
))
953 && parse_sexp_ignore_comments
)
955 /* we have encountered a comment start sequence and we
956 are ignoring all text inside comments. we must record
957 the comment style this sequence begins so that later,
958 only a comment end of the same style actually ends
959 the comment section */
961 comstyle
= SYNTAX_COMMENT_STYLE (FETCH_CHAR (from
));
965 if (SYNTAX_PREFIX (c
))
968 switch (SWITCH_ENUM_CAST (code
))
972 if (from
== stop
) goto lose
;
974 /* treat following character as a word constituent */
977 if (depth
|| !sexpflag
) break;
978 /* This word counts as a sexp; return at end of it. */
981 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from
))))
986 if (from
== stop
) goto lose
;
1000 if (!parse_sexp_ignore_comments
) break;
1009 c
= FETCH_CHAR (from
);
1010 if (SYNTAX (c
) == Sendcomment
1011 && SYNTAX_COMMENT_STYLE (c
) == comstyle
)
1012 /* we have encountered a comment end of the same style
1013 as the comment sequence which began this comment
1017 if (from
< stop
&& SYNTAX_COMEND_FIRST (c
)
1018 && SYNTAX_COMEND_SECOND (FETCH_CHAR (from
))
1019 && SYNTAX_COMMENT_STYLE (c
) == comstyle
)
1020 /* we have encountered a comment end of the same style
1021 as the comment sequence which began this comment
1030 if (from
!= stop
&& c
== FETCH_CHAR (from
))
1040 if (!++depth
) goto done
;
1045 if (!--depth
) goto done
;
1046 if (depth
< min_depth
)
1047 error ("Containing expression ends prematurely");
1051 stringterm
= FETCH_CHAR (from
- 1);
1054 if (from
>= stop
) goto lose
;
1055 if (FETCH_CHAR (from
) == stringterm
) break;
1056 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from
))))
1065 if (!depth
&& sexpflag
) goto done
;
1070 /* Reached end of buffer. Error if within object, return nil if between */
1071 if (depth
) goto lose
;
1076 /* End of object reached */
1087 if (quoted
= char_quoted (from
))
1089 c
= FETCH_CHAR (from
);
1092 if (code
== Sendcomment
)
1093 comstyle
= SYNTAX_COMMENT_STYLE (c
);
1094 if (from
> stop
&& SYNTAX_COMEND_SECOND (c
)
1095 && SYNTAX_COMEND_FIRST (FETCH_CHAR (from
- 1))
1096 && !char_quoted (from
- 1)
1097 && parse_sexp_ignore_comments
)
1099 /* we must record the comment style encountered so that
1100 later, we can match only the proper comment begin
1101 sequence of the same style */
1103 comstyle
= SYNTAX_COMMENT_STYLE (FETCH_CHAR (from
- 1));
1107 if (SYNTAX_PREFIX (c
))
1110 switch (SWITCH_ENUM_CAST (quoted
? Sword
: code
))
1114 if (depth
|| !sexpflag
) break;
1115 /* This word counts as a sexp; count object finished after passing it. */
1118 quoted
= char_quoted (from
- 1);
1121 if (! (quoted
|| SYNTAX (FETCH_CHAR (from
- 1)) == Sword
1122 || SYNTAX (FETCH_CHAR (from
- 1)) == Ssymbol
1123 || SYNTAX (FETCH_CHAR (from
- 1)) == Squote
))
1132 if (from
!= stop
&& c
== FETCH_CHAR (from
- 1))
1142 if (!++depth
) goto done2
;
1147 if (!--depth
) goto done2
;
1148 if (depth
< min_depth
)
1149 error ("Containing expression ends prematurely");
1153 if (!parse_sexp_ignore_comments
)
1156 if (code
!= SYNTAX (c
))
1157 /* For a two-char comment ender, we can assume
1158 it does end a comment. So scan back in a simple way. */
1160 if (from
!= stop
) from
--;
1163 if (SYNTAX (c
= FETCH_CHAR (from
)) == Scomment
1164 && SYNTAX_COMMENT_STYLE (c
) == comstyle
)
1173 if (SYNTAX_COMSTART_SECOND (c
)
1174 && SYNTAX_COMSTART_FIRST (FETCH_CHAR (from
))
1175 && SYNTAX_COMMENT_STYLE (c
) == comstyle
1176 && !char_quoted (from
))
1183 /* Look back, counting the parity of string-quotes,
1184 and recording the comment-starters seen.
1185 When we reach a safe place, assume that's not in a string;
1186 then step the main scan to the earliest comment-starter seen
1187 an even number of string quotes away from the safe place.
1189 OFROM[I] is position of the earliest comment-starter seen
1190 which is I+2X quotes from the comment-end.
1191 PARITY is current parity of quotes from the comment end. */
1194 char my_stringend
= 0;
1195 int string_lossage
= 0;
1196 int comment_end
= from
;
1197 int comstart_pos
= 0;
1198 int comstart_parity
= 0;
1199 int scanstart
= from
- 1;
1201 /* At beginning of range to scan, we're outside of strings;
1202 that determines quote parity to the comment-end. */
1203 while (from
!= stop
)
1205 /* Move back and examine a character. */
1208 c
= FETCH_CHAR (from
);
1211 /* If this char is the second of a 2-char comment sequence,
1212 back up and give the pair the appropriate syntax. */
1213 if (from
> stop
&& SYNTAX_COMEND_SECOND (c
)
1214 && SYNTAX_COMEND_FIRST (FETCH_CHAR (from
- 1)))
1218 c
= FETCH_CHAR (from
);
1221 /* If this char starts a 2-char comment start sequence,
1222 treat it like a 1-char comment starter. */
1223 if (from
< scanstart
&& SYNTAX_COMSTART_FIRST (c
)
1224 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from
+ 1))
1225 && comstyle
== SYNTAX_COMMENT_STYLE (FETCH_CHAR (from
+ 1)))
1228 /* Ignore escaped characters. */
1229 if (char_quoted (from
))
1232 /* Track parity of quotes. */
1233 if (code
== Sstring
)
1236 if (my_stringend
== 0)
1238 /* If we have two kinds of string delimiters.
1239 There's no way to grok this scanning backwards. */
1240 else if (my_stringend
!= c
)
1244 /* Record comment-starters according to that
1245 quote-parity to the comment-end. */
1246 if (code
== Scomment
)
1248 comstart_parity
= parity
;
1249 comstart_pos
= from
;
1252 /* If we find another earlier comment-ender,
1253 any comment-starts earlier than that don't count
1254 (because they go with the earlier comment-ender). */
1255 if (code
== Sendcomment
1256 && SYNTAX_COMMENT_STYLE (FETCH_CHAR (from
)) == comstyle
)
1259 /* Assume a defun-start point is outside of strings. */
1261 && (from
== stop
|| FETCH_CHAR (from
- 1) == '\n'))
1265 if (comstart_pos
== 0)
1267 /* If the earliest comment starter
1268 is followed by uniform paired string quotes or none,
1269 we know it can't be inside a string
1270 since if it were then the comment ender would be inside one.
1271 So it does start a comment. Skip back to it. */
1272 else if (comstart_parity
== 0 && !string_lossage
)
1273 from
= comstart_pos
;
1276 /* We had two kinds of string delimiters mixed up
1277 together. Decode this going forwards.
1278 Scan fwd from the previous comment ender
1279 to the one in question; this records where we
1280 last passed a comment starter. */
1281 struct lisp_parse_state state
;
1282 scan_sexps_forward (&state
, find_defun_start (comment_end
),
1283 comment_end
- 1, -10000, 0, Qnil
, 0);
1284 if (state
.incomment
)
1285 from
= state
.comstart
;
1287 /* We can't grok this as a comment; scan it normally. */
1294 stringterm
= FETCH_CHAR (from
);
1297 if (from
== stop
) goto lose
;
1298 if (!char_quoted (from
- 1)
1299 && stringterm
== FETCH_CHAR (from
- 1))
1304 if (!depth
&& sexpflag
) goto done2
;
1309 /* Reached start of buffer. Error if within object, return nil if between */
1310 if (depth
) goto lose
;
1321 XSETFASTINT (val
, from
);
1325 error ("Unbalanced parentheses");
1333 register enum syntaxcode code
;
1334 register int beg
= BEGV
;
1335 register int quoted
= 0;
1338 && ((code
= SYNTAX (FETCH_CHAR (pos
- 1))) == Scharquote
1339 || code
== Sescape
))
1340 pos
--, quoted
= !quoted
;
1344 DEFUN ("scan-lists", Fscan_lists
, Sscan_lists
, 3, 3, 0,
1345 "Scan from character number FROM by COUNT lists.\n\
1346 Returns the character number of the position thus found.\n\
1348 If DEPTH is nonzero, paren depth begins counting from that value,\n\
1349 only places where the depth in parentheses becomes zero\n\
1350 are candidates for stopping; COUNT such places are counted.\n\
1351 Thus, a positive value for DEPTH means go out levels.\n\
1353 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\
1355 If the beginning or end of (the accessible part of) the buffer is reached\n\
1356 and the depth is wrong, an error is signaled.\n\
1357 If the depth is right but the count is not used up, nil is returned.")
1358 (from
, count
, depth
)
1359 Lisp_Object from
, count
, depth
;
1361 CHECK_NUMBER (from
, 0);
1362 CHECK_NUMBER (count
, 1);
1363 CHECK_NUMBER (depth
, 2);
1365 return scan_lists (XINT (from
), XINT (count
), XINT (depth
), 0);
1368 DEFUN ("scan-sexps", Fscan_sexps
, Sscan_sexps
, 2, 2, 0,
1369 "Scan from character number FROM by COUNT balanced expressions.\n\
1370 If COUNT is negative, scan backwards.\n\
1371 Returns the character number of the position thus found.\n\
1373 Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\
1375 If the beginning or end of (the accessible part of) the buffer is reached\n\
1376 in the middle of a parenthetical grouping, an error is signaled.\n\
1377 If the beginning or end is reached between groupings\n\
1378 but before count is used up, nil is returned.")
1380 Lisp_Object from
, count
;
1382 CHECK_NUMBER (from
, 0);
1383 CHECK_NUMBER (count
, 1);
1385 return scan_lists (XINT (from
), XINT (count
), 0, 1);
1388 DEFUN ("backward-prefix-chars", Fbackward_prefix_chars
, Sbackward_prefix_chars
,
1390 "Move point backward over any number of chars with prefix syntax.\n\
1391 This includes chars with \"quote\" or \"prefix\" syntax (' or p).")
1397 while (pos
> beg
&& !char_quoted (pos
- 1)
1398 && (SYNTAX (FETCH_CHAR (pos
- 1)) == Squote
1399 || SYNTAX_PREFIX (FETCH_CHAR (pos
- 1))))
1407 /* Parse forward from FROM to END,
1408 assuming that FROM has state OLDSTATE (nil means FROM is start of function),
1409 and return a description of the state of the parse at END.
1410 If STOPBEFORE is nonzero, stop at the start of an atom.
1411 If COMMENTSTOP is nonzero, stop at the start of a comment. */
1414 scan_sexps_forward (stateptr
, from
, end
, targetdepth
,
1415 stopbefore
, oldstate
, commentstop
)
1416 struct lisp_parse_state
*stateptr
;
1418 int end
, targetdepth
, stopbefore
;
1419 Lisp_Object oldstate
;
1422 struct lisp_parse_state state
;
1424 register enum syntaxcode code
;
1425 struct level
{ int last
, prev
; };
1426 struct level levelstart
[100];
1427 register struct level
*curlevel
= levelstart
;
1428 struct level
*endlevel
= levelstart
+ 100;
1430 register int depth
; /* Paren depth of current scanning location.
1431 level - levelstart equals this except
1432 when the depth becomes negative. */
1433 int mindepth
; /* Lowest DEPTH value seen. */
1434 int start_quoted
= 0; /* Nonzero means starting after a char quote */
1440 if (NILP (oldstate
))
1443 state
.instring
= -1;
1444 state
.incomment
= 0;
1445 state
.comstyle
= 0; /* comment style a by default */
1449 tem
= Fcar (oldstate
);
1455 oldstate
= Fcdr (oldstate
);
1456 oldstate
= Fcdr (oldstate
);
1457 oldstate
= Fcdr (oldstate
);
1458 tem
= Fcar (oldstate
);
1459 state
.instring
= !NILP (tem
) ? XINT (tem
) : -1;
1461 oldstate
= Fcdr (oldstate
);
1462 tem
= Fcar (oldstate
);
1463 state
.incomment
= !NILP (tem
);
1465 oldstate
= Fcdr (oldstate
);
1466 tem
= Fcar (oldstate
);
1467 start_quoted
= !NILP (tem
);
1469 /* if the eight element of the list is nil, we are in comment
1470 style a. if it is non-nil, we are in comment style b */
1471 oldstate
= Fcdr (oldstate
);
1472 oldstate
= Fcdr (oldstate
);
1473 tem
= Fcar (oldstate
);
1474 state
.comstyle
= !NILP (tem
);
1479 curlevel
->prev
= -1;
1480 curlevel
->last
= -1;
1482 /* Enter the loop at a place appropriate for initial state. */
1484 if (state
.incomment
) goto startincomment
;
1485 if (state
.instring
>= 0)
1487 if (start_quoted
) goto startquotedinstring
;
1490 if (start_quoted
) goto startquoted
;
1494 code
= SYNTAX (FETCH_CHAR (from
));
1496 if (code
== Scomment
)
1497 state
.comstart
= from
-1;
1499 else if (from
< end
&& SYNTAX_COMSTART_FIRST (FETCH_CHAR (from
- 1))
1500 && SYNTAX_COMSTART_SECOND (FETCH_CHAR (from
)))
1502 /* Record the comment style we have entered so that only
1503 the comment-end sequence of the same style actually
1504 terminates the comment section. */
1506 state
.comstyle
= SYNTAX_COMMENT_STYLE (FETCH_CHAR (from
));
1507 state
.comstart
= from
-1;
1511 if (SYNTAX_PREFIX (FETCH_CHAR (from
- 1)))
1513 switch (SWITCH_ENUM_CAST (code
))
1517 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
1518 curlevel
->last
= from
- 1;
1520 if (from
== end
) goto endquoted
;
1523 /* treat following character as a word constituent */
1526 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
1527 curlevel
->last
= from
- 1;
1531 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from
))))
1536 if (from
== end
) goto endquoted
;
1548 curlevel
->prev
= curlevel
->last
;
1556 /* Enter the loop in the middle so that we find
1557 a 2-char comment ender if we start in the middle of it. */
1558 prev
= FETCH_CHAR (from
- 1);
1559 goto startincomment_1
;
1561 /* At beginning of buffer, enter the loop the ordinary way. */
1564 state
.incomment
= 1;
1569 if (from
== end
) goto done
;
1570 prev
= FETCH_CHAR (from
);
1571 if (SYNTAX (prev
) == Sendcomment
1572 && SYNTAX_COMMENT_STYLE (prev
) == state
.comstyle
)
1573 /* Only terminate the comment section if the endcomment
1574 of the same style as the start sequence has been
1579 if (from
< end
&& SYNTAX_COMEND_FIRST (prev
)
1580 && SYNTAX_COMEND_SECOND (FETCH_CHAR (from
))
1581 && SYNTAX_COMMENT_STYLE (prev
) == state
.comstyle
)
1582 /* Only terminate the comment section if the end-comment
1583 sequence of the same style as the start sequence has
1584 been encountered. */
1587 state
.incomment
= 0;
1588 state
.comstyle
= 0; /* reset the comment style */
1592 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
1594 /* curlevel++->last ran into compiler bug on Apollo */
1595 curlevel
->last
= from
- 1;
1596 if (++curlevel
== endlevel
)
1597 error ("Nesting too deep for parser");
1598 curlevel
->prev
= -1;
1599 curlevel
->last
= -1;
1600 if (targetdepth
== depth
) goto done
;
1605 if (depth
< mindepth
)
1607 if (curlevel
!= levelstart
)
1609 curlevel
->prev
= curlevel
->last
;
1610 if (targetdepth
== depth
) goto done
;
1614 if (stopbefore
) goto stop
; /* this arg means stop at sexp start */
1615 curlevel
->last
= from
- 1;
1616 state
.instring
= FETCH_CHAR (from
- 1);
1620 if (from
>= end
) goto done
;
1621 if (FETCH_CHAR (from
) == state
.instring
) break;
1622 switch (SWITCH_ENUM_CAST (SYNTAX (FETCH_CHAR (from
))))
1627 startquotedinstring
:
1628 if (from
>= end
) goto endquoted
;
1632 state
.instring
= -1;
1633 curlevel
->prev
= curlevel
->last
;
1643 stop
: /* Here if stopping before start of sexp. */
1644 from
--; /* We have just fetched the char that starts it; */
1645 goto done
; /* but return the position before it. */
1650 state
.depth
= depth
;
1651 state
.mindepth
= mindepth
;
1652 state
.thislevelstart
= curlevel
->prev
;
1653 state
.prevlevelstart
1654 = (curlevel
== levelstart
) ? -1 : (curlevel
- 1)->last
;
1655 state
.location
= from
;
1661 /* This comment supplies the doc string for parse-partial-sexp,
1662 for make-docfile to see. We cannot put this in the real DEFUN
1663 due to limits in the Unix cpp.
1665 DEFUN ("parse-partial-sexp", Ffoo, Sfoo, 2, 6, 0,
1666 "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\
1667 Parsing stops at TO or when certain criteria are met;\n\
1668 point is set to where parsing stops.\n\
1669 If fifth arg STATE is omitted or nil,\n\
1670 parsing assumes that FROM is the beginning of a function.\n\
1671 Value is a list of eight elements describing final state of parsing:\n\
1672 0. depth in parens.\n\
1673 1. character address of start of innermost containing list; nil if none.\n\
1674 2. character address of start of last complete sexp terminated.\n\
1675 3. non-nil if inside a string.\n\
1676 (it is the character that will terminate the string.)\n\
1677 4. t if inside a comment.\n\
1678 5. t if following a quote character.\n\
1679 6. the minimum paren-depth encountered during this scan.\n\
1680 7. t if in a comment of style `b'.\n\
1681 If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\
1682 in parentheses becomes equal to TARGETDEPTH.\n\
1683 Fourth arg STOPBEFORE non-nil means stop when come to\n\
1684 any character that starts a sexp.\n\
1685 Fifth arg STATE is an eight-list like what this function returns.\n\
1686 It is used to initialize the state of the parse. Its second and third
1687 elements are ignored.
1688 Sixth args COMMENTSTOP non-nil means stop at the start of a comment.")
1689 (from, to, targetdepth, stopbefore, state, commentstop)
1692 DEFUN ("parse-partial-sexp", Fparse_partial_sexp
, Sparse_partial_sexp
, 2, 6, 0,
1693 0 /* See immediately above */)
1694 (from
, to
, targetdepth
, stopbefore
, oldstate
, commentstop
)
1695 Lisp_Object from
, to
, targetdepth
, stopbefore
, oldstate
, commentstop
;
1697 struct lisp_parse_state state
;
1700 if (!NILP (targetdepth
))
1702 CHECK_NUMBER (targetdepth
, 3);
1703 target
= XINT (targetdepth
);
1706 target
= -100000; /* We won't reach this depth */
1708 validate_region (&from
, &to
);
1709 scan_sexps_forward (&state
, XINT (from
), XINT (to
),
1710 target
, !NILP (stopbefore
), oldstate
,
1711 !NILP (commentstop
));
1713 SET_PT (state
.location
);
1715 return Fcons (make_number (state
.depth
),
1716 Fcons (state
.prevlevelstart
< 0 ? Qnil
: make_number (state
.prevlevelstart
),
1717 Fcons (state
.thislevelstart
< 0 ? Qnil
: make_number (state
.thislevelstart
),
1718 Fcons (state
.instring
>= 0 ? make_number (state
.instring
) : Qnil
,
1719 Fcons (state
.incomment
? Qt
: Qnil
,
1720 Fcons (state
.quoted
? Qt
: Qnil
,
1721 Fcons (make_number (state
.mindepth
),
1722 Fcons (state
.comstyle
? Qt
: Qnil
,
1731 /* This has to be done here, before we call Fmake_char_table. */
1732 Qsyntax_table
= intern ("syntax-table");
1733 staticpro (&Qsyntax_table
);
1735 /* Intern this now in case it isn't already done.
1736 Setting this variable twice is harmless.
1737 But don't staticpro it here--that is done in alloc.c. */
1738 Qchar_table_extra_slots
= intern ("char-table-extra-slots");
1740 /* Now we are ready to set up this property, so we can
1741 create syntax tables. */
1742 Fput (Qsyntax_table
, Qchar_table_extra_slots
, make_number (0));
1744 temp
= Fcons (make_number ((int) Swhitespace
), Qnil
);
1746 Vstandard_syntax_table
= Fmake_char_table (Qsyntax_table
, temp
);
1748 temp
= Fcons (make_number ((int) Sword
), Qnil
);
1749 for (i
= 'a'; i
<= 'z'; i
++)
1750 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, i
, temp
);
1751 for (i
= 'A'; i
<= 'Z'; i
++)
1752 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, i
, temp
);
1753 for (i
= '0'; i
<= '9'; i
++)
1754 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, i
, temp
);
1756 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '$', temp
);
1757 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '%', temp
);
1759 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '(',
1760 Fcons (make_number (Sopen
), make_number (')')));
1761 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, ')',
1762 Fcons (make_number (Sclose
), make_number ('(')));
1763 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '[',
1764 Fcons (make_number (Sopen
), make_number (']')));
1765 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, ']',
1766 Fcons (make_number (Sclose
), make_number ('[')));
1767 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '{',
1768 Fcons (make_number (Sopen
), make_number ('}')));
1769 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '}',
1770 Fcons (make_number (Sclose
), make_number ('{')));
1771 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '"',
1772 Fcons (make_number ((int) Sstring
), Qnil
));
1773 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, '\\',
1774 Fcons (make_number ((int) Sescape
), Qnil
));
1776 temp
= Fcons (make_number ((int) Ssymbol
), Qnil
);
1777 for (i
= 0; i
< 10; i
++)
1778 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, "_-+*/&|<>="[i
], temp
);
1780 temp
= Fcons (make_number ((int) Spunct
), Qnil
);
1781 for (i
= 0; i
< 12; i
++)
1782 SET_RAW_SYNTAX_ENTRY (Vstandard_syntax_table
, ".,;:?!#@~^'`"[i
], temp
);
1787 Qsyntax_table_p
= intern ("syntax-table-p");
1788 staticpro (&Qsyntax_table_p
);
1790 DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments
,
1791 "Non-nil means `forward-sexp', etc., should treat comments as whitespace.");
1793 words_include_escapes
= 0;
1794 DEFVAR_BOOL ("words-include-escapes", &words_include_escapes
,
1795 "Non-nil means `forward-word', etc., should treat escape chars part of words.");
1797 defsubr (&Ssyntax_table_p
);
1798 defsubr (&Ssyntax_table
);
1799 defsubr (&Sstandard_syntax_table
);
1800 defsubr (&Scopy_syntax_table
);
1801 defsubr (&Sset_syntax_table
);
1802 defsubr (&Schar_syntax
);
1803 defsubr (&Smatching_paren
);
1804 defsubr (&Smodify_syntax_entry
);
1805 defsubr (&Sdescribe_syntax
);
1807 defsubr (&Sforward_word
);
1809 defsubr (&Sforward_comment
);
1810 defsubr (&Sscan_lists
);
1811 defsubr (&Sscan_sexps
);
1812 defsubr (&Sbackward_prefix_chars
);
1813 defsubr (&Sparse_partial_sexp
);