1 /*****************************************************************************/
5 /* Configuration file scanner for the ld65 linker */
9 /* (C) 1998-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 /* Config file tokens */
50 CFGTOK_INTCON, /* Integer constant */
51 CFGTOK_STRCON, /* String constant */
52 CFGTOK_IDENT, /* Identifier */
68 /* Special identifiers */
140 /* Mapping table entry, special identifier --> token */
141 typedef struct IdentTok IdentTok;
143 const char* Ident; /* Identifier */
144 cfgtok_t Tok; /* Token for identifier */
146 #define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
150 /* Current token and attributes */
151 #define CFG_MAX_IDENT_LEN 255
152 extern cfgtok_t CfgTok;
153 extern char CfgSVal [CFG_MAX_IDENT_LEN+1];
154 extern unsigned long CfgIVal;
157 extern unsigned CfgErrorLine;
158 extern unsigned CfgErrorCol;
162 /*****************************************************************************/
164 /*****************************************************************************/
168 void CfgWarning (const char* Format, ...) attribute((format(printf,1,2)));
169 /* Print a warning message adding file name and line number of the config file */
171 void CfgError (const char* Format, ...) attribute((format(printf,1,2)));
172 /* Print an error message adding file name and line number of the config file */
174 void CfgNextTok (void);
175 /* Read the next token from the input stream */
177 void CfgConsume (cfgtok_t T, const char* Msg);
178 /* Skip a token, print an error message if not found */
180 void CfgConsumeSemi (void);
181 /* Consume a semicolon */
183 void CfgConsumeColon (void);
184 /* Consume a colon */
186 void CfgOptionalComma (void);
187 /* Consume a comma if there is one */
189 void CfgOptionalAssign (void);
190 /* Consume an equal sign if there is one */
192 void CfgAssureInt (void);
193 /* Make sure the next token is an integer */
195 void CfgAssureStr (void);
196 /* Make sure the next token is a string constant */
198 void CfgAssureIdent (void);
199 /* Make sure the next token is an identifier */
201 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
202 /* Check the range of CfgIVal */
204 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
205 /* Map an identifier to one of the special tokens in the table */
207 void CfgBoolToken (void);
208 /* Map an identifier or integer to a boolean token */
210 void CfgSetName (const char* Name);
211 /* Set a name for a config file */
213 const char* CfgGetName (void);
214 /* Get the name of the config file */
216 void CfgSetBuf (const char* Buf);
217 /* Set a memory buffer for the config */
220 /* Return true if we have a configuration available */
222 void CfgOpenInput (void);
223 /* Open the input file if we have one */
225 void CfgCloseInput (void);
226 /* Close the input file if we have one */
230 /* End of scanner.h */