/* -*-C-*-
-$Id: syntax.c,v 1.28 2004/12/17 03:46:22 cph Exp $
+$Id: syntax.c,v 1.29 2005/07/15 05:31:09 cph Exp $
Copyright 1987,1988,1989,1991,1993,1996 Massachusetts Institute of Technology
-Copyright 2000,2004 Massachusetts Institute of Technology
+Copyright 2000,2004,2005 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
/* Convert a letter which signifies a syntax code
into the code it signifies. */
-#define ILLEGAL ((char) syntaxcode_max)
+#define ILLEGAL ((unsigned char) syntaxcode_max)
-char syntax_spec_code[0200] =
+unsigned char syntax_spec_code [0x80] =
{
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
- ((char) syntaxcode_whitespace), ILLEGAL, ((char) syntaxcode_string),
- ILLEGAL, ((char) syntaxcode_math), ILLEGAL, ILLEGAL,
- ((char) syntaxcode_quote),
- ((char) syntaxcode_open), ((char) syntaxcode_close), ILLEGAL, ILLEGAL,
- ILLEGAL, ((char) syntaxcode_whitespace), ((char) syntaxcode_punct),
- ((char) syntaxcode_charquote),
+ ((unsigned char) syntaxcode_whitespace),
+ ILLEGAL,
+ ((unsigned char) syntaxcode_string),
+ ILLEGAL,
+ ((unsigned char) syntaxcode_math),
+ ILLEGAL,
+ ILLEGAL,
+ ((unsigned char) syntaxcode_quote),
+
+ ((unsigned char) syntaxcode_open),
+ ((unsigned char) syntaxcode_close),
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ((unsigned char) syntaxcode_whitespace),
+ ((unsigned char) syntaxcode_punct),
+ ((unsigned char) syntaxcode_charquote),
+
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
- ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ((char) syntaxcode_comment),
- ILLEGAL, ((char) syntaxcode_endcomment), ILLEGAL,
+
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ((unsigned char) syntaxcode_comment),
+ ILLEGAL,
+ ((unsigned char) syntaxcode_endcomment),
+ ILLEGAL,
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
- ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
- ((char) syntaxcode_word),
- ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ((char) syntaxcode_escape), ILLEGAL,
- ILLEGAL, ((char) syntaxcode_symbol),
+
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ((unsigned char) syntaxcode_word),
+
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ((unsigned char) syntaxcode_escape),
+ ILLEGAL,
+ ILLEGAL,
+ ((unsigned char) syntaxcode_symbol),
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
- ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
- ((char) syntaxcode_word),
+
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ILLEGAL,
+ ((unsigned char) syntaxcode_word),
+
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL
};
' ', '.', 'w', '_', '(', ')', '\'', '\"', '$', '\\', '/', '<', '>'
};
\f
-#define MERGE_PREFIX_BIT(bit) \
+#define MERGE_PREFIX_BIT(bit) do \
{ \
if ((result & bit) != 0) \
error_bad_range_arg (1); \
result |= bit; \
-}
+} while (0)
#define MERGE_COMMENT(bit) MERGE_PREFIX_BIT ((bit) << 12)
DEFINE_PRIMITIVE ("STRING->SYNTAX-ENTRY", Prim_string_to_syntax_entry, 1, 1, 0)
{
- long length, c, result;
+ unsigned long length;
+ unsigned long result;
unsigned char * scan;
PRIMITIVE_HEADER (1);
if ((length--) > 0)
{
- c = (*scan++);
+ unsigned long c = (*scan++);
if (c >= 0200) error_bad_range_arg (1);
- result = (syntax_spec_code [c]);
+ result = (syntax_spec_code[c]);
if (result == ILLEGAL) error_bad_range_arg (1);
}
else
- result = ((long) syntaxcode_whitespace);
+ result = ((unsigned long) syntaxcode_whitespace);
if ((length--) > 0)
{
- c = (*scan++);
+ unsigned long c = (*scan++);
if (c != ' ') result |= (c << 4);
}
if (((SYNTAX_ENTRY_CODE (result)) == syntaxcode_endcomment)
&& (! ((SYNTAX_ENTRY_COMMENT_BITS (result)) & COMEND_FIRST)))
MERGE_COMMENT (COMEND_FIRST_A);
- PRIMITIVE_RETURN (LONG_TO_UNSIGNED_FIXNUM (result));
+ PRIMITIVE_RETURN (ULONG_TO_FIXNUM (result));
}
DEFINE_PRIMITIVE ("CHAR->SYNTAX-CODE", Prim_char_to_syntax_code, 2, 2, 0)