1 /* $Id: cpp.h,v 1.47.2.1 2011/02/26 06:36:40 ragge Exp $ */
4 * Copyright (c) 2004,2010 Anders Magnusson (ragge@ludd.luth.se).
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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 */
33 typedef unsigned char usch
;
35 extern usch
*stringbuf
;
41 extern int tflag
, Cflag
, Pflag
;
42 extern int Mflag
, dMflag
;
46 /* args for lookup() */
50 /* buffer used internally */
52 #if defined(__pdp11__)
56 /* winxp seems to fail > 26608 bytes */
59 #define CPPBUF (65536*2)
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 */
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
];
80 extern unsigned short bptr
[RECMAX
];
82 #define MKB(l,h) (l+((h)<<8))
84 /* quick checks for some characters */
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)
94 /* definition for include file info */
97 const usch
*fname
; /* current fn, changed if #line found */
98 const usch
*orgfn
; /* current fn, not changed */
115 /* Symbol table entry */
130 * Struct used in parse tree evaluation.
132 * - number type (NUMBER, UNUMBER)
133 * - zero (0) if divided by zero.
139 unsigned long long uval
;
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
);
154 int pushfile(const usch
*fname
, const usch
*fn
, int idx
, void *incs
);
163 void setfile(char *);
165 void yyerror(const char *);
166 void unpstr(const usch
*);
167 usch
*savstr(const usch
*str
);
171 void putstr(const usch
*s
);
173 usch
*sheap(const char *fmt
, ...);
174 void xwarning(usch
*);
176 #ifdef HAVE_CPP_VARARG_MACRO_GCC
177 #define warning(...) xwarning(sheap(__VA_ARGS__))
178 #define error(...) xerror(sheap(__VA_ARGS__))
180 #define warning printf