]> git.sur5r.net Git - cc65/blob - src/ca65/scanner.h
Added condes tables to c64 config
[cc65] / src / ca65 / scanner.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 scanner.h                                 */
4 /*                                                                           */
5 /*                  The scanner for the ca65 macroassembler                  */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2000 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef SCANNER_H
37 #define SCANNER_H
38
39
40
41 /* common */
42 #include "filepos.h"
43
44
45
46 /*****************************************************************************/
47 /*                                   Data                                    */
48 /*****************************************************************************/
49
50
51
52 /* Tokens */
53 enum Token {
54     TOK_NONE,           /* Start value, invalid */
55     TOK_EOF,            /* End of input file */
56     TOK_SEP,            /* Separator (usually newline) */
57     TOK_IDENT,          /* An identifier */
58     TOK_MNEMO,          /* A mnemonic */
59
60     TOK_INTCON,         /* Integer constant */
61     TOK_CHARCON,        /* Character constant */
62     TOK_STRCON,         /* String constant */
63
64     TOK_A,              /* A)ccu */
65     TOK_X,              /* X register */
66     TOK_Y,              /* Y register */
67     TOK_S,              /* S register */
68
69     TOK_ULABEL,         /* :++ or :-- */
70
71     TOK_EQ,             /* = */
72     TOK_NE,             /* <> */
73     TOK_LT,             /* < */
74     TOK_GT,             /* > */
75     TOK_LE,             /* <= */
76     TOK_GE,             /* >= */
77
78     TOK_BAND,           /* .and */
79     TOK_BOR,            /* .or */
80     TOK_BXOR,           /* .xor */
81     TOK_BNOT,           /* .not */
82
83     TOK_PLUS,           /* + */
84     TOK_MINUS,          /* - */
85     TOK_MUL,            /* * */
86     TOK_STAR = TOK_MUL, /* Alias */
87     TOK_DIV,            /* / */
88     TOK_MOD,            /* ! */
89     TOK_OR,             /* | */
90     TOK_XOR,            /* ^ */
91     TOK_AND,            /* & */
92     TOK_SHL,            /* << */
93     TOK_SHR,            /* >> */
94     TOK_NOT,            /* ~ */
95
96     TOK_PC,             /* $ if enabled */
97     TOK_NAMESPACE,      /* :: */
98     TOK_DOT,            /* . */
99     TOK_COMMA,          /* , */
100     TOK_HASH,           /* # */
101     TOK_COLON,          /* : */
102     TOK_LPAREN,         /* ( */
103     TOK_RPAREN,         /* ) */
104     TOK_LBRACK,         /* [ */
105     TOK_RBRACK,         /* ] */
106
107     TOK_MACPARAM,       /* Macro parameter, not generated by scanner */
108     TOK_REPCOUNTER,     /* Repeat counter, not generated by scanner */
109
110     /* The next ones are tokens for the pseudo instructions. Keep together! */
111     TOK_FIRSTPSEUDO,
112     TOK_A16             = TOK_FIRSTPSEUDO,
113     TOK_A8,
114     TOK_ADDR,
115     TOK_ALIGN,
116     TOK_ASCIIZ,
117     TOK_AUTOIMPORT,
118     TOK_BLANK,
119     TOK_BSS,
120     TOK_BYTE,
121     TOK_CASE,
122     TOK_CODE,
123     TOK_CONCAT,     
124     TOK_CONDES,
125     TOK_CONST,
126     TOK_CONSTRUCTOR,
127     TOK_CPU,
128     TOK_DATA,
129     TOK_DBG,
130     TOK_DBYT,
131     TOK_DEBUGINFO,
132     TOK_DEFINE,
133     TOK_DEFINED,
134     TOK_DESTRUCTOR,
135     TOK_DWORD,
136     TOK_ELSE,
137     TOK_ELSEIF,
138     TOK_END,
139     TOK_ENDIF,
140     TOK_ENDMACRO,
141     TOK_ENDPROC,
142     TOK_ENDREP,
143     TOK_ERROR,
144     TOK_EXITMACRO,
145     TOK_EXPORT,
146     TOK_EXPORTZP,
147     TOK_FARADDR,
148     TOK_FEATURE,
149     TOK_FILEOPT,
150     TOK_FORCEWORD,
151     TOK_GLOBAL,
152     TOK_GLOBALZP,
153     TOK_I16,
154     TOK_I8,
155     TOK_IF,
156     TOK_IFBLANK,
157     TOK_IFCONST,
158     TOK_IFDEF,
159     TOK_IFNBLANK,
160     TOK_IFNCONST,
161     TOK_IFNDEF,
162     TOK_IFNREF,
163     TOK_IFP02,
164     TOK_IFP816,
165     TOK_IFPC02,
166     TOK_IFREF,
167     TOK_IMPORT,
168     TOK_IMPORTZP,
169     TOK_INCBIN,
170     TOK_INCLUDE,
171     TOK_LEFT,
172     TOK_LINECONT,
173     TOK_LIST,
174     TOK_LISTBYTES,
175     TOK_LOCAL,
176     TOK_LOCALCHAR,
177     TOK_MACPACK,
178     TOK_MACRO,
179     TOK_MATCH,
180     TOK_MID,
181     TOK_NULL,
182     TOK_ORG,
183     TOK_OUT,
184     TOK_P02,
185     TOK_P816,
186     TOK_PAGELENGTH,
187     TOK_PARAMCOUNT,
188     TOK_PC02,
189     TOK_PROC,
190     TOK_REFERENCED,
191     TOK_RELOC,
192     TOK_REPEAT,
193     TOK_RES,
194     TOK_RIGHT,
195     TOK_RODATA,
196     TOK_SEGMENT,
197     TOK_SMART,
198     TOK_STRAT,
199     TOK_STRING,
200     TOK_STRLEN,
201     TOK_SUNPLUS,
202     TOK_TCOUNT,
203     TOK_WARNING,
204     TOK_WORD,
205     TOK_XMATCH,
206     TOK_ZEROPAGE,
207     TOK_LASTPSEUDO      = TOK_ZEROPAGE,
208
209     TOK_COUNT           /* Count of tokens */
210 };
211
212
213
214 /* Scanner variables */
215 #define MAX_INPUT_FILES 254             /* No more than this files total */
216 #define MAX_STR_LEN     255             /* Maximum length of any string */
217 extern enum Token Tok;                  /* Current token */
218 extern int WS;                          /* Flag: Whitespace before token */
219 extern long IVal;                       /* Integer token attribute */
220 extern char SVal [MAX_STR_LEN+1];       /* String token attribute */
221
222 extern FilePos  CurPos;                 /* Name and position in file */
223 extern int      ForcedEnd;              /* Force end of assembly */
224
225
226
227 /*****************************************************************************/
228 /*                                   Code                                    */
229 /*****************************************************************************/
230
231
232
233 void NewInputFile (const char* Name);
234 /* Open a new input file */
235
236 void DoneInputFile (void);
237 /* Close the current input file */
238
239 void NewInputData (const char* Data, int Malloced);
240 /* Add a chunk of input data to the input stream */
241
242 void LocaseSVal (void);
243 /* Make SVal lower case */
244
245 void UpcaseSVal (void);
246 /* Make SVal upper case */
247
248 void NextRawTok (void);
249 /* Read the next raw token from the input stream */
250
251 int TokHasSVal (enum Token Tok);
252 /* Return true if the given token has an attached SVal */
253
254 int TokHasIVal (enum Token Tok);
255 /* Return true if the given token has an attached IVal */
256
257 int GetSubKey (const char** Keys, unsigned Count);
258 /* Search for a subkey in a table of keywords. The current token must be an
259  * identifier and all keys must be in upper case. The identifier will be
260  * uppercased in the process. The function returns the index of the keyword,
261  * or -1 if the keyword was not found.
262  */
263
264 void InitScanner (const char* InFile);
265 /* Initialize the scanner, open the given input file */
266
267 void DoneScanner (void);
268 /* Release scanner resources */
269
270
271
272 /* End of scanner.h */
273
274 #endif
275
276
277