1 /*****************************************************************************/
5 /* Configuration file scanner for the da65 disassembler */
9 /* (C) 2000-2005 Ullrich von Bassewitz */
10 /* Römerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
41 /*****************************************************************************/
43 /*****************************************************************************/
47 /* Info file tokens */
48 typedef enum token_t {
102 INFOTOK_COMMENTSTART,
103 INFOTOK_IGNOREUNKNOWN,
111 /* Mapping table entry, special identifier --> token */
112 typedef struct IdentTok IdentTok;
114 const char* Ident; /* Identifier */
115 token_t Tok; /* Token for identifier */
117 #define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
121 /* Current token and attributes */
122 #define CFG_MAX_IDENT_LEN 255
123 extern unsigned InfoTok;
124 extern char InfoSVal[CFG_MAX_IDENT_LEN+1];
125 extern long InfoIVal;
128 extern unsigned InfoErrorLine;
129 extern unsigned InfoErrorCol;
133 /*****************************************************************************/
135 /*****************************************************************************/
139 void InfoWarning (const char* Format, ...);
140 /* Print a warning message adding file name and line number of the config file */
142 void InfoError (const char* Format, ...);
143 /* Print an error message adding file name and line number of the config file */
145 void InfoNextTok (void);
146 /* Read the next token from the input stream */
148 void InfoConsume (unsigned T, const char* Msg);
149 /* Skip a token, print an error message if not found */
151 void InfoConsumeLCurly (void);
152 /* Consume a left curly brace */
154 void InfoConsumeRCurly (void);
155 /* Consume a right curly brace */
157 void InfoConsumeSemi (void);
158 /* Consume a semicolon */
160 void InfoConsumeColon (void);
161 /* Consume a colon */
163 void InfoOptionalComma (void);
164 /* Consume a comma if there is one */
166 void InfoOptionalAssign (void);
167 /* Consume an equal sign if there is one */
169 void InfoAssureInt (void);
170 /* Make sure the next token is an integer */
172 void InfoAssureStr (void);
173 /* Make sure the next token is a string constant */
175 void InfoAssureChar (void);
176 /* Make sure the next token is a char constant */
178 void InfoAssureIdent (void);
179 /* Make sure the next token is an identifier */
181 void InfoRangeCheck (long Lo, long Hi);
182 /* Check the range of InfoIVal */
184 void InfoSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
185 /* Map an identifier to one of the special tokens in the table */
187 void InfoBoolToken (void);
188 /* Map an identifier or integer to a boolean token */
190 void InfoSetName (const char* Name);
191 /* Set a name for a config file */
193 const char* InfoGetName (void);
194 /* Get the name of the config file */
197 /* Return true if we have an info file given */
199 void InfoOpenInput (void);
200 /* Open the input file if we have one */
202 void InfoCloseInput (void);
203 /* Close the input file if we have one */
207 /* End of scanner.h */