summaryrefslogtreecommitdiff
path: root/bcc/scan.h
blob: 48ff5d2b1b1cdbc986553930f1559c715d5c7198 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/* scan.h - scanner for bcc */

/* Copyright (C) 1992 Bruce Evans */

#define NAMESIZE	64	/* limit on identifier lengths */
#define SYMOFCHAR(ch)	(symofchar[(unsigned char) (ch)])

/* scanner codes */

enum scan_states
{
/* The first group of entries consists of all the values that occur in the
   switch for cppscan().
*/
    IDENT,
    INTCONST,
#define MAXIDSYM INTCONST	/* IDENT and INTCONST must be the only
				 * symofchar[] entries below this */
    FLOATCONST,
#define MAXPPNUMSYM FLOATCONST	/* IDENT, INTCONST and FLOATCONST must be the
				 * only symofchar[] entries below this */
    CHARCONST,
    CONTROL,
    SLASH,
    SPECIALCHAR,
    STRINGCONST,

/* The next group of entries are all the rest of the values that occur in
   symofchar[] and so in the switch for nextsym().
*/
    AMPERSAND,			/* ADDRESSOP or ANDOP */
    BADCHAR,
    COLON,			/* also COLONOP */
    COMMA,			/* also COMMAOP */
    DECSYM,			/* PREDECOP or POSTDECOP */
    EOFSYM,
    HYPHEN,			/* NEGOP or SUBOP */
    INCSYM,			/* PREINCOP or POSTINCOP */
    LBRACE,
    LBRACKET,
    LPAREN,
    RBRACE,
    RBRACKET,
    RPAREN,
    SEMICOLON,
    STAR,			/* INDIRECTOP or MULOP */
    WHITESPACE,

/* The next group of entries consists of all operator codes.  These codes must
   be contiguous so they can be used as (offsetted) array indexes.  The group
   is ordered by operator-precedence (this is not necessary).  The first part
   of it overlaps the previous group.
*/

/* Assign-abops (level 1) belong here but are at end to improve switch. */

#define FIRSTOP CONDOP
    CONDOP,			/* level 2 */

    OROP,			/* level 5 */

    EOROP,			/* level 6 */

    ANDOP,			/* level 7 */

    GTOP,			/* level 9 */
    LTOP,

    ADDOP,			/* level 11 */

    DIVOP,			/* level 12 */
    MODOP,

    LOGNOTOP,			/* level 13 */
    NOTOP,

    STRUCELTOP,			/* level 14 */
    STRUCPTROP,

/* End of symbols that appear in symofchar[]. */

    ASSIGNOP,			/* level 1 - assign ops must be contiguous */
    ADDABOP,
    ANDABOP,
    DIVABOP,
    EORABOP,
    MODABOP,
    MULABOP,
    ORABOP,
    SLABOP,
    SRABOP,
    SUBABOP,

    COMMAOP,			/* level 0 */

    COLONOP,			/* level 2 */

    LOGOROP,			/* level 3 */

    LOGANDOP,			/* level 4 */

    EQOP,			/* level 8 */
    NEOP,

    GEOP,			/* level 9 */
    LEOP,

    SLOP,			/* level 10 */
    SROP,

    SUBOP,			/* level 11 */

    MULOP,			/* level 12 */

    ADDRESSOP,			/* level 13 */
    CASTOP,
    INDIRECTOP,
    NEGOP,
    PREDECOP,
    PREINCOP,
    POSTDECOP,
    POSTINCOP,

    FUNCOP,			/* level 14 */
    LISTOP,
    ROOTLISTOP,

    LEAF,			/* special */
    PTRADDABOP,
    PTRADDOP,
    PTRSUBOP,

/* end of operator codes (they must stay contiguous) */

#define LASTOP PTRSUBOP

    ENUMDECL,
    NULLDECL,
    SIGNDECL,
    STRUCTDECL,
    TYPEDECL,
    TYPEDEFNAME,
    UNIONDECL,
    UNSIGNDECL,

    AUTODECL,
    EXTERNDECL,
    REGDECL,
    STATICDECL,
    TYPEDEFDECL,

    ASMSYM,
    BREAKSYM,
    CASESYM,
    CONTSYM,
    DEFAULTSYM,
    DEFINEDSYM,
    DOSYM,
    ELSESYM,
    FORSYM,
    GOTOSYM,
    IFSYM,
    RETURNSYM,
    SIZEOFSYM,
    SWITCHSYM,
    WHILESYM,

    ASMCNTL,
    DEFINECNTL,
    ENDASMCNTL,
    INCLUDECNTL,
    LINECNTL,
    UNDEFCNTL,
    WARNINGCNTL,
    ERRORCNTL,

    ELIFCNTL,			/* "IF" controls must be contiguous */
    ELSECNTL,
    ENDIFCNTL,
    IFCNTL,
    IFDEFCNTL,
    IFNDEFCNTL
};

EXTERN op_pt arg1op;		/* LISTOP, or ROOTLISTOP if arg1inreg */
EXTERN struct
{
    union
    {
	char *s;
	value_t v;
	double d;
    }
      value;
    struct typestruct *type;
}
 constant;			/* value of last constant scanned */
				/* sym tells type */
EXTERN char funcname[NAMESIZE];	/* name of current function for unique labels */
EXTERN char gs2name[2 + NAMESIZE];	/* 2 reserved for namespace keys */
#define gsname (gs2name + 2)	/* before last identifier */
EXTERN struct symstruct *gsymptr;	/* symbol ptr for last identifier */
EXTERN bool_t incppexpr;	/* nonzero while scanning cpp expression */
EXTERN sym_t sym;		/* current symbol */
extern sym_t symofchar[];	/* table to convert chars to their symbols */
EXTERN bool_t expect_statement; /* If set #asm needs to clear the recursive
				 * pending operations. ie: if stmts. */