]> git.sur5r.net Git - cc65/blob - src/da65/scanner.h
Fix codesize setting
[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     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 token_t {
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 tokens */
63     CFGTOK_GLOBAL,
64     CFGTOK_RANGE,
65     CFGTOK_LABEL,
66
67     /* Global section */
68     CFGTOK_INPUTNAME,
69     CFGTOK_OUTPUTNAME,
70     CFGTOK_PAGELENGTH,
71     CFGTOK_STARTADDR,
72
73     /* Range section */
74     CFGTOK_START,
75     CFGTOK_END,
76     CFGTOK_TYPE,
77
78     CFGTOK_CODE,
79     CFGTOK_BYTETAB,
80     CFGTOK_WORDTAB,
81     CFGTOK_DWORDTAB,
82     CFGTOK_ADDRTAB,
83     CFGTOK_RTSTAB,
84     CFGTOK_TEXTTAB,
85
86     /* Label section */
87     CFGTOK_NAME,
88     CFGTOK_ADDR,
89     CFGTOK_SIZE,
90
91     /* */
92     CFGTOK_TRUE,
93     CFGTOK_FALSE
94 } token_t;
95
96
97 /* Mapping table entry, special identifier --> token */
98 typedef struct IdentTok_ IdentTok;
99 struct IdentTok_ {
100     const char*         Ident;          /* Identifier */
101     token_t             Tok;            /* Token for identifier */
102 };
103 #define ENTRY_COUNT(s)  (sizeof (s) / sizeof (s [0]))
104
105
106
107 /* Current token and attributes */
108 #define CFG_MAX_IDENT_LEN  255
109 extern unsigned         CfgTok;
110 extern char             CfgSVal [CFG_MAX_IDENT_LEN+1];
111 extern long             CfgIVal;
112
113 /* Error location */
114 extern unsigned         CfgErrorLine;
115 extern unsigned         CfgErrorCol;
116
117
118
119 /*****************************************************************************/
120 /*                                   Code                                    */
121 /*****************************************************************************/
122
123
124
125 void CfgWarning (const char* Format, ...);
126 /* Print a warning message adding file name and line number of the config file */
127
128 void CfgError (const char* Format, ...);
129 /* Print an error message adding file name and line number of the config file */
130
131 void CfgNextTok (void);
132 /* Read the next token from the input stream */
133
134 void CfgConsume (unsigned T, const char* Msg);
135 /* Skip a token, print an error message if not found */
136
137 void CfgConsumeLCurly (void);
138 /* Consume a left curly brace */
139
140 void CfgConsumeRCurly (void);
141 /* Consume a right curly brace */
142
143 void CfgConsumeSemi (void);
144 /* Consume a semicolon */
145
146 void CfgConsumeColon (void);
147 /* Consume a colon */
148
149 void CfgOptionalComma (void);
150 /* Consume a comma if there is one */
151
152 void CfgOptionalAssign (void);
153 /* Consume an equal sign if there is one */
154
155 void CfgAssureInt (void);
156 /* Make sure the next token is an integer */
157
158 void CfgAssureStr (void);
159 /* Make sure the next token is a string constant */
160
161 void CfgAssureIdent (void);
162 /* Make sure the next token is an identifier */
163
164 void CfgRangeCheck (long Lo, long Hi);
165 /* Check the range of CfgIVal */
166
167 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
168 /* Map an identifier to one of the special tokens in the table */
169
170 void CfgBoolToken (void);
171 /* Map an identifier or integer to a boolean token */
172
173 void CfgSetName (const char* Name);
174 /* Set a name for a config file */
175
176 const char* CfgGetName (void);
177 /* Get the name of the config file */
178
179 void CfgSetBuf (const char* Buf);
180 /* Set a memory buffer for the config */
181
182 int CfgAvail (void);
183 /* Return true if we have a configuration available */
184
185 void CfgOpenInput (void);
186 /* Open the input file if we have one */
187
188 void CfgCloseInput (void);
189 /* Close the input file if we have one */
190
191
192
193 /* End of scanner.h */
194 #endif
195
196
197