home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / lucid / lemacs-19.6 / src / syntax.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-13  |  49.3 KB  |  1,889 lines

  1. /* GNU Emacs routines to deal with syntax tables; also word and list parsing.
  2.    Copyright (C) 1985-1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  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)
  9. any later version.
  10.  
  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.
  15.  
  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, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20.  
  21. #include "config.h"
  22. #include <ctype.h>
  23. #include "lisp.h"
  24. #include "commands.h"
  25. #include "buffer.h"
  26. #include "syntax.h"
  27.  
  28. Lisp_Object Qsyntax_table_p;
  29.  
  30. int words_include_escapes;
  31.  
  32. extern int zmacs_region_stays;
  33.  
  34. /* There is an alist of syntax tables: names (strings) vs obarrays. */
  35.  
  36. DEFUN ("syntax-table-p", Fsyntax_table_p, Ssyntax_table_p, 1, 1, 0,
  37.   "Return t if ARG is a syntax table.\n\
  38. Any vector of 256 elements will do.")
  39.   (obj)
  40.      Lisp_Object obj;
  41. {
  42.   if (VECTORP (obj) && XVECTOR (obj)->size == 0400)
  43.     return Qt;
  44.   return Qnil;
  45. }
  46.  
  47. static Lisp_Object
  48. check_syntax_table (obj)
  49.      Lisp_Object obj;
  50. {
  51.   register Lisp_Object tem;
  52.   while (tem = Fsyntax_table_p (obj),
  53.      NILP (tem))
  54.     obj = wrong_type_argument (Qsyntax_table_p, obj);
  55.   return obj;
  56. }   
  57.  
  58.  
  59. DEFUN ("syntax-table", Fsyntax_table, Ssyntax_table, 0, 0, 0,
  60.   "Return the current syntax table.\n\
  61. This is the one specified by the current buffer.")
  62.   ()
  63. {
  64.   return current_buffer->syntax_table;
  65. }
  66.  
  67. DEFUN ("standard-syntax-table", Fstandard_syntax_table,
  68.    Sstandard_syntax_table, 0, 0, 0,
  69.   "Return the standard syntax table.\n\
  70. This is the one used for new buffers.")
  71.   ()
  72. {
  73.   return Vstandard_syntax_table;
  74. }
  75.  
  76. DEFUN ("copy-syntax-table", Fcopy_syntax_table, Scopy_syntax_table, 0, 1, 0,
  77.   "Construct a new syntax table and return it.\n\
  78. It is a copy of the TABLE, which defaults to the standard syntax table.")
  79.   (table)
  80.      Lisp_Object table;
  81. {
  82.   Lisp_Object size, val;
  83.   XFASTINT (size) = 0400;
  84.   XFASTINT (val) = 0;
  85.   val = Fmake_vector (size, val);
  86.   if (!NILP (table))
  87.     table = check_syntax_table (table);
  88.   else if (NILP (Vstandard_syntax_table))
  89.     /* Can only be null during initialization */
  90.     return val;
  91.   else table = Vstandard_syntax_table;
  92.  
  93.   memcpy (XVECTOR (val)->contents, XVECTOR (table)->contents,
  94.       0400 * sizeof (Lisp_Object));
  95.   return val;
  96. }
  97.  
  98. DEFUN ("set-syntax-table", Fset_syntax_table, Sset_syntax_table, 1, 1, 0,
  99.   "Select a new syntax table for the current buffer.\n\
  100. One argument, a syntax table.")
  101.   (table)
  102.      Lisp_Object table;
  103. {
  104.   table = check_syntax_table (table);
  105.   current_buffer->syntax_table = table;
  106.   /* Indicate that this buffer now has a specified syntax table.  */
  107.   current_buffer->local_var_flags |= buffer_local_flags.syntax_table;
  108.   return table;
  109. }
  110.  
  111. /* Convert a letter which signifies a syntax code
  112.  into the code it signifies.
  113.  This is used by modify-syntax-entry, and other things. */
  114.  
  115. unsigned char syntax_spec_code[0400] =
  116.   { 0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
  117.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
  118.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
  119.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
  120.     (char) Swhitespace, 0377, (char) Sstring, 0377,
  121.         (char) Smath, 0377, 0377, (char) Squote,
  122.     (char) Sopen, (char) Sclose, 0377, 0377,
  123.     0377, (char) Swhitespace, (char) Spunct, (char) Scharquote,
  124.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
  125.     0377, 0377, 0377, 0377,
  126.     (char) Scomment, 0377, (char) Sendcomment, 0377,
  127.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,   /* @, A, ... */
  128.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
  129.     0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
  130.     0377, 0377, 0377, 0377, (char) Sescape, 0377, 0377, (char) Ssymbol,
  131.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,   /* `, a, ... */
  132.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377,
  133.     0377, 0377, 0377, 0377, 0377, 0377, 0377, (char) Sword,
  134.     0377, 0377, 0377, 0377, 0377, 0377, 0377, 0377
  135.   };
  136.  
  137. /* Indexed by syntax code, give the letter that describes it. */
  138.  
  139. unsigned char syntax_code_spec[13] =
  140.   {
  141.     ' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>'
  142.   };
  143.  
  144. DEFUN ("char-syntax", Fchar_syntax, Schar_syntax, 1, 1, 0,
  145.   "Return the syntax code of CHAR, described by a character.\n\
  146. For example, if CHAR is a word constituent, the character `?w' is returned.\n\
  147. The characters that correspond to various syntax codes\n\
  148. are listed in the documentation of `modify-syntax-entry'.")
  149.   (ch)
  150.      Lisp_Object ch;
  151. {
  152.   CHECK_FIXNUM (ch, 0);
  153.   return make_number (syntax_code_spec[(int) SYNTAX (0xFF & XINT (ch))]);
  154. }
  155.  
  156. #ifdef NEW_SYNTAX
  157.  
  158. /* This comment supplies the doc string for modify-syntax-entry,
  159.    for make-docfile to see.  We cannot put this in the real DEFUN
  160.    due to limits in the Unix cpp.
  161.  
  162. DEFUN ("modify-syntax-entry", foo, bar, 0, 0, 0,
  163.   "Set syntax for character CHAR according to string S.\n\
  164. The syntax is changed only for table TABLE, which defaults to\n\
  165.  the current buffer's syntax table.\n\
  166. The first character of S should be one of the following:\n\
  167.   Space    whitespace syntax.    w   word constituent.\n\
  168.   _        symbol constituent.   .   punctuation.\n\
  169.   (        open-parenthesis.     )   close-parenthesis.\n\
  170.   \"        string quote.         \\   character-quote.\n\
  171.   $        paired delimiter.     '   expression quote or prefix operator.\n\
  172.   <       comment starter.     >   comment ender.\n\
  173. Only single-character comment start and end sequences are represented thus.\n\
  174. Two-character sequences are represented as described below.\n\
  175. The second character of S is the matching parenthesis,\n\
  176.  used only if the first character is `(' or `)'.\n\
  177. Any additional characters are flags.\n\
  178. Defined flags are the characters 1, 2, 3, 4, 5, 6, 7, 8, p, a, and b.\n\
  179.  1 means C is the first of a two-char comment start sequence of style a.\n\
  180.  2 means C is the second character of such a sequence.\n\
  181.  3 means C is the first of a two-char comment end sequence of style a.\n\
  182.  4 means C is the second character of such a sequence.\n\
  183.  5 means C is the first of a two-char comment start sequence of style b.\n\
  184.  6 means C is the second character of such a sequence.\n\
  185.  7 means C is the first of a two-char comment end sequence of style b.\n\
  186.  8 means C is the second character of such a sequence.\n\
  187.  p means C is a prefix character for `backward-prefix-chars';\n\
  188.    such characters are treated as whitespace when they occur\n\
  189.    between expressions.\n\
  190.  a means C is comment starter or comment ender for comment style a (default)\n\
  191.  b means C is comment starter or comment ender for comment style b.")
  192.   (c, newentry, syntax_table)
  193. */
  194.  
  195. #else /* !NEW_SYNTAX */
  196.  
  197. /* This comment supplies the doc string for modify-syntax-entry,
  198.    for make-docfile to see.  We cannot put this in the real DEFUN
  199.    due to limits in the Unix cpp.
  200.  
  201. ****DEFUN ("modify-syntax-entry", foo, bar, 0, 0, 0,
  202.   "Set syntax for character CHAR according to string S.\n\
  203. The syntax is changed only for table TABLE, which defaults to\n\
  204.  the current buffer's syntax table.\n\
  205. The first character of S should be one of the following:\n\
  206.   Space    whitespace syntax.    w   word constituent.\n\
  207.   _        symbol constituent.   .   punctuation.\n\
  208.   (        open-parenthesis.     )   close-parenthesis.\n\
  209.   \"        string quote.         \\   character-quote.\n\
  210.   $        paired delimiter.     '   expression quote or prefix operator.\n\
  211.   <       comment starter.     >   comment ender.\n\
  212. Only single-character comment start and end sequences are represented thus.\n\
  213. Two-character sequences are represented as described below.\n\
  214. The second character of S is the matching parenthesis,\n\
  215.  used only if the first character is `(' or `)'.\n\
  216. Any additional characters are flags.\n\
  217. Defined flags are the characters 1, 2, 3, 4, and p.\n\
  218.  1 means C is the start of a two-char comment start sequence.\n\
  219.  2 means C is the second character of such a sequence.\n\
  220.  3 means C is the start of a two-char comment end sequence.\n\
  221.  4 means C is the second character of such a sequence.\n\
  222.  p means C is a prefix character for `backward-prefix-chars';
  223.    such characters are treated as whitespace when they occur
  224.    between expressions.")
  225.   (c, newentry, syntax_table)
  226. */
  227. #endif /* NEW_SYNTAX */
  228.  
  229. DEFUN ("modify-syntax-entry", Fmodify_syntax_entry, Smodify_syntax_entry, 2, 3, 
  230.   /* I really don't know why this is interactive
  231.      help-form should at least be made useful whilst reading the second arg
  232.    */
  233.   "cSet syntax for character: \nsSet syntax for %s to: ",
  234.   0 /* See immediately above */)
  235.   (c, newentry, syntax_table)
  236.      Lisp_Object c, newentry, syntax_table;
  237. {
  238.   register unsigned char *p, match;
  239.   register enum syntaxcode code;
  240.   Lisp_Object val;
  241.  
  242. #ifdef NEW_SYNTAX
  243.   int b_flag_seen_p = 0;
  244. #endif /* NEW_SYNTAX */
  245.  
  246.   CHECK_FIXNUM (c, 0);
  247.   CHECK_STRING (newentry, 1);
  248.   if (NILP (syntax_table))
  249.     syntax_table = current_buffer->syntax_table;
  250.   else
  251.     syntax_table = check_syntax_table (syntax_table);
  252.  
  253.   p = XSTRING (newentry)->data;
  254.   code = (enum syntaxcode) syntax_spec_code[*p++];
  255.   if (((int) code & 0377) == 0377)
  256.     error ("invalid syntax description letter: %c", c);
  257.  
  258.   match = *p;
  259.   if (match) p++;
  260.   if (match == ' ') match = 0;
  261.  
  262.   XFASTINT (val) = (match << 8) + (int) code;
  263.   
  264.   while (*p)
  265.     switch (*p++)
  266.       {
  267.  
  268. #ifdef NEW_SYNTAX
  269.  
  270.       case '1':
  271.     XFASTINT (val) |= SYNTAX_FIRST_OF_START_A << 16;
  272.     break;
  273.  
  274.       case '2':
  275.     XFASTINT (val) |= SYNTAX_SECOND_OF_START_A << 16;
  276.     break;
  277.  
  278.       case '3':
  279.     XFASTINT (val) |= SYNTAX_FIRST_OF_END_A << 16;
  280.     break;
  281.  
  282.       case '4':
  283.     XFASTINT (val) |= SYNTAX_SECOND_OF_END_A << 16;
  284.     break;
  285.  
  286.       case '5':
  287.     XFASTINT (val) |= SYNTAX_FIRST_OF_START_B << 16;
  288.     break;
  289.  
  290.       case '6':
  291.     XFASTINT (val) |= SYNTAX_SECOND_OF_START_B << 16;
  292.     break;
  293.  
  294.       case '7':
  295.     XFASTINT (val) |= SYNTAX_FIRST_OF_END_B << 16;
  296.     break;
  297.  
  298.       case '8':
  299.     XFASTINT (val) |= SYNTAX_SECOND_OF_END_B << 16;
  300.     break;
  301.  
  302.       case 'a':
  303.     if (code == Scomment)
  304.       XFASTINT (val) |= SYNTAX_FIRST_OF_START_A << 16;
  305.     else if (code == Sendcomment)
  306.       XFASTINT (val) |= SYNTAX_FIRST_OF_END_A << 16;
  307.  
  308.     break;
  309.  
  310.       case 'b':
  311.     if (code == Scomment)
  312.       XFASTINT (val) |= SYNTAX_FIRST_OF_START_B << 16;
  313.     else if (code == Sendcomment)
  314.       XFASTINT (val) |= SYNTAX_FIRST_OF_END_B << 16;
  315.  
  316.     b_flag_seen_p = 1;
  317.     break;
  318.  
  319.       case 'p':
  320.     XFASTINT (val) |= 1 << 24;
  321.     break;
  322.  
  323. #else /* !NEW_SYNTAX */
  324.  
  325.       case '1':
  326.     XFASTINT (val) |= 1 << 16;
  327.     break;
  328.  
  329.       case '2':
  330.     XFASTINT (val) |= 1 << 17;
  331.     break;
  332.  
  333.       case '3':
  334.     XFASTINT (val) |= 1 << 18;
  335.     break;
  336.  
  337.       case '4':
  338.     XFASTINT (val) |= 1 << 19;
  339.     break;
  340.  
  341.       case 'p':
  342.     XFASTINT (val) |= 1 << 20;
  343.     break;
  344.  
  345. #endif /* NEW_SYNTAX */
  346.  
  347.       }
  348.     
  349. #ifdef NEW_SYNTAX
  350.  
  351.   /* default single char style is a if b has not been seen */
  352.   if (!b_flag_seen_p)
  353.     if (code == Scomment)
  354.       XFASTINT (val) |= SYNTAX_FIRST_OF_START_A << 16;
  355.     else if (code == Sendcomment)
  356.       XFASTINT (val) |= SYNTAX_FIRST_OF_END_A << 16;
  357.  
  358. #endif /* NEW_SYNTAX */
  359.  
  360.   XVECTOR (syntax_table)->contents[0xFF & XINT (c)] = val;
  361.  
  362.   return Qnil;
  363. }
  364.  
  365. /* Dump syntax table to buffer in human-readable format */
  366.  
  367. static void
  368. describe_syntax (value)
  369.     Lisp_Object value;
  370. {
  371.   register enum syntaxcode code;
  372.   char desc, match, start1, start2, end1, end2, prefix;
  373.   char str[2];
  374. #ifdef NEW_SYNTAX
  375.   char start1b, start2b, end1b, end2b;
  376. #endif /* NEW_SYNTAX */
  377.  
  378.   Findent_to (make_number (16), make_number (1));
  379.  
  380.   if (!FIXNUMP (value))
  381.     {
  382.       insert_string ("invalid");
  383.       return;
  384.     }
  385.  
  386.   code = (enum syntaxcode) (XINT (value) & 0377);
  387.   match = (XINT (value) >> 8) & 0377;
  388.  
  389. #ifdef NEW_SYNTAX
  390.  
  391.   start1 = (XINT (value) >> 16) & SYNTAX_FIRST_OF_START_A;
  392.   start2 = (XINT (value) >> 16) & SYNTAX_SECOND_OF_START_A;
  393.   end1 = (XINT (value) >> 16) & SYNTAX_FIRST_OF_END_A;
  394.   end2 = (XINT (value) >> 16) & SYNTAX_SECOND_OF_END_A;
  395.   start1b = (XINT (value) >> 16) & SYNTAX_FIRST_OF_START_B;
  396.   start2b = (XINT (value) >> 16) & SYNTAX_SECOND_OF_START_B;
  397.   end1b = (XINT (value) >> 16) & SYNTAX_FIRST_OF_END_B;
  398.   end2b = (XINT (value) >> 16) & SYNTAX_SECOND_OF_END_B;
  399.   
  400.   prefix = (XINT (value) >> 24) & 1;
  401.  
  402. #else /* !NEW_SYNTAX */
  403.  
  404.   start1 = (XINT (value) >> 16) & 1;
  405.   start2 = (XINT (value) >> 17) & 1;
  406.   end1 = (XINT (value) >> 18) & 1;
  407.   end2 = (XINT (value) >> 19) & 1;
  408.   prefix = (XINT (value) >> 20) & 1;
  409.  
  410. #endif /* NEW_SYNTAX */
  411.  
  412.   if ((int) code < 0 || (int) code >= (int) Smax)
  413.     {
  414.       insert_string ("invalid");
  415.       return;
  416.     }
  417.   desc = syntax_code_spec[(int) code];
  418.  
  419.   str[0] = desc, str[1] = 0;
  420.   insert_raw_string (str, 1);
  421.  
  422.   str[0] = match ? match : ' ';
  423.   insert_raw_string (str, 1);
  424.  
  425. #ifdef NEW_SYNTAX
  426.  
  427.   if (start1)
  428.     if (code==Scomment)
  429.       insert_raw_string ("a", 1);
  430.     else
  431.       insert_raw_string ("1", 1);
  432.  
  433.   if (start2)
  434.     insert_raw_string ("2", 1);
  435.  
  436.   if (end1)
  437.     if (code==Sendcomment)
  438.       insert_raw_string ("a", 1);
  439.     else
  440.       insert_raw_string ("3", 1);
  441.  
  442.   if (end2)
  443.     insert_raw_string ("4", 1);
  444.  
  445.   if (start1b)
  446.     if (code==Scomment)
  447.       insert_raw_string ("b", 1);
  448.     else
  449.       insert_raw_string ("5", 1);
  450.  
  451.   if (start2b)
  452.     insert_raw_string ("6", 1);
  453.  
  454.   if (end1b)
  455.     if (code==Sendcomment)
  456.       insert_raw_string ("b", 1);
  457.     else
  458.       insert_raw_string ("7", 1);
  459.  
  460.   if (end2b)
  461.     insert_raw_string ("8", 1);
  462.  
  463. #else /* !NEW_SYNTAX */
  464.  
  465.   if (start1)
  466.     insert_raw_string ("1", 1);
  467.   if (start2)
  468.     insert_raw_string ("2", 1);
  469.  
  470.   if (end1)
  471.     insert_raw_string ("3", 1);
  472.   if (end2)
  473.     insert_raw_string ("4", 1);
  474.  
  475. #endif /* NEW_SYNTAX */
  476.  
  477.   if (prefix)
  478.     insert_raw_string ("p", 1);
  479.  
  480.   insert_string ("\twhich means: ");
  481.  
  482. #ifdef SWITCH_ENUM_BUG
  483.   switch ((int) code)
  484. #else
  485.   switch (code)
  486. #endif
  487.     {
  488.     case Swhitespace:
  489.       insert_string ("whitespace"); break;
  490.     case Spunct:
  491.       insert_string ("punctuation"); break;
  492.     case Sword:
  493.       insert_string ("word"); break;
  494.     case Ssymbol:
  495.       insert_string ("symbol"); break;
  496.     case Sopen:
  497.       insert_string ("open"); break;
  498.     case Sclose:
  499.       insert_string ("close"); break;
  500.     case Squote:
  501.       insert_string ("quote"); break;
  502.     case Sstring:
  503.       insert_string ("string"); break;
  504.     case Smath:
  505.       insert_string ("math"); break;
  506.     case Sescape:
  507.       insert_string ("escape"); break;
  508.     case Scharquote:
  509.       insert_string ("charquote"); break;
  510.     case Scomment:
  511.       insert_string ("comment"); break;
  512.     case Sendcomment:
  513.       insert_string ("endcomment"); break;
  514.     default:
  515.       insert_string ("invalid");
  516.       return;
  517.     }
  518.  
  519.   if (match)
  520.     {
  521.       insert_string (", matches ");
  522.       
  523.       str[0] = match, str[1] = 0;
  524.       insert_raw_string (str, 1);
  525.     }
  526.  
  527. #ifdef NEW_SYNTAX
  528.  
  529.   if (start1)
  530.     if (code==Scomment)
  531.       insert_string (",\n\t  starts comment style a");
  532.     else
  533.       insert_string (",\n\t  is the first char of a style a, comment-start sequence");
  534.  
  535.   if (start2)
  536.     insert_string (",\n\t  is the second char of a style a, comment-start sequence");
  537.  
  538.   if (end1)
  539.     if (code==Sendcomment)
  540.       insert_string (",\n\t  ends comment style a");
  541.     else
  542.       insert_string (",\n\t  is the first char of a style a, comment-end sequence");
  543.  
  544.   if (end2)
  545.     insert_string (",\n\t  is the second char of a style a, comment-end sequence");
  546.  
  547.   if (start1b)
  548.     if (code==Scomment)
  549.       insert_string (",\n\t  starts comment style b");
  550.     else
  551.       insert_string (",\n\t  is the first char of a style b, comment-start sequence");
  552.  
  553.   if (start2b)
  554.     insert_string (",\n\t  is the second char of a style b, comment-start sequence");
  555.  
  556.   if (end1b)
  557.     if (code==Sendcomment)
  558.       insert_string (",\n\t  ends comment style b");
  559.     else
  560.       insert_string (",\n\t  is the first char of a style b, comment-end sequence");
  561.  
  562.   if (end2b)
  563.     insert_string (",\n\t  is the second char of a style b, comment-end sequence");
  564.  
  565. #else /* !NEW_SYNTAX */
  566.  
  567.   if (start1)
  568.     insert_string (",\n\t  is the first character of a comment-start sequence");
  569.   if (start2)
  570.     insert_string (",\n\t  is the second character of a comment-start sequence");
  571.  
  572.   if (end1)
  573.     insert_string (",\n\t  is the first character of a comment-end sequence");
  574.   if (end2)
  575.     insert_string (",\n\t  is the second character of a comment-end sequence");
  576.  
  577. #endif /* NEW_SYNTAX */
  578.  
  579.   if (prefix)
  580.     insert_string (",\n\t  is a prefix character for `backward-prefix-chars'");
  581.  
  582.   insert_string ("\n");
  583. }
  584.  
  585.  
  586. static Lisp_Object
  587. describe_syntax_1 (vector)
  588.      Lisp_Object vector;
  589. {
  590.   struct buffer *old = current_buffer;
  591.   int i, size = XVECTOR (vector)->size, range_start = 0;
  592.   Lisp_Object string, current_code = XVECTOR (vector)->contents[0];
  593.   int top;
  594.  
  595.   internal_set_buffer (XBUFFER (Vstandard_output));
  596.  
  597.   top = ((NILP (current_buffer->ctl_arrow) ||
  598.       EQ (current_buffer->ctl_arrow, Qt))
  599.      ? size : (FIXNUMP (current_buffer->ctl_arrow)
  600.            ? XINT (current_buffer->ctl_arrow)
  601.            : 0240));
  602.   for (i = 1; i <= size; i++)
  603.     {
  604.       QUIT;
  605.  
  606.       if ((i == size ) || 
  607.       (XINT (current_code) != XINT (XVECTOR (vector)->contents[i])))
  608.     /* end of vector or end of range */
  609.     {
  610.       unsigned char c = range_start;
  611.       if (c >= top)
  612.         insert_raw_string ((char *) &c, 1);
  613.       else
  614.         {
  615.           string = Fsingle_key_description (make_number (range_start));
  616.           insert_raw_string ((char *) XSTRING (string)->data,
  617.                  XSTRING (string)->size);
  618.         }
  619.       
  620.       if (i - range_start > 1)    /* Really was a range */
  621.         {
  622.           insert_string (" .. ");
  623.           c = i - 1;
  624.           if (c >= top)
  625.         insert_raw_string ((char *) &c, 1);
  626.           else
  627.         {
  628.           string = Fsingle_key_description (make_number (i - 1));
  629.           insert_raw_string ((char *) XSTRING (string)->data,
  630.                      XSTRING (string)->size);
  631.         }
  632.           describe_syntax (current_code);
  633.         }
  634.       describe_syntax (current_code);
  635.     }
  636.       range_start = i;
  637.       if (i < size)
  638.     current_code = XVECTOR (vector)->contents[i];
  639.     }
  640.  
  641.   internal_set_buffer (old);
  642.   return Qnil;
  643. }
  644.  
  645. DEFUN ("describe-syntax", Fdescribe_syntax, Sdescribe_syntax, 0, 0, "",
  646.   "Describe the syntax specifications in the syntax table.\n\
  647. The descriptions are inserted in a buffer, which is then displayed.")
  648.      ()
  649. {
  650.   internal_with_output_to_temp_buffer
  651.     ("*Help*", describe_syntax_1, current_buffer->syntax_table, Qnil);
  652.   
  653.   return Qnil;
  654. }
  655.  
  656. /* Return the position across COUNT words from FROM.
  657.    If that many words cannot be found before the end of the buffer, return 0.
  658.    COUNT negative means scan backward and stop at word beginning.  */
  659.  
  660. int
  661. scan_words (from, count)
  662.      register int from, count;
  663. {
  664.   register int beg = BEGV;
  665.   register int end = ZV;
  666.   register enum syntaxcode code;
  667.   
  668.   immediate_quit = 1;
  669.   QUIT;
  670.   
  671.   while (count > 0)
  672.     {
  673.       while (1)
  674.     {
  675.       if (from == end)
  676.         {
  677.           immediate_quit = 0;
  678.           return 0;
  679.         }
  680.       code = SYNTAX (CHAR_AT (from));
  681.       if (words_include_escapes
  682.           && (code == Sescape || code == Scharquote))
  683.         break;
  684.       if (code == Sword)
  685.         break;
  686.       from++;
  687.     }
  688.       while (1)
  689.     {
  690.       if (from == end) break;
  691.       code = SYNTAX (CHAR_AT (from));
  692.       if (!(words_include_escapes
  693.         && (code == Sescape || code == Scharquote)))
  694.         if (code != Sword)
  695.           break;
  696.       from++;
  697.     }
  698.       count--;
  699.     }
  700.   while (count < 0)
  701.     {
  702.       while (1)
  703.     {
  704.       if (from == beg)
  705.         {
  706.           immediate_quit = 0;
  707.           return 0;
  708.         }
  709.       code = SYNTAX (CHAR_AT (from - 1));
  710.       if (words_include_escapes
  711.           && (code == Sescape || code == Scharquote))
  712.         break;
  713.       if (code == Sword)
  714.         break;
  715.       from--;
  716.     }
  717.       while (1)
  718.     {
  719.       if (from == beg) break;
  720.       code = SYNTAX (CHAR_AT (from - 1));
  721.       if (!(words_include_escapes
  722.         && (code == Sescape || code == Scharquote)))
  723.         if (code != Sword)
  724.           break;
  725.       from--;
  726.     }
  727.       count++;
  728.     }
  729.  
  730.   immediate_quit = 0;
  731.  
  732.   return from;
  733. }
  734.  
  735. DEFUN ("forward-word", Fforward_word, Sforward_word, 1, 1, "p",
  736.   "Move point forward ARG words (backward if ARG is negative).\n\
  737. Normally returns t.\n\
  738. If an edge of the buffer is reached, point is left there\n\
  739. and nil is returned.")
  740.   (count)
  741.      Lisp_Object count;
  742. {
  743.   int val;
  744.   CHECK_FIXNUM (count, 0);
  745.  
  746.   if (!(val = scan_words (point, XINT (count))))
  747.     {
  748.       SET_PT (XINT (count) > 0 ? ZV : BEGV);
  749.       return Qnil;
  750.     }
  751.   SET_PT (val);
  752.   zmacs_region_stays = 1;
  753.   return Qt;
  754. }
  755.  
  756. int parse_sexp_ignore_comments;
  757.  
  758. static int char_quoted (int);
  759.  
  760. #ifdef NEW_SYNTAX
  761.  
  762. static int 
  763. find_end_of_comment (from, stop, comstyle)
  764.      int from, stop, comstyle;
  765. {
  766.   register int c;
  767.   register enum syntaxcode code;
  768.   int stylemask = (comstyle ? SYNTAX_COMMENT_STYLE_B : SYNTAX_COMMENT_STYLE_A);
  769.   int stylesmatch;
  770.  
  771.   while (from < stop)
  772.     {
  773.       c = CHAR_AT (from);
  774.       code = SYNTAX (c);
  775.       stylesmatch = (comstyle ? SYNTAX_SINGLE_CHAR_STYLE_B (c)
  776.              : SYNTAX_SINGLE_CHAR_STYLE_A (c));
  777.  
  778.       /* ignore 1 char comment sequences with non-matching comstyle */
  779.       if (code == Sendcomment && stylesmatch && !char_quoted (from))
  780.     break;
  781.  
  782.       from++;
  783.       if (from < stop && SYNTAX_PREFIX (c))
  784.     { from++; continue; }
  785.  
  786.       /* only break on comment end sequence with matching comstyle */
  787.       if (from < stop && SYNTAX_END_SEQUENCE (c, CHAR_AT (from), stylemask))
  788.     break;
  789.     }
  790.   return from;
  791. }
  792.  
  793.  
  794. static int 
  795. find_start_of_comment (from, stop, comstyle)
  796.      int from, stop, comstyle;
  797. {
  798.   /* Look back, counting the parity of string-quotes,
  799.      and recording the comment-starters seen.
  800.      When we reach a safe place, assume that's not in a string;
  801.      then step the main scan to the earliest comment-starter seen
  802.      an even number of string quotes away from the safe place.
  803.      
  804.      OFROM[I] is position of the earliest comment-starter seen
  805.      which is I+2X quotes from the comment-end.
  806.      PARITY is current parity of quotes from the comment end.  */
  807.   {
  808.     int ofrom[2];
  809.     int parity = 0;
  810.     int stylesmatch;
  811.     int c;
  812.     enum syntaxcode code;
  813.     int matching_start_found=0;
  814.     
  815.     ofrom[0] = ofrom[1] = from;
  816.     
  817.     /* At beginning of range to scan, we're outside of strings;
  818.        that determines quote parity to the comment-end.  */
  819.     while (from != stop)
  820.       {
  821.     /* Move back and examine a character.  */
  822.     from--;
  823.     
  824.     c = CHAR_AT (from);
  825.     code = SYNTAX (c);
  826.     
  827.     /* check to see if this character is part of a comment sequence 
  828.        of the appropriate style. if so, record the style of the comment
  829.        found so that it can be matched later on */
  830.     if (code == Scomment || code == Sendcomment)
  831.       stylesmatch = (comstyle ? SYNTAX_SINGLE_CHAR_STYLE_B (c) :
  832.              SYNTAX_SINGLE_CHAR_STYLE_A (c));
  833.  
  834.     /* If this char is the second of a 2-char comment sequence,
  835.        back up and give the pair the appropriate syntax.  */
  836.     else if (from > stop && SYNTAX_START (CHAR_AT (from-1), c))
  837.       {
  838.         if (stylesmatch = SYNTAX_START_SEQUENCE 
  839.         (CHAR_AT (from-1), c, 
  840.          (comstyle ? SYNTAX_COMMENT_STYLE_B 
  841.           : SYNTAX_COMMENT_STYLE_A)))
  842.           from--;
  843.         code = Scomment;
  844.       }
  845.     else if (from > stop && SYNTAX_END (CHAR_AT (from-1), c))
  846.       {
  847.         if (stylesmatch = SYNTAX_END_SEQUENCE 
  848.         (CHAR_AT (from-1), c,
  849.          (comstyle ? SYNTAX_COMMENT_STYLE_B 
  850.           : SYNTAX_COMMENT_STYLE_A)))
  851.           from--;
  852.         code = Sendcomment;
  853.       }
  854.  
  855.     /* Ignore escaped characters.  */
  856.     if (char_quoted (from))
  857.       continue;
  858.     
  859.     /* Track parity of quotes between here and comment-end.  */
  860.     if (code == Sstring)
  861.       parity ^= 1;
  862.     
  863.     /* Record comment-starters according to that
  864.        quote-parity to the comment-end.  */
  865.     if (code == Scomment && stylesmatch)
  866.       {
  867.         ofrom[parity] = from;
  868.         matching_start_found = 1;
  869.       }
  870.     
  871.     /* If we come to another comment-end, assume it's not inside a 
  872.        string. note that if we've found a comment start of the matching
  873.        style, any subsequent preceding endcoment satisfies.
  874.        That determines the quote parity to the comment-end.  */
  875.     if (code == Sendcomment && 
  876.         (matching_start_found ? 1 : stylesmatch))
  877.       break;
  878.       }
  879.     return ofrom[parity];
  880.   }
  881. }
  882.  
  883.  
  884. DEFUN ("backward-syntactic-ws", Fbackward_syntactic_ws, Sbackward_syntactic_ws,
  885.   0, 0, 0,
  886.   "Move point backward over all syntactic whitespace.\n\
  887. This includes all chars with \"whitespace\" syntax (Space), and, if\n\
  888. parse-sexp-ignore-comments is non-nil, all characters within comments.")
  889.   ()
  890. {
  891.   int beg = BEGV;
  892.   register int pos = point;
  893.   int c;
  894.   enum syntaxcode code;
  895.   int comstyle;
  896.   int stylemask = SYNTAX_COMMENT_STYLE_B;
  897.  
  898.   while (pos > beg)
  899.     {
  900.       pos--;
  901.       if (char_quoted (pos))
  902.     { pos--; continue; }
  903.  
  904.       c = CHAR_AT (pos);
  905.       code = SYNTAX (c);
  906.  
  907.       if (code == Scomment || code == Sendcomment)
  908.     comstyle = SYNTAX_SINGLE_CHAR_STYLE_B (c);
  909.  
  910.       else if (pos > beg
  911.            && SYNTAX_END (CHAR_AT (pos-1), c)
  912.            && !char_quoted (pos-1)
  913.            && parse_sexp_ignore_comments)
  914.     {
  915.       code = Sendcomment;
  916.       comstyle = SYNTAX_END_SEQUENCE (CHAR_AT (pos-1), c, stylemask);
  917.       pos--;
  918.     }
  919.  
  920.       if (code == Sendcomment && parse_sexp_ignore_comments)
  921.     pos = find_start_of_comment (pos, beg, comstyle);
  922.  
  923.       else if (code != Swhitespace && 
  924.            SYNTAX (c) != Scomment &&
  925.            SYNTAX (c) != Sendcomment)
  926.     break;
  927.     }
  928.  
  929.   SET_PT (pos);
  930.   return Qnil;
  931. }
  932.  
  933. DEFUN ("forward-syntactic-ws", Fforward_syntactic_ws, Sforward_syntactic_ws,
  934.   0, 0, 0,
  935.   "Move point forward over all syntactic whitespace.\n\
  936. This includes all chars with \"whitespace\" syntax (Space), and, if\n\
  937. parse-sexp-ignore-comments is non-nil, all characters within comments.")
  938.   ()
  939. {
  940.   int end = ZV;
  941.   register int pos = point;
  942.   int c;
  943.   enum syntaxcode code;
  944.   int comstyle;
  945.   int stylemask = SYNTAX_COMMENT_STYLE_B;
  946.  
  947.   while (pos < end)
  948.     {
  949.       if (char_quoted (pos))
  950.     { pos++; continue; }
  951.  
  952.       c = CHAR_AT (pos);
  953.       code = SYNTAX (c);
  954.  
  955.       if (code == Scomment)
  956.     comstyle = SYNTAX_SINGLE_CHAR_STYLE_B (c);
  957.  
  958.       else if (pos < end
  959.            && SYNTAX_START (c, (CHAR_AT (pos+1)))
  960.            && !char_quoted (pos+1)
  961.            && parse_sexp_ignore_comments)
  962.     {
  963.       code = Scomment;
  964.       comstyle = SYNTAX_START_SEQUENCE (c, (CHAR_AT (pos+1)), stylemask);
  965.       pos++;
  966.     }
  967.  
  968.       if (code == Scomment && parse_sexp_ignore_comments)
  969.     pos = find_end_of_comment (pos, end, comstyle);
  970.  
  971.       else if (code != Swhitespace && 
  972.            SYNTAX (c) != Scomment && 
  973.            SYNTAX (c) != Sendcomment )
  974.     break;
  975.  
  976.       pos++;
  977.     }
  978.  
  979.   SET_PT (pos);
  980.   return Qnil;
  981. }
  982.  
  983. #endif /* NEW_SYNTAX */
  984.  
  985.  
  986. Lisp_Object
  987. scan_lists (from, count, depth, sexpflag)
  988.      register int from;
  989.      int count, depth, sexpflag;
  990. {
  991.   Lisp_Object val;
  992.   register int stop;
  993.   register int c;
  994.   char stringterm;
  995.   int quoted;
  996.   int mathexit = 0;
  997.   register enum syntaxcode code;
  998.   int min_depth = depth;    /* Err out if depth gets less than this. */
  999. #ifdef NEW_SYNTAX
  1000.   int comstyle;            /* for keeping track of comment style */
  1001.   int stylemask = SYNTAX_COMMENT_STYLE_B;
  1002. #endif /* NEW_SYNTAX */
  1003.  
  1004.   if (depth > 0) min_depth = 0;
  1005.  
  1006.   immediate_quit = 1;
  1007.   QUIT;
  1008.  
  1009.   while (count > 0)
  1010.     {
  1011.       stop = ZV;
  1012.       while (from < stop)
  1013.     {
  1014.       c = CHAR_AT (from);
  1015.       code = SYNTAX(c);
  1016.  
  1017.       from++;
  1018.  
  1019. #ifdef NEW_SYNTAX
  1020.       
  1021.       if (code == Scomment || code == Sendcomment)
  1022.         comstyle = SYNTAX_SINGLE_CHAR_STYLE_B (c);
  1023.  
  1024.       else if (from < stop
  1025.            && SYNTAX_START (c, (CHAR_AT (from)))
  1026.            && parse_sexp_ignore_comments)
  1027.         {
  1028.           code = Scomment;
  1029.           comstyle = SYNTAX_START_SEQUENCE(c, (CHAR_AT (from)), stylemask);
  1030.           from++;
  1031.         }
  1032.  
  1033. #else /* !NEW_SYNTAX */
  1034.  
  1035.       if (from < stop && SYNTAX_COMSTART_FIRST (c)
  1036.           && SYNTAX_COMSTART_SECOND (CHAR_AT (from))
  1037.           && parse_sexp_ignore_comments)
  1038.         code = Scomment, from++;
  1039.  
  1040. #endif /* NEW_SYNTAX */
  1041.  
  1042.       if (SYNTAX_PREFIX (c))
  1043.         continue;
  1044.  
  1045. #ifdef SWITCH_ENUM_BUG
  1046.       switch ((int) code)
  1047. #else
  1048.       switch (code)
  1049. #endif
  1050.         {
  1051.         case Sescape:
  1052.         case Scharquote:
  1053.           if (from == stop) goto lose;
  1054.           from++;
  1055.           /* treat following character as a word constituent */
  1056.         case Sword:
  1057.         case Ssymbol:
  1058.           if (depth || !sexpflag) break;
  1059.           /* This word counts as a sexp; return at end of it. */
  1060.           while (from < stop)
  1061.         {
  1062. #ifdef SWITCH_ENUM_BUG
  1063.           switch ((int) SYNTAX(CHAR_AT (from)))
  1064. #else
  1065.           switch (SYNTAX(CHAR_AT (from)))
  1066. #endif
  1067.             {
  1068.             case Scharquote:
  1069.             case Sescape:
  1070.               from++;
  1071.               if (from == stop) goto lose;
  1072.               break;
  1073.             case Sword:
  1074.             case Ssymbol:
  1075.             case Squote:
  1076.               break;
  1077.             default:
  1078.               goto done;
  1079.             }
  1080.           from++;
  1081.         }
  1082.           goto done;
  1083.  
  1084.         case Scomment:
  1085.           if (!parse_sexp_ignore_comments) break;
  1086. #ifdef NEW_SYNTAX
  1087.           from = find_end_of_comment (from, stop, comstyle);
  1088.           if (from == stop) goto done;
  1089. #else /* !NEW_SYNTAX */
  1090.           while (1)
  1091.         {
  1092.           if (from == stop) goto done;
  1093.           if (SYNTAX (c = CHAR_AT (from)) == Sendcomment)
  1094.             break;
  1095.           from++;
  1096.           if (from < stop && SYNTAX_COMEND_FIRST (c)
  1097.                && SYNTAX_COMEND_SECOND (CHAR_AT (from)))
  1098.             { from++; break; }
  1099.         }
  1100. #endif /* NEW_SYNTAX */
  1101.           break;
  1102.  
  1103.         case Smath:
  1104.           if (!sexpflag)
  1105.         break;
  1106.           if (from != stop && c == CHAR_AT (from))
  1107.         from++;
  1108.           if (mathexit)
  1109.         {
  1110.           mathexit = 0;
  1111.           goto close1;
  1112.         }
  1113.           mathexit = 1;
  1114.  
  1115.         case Sopen:
  1116.           if (!++depth) goto done;
  1117.           break;
  1118.  
  1119.         case Sclose:
  1120.         close1:
  1121.           if (!--depth) goto done;
  1122.           if (depth < min_depth)
  1123.         error ("Containing expression ends prematurely");
  1124.           break;
  1125.  
  1126.         case Sstring:
  1127.           stringterm = CHAR_AT (from - 1);
  1128.           while (1)
  1129.         {
  1130.           if (from >= stop) goto lose;
  1131.           if (CHAR_AT (from) == stringterm) break;
  1132. #ifdef SWITCH_ENUM_BUG
  1133.           switch ((int) SYNTAX(CHAR_AT (from)))
  1134. #else
  1135.           switch (SYNTAX(CHAR_AT (from)))
  1136. #endif
  1137.             {
  1138.             case Scharquote:
  1139.             case Sescape:
  1140.               from++;
  1141.             }
  1142.           from++;
  1143.         }
  1144.           from++;
  1145.           if (!depth && sexpflag) goto done;
  1146.           break;
  1147.         }
  1148.     }
  1149.  
  1150.       /* Reached end of buffer.  Error if within object, return nil if between */
  1151.       if (depth) goto lose;
  1152.  
  1153.       immediate_quit = 0;
  1154.       return Qnil;
  1155.  
  1156.       /* End of object reached */
  1157.     done:
  1158.       count--;
  1159.     }
  1160.  
  1161.   while (count < 0)
  1162.     {
  1163.       stop = BEGV;
  1164.       while (from > stop)
  1165.     {
  1166.       from--;
  1167.       if (quoted = char_quoted (from))
  1168.         from--;
  1169.  
  1170.       c = CHAR_AT (from);
  1171.       code = SYNTAX (c);
  1172.  
  1173. #ifdef NEW_SYNTAX
  1174.  
  1175.       if (code == Scomment || code == Sendcomment)
  1176.         comstyle = SYNTAX_SINGLE_CHAR_STYLE_B (c);
  1177.  
  1178.       else if (from > stop
  1179.            && SYNTAX_END (CHAR_AT (from-1), c)
  1180.            && !char_quoted (from-1)
  1181.            && parse_sexp_ignore_comments)
  1182.         {
  1183.           code = Sendcomment;
  1184.           comstyle = SYNTAX_END_SEQUENCE (CHAR_AT (from-1), c, stylemask);
  1185.           from--;
  1186.         }
  1187.  
  1188. #else /* !NEW_SYNTAX */
  1189.  
  1190.       if (from > stop && SYNTAX_COMEND_SECOND (c)
  1191.           && SYNTAX_COMEND_FIRST (CHAR_AT (from - 1))
  1192.           && !char_quoted (from - 1)
  1193.           && parse_sexp_ignore_comments)
  1194.         code = Sendcomment, from--;
  1195.  
  1196. #endif /* NEW_SYNTAX */
  1197.  
  1198.       if (SYNTAX_PREFIX (c))
  1199.         continue;
  1200.  
  1201. #ifdef SWITCH_ENUM_BUG
  1202.       switch ((int) (quoted ? Sword : code))
  1203. #else
  1204.       switch (quoted ? Sword : code)
  1205. #endif
  1206.         {
  1207.         case Sword:
  1208.         case Ssymbol:
  1209.           if (depth || !sexpflag) break;
  1210.           /* This word counts as a sexp; count object finished after 
  1211.          passing it. */
  1212.           while (from > stop)
  1213.         {
  1214.           quoted = char_quoted (from - 1);
  1215.           if (quoted)
  1216.             from--;
  1217.           if (! (quoted || SYNTAX(CHAR_AT (from - 1)) == Sword
  1218.              || SYNTAX(CHAR_AT (from - 1)) == Ssymbol
  1219.              || SYNTAX(CHAR_AT (from - 1)) == Squote))
  1220.                     goto done2;
  1221.           from--;
  1222.         }
  1223.           goto done2;
  1224.  
  1225.         case Smath:
  1226.           if (!sexpflag)
  1227.         break;
  1228.           if (from != stop && c == CHAR_AT (from - 1))
  1229.         from--;
  1230.           if (mathexit)
  1231.         {
  1232.           mathexit = 0;
  1233.           goto open2;
  1234.         }
  1235.           mathexit = 1;
  1236.  
  1237.         case Sclose:
  1238.           if (!++depth) goto done2;
  1239.           break;
  1240.  
  1241.         case Sopen:
  1242.         open2:
  1243.           if (!--depth) goto done2;
  1244.           if (depth < min_depth)
  1245.         error ("Containing expression ends prematurely");
  1246.           break;
  1247.  
  1248.         case Sendcomment:
  1249.           if (!parse_sexp_ignore_comments)
  1250.         break;
  1251. #ifdef NEW_SYNTAX
  1252.  
  1253.           from = find_start_of_comment (from, stop, comstyle);
  1254.  
  1255. #else /* !NEW_SYNTAX */
  1256.  
  1257.           /* Look back, counting the parity of string-quotes,
  1258.          and recording the comment-starters seen.
  1259.          When we reach a safe place, assume that's not in a string;
  1260.          then step the main scan to the earliest comment-starter seen
  1261.          an even number of string quotes away from the safe place.
  1262.  
  1263.          OFROM[I] is position of the earliest comment-starter seen
  1264.          which is I+2X quotes from the comment-end.
  1265.          PARITY is current parity of quotes from the comment end.  */
  1266.           {
  1267.         int ofrom[2];
  1268.         int parity = 0;
  1269.  
  1270.         ofrom[0] = ofrom[1] = from;
  1271.  
  1272.         /* At beginning of range to scan, we're outside of strings;
  1273.            that determines quote parity to the comment-end.  */
  1274.         while (from != stop)
  1275.           {
  1276.             /* Move back and examine a character.  */
  1277.             from--;
  1278.  
  1279.             c = CHAR_AT (from);
  1280.             code = SYNTAX (c);
  1281.  
  1282.             /* If this char is the second of a 2-char comment sequence,
  1283.                back up and give the pair the appropriate syntax.  */
  1284.             if (from > stop && SYNTAX_COMEND_SECOND (c)
  1285.             && SYNTAX_COMEND_FIRST (CHAR_AT (from - 1)))
  1286.               code = Sendcomment, from--;
  1287.             else if (from > stop && SYNTAX_COMSTART_SECOND (c)
  1288.                  && SYNTAX_COMSTART_FIRST (CHAR_AT (from - 1)))
  1289.               code = Scomment, from--;
  1290.  
  1291.             /* Ignore escaped characters.  */
  1292.             if (char_quoted (from))
  1293.               continue;
  1294.  
  1295.             /* Track parity of quotes between here and comment-end.  */
  1296.             if (code == Sstring)
  1297.               parity ^= 1;
  1298.  
  1299.             /* Record comment-starters according to that
  1300.                quote-parity to the comment-end.  */
  1301.             if (code == Scomment)
  1302.               ofrom[parity] = from;
  1303.  
  1304.             /* If we come to another comment-end,
  1305.                assume it's not inside a string.
  1306.                That determines the quote parity to the comment-end.  */
  1307.             if (code == Sendcomment)
  1308.               break;
  1309.           }
  1310.         from = ofrom[parity];
  1311.           }
  1312.  
  1313. #endif /* NEW_SYNTAX */
  1314.  
  1315.           break;
  1316.  
  1317.         case Sstring:
  1318.           stringterm = CHAR_AT (from);
  1319.           while (1)
  1320.         {
  1321.           if (from == stop) goto lose;
  1322.           if (!char_quoted (from - 1)
  1323.               && stringterm == CHAR_AT (from - 1))
  1324.             break;
  1325.           from--;
  1326.         }
  1327.           from--;
  1328.           if (!depth && sexpflag) goto done2;
  1329.           break;
  1330.         }
  1331.     }
  1332.  
  1333.       /* Reached start of buffer.  Error if within object, return nil if between */
  1334.       if (depth) goto lose;
  1335.  
  1336.       immediate_quit = 0;
  1337.       return Qnil;
  1338.  
  1339.     done2:
  1340.       count++;
  1341.     }
  1342.  
  1343.  
  1344.   immediate_quit = 0;
  1345.   XFASTINT (val) = from;
  1346.   return val;
  1347.  
  1348.  lose:
  1349.   error ("Unbalanced parentheses");
  1350.   /* NOTREACHED */
  1351.   return Qnil; /* warning suppression */
  1352. }
  1353.  
  1354. static int
  1355. char_quoted (pos)
  1356.      register int pos;
  1357. {
  1358.   register enum syntaxcode code;
  1359.   register int beg = BEGV;
  1360.   register int quoted = 0;
  1361.  
  1362.   while (pos > beg
  1363.      && ((code = SYNTAX (CHAR_AT (pos - 1))) == Scharquote
  1364.          || code == Sescape))
  1365.     pos--, quoted = !quoted;
  1366.   return quoted;
  1367. }
  1368.  
  1369. DEFUN ("scan-lists", Fscan_lists, Sscan_lists, 3, 3, 0,
  1370.   "Scan from character number FROM by COUNT lists.\n\
  1371. Returns the character number of the position thus found.\n\
  1372. \n\
  1373. If DEPTH is nonzero, paren depth begins counting from that value,\n\
  1374. only places where the depth in parentheses becomes zero\n\
  1375. are candidates for stopping; COUNT such places are counted.\n\
  1376. Thus, a positive value for DEPTH means go out levels.\n\
  1377. \n\
  1378. Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\
  1379. \n\
  1380. If the beginning or end of (the accessible part of) the buffer is reached\n\
  1381. and the depth is wrong, an error is signaled.\n\
  1382. If the depth is right but the count is not used up, nil is returned.")
  1383.   (from, count, depth)
  1384.      Lisp_Object from, count, depth;
  1385. {
  1386.   CHECK_FIXNUM (from, 0);
  1387.   CHECK_FIXNUM (count, 1);
  1388.   CHECK_FIXNUM (depth, 2);
  1389.  
  1390.   return scan_lists (XINT (from), XINT (count), XINT (depth), 0);
  1391. }
  1392.  
  1393. DEFUN ("scan-sexps", Fscan_sexps, Sscan_sexps, 2, 2, 0,
  1394.   "Scan from character number FROM by COUNT balanced expressions.\n\
  1395. If COUNT is negative, scan backwards.\n\
  1396. Returns the character number of the position thus found.\n\
  1397. \n\
  1398. Comments are ignored if `parse-sexp-ignore-comments' is non-nil.\n\
  1399. \n\
  1400. If the beginning or end of (the accessible part of) the buffer is reached\n\
  1401. in the middle of a parenthetical grouping, an error is signaled.\n\
  1402. If the beginning or end is reached between groupings\n\
  1403. but before count is used up, nil is returned.")
  1404.   (from, count)
  1405.      Lisp_Object from, count;
  1406. {
  1407.   CHECK_FIXNUM (from, 0);
  1408.   CHECK_FIXNUM (count, 1);
  1409.  
  1410.   return scan_lists (XINT (from), XINT (count), 0, 1);
  1411. }
  1412.  
  1413. DEFUN ("backward-prefix-chars", Fbackward_prefix_chars, Sbackward_prefix_chars,
  1414.   0, 0, 0,
  1415.   "Move point backward over any number of chars with prefix syntax.\n\
  1416. This includes chars with \"quote\" or \"prefix\" syntax (' or p).")
  1417.   ()
  1418. {
  1419.   int beg = BEGV;
  1420.   int pos = point;
  1421.  
  1422.   while (pos > beg && !char_quoted (pos - 1)
  1423.      && (SYNTAX (CHAR_AT (pos - 1)) == Squote
  1424.          || SYNTAX_PREFIX (CHAR_AT (pos - 1))))
  1425.     pos--;
  1426.  
  1427.   SET_PT (pos);
  1428.  
  1429.   return Qnil;
  1430. }
  1431.  
  1432. struct lisp_parse_state
  1433.   {
  1434.     int depth;        /* Depth at end of parsing */
  1435.     int instring;    /* -1 if not within string, else desired terminator. */
  1436.     int incomment;    /* Nonzero if within a comment at end of parsing */
  1437. #ifdef NEW_SYNTAX
  1438.     int comstyle;    /* comment style: a or b */
  1439. #endif /* NEW_SYNTAX */
  1440.     int quoted;        /* Nonzero if just after an escape char at end of parsing */
  1441.     int thislevelstart;    /* Char number of most recent start-of-expression at current level */
  1442.     int prevlevelstart; /* Char number of start of containing expression */
  1443.     int location;    /* Char number at which parsing stopped. */
  1444.     int mindepth;    /* Minimum depth seen while scanning.  */
  1445.   };
  1446.  
  1447. /* Parse forward from FROM to END,
  1448.    assuming that FROM is the start of a function, 
  1449.    and return a description of the state of the parse at END. */
  1450.  
  1451. static struct lisp_parse_state val_scan_sexps_forward;
  1452.  
  1453. static struct lisp_parse_state *
  1454. scan_sexps_forward (from, end, targetdepth, stopbefore, oldstate)
  1455.      register int from;
  1456.      int end, targetdepth, stopbefore;
  1457.      Lisp_Object oldstate;
  1458. {
  1459.   struct lisp_parse_state state;
  1460.  
  1461.   register enum syntaxcode code;
  1462.   struct level { int last, prev; };
  1463.   struct level levelstart[100];
  1464.   register struct level *curlevel = levelstart;
  1465.   struct level *endlevel = levelstart + 100;
  1466.   char prev;
  1467.   register int depth;    /* Paren depth of current scanning location.
  1468.                level - levelstart equals this except
  1469.                when the depth becomes negative.  */
  1470.   int mindepth;        /* Lowest DEPTH value seen.  */
  1471.   int start_quoted = 0;        /* Nonzero means starting after a char quote */
  1472.   Lisp_Object tem;
  1473.  
  1474. #ifdef NEW_SYNTAX
  1475.   int stylemask = SYNTAX_COMMENT_STYLE_B;
  1476. #endif /* NEW_SYNTAX */
  1477.  
  1478.   immediate_quit = 1;
  1479.   QUIT;
  1480.  
  1481.   if (NILP (oldstate))
  1482.     {
  1483.       depth = 0;
  1484.       state.instring = -1;
  1485.       state.incomment = 0;
  1486. #ifdef NEW_SYNTAX
  1487.       state.comstyle = 0;    /* default comstyle is a */
  1488. #endif /* NEW_SYNTAX */
  1489.     }
  1490.   else
  1491.     {
  1492.       tem = Fcar (oldstate);
  1493.       if (!NILP (tem))
  1494.     depth = XINT (tem);
  1495.       else
  1496.     depth = 0;
  1497.  
  1498.       oldstate = Fcdr (oldstate);
  1499.       oldstate = Fcdr (oldstate);
  1500.       oldstate = Fcdr (oldstate);
  1501.       tem = Fcar (oldstate);
  1502.       state.instring = !NILP (tem) ? XINT (tem) : -1;
  1503.  
  1504.       oldstate = Fcdr (oldstate);
  1505.       tem = Fcar (oldstate);
  1506.       state.incomment = !NILP (tem);
  1507.  
  1508.       oldstate = Fcdr (oldstate);
  1509.       tem = Fcar (oldstate);
  1510.       start_quoted = !NILP (tem);
  1511.  
  1512. #ifdef NEW_SYNTAX
  1513.       /* if eighth element of the list is nil, we are in comment style
  1514.      a. if it is non-nil, we are in comment style b */
  1515.       oldstate = Fcdr (oldstate);
  1516.       oldstate = Fcdr (oldstate);
  1517.       oldstate = Fcdr (oldstate);
  1518.       tem = Fcar (oldstate);
  1519.       state.comstyle = !NILP (tem);
  1520. #endif /* NEW_SYNTAX */
  1521.  
  1522.     }
  1523.   state.quoted = 0;
  1524.   mindepth = depth;
  1525.  
  1526.   curlevel->prev = -1;
  1527.   curlevel->last = -1;
  1528.  
  1529.   /* Enter the loop at a place appropriate for initial state. */
  1530.  
  1531.   if (state.incomment) goto startincomment;
  1532.   if (state.instring >= 0)
  1533.     {
  1534.       if (start_quoted) goto startquotedinstring;
  1535.       goto startinstring;
  1536.     }
  1537.   if (start_quoted) goto startquoted;
  1538.  
  1539.   while (from < end)
  1540.     {
  1541.       code = SYNTAX(CHAR_AT (from));
  1542.       from++;
  1543.  
  1544. #ifdef NEW_SYNTAX
  1545.  
  1546.       if (code == Scomment || code == Sendcomment)
  1547.     state.comstyle = SYNTAX_SINGLE_CHAR_STYLE_B (CHAR_AT (from-1));
  1548.  
  1549.       else if (from < end && SYNTAX_START (CHAR_AT (from-1), (CHAR_AT (from))))
  1550.     {
  1551.       code = Scomment;
  1552.       state.comstyle = 
  1553.         SYNTAX_START_SEQUENCE(CHAR_AT (from-1), CHAR_AT (from), stylemask);
  1554.       from++;
  1555.     }
  1556.  
  1557. #else /* !NEW_SYNTAX */
  1558.  
  1559.       if (from < end && SYNTAX_COMSTART_FIRST (CHAR_AT (from - 1))
  1560.        && SYNTAX_COMSTART_SECOND (CHAR_AT (from)))
  1561.     code = Scomment, from++;
  1562.  
  1563. #endif /* NEW_SYNTAX */
  1564.  
  1565.       if (SYNTAX_PREFIX (CHAR_AT (from - 1)))
  1566.     continue;
  1567. #ifdef SWITCH_ENUM_BUG
  1568.       switch ((int) code)
  1569. #else
  1570.       switch (code)
  1571. #endif
  1572.     {
  1573.     case Sescape:
  1574.     case Scharquote:
  1575.       if (stopbefore) goto stop;  /* this arg means stop at sexp start */
  1576.       curlevel->last = from - 1;
  1577.     startquoted:
  1578.       if (from == end) goto endquoted;
  1579.       from++;
  1580.       goto symstarted;
  1581.       /* treat following character as a word constituent */
  1582.     case Sword:
  1583.     case Ssymbol:
  1584.       if (stopbefore) goto stop;  /* this arg means stop at sexp start */
  1585.       curlevel->last = from - 1;
  1586.     symstarted:
  1587.       while (from < end)
  1588.         {
  1589. #ifdef SWITCH_ENUM_BUG
  1590.           switch ((int) SYNTAX(CHAR_AT (from)))
  1591. #else
  1592.           switch (SYNTAX(CHAR_AT (from)))
  1593. #endif
  1594.         {
  1595.         case Scharquote:
  1596.         case Sescape:
  1597.           from++;
  1598.           if (from == end) goto endquoted;
  1599.           break;
  1600.         case Sword:
  1601.         case Ssymbol:
  1602.         case Squote:
  1603.           break;
  1604.         default:
  1605.           goto symdone;
  1606.         }
  1607.           from++;
  1608.         }
  1609.     symdone:
  1610.       curlevel->prev = curlevel->last;
  1611.       break;
  1612.  
  1613.     case Scomment:
  1614.       state.incomment = 1;
  1615.     startincomment:
  1616.  
  1617. #ifdef NEW_SYNTAX
  1618.  
  1619.       from = find_end_of_comment (from, end, state.comstyle);
  1620.       if (from == end) goto done;
  1621.  
  1622. #else /* !NEW_SYNTAX */
  1623.  
  1624.       while (1)
  1625.         {
  1626.           if (from == end) goto done;
  1627.           if (SYNTAX (prev = CHAR_AT (from)) == Sendcomment)
  1628.         break;
  1629.           from++;
  1630.           if (from < end && SYNTAX_COMEND_FIRST (prev)
  1631.            && SYNTAX_COMEND_SECOND (CHAR_AT (from)))
  1632.         { from++; break; }
  1633.         }
  1634.  
  1635. #endif /* NEW_SYNTAX */
  1636.  
  1637.       state.incomment = 0;
  1638.       break;
  1639.  
  1640.     case Sopen:
  1641.       if (stopbefore) goto stop;  /* this arg means stop at sexp start */
  1642.       depth++;
  1643.       /* curlevel++->last ran into compiler bug on Apollo */
  1644.       curlevel->last = from - 1;
  1645.       if (++curlevel == endlevel)
  1646.         error ("Nesting too deep for parser");
  1647.       curlevel->prev = -1;
  1648.       curlevel->last = -1;
  1649.       if (!--targetdepth) goto done;
  1650.       break;
  1651.  
  1652.     case Sclose:
  1653.       depth--;
  1654.       if (depth < mindepth)
  1655.         mindepth = depth;
  1656.       if (curlevel != levelstart)
  1657.         curlevel--;
  1658.       curlevel->prev = curlevel->last;
  1659.       if (!++targetdepth) goto done;
  1660.       break;
  1661.  
  1662.     case Sstring:
  1663.       if (stopbefore) goto stop;  /* this arg means stop at sexp start */
  1664.       curlevel->last = from - 1;
  1665.       state.instring = CHAR_AT (from - 1);
  1666.     startinstring:
  1667.       while (1)
  1668.         {
  1669.           if (from >= end) goto done;
  1670.           if (CHAR_AT (from) == state.instring) break;
  1671. #ifdef SWITCH_ENUM_BUG
  1672.           switch ((int) SYNTAX(CHAR_AT (from)))
  1673. #else
  1674.           switch (SYNTAX(CHAR_AT (from)))
  1675. #endif
  1676.         {
  1677.         case Scharquote:
  1678.         case Sescape:
  1679.           from++;
  1680.         startquotedinstring:
  1681.           if (from >= end) goto endquoted;
  1682.         }
  1683.           from++;
  1684.         }
  1685.       state.instring = -1;
  1686.       curlevel->prev = curlevel->last;
  1687.       from++;
  1688.       break;
  1689.  
  1690.     case Smath:
  1691.       break;
  1692.     }
  1693.     }
  1694.   goto done;
  1695.  
  1696.  stop:   /* Here if stopping before start of sexp. */
  1697.   from--;    /* We have just fetched the char that starts it; */
  1698.   goto done; /* but return the position before it. */
  1699.  
  1700.  endquoted:
  1701.   state.quoted = 1;
  1702.  done:
  1703.   state.depth = depth;
  1704.   state.mindepth = mindepth;
  1705.   state.thislevelstart = curlevel->prev;
  1706.   state.prevlevelstart
  1707.     = (curlevel == levelstart) ? -1 : (curlevel - 1)->last;
  1708.   state.location = from;
  1709.   immediate_quit = 0;
  1710.  
  1711.   val_scan_sexps_forward = state;
  1712.   return &val_scan_sexps_forward;
  1713. }
  1714.  
  1715. #ifdef NEW_SYNTAX
  1716.  
  1717. /* This comment supplies the doc string for parse-partial-sexp,
  1718.    for make-docfile to see.  We cannot put this in the real DEFUN
  1719.    due to limits in the Unix cpp.
  1720.  
  1721. DEFUN ("parse-partial-sexp", Ffoo, Sfoo, 2, 5, 0,
  1722.   "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\
  1723. Parsing stops at TO or when certain criteria are met;\n\
  1724.  point is set to where parsing stops.\n\
  1725. If fifth arg STATE is omitted or nil,\n\
  1726.  parsing assumes that FROM is the beginning of a function.\n\
  1727. Value is a list of eight elements describing final state of parsing:\n\
  1728.  1. depth in parens.\n\
  1729.  2. character address of start of innermost containing list; nil if none.\n\
  1730.  3. character address of start of last complete sexp terminated.\n\
  1731.  4. non-nil if inside a string.\n\
  1732.     (it is the character that will terminate the string.)\n\
  1733.  5. t if inside a comment.\n\
  1734.  6. t if following a quote character.\n\
  1735.  7. the minimum paren-depth encountered during this scan.\n\
  1736.  8. nil if in comment style a, or not in a comment; t if in comment style b\n\
  1737. If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\
  1738. in parentheses becomes equal to TARGETDEPTH.\n\
  1739. Fourth arg STOPBEFORE non-nil means stop when come to\n\
  1740.  any character that starts a sexp.\n\
  1741. Fifth arg STATE is a seven-list like what this function returns.\n\
  1742. It is used to initialize the state of the parse.")
  1743.   (from, to, targetdepth, stopbefore, oldstate)
  1744. */
  1745.  
  1746. #else /* !NEW_SYNTAX */
  1747.  
  1748. /* This comment supplies the doc string for parse-partial-sexp,
  1749.    for make-docfile to see.  We cannot put this in the real DEFUN
  1750.    due to limits in the Unix cpp.
  1751.  
  1752. ****DEFUN ("parse-partial-sexp", Ffoo, Sfoo, 2, 5, 0,
  1753.   "Parse Lisp syntax starting at FROM until TO; return status of parse at TO.\n\
  1754. Parsing stops at TO or when certain criteria are met;\n\
  1755.  point is set to where parsing stops.\n\
  1756. If fifth arg STATE is omitted or nil,\n\
  1757.  parsing assumes that FROM is the beginning of a function.\n\
  1758. Value is a list of seven elements describing final state of parsing:\n\
  1759.  1. depth in parens.\n\
  1760.  2. character address of start of innermost containing list; nil if none.\n\
  1761.  3. character address of start of last complete sexp terminated.\n\
  1762.  4. non-nil if inside a string.\n\
  1763.     (it is the character that will terminate the string.)\n\
  1764.  5. t if inside a comment.\n\
  1765.  6. t if following a quote character.\n\
  1766.  7. the minimum paren-depth encountered during this scan.\n\
  1767. If third arg TARGETDEPTH is non-nil, parsing stops if the depth\n\
  1768. in parentheses becomes equal to TARGETDEPTH.\n\
  1769. Fourth arg STOPBEFORE non-nil means stop when come to\n\
  1770.  any character that starts a sexp.\n\
  1771. Fifth arg STATE is a seven-list like what this function returns.\n\
  1772. It is used to initialize the state of the parse.")
  1773.   (from, to, targetdepth, stopbefore, oldstate)
  1774. */
  1775.  
  1776. #endif /* NEW_SYNTAX */
  1777.  
  1778. DEFUN ("parse-partial-sexp", Fparse_partial_sexp, Sparse_partial_sexp, 2, 5, 0,
  1779.   0 /* See immediately above */)
  1780.   (from, to, targetdepth, stopbefore, oldstate)
  1781.      Lisp_Object from, to, targetdepth, stopbefore, oldstate;
  1782. {
  1783.   struct lisp_parse_state state;
  1784.   int target;
  1785.  
  1786.   if (!NILP (targetdepth))
  1787.     {
  1788.       CHECK_FIXNUM (targetdepth, 3);
  1789.       target = XINT (targetdepth);
  1790.     }
  1791.   else
  1792.     target = -100000;        /* We won't reach this depth */
  1793.  
  1794.   validate_region (&from, &to);
  1795.   state = *scan_sexps_forward (XINT (from), XINT (to),
  1796.                    target, !NILP (stopbefore), oldstate);
  1797.  
  1798.   SET_PT (state.location);
  1799.   
  1800.   return Fcons (make_number (state.depth),
  1801.        Fcons (state.prevlevelstart < 0 ? Qnil : make_number (state.prevlevelstart),
  1802.          Fcons (state.thislevelstart < 0 ? Qnil : make_number (state.thislevelstart),
  1803.            Fcons (state.instring >= 0 ? make_number (state.instring) : Qnil,
  1804.          Fcons (state.incomment ? Qt : Qnil,
  1805.            Fcons (state.quoted ? Qt : Qnil,
  1806. #ifdef NEW_SYNTAX
  1807.              Fcons (make_number (state.mindepth), 
  1808.                Fcons (state.comstyle ? Qt : Qnil,
  1809.                 Qnil))))))));
  1810. #else /* !NEW_SYNTAX */
  1811.               Fcons (make_number (state.mindepth), Qnil)))))));
  1812. #endif /* NEW_SYNTAX */
  1813. }
  1814.  
  1815. void
  1816. init_syntax_once ()
  1817. {
  1818.   register int i;
  1819.   register struct Lisp_Vector *v;
  1820.  
  1821.   /* Set this now, so first buffer creation can refer to it. */
  1822.   /* Make it nil before calling copy-syntax-table
  1823.     so that copy-syntax-table will know not to try to copy from garbage */
  1824.   Vstandard_syntax_table = Qnil;
  1825.   Vstandard_syntax_table = Fcopy_syntax_table (Qnil);
  1826.  
  1827.   v = XVECTOR (Vstandard_syntax_table);
  1828.  
  1829.   for (i = 'a'; i <= 'z'; i++)
  1830.     XFASTINT (v->contents[i]) = (int) Sword;
  1831.   for (i = 'A'; i <= 'Z'; i++)
  1832.     XFASTINT (v->contents[i]) = (int) Sword;
  1833.   for (i = '0'; i <= '9'; i++)
  1834.     XFASTINT (v->contents[i]) = (int) Sword;
  1835.   XFASTINT (v->contents['$']) = (int) Sword;
  1836.   XFASTINT (v->contents['%']) = (int) Sword;
  1837.  
  1838.   XFASTINT (v->contents['(']) = (int) Sopen + (')' << 8);
  1839.   XFASTINT (v->contents[')']) = (int) Sclose + ('(' << 8);
  1840.   XFASTINT (v->contents['[']) = (int) Sopen + (']' << 8);
  1841.   XFASTINT (v->contents[']']) = (int) Sclose + ('[' << 8);
  1842.   XFASTINT (v->contents['{']) = (int) Sopen + ('}' << 8);
  1843.   XFASTINT (v->contents['}']) = (int) Sclose + ('{' << 8);
  1844.   XFASTINT (v->contents['"']) = (int) Sstring;
  1845.   XFASTINT (v->contents['\\']) = (int) Sescape;
  1846.  
  1847.   for (i = 0; i < 10; i++)
  1848.     XFASTINT (v->contents["_-+*/&|<>="[i]]) = (int) Ssymbol;
  1849.  
  1850.   for (i = 0; i < 12; i++)
  1851.     XFASTINT (v->contents[".,;:?!#@~^'`"[i]]) = (int) Spunct;
  1852. }
  1853.  
  1854. void
  1855. syms_of_syntax ()
  1856. {
  1857.   Qsyntax_table_p = intern ("syntax-table-p");
  1858.   staticpro (&Qsyntax_table_p);
  1859.  
  1860.   DEFVAR_BOOL ("parse-sexp-ignore-comments", &parse_sexp_ignore_comments,
  1861.     "Non-nil means `forward-sexp', etc., should treat comments as whitespace.");
  1862.  
  1863.   words_include_escapes = 0;
  1864.   DEFVAR_BOOL ("words-include-escapes", &words_include_escapes,
  1865.     "Non-nil means `forward-word', etc., should treat escape chars part of words.");
  1866.  
  1867.   defsubr (&Ssyntax_table_p);
  1868.   defsubr (&Ssyntax_table);
  1869.   defsubr (&Sstandard_syntax_table);
  1870.   defsubr (&Scopy_syntax_table);
  1871.   defsubr (&Sset_syntax_table);
  1872.   defsubr (&Schar_syntax);
  1873.   defsubr (&Smodify_syntax_entry);
  1874.   defsubr (&Sdescribe_syntax);
  1875.  
  1876.   defsubr (&Sforward_word);
  1877.  
  1878.   defsubr (&Sscan_lists);
  1879.   defsubr (&Sscan_sexps);
  1880.   defsubr (&Sbackward_prefix_chars);
  1881.  
  1882. #ifdef NEW_SYNTAX
  1883.   defsubr (&Sbackward_syntactic_ws);
  1884.   defsubr (&Sforward_syntactic_ws);
  1885. #endif /* NEW_SYNTAX */
  1886.  
  1887.   defsubr (&Sparse_partial_sexp);
  1888. }
  1889.