source: mainline/uspace/app/pcc/cc/cpp/cpp.h@ a7de7182

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a7de7182 was a7de7182, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Added pcc source tree (contents of pcc-1.0.0.tgz)

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/* $Id: cpp.h,v 1.47.2.1 2011/02/26 06:36:40 ragge Exp $ */
2
3/*
4 * Copyright (c) 2004,2010 Anders Magnusson (ragge@ludd.luth.se).
5 * All rights reserved.
6 *
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.
15 *
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.
26 */
27
28#include <stdio.h> /* for obuf */
29#include <stdlib.h>
30
31#include "config.h"
32
33typedef unsigned char usch;
34extern usch yytext[];
35extern usch *stringbuf;
36
37extern int trulvl;
38extern int flslvl;
39extern int elflvl;
40extern int elslvl;
41extern int tflag, Cflag, Pflag;
42extern int Mflag, dMflag;
43extern usch *Mfile;
44extern int ofd;
45
46/* args for lookup() */
47#define FIND 0
48#define ENTER 1
49
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
62
63#define MAXARGS 128 /* Max # of args to a macro. Should be enouth */
64
65#define NAMEMAX CPPBUF /* currently pushbackbuffer */
66#define BBUFSZ (NAMEMAX+CPPBUF+1)
67
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 */
75
76/* Used in macro expansion */
77#define RECMAX 10000 /* max # of recursive macros */
78extern struct symtab *norep[RECMAX];
79extern int norepptr;
80extern unsigned short bptr[RECMAX];
81extern int bidx;
82#define MKB(l,h) (l+((h)<<8))
83
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)
92extern char spechr[];
93
94/* definition for include file info */
95struct 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;
114
115/* Symbol table entry */
116struct symtab {
117 const usch *namep;
118 const usch *value;
119 const usch *file;
120 int line;
121};
122
123struct initar {
124 struct initar *next;
125 int type;
126 char *str;
127};
128
129/*
130 * Struct used in parse tree evaluation.
131 * op is one of:
132 * - number type (NUMBER, UNUMBER)
133 * - zero (0) if divided by zero.
134 */
135struct nd {
136 int op;
137 union {
138 long long val;
139 unsigned long long uval;
140 } n;
141};
142
143#define nd_val n.val
144#define nd_uval n.uval
145
146struct symtab *lookup(const usch *namep, int enterf);
147usch *gotident(struct symtab *nl);
148int slow; /* scan slowly for new tokens */
149int submac(struct symtab *nl, int);
150int kfind(struct symtab *nl);
151int doexp(void);
152int donex(void);
153
154int pushfile(const usch *fname, const usch *fn, int idx, void *incs);
155void popfile(void);
156void prtline(void);
157int yylex(void);
158int sloscan(void);
159void cunput(int);
160int curline(void);
161char *curfile(void);
162void setline(int);
163void setfile(char *);
164int yyparse(void);
165void yyerror(const char *);
166void unpstr(const usch *);
167usch *savstr(const usch *str);
168void savch(int c);
169void mainscan(void);
170void putch(int);
171void putstr(const usch *s);
172void line(void);
173usch *sheap(const char *fmt, ...);
174void xwarning(usch *);
175void 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
183int cinput(void);
184void getcmnt(void);
Note: See TracBrowser for help on using the repository browser.