1 /*****************************************************************************/
5 /* Configuration file scanner for the sim65 6502 simulator */
9 /* (C) 1998-2003 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 /*****************************************************************************/
46 /*****************************************************************************/
48 /*****************************************************************************/
52 /* Config file tokens */
76 /* Special identifiers */
84 /* Mapping table entry, special identifier --> token */
85 typedef struct IdentTok IdentTok;
87 const char* Ident; /* Identifier */
88 cfgtok_t Tok; /* Token for identifier */
90 #define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
94 /* Current token and attributes */
95 #define CFG_MAX_IDENT_LEN 255
96 extern cfgtok_t CfgTok;
97 extern char CfgSVal [CFG_MAX_IDENT_LEN+1];
98 extern unsigned long CfgIVal;
101 extern unsigned CfgErrorLine;
102 extern unsigned CfgErrorCol;
106 /*****************************************************************************/
108 /*****************************************************************************/
112 void CfgWarning (const char* Format, ...) attribute((format(printf,1,2)));
113 /* Print a warning message adding file name and line number of the config file */
115 void CfgError (const char* Format, ...) attribute((format(printf,1,2)));
116 /* Print an error message adding file name and line number of the config file */
118 void CfgNextTok (void);
119 /* Read the next token from the input stream */
121 void CfgConsume (cfgtok_t T, const char* Msg);
122 /* Skip a token, print an error message if not found */
124 void CfgConsumeSemi (void);
125 /* Consume a semicolon */
127 void CfgConsumeColon (void);
128 /* Consume a colon */
130 void CfgConsumeRCurly (void);
131 /* Consume a right curly brace */
133 void CfgOptionalComma (void);
134 /* Consume a comma if there is one */
136 void CfgOptionalAssign (void);
137 /* Consume an equal sign if there is one */
139 void CfgAssureInt (void);
140 /* Make sure the next token is an integer */
142 void CfgAssureStr (void);
143 /* Make sure the next token is a string constant */
145 void CfgAssureIdent (void);
146 /* Make sure the next token is an identifier */
148 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
149 /* Check the range of CfgIVal */
151 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
152 /* Map an identifier to one of the special tokens in the table */
154 void CfgBoolToken (void);
155 /* Map an identifier or integer to a boolean token */
157 void CfgSetName (const char* Name);
158 /* Set a name for a config file */
160 const char* CfgGetName (void);
161 /* Get the name of the config file */
163 void CfgSetBuf (const char* Buf);
164 /* Set a memory buffer for the config */
167 /* Return true if we have a configuration available */
169 void CfgOpenInput (void);
170 /* Open the input file if we have one */
172 void CfgCloseInput (void);
173 /* Close the input file if we have one */
177 /* End of scanner.h */