1 /* -*-C-*-
2 
3 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
4     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Massachusetts
6     Institute of Technology
7 
8 This file is part of MIT/GNU Scheme.
9 
10 MIT/GNU Scheme is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or (at
13 your option) any later version.
14 
15 MIT/GNU Scheme is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with MIT/GNU Scheme; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
23 USA.
24 
25 */
26 
27 /* Definitions for Edwin syntax tables. */
28 
29 /* NOTE: This program was created by translation from the syntax table
30    code of GNU Emacs; it was translated from the original C to 68000
31    assembly language (in 1986), and then translated back from 68000
32    assembly language to C (in 1987).  */
33 
34 /* CODE is the syntax code for the character. */
35 #define SYNTAX_ENTRY_CODE(entry) ((enum syntaxcode) ((entry) & 0xF))
36 
37 /* MATCH is a matching delimiter, if the character is a delimiter type.
38    For example, if the character is '(', then MATCH is usually ')'. */
39 #define SYNTAX_ENTRY_MATCH(entry) (((entry) >> 4) & 0xFF)
40 
41 /* Bits indicating whether this character is part of a two-character
42    comment delimiter sequence. */
43 #define SYNTAX_ENTRY_COMMENT_BITS(entry) (((entry) >> 12) & 0xFF)
44 
45 #define COMSTART_FIRST_A	0x80
46 #define COMSTART_FIRST_B	0x40
47 #define COMSTART_SECOND_A	0x20
48 #define COMSTART_SECOND_B	0x10
49 #define COMEND_FIRST_A		0x08
50 #define COMEND_FIRST_B		0x04
51 #define COMEND_SECOND_A		0x02
52 #define COMEND_SECOND_B		0x01
53 
54 #define COMMENT_STYLE_A		0xAA
55 #define COMMENT_STYLE_B		0x55
56 #define COMSTART_FIRST		0xC0
57 #define COMSTART_SECOND		0x30
58 #define COMEND_FIRST		0x0C
59 #define COMEND_SECOND		0x03
60 
61 #define SYNTAX_ENTRY_COMMENT_STYLE(sentry, m)				\
62   ((((SYNTAX_ENTRY_COMMENT_BITS (sentry)) & (m) & COMMENT_STYLE_A)	\
63     ? COMMENT_STYLE_A							\
64     : 0)								\
65    | (((SYNTAX_ENTRY_COMMENT_BITS (sentry)) & (m) & COMMENT_STYLE_B)	\
66       ? COMMENT_STYLE_B							\
67       : 0))
68 
69 /* PREFIX says to skip over this character if it precedes an s-expression.  */
70 #define SYNTAX_ENTRY_PREFIX(entry) (((entry) >> 20) & 1)
71 
72 enum syntaxcode			/* The possible syntax codes. */
73   {
74     syntaxcode_whitespace,	/* whitespace char */
75     syntaxcode_punct,		/* random punctuation char */
76     syntaxcode_word,		/* word constituent */
77     syntaxcode_symbol,		/* symbol constituent other than word */
78     syntaxcode_open,		/* beginning delimiter */
79     syntaxcode_close,		/* ending delimiter */
80     syntaxcode_quote,		/* prefix char like Lisp ' */
81     syntaxcode_string,		/* string-grouping char like Lisp " */
82     syntaxcode_math,		/* delimiters like $ in Tex. */
83     syntaxcode_escape,		/* char that begins a C-style escape */
84     syntaxcode_charquote,	/* char that quotes the following char */
85     syntaxcode_comment,		/* a comment-starting char */
86     syntaxcode_endcomment,	/* a comment-ending char */
87     syntaxcode_max		/* Upper bound on codes that are meaningful */
88   };
89 
90 #define SYNTAX_ENTRY_QUOTE(entry)					\
91   (((SYNTAX_ENTRY_CODE (entry)) == syntaxcode_escape)			\
92    || ((SYNTAX_ENTRY_CODE (entry)) == syntaxcode_charquote))
93 
94 /* This array, indexed by a character, contains the syntax code which that
95    character signifies (as a char).  For example,
96    ((enum syntaxcode) syntax_spec_code['w']) is syntaxcode_word. */
97 extern unsigned char syntax_spec_code [0x80];
98 
99 #define SYNTAX_TABLE_P(argument)					\
100   ((VECTOR_P (argument)) && ((VECTOR_LENGTH (argument)) == 0x100))
101 
102 #define SYNTAX_TABLE_TYPE SCHEME_OBJECT
103 
104 #define SYNTAX_TABLE_REF(table, index)					\
105   (VECTOR_REF ((table), ((index) & 0xFF)))
106