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