]> git.sur5r.net Git - cc65/blob - src/da65/scanner.h
Started to add support for segments.
[cc65] / src / da65 / scanner.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 scanner.h                                 */
4 /*                                                                           */
5 /*           Configuration file scanner for the da65 disassembler            */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2000-2007 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 /*****************************************************************************/
42 /*                                   Data                                    */
43 /*****************************************************************************/
44
45
46
47 /* Info file tokens */
48 typedef enum token_t {
49     INFOTOK_NONE,
50     INFOTOK_INTCON,
51     INFOTOK_STRCON,
52     INFOTOK_CHARCON,
53     INFOTOK_IDENT,
54     INFOTOK_LCURLY,
55     INFOTOK_RCURLY,
56     INFOTOK_SEMI,
57     INFOTOK_COMMA,
58     INFOTOK_EQ,
59     INFOTOK_COLON,
60     INFOTOK_DOT,
61     INFOTOK_EOF,
62
63     /* Special tokens */
64     INFOTOK_GLOBAL,
65     INFOTOK_RANGE,
66     INFOTOK_LABEL,
67     INFOTOK_ASMINC,
68     INFOTOK_SEGMENT,
69
70     /* Global section */
71     INFOTOK_ARGUMENT_COLUMN,
72     INFOTOK_COMMENT_COLUMN,
73     INFOTOK_COMMENTS,
74     INFOTOK_CPU,
75     INFOTOK_HEXOFFS,
76     INFOTOK_INPUTNAME,
77     INFOTOK_INPUTOFFS,
78     INFOTOK_INPUTSIZE,
79     INFOTOK_LABELBREAK,
80     INFOTOK_MNEMONIC_COLUMN,
81     INFOTOK_OUTPUTNAME,
82     INFOTOK_PAGELENGTH,
83     INFOTOK_STARTADDR,
84     INFOTOK_TEXT_COLUMN,
85
86     /* Range section */
87     INFOTOK_START,
88     INFOTOK_END,
89     INFOTOK_TYPE,
90
91     INFOTOK_CODE,
92     INFOTOK_BYTETAB,
93     INFOTOK_DBYTETAB,
94     INFOTOK_WORDTAB,
95     INFOTOK_DWORDTAB,
96     INFOTOK_ADDRTAB,
97     INFOTOK_RTSTAB,
98     INFOTOK_TEXTTAB,
99     INFOTOK_SKIP,
100
101     /* Label section */
102     INFOTOK_NAME,
103     INFOTOK_COMMENT,
104     INFOTOK_ADDR,
105     INFOTOK_SIZE,
106
107     /* ASMINC section */
108     INFOTOK_FILE,
109     INFOTOK_COMMENTSTART,
110     INFOTOK_IGNOREUNKNOWN,
111
112     /* */
113     INFOTOK_TRUE,
114     INFOTOK_FALSE
115 } token_t;
116
117
118 /* Mapping table entry, special identifier --> token */
119 typedef struct IdentTok IdentTok;
120 struct IdentTok {
121     const char*         Ident;          /* Identifier */
122     token_t             Tok;            /* Token for identifier */
123 };
124 #define ENTRY_COUNT(s)  (sizeof (s) / sizeof (s [0]))
125
126
127
128 /* Current token and attributes */
129 #define CFG_MAX_IDENT_LEN  255
130 extern unsigned         InfoTok;
131 extern char             InfoSVal[CFG_MAX_IDENT_LEN+1];
132 extern long             InfoIVal;
133
134 /* Error location */
135 extern unsigned         InfoErrorLine;
136 extern unsigned         InfoErrorCol;
137
138
139
140 /*****************************************************************************/
141 /*                                   Code                                    */
142 /*****************************************************************************/
143
144
145
146 void InfoWarning (const char* Format, ...);
147 /* Print a warning message adding file name and line number of the config file */
148
149 void InfoError (const char* Format, ...);
150 /* Print an error message adding file name and line number of the config file */
151
152 void InfoNextTok (void);
153 /* Read the next token from the input stream */
154
155 void InfoConsume (unsigned T, const char* Msg);
156 /* Skip a token, print an error message if not found */
157
158 void InfoConsumeLCurly (void);
159 /* Consume a left curly brace */
160
161 void InfoConsumeRCurly (void);
162 /* Consume a right curly brace */
163
164 void InfoConsumeSemi (void);
165 /* Consume a semicolon */
166
167 void InfoConsumeColon (void);
168 /* Consume a colon */
169
170 void InfoOptionalComma (void);
171 /* Consume a comma if there is one */
172
173 void InfoOptionalAssign (void);
174 /* Consume an equal sign if there is one */
175
176 void InfoAssureInt (void);
177 /* Make sure the next token is an integer */
178
179 void InfoAssureStr (void);
180 /* Make sure the next token is a string constant */
181
182 void InfoAssureChar (void);
183 /* Make sure the next token is a char constant */
184
185 void InfoAssureIdent (void);
186 /* Make sure the next token is an identifier */
187
188 void InfoRangeCheck (long Lo, long Hi);
189 /* Check the range of InfoIVal */
190
191 void InfoSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
192 /* Map an identifier to one of the special tokens in the table */
193
194 void InfoBoolToken (void);
195 /* Map an identifier or integer to a boolean token */
196
197 void InfoSetName (const char* Name);
198 /* Set a name for a config file */
199
200 const char* InfoGetName (void);
201 /* Get the name of the config file */
202
203 int InfoAvail ();
204 /* Return true if we have an info file given */
205
206 void InfoOpenInput (void);
207 /* Open the input file if we have one */
208
209 void InfoCloseInput (void);
210 /* Close the input file if we have one */
211
212
213
214 /* End of scanner.h */
215 #endif
216
217
218