OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [lcc/] [cpp/] [cpp.h] - Blame information for rev 288

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.