History

bleh, still have to .keep some dirs.

initial commit

echoline committed 11 years ago

Commit 3833b13No parent (first commit)14470 files · +3080158 −-4496Browse files

Showing the changes to sys/src/cmd/cpp/cpp.h (1 of 14470 files). Show all

Unified · Split

sys/src/cmd/cpp/cpp.h+169−0
@@ -0,0 +1,169 @@
1/*
2 * This file is part of the UCB release of Plan 9. It is subject to the license
3 * terms in the LICENSE file found in the top-level directory of this
4 * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
5 * part of the UCB release of Plan 9, including this file, may be copied,
6 * modified, propagated, or distributed except according to the terms contained
7 * in the LICENSE file.
8 */
9
10#define INS 32768 /* input buffer */
11#define OBS 4096 /* outbut buffer */
12#define NARG 128 /* Max number arguments to a macro */
13#define NINCLUDE 64 /* Max number of include directories (-I) */
14#define NIF 32 /* depth of nesting of #if */
15#ifndef EOF
16#define EOF (-1)
17#endif
18#ifndef NULL
19#define NULL 0
20#endif
21
22enum toktype { END, UNCLASS, NAME, NUMBER, STRING, CCON, NL, WS, DSHARP,
23 EQ, NEQ, LEQ, GEQ, LSH, RSH, LAND, LOR, PPLUS, MMINUS,
24 ARROW, SBRA, SKET, LP, RP, DOT, AND, STAR, PLUS, MINUS,
25 TILDE, NOT, SLASH, PCT, LT, GT, CIRC, OR, QUEST,
26 COLON, ASGN, COMMA, SHARP, SEMIC, CBRA, CKET,
27 ASPLUS, ASMINUS, ASSTAR, ASSLASH, ASPCT, ASCIRC, ASLSH,
28 ASRSH, ASOR, ASAND, ELLIPS,
29 DSHARP1, NAME1, DEFINED, UMINUS };
30
31enum kwtype { KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KDEFINE,
32 KUNDEF, KLINE, KERROR, KWARNING, KPRAGMA, KDEFINED,
33 KLINENO, KFILE, KDATE, KTIME, KSTDC, KEVAL };
34
35#define ISDEFINED 01 /* has #defined value */
36#define ISKW 02 /* is PP keyword */
37#define ISUNCHANGE 04 /* can't be #defined in PP */
38#define ISMAC 010 /* builtin macro, e.g. __LINE__ */
39#define ISVARMAC 020 /* variadic macro */
40
41#define EOB 0xFE /* sentinel for end of input buffer */
42#define EOFC 0xFD /* sentinel for end of input file */
43#define XPWS 1 /* token flag: white space to assure token sep. */
44
45enum { Notinmacro, Inmacro };
46
47typedef struct token {
48 unsigned char type;
49 unsigned char flag;
50 unsigned short hideset;
51 unsigned int wslen;
52 unsigned int len;
53 uchar *t;
54} Token;
55
56typedef struct tokenrow {
57 Token *tp; /* current one to scan */
58 Token *bp; /* base (allocated value) */
59 Token *lp; /* last+1 token used */
60 int max; /* number allocated */
61} Tokenrow;
62
63typedef struct source {
64 char *filename; /* name of file of the source */
65 int line; /* current line number */
66 int lineinc; /* adjustment for \\n lines */
67 uchar *inb; /* input buffer */
68 uchar *inp; /* input pointer */
69 uchar *inl; /* end of input */
70 int ins; /* input buffer size */
71 int fd; /* input source */
72 int ifdepth; /* conditional nesting in include */
73 struct source *next; /* stack for #include */
74} Source;
75
76typedef struct nlist {
77 struct nlist *next;
78 uchar *name;
79 int len;
80 Tokenrow *vp; /* value as macro */
81 Tokenrow *ap; /* list of argument names, if any */
82 char val; /* value as preprocessor name */
83 char flag; /* is defined, is pp name */
84} Nlist;
85
86typedef struct includelist {
87 char deleted;
88 char always;
89 char *file;
90} Includelist;
91
92#define new(t) (t *)domalloc(sizeof(t))
93#define quicklook(a,b) (namebit[(a)&077] & (1<<((b)&037)))
94#define quickset(a,b) namebit[(a)&077] |= (1<<((b)&037))
95extern unsigned long namebit[077+1];
96
97enum errtype { WARNING, ERROR, FATAL };
98
99void expandlex(void);
100void fixlex(void);
101void setup(int, char **);
102#define gettokens cpp_gettokens
103int gettokens(Tokenrow *, int);
104int comparetokens(Tokenrow *, Tokenrow *);
105Source *setsource(char *, int, char *);
106void unsetsource(void);
107void puttokens(Tokenrow *);
108void process(Tokenrow *);
109void *dorealloc(void *, int);
110void *domalloc(int);
111void dofree(void *);
112void error(enum errtype, char *, ...);
113void flushout(void);
114int fillbuf(Source *);
115int trigraph(Source *);
116int foldline(Source *);
117Nlist *lookup(Token *, int);
118void control(Tokenrow *);
119void dodefine(Tokenrow *);
120void doadefine(Tokenrow *, int);
121void doinclude(Tokenrow *);
122void doif(Tokenrow *, enum kwtype);
123void expand(Tokenrow *, Nlist *, int);
124void builtin(Tokenrow *, int);
125int gatherargs(Tokenrow *, Tokenrow **, int, int *);
126void substargs(Nlist *, Tokenrow *, Tokenrow **);
127void expandrow(Tokenrow *, char *, int);
128void maketokenrow(int, Tokenrow *);
129Tokenrow *copytokenrow(Tokenrow *, Tokenrow *);
130Token *growtokenrow(Tokenrow *);
131Tokenrow *normtokenrow(Tokenrow *);
132void adjustrow(Tokenrow *, int);
133void movetokenrow(Tokenrow *, Tokenrow *);
134void insertrow(Tokenrow *, int, Tokenrow *);
135void peektokens(Tokenrow *, char *);
136void doconcat(Tokenrow *);
137Tokenrow *stringify(Tokenrow *);
138int lookuparg(Nlist *, Token *);
139long eval(Tokenrow *, int);
140void genline(void);
141void setempty(Tokenrow *);
142void makespace(Tokenrow *);
143char *outnum(char *, int);
144int digit(int);
145uchar *newstring(uchar *, int, int);
146int checkhideset(int, Nlist *);
147void prhideset(int);
148int newhideset(int, Nlist *);
149int unionhideset(int, int);
150void iniths(void);
151void setobjname(char *);
152void clearwstab(void);
153#define rowlen(tokrow) ((tokrow)->lp - (tokrow)->bp)
154
155extern char *outp;
156extern Token nltoken;
157extern Source *cursource;
158extern char *curtime;
159extern int incdepth;
160extern int ifdepth;
161extern int ifsatisfied[NIF];
162extern int Mflag;
163extern int nolineinfo;
164extern int skipping;
165extern int verbose;
166extern int Cplusplus;
167extern Nlist *kwdefined;
168extern Includelist includelist[NINCLUDE];
169extern char wd[];