xref: /plan9/sys/src/cmd/gs/src/scanchar.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1990, 1995, 1996 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: scanchar.h,v 1.4 2002/02/21 22:24:53 giles Exp $ */
18 /* Definitions for token scanner character type table */
19 /* Requires scommon.h */
20 
21 #ifndef scanchar_INCLUDED
22 #  define scanchar_INCLUDED
23 
24 /*
25  * An array for fast scanning of names, numbers, and hex strings.
26  * Indexed by character code (including exceptions), it contains:
27  *      0 - max_radix-1 for valid digits,
28  *      ctype_name for other characters valid in names,
29  *      ctype_btoken for characters introducing binary tokens
30  *        (if the binary token feature is enabled),
31  *      ctype_space for whitespace characters,
32  *      ctype_exception for exceptions (see scommon.h), and
33  *      ctype_other for everything else.
34  * Exceptions are negative values; we bias the table origin accordingly.
35  *
36  * NOTE: This table is defined in iscantab.c and used in a variety of places.
37  * If any of the values below change, you must edit the table.
38  */
39 extern const byte scan_char_array[max_stream_exception + 256];
40 
41 #define scan_char_decoder (&scan_char_array[max_stream_exception])
42 #define min_radix 2
43 #define max_radix 36
44 #define ctype_name 100
45 #define ctype_btoken 101
46 #define ctype_space 102
47 #define ctype_other 103
48 #define ctype_exception 104
49 /* Special characters with no \xxx representation */
50 #define char_NULL 0
51 #define char_EOT 004		/* ^D, job delimiter */
52 #define char_VT 013		/* ^K, vertical tab */
53 #define char_DOS_EOF 032	/* ^Z */
54 /*
55  * Most systems define '\n' as 0x0a and '\r' as 0x0d; however, OS-9
56  * has '\n' = '\r' = 0x0d and '\l' = 0x0a.  To deal with this,
57  * we introduce abstract characters char_CR and char_EOL such that
58  * any of [char_CR], [char_CR char_EOL], or [char_EOL] is recognized
59  * as an end-of-line sequence.
60  */
61 #define char_CR '\r'
62 #if '\r' == '\n'
63 #  define char_EOL 0x0a		/* non-OS-9 compilers complain about '\l' */
64 #else
65 #  define char_EOL '\n'
66 #endif
67 
68 #endif /* scanchar_INCLUDED */
69