1 /*****************************************************************************/
5 /* Source file line info structure */
9 /* (C) 1998-2003 Ullrich von Bassewitz */
10 /* Römerstrasse 52 */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
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. */
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: */
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 */
32 /*****************************************************************************/
48 /*****************************************************************************/
49 /* Token definitions */
50 /*****************************************************************************/
54 typedef enum token_t {
66 /* Tokens denoting types */
68 TOK_ENUM = TOK_FIRSTTYPE,
80 TOK_LASTTYPE = TOK_VOID,
82 /* Control statements */
103 /* Primary operators */
122 TOK_MUL = TOK_STAR, /* Alias */
173 /*****************************************************************************/
175 /*****************************************************************************/
180 typedef struct Token Token;
182 token_t Tok; /* The token itself */
183 long IVal; /* The integer attribute */
184 double FVal; /* The float attribute */
185 ident Ident; /* Identifier if IDENT */
186 LineInfo* LI; /* Source line where the token comes from */
187 type* Type; /* Type if integer or float constant */
190 extern Token CurTok; /* The current token */
191 extern Token NextTok; /* The next token */
195 /*****************************************************************************/
197 /*****************************************************************************/
201 void SymName (char* s);
202 /* Get symbol from input stream */
205 /* Get symbol from input stream or return 0 if not a symbol. */
207 void NextToken (void);
208 /* Get next token from input stream */
210 void SkipTokens (const token_t* TokenList, unsigned TokenCount);
211 /* Skip tokens until we reach TOK_CEOF or a token in the given token list.
212 * This routine is used for error recovery.
215 int Consume (token_t Token, const char* ErrorMsg);
216 /* Eat token if it is the next in the input stream, otherwise print an error
217 * message. Returns true if the token was found and false otherwise.
220 int ConsumeColon (void);
221 /* Check for a colon and skip it. */
223 int ConsumeSemi (void);
224 /* Check for a semicolon and skip it. */
226 int ConsumeComma (void);
227 /* Check for a comma and skip it. */
229 int ConsumeLParen (void);
230 /* Check for a left parenthesis and skip it */
232 int ConsumeRParen (void);
233 /* Check for a right parenthesis and skip it */
235 int ConsumeLBrack (void);
236 /* Check for a left bracket and skip it */
238 int ConsumeRBrack (void);
239 /* Check for a right bracket and skip it */
241 int ConsumeLCurly (void);
242 /* Check for a left curly brace and skip it */
244 int ConsumeRCurly (void);
245 /* Check for a right curly brace and skip it */
249 /* End of scanner.h */