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