home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.004 / xemacs-1 / xemacs-19.13 / src / syntax.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  7.6 KB  |  206 lines

  1. /* Declarations having to do with XEmacs syntax tables.
  2.    Copyright (C) 1985, 1992, 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of XEmacs.
  5.  
  6. XEmacs is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by the
  8. Free Software Foundation; either version 2, or (at your option) any
  9. later version.
  10.  
  11. XEmacs is distributed in the hope that it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14. for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with XEmacs; see the file COPYING.  If not, write to the Free
  18. Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* Synched up with: FSF 19.28. */
  21.  
  22. #ifndef _XEMACS_SYNTAX_H_
  23. #define _XEMACS_SYNTAX_H_
  24.  
  25. extern Lisp_Object Qsyntax_table_p;
  26. extern Lisp_Object Fsyntax_table_p (Lisp_Object);
  27. extern Lisp_Object Fsyntax_table (Lisp_Object);
  28. extern Lisp_Object Fset_syntax_table (Lisp_Object, Lisp_Object);
  29.  
  30. /* The standard syntax table is stored where it will automatically
  31.    be used in all new buffers.  */
  32. extern Lisp_Object Vstandard_syntax_table;
  33.  
  34. /* A syntax table is a Lisp vector of length 0400, whose elements are integers.
  35.  
  36. The low 7 bits of the integer is a code, as follows. The 8th bit is
  37. used as the prefix bit flag (see below).
  38. */
  39.  
  40. enum syntaxcode
  41.   {
  42.     Swhitespace, /* for a whitespace character */
  43.     Spunct,     /* for random punctuation characters */
  44.     Sword,     /* for a word constituent */
  45.     Ssymbol,     /* symbol constituent but not word constituent */
  46.     Sopen,     /* for a beginning delimiter */
  47.     Sclose,      /* for an ending delimiter */
  48.     Squote,     /* for a prefix character like Lisp ' */
  49.     Sstring,     /* for a string-grouping character like Lisp " */
  50.     Smath,     /* for delimiters like $ in Tex. */
  51.     Sescape,     /* for a character that begins a C-style escape */
  52.     Scharquote,  /* for a character that quotes the following character */
  53.     Scomment,    /* for a comment-starting character */
  54.     Sendcomment, /* for a comment-ending character */
  55.     Sinherit,    /* use the standard syntax table for this character */
  56.     Smax     /* Upper bound on codes that are meaningful */
  57.   };
  58.  
  59. MAC_DECLARE_EXTERN (Emchar, mactemp_syntax_ch)
  60. MAC_DECLARE_EXTERN (int, mactemp_syntax_int)
  61.  
  62. #ifdef MULE
  63. Lose.
  64. #else
  65. /* Return the raw syntax code for a particular character and table */
  66. #define RAW_SYNTAX_CODE(table, c) \
  67.   (XINT (vector_data (XVECTOR (table))[(unsigned char) (c)]))
  68. #endif
  69.  
  70. /* Return the syntax code for a particular character and table, taking
  71.    into account inheritance.  We must use a temp variable to hold the
  72.    character in case it is side effectual, such as '*d++' in regex.c.
  73.    Putting the raw syntax code into a temp variable is only an
  74.    optimization. */
  75.  
  76. #define SYNTAX_CODE(table, c)                        \
  77. MAC_BEGIN                                \
  78.   MAC_DECLARE (Emchar, mactemp_syntax_ch, (Emchar) (unsigned char) (c))    \
  79.   MAC_DECLARE (int, mactemp_syntax_int,                    \
  80.            RAW_SYNTAX_CODE (table, mactemp_syntax_ch))        \
  81.   (enum syntaxcode) (mactemp_syntax_int & 0177) == Sinherit ?        \
  82.     RAW_SYNTAX_CODE (Vstandard_syntax_table, mactemp_syntax_ch) :    \
  83.     mactemp_syntax_int                            \
  84. MAC_END
  85.  
  86. #define SYNTAX(table, c) \
  87.   ((enum syntaxcode) (SYNTAX_CODE (table, c) & 0177))
  88.  
  89. /* The prefix flag bit for backward-prefix-chars is now put into bit 7. */
  90.  
  91. #define SYNTAX_PREFIX(table, c) \
  92.   ((SYNTAX_CODE (table, c) >> 7) & 1)
  93.  
  94. /* The next 8 bits of the number is a character,
  95.  the matching delimiter in the case of Sopen or Sclose. */
  96.  
  97. #define SYNTAX_MATCH(table, c) \
  98.   ((SYNTAX_CODE (table, c) >> 8) & 0377)
  99.  
  100. /* The next 8 bits are used to implement up to two comment styles
  101.    in a single buffer. They have the following meanings:
  102.  
  103.   1. first of a one or two character comment-start sequence of style a.
  104.   2. first of a one or two character comment-start sequence of style b.
  105.   3. second of a two-character comment-start sequence of style a.
  106.   4. second of a two-character comment-start sequence of style b.
  107.   5. first of a one or two character comment-end sequence of style a.
  108.   6. first of a one or two character comment-end sequence of style b.
  109.   7. second of a two-character comment-end sequence of style a.
  110.   8. second of a two-character comment-end sequence of style b.
  111.  */
  112.  
  113. #define SYNTAX_COMMENT_BITS(table, c) \
  114.   ((SYNTAX_CODE (table, c) >> 16) &0xff)
  115.  
  116. #define SYNTAX_FIRST_OF_START_A  0x80
  117. #define SYNTAX_FIRST_OF_START_B  0x40
  118. #define SYNTAX_SECOND_OF_START_A 0x20
  119. #define SYNTAX_SECOND_OF_START_B 0x10
  120. #define SYNTAX_FIRST_OF_END_A    0x08
  121. #define SYNTAX_FIRST_OF_END_B    0x04
  122. #define SYNTAX_SECOND_OF_END_A   0x02
  123. #define SYNTAX_SECOND_OF_END_B   0x01
  124.  
  125. #define SYNTAX_COMMENT_STYLE_A   0xaa
  126. #define SYNTAX_COMMENT_STYLE_B   0x55
  127. #define SYNTAX_FIRST_CHAR_START  0xc0
  128. #define SYNTAX_FIRST_CHAR_END    0x0c
  129. #define SYNTAX_FIRST_CHAR        0xcc
  130. #define SYNTAX_SECOND_CHAR_START 0x30
  131. #define SYNTAX_SECOND_CHAR_END   0x03
  132. #define SYNTAX_SECOND_CHAR       0x33
  133.  
  134. #define SYNTAX_START_P(table, a, b)                    \
  135.   ((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_START)        \
  136.    && (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_START))
  137.  
  138. #define SYNTAX_END_P(table, a, b)                    \
  139.   ((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_END)        \
  140.    && (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_END))
  141.  
  142. #define SYNTAX_STYLES_MATCH_START_P(table, a, b, mask)                \
  143.   ((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_START & (mask))        \
  144.    && (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_START & (mask)))
  145.  
  146. #define SYNTAX_STYLES_MATCH_END_P(table, a, b, mask)              \
  147.   ((SYNTAX_COMMENT_BITS (table, a) & SYNTAX_FIRST_CHAR_END & (mask))      \
  148.    && (SYNTAX_COMMENT_BITS (table, b) & SYNTAX_SECOND_CHAR_END & (mask)))
  149.  
  150. #define SYNTAX_STYLES_MATCH_1CHAR_P(table, a, mask)    \
  151.   ((SYNTAX_COMMENT_BITS (table, a) & (mask)))
  152.  
  153. #define STYLE_FOUND_P(table, a, b, startp, style)    \
  154.   ((SYNTAX_COMMENT_BITS (table, a) &            \
  155.     ((startp) ? SYNTAX_FIRST_CHAR_START :        \
  156.      SYNTAX_FIRST_CHAR_END) & (style))            \
  157.    && (SYNTAX_COMMENT_BITS (table, b) &            \
  158.     ((startp) ? SYNTAX_SECOND_CHAR_START :         \
  159.      SYNTAX_SECOND_CHAR_END) & (style)))
  160.  
  161. #define SYNTAX_COMMENT_MASK_START(table, a, b)            \
  162.   ((STYLE_FOUND_P (table, a, b, 1, SYNTAX_COMMENT_STYLE_A)    \
  163.     ? SYNTAX_COMMENT_STYLE_A                    \
  164.     : (STYLE_FOUND_P (table, a, b, 1, SYNTAX_COMMENT_STYLE_B)    \
  165.          ? SYNTAX_COMMENT_STYLE_B                \
  166.      : 0)))
  167.  
  168. #define SYNTAX_COMMENT_MASK_END(a, b)                \
  169.   ((STYLE_FOUND_P (table, a, b, 0, SYNTAX_COMMENT_STYLE_A)    \
  170.    ? SYNTAX_COMMENT_STYLE_A                    \
  171.    : (STYLE_FOUND_P (table, a, b, 0, SYNTAX_COMMENT_STYLE_B)    \
  172.       ? SYNTAX_COMMENT_STYLE_B                    \
  173.       : 0)))
  174.  
  175. #define STYLE_FOUND_1CHAR_P(table, a, style)    \
  176.   ((SYNTAX_COMMENT_BITS (table, a) & (style)))
  177.  
  178. #define SYNTAX_COMMENT_1CHAR_MASK(table, a)            \
  179.   ((STYLE_FOUND_1CHAR_P (table, a, SYNTAX_COMMENT_STYLE_A)    \
  180.    ? SYNTAX_COMMENT_STYLE_A                    \
  181.    : (STYLE_FOUND_1CHAR_P (table, a, SYNTAX_COMMENT_STYLE_B)    \
  182.       ? SYNTAX_COMMENT_STYLE_B                    \
  183.      : 0)))
  184.  
  185. /* This array, indexed by a character, contains the syntax code which that
  186.  character signifies (as a char).  For example,
  187.  (enum syntaxcode) syntax_spec_code['w'] is Sword. */
  188.  
  189. extern CONST unsigned char syntax_spec_code[0400];
  190.  
  191. /* Indexed by syntax code, give the letter that describes it. */
  192.  
  193. #ifdef MULE
  194. extern CONST unsigned char syntax_code_spec[15];
  195. #else
  196. extern CONST unsigned char syntax_code_spec[14];
  197. #endif /* MULE */
  198.  
  199. extern Lisp_Object scan_lists (struct buffer *buf, int from, int count,
  200.                    int depth, int sexpflag, int no_error);
  201. extern int char_quoted (struct buffer *buf, int pos);
  202.  
  203. extern int no_quit_in_re_search;
  204.  
  205. #endif /* _XEMACS_SYNTAX_H_ */
  206.