Pristine Ack-5.5
[Ack-5.5.git] / util / cpp / macro.h
1 /* $Id: macro.h,v 1.9 1994/06/24 10:18:38 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 /* PREPROCESSOR: DEFINITION OF MACRO DESCRIPTOR */
7
8 /*      The flags of the mc_flag field of the macro structure. Note that
9         these flags can be set simultaneously.
10 */
11 #define NOFLAG          0               /* no special flags     */
12 #define FUNC            01              /* function attached    */
13 #define NOREPLACE       02              /* don't replace        */
14
15 #define FORMALP 0200    /* mask for creating macro formal parameter     */
16
17 /*      The macro descriptor is very simple, except the fact that the
18         mc_text, which points to the replacement text, contains the
19         non-ascii characters \201, \202, etc, indicating the position of a
20         formal parameter in this text.
21 */
22 struct macro    {
23         struct macro *next;
24         char *  mc_text;        /* the replacement text         */
25         int     mc_nps;         /* number of formal parameters  */
26         int     mc_length;      /* length of replacement text   */
27         int     mc_count;       /* # of "concurrent" invocations*/
28         char    mc_flag;        /* marking this macro           */
29 };
30
31
32 /* allocation definitions of struct macro */
33 extern char *st_alloc();
34 extern struct macro *h_macro;
35 #ifdef DEBUG
36 extern int cnt_macro;
37 extern char *std_alloc();
38 #define new_macro() ((struct macro *) std_alloc((char **)&h_macro, sizeof(struct macro), 20, &cnt_macro))
39 #else
40 #define new_macro() ((struct macro *) st_alloc((char **)&h_macro, sizeof(struct macro), 20))
41 #endif
42 #define free_macro(p) st_free(p, &h_macro, sizeof(struct macro))
43
44 struct mlist {
45         struct mlist *next;
46         struct macro *m_mac;
47         char *m_repl;
48         int m_level;
49 };
50
51 /* allocation definitions of struct mlist */
52 extern char *st_alloc();
53 extern struct mlist *h_mlist;
54 #ifdef DEBUG
55 extern int cnt_mlist;
56 extern char *std_alloc();
57 #define new_mlist() ((struct mlist *) std_alloc((char **)&h_mlist, sizeof(struct mlist), 20, &cnt_mlist))
58 #else
59 #define new_mlist() ((struct mlist *) st_alloc((char **)&h_mlist, sizeof(struct mlist), 20))
60 #endif
61 #define free_mlist(p) st_free(p, &h_mlist, sizeof(struct mlist))
62
63
64 /* `token' numbers of keywords of command-line processor
65 */
66 #define K_UNKNOWN       0
67 #define K_DEFINE        1
68 #define K_ELIF          2
69 #define K_ELSE          3
70 #define K_ENDIF         4
71 #define K_IF            5
72 #define K_IFDEF         6
73 #define K_IFNDEF        7
74 #define K_INCLUDE       8
75 #define K_LINE          9
76 #define K_UNDEF         10
77 #define K_PRAGMA        11
78 #define K_FILE          100     /* for dependency generator */