* add p cc
[mascara-docs.git] / compilers / pcc / pcc-1.0.0 / cc / cpp / cpp.h
blobab0d42d7554d077d267b1f36e0e5d81fa57a2a72
1 /* $Id: cpp.h,v 1.47.2.1 2011/02/26 06:36:40 ragge Exp $ */
3 /*
4 * Copyright (c) 2004,2010 Anders Magnusson (ragge@ludd.luth.se).
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include <stdio.h> /* for obuf */
29 #include <stdlib.h>
31 #include "config.h"
33 typedef unsigned char usch;
34 extern usch yytext[];
35 extern usch *stringbuf;
37 extern int trulvl;
38 extern int flslvl;
39 extern int elflvl;
40 extern int elslvl;
41 extern int tflag, Cflag, Pflag;
42 extern int Mflag, dMflag;
43 extern usch *Mfile;
44 extern int ofd;
46 /* args for lookup() */
47 #define FIND 0
48 #define ENTER 1
50 /* buffer used internally */
51 #ifndef CPPBUF
52 #if defined(__pdp11__)
53 #define CPPBUF BUFSIZ
54 #define BUF_STACK
55 #elif defined(WIN32)
56 /* winxp seems to fail > 26608 bytes */
57 #define CPPBUF 16384
58 #else
59 #define CPPBUF (65536*2)
60 #endif
61 #endif
63 #define MAXARGS 128 /* Max # of args to a macro. Should be enouth */
65 #define NAMEMAX CPPBUF /* currently pushbackbuffer */
66 #define BBUFSZ (NAMEMAX+CPPBUF+1)
68 #define GCCARG 0xfd /* has gcc varargs that may be replaced with 0 */
69 #define VARG 0xfe /* has varargs */
70 #define OBJCT 0xff
71 #define WARN 1 /* SOH, not legal char */
72 #define CONC 2 /* STX, not legal char */
73 #define SNUFF 3 /* ETX, not legal char */
74 #define EBLOCK 4 /* EOT, not legal char */
76 /* Used in macro expansion */
77 #define RECMAX 10000 /* max # of recursive macros */
78 extern struct symtab *norep[RECMAX];
79 extern int norepptr;
80 extern unsigned short bptr[RECMAX];
81 extern int bidx;
82 #define MKB(l,h) (l+((h)<<8))
84 /* quick checks for some characters */
85 #define C_SPEC 001
86 #define C_EP 002
87 #define C_ID 004
88 #define C_I (C_SPEC|C_ID)
89 #define C_2 010 /* for yylex() tokenizing */
90 #define C_WSNL 020 /* ' ','\t','\r','\n' */
91 #define iswsnl(x) (spechr[x] & C_WSNL)
92 extern char spechr[];
94 /* definition for include file info */
95 struct includ {
96 struct includ *next;
97 const usch *fname; /* current fn, changed if #line found */
98 const usch *orgfn; /* current fn, not changed */
99 int lineno;
100 int infil;
101 usch *curptr;
102 usch *maxread;
103 usch *ostr;
104 usch *buffer;
105 int idx;
106 void *incs;
107 const usch *fn;
108 #ifdef BUF_STACK
109 usch bbuf[BBUFSZ];
110 #else
111 usch *bbuf;
112 #endif
113 } *ifiles;
115 /* Symbol table entry */
116 struct symtab {
117 const usch *namep;
118 const usch *value;
119 const usch *file;
120 int line;
123 struct initar {
124 struct initar *next;
125 int type;
126 char *str;
130 * Struct used in parse tree evaluation.
131 * op is one of:
132 * - number type (NUMBER, UNUMBER)
133 * - zero (0) if divided by zero.
135 struct nd {
136 int op;
137 union {
138 long long val;
139 unsigned long long uval;
140 } n;
143 #define nd_val n.val
144 #define nd_uval n.uval
146 struct symtab *lookup(const usch *namep, int enterf);
147 usch *gotident(struct symtab *nl);
148 int slow; /* scan slowly for new tokens */
149 int submac(struct symtab *nl, int);
150 int kfind(struct symtab *nl);
151 int doexp(void);
152 int donex(void);
154 int pushfile(const usch *fname, const usch *fn, int idx, void *incs);
155 void popfile(void);
156 void prtline(void);
157 int yylex(void);
158 int sloscan(void);
159 void cunput(int);
160 int curline(void);
161 char *curfile(void);
162 void setline(int);
163 void setfile(char *);
164 int yyparse(void);
165 void yyerror(const char *);
166 void unpstr(const usch *);
167 usch *savstr(const usch *str);
168 void savch(int c);
169 void mainscan(void);
170 void putch(int);
171 void putstr(const usch *s);
172 void line(void);
173 usch *sheap(const char *fmt, ...);
174 void xwarning(usch *);
175 void xerror(usch *);
176 #ifdef HAVE_CPP_VARARG_MACRO_GCC
177 #define warning(...) xwarning(sheap(__VA_ARGS__))
178 #define error(...) xerror(sheap(__VA_ARGS__))
179 #else
180 #define warning printf
181 #define error printf
182 #endif
183 int cinput(void);
184 void getcmnt(void);