1 /*****************************************************************************/
5 /* Configuration file scanner for the da65 disassembler */
9 /* (C) 2000 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
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 */
48 typedef enum token_t {
93 /* Mapping table entry, special identifier --> token */
94 typedef struct IdentTok_ IdentTok;
96 const char* Ident; /* Identifier */
97 token_t Tok; /* Token for identifier */
99 #define ENTRY_COUNT(s) (sizeof (s) / sizeof (s [0]))
103 /* Current token and attributes */
104 #define CFG_MAX_IDENT_LEN 255
105 extern unsigned CfgTok;
106 extern char CfgSVal [CFG_MAX_IDENT_LEN+1];
107 extern unsigned long CfgIVal;
110 extern unsigned CfgErrorLine;
111 extern unsigned CfgErrorCol;
115 /*****************************************************************************/
117 /*****************************************************************************/
121 void CfgWarning (const char* Format, ...);
122 /* Print a warning message adding file name and line number of the config file */
124 void CfgError (const char* Format, ...);
125 /* Print an error message adding file name and line number of the config file */
127 void CfgNextTok (void);
128 /* Read the next token from the input stream */
130 void CfgConsume (unsigned T, const char* Msg);
131 /* Skip a token, print an error message if not found */
133 void CfgConsumeLCurly (void);
134 /* Consume a left curly brace */
136 void CfgConsumeRCurly (void);
137 /* Consume a right curly brace */
139 void CfgConsumeSemi (void);
140 /* Consume a semicolon */
142 void CfgConsumeColon (void);
143 /* Consume a colon */
145 void CfgOptionalComma (void);
146 /* Consume a comma if there is one */
148 void CfgOptionalAssign (void);
149 /* Consume an equal sign if there is one */
151 void CfgAssureInt (void);
152 /* Make sure the next token is an integer */
154 void CfgAssureStr (void);
155 /* Make sure the next token is a string constant */
157 void CfgAssureIdent (void);
158 /* Make sure the next token is an identifier */
160 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
161 /* Check the range of CfgIVal */
163 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
164 /* Map an identifier to one of the special tokens in the table */
166 void CfgBoolToken (void);
167 /* Map an identifier or integer to a boolean token */
169 void CfgSetName (const char* Name);
170 /* Set a name for a config file */
172 const char* CfgGetName (void);
173 /* Get the name of the config file */
175 void CfgSetBuf (const char* Buf);
176 /* Set a memory buffer for the config */
179 /* Return true if we have a configuration available */
181 void CfgOpenInput (void);
182 /* Open the input file if we have one */
184 void CfgCloseInput (void);
185 /* Close the input file if we have one */
189 /* End of scanner.h */