]> git.sur5r.net Git - cc65/blob - src/sim65/scanner.h
support for .zeropage segment in GEOS
[cc65] / src / sim65 / scanner.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 scanner.h                                 */
4 /*                                                                           */
5 /*            Configuration file scanner for the sim65 6502 simulator        */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2002 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     /* Primary blocks */
63     CFGTOK_CHIPS,
64
65     /* Chips section */
66     CFGTOK_NAME,
67     CFGTOK_ADDR,
68     CFGTOK_RANGE,
69
70     /* Special identifiers */
71     CFGTOK_TRUE,
72     CFGTOK_FALSE
73
74 } cfgtok_t;
75
76
77
78 /* Mapping table entry, special identifier --> token */
79 typedef struct IdentTok IdentTok;
80 struct IdentTok {
81     const char* Ident;          /* Identifier */
82     cfgtok_t    Tok;            /* Token for identifier */
83 };
84 #define ENTRY_COUNT(s)  (sizeof (s) / sizeof (s [0]))
85
86
87
88 /* Current token and attributes */
89 #define CFG_MAX_IDENT_LEN  255
90 extern cfgtok_t         CfgTok;
91 extern char             CfgSVal [CFG_MAX_IDENT_LEN+1];
92 extern unsigned long    CfgIVal;
93
94 /* Error location */
95 extern unsigned         CfgErrorLine;
96 extern unsigned         CfgErrorCol;
97
98
99
100 /*****************************************************************************/
101 /*                                   Code                                    */
102 /*****************************************************************************/
103
104
105
106 void CfgWarning (const char* Format, ...) attribute((format(printf,1,2)));
107 /* Print a warning message adding file name and line number of the config file */
108
109 void CfgError (const char* Format, ...) attribute((format(printf,1,2)));
110 /* Print an error message adding file name and line number of the config file */
111
112 void CfgNextTok (void);
113 /* Read the next token from the input stream */
114
115 void CfgConsume (cfgtok_t T, const char* Msg);
116 /* Skip a token, print an error message if not found */
117
118 void CfgConsumeSemi (void);
119 /* Consume a semicolon */
120
121 void CfgConsumeColon (void);
122 /* Consume a colon */
123
124 void CfgOptionalComma (void);
125 /* Consume a comma if there is one */
126
127 void CfgOptionalAssign (void);
128 /* Consume an equal sign if there is one */
129
130 void CfgAssureInt (void);
131 /* Make sure the next token is an integer */
132
133 void CfgAssureStr (void);
134 /* Make sure the next token is a string constant */
135
136 void CfgAssureIdent (void);
137 /* Make sure the next token is an identifier */
138
139 void CfgRangeCheck (unsigned long Lo, unsigned long Hi);
140 /* Check the range of CfgIVal */
141
142 void CfgSpecialToken (const IdentTok* Table, unsigned Size, const char* Name);
143 /* Map an identifier to one of the special tokens in the table */
144
145 void CfgBoolToken (void);
146 /* Map an identifier or integer to a boolean token */
147
148 void CfgSetName (const char* Name);
149 /* Set a name for a config file */
150
151 const char* CfgGetName (void);
152 /* Get the name of the config file */
153
154 void CfgSetBuf (const char* Buf);
155 /* Set a memory buffer for the config */
156
157 int CfgAvail (void);
158 /* Return true if we have a configuration available */
159
160 void CfgOpenInput (void);
161 /* Open the input file if we have one */
162
163 void CfgCloseInput (void);
164 /* Close the input file if we have one */
165
166
167
168 /* End of scanner.h */
169 #endif
170
171
172