Pristine Ack-5.5
[Ack-5.5.git] / util / cpp / class.h
1 /* $Id: class.h,v 1.5 1994/06/24 10:18:04 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 /* U S E   O F   C H A R A C T E R   C L A S S E S */
7
8 /*      As a starter, chars are divided into classes, according to which
9         token they can be the start of.
10         At present such a class number is supposed to fit in 4 bits.
11 */
12
13 #define class(ch)       (tkclass[(unsigned char) ch])
14
15 /*      Being the start of a token is, fortunately, a mutual exclusive
16         property, so, as there are less than 16 classes they can be
17         packed in 4 bits.
18 */
19
20 #define STSKIP  0       /* spaces and so on: skipped characters         */
21 #define STNL    1       /* newline character(s): update linenumber etc. */
22 #define STGARB  2       /* garbage ascii character: not allowed         */
23 #define STSIMP  3       /* this character can occur as token            */
24 #define STCOMP  4       /* this one can start a compound token          */
25 #define STIDF   5       /* being the initial character of an identifier */
26 #define STCHAR  6       /* the starter of a character constant          */
27 #define STSTR   7       /* the starter of a string                      */
28 #define STNUM   8       /* the starter of a numeric constant            */
29 #define STEOI   9       /* End-Of-Information mark                      */
30
31 /*      But occurring inside a token is not, so we need 1 bit for each
32         class.
33 */
34 #define _I_     01
35 #define _O_     02
36 #define _D_     04
37 #define _H_     010
38
39 #define in_idf(ch)      (tk2class[(unsigned char)ch] & _I_)
40 #define is_oct(ch)      (tk2class[(unsigned char)ch] & _O_)
41 #define is_dig(ch)      (tk2class[(unsigned char)ch] & _D_)
42 #define is_hex(ch)      (tk2class[(unsigned char)ch] & _H_)
43
44 extern char tkclass[], tk2class[];