]> git.sur5r.net Git - cc65/blob - src/ld65/scanner.h
One more place where OutputNameUsed must be flagged.
[cc65] / src / ld65 / scanner.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 scanner.h                                 */
4 /*                                                                           */
5 /*              Configuration file scanner for the ld65 linker               */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2010 Ullrich von Bassewitz                                       */
10 /*               Roemerstrasse 52                                            */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
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.                                    */
18 /*                                                                           */
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:                            */
22 /*                                                                           */
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              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef SCANNER_H
37 #define SCANNER_H
38
39
40
41 #include "strbuf.h"
42
43
44
45 /*****************************************************************************/
46 /*                                   Data                                    */
47 /*****************************************************************************/
48
49
50
51 /* Config file tokens */
52 typedef enum {
53     CFGTOK_NONE,
54     CFGTOK_INTCON,              /* Integer constant */
55     CFGTOK_STRCON,              /* String constant */
56     CFGTOK_IDENT,               /* Identifier */
57     CFGTOK_PLUS,
58     CFGTOK_MINUS,
59     CFGTOK_MUL,
60     CFGTOK_DIV,
61     CFGTOK_LPAR,
62     CFGTOK_RPAR,
63     CFGTOK_LCURLY,
64     CFGTOK_RCURLY,
65     CFGTOK_SEMI,
66     CFGTOK_COMMA,
67     CFGTOK_EQ,
68     CFGTOK_COLON,
69     CFGTOK_DOT,
70     CFGTOK_EOF,
71
72     /* Special identifiers */
73     CFGTOK_MEMORY,
74     CFGTOK_FILES,
75     CFGTOK_SEGMENTS,
76     CFGTOK_FORMATS,
77     CFGTOK_FEATURES,
78     CFGTOK_SYMBOLS,
79
80     CFGTOK_START,
81     CFGTOK_SIZE,
82     CFGTOK_TYPE,
83     CFGTOK_FILE,
84     CFGTOK_DEFINE,
85     CFGTOK_FILL,
86     CFGTOK_FILLVAL,
87     CFGTOK_EXPORT,
88     CFGTOK_IMPORT,
89     CFGTOK_OS,
90     CFGTOK_ID,
91     CFGTOK_VERSION,
92     CFGTOK_FORMAT,
93
94     CFGTOK_LOAD,
95     CFGTOK_RUN,
96     CFGTOK_ALIGN,
97     CFGTOK_ALIGN_LOAD,
98     CFGTOK_OFFSET,
99     CFGTOK_OPTIONAL,
100
101     CFGTOK_RO,
102     CFGTOK_RW,
103     CFGTOK_BSS,
104     CFGTOK_ZP,
105
106     CFGTOK_O65,
107     CFGTOK_BIN,
108
109     CFGTOK_SMALL,
110     CFGTOK_LARGE,
111
112     CFGTOK_TRUE,
113     CFGTOK_FALSE,
114
115     CFGTOK_LUNIX,
116     CFGTOK_OSA65,
117     CFGTOK_CC65,
118     CFGTOK_OPENCBM,
119
120     CFGTOK_CONDES,
121     CFGTOK_STARTADDRESS,
122
123     CFGTOK_VALUE,
124     CFGTOK_WEAK,
125
126     CFGTOK_SEGMENT,
127     CFGTOK_LABEL,
128     CFGTOK_COUNT,
129     CFGTOK_ORDER,
130
131     CFGTOK_CONSTRUCTOR,
132     CFGTOK_DESTRUCTOR,
133     CFGTOK_INTERRUPTOR,
134
135     CFGTOK_DECREASING,
136     CFGTOK_INCREASING,
137
138     CFGTOK_DEFAULT
139
140 } cfgtok_t;
141
142
143
144 /* Mapping table entry, special identifier --> token */
145 typedef struct IdentTok IdentTok;
146 struct IdentTok {
147     const char* Ident;          /* Identifier */
148     cfgtok_t    Tok;            /* Token for identifier */
149 };
150 #define ENTRY_COUNT(s)  (sizeof (s) / sizeof (s [0]))
151
152
153
154 /* Current token and attributes */
155 extern cfgtok_t         CfgTok;
156 extern StrBuf           CfgSVal;
157 extern unsigned long    CfgIVal;
158
159 /* Error location */
160 extern unsigned         CfgErrorLine;
161 extern unsigned         CfgErrorCol;
162
163
164
165 /*****************************************************************************/
166 /*                                   Code                                    */
167 /*****************************************************************************/
168
169
170
171 void CfgWarning (const char* Format, ...) attribute((format(printf,1,2)));
172 /* Print a warning message adding file name and line number of the config file */
173
174 void CfgError (const char* Format, ...) attribute((format(printf,1,2)));
175 /* Print an error message adding file name and line number of the config file */
176
177 void CfgNextTok (void);
178 /* Read the next token from the input stream */
179
180 void CfgConsume (cfgtok_t T, const char* Msg);
181 /* Skip a token, print an error message if not found */
182
183 void CfgConsumeSemi (void);
184 /* Consume a semicolon */
185
186 void CfgConsumeColon (void);
187 /* Consume a colon */
188
189 void CfgOptionalComma (void);
190 /* Consume a comma if there is one */
191
192 void CfgOptionalAssign (void);
193 /* Consume an equal sign if there is one */
194
195 void CfgAssureInt (void);
196 /* Make sure the next token is an integer */
197
198 void CfgAssureStr (void);
199 /* Make sure the next token is a string constant */
200
201 void CfgAssureIdent (void);
202 /* Make sure the next token is an identifier */
203
204 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
205 /* Check the range of CfgIVal */
206
207 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
208 /* Map an identifier to one of the special tokens in the table */
209
210 void CfgBoolToken (void);
211 /* Map an identifier or integer to a boolean token */
212
213 void CfgSetName (const char* Name);
214 /* Set a name for a config file */
215
216 const char* CfgGetName (void);
217 /* Get the name of the config file */
218
219 void CfgSetBuf (const char* Buf);
220 /* Set a memory buffer for the config */
221
222 int CfgAvail (void);
223 /* Return true if we have a configuration available */
224
225 void CfgOpenInput (void);
226 /* Open the input file if we have one */
227
228 void CfgCloseInput (void);
229 /* Close the input file if we have one */
230
231
232
233 /* End of scanner.h */
234 #endif
235
236
237
238