]> git.sur5r.net Git - cc65/blob - src/ld65/scanner.h
Added command line response files
[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-2000 Ullrich von Bassewitz                                       */
10 /*               Wacholderweg 14                                             */
11 /*               D-70597 Stuttgart                                           */
12 /* EMail:        uz@musoftware.de                                            */
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,
51     CFGTOK_STRCON,
52     CFGTOK_IDENT,
53     CFGTOK_LCURLY,
54     CFGTOK_RCURLY,
55     CFGTOK_SEMI,
56     CFGTOK_COMMA,
57     CFGTOK_EQ,
58     CFGTOK_COLON,
59     CFGTOK_DOT,
60     CFGTOK_EOF,
61
62     /* Special identifiers */
63     CFGTOK_MEMORY,
64     CFGTOK_FILES,
65     CFGTOK_SEGMENTS,
66     CFGTOK_FORMATS,
67     CFGTOK_FEATURES,
68
69     CFGTOK_START,
70     CFGTOK_SIZE,
71     CFGTOK_TYPE,
72     CFGTOK_FILE,
73     CFGTOK_DEFINE,
74     CFGTOK_FILL,
75     CFGTOK_FILLVAL,
76     CFGTOK_EXPORT,
77     CFGTOK_IMPORT,
78     CFGTOK_OS,
79     CFGTOK_FORMAT,
80
81     CFGTOK_LOAD,
82     CFGTOK_RUN,
83     CFGTOK_ALIGN,
84     CFGTOK_OFFSET,
85
86     CFGTOK_RO,
87     CFGTOK_RW,
88     CFGTOK_BSS,
89     CFGTOK_ZP,
90     CFGTOK_WPROT,
91
92     CFGTOK_O65,
93     CFGTOK_BIN,
94
95     CFGTOK_SMALL,
96     CFGTOK_LARGE,
97
98     CFGTOK_TRUE,
99     CFGTOK_FALSE,
100
101     CFGTOK_LUNIX,
102     CFGTOK_OSA65,
103
104     CFGTOK_CONDES,
105     CFGTOK_SEGMENT,
106     CFGTOK_LABEL,
107     CFGTOK_COUNT,
108     CFGTOK_ORDER,
109
110     CFGTOK_CONSTRUCTOR,
111     CFGTOK_DESTRUCTOR,
112
113     CFGTOK_DECREASING,
114     CFGTOK_INCREASING
115
116 } cfgtok_t;
117
118
119
120 /* Mapping table entry, special identifier --> token */
121 typedef struct IdentTok_ IdentTok;
122 struct IdentTok_ {
123     const char* Ident;          /* Identifier */
124     cfgtok_t    Tok;            /* Token for identifier */
125 };
126 #define ENTRY_COUNT(s)  (sizeof (s) / sizeof (s [0]))
127
128
129
130 /* Current token and attributes */
131 #define CFG_MAX_IDENT_LEN  255
132 extern cfgtok_t         CfgTok;
133 extern char             CfgSVal [CFG_MAX_IDENT_LEN+1];
134 extern unsigned long    CfgIVal;
135
136 /* Error location */
137 extern unsigned         CfgErrorLine;
138 extern unsigned         CfgErrorCol;
139
140
141
142 /*****************************************************************************/
143 /*                                   Code                                    */
144 /*****************************************************************************/
145
146
147
148 void CfgWarning (const char* Format, ...) attribute((format(printf,1,2)));
149 /* Print a warning message adding file name and line number of the config file */
150
151 void CfgError (const char* Format, ...) attribute((format(printf,1,2)));
152 /* Print an error message adding file name and line number of the config file */
153
154 void CfgNextTok (void);
155 /* Read the next token from the input stream */
156
157 void CfgConsume (cfgtok_t T, const char* Msg);
158 /* Skip a token, print an error message if not found */
159
160 void CfgConsumeSemi (void);
161 /* Consume a semicolon */
162
163 void CfgConsumeColon (void);
164 /* Consume a colon */
165
166 void CfgOptionalComma (void);
167 /* Consume a comma if there is one */
168
169 void CfgOptionalAssign (void);
170 /* Consume an equal sign if there is one */
171
172 void CfgAssureInt (void);
173 /* Make sure the next token is an integer */
174
175 void CfgAssureStr (void);
176 /* Make sure the next token is a string constant */
177
178 void CfgAssureIdent (void);
179 /* Make sure the next token is an identifier */
180
181 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
182 /* Check the range of CfgIVal */
183
184 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
185 /* Map an identifier to one of the special tokens in the table */
186
187 void CfgBoolToken (void);
188 /* Map an identifier or integer to a boolean token */
189
190 void CfgSetName (const char* Name);
191 /* Set a name for a config file */
192
193 const char* CfgGetName (void);
194 /* Get the name of the config file */
195
196 void CfgSetBuf (const char* Buf);
197 /* Set a memory buffer for the config */
198
199 int CfgAvail (void);
200 /* Return true if we have a configuration available */
201
202 void CfgOpenInput (void);
203 /* Open the input file if we have one */
204
205 void CfgCloseInput (void);
206 /* Close the input file if we have one */
207
208
209
210 /* End of scanner.h */
211 #endif
212
213
214
215