]> git.sur5r.net Git - cc65/blob - src/cc65/scanner.h
3becee72f46cff4cd4a35d3660268472bb32b286
[cc65] / src / cc65 / scanner.h
1 /*
2  * scanner.h
3  *
4  * Ullrich von Bassewitz, 07.06.1998
5  */
6
7
8
9 #ifndef SCANNER_H
10 #define SCANNER_H
11
12
13
14 #include "datatype.h"
15 #include "ident.h"
16
17
18
19 /*****************************************************************************/
20 /*                             token definitions                             */
21 /*****************************************************************************/
22
23
24
25 #define CEOF            0
26
27 #define AUTO            10
28 #define EXTERN          11
29 #define REGISTER        12
30 #define STATIC          13
31 #define TYPEDEF         14
32 #define ENUM            15
33 #define CONST           16
34 #define VOLATILE        17
35
36 #define FIRSTTYPE       19
37 #define CHAR            19
38 #define INT             20
39 #define DOUBLE          21
40 #define FLOAT           22
41 #define LONG            23
42 #define UNSIGNED        24
43 #define SIGNED          25
44 #define SHORT           26
45 #define STRUCT          27
46 #define UNION           28
47 #define VOID            29
48 #define LASTTYPE        29
49
50 #define DO              30
51 #define FOR             31
52 #define GOTO            32
53 #define IF              33
54 #define RETURN          34
55 #define SWITCH          35
56 #define WHILE           36
57
58 #define ASM             40
59 #define CASE            41
60 #define DEFAULT         42
61 #define BREAK           43
62 #define CONTINUE        44
63 #define ELSE            45
64 #define ELLIPSIS        46
65 #define SIZEOF          47
66
67 #define IDENT           50
68 #define SEMI            51
69
70 /* primary operators */
71 #define LBRACK          52
72 #define LPAREN          53
73 #define DOT             54
74 #define PREF            55
75
76 #define LCURLY          56
77 #define RBRACK          57
78 #define COMP            58
79 #define INC             59
80 #define PASGN           60
81 #define PLUS            61
82 #define COMMA           62
83 #define DEC             63
84 #define SASGN           64
85 #define RCURLY          65
86 #define MINUS           66
87 #define MASGN           67
88 #define STAR            68
89 #define DASGN           69
90 #define DIV             70
91 #define DAMP            71
92 #define AASGN           72
93 #define AMP             73
94 #define NE              74
95 #define BANG            75
96 #define DBAR            76
97 #define OASGN           77
98 #define BAR             78
99 #define EQ              79
100 #define ASGN            80
101 #define SLASGN          81
102 #define ASL             82
103
104 /* inequalities */
105 #define LE              83
106 #define LT              84
107 #define GE              85
108 #define GT              86
109
110 #define SRASGN          87
111 #define ASR             88
112 #define XOASGN          89
113 #define XOR             90
114 #define MOASGN          91
115 #define MOD             92
116 #define QUEST           93
117 #define COLON           94
118 #define RPAREN          95
119 #define SCONST          96
120 #define ICONST          97
121 #define CCONST          98
122 #define FCONST          99
123
124 #define FASTCALL        100
125 #define AX              101
126 #define EAX             102
127
128 #define PRAGMA          110
129
130
131
132 /*****************************************************************************/
133 /*                                   data                                    */
134 /*****************************************************************************/
135
136
137
138 /* Token stuff */
139 typedef struct Token_ Token;
140 struct Token_ {
141     unsigned    Tok;            /* The token itself */
142     long        IVal;           /* The integer attribute */
143     ident       Ident;          /* Identifier if IDENT */
144     unsigned    Pos;            /* Source line where the token comes from */
145     type*       IType;          /* Type if integer constant */
146 };
147
148 extern Token CurTok;            /* The current token */
149 extern Token NextTok;           /* The next token */
150
151 /* Defines to make the old code work */
152 #define curtok  CurTok.Tok
153 #define curval  CurTok.IVal
154 #define curpos  CurTok.Pos
155 #define curtype CurTok.IType
156
157 #define nxttok  NextTok.Tok
158 #define nxtval  NextTok.IVal
159 #define nxtpos  NextTok.Pos
160 #define nxttype NextTok.IType
161
162
163
164 /*****************************************************************************/
165 /*                                   code                                    */
166 /*****************************************************************************/
167
168
169
170 void symname (char* s);
171 /* Get symbol from input stream */
172
173 int issym (char* s);
174 /* Get symbol from input stream or return 0 if not a symbol. */
175
176 void gettok (void);
177 /* Get next token from input stream */
178
179 void Consume (unsigned Token, unsigned char ErrNum);
180 /* Eat token if it is the next in the input stream, otherwise print an error
181  * message.
182  */
183
184 void ConsumeColon (void);
185 /* Check for a colon and skip it. */
186
187 void ConsumeSemi (void);
188 /* Check for a semicolon and skip it. */
189
190 void ConsumeLParen (void);
191 /* Check for a left parenthesis and skip it */
192
193 void ConsumeRParen (void);
194 /* Check for a right parenthesis and skip it */
195
196 void ConsumeLBrack (void);
197 /* Check for a left bracket and skip it */
198
199 void ConsumeRBrack (void);
200 /* Check for a right bracket and skip it */
201
202 void ConsumeLCurly (void);
203 /* Check for a left curly brace and skip it */
204
205 void ConsumeRCurly (void);
206 /* Check for a right curly brace and skip it */
207
208
209
210 /* End of scanner.h */
211 #endif
212
213
214
215
216
217