1 /*****************************************************************************/
5 /* Configuration file scanner for the ld65 linker */
9 /* (C) 1998-2012, Ullrich von Bassewitz */
10 /* Roemerstrasse 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 /*****************************************************************************/
47 /*****************************************************************************/
49 /*****************************************************************************/
53 /* Config file tokens */
56 CFGTOK_INTCON, /* Integer constant */
57 CFGTOK_STRCON, /* String constant */
58 CFGTOK_IDENT, /* Identifier */
74 /* Special identifiers */
153 /* Mapping table entry, special identifier --> token */
154 typedef struct IdentTok IdentTok;
156 const char* Ident; /* Identifier */
157 cfgtok_t Tok; /* Token for identifier */
159 #define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
163 /* Current token and attributes */
164 extern cfgtok_t CfgTok;
165 extern StrBuf CfgSVal;
166 extern unsigned long CfgIVal;
168 /* Error location. PLEASE NOTE: I'm abusing the FilePos structure to some
169 * degree. It is used mostly to hold a file position, where the Name member
170 * is an index into the source file table of an object file. As used in config
171 * file processing, the Name member is a string pool index instead. This is
172 * distinguished by the object file pointer being NULL or not in the structs
173 * where this is relevant.
175 extern FilePos CfgErrorPos;
179 /*****************************************************************************/
181 /*****************************************************************************/
185 void CfgWarning (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3)));
186 /* Print a warning message adding file name and line number of the config file */
188 void CfgError (const FilePos* Pos, const char* Format, ...) attribute((format(printf,2,3)));
189 /* Print an error message adding file name and line number of a given file */
191 void CfgNextTok (void);
192 /* Read the next token from the input stream */
194 void CfgConsume (cfgtok_t T, const char* Msg);
195 /* Skip a token, print an error message if not found */
197 void CfgConsumeSemi (void);
198 /* Consume a semicolon */
200 void CfgConsumeColon (void);
201 /* Consume a colon */
203 void CfgOptionalComma (void);
204 /* Consume a comma if there is one */
206 void CfgOptionalAssign (void);
207 /* Consume an equal sign if there is one */
209 void CfgAssureInt (void);
210 /* Make sure the next token is an integer */
212 void CfgAssureStr (void);
213 /* Make sure the next token is a string constant */
215 void CfgAssureIdent (void);
216 /* Make sure the next token is an identifier */
218 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
219 /* Check the range of CfgIVal */
221 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
222 /* Map an identifier to one of the special tokens in the table */
224 void CfgBoolToken (void);
225 /* Map an identifier or integer to a boolean token */
227 void CfgSetName (const char* Name);
228 /* Set a name for a config file */
230 void CfgSetBuf (const char* Buf);
231 /* Set a memory buffer for the config */
234 /* Return true if we have a configuration available */
236 void CfgOpenInput (void);
237 /* Open the input file if we have one */
239 void CfgCloseInput (void);
240 /* Close the input file if we have one */
244 /* End of scanner.h */