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+
22+enum 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+
31+enum 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+
45+enum { Notinmacro, Inmacro };
46+
47+typedef 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+
56+typedef 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+
63+typedef 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+
76+typedef 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+
86+typedef 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))
95+extern unsigned long namebit[077+1];
96+
97+enum errtype { WARNING, ERROR, FATAL };
98+
99+void expandlex(void);
100+void fixlex(void);
101+void setup(int, char **);
102+#define gettokens cpp_gettokens
103+int gettokens(Tokenrow *, int);
104+int comparetokens(Tokenrow *, Tokenrow *);
105+Source *setsource(char *, int, char *);
106+void unsetsource(void);
107+void puttokens(Tokenrow *);
108+void process(Tokenrow *);
109+void *dorealloc(void *, int);
110+void *domalloc(int);
111+void dofree(void *);
112+void error(enum errtype, char *, ...);
113+void flushout(void);
114+int fillbuf(Source *);
115+int trigraph(Source *);
116+int foldline(Source *);
117+Nlist *lookup(Token *, int);
118+void control(Tokenrow *);
119+void dodefine(Tokenrow *);
120+void doadefine(Tokenrow *, int);
121+void doinclude(Tokenrow *);
122+void doif(Tokenrow *, enum kwtype);
123+void expand(Tokenrow *, Nlist *, int);
124+void builtin(Tokenrow *, int);
125+int gatherargs(Tokenrow *, Tokenrow **, int, int *);
126+void substargs(Nlist *, Tokenrow *, Tokenrow **);
127+void expandrow(Tokenrow *, char *, int);
128+void maketokenrow(int, Tokenrow *);
129+Tokenrow *copytokenrow(Tokenrow *, Tokenrow *);
130+Token *growtokenrow(Tokenrow *);
131+Tokenrow *normtokenrow(Tokenrow *);
132+void adjustrow(Tokenrow *, int);
133+void movetokenrow(Tokenrow *, Tokenrow *);
134+void insertrow(Tokenrow *, int, Tokenrow *);
135+void peektokens(Tokenrow *, char *);
136+void doconcat(Tokenrow *);
137+Tokenrow *stringify(Tokenrow *);
138+int lookuparg(Nlist *, Token *);
139+long eval(Tokenrow *, int);
140+void genline(void);
141+void setempty(Tokenrow *);
142+void makespace(Tokenrow *);
143+char *outnum(char *, int);
144+int digit(int);
145+uchar *newstring(uchar *, int, int);
146+int checkhideset(int, Nlist *);
147+void prhideset(int);
148+int newhideset(int, Nlist *);
149+int unionhideset(int, int);
150+void iniths(void);
151+void setobjname(char *);
152+void clearwstab(void);
153+#define rowlen(tokrow) ((tokrow)->lp - (tokrow)->bp)
154+
155+extern char *outp;
156+extern Token nltoken;
157+extern Source *cursource;
158+extern char *curtime;
159+extern int incdepth;
160+extern int ifdepth;
161+extern int ifsatisfied[NIF];
162+extern int Mflag;
163+extern int nolineinfo;
164+extern int skipping;
165+extern int verbose;
166+extern int Cplusplus;
167+extern Nlist *kwdefined;
168+extern Includelist includelist[NINCLUDE];
169+extern char wd[];